Calling RPGLE program from command line with parameters

125 pts.
Tags:
AS/400
RPGLE
How do I pass numeric data to CL program from AS/400 command line?
1

Answer Wiki

Thanks. We'll let you know when a new response is added.

To pass numeric data from a command line, it needs to be passed as follows:

CALL PGM(DEVHR/TEST2) PARM(‘abcd’ X’006F’)
It’s passed as hex value.

Discuss This Question: 3  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • harish1990

    the snippet is   DA                S              5             
      DB                S              3  0          
       *                                             
       /FREE                                         
          DSPLY A;                                   
          DSPLY B;                                   
          *INLR = *ON;                               
       /END-FREE                                     
      C     *INZSR        BEGSR                      
      C     *ENTRY        PLIST                      
      C                   PARM                    A  
      C                   PARM                    B  
      C                   ENDSR                      

    im calling this program from the command like

    CALL PGM(DEVHR/TEST2) PARM('abcd' 6)

    during debug A has 'ABCD' but B has 000...why this happening Some one please guide me on this..!!!!

    125 pointsBadges:
    report
  • NeilD

    Using your example of a numeric (3,0) field it should be represented as follows:

    CALL PGM(DEVHR/TEST2) PARM('abcd' X'006F')


    570 pointsBadges:
    report
  • TheRealRaven
    during debug A has 'ABCD' but B has 000...why this happening Some one please guide me on this..!!!!

    It's happening because you are using a CALL command on a command line, and you haven't declared any definitions for the two parameters. There is no way that the command line can know how you defined B in your program.

    You declared B in your program as a 3-digit packed-decimal field with zero decimal places. Yet you typed a single-digit "8" on the command line.

    Since the command line had no idea what you wanted, the "8" was stored in memory in the default numeric format. It was stored as a 15-digit packed-decimal field with 5 decimal positions. In that format, the first three positions are "000", and those are the only three positions that you defined in your program.

    You have three general alternatives:
    1. Declare B as a 15.5 field in your RPG program.
    2. Pass the parameter as a hex string, i.e., x'008F', so that it matches a 3.0 field in memory.
    3. Or declare the parameter for the command line. You would do that by creating a matching *CMD object.
    32,280 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: