IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to pass more than one parameters from JCL to program?


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
dejunzhu

Active User


Joined: 08 May 2008
Posts: 390
Location: China

PostPosted: Fri Jul 05, 2013 11:32 am
Reply with quote

I' trying to pass two parameters from JCL to program using below step:
Code:
//CMBPSYSB EXEC PGM=TEST,PARM=(&PARM,9),COND=(4,LT)
//SYSPRINT DD   SYSOUT=*                                   
//SYSOUT   DD   SYSOUT=*                                   


In the linkage section of program TEST,
Code:
*****************************************************************
*               LINKAGE          SECTION                        *
*****************************************************************
 LINKAGE                         SECTION.                         
*                                                                 
* 批量控制参数 PARM 结构                                         
 COPY     CKCPARM.                                               
*                                                                 
 01  LK-INPUT-PARM.                                               
     05  LK-INPUT-LEN            PIC   S9(4) COMP.               
     05  LK-INPUT-CHKPT-CNT      PIC   X(1) .                     
*                                                                 
******************************************************************
*               PROCEDURE        DIVISION                        *
******************************************************************
*                                                                 
 PROCEDURE                       DIVISION                         
                                 USING LK-PARM-REC           
                                       LK-INPUT-PARM.             
*                                                                 

when I display the two parameters, I can see the first parameters was successfully passed to LK-PARM-REC of program , but the second parameter was not received into LK-INPUT-PARM.

Can u please advise how to pass the second parameter?
THanks.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Fri Jul 05, 2013 12:00 pm
Reply with quote

You pass everything as one parameter and store in a structure.
Back to top
View user's profile Send private message
dejunzhu

Active User


Joined: 08 May 2008
Posts: 390
Location: China

PostPosted: Fri Jul 05, 2013 12:47 pm
Reply with quote

Thanks for your reply.
Passing and receiving is good for only one parameter.
But I really need to pass 2 parameters...

How can I receive it from my program?
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Fri Jul 05, 2013 12:52 pm
Reply with quote

I think that Nic is intimating that you pass ONE string to the program, and within the program you delimit the different sections of the string passed to get the required parameters.
Back to top
View user's profile Send private message
Stefan

Active User


Joined: 12 Jan 2006
Posts: 110
Location: Germany

PostPosted: Fri Jul 05, 2013 12:59 pm
Reply with quote

Quote:
The system is going to "call" your program, with one item of linkage, the contents of the PARM from the JCL with the first two bytes being a binary field containing the length of the PARM itself.


This is a quote by Bill Woodger from another thread in this forum.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Fri Jul 05, 2013 2:00 pm
Reply with quote

Show yourself what you passed in Parm and also display yourself what you received in program when you have used Nic's advice
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Fri Jul 05, 2013 2:34 pm
Reply with quote

I can see why you are having this problem - I have just had a look through the index and contents of both the language reference and the programming guide and I can find no obvious reference to receiving a parameter from JCL. Passing parameters from module to module, yes; from JCL to program, no. Maybe someone else can post details of which section(s) of those two manuals to look at - or an alternative source (within the IBM manuals).
Back to top
View user's profile Send private message
dejunzhu

Active User


Joined: 08 May 2008
Posts: 390
Location: China

PostPosted: Fri Jul 05, 2013 2:41 pm
Reply with quote

Nic Clouston wrote:
Passing parameters from module to module, yes; from JCL to program, no.

If this is true, why passing more than one parameters is supported by JCL???
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Fri Jul 05, 2013 2:49 pm
Reply with quote

Because JCL is not COBOL - it is a different language and a different type of language too with its own rules jsust as COBOL has its own rules. And I think you have a typo - JCL passes ONE parameter, of up to 100 bytes.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Jul 05, 2013 3:30 pm
Reply with quote

dejunzhu,

There is a, single, PARM value in the JCL.

Whether the content of that is understood as separate pieces of information in the program that is the target of the EXEC is entirely up to that program, the JCL processor does not care (beyond how it is specified to operate in the JCL) anything about it. To the JCL it is one, and only one parameter, where there are multiple commas, some equals signs, or the word Banana repeated several times, it is all the same to the JCL.

One PARM value from the JCL. You define one parameter in your COBOL program. Then, in the COBOL program, you take the content of that, and interpret it however you like.

