On Wed, Oct 2, 2013 at 9:36 AM, Raupach, Robert E (CTO Architecture +
Engineering) <[email protected]> wrote:

> Greetings...
>
> A colleague asked me the following question:
>
>   "Is there a way to determine how many parameters are being passed into a
> COBOL program?"
>
> I could show him in Assembler, but in COBOL, I wouldn't have a clue.
>
>
The following is specific to z/OS COBOL only and assumes that an IBM
standard parm list is used.  In the future, if COBOL comes to support XP
linkage, the following will not work.  Until then it does because the last
parm will have the left most bit set, making it a negative number.

this also assumes that at least 1 parm is passed.

LINKAGE SECTION.

01  L-ADDR-1                 PIC S9(9) COMP-5.
01  L-ADDR-1-PTR REDEFINES L-ADDR-1 POINTER.

01  L-ADDR-2                 PIC S9(9) COMP-5.
01  L-ADDR-2-PTR REDEFINES L-ADDR-2 POINTER.

01  LINKAGE-PARMS-1          PIC X(64).

01  LINKAGE-PARMS-2          PIC S9(9) COMP-3.

PROCEDURE DIVISION USING BY VALUE L-ADDR-1 L-ADDR-2.

    SET ADDRESS OF LINKAGE-PARMS-1   TO L-ADDR-1-PTR
    MOVE LINKAGE-PARMS-1             TO CARP-PARM-AREA

    IF L-ADDR-1 > +0
      SET ADDRESS OF LINKAGE-PARMS-2 TO L-ADDR-2-PTR
      SET  WS-PARM-2-PRESENT         TO TRUE
    ELSE
      SET WS-PARM-2-ABSENT           TO TRUE
    END-IF

    IF WS-PARM-2-PRESENT
      MOVE LINKAGE-PARMS-2 TO WS-SVEFFDT
      MOVE 'Y'             TO WS-EFFDT
    ELSE
      MOVE LOW-VALUES TO WS-EFFDT
    END-IF


> Can someone advise?
> Thx,
> Bob R
>
> ************************************************************
> This communication, including attachments, is for the exclusive use of
> addressee and may contain proprietary, confidential and/or privileged
> information.  If you are not the intended recipient, any use, copying,
> disclosure, dissemination or distribution is strictly prohibited.  If you
> are not the intended recipient, please notify the sender immediately by
> return e-mail, delete this communication and destroy all copies.
> ************************************************************
>
>
> ----------------------------------------------------------------------
> For IBM-MAIN subscribe / signoff / archive access instructions,
> send email to [email protected] with the message: INFO IBM-MAIN
>

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to