passing data from sysin jcl to PL/I program

I need to pass data from SYSIN JCL to PL/I program. Below is my code from JCL and PL/I program and values are not being passed. Can anyone help please?

//SYSIN DD *
12345

PROG: PROC(INPARM) OPTIONS(MAIN REENTRANT) REORDER;
DCL INPARM            CHAR(5) VARYING;

PUT SKIP LIST('INPARAM - '|| INPARM);

Upvotes: 1

Views: 724

Answers (1)

phunsoft
phunsoft

Reputation: 2735

The PL/1 code you show does not read any file, it only consumes the PARM data. I assume by mainframe you mean IBM z/OS? On z/OS, PARM data is passed via EXEC PGM=xyz,PARM=, and this data can be up to 100 characters. So, redefine the INPARM variable as CHAR(100) VARYING.

SYSIN as shown is a data set definition; the program needs to define, open, and read a data set with ddname (file name) SYSIN. You also need to define an end-of-data flag, and define an ON condition that is triggered when all data from SYSIN has been read.

Here is some code snippet:

DCL SYSIN FILE EXTERNAL RECORD INPUT ENVIRONMENT(FB RECSIZE(80));
DCL INPUT_RECORD CHAR(80);
DCL EOF_SYSIN BIT(1) INIT('0'B);

ON ENDFILE(SYSIN) BEGIN;
    EOF_SYSIN = '1'B;
    END;

OPEN FILE(SYSIN);

DO WHILE (¬EOF);
    ... process the record just read ...
    READ FILE(SYSIN) INTO(INPUT_RECORD);
    END;

CLOSE FILE(SYSIN);

Upvotes: 5

Related Questions