Is there a way to create a COBOL sub-program (procedural) that accepts a variable number of arguments similar to the "C" va_start or "Java" ... or "C#" params keyword.
I believe that PARAMS can only be specified in the procedure division header of a method and not in a procedural program but I am awaiting confirmation on this.
The parameter array must be that of a managed type so to pass in a variable number of pic x fields you would receive this as an array of strings.
working-storage section. 01 param1 pic x value "1". 01 param2 pic x value "2". 01 param3 pic x value "3". procedure division. declare myobj = new MyClass invoke myobj::mymethod(param1, param2, param3) ... class-id MyClass. method-id mymethod. procedure division using params data-fld-nms as string occurs any. perform varying s1 as string thru data-fld-nms display s1 end-perform
This is managed JVM code.
You can use PARAMS in the procedure division header of a procedural COBOL program but the parameters in the calling program must be passed by value.
working-storage section. 01 param1 pic x value "1". 01 param2 pic x value "2". 01 param3 pic x value "3". procedure division. call "prog2" using by value param1, param2 param3 ... program-id. prog2. procedure division using params myparams as string occurs any. perform varying s1 as string thru myparams display s1 end-perform