Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CPD5D02

Status
Not open for further replies.

rpgpgmr01

Programmer
Oct 12, 2005
3
GB
Hello...please Help!

I'm new to ILE RPG and am getting msg

Message ID . . . . . . : CPD5D02
Date sent . . . . . . : 10/12/05 Time sent . . . . . . : 04:40:07

Message . . . . : Definition not found for symbol 'Mod2'.

When using the following command to bind the modules into program object PGMA:

CRTPGM PGM(PGMA) MODULE(MOD1 MOD2) ACTGRP(*CALLER)

The modules have been previously created by using PDM option 15.

I have a main procedure and two subprocedures in MOD2 and they both have the keyword EXPORT on the procedure begin statements.

The same error message is also given for the two subprocedures in MOD2.



 
rpgpgmr01,

Seeing the code would help. What did you put in the CRTPGM parm for ENTMOD? Is your LIBL correct?

MdnghtPgmr
 
Thanks for your reply.

Here's the code. It's taken from book ILE by Example by Mike Cravitz. (AS I said I'm new to ILE and am just trying to learn the basics).

MOD1:

D PrmInvoke S 2
D InvokeProc1 C 'P1'
D InvokeProc2 C 'P2'
D InvokeMod2 C 'M2'
C *Entry Plist
C Parm PrmInvoke
C Select
C When PrmInvoke = InvokeProc1
C CallB 'Proc1'
C When PrmInvoke = InvokeProc2
C CallB 'Proc2'
C When PrmInvoke = InvokeMod2
C CallB 'Mod2'
C Endsl
C Eval *inLR = *On


MOD2:

D Proc1 PR
D Proc2 PR
D DummyFld S 1
D Msg C 'You invoked the main procedure.'
C Msg Dsply DummyFld
C Eval *InLR = *On
P Proc1 B Export
D Msg C 'You invoked Proc1.'
C Msg Dsply DummyFld
P Proc1 E
P Proc2 B Export
D Msg C 'You invoked Proc2.'
C Msg Dsply DummyFld
P Proc2 E


Have tyied the following command as well:

CRTPGM PGM(PGMA)
MODULE(*CURLIB/MOD1 *CURLIB/MOD2)
ENTMOD(*CURLIB/MOD1)
ACTGRP(*CALLER)

MOD1 and MOD2 are in my current library.
 
Hi,

I've just changed all references to procedure names to UPPERCASE and it's worked!

I wonder why that should make a difference?

But the source of the example in my book was as per the source I've posted earlier.
 
rpgpgrm01,

Okay, first off, don't confuse modules and procedures. A module may contain one or more procedures. Procedures can be called, modules may not. So in your case you have a module, MOD2, which contains two procedures, Proc1 and Proc2.

The other thing that jumps out at me is the lack of header specs. Did you omit them? If not the MOD2 needs the NOMAIN header spec.

In MOD1 you need to put in the prototypes for Proc1 and Proc2. Most people use a seperate source member and place all the prototype in that member then use the \COPY compiler directive to bring them in.

I know this is a lot to take in! I'm just learning most of this stuff myself. I will post a VERY simple sample.


Okay first are the header specs I bring in with the /COPY. Source member HEADER.
Code:
H DEBUG OPTION( *SRCSTMT : *NODEBUGIO ) DATFMT(*USA/) 
 H BNDDIR( 'BIND.DIR' )                                
  /If Defined( *CRTBNDRPG )                            
 H DFTACTGRP ( *NO ) ACTGRP( *CALLER )                 
  /EndIf

Nextt the prototypes. Source member PROTOTYPE.
Code:
*--------------------------------------------------------------------- 
 * MsgBox - Answer = MsgBox( PromptStr )                                
 *--------------------------------------------------------------------- 
                                                                        
D MsgBox          PR             1A   
D  PromptStr                  1024A   OPTIONS( *VARSIZE ) CONST         
                                                                        
                                                                        
 *--------------------------------------------------------------------- 
 * GetMethod - INTERNAL                                                 
 *--------------------------------------------------------------------- 
                                                                        
D GetMethod       PR             1A                     
D  PolicyNumber                  6S 0 CONST                             
                                                                        
                                                                        
 *--------------------------------------------------------------------- 
 * ActMethod - If ActMethod ...                                         
 *--------------------------------------------------------------------- 
                                                                        
D ActMethod       PR             1N                         
D  PolicyNumber                  6S 0 CONST                             


*--------------------------------------------------------------------- 
 * PutMethod - If PutMethod( PolicyNumber : Method )...                 
 *--------------------------------------------------------------------- 
                                                                        
D PutMethod       PR             1N                                     
D  PolicyNumber                  6S 0 CONST                             
D  Mehtod                        1A   CONST

And then the procedures. I did mine as separate source members and separate modules but that is not needed. I think most people keep them in one source member.

Code:
H DEBUG OPTION( *SRCSTMT : *NODEBUGIO ) DATFMT(*USA/)           
 HNOMAIN                                                         
                                                                 
 FMBD010    CF   E             WORKSTN USROPN                    
                                                                 
  /COPY YOURLIB/QRPGLESRC,PROTOTYPE                             
                                                                 
                                                                 
 P MsgBox          B                   EXPORT                    
                                                                 
 D MsgBox          PI             1A                      
 D  PromptStr                  1024A   OPTIONS( *VARSIZE ) CONST 
                                                                 
 D ItsVar          S             10                              
                                                                 
  /FREE                                                          
                                                                 
   Open MBD010;                                                  
   Write MBD010C;                                                
                                                                 
   Message = PromptStr;                                          
   Clear YesOrNo;                                                
                                                                 
   DoU YesOrNo = 'Y' Or YesOrNo = 'N' Or *IN03 = *ON;            
      ExFmt MBD010D; 
  EndDo;             
                     
  Close MBD010;      
  Return YesOrNo;    
  *INLR = *ON;       
                     
 /END-FREE           
                     
P MsgBox          E

The following is just the DDS for the display file used above.

Code:
      A                                      DSPSIZ(24 80 *DS3) 
      A                                      REF(*LIBL/AILDATA) 
      A                                      PRINT              
      A                                      CA01(03 'EXIT')    
      A                                      CA02(12 'CANCEL')  
      A                                      HELP(29)           
     A          R MBD010C                                                        
     A                                      WINDOW(*DFT 15 45)                   
     A                                      OVERLAY                              
     A                                      WDWBORDER((*DSPATR RI))              
     A                                 13  1'F2=Cancel'                          
     A            MESSAGE       40A  O 14  2DSPATR(RI)                           
     A N30                                  DSPATR(ND)                           
     A          R MBD010D                                                        
     A                                      WINDOW(MBD010C)                      
     A                                  4  1'Enter (Y/N) In Response To The Que- 
     A                                      stion Below'                         
     A                                      COLOR(BLU)                           
     A            MESSAGE       40A  O  8  4                                     
     A            YESORNO        1A  B 11 23                                     
     A          R DUMMY                     ASSUME KEEP                          
     A                                  1  2' '                                  
      *                                                                          
      *  MESSAGE SUBFILE PANEL                                                   
      *                                                                          
     A          R MSGSFL                    SFL                                  
     A                                      SFLMSGRCD(24)                        
     A            MSGKEY                    SFLMSGKEY                            
     A            WQPGMN                    SFLPGMQ        
      *                                                    
      * MESSAGE SUBFILE CONTROL PANEL                      
      *                                                    
     A          R MSGCTL                    SFLCTL(MSGSFL) 
     A                                      OVERLAY        
     A        80                            SFLDSP         
     A        80                            SFLDSPCTL      
     A        80                            SFLINZ         
     A        80                            SFLEND         
     A                                      SFLSIZ(0005)   
     A                                      SFLPAG(0001)   
     A            WQPGMN                    SFLPGMQ

And the next procedure.

Code:
H DEBUG OPTION( *SRCSTMT : *NODEBUGIO ) DATFMT(*USA/) 
 HNOMAIN                                               
                                                       
 FANNMSTR   IF   E           K DISK    USROPN          
                                                       
  /COPY YOURLIB/QRPGLESRC,PROTOTYPE                   
                                                       
                                                       
 P GetMethod       B                   EXPORT          
                                                       
 D GetMethod       PI             1A            
 D  PolicyNumber                  6S 0 CONST           
                                                       
 D Method          S              1                    
                                                       
  /FREE                                                
                                                       
   Open ANNMSTR;                                       
   Chain PolicyNumber ANNMSTR;                         
   If NOT( %FOUND( ANNMSTR ) );                        
      Method = *BLANKS;                                
   Else;                                               
      Method = FXMETH;                                 
   EndIf;                                              
   Close ANNMSTR;        
   Return Method;        
   *INLR = *ON;          
                         
  /END-FREE              
                         
 P GetMethod       E

And yet another procedure.

Code:
H DEBUG OPTION( *SRCSTMT : *NODEBUGIO ) DATFMT(*USA/)  
 HNOMAIN                                                
                                                        
 FMETHOD    IF   E           K DISK    USROPN           
                                                        
  /COPY YOURLIB/QRPGLESRC,PROTOTYPE                    
                                                        
                                                        
 P ActMethod       B                   EXPORT           
                                                        
 D ActMethod       PI             1N   OPDESC           
 D  PolicyNumber                  6S 0 CONST            
                                                        
 D MethodCode      S              1A                    
 D Active          S              1N                    
                                                        
  /FREE                                                 
                                                        
   MethodCode = GetMethod( PolicyNumber );              
   Open METHOD;                                         
   Chain MethodCode METHOD;                             
   If NOT( %FOUND( METHOD ) );                          
      Active = *OFF;                                    
   ElseIf MEPLCD = 'A';                                 
      Active = *ON;    
   EndIf;              
   Close METHOD;       
   Return Active;      
   *INLR = *ON;        
                       
  /END-FREE            
                       
 P ActMethod       E

And now a program to bring them all together. Keep in mind that before compiling the following program I bound all the procedures into a service program and placed the service program into a binding directory. See the HEADER spec.

Code:
  /COPY YOURLIB/QRPGLESRC,HEADER                                        
                                                                      
  /COPY YOURLIB/QRPGLESRC,PROTOTYPE                                  
                                                                      
                                                                      
                                                                      
 D PolicyNumber    S              6  0                                
 D PolicyAlpha     S              6                                   
 D TextMessage     S             80                                   
 D Answer          S              1                                   
                                                                      
                                                                      
 C     *ENTRY        PList                                            
 C                   Parm                    PolicyAlpha              
                                                                      
                                                                      
  /FREE                                                               
                                                                      
   PolicyNumber = %INT( PolicyAlpha );                                
                                                                      
   If ActMethod( PolicyNumber );                                      
      TextMessage = %TRIM( PolicyAlpha ) + ' Is An Active Policy.';   
   Else;                                                              
      TextMessage = %TRIM( PolicyAlpha ) + ' Is An Inactive Policy.';
   EndIf;                          
                                   
   Answer = MsgBox( TextMessage ); 
                                   
   *INLR = *ON;                    
                                   
  /END-FREE


And there you have it. Simple stuff I know but it’s how I got started. And I know, it’s in free format and your code was fixed. It should be fairly easy to convert. ;-)

Anyway, I hope that helps get you started in the right direction. Sorry for the length of the post…
MdnghtPgmr

 
Okay, now I'm confused. Is this due to the difference between bind by copy and bind by referance? How can MOD1 not have any PR specs? And I thought CALLB had to be changed to CALLP.? Or is the call thing just because of free format? I'm beginning to think I've forgotten more then I ever knew :-( Does anyone have the answers to these burning questions?
 
rpgpgmr1,

As you discovered, the name in the CALL command IS case-sensitive.
 
Most objects on the AS/400 (except in the IFS) have uppercase names. There are some C runtime routines and some special APIs that have mixed case (which is why the EXTNAME keyword requires a quoted string), but anything in the QSYS.LIB (normal OS/400 programs and DB2/400 files) or QDLS (used for OfficeVision, which is no longer supported) file systems are uppercase only.

Me transmitte sursum, Caledoni!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top