×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

CRTSRVPGM & CRTPGM Error

CRTSRVPGM & CRTPGM Error

CRTSRVPGM & CRTPGM Error

(OP)
I have just started using RPG to use *MODULE definitions of subprocedures for prototype parameter calls. I have successfully compiled modules ( CRTRPGMOD ) and used modules in a program ( CRTPGM ).

I have not been able to use the same modules via a service program for a call by reference.

The problem I get is when I try to CRTPGM using a service program that contans my modules.   I get the following compile errors:-

CODE


CRTRPGMOD MODULE(MyLib/TEST01M1)
          SRCFILE(MyLib/QRPGSRC)
          DBGVIEW(*LIST)
CRTRPGMOD MODULE(MyLib/TEST01M2)
          SRCFILE(MyLib/QRPGSRC)
          DBGVIEW(*LIST)
CRTRPGMOD MODULE(MyLib/TEST01M3)
          SRCFILE(MyLib/QRPGSRC)
          DBGVIEW(*LIST)

CRTSRVPGM SRVPGM(MyLib/TESTSRV1)
          MODULE(MyLib/TEST01M3
                 MyLib/TEST01M1
                 MyLib/TEST01M2)
                 EXPORT (*ALL)                     

CRTPGM PGM(MyLib/TEST01)
    MODULE(MyLib/TEST01M1 MyLib/TEST01M2)
    ENTMOD(TEST01M1)
    BNDSRVPGM (MyLib/TESTSRV1)

Definition supplied multiple times for symbol 'ADDNUMBERS'.
Definition supplied multiple times for symbol 'TEST01M1'.


AddNumbers is defined in TEST01M2.
TEST01M1 calls the TEST01M2 subprocedure ADDNUMBERS.

Any help would be appreciated.


TEST01M1

CODE

H DEBUG DATEDIT(*YMD)                                                  
D/COPY QRPGSRC,TEST01C1                                                
D W1Number1       S             13  3
D W1Number2       S             13  3
D W1String1       S             10      
D MyResult        S             13  3   
 /FREE                                                                 
  CALLP(E) AddNumbers(10:11:'          ');
  W1Number1 = 30;           
  W1Number2 = 40;           
  W1String1 = 'XXX';
  MyResult = AddNumbers(W1Number1:W1Number2:W1String1);
 /END-FREE          
C                   SETON        LR

TEST01M2

CODE

H NOMAIN                                     
H DEBUG DATEDIT(*YMD)                        
D/COPY QRPGSRC,TEST01C1                      
 *                                           
 * Prototype Boundry Start ------------------
 *                                           
P AddNumbers      B                   EXPORT
D                 PI            13  3        
D P1Number1                     13  3 VALUE  
D P1Number2                     13  3 VALUE  
D P1String1                     10    VALUE  
 *                                           
D M1Number1       S             13  3        
D M1Number2       S             13  3        
 /FREE                                       
       M1Number1 = P1Number1;                
       M1Number2 = P1Number2;                
       RETURN P1Number1 + P1Number2;         
 /END-FREE
*                                                           
P AddNumbers     E                      
*                                       
* Prototype Boundry End   --------------
*                                           

TEST01C1

CODE

  *                                           
  * Universal Prototype Definition            
 D AddNumbers      PR            13  3        
 D                               13  3 VALUE  
 D                               13  3 VALUE  
 D                               10    VALUE  


 

Dazed and confused.

Remember.. 'Depression is just anger without enthusiasum'.
 

RE: CRTSRVPGM & CRTPGM Error

What you need to do is define conditions in your copy members, so they are not copied in more than once:

CODE

      /IF NOT DEFINED (Your_Function_DONT_COPY)
      /DEFINE Your_Function_DONT_COPY           
     DYour_...                                      
     D Function        PR              N               
     D Parm1                         10A   Const       
     D Parm2                         10A   Const       
      /ENDIF    
   

Do this for each function in your copy members (with a separate definition for each).

-- Francis
I'd like to change the world, but I can't find the source code.

RE: CRTSRVPGM & CRTPGM Error

Skittle,
1/ Why don't you give the same name to source file (TEST01C1) and prototype (AddNumbers), it's confusing ?
   Give it the same name or store all the prototypes you need for your app in the same member then copy this member.

