View previous topic :: View next topic |
Author |
Message |
psridhar Beginner
Joined: 16 May 2004 Posts: 68 Topics: 26
|
Posted: Wed Oct 26, 2005 7:10 am Post subject: Passing a variable to COBOL program using SYSIN in a JCL |
|
|
Hi
I need to pass a variable to a COBOL program through a JCL using SYSIN.
I have two steps in a JCL. One is FTP and another one is COBOL program execution. I need to pass the return code of the FTP step to the COBOL program using SYSIN. I will use ACCEPT in my COBOL to read the value.
How can I pass a variable to a program using SYSIN.
Regards
Sridhar P |
|
Back to top |
|
 |
vkphani Intermediate

Joined: 05 Sep 2003 Posts: 483 Topics: 48
|
Posted: Wed Oct 26, 2005 7:36 am Post subject: |
|
|
In the second step use the COND parameter to check the return code from the first step and pass this return code to cobol pgm in the second step thru sysin. |
|
Back to top |
|
 |
superk Advanced

Joined: 19 Dec 2002 Posts: 684 Topics: 5
|
Posted: Wed Oct 26, 2005 7:41 am Post subject: |
|
|
This is a piece of REXX (shareware) code that will retrieve the STEP NAME and RETURN-CODE values from any steps that have run prior to it being called:
Code: |
/* REXX */
/* GET THE STEP NAME AND RETURN CODE */
NUMERIC DIGITS(32) /* ENSURE MAX PRECISION */
TCB=STORAGE(D2X(540),4) /* PSATOLD IN PSA */
JSCB =STORAGE(D2X(C2D(TCB)+180),4) /* TCBJSCB IN TCB */
JCT = STORAGE(D2X(C2D(JSCB)+261),3) /* JSCBJCTA IN JSCB */
THIS_STEP_NO = X2D(C2X(STORAGE(D2X(C2D(JSCB)+228),1)))
/* THIS STEP NO. */
FSCT = STORAGE(D2X(C2D(JCT)+48),3) /* JCTSDKAD IN JCT */
/* IS FIRST SCT */
TEMP_SCT = FSCT
DO I = 1 TO (THIS_STEP_NO - 1)
STEP = STORAGE(D2X(C2D(TEMP_SCT)+68),8)
RCSTEP = X2D(C2X(STORAGE(D2X(C2D(TEMP_SCT)+24),2)))
/* SCTSEXEC IN SCT */
BYPASS = STORAGE(D2X(C2D(TEMP_SCT)+188),1)
IF X2D(C2X(BYPASS)) = 80 THEN /* CHECK IF STEP WAS NOT EXECUTED */
DO
RCSTEP = 'FLUSHED '
END
SAY 'STEP ==>' STEP ' RC ==>' RCSTEP
TEMP_SCT = STORAGE(D2X(C2D(TEMP_SCT)+36),3)
END
EXIT
|
You could modify it slightly to write the STEP and RETURN-CODE values to a dataset. Then, use that dataset as input to your SYSIN DD.
I believe that there is also a similar shareware utility written in COBOL. I believe that a copy has been posted in this forum before. |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Wed Oct 26, 2005 7:41 am Post subject: |
|
|
Psridhar,
You cannot pass the return-code of a step as sysin. What exactly are you trying to do ? Are you bypassing your processing if the ftp step returns a return code other than zero ? If so you can use JCL COND parameter to skip the step.
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
psridhar Beginner
Joined: 16 May 2004 Posts: 68 Topics: 26
|
Posted: Wed Oct 26, 2005 8:15 am Post subject: |
|
|
Hi friends
Thanks for the reply.
Hi Kolusu,
What I want to do is, in my program, I have to check the return code of the FTP step and perform different processes depending on the return code of the FTP step. I have to execute my program. That is for sure. But the path it takes depends on the FTP return code.
In general, Can I pass a variable like date, etc.. as SYSIN parameter to a cobol program.
Hope I am clear.
Regards
Sridhar P |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
|
Back to top |
|
 |
vkphani Intermediate

Joined: 05 Sep 2003 Posts: 483 Topics: 48
|
|
Back to top |
|
 |