If you have PARM='A,B' in the JCL, then you will get two-byte binary with a value of three, followed by A,B in your program. It is entirely up to your program to "realise" that this, to your program, is "two parameters".

Nic,

I've never seen any formal documentation of the process from IBM. I'd guess it must be in some Assembler manual. For COBOL, it is knowledge which just "exists" and gets passed on.... "Just copy program XYZ and make sure you know what it is doing..."

Having said that, mostly it is done badly, so perhaps someone should fill in a suggestion slip and send it to the COBOL people...

I think that the link Stefan provided already should be clear enough :-)
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Fri Jul 05, 2013 3:55 pm
Reply with quote

dejunzhu wrote:
Nic Clouston wrote:
Passing parameters from module to module, yes; from JCL to program, no.

If this is true, why passing more than one parameters is supported by JCL???

What do you base that (completely false) statement on?
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Fri Jul 05, 2013 5:08 pm
Reply with quote

Akatsukami wrote:
dejunzhu wrote:
Nic Clouston wrote:
Passing parameters from module to module, yes; from JCL to program, no.

If this is true, why passing more than one parameters is supported by JCL???

What do you base that (completely false) statement on?

On the fact that his parameter contains a comma... icon_lol.gif
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Fri Jul 05, 2013 5:10 pm
Reply with quote

That's a comma type of error though

OK OK I'll get my coat icon_rolleyes.gif
Back to top
View user's profile Send private message
dejunzhu

Active User


Joined: 08 May 2008
Posts: 390
Location: China

PostPosted: Fri Jul 05, 2013 6:01 pm
Reply with quote

okay, I have got the desired solution.
No matter how many parameters delimited by comma, just coding one 01-level variable in LINKAGE SECTION as the receiving area of the program will do.
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Fri Jul 05, 2013 6:22 pm
Reply with quote

Hope you are aware of the limitations as well
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Fri Jul 05, 2013 8:22 pm
Reply with quote

dejunzhu wrote:
okay, I have got the desired solution.
No matter how many parameters delimited by comma, just coding one 01-level variable in LINKAGE SECTION as the receiving area of the program will do.


...and if the parameter values are not all the fixed-length that your 01-level variable specifies....?

Garry.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Sat Jul 06, 2013 2:46 am
Reply with quote

Bill Woodger wrote:
I've never seen any formal documentation of the process from IBM. I'd guess it must be in some Assembler manual. For COBOL, it is knowledge which just "exists" and gets passed on.... "Just copy program XYZ and make sure you know what it is doing..."

Having said that, mostly it is done badly, so perhaps someone should fill in a suggestion slip and send it to the COBOL people...

It's alluded to, but not explained, in the USING phrase topic of the Enterprise COBOL Language Reference. In the Enterprise PL/I Language Reference, it's made explicit in Passing arguments to the MAIN procedure. Perhaps the folks working on one set of manuals need to bring in the folks working on the other set as consultants... icon_smile.gif
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Sat Jul 06, 2013 6:04 am
Reply with quote

The Programming Guide adds
Quote:
When you run an Enterprise COBOL program under z/OS and pass the program a parameter string, for example, by using JCL or a TSO command, the parameter list consists of a character string that has a halfword prefix that contains the string length.

About this task
You can access the parameter string by using a LINKAGE SECTION and standard COBOL coding as shown in the example referenced below:

Example: accessing main program parameters under z/OS

Alternatively, you can obtain the parameter string by calling either of the following Language Environment callable services, which are described in the related references below:
•CEE3PRM (query parameter string): obtain the parameter string (if not longer than 80 characters)
•CEE3PR2 (query parameter string long): obtain the parameter string and its length
In either case, the parameter string might contain program arguments, runtime options, or both.
in Accessing main program parameters under z/OS
Back to top
View user's profile Send private message
dejunzhu

Active User


Joined: 08 May 2008
Posts: 390
Location: China

PostPosted: Sat Jul 06, 2013 8:47 am
Reply with quote

Another new problem occurred, if I pass parameters via below PARMS ,
Code:
//RUNPRG  EXEC PGM=IKJEFT01,DYNAMNBR=20
//SYSTSPRT DD SYSOUT=*                 
//SYSTSIN DD *                         
 DSN SYSTEM(DB11)                     
 RUN PROGRAM(TST00000) PLAN(TESTPLAN) -
 PARMS('&PAR,0004')               
