Problem:
How can one determine how many parameters a COBOL program has been called with, for example "CALL 'A' USING A, B, C"?
On the mainframe it is possible to use an Assembler program to search the save area chain to find the previous save area and retrieve reg 1 from that save area. How can this be done in COBOL?
Resolution:
This can be acheived by using the routine CBL_GET_PROGRAM_INFO() to walk back up the call stack. This will determine how many parameters each program was called with.
See attached demo programs for an example of using this function. These programs need to be compiled using the Non-Mainframe dialect in Mainframe Express
'proga' calls 'progb' with two parameters. 'progb' calls 'progc' to do the stack walking.
cobol proga gnt;
cobol progb gnt;
cobol progc gnt;
run proga
Attachments:
#MFDS
#EnterpriseDeveloper

