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

how to pass multiple parameters through PARM


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
rohanthengal

Active User


Joined: 19 Mar 2009
Posts: 206
Location: Globe, India

PostPosted: Thu Jun 09, 2011 12:27 pm
Reply with quote

i want to know about the way to pass multiple parameters through PARM in JCL.
One of the way which i found is PARM='TASK1,TASK2,TASK3'.
But it would be appreciable if anyone can help me to the way to receive these values in COBOL pgm.
like:
LINKAGE SECTION.
01 LS-VALUES.
05 LS-LENGTH PIC S9(4) COMP.
05 LS-DATA PIC X(20).
will LS-DATA hold the values that are sent by PARM ? OR Do i need to group them by comma separation ? like shown below:
LINKAGE SECTION.
01 LS-VALUES.
05 LS-LENGTH PIC S9(4) COMP.
05 LS-DATA.
10 LS-DATA1 PIC X(5).
10 LS-COMMA1 PIC X(1).
10 LS-DATA2 PIC X(5).
10 LS-COMMA2 PIC X(1).
10 LS-DATA3 PIC X(5).
10 LS-COMMA3 PIC X(1).

I want to know the same as i dont have an access to mainframes for some time. Thank you !
Back to top
View user's profile Send private message
expat

Global Moderator


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

PostPosted: Thu Jun 09, 2011 12:30 pm
Reply with quote

Moved to COBOL forum as that appears to be where the real problem lies.
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: Thu Jun 09, 2011 12:52 pm
Reply with quote

The PARM form the JCL will arive as a piece of storage up to 102 bytes in length. The first two bytes, a binary half-word, indicate the length of the data that follows (0-100).

In your example, you could define the up-to-100-bytes either way. The data still looks the same, ie 'TASK1,TASK2,TASK3'. The parm will arrive exactly "asis" from the JCL. Up to you to process it.

With your first definition, the last three bytes would contain undefined values.

With your second definition you limit yourself to parameters of the same length (and LS-COMMA-3, in your example, would contain an undefined value).

Code:

01 LS-DATA-FROM-JCL-PARM.
    05 LS-DFJP-LENGTH-OF-PARM PIC S9(4) COMP.
    05 LS-DFJP-PARM-DATA.
       10  FILLER
             OCCURS 0 TO 100 TIMES
               DEPENDING ON
                 LS-DFJP-LENGTH-OF-PARM.
           15  FILLER PIC X.


Defined this way, you will have LS-DFJP-PARM-DATA with no undefined values, being the exact length of the PARM specified in the JCL.

You can MOVE it or UNSTRING it or whatever. Would work with zero length, but better to handle that specifically as an if.

This way you can have "positional" parameters up to any number that you support and which fit in the maximum length of the PARM (100 characters), and the parameters do not need to be the same length (just UNSTRING 'em into appropriate receiving fields).
Back to top
View user's profile Send private message
nigelosberry

New User


Joined: 06 Jan 2009
Posts: 88
Location: Ggn, IN

PostPosted: Thu Jun 09, 2011 12:53 pm
Reply with quote

rohanthengal wrote:
will LS-DATA hold the values that are sent by PARM ? OR Do i need to group them by comma separation ?


The whole PARM will arrive in your program as a single string of alphanumeric characters. The first 2 bytes(i.e. a halfword) in that string will be the length of the string.
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: Thu Jun 09, 2011 1:16 pm
Reply with quote

nigelosberry wrote:

[...]
The whole PARM will arrive in your program as a single string of alphanumeric characters. The first 2 bytes(i.e. a halfword) in that string will be the length of the string.


I know what you mean, but, literally, since this is computers, how would that work? The first two bytes of an "alpahnumeric string", as a half-word binary, would be way-way-way over 100 - or way-way-way less, if you define it as signed.
Back to top
View user's profile Send private message
nigelosberry

New User


Joined: 06 Jan 2009
Posts: 88
Location: Ggn, IN

PostPosted: Thu Jun 09, 2011 1:22 pm
Reply with quote

nigelosberry wrote:

[...]
The whole PARM will arrive in your program as a single string of alphanumeric characters. The first 2 bytes(i.e. a halfword) in that string will be the length of the string.



Oops!
Thanks Bill. Yes, my statement may be interpreted incorrectly.

Correction:
The whole PARM will arrive as a series of bytes where the first 2 bytes is the length of the PARM string one has supplied in the JCL. Of course there is a limit to the maximum length of a parm in a jcl.
Back to top
View user's profile Send private message
cvkumar59

New User


Joined: 25 Aug 2006
Posts: 18

PostPosted: Mon Oct 31, 2011 5:49 pm
Reply with quote

Could you please let me know how the data is passed through the PARM in jCl , anyway the declaration is provided above by Bill. Also could you please let us know the code in Procedure division .

Thanks,
Kumar
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: Mon Oct 31, 2011 6:04 pm
Reply with quote

I'm not sure I get your question.

On the EXEC PGM=, you have "PARM='and then some character string'" Check in the JCL manual on exact details, when you don't need quotes, maxium length, how to do continuation if needed, etc.

In the Cobol program, code something like the above (there are other possibilities, search the Cobol forum here).

In the procedure, with the above definition, just MOVE LS-DFJP-PARM-DATA to wherever you want it to be. Or, UNSTRING LS-DFJP-PARM-DATA if you have multiple parameter elements seperated by commas.

Unless you can be more specific, I don't know what else to type.
Back to top
View user's profile Send private message
don.leahy

Active Member


Joined: 06 Jul 2010
Posts: 765
Location: Whitby, ON, Canada

PostPosted: Mon Oct 31, 2011 6:35 pm
Reply with quote

cvkumar59 wrote:
Could you please let me know how the data is passed through the PARM in jCl , anyway the declaration is provided above by Bill. Also could you please let us know the code in Procedure division .

Thanks,
Kumar
Code:
PROCEDURE DIVISION USING LS-VALUES.
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: Mon Oct 31, 2011 7:39 pm
Reply with quote

Forgot to mention, if you have a new question, start a new topic please.

Yes, you'll need to mention your dataname on your Procedure Division header, as Don has pointed out, and the definition must be in the Linkage section. The operating 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.
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts Multiple table unload using INZUTILB DB2 2
No new posts Grouping by multiple headers DFSORT/ICETOOL 7
No new posts JCL EXEC PARM data in C Java & MQSeries 2
Search our Forums:

Back to Top