Mark Garton wrote on 07/06/2007 10:16:47:
Below is how the C module is described/used in the
existing program.
DToBCD           PR
D                               18P 0
DFromBCD         PR
D                               10
D BCDPacked       S             18P 0 EXPORT
D BCDChar         S             10    EXPORT
C                   CALLP     ToBCD(BCDPacked)
Here is how the service program modules look:
 /Copy *LIBL/QCPYSRC,PCS_Format   (contains prototypes just as above)
D BCDPacked       s             18P 0 Export
D BCDChar         s             10    Export
This is my first attempt at creating a service program from scratch. How
should the variables BCDPacked and BCDChar be described?   The above 
works
when I have the one module but when I start adding other modules I get a
multiple definition error when I try to create service program.  So that
means that the variables are global when described as above?  Is there a
better way to do this?
I believe that putting the EXPORT keyword on the definition for BCDPacked 
and BCDChar means that those variables will be available to every module 
that is bound in to the *PGM object.   So, if you have those two variables 
defined in the second module you are adding, you will have the error you 
describe.  Unless you have a _really_ good reason to EXPORT standalone 
variables and fully understand why you want them exported, you should 
probably remove the EXPORT keyword from these D-specs
D BCDPacked       s             18P 0 Export
D BCDChar         s             10    Export
It is worth noting that the entry for EXPORT in the RPG documentation has 
this tip:
"The keywords IMPORT and EXPORT allow you to define a "hidden" interface 
between modules. As a result, use of these keywords should be limited only 
to those data items which are global throughout the application. It is 
also suggested that this global data be limited to things like global 
attributes which are set once and never modified elsewhere."
Hope this helps,
Adam
Attention:
The information contained in this message and or attachments is 
intended only for the person or entity to which it is addressed and may contain 
confidential and/or privileged material. Any review, retransmission, 
dissemination or other use of, or taking of any action in reliance upon, this 
information by persons or entities other than the intended recipient is 
prohibited. If you received this message in error, please contact the sender 
and 
delete the material from any system and destroy any copies. Thank you for your 
time and consideration.
Attention: 
Le contenu de ce message et(ou) les fichiers ci-joints s?adressent 
exclusivement à la personne ou -entité à laquelle ils sont destinés. Ils 
peuvent 
contenir de l?information confidentielle, protégée et(ou) classifiée. Il est 
strictement interdit à toute personne ou entité autre que le(la) destinataire 
prévu(e) de ce message d?examiner, de réviser, de retransmettre ou de diffuser 
cette information, de prendre une quelconque action en fonction ou sur la base 
de celle-ci, ou d?en faire tout autre usage. Si vous avez reçu ce message par 
erreur, veuillez communiquer avec l?expéditeur(trice), supprimer ce message et 
les fichiers ci-inclus de tout système, et en détruire toutes copies, qu?elles 
soient électroniques ou imprimées. Nous vous remercions de votre entière 
collaboration. 
As an Amazon Associate we earn from qualifying purchases.