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