psridhar Beginner
Joined: 16 May 2004 Posts: 68 Topics: 26
|
Posted: Wed Oct 26, 2005 8:46 am Post subject: |
|
|
Hi Kolusu,
I really searched for more than one hour in this forum to get the answer to my requirement but I did not find.
None of your two postings answered my question.
Let me explain my problem again.
In my program, I have to check the return code of the FTP step and perform different processes depending on the return code of the FTP step. I have to execute my program what ever may be the return code of the previous step. That is for sure. But the path it takes depends on the FTP return code.
I tried the below code.
Code: | //SYSIN DD *
TCPIP.RC
/* |
Where TCPIP is my previous step name. But my program is reading "TCPIP.RC" string as input but not the actual return code of the TCPIP step.
In the second posting you gave, the date '2004-06-24' is a constant and I don't want that one. Say if I want to find the system date from JCL or some other variable from a SPUFI in previous step, and pass it to the program, how do we handle it.
Regards
Sridhar P |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Wed Oct 26, 2005 9:02 am Post subject: |
|
|
psridhar wrote: | None of your two postings answered my question.Let me explain my problem again.
In my program, I have to check the return code of the FTP step and perform different processes depending on the return code of the FTP step. I have to execute my program what ever may be the return code of the previous step. That is for sure. But the path it takes depends on the FTP return code.
|
Psridhar,
Read my post clearly once again and come back to complain. In my first post , I clearly mentioned this
kolusu wrote: |
You cannot pass the return-code of a step as sysin. What exactly are you trying to do ? Are you bypassing your processing if the ftp step returns a return code other than zero ? If so you can use JCL COND parameter to skip the step.
|
For which you had another question
psridhar wrote: |
In general, Can I pass a variable like date, etc.. as SYSIN parameter to a cobol program.
|
This is when I pointed out 2 threads which uses the accept verb and receives the values from sysin.
psridhar wrote: |
In the second posting you gave, the date '2004-06-24' is a constant and I don't want that one. Say if I want to find the system date from JCL or some other variable from a SPUFI in previous step, and pass it to the program, how do we handle it.
|
*Sigh* That is an example showing as to how to pass values and recieve it in the program using accept verb.
You can put the whatever values you want in a 80 byte file and assign it to sysin in your jcl and you can use the accept verb to read that as a file.
check this link
http://www.mvsforums.com/helpboards/viewtopic.php?t=1581&highlight=accept
Btw if you are not aware COBOL has inbuilt date features which can get the current date
Thanks,
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
psridhar Beginner
Joined: 16 May 2004 Posts: 68 Topics: 26
|
Posted: Wed Oct 26, 2005 9:27 am Post subject: |
|
|
Hi Kolusu,
Lets have a look at the below JCL.
Code: | //TCPIP ......EXEC PGM=.....
//
//
...
//EXECPGM ......EXEC PGM=.....
//
//
...
//SYSIN DD *
TCPIP.RC
/*
//SYSTSIN DD *
DSN SYSTEM(DS0T)
RUN PROGRAM(PMPB130) -
PLAN(YABB001)
END |
If TCPIP return code is 1954 then my COBOL program has to take one path and if TCPIP return code is 3454 then my COBOL program has to take another path.
May I know whether it is possible or not?
Regards
Sridhar P |
|
Back to top |
|
 |
superk Advanced

Joined: 19 Dec 2002 Posts: 684 Topics: 5
|
Posted: Wed Oct 26, 2005 9:34 am Post subject: |
|
|
Not. |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Wed Oct 26, 2005 9:49 am Post subject: |
|
|
Psirdhar,
I give up. You are going in circles. There is no direct way to pass the return code as sysin to a cobol program. clipart {frustrated}
You need to use the rexx routine posted by superk in this thread which will create the sysin cards for cobol program.
Another alternative is to use IF/THEN/ELSE/ENDIF statement constructs for all the possible return codes.
Code: |
//TCPIP ......EXEC PGM=.....
//
//
...
//IFTEST1 IF TCPIP.RC = 1954 THEN
//EXECPGM ......EXEC PGM=.....
//
//
...
//SYSIN DD *
1954
/*
//SYSTSIN DD *
DSN SYSTEM(DS0T)
RUN PROGRAM(PMPB130) -
PLAN(YABB001)
END
/*
// ELSE
//IFTEST2 IF TCPIP.RC = 3454 THEN
//EXECPGM ......EXEC PGM=.....
//
//
...
//SYSIN DD *
3454
/*
//SYSTSIN DD *
DSN SYSTEM(DS0T)
RUN PROGRAM(PMPB130) -
PLAN(YABB001)
END
/*
//ENDTEST2 ENDIF
//ENDTEST1 ENDIF
|
Check this link for a detailed explanation of the IF/THEN/ELSE/ENDIF statement constructs
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IEA2B631/17.0?DT=20030423085347
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
semigeezer Supermod
Joined: 03 Jan 2003 Posts: 1014 Topics: 13 Location: Atlantis
|
Posted: Wed Oct 26, 2005 10:52 am Post subject: |
|
|
Psirdhar, you are confused about what a DD statement does. A DD statement simply references a file. It is data. Nothing more. A SYSIN DD * statement is also just data. The JCL interpreter does not look at or change the data in files or in inline data. It just makes that data, unchanged, available to the program. As many others have pointed out, you can find the previous return codes by looking at MVS control blocks, as Kevin's rexx exec does. If you understand using control blocks in a COBOL program, you can look at the previous return codes from directly within your COBOL program and not bother with any special JCL.
In general however, be aware that IBM publishes which control blocks are for public use and which ones are subject to change without notice. Before you use control blocks, you should verify that they are intended interfaces by looking in the data areas books.
If the return code is important to you, your best options are to either use multiple COBOL steps with IF/ELSE logic or COND conditions, or to do the whole process in Rexx under IKJEFT01 (invoke FTP , get the return code, write tht to a file and call your COBOL program all within the same Rexx program). Doing everything in Rexx would be my choice because it is fairly easy to write and maintain and it doesn't depend on control blocks that might change someday |
|
Back to top |
|
 |
Phantom Data Mgmt Moderator

Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
|
Posted: Mon Oct 31, 2005 2:37 am Post subject: |
|
|
psridhar,
I am just summarizing whatever is been discussed by others so far.
You just have 3 options left.
1. Use REXX to get the return code of a JOB or Job Step. For this, you first need to understand Control Blocks.
2. If you are sure that the FTP step can return only few possible return-codes 2 or 3 then follow the IF/THEN/ELSE logic provided by Kolusu. You invoke the same cobol program but with different Hard-Coded Sysin cards. This solution is not feasible (doesn't look good) when you have lots of possible return-codes.
3. Introduce a new step b/w your FTP and COBOL program. This could be a REXX or something else. Using the new step you need to build a SYSIN card dynamically.
Does this solve your problem,
Thanks,
Phantom |
|
Back to top |
|
 |
|
|