passing array as parameter

0 pts.
Tags:
RPG
Hi all How can we pass a character array as parameter from one RPG program to another ? Regards Skapoor
ASKED: July 5, 2005  9:28 AM
UPDATED: October 28, 2009  3:33 AM

Answer Wiki

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

Good morning,
Depends on the size of the array.
There are number of techniques from passing the array as a data structure to storing the array in a user space, to not using the indicator LR in the called module which will allow access to the array.

You can also try Google for snippets of code.

From the IBM Manuals

Passing parameters
In an OPM or ILE call, a parameter is an expression that represents a value that the calling application passes to the API specified in the call. HLL languages use the following methods for passing parameters:

By value, directly
The value of the data object is placed directly into the parameter list.

By value, indirectly
The value of the data object is copied to a temporary location. The address of the copy (a pointer) is placed into the parameter list. By value, indirectly is not done explicitly by the application programmer. It is done by the operating system at run time.

By reference
A pointer to the data object is placed into the parameter list. Changes made by the called API to the parameter are reflected in the calling application.

When you call an API, the protocol for passing parameters is to typically pass a space pointer that points to the information being passed. (This is also referred to as pass-by-reference.) This is the convention used by the control language (CL), RPG, and COBOL compilers. Care must be used in those languages that support pass-by-value (such as ILE C) to ensure that these conventions are followed. Refer to the appropriate language documentation for instructions. The parameter passing convention of pass-by-reference can be used in all programming languages. Some of the UNIX(R)-type APIs require pass-by-value parameter passing. VisualAge(R) C++ for OS/400(R) also supports pass-by-value parameter passing.

HLL semantics usually determine when data is passed by value and when it is passed by reference. For example, ILE C passes and accepts parameters by value, directly, while for OPM and ILE COBOL and OPM and ILE RPG parameters are usually passed by reference. You must ensure that the calling program or procedure passes parameters in the manner expected by the called API. The OPM or ILE HLL programmer’s guides contain more information on passing parameters to different languages.

The ILE languages support the following parameter-passing styles:

ILE C passes and accepts parameters by value (directly and indirectly) and by reference.
ILE COBOL supports the passing of parameters by value (indirectly) and by reference.
ILE RPG supports the passing of parameters by value (directly and indirectly) and by reference.
ILE CL supports the passing of parameters by reference.

Discuss This Question: 4  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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • Jmthirion
    Hi, What I do in these cases is passing it thru alpha parm(s) using MOVEA to transfer the array into a single field and recovering data movin back that data from the entry paramater to the new array. Naturaly if your array is more than 256 characters you will have tu use a few fields of 256 car. As simple as that Hope this help Jean-Marc.
    0 pointsBadges:
    report
  • JonP
    You simply do it! Unless I am completely misunderstanding the question you pass an array by simply using the name of the array as the parm. Like so: D Test s 10a Dim(20) C Call 'XYZ' C Parm Test It works the same way for a CallP i.e. D XYZ pr ExtPgm('XYZ') D Array 10a Dim(20) C CallP XYZ( Test ) // or in /Free form XYZ( Test ); What aspect are you having trouble with?
    0 pointsBadges:
    report
  • JackMcCoach
    I use an overlay: ***** calling program **** C CALL 'WORK' C PARM ORR21 10000 ***** called program **** C *entry plist C parm ORRARR DORRARR DS D ORR100 10000A D ORR 20A overlay(ORR100)dim(500)
    0 pointsBadges:
    report
  • TomLiotta
    The primary answer is inappropriate if the question is specifically about one RPG program calling another. It is misleading in describing passing by value, either directly or indirectly. Program to program calls do not allow 'by value'. It will always be 'by reference' or by passing the address of the parm. In short, as noted by JonP, you just do it. Make sure both programs use the same definition. Tom
    125,585 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.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

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

Following