//SYSPRINT DD SYSOUT=*                 

From the message printed by the program TST00000,
Code:
********************************* TOP OF DATA **
INPUT  PARM :   &PAR,0004           
 

we can see that PAR was not expanded...(I have used SET statement to set PAR to a string, and I'm expecting PAR to be expanded for the program)
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Sat Jul 06, 2013 12:38 pm
Reply with quote

Hi,

You cannot use symbolic parameters in instream data



Gerry
Back to top
View user's profile Send private message
dejunzhu

Active User


Joined: 08 May 2008
Posts: 390
Location: China

PostPosted: Sat Jul 06, 2013 12:47 pm
Reply with quote

gcicchet wrote:
Hi,

You cannot use symbolic parameters in instream data



Gerry

Thanks for your reply.
What if I need to passing symbolic parameters into a program that accesses DB2? Can you please advise?
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sat Jul 06, 2013 12:59 pm
Reply with quote

Well, goodness me, they have updated the manual. Robert's quote is from the Enterprise Cobol Version 5 Release 1 Programming Guide, which has been available for about three weeks.

Not only have they updated the manual, but they've included an example which is basically how I code it rather than using "reference-modification" :-)

There we go. And you don't have to wait for V5.1 to use it. It would work from OS/VS COBOL onwards, and it is not the COBOL that provides the limit, it is when OS appeared (and they decided to allow a PARM in the JCL). The ODO for a variable-length field worked in 1964 at least, the earliest I can track it down to through documentation...
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sat Jul 06, 2013 1:15 pm
Reply with quote

One way to do it is to not use the PARM directly. Have a new, not very big, program which takes the PARM and writes it to a file. Read that file in your DB2 program, instead of trying to use the PARM.

You could also look to "generate" the Control Cards to execute your program, allowing for the symbol-substitution to take place and then be included in the generated cards.

You may also want to investigate the Language Environment route, from the piece which Robert posted. I'm not sure what "TSO" is going to do with options it doesn't recognise.

It is not, at any current release of z/OS, going to work how you have coded it.
Back to top
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Sat Jul 06, 2013 1:33 pm
Reply with quote

Hi,

you can try this
Code:


//         SET PAR='ABC'                                               
//SORT0001 EXEC PGM=SORT,                                             
//             PARM='JP1"&PAR",LIST'                                   
//SORTOUT  DD DSN=&&PARMS,                                             
//            DISP=(,PASS,DELETE),                                     
//            UNIT=SYSDA,                                             
//            SPACE=(TRK,(1))                                         
//SYSOUT   DD SYSOUT=*                                                 
//SYSIN    DD *                                                       
 SORT FIELDS=COPY                                                     
 OUTFIL FILES=OUT,REMOVECC,NODETAIL,                                   
        HEADER1=(' PARMS(',X'7D',JP1,C',0004',X'7D',C')')             
//SORTIN    DD *                                                       
/*                                                                     
//RUNPRG  EXEC PGM=IKJEFT01,DYNAMNBR=20                               
//SYSTSPRT DD SYSOUT=*                                                 
//SYSTSIN DD *                                                         
 DSN SYSTEM(DB11)                                                     
 RUN PROGRAM(TST00000) PLAN(TESTPLAN) -                               
//         DD DSN=&&PARMS,                                             
//            DISP=(OLD,DELETE)                                       
//SYSPRINT DD SYSOUT=*                                                 



Gerry
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sat Jul 06, 2013 1:47 pm
Reply with quote

And you can easily adapt Gerry's example to write the parameter to a file.

You can "maximise" the potential length of the parameter, but if you need more than 69/71 characters, you'll need to find out how to divide-and-continue the parameter.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM Goto page 1, 2  Next

 


Similar Topics
Topic Forum Replies
No new posts Using API Gateway from CICS program CICS 0
No new posts DB2 Event passed to the Application P... DB2 1
No new posts How to pass the PARM value to my targ... COBOL Programming 8
No new posts Dynamically pass table name to a sele... DB2 2
No new posts REXX code to expand copybook in a cob... CLIST & REXX 2
Search our Forums:

Back to Top