MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Passing a variable to COBOL program using SYSIN in a JCL

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Job Control Language(JCL)
View previous topic :: View next topic  
Author Message
psridhar
Beginner


Joined: 16 May 2004
Posts: 68
Topics: 26

PostPosted: Wed Oct 26, 2005 7:10 am    Post subject: Passing a variable to COBOL program using SYSIN in a JCL Reply with quote

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
View user's profile Send private message
vkphani
Intermediate


Joined: 05 Sep 2003
Posts: 483
Topics: 48

PostPosted: Wed Oct 26, 2005 7:36 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
superk
Advanced


Joined: 19 Dec 2002
Posts: 684
Topics: 5

PostPosted: Wed Oct 26, 2005 7:41 am    Post subject: Reply with quote

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
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Oct 26, 2005 7:41 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
psridhar
Beginner


Joined: 16 May 2004
Posts: 68
Topics: 26

PostPosted: Wed Oct 26, 2005 8:15 am    Post subject: Reply with quote

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
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Oct 26, 2005 8:16 am    Post subject: Reply with quote

Quote:

In general, Can I pass a variable like date, etc.. as SYSIN parameter to a cobol program.


Psridhar,

Please search before posting. Passing parms has been discussed many times here. check these links

http://mvsforums.com/helpboards/viewtopic.php?t=4469&highlight=accept

http://mvsforums.com/helpboards/viewtopic.php?t=2456&highlight=accept

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vkphani
Intermediate


Joined: 05 Sep 2003
Posts: 483
Topics: 48

PostPosted: Wed Oct 26, 2005 8:21 am    Post subject: Reply with quote

Yes you can pass variables like date etc thru SYSIN parameter to a cobol program.

These link might be useful;

http://mvsforums.com/helpboards/viewtopic.php?t=442&highlight=passing+value

http://mvsforums.com/helpboards/viewtopic.php?t=2456&highlight=pass+data
Back to top
View user's profile Send private message Send e-mail
psridhar
Beginner


Joined: 16 May 2004
Posts: 68
Topics: 26

PostPosted: Wed Oct 26, 2005 8:46 am    Post subject: Reply with quote

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
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Oct 26, 2005 9:02 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
psridhar
Beginner


Joined: 16 May 2004
Posts: 68
Topics: 26

PostPosted: Wed Oct 26, 2005 9:27 am    Post subject: Reply with quote

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
View user's profile Send private message
superk
Advanced


Joined: 19 Dec 2002
Posts: 684
Topics: 5

PostPosted: Wed Oct 26, 2005 9:34 am    Post subject: Reply with quote

Not.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Oct 26, 2005 9:49 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
semigeezer
Supermod


Joined: 03 Jan 2003
Posts: 1014
Topics: 13
Location: Atlantis

PostPosted: Wed Oct 26, 2005 10:52 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Phantom
Data Mgmt Moderator
Data Mgmt Moderator


Joined: 07 Jan 2003
Posts: 1056
Topics: 91
Location: The Blue Planet

PostPosted: Mon Oct 31, 2005 2:37 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Job Control Language(JCL) All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group