View previous topic :: View next topic
|
Author |
Message |
dejunzhu
Active User
Joined: 08 May 2008 Posts: 390 Location: China
|
|
|
|
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 |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
You pass everything as one parameter and store in a structure. |
|
Back to top |
|
|
dejunzhu
Active User
Joined: 08 May 2008 Posts: 390 Location: China
|
|
|
|
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 |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
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 |
|
|
Stefan
Active User
Joined: 12 Jan 2006 Posts: 110 Location: Germany
|
|
|
|
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 |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
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 |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
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 |
|
|
dejunzhu
Active User
Joined: 08 May 2008 Posts: 390 Location: China
|
|
|
|
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 |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1787 Location: Bloomington, IL
|
|
|
|
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 |
|
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1315 Location: Vilnius, Lithuania
|
|
|
|
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... |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8796 Location: Welsh Wales
|
|
|
|
That's a comma type of error though
OK OK I'll get my coat |
|
Back to top |
|
|
dejunzhu
Active User
Joined: 08 May 2008 Posts: 390 Location: China
|
|
|
|
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 |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Hope you are aware of the limitations as well |
|
Back to top |
|
|
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1205 Location: Dublin, Ireland
|
|
|
|
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 |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1787 Location: Bloomington, IL
|
|
|
|
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... |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
dejunzhu
Active User
Joined: 08 May 2008 Posts: 390 Location: China
|
|
|
|
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 |
|
|
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
You cannot use symbolic parameters in instream data
Gerry |
|
Back to top |
|
|
dejunzhu
Active User
Joined: 08 May 2008 Posts: 390 Location: China
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
|