2/ Don't use QRPGLESRC to store your /COPY of Prototypes. Use QCOPYSRC or QCPYSRC if you prefer to be created if needed instead.

3/ Give names on your prototype def lines even if not required, it's better for future maintenance.

3/ The " PI " line is equivalent to the old *ENTRY PLIST" so you don't need the useless work fields M1Number1 and 2 in TEST01M2.

4/ If you include the modules in the service program, do not include them again in the user program and never use export(*ALL).

5/ Create a source file named QSRVSRC to be used for exported bind procedure :

CODE

CRTSRCPF Mylib/QSRVSRC TEXT('Bind Language ... ')

6/ Create a new "bind" member (source type "BND") named like the service program in the QSRVSRC source file that'll contain the names of exported procedures defined in the related service program

CODE

 /* ================================================== */     
 /* New exports MUST be added at the end.              */     
 /* Old exports MUST NEVER be removed from the list.   */     
 /* !!! The order MUST NEVER CHANGE !!!                */   
 /* !!! The signature MUST NEVER CHANGE and it         */
 /* should always be the name of the associated        */
 /* Service Program !!!                                */   
 /* ================================================== */     
 STRPGMEXP  PGMLVL(*CURRENT) LVLCHK(*YES) SIGNATURE('YourAppNameOrWhatever')   <-- Hint : never change the signature later !
 EXPORT SYMBOL(ADDNUMBERS)                                        
 ENDPGMEXP
- The subsequent exports if any must be added at the end and the exports order must never change.  ( swear here :) )
- A "BND" member is never compiled.                                                  

7/ Compile the service program like below and never use EXPORT (*ALL) ( swear again ! )

CODE

CRTSRVPGM SRVPGM(MyLib/TESTSRV1)
          MODULE(MyLib/TEST01M3
                 MyLib/TEST01M1
                 MyLib/TEST01M2)
          EXPORT(*SRCFILE)           
          SRCFILE(MyLib/QSRVSRC)     
8/ Create a Bind Directory using

CODE

CRTBNDDIR MyLib/MYBNDDIR TEXT(...)

9/ Add the service program into via ADDBNDDIRE or WRKBNDDIR.

CODE


ADDBNDDIRE BNDDIR(MYLIB/MYBNDDIR) OBJ((MYLIB/TESTSRV1 *SRVPGM))

10/ Add the BNDDIR name on H spec of user program TEST01

CODE

H BNDDIR('MYBNDDIR')

11/ Just compile as usual with opt 14 (PDM) or WDSc (you don't need CRTPGM here) and you're done.

                     


 

RE: CRTSRVPGM & CRTPGM Error

Hi,
you forgot to post the source from your 3rd module TEST01M3,
so I tried to cvreate the program only from 2 modules you posted.

You can create/link your main program from the modules so:

1. First create all modules:

CODE

Create modules:

CRTRPGMOD MODULE(mylib/TEST01M1)
          SRCFILE(IBPDSRC/QRPGLESRC)
          DBGVIEW(*SOURCE)

CRTRPGMOD MODULE(mylib/TEST01M2)
          SRCFILE(IBPDSRC/QRPGLESRC)
          DBGVIEW(*SOURCE)
                        

2. create/link the ILE program:

You can create the ILE program at 2 ways:
2a. ILE program from the modules (without service program):

CODE

CRTPGM PGM(mylib/TEST01)
       MODULE(mylib/TEST01M1 mylib/TEST01M2)
       ENTMOD(mylib/TEST01M1)                

2b. ILE program from the service program and the main module:
2b-1. create service program from the modules which contain procedures - in your case the procedure is in TEST01M2

CODE

CRTSRVPGM SRVPGM(mylib/TESTSRV1)
          MODULE(mylib/TEST01M2)
          EXPORT(*ALL) DETAIL(*BASIC)
2b-2. create the ILE program - link it from the main module
TEST01M1 and the service program

CODE

CRTPGM PGM(mylib/TEST01)
       MODULE(mylib/TEST01M1)
       BNDSRVPGM(mylib/TESTSRV1)


 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close