View previous topic :: View next topic
|
Author |
Message |
sriraj1122
New User
Joined: 18 Dec 2008 Posts: 15 Location: Hyderabad
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
sriraj1122
New User
Joined: 18 Dec 2008 Posts: 15 Location: Hyderabad
|
|
|
|
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 |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
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 |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
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 |
|
|
sriraj1122
New User
Joined: 18 Dec 2008 Posts: 15 Location: Hyderabad
|
|
|
|
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 |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
the ts keeps changing from s9(2) comp to s9(4) comp. |
|
Back to top |
|
|
|