code

Name
Astradyne (UK) Ltd
Scriptlanguage
Plain Text
Tabwidth
0
Date
Tue, 24 Apr 2007 11:33:02 +0100
IP
192.168.0.33

In an RPG400 program you can call a program without passing the expected number of parameters by using the *PSDS (program status data structure) in the called program and using it to determine which parameters (if any) were passed. The trick is to only refer to the parameter variable if it was passed otherwise you will get a pointer/resolve error. To do this, define work variables that will be populated with the parameter values by your program and refer to these in the rest of your code.

  1.     I* Program Status Data Structure                                           
  2.     I          SDS                                                           
  3.     I                                      37  390@PARMS                     
  4.     ***************************************************************************
  5.     C          *ENTRY    PLIST                                               
  6.     C                    PARM          P1COMP  3                             
  7.     C                    PARM          P1DIV  3                             
  8.     C                    PARM          P1ACCT 10                             
  9.     C*                                                                         
  10.     C* Check which parameters were passed...                                   
  11.     C                    MOVE *BLANKS  WKCOMP  3                             
  12.     C                    MOVE *BLANKS  WKDUV  3                             
  13.     C                    MOVE *BLANKS  WKACCT  3                             
  14.     C*                                                                         
  15.     C          @PARMS    IFGE 1                                               
  16.     C                    MOVE P1COMP    WKCOMP                               
  17.     C                    ENDIF                                               
  18.     C*                                                                         
  19.     C          @PARMS    IFGE 2                                               
  20.     C                    MOVE P1DIV    WKDIV
  21.     C                    ENDIF               
  22.     C*                                       
  23.     C          @PARMS    IFGE 3             
  24.     C                    MOVE P1ACCT    WKACCT
  25.     C                    ENDIF               
  26.     C*