How to print dataset content using Rexx - rexx

I'm trying to print the data (line by line) found in the IO.ME.DATA dataset (see my jcl).
I get the following error and looking to get the syntax right:
10 +++ DO I = 1 TO SYSTSIN.0
Error running MYREXX, line 10: Bad arithmetic conversion
I'm new to REXX. Thanks
JCL
//JCL01 JOB 000,'TEST REXX',
// CLASS=T,
// MSGCLASS=X,
// USER=ME
/*JOBPARM R=999,T=999,L=9999,S=ANY
//*
//STEPREXX EXEC PGM=IKJEFT01,PARM='MYREXX'
//SYSEXEC DD DISP=SHR,DSN=IO.ME.REXX
//SYSTSPRT DD SYSOUT=*
//SYSTSIN DD DISP=SHR,DSN=IO.ME.DATA
//
MYREXX (IO.ME.REXX)
SAY 'START OF REXX CODE.'
"EXECIO * DISKR SYSTSIN (STEM LINE. FINIS"
DO I = 1 TO SYSTSIN.0
SAY "VALUE OF I : " SYSTSIN.I
END
SAY 'END OF REXX CODE.'
DATA (from IO.ME.DATA)
MYDATA1,A
MYDATA2,B
MYDATA3,C
MYDATA4,D
MYDATA5,E

Try changing the do loop to
DO I = 1 TO Line.0
SAY "VALUE OF I : " Line.I
END
the command
"EXECIO * DISKR SYSTSIN (STEM LINE. FINIS"
says read the file SYSTSIN in to the stem variable Line. The number of lines read will be placed into line.0, line.1 will hold the first line in the file etc.

In addition to what #Bruce Martin wrote, don't point SYSTSIN to your input data. Use a different DD. IKJEFT01 uses SYSTSIN for its own purposes. Even if it works in this particular case, it's a bad habit to use DDNAMES that are known to be used for other purposes for your own.
//JCL01 JOB 000,'TEST REXX',
// CLASS=T,
// MSGCLASS=X,
// USER=ME
/*JOBPARM R=999,T=999,L=9999,S=ANY
//*
//STEPREXX EXEC PGM=IKJEFT01,PARM='MYREXX'
//SYSEXEC DD DISP=SHR,DSN=IO.ME.REXX
//SYSTSPRT DD SYSOUT=*
//SYSTSIN DD DUMMY
//MYDATA DD DISP=SHR,DSN=IO.ME.DATA
//*
This wasn't going to fit in a comment, but I felt it important to point out.

Related

Steps involved to execute a COBOL program static calling a COBOL/DB2 subprogram

I have a main program which is purely COBOL, and a COBOL-DB2 subprogram. I compiled both using a cobol-db2 compiler, return code is 4 (informational warning only). Then, I bind them both. Now I'm trying to execute the main program using a JCL DB2, however, it doesn't seem to be able to call the subprogram or even execute the run step.
This is my JCL DB2 to run the mainprog calling the subprog:
//GO EXEC PGM=IKJEFT01,DYNAMNBR=20,REGION=4M,COND=(4,LT)
//STEPLIB DD DSN=DSN910.DB9G.RUNLIB.LOAD,
// DISP=SHR
// DD DISP=SHR,DSN=DSN910.DB9G.SDSNEXIT
// DD DISP=SHR,DSN=DSN910.SDSNLOAD
// DD DISP=SHR,DSN=ISP.SISPLOAD
// DD DISP=SHR,DSN=GDDM.SADMMOD
//SYSOUT DD SYSOUT=*
//SYUDUMP DD SYSOUT=*
//CEEDUMP DD SYSOUT=*
//TRANFILE DD DSN=PROJECT.ABC.TRANKSDS,DISP=SHR
//MGMTREPT DD DSN=PROJECT.ABC.MGMTREPT,
// UNIT=SYSDA,DISP=(NEW,CATLG),
// SPACE=(32,(3,3)),
// DCB=(RECFM=FB,LRECL=81,BLKSIZE=81)
//SYSPRINT DD SYSOUT=*
//SYSTSPRT DD SYSOUT=*
//SYSTSIN DD *
DSN SYSTEM(DB9G)
RUN PROGRAM(ABCREPRT) PLAN(DSNTIA91)
END
/*
Then this is the SDSF of the JCL, return code = 0:
NP DDNAME StepName ProcStep DSID
JESMSGLG JES2 2
JESJCL JES2 3
JESYSMSG JES2 4
Shouldn't GO stepname appear as well if it's a successful execution?
I would at least expect a READY message on //SYSTSPRT if that step did start. So, yes there should be an entry for SYSTSPRT in that list. Did you look at the OUTPUT queue in SDSF to see if some output of your job went to this queue instead of the HOLD queue?
You could replace the DSN ... END sequence in //SYSTSIN with some TSO command, say LISTA and see if this produces some output.

Run step when previous JCL step did not find file

In the following JCL, the HFS path /u/woodsmn/jjk does not exist. It raises a JCL error and does not run the COPYHFS step, nor any other steps. I want it to detect the missing file, and run the FAILIND step.
I suspect MVS raises a JCL error and completely ignores any COND conditions that might apply. I was hoping it raise some failure step condition code and behave that way.
How can I re-write this to execute steps when a PATH does not exist?
//WOODSMN1 JOB (1111),MSGLEVEL=(1,1),CLASS=A,MSGCLASS=H,
// USER=WOODSMN,REGION=1M
//COPYHFS EXEC PGM=IKJEFT01
//INHFS DD PATH='/u/woodsmn/jjk',
// PATHOPTS=(ORDONLY),RECFM=VB,LRECL=255,BLKSIZE=32760
//OUTMVS DD DSN=WOODSMN.TESTDS1,
// DISP=(NEW,CATLG,DELETE),
// SPACE=(TRK,(1,1)),
// DCB=(LRECL=80,RECFM=FB,BLKSIZE=8080)
//SYSTSPRT DD SYSOUT=*
//SYSTSIN DD *
OCOPY INDD(INHFS) OUTDD(OUTMVS) CONVERT(NO)
/*
//*
//NETVIEW EXEC PGM=IEFBR14,COND=(0,EQ,COPYHFS)
//*
//SUCCIND EXEC PGM=IEBGENER,REGION=1M,COND=(0,EQ,NETVIEW)
//SYSPRINT DD SYSOUT=*
//SYSUT1 DD *
Attempt to put file succeeded
/*
//SYSUT2 DD PATHOPTS=(ORDWR,OTRUNC,OCREAT),PATHMODE=SIRWXU,
// PATHDISP=(KEEP,DELETE),
// PATH='/u/woodsmn/TESTDS.SUCCESS'
//SYSIN DD DUMMY
//*
//FAILIND EXEC PGM=IEBGENER,REGION=1M,COND=(0,GT,NETVIEW)
//SYSPRINT DD SYSOUT=*
//SYSUT1 DD *
Attempt to put file failed
/*
//SYSUT2 DD PATHOPTS=(ORDWR,OTRUNC,OCREAT),PATHMODE=SIRWXU,
// PATHDISP=(KEEP,DELETE),
// PATH='/u/woodsmn/TESTDS.FAIL'
//SYSIN DD DUMMY
//
Use BPXBATCH to execute a shell command to test the existence of your directory.
//EXIST001 EXEC PGM=BPXBATCH,PARM='SH test -e /u/woodsmn/jjk'
//STDOUT DD SYSOUT=*
//STDERR DD SYSOUT=*
You may have to get a bit more exotic and use the STDPARM DD to pass a `set -o errexit' to get the return code to work exactly as you wish.
Two things to change:
Firstly, run IKJEFT1B instead of IKJEFT01, because the former will end when a command in SYSTSIN ends with a non-zero returncode, and that return code will become the step return code.
Secondly, allocate the z/OS UNIX file with the ALLOC command just before the OCOPY. ALLOC will return with RC=12 if it cannot allocate the file (for whatever reason).
So, your first step should look like this:
//COPYHFS EXEC PGM=IKJEFT1B
//OUTMVS DD DSN=WOODSMN.TESTDS1,
// DISP=(NEW,CATLG,DELETE),
// SPACE=(TRK,(1,1)),
// DCB=(LRECL=80,RECFM=FB,BLKSIZE=8080)
//SYSTSPRT DD SYSOUT=*
//SYSTSIN DD *
ALLOC F(INHFS) PATH('/u/woodsmn/jjk') -
PATHOPTS(ORDONLY) RECFM(V B) LRECL(255) BLKSIZE(32760)
OCOPY INDD(INHFS) OUTDD(OUTMVS) CONVERT(NO)
/*
You can then test the return code from the COPYHFS step as usual. (And btw, you don't need that NETVIEW step, but instead test the return code from the COPYHFS step directly.)
IKJEFT1B, as well as IKJEFT01, and the third variation IKJEFT1Aare described in Appendix A. Executing the terminal monitor program in the manual z/OS TSO/E Customization.

JCL, What is the DD statement I would need to bring in my VSAM file for my cobol to use

VSAM file i need to use KC02477.NEWEMP.WORKASGN.KSDS
my cobol is using imbedded sql, I am having trouble getting it to compile using the input file, what is the correct syntax for the dd statement
****** ***************************** Top of Data ******************************
000001 //KC03AF5A JOB (12345678),'KC03AF5',MSGLEVEL=(1,1),
000002 // NOTIFY=KC03AF5,MSGCLASS=H,CLASS=A,REGION=0M
000003 //***********************************************************
000004 //FFFPROC JCLLIB ORDER=(KC02477.SHARED.PROCLIB)
000005 //*********************************************************************
000006 //DSNHICOB EXEC DSNHICOB,MEMBER=COBOL04, << MEMBERNAME IN COBOL PDS
000007 // SLIB='KC03AF5.BRAPAX' << COBOL PDS LIB INFO
000008 //*********************************************************************
000009 //BIND.SYSTSIN DD *
000010 DSN SYSTEM (DBAG)
000011 BIND PACKAGE(COL9G) MEMBER(COBOL04) ENCODING(EBCDIC) -
000012 ACT(REP) ISO(CS) OWNER(KC03AF5)
000013 BIND PLAN(BP278031) PKLIST(COL9G.*) -
000014 ACT(REP) ISO(CS) ENCODING(EBCDIC) -
000015 OWNER(KC03AF5)
000016 END
000017 //*********************************************************************
000018 //RUN.SYSTSIN DD *
000019 DSN SYSTEM(DBAG)
000020 RUN PROGRAM(COBOL04) PLAN(BP278031)
000021 END
000022 //RUN.REPORT1 DD SYSOUT=*
The DD statement would typically be :-
//ddname DD DSN=KC02477.NEWEMP.WORKASGN.KSDS,DISP=SHR
where ddname would be defined within the program.

How to get text in my new member using JCL

I have to make a new member in a JCL. This isn't a problem:
My code:
//STEP1 EXEC PGM=IEBGENER
//SYSUT1 DD *
//SYSUT2 DD DISP=(NEW,KEEP),UNIT=SYSALLDA,DSN=name.JCL4(MEMBER),
SPACE=(CYL,(1,1,45)),
VOL=SER=DMTU01
//SYSPRINT DD SYSOUT=*
//SYSIN DD DUMMY
/*
But I want that my MEMBER1 contains text.
So when I go in JCL4 and I press an e (edit) before MEMBER, I want to see some text like 'Hallo'. Can someone help me to explain how to do this?
If you are creating a new member in an existing JCL dataset, Try:
//STEP1 EXEC PGM=IEBGENER
//SYSUT1 DD *
Hello
/*
//SYSUT2 DD DSN=name.JCL4(MEMBER),DISP=(SHR,KEEP)
//SYSIN DD DUMMY
/*
The Disp refers to the dataset and not the member. so if the dataset already exists, you do not need to create it !!.
If you want create a new JCL dataset and a member at the same time,
the JCL should be like (where you catlg the dataset)
//STEP1 EXEC PGM=IEBGENER
//SYSUT1 DD *
Hello
/*
//SYSUT2 DD DSN=name.JCL4(MEMBER),DISP=(NEW,CATLG),
// UNIT=SYSALLDA, should this be sysda ???
// SPACE=(CYL,(1,1,45)),
// VOL=SER=DMTU01
//SYSIN DD DUMMY
/*

search if string from a pds is present in another pds

I have a pds (say A) having jobnames (superset).
I have another pds (say B) having lesser number of jobnames (subset).
best way to find a A-B into another file C using JCL ?
Try using SYNCORT JOINKEYS,
this example is pretty much
what you need. The JCL below is a specific example. AF1 is the Superset file (A) containing all job names, AF2 is the Subset
file (B). SORTOUT will contain the difference (A-B).
//MYJOB JOB Whatever your job card needs
//AMINUSB EXEC PGM=SYNCSORT,PARM='INCORE=OFF'
//AF1 DD * Superset file 'A'
J000001
J000002
J000003
J000004
J000005
J000006
J000007
J000008
J000009
J000010
J000011
J000012
/*
//BF2 DD * Subset file 'B'
J000001
J000003
J000004
J000008
J000010
J000011
/*
//SORTOUT DD SYSOUT=* 'A' - 'B'
//*
//SORTMSG DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//CEEDUMP DD SYSOUT=*
//STATOUT DD SYSOUT=*
//SYSIN DD *
JOINKEYS FILE=F1,FIELDS=(1,7,A)
JOINKEYS FILE=F2,FIELDS=(1,7,A)
JOIN UNPAIRED,F1,ONLY
REFORMAT FIELDS=(F1:1,7)
OPTION COPY
END
/*
If you run this, SORTOUT will contain the following data:
J000002
J000005
J000006
J000007
J000009
J000012
Note: You will have to refomat the JOB card to whatever your installation requires. The rest should work pretty much
as illustrated.