Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Parameter from JCL to COBOL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
sriraj1122

New User


Joined: 18 Dec 2008
Posts: 15
Location: Hyderabad

PostPosted: Mon Nov 15, 2010 3:54 pm    Post subject: Parameter from JCL to COBOL
Reply with quote

Hi ,

I am trying to write a simple cobol program which receives name parameter from JCL and display it from spool.. Im not able to get the desired result.

Cld anyone pls help ..
My cobol program goes like this

Code:
WORKING-STORAGE SECTION.                                       
01 WS-NAME         PIC X(10) VALUE SPACES.                     
LINKAGE  SECTION.                                             
01 PARM-BUFFER.                                               
   05 PARM-LENGTH PIC S9(4) COMP.                             
   05 PARM-NAME   PIC X(10).                                   
PROCEDURE DIVISION USING PARM-BUFFER.                         
    MOVE 'ABC' TO WS-NAME.                                     
    DISPLAY WS-NAME.                                           
    DISPLAY PARM-NAME.                                         
    DISPLAY PARM-LENGTH.                                       
    STOP RUN.


My Exec JCL is as below .

Code:

//STEP1 EXEC PGM=TEST,                                       
//      PARM='XYZ'                                           
//STEPLIB DD DISP=SHR,DSN=DEV.UT3.CICSLOAD                   
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*



Im getting the below result.

ABC

00010

*************
Pls help me how to get XYZ in spool.
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8055
Location: East Dubuque, Illinois, USA

PostPosted: Mon Nov 15, 2010 5:52 pm    Post subject:
Reply with quote

I took your code and ran it to receive output of
Code:
 ABC
 XYZ.......
 00003
which is exactly as expected. The 10 length in your post indicates a problem -- parameters passed from JCL usually reflect the actual length, not the length of the variable. Which version of the compiler are you using?
Back to top
View user's profile Send private message
sriraj1122

New User


Joined: 18 Dec 2008
Posts: 15
Location: Hyderabad

PostPosted: Mon Nov 15, 2010 7:26 pm    Post subject: Reply to: Parameter from JCL to COBOL
Reply with quote

Hi Robert,

Firstly Thanks for ur response
Even if I change the length of the variable in linkage section im getting the same result.

WORKING-STORAGE SECTION.
01 WS-NAME PIC X(10) VALUE 'ABC'.
LINKAGE SECTION.
01 PARM-BUFFER.
05 PARM-LENGTH PIC S9(2) COMP.
05 PARM-NAME PIC X(06).

And how to know the version of the compiler we are using ???
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Mon Nov 15, 2010 7:53 pm    Post subject: Reply to: Parameter from JCL to COBOL
Reply with quote

To make this process entirely flexible, define PARM-NAME (or whenever you want to name it) as PIC X(100), which is the maximum parm-size that can be passed from JCL and then define PARM-LENGTH as PIC S9(04) COMP.

Programmatically, you can then determine whether or not a parm had been passed, by checking PARM-LENGTH for a value of GREATER THAN ZERO, in which case, use REFERENCE MODIFICATION to move it to a WORKING-STORAGE field -

Code:

03  WS-PARM-AREA   PIC  X(100)      VALUE SPACES.

IF  PARM-LENGTH > ZERO
    MOVE PARM-NAME TO WS-PARM-AREA (1:PARM-LENGTH)
END-IF.

You should normally define PARM-LENGTH as PIC S9(04) COMP/COMP-4/BINARY/COMP-5, because PIC S9(01) through PIC S9(04) occupies 2-Bytes (halfword-binary), regardless.

Bill
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Mon Nov 15, 2010 8:33 pm    Post subject: Reply to: Parameter from JCL to COBOL
Reply with quote

On second thought, because the sending field is in LINKAGE, use REFERENCE MODIFICATION on it as well. This will prevent a S0C4 and cause the compiler to build an MVCL, but I'm over it -

Code:

MOVE PARM-NAME (1:PARM-LENGTH) TO WS-PARM-AREA (1:PARM-LENGTH).

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

New User


Joined: 18 Dec 2008
Posts: 15
Location: Hyderabad

PostPosted: Tue Nov 16, 2010 3:13 pm    Post subject: Reply to: Parameter from JCL to COBOL
Reply with quote

Hi Bill,

thnx for ur reply..but when im using reference modification im getting below outut

ABC
" 0 " 0 " 0 " 0 " 0 " 0 " 0 " 0
00010
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Tue Nov 16, 2010 4:46 pm    Post subject: Reply to: Parameter from JCL to COBOL
Reply with quote

Something's wrong here. If you pass 'ABC' as your JCL parameter, LINKAGE fields PARM-LENGTH will equal X'0003' and PARM-NAME (1:PARM-LENGTH) will equal 'ABC'.

After moving PARM-NAME (1:PARM-LENGTH) to WS-PARM-AREA (1:PARM-LENGTH), WS-PARM-AREA will equal 'ABC', padded with low-order SPACES (leave the VALUE SPACES clause for this field as-is).

This has been working the same way for over 25 years, since the introduction of VS/COBOL II and reference modification.

You must be doing something wrong.

Use the above example and it will work as described.

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

Global Moderator


Joined: 20 Oct 2006
Posts: 6967
Location: porcelain throne

PostPosted: Tue Nov 16, 2010 5:46 pm    Post subject:
Reply with quote

the ts keeps changing from s9(2) comp to s9(4) comp.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am
No new posts Cobol upgrade - source code missing f... gthmrj IBM Tools 1 Wed Apr 26, 2017 6:04 pm
No new posts COBOL Programming Sandpit? jodrisco COBOL Programming 6 Wed Apr 12, 2017 3:47 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us