Home > Ask the AS/400 Experts > iSeries Application Development Questions & Answers > Passing parameters in an ILE RPG module
Ask The iSeries 400 Expert: Questions & Answers
EMAIL THIS

Passing parameters in an ILE RPG module

John Blenkinsop EXPERT RESPONSE FROM: John Blenkinsop

Pose a Question
Other iSeries 400 Categories
Meet all iSeries 400 Experts
Become an Expert for this site


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


>
QUESTION POSED ON: 08 February 2007
I have an ILE RPG module that needs to pass parameters to a ILE CL module and receive a return value. Prototyping the CL call as EXTPGM will not get us the return value and hence we need to use EXTPROC. How do we receive a value from the CL Module and use it in RPG Module? How should the call statement be written?

>
EXPERT RESPONSE
The CL module has a PGM statement that lists the variable names passed into and out of the module. All values passed in will also be passed out.

The RPGLE source must contain a procedure prototype naming the CL *MODULE object in the EXTPROC keyword. Note: The procedure name is in fact the *MODULE object name. No return value must be specified. The prototype parameters following the procedure name statement must be of the same type and size as the parameters in the CLLE module.

When defining parameters for RPGLE<-->CLLE procedure calls, try to avoid 1-byte lengths, for reasons which used to be valid but probably are not any more. I make a habit of defining return codes as seven characters, because I can then pass a meaningful value or a message ID. Also, avoid 1 and 2 byte integer and unsigned fields, 1-byte graphic and UCS-2, and 4-byte floating-point fields. You may have no problems with them, but if you do have problems it may be connected with field types.

Use NO keywords on the prototype parameter statements in the RPG. The parameters will be passed by address.

Example:

In CLLE (source member SAMPLE_2) :

             PGM        PARM(&RTCD &COMMAND)

             DCL        VAR(&RTCD)    TYPE(*CHAR) LEN(7)
             DCL        VAR(&COMMAND) TYPE(*CHAR) LEN(50) 

Use CRTCLMOD to create the *MODULE object. No special options need to be used.

In RPGLE :

      D Sample_2        PR                  ExtProc('SAMPLE_2')
      D  pRtcd                         7
      D  pCmd                         50 

In your C-specs use CALLP to call the CLLE module:

      C                   CallP     Sample_2(wkRTCD : Command)

If the CLLE module changes the values in the fields &RTCD or &COMMAND, those changed values will be reflected in the fields WKRTCD and Command in the RPGLE program.

NOTE: To compile the RPGLE object, you must either create it as a *MODULE object and then create a bound program from the two *MODULE objects, or else you can create the RPGLE as a *PGM object directly using CRTBNDRPG -- but only if you add the CLLE *MODULE object name to a binding directory and specify the following options on the CRTBNDRPG command:

DFTACTGRP(*NO) ACTGRP(*CALLER)
BNDDIR(your_binding_directory_name)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED CONTENT
iSeries Application Development
Monitoring escape messages and using RCVMSG for diagnostic messages
Listing contents of multiple FTP directories on AS/400
Chain operation error after converting RPG3 to ILE RPG (RPGIV)
Space offset X'0015FF00' or X'0000000000000000' is outside current limit for object QIGC2424C
Searching fields for values
Searching part of a name or address in AS/400
iSeries application display subfiles with other program windows
What's happening to my subfile?
What happening to my subfile?
Passing parameters in an ILE RPG module

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice

HomeNewsTopicsITKnowledge ExchangeTipsBlogsAsk the ExpertsMultimediaWhite PapersProducts
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 1999 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts