View previous topic :: View next topic
|
Author |
Message |
chatterjesis
New User
Joined: 31 Aug 2008 Posts: 31 Location: hyderabad
|
|
|
|
I have a Cobol code,in which i am trying to count number of lines of a flat file and trying to display it with the name of the flat file.
I am passing the name of the flat file through PARM.Below is the cobol program partly
Code: |
LINKAGE SECTION.
01 PARM-BUFFER.
05 PARM-LENGTH pic S9(4) COMP.
05 PARM-DATA pic X(40).
PROCEDURE DIVISION USING PARM-BUFFER.
PARA-1.
DISPLAY PARM-DATA.
DISPLAY PARM-LENGTH.
INITIALIZE WS-PARM-DATA.
MOVE PARM-DATA TO WS-PARM-DATA.
|
Then later i am writing the values in the out file.
The JCL I have used looks like,
Code: |
//STEP1 EXEC PGM=DISPARM,
// PARM='ABC_TABLE'
//STEPLIB DD DISP=SHR,DSN=loadlib name
//IN1 DD DSN=S45763.input file,DISP=OLD
//OUT1 DD DSN=output file,DISP=MOD
//* DISP=(NEW,CATLG,DELETE),
//* SPACE=(CYL,(10,10),RLSE,,ROUND),
//* UNIT=SYSDA
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//CEEDUMP DD SYSOUT=*
|
The output i am getting in sysout and out file is like below
Code: |
TABLE : C " 0 " 0 " 0 " 0 " COUNT : 00721
|
also the parm length value is coming as 10
Can anyone please help.If you need any more information please let me know.
[/quote] |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
You need to verify PARM-LENGTH exceeds ZERO and use REFERENCE MODIFICATION in the MOVE -
Code: |
MOVE PARM-DATA (1:PARM-LENGTH) TO WS-PARM-DATA (1:PARM-LENGTH).
|
Also, define PARM-DATA and WS-PARM-DATA as PIC X(100), which is the maximum length of a JCL parm passed to a program.
Bill |
|
Back to top |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
I think better would be :
Code: |
MOVE PARM-DATA (1:PARM-LENGTH) TO WS-PARM-DATA (1:). |
otherwise beyond parm-length ws-parm-data is not initialized to spaces |
|
Back to top |
|
|
chatterjesis
New User
Joined: 31 Aug 2008 Posts: 31 Location: hyderabad
|
|
|
|
I coded it as below,
Code: |
LINKAGE SECTION.
01 PARM-BUFFER.
05 PARM-LENGTH pic S9(4) COMP.
05 PARM-DATA pic X(100).
PROCEDURE DIVISION USING PARM-BUFFER.
PARA-1.
DISPLAY PARM-DATA.
DISPLAY PARM-LENGTH.
MOVE PARM-DATA (1:PARM-LENGTH) TO
WS-PARM-DATA(1:PARM-LENGTH).
|
No luck still!
Its giving output like
Code: |
TABLE : รท COUNT : 00721
|
|
|
Back to top |
|
|
chatterjesis
New User
Joined: 31 Aug 2008 Posts: 31 Location: hyderabad
|
|
|
|
Thanks to both for the reply
MOVE PARM-DATA (1:PARM-LENGTH) TO WS-PARM-DATA (1.
is also giving same output.
Please help! |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Guy,
In the above posted code, WS-PARM-DATA is INITIALIZED, followed by the MOVE and the field remainder will contain the correct target data, based upon the INITIALIZE.
So, I believe the contents of WS-PARM-DATA will be OK....
Bill |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Try issuing a DISPLAY of WS-PARM-DATA after the MOVE.
Also, when displaying PARM-DATA, you need to use reference modification.
Under the covers, PARM-DATA is a variable-length field in LINKAGE and so, this is why you must use PARM-LENGTH in the display of PARM-DATA as its contents is based solely upon the value/length in PARM-LENGTH.
Bill |
|
Back to top |
|
|
chatterjesis
New User
Joined: 31 Aug 2008 Posts: 31 Location: hyderabad
|
|
|
|
On displaying the linkage value before and after move along with PARM length below could be seen in SYSOUT
Code: |
C " 0 " 0 " 0 " 0 " 0 " 0 " 0 " 0 C
00010
|
the parm length is coming as 10 though the value i am passing is not of length 10.is it becuase s9(4) comp.
both the linkage parm and ws-parm shows junk value still. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
You should be issuing -
Code: |
DISPLAY 'PARM-DATA IS: ', PARM-DATA (1:PARM-LENGTH)
MOVE PARM-LENGTH TO WS-LENGTH
DISPLAY 'PARM-LENGTH: ', WS-LENGTH
MOVE SPACES TO WS-PARM-DATA
MOVE PARM-DATA (1:PARM-LENGTH) TO WS-PARM-DATA (1:PARM-LENGTH).
DISPLAY 'WS-PARM-DATA: ', WS-PARM-DATA
*
03 WS-LENGTH PIC 9(03).
03 WS-PARM-DATA PIC X(100).
|
The readable display of PARM-DATA and WS-PARM-DATA should be EQUAL.
Please confirm....
Bill |
|
Back to top |
|
|
chatterjesis
New User
Joined: 31 Aug 2008 Posts: 31 Location: hyderabad
|
|
|
|
Bill,
Thanks for you help.
I have used the same code given by you.
Which is giving below output at sysout.
Code: |
PARM-DATA IS:
PARM-LENGTH: 010
WS-PARM-DATA:
|
The code I used is as below,
Code: |
WORKING-STORAGE SECTION.
01 MESSAGE-TEXT.
05 FILLER PIC X(10) VALUE 'TABLE : '.
05 WS-PARM-DATA PIC X(100).
05 FILLER PIC X(10) VALUE 'COUNT : '.
05 WS-COUNT PIC 9(5) VALUE 0.
01 WS-LENGTH PIC 9(3).
77 WS002-FILE-STATUS PIC X(2) VALUE SPACES.
77 WS001-FILE-STATUS PIC X(2) VALUE SPACES.
01 EOF PIC X(5) VALUE 'FALSE'.
01 FILE-REC PIC X(130).
LINKAGE SECTION.
01 PARM-BUFFER.
05 PARM-LENGTH pic S9(4) COMP.
05 PARM-DATA pic X(100).
PROCEDURE DIVISION USING PARM-BUFFER.
PARA-1.
DISPLAY 'PARM-DATA IS: ', PARM-DATA (1:PARM-LENGTH)
MOVE PARM-LENGTH TO WS-LENGTH
DISPLAY 'PARM-LENGTH: ', WS-LENGTH
MOVE SPACES TO WS-PARM-DATA
MOVE PARM-DATA (1:PARM-LENGTH) TO WS-PARM-DATA
(1:PARM-LENGTH).
DISPLAY 'WS-PARM-DATA: ', WS-PARM-DATA.
PARA-2.
OPEN EXTEND FILE2.
OPEN INPUT TRANS-FILE.
READ TRANS-FILE AT END MOVE 'TRUE' TO EOF
IF WS001-FILE-STATUS = 00
DISPLAY "File READ STARTED."
CONTINUE
ELSE
DISPLAY "WS-ERROR While reading file"
END-IF.
PERFORM UNTIL EOF = 'TRUE'
ADD 1 to WS-COUNT
READ TRANS-FILE AT END MOVE 'TRUE' TO EOF
END-READ
END-PERFORM.
MOVE MESSAGE-TEXT TO FILE-REC
WRITE FILE2-DET FROM FILE-REC
IF WS002-FILE-STATUS = 00
DISPLAY "File WRITTEN SUCCESSFULLY."
CONTINUE
ELSE
DISPLAY "WS-ERROR While WRITING file"
END-IF.
CLOSE FILE2.
STOP RUN.
|
I am not sure why its not coming |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
What's the PARM value you're passing in the JCL? Apparently, there's 10-bytes of "something" because the displayed-length is 010?
I'm at a loss....
Bill |
|
Back to top |
|
|
chatterjesis
New User
Joined: 31 Aug 2008 Posts: 31 Location: hyderabad
|
|
|
|
Hi Bill
Many thanks again for your quick response!
PARM='ABC.ABC_TABLE'
This is the value I passed.... |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Yes, but that's 13-positions, so PARM-LENGTH should be 13, but it's displayed as 10?
Something is out of whack here.
Try passing the value 'MYDDNME' and PARM-LENGTH should be 7.
Bill |
|
Back to top |
|
|
chatterjesis
New User
Joined: 31 Aug 2008 Posts: 31 Location: hyderabad
|
|
|
|
passed
Code: |
//STEP1 EXEC PGM=DISPARM,
// PARM='MYDDNME'
|
again length shown is 10 |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
I changed your code slightly but it's working fine -- my move is to WS-PARM-DATA, not WS-PARM-DATA (1 : PARM-LENGTH):
Code: |
WORKING-STORAGE SECTION.
01 MESSAGE-TEXT.
05 FILLER PIC X(10) VALUE 'TABLE : '.
05 WS-PARM-DATA PIC X(100).
05 FILLER PIC X(10) VALUE 'COUNT : '.
05 WS-COUNT PIC 9(5) VALUE 0.
01 WS-LENGTH PIC 9(3).
77 WS002-FILE-STATUS PIC X(2) VALUE SPACES.
77 WS001-FILE-STATUS PIC X(2) VALUE SPACES.
01 EOF PIC X(5) VALUE 'FALSE'.
01 FILE-REC PIC X(130).
LINKAGE SECTION.
01 PARM-BUFFER.
05 PARM-LENGTH PIC S9(4) COMP.
05 PARM-DATA PIC X(100).
PROCEDURE DIVISION USING PARM-BUFFER.
PARA-1.
DISPLAY 'PARM-LENGTH: ' PARM-LENGTH.
DISPLAY 'PARM-DATA IS: ' PARM-DATA (1 : PARM-LENGTH).
MOVE PARM-LENGTH TO WS-LENGTH .
DISPLAY ' WS-LENGTH: ' WS-LENGTH .
MOVE SPACES TO WS-PARM-DATA .
MOVE PARM-DATA (1 : PARM-LENGTH)
TO WS-PARM-DATA .
DISPLAY 'WS-PARM-DATA: ' WS-PARM-DATA.
PARA-2. |
with run JCL of
Code: |
//STEP1 EXEC PGM=PROG01,REGION=0M,PARM=('THIS IS A LONG PARAMETER GX
// OING ON FOR A WHILE 12345678901234567890123456789012X
// 345678901234567890') |
gives expected results of
Code: |
PARM-LENGTH: 0100
PARM-DATA IS: THIS IS A LONG PARAMETER GOING ON FOR A WHILE 12345678901234567890123456789012345678901234567890
WS-LENGTH: 100
WS-PARM-DATA: THIS IS A LONG PARAMETER GOING ON FOR A WHILE 12345678901234567890123456789012345678901234567890 |
I also tested with a 3-byte and 10-byte parameter and got exactly what was passed in the PARM. |
|
Back to top |
|
|
don.leahy
Active Member
Joined: 06 Jul 2010 Posts: 765 Location: Whitby, ON, Canada
|
|
|
|
I ran a test using a very simple program that incorporated the same logic as the original poster's program, and it works as expected.
There must be something missing from the information provided by the OP. I can't think of what it might be other than something like running the wrong version of the program. i.e. the source code posted isn't what is being executed. |
|
Back to top |
|
|
chatterjesis
New User
Joined: 31 Aug 2008 Posts: 31 Location: hyderabad
|
|
|
|
I am not sure why,I did the same changes as suggested still getting below output.
Code: |
PARM-LENGTH: 00010
PARM-DATA IS:
WS-LENGTH: 010
WS-PARM-DATA:
|
What could be the problem
Somehow the PARM data is notpassed at all and length comes 10 always... |
|
Back to top |
|
|
chatterjesis
New User
Joined: 31 Aug 2008 Posts: 31 Location: hyderabad
|
|
|
|
Hi Don,
By wrong version what do you mean?
is it related to my cobol version?or something else.
I have pasted exactly what I am executing.....not sure why its not working?
what do you suggest now? |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
Did you put () around your parm - the only example I can see of yours does not have the parentheses but Robert' does? |
|
Back to top |
|
|
chatterjesis
New User
Joined: 31 Aug 2008 Posts: 31 Location: hyderabad
|
|
|
|
used that too,after you said.... no luck |
|
Back to top |
|
|
don.leahy
Active Member
Joined: 06 Jul 2010 Posts: 765 Location: Whitby, ON, Canada
|
|
|
|
chatterjesis wrote: |
Hi Don,
By wrong version what do you mean?
is it related to my cobol version?or something else.
I have pasted exactly what I am executing.....not sure why its not working?
what do you suggest now? |
I was questioning your results because not all of your DISPLAY output is consistent with the code you provided. In the latest example you gave us, PARM-LENGTH is shown as 00010 (5 digits rather than 4). The other reason I am questioning it is that two of us have now replicated your code (as you provided it) and we are not getting the same results. It is very unlikely that your mainframe is behaving differently than ours, which makes human error much more likely.
I would also like to suggest that when you show us your DISPLAY output, you also show it in HEX format. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Show us JCL, code, and output all from one run -- so we know exactly what you did and the results you got. |
|
Back to top |
|
|
Jose Mateo
Active User
Joined: 29 Oct 2010 Posts: 121 Location: Puerto Rico
|
|
|
|
Good day to all,
Put a 'X' in column 73 (continuation) on the exec line in the JCL and try it again. |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
Quote: |
Put a 'X' in column 73 (continuation) on the exec line in the JCL and try it again |
Why? Continuation marks occur in cc72 and should not be needed in this case - there is no over-run from line 1 of the exec statement to line 2. |
|
Back to top |
|
|
Jose Mateo
Active User
Joined: 29 Oct 2010 Posts: 121 Location: Puerto Rico
|
|
|
|
Thank you Mr. Clouston for correcting me (JCL is not one of my strong points) and my suggestion was a trail & error thing to see if it corrected the situation.
Chatterjesis, is this EXEC is it within a PROC? if it is then it might be that the EXEC PROC has a parm which nullify any other parm in the proc. |
|
Back to top |
|
|
|