Andy400
asked on
Passing Array as parameter in COBOL/400, is it possible?
Hi
I am new to COBOL/400 preogramming although know RPG,ILE RPG for 4 years.
Can anyone please guide me is it posible to passing Array as parameter in COBOL/400?
I have done it in ILE RPG but dn't know how it works in COBOL 400.
Please help, a code example will be of great help
Andy400
I am new to COBOL/400 preogramming although know RPG,ILE RPG for 4 years.
Can anyone please guide me is it posible to passing Array as parameter in COBOL/400?
I have done it in ILE RPG but dn't know how it works in COBOL 400.
Please help, a code example will be of great help
Andy400
ASKER
Hi tliotta,
Thanks for responce.
I am writting a cobol/400 program. TypeCBLLE.(OS/400-V5R3)
The program will be invoked from GUI screen developed using EGL technolgy. The call will be storeprocedue call; which has my COBOL/400 pgm as external object linked to store procedure.
All incomming parameters will be sent in Char format which my cobol/400 willl redefine as per requirements.
Basic issue is
1.Parameter which is passedTO COBOL/400 is in form of array (Dim 15). theses are 15 records in single parameter
2.It needs to be recevied as ARRAY.
I am not sure how to go about it , if any sample code is given it will be most helpfull.
Thanks for responce.
I am writting a cobol/400 program. TypeCBLLE.(OS/400-V5R3)
The program will be invoked from GUI screen developed using EGL technolgy. The call will be storeprocedue call; which has my COBOL/400 pgm as external object linked to store procedure.
All incomming parameters will be sent in Char format which my cobol/400 willl redefine as per requirements.
Basic issue is
1.Parameter which is passedTO COBOL/400 is in form of array (Dim 15). theses are 15 records in single parameter
2.It needs to be recevied as ARRAY.
I am not sure how to go about it , if any sample code is given it will be most helpfull.
Andy400:
Just to clarify for your use, you are compiling ILE COBOL which should be distinguished from COBOL/400. I'm not sure if COBOL/400 could do this and I'll have to do some research on how ILE COBOL would receive whatever kind(s) of structures that EGL might be attempting to pass. (Your source member type of [CBLLE] should cause the ILE COBOL compiler to be invoked.)
If EGL invokes program objects, then the physical mechanism of parameter passing will be "by reference". That means that the only thing in the actual argument list will be a pointer. Your compiled program would have a LINKAGE SECTION item declared and it would become based on what address was in the pointer.
You don't do any coding for the pointer. You simply place your data definition in the LINKAGE SECTION and reference the data element name in the PROCEDURE DIVISION USING ... statement. If you expect an array, then you code the data definition as an array. A likely structure would consist of an 01-level item that had the actual array definition on a lower-level item within it.
That would be what I would expect -- a single 01-level group item with the array defined at a lower level, a single argument address. I don't EGL available to check that out.
Unfortunately, I can't check out how EGL will structure the array in memory either.
Since (AFAIK) EGL has more COBOL in its heritage than other languages, I would expect that any array would be structured so that a COBOL definition should be fairly obvious.
I don't think there's much more I can say. I could make a guess or two about what some specific LINKAGE SECTION definitions would look like if I knew more about how the array is defined in EGL.
Also, because this is EGL instead of just one program calling another, I can't make the guaranteed assertion that EGL is making a "program call" rather than a "procedure call".
A procedure can have parameters passed "by reference" or "by value". If EGL can access procedures, then the COBOL _might_ expect arguments to arrive "by value". I figure that to be less likely enough to ignore it for now.
So, what exactly is the "problem"? Are you needing to learn how to code in COBOL? Are you choosing COBOL other than some other language for a reason? Do you have background in iSeries programming?
I see that this is i5/OS V5R3 (previously OS/400). You are aware that V5R3 is no longer supported by IBM, right? Can you determine if all relevant PTFs have been applied?
Tom
Just to clarify for your use, you are compiling ILE COBOL which should be distinguished from COBOL/400. I'm not sure if COBOL/400 could do this and I'll have to do some research on how ILE COBOL would receive whatever kind(s) of structures that EGL might be attempting to pass. (Your source member type of [CBLLE] should cause the ILE COBOL compiler to be invoked.)
If EGL invokes program objects, then the physical mechanism of parameter passing will be "by reference". That means that the only thing in the actual argument list will be a pointer. Your compiled program would have a LINKAGE SECTION item declared and it would become based on what address was in the pointer.
You don't do any coding for the pointer. You simply place your data definition in the LINKAGE SECTION and reference the data element name in the PROCEDURE DIVISION USING ... statement. If you expect an array, then you code the data definition as an array. A likely structure would consist of an 01-level item that had the actual array definition on a lower-level item within it.
That would be what I would expect -- a single 01-level group item with the array defined at a lower level, a single argument address. I don't EGL available to check that out.
Unfortunately, I can't check out how EGL will structure the array in memory either.
Since (AFAIK) EGL has more COBOL in its heritage than other languages, I would expect that any array would be structured so that a COBOL definition should be fairly obvious.
I don't think there's much more I can say. I could make a guess or two about what some specific LINKAGE SECTION definitions would look like if I knew more about how the array is defined in EGL.
Also, because this is EGL instead of just one program calling another, I can't make the guaranteed assertion that EGL is making a "program call" rather than a "procedure call".
A procedure can have parameters passed "by reference" or "by value". If EGL can access procedures, then the COBOL _might_ expect arguments to arrive "by value". I figure that to be less likely enough to ignore it for now.
So, what exactly is the "problem"? Are you needing to learn how to code in COBOL? Are you choosing COBOL other than some other language for a reason? Do you have background in iSeries programming?
I see that this is i5/OS V5R3 (previously OS/400). You are aware that V5R3 is no longer supported by IBM, right? Can you determine if all relevant PTFs have been applied?
Tom
ASKER
Tom,
Thanks for the response, apologies for late reply.
I do have coding exp in RPG/LE around 4 years, but I am very new in Cobol/400 coding.
Writing is COBOL is mandatory as current application is written in that way.
To make it short,
I am passing string in Char (Appx length 250) to COBOL (ILE) program. This program needs to receive it in array format, so that in the PROCEDURE DIVISION USING ..Statement it receives it that way.
I need some practical example which works. If a code sample is posted then it will be a great help.
Here you can assume that a char string as parameter is passed to Cobol program which is called from command line. If this works I can take care of EGL thing.
Thanks in advance.
Andy
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks a lot.
I would have accepted the entire parameter (PIC X(250) then parsed it within the program.
Of course it's possible. How it's done will depend on a little more info from you.
RPG passing to COBOL? COBOL/400 or ILE COBOL? (RPG/400 or ILE RPG?) COBOL program receiving the parm or COBOL module/procedure? And it shouldn't make a difference, but OS version/release?
Tom