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

PARM field showing Junk value


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

New User


Joined: 31 Aug 2008
Posts: 31
Location: hyderabad

PostPosted: Wed Mar 16, 2011 3:34 pm
Reply with quote

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
View user's profile Send private message
Bill O'Boyle

CICS Moderator


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

PostPosted: Wed Mar 16, 2011 3:59 pm
Reply with quote

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
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Wed Mar 16, 2011 4:37 pm
Reply with quote

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
View user's profile Send private message
chatterjesis

New User


Joined: 31 Aug 2008
Posts: 31
Location: hyderabad

PostPosted: Wed Mar 16, 2011 4:38 pm
Reply with quote

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
View user's profile Send private message
chatterjesis

New User


Joined: 31 Aug 2008
Posts: 31
Location: hyderabad

PostPosted: Wed Mar 16, 2011 4:43 pm
Reply with quote

Thanks to both for the reply

MOVE PARM-DATA (1:PARM-LENGTH) TO WS-PARM-DATA (1icon_smile.gif.

is also giving same output.

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

CICS Moderator


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

PostPosted: Wed Mar 16, 2011 4:46 pm
Reply with quote

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
View user's profile Send private message
Bill O'Boyle

CICS Moderator


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

PostPosted: Wed Mar 16, 2011 4:51 pm
Reply with quote

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
View user's profile Send private message
chatterjesis

New User


Joined: 31 Aug 2008
Posts: 31
Location: hyderabad

PostPosted: Wed Mar 16, 2011 5:42 pm
Reply with quote

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
View user's profile Send private message
Bill O'Boyle

CICS Moderator


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

PostPosted: Wed Mar 16, 2011 6:05 pm
Reply with quote

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
View user's profile Send private message
chatterjesis

New User


Joined: 31 Aug 2008
Posts: 31
Location: hyderabad

PostPosted: Wed Mar 16, 2011 9:07 pm
Reply with quote

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 icon_eek.gif
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


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

PostPosted: Wed Mar 16, 2011 9:35 pm
Reply with quote

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
View user's profile Send private message
chatterjesis

New User


Joined: 31 Aug 2008
Posts: 31
Location: hyderabad

PostPosted: Wed Mar 16, 2011 9:58 pm
Reply with quote

Hi Bill

Many thanks again for your quick response!

PARM='ABC.ABC_TABLE'

This is the value I passed....
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


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

PostPosted: Wed Mar 16, 2011 10:02 pm
Reply with quote

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
View user's profile Send private message
chatterjesis

New User


Joined: 31 Aug 2008
Posts: 31
Location: hyderabad

PostPosted: Wed Mar 16, 2011 11:05 pm
Reply with quote

passed
Code:


//STEP1 EXEC PGM=DISPARM,                                 
//             PARM='MYDDNME'                             



again length shown is 10 icon_sad.gif
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed Mar 16, 2011 11:44 pm
Reply with quote

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
View user's profile Send private message
don.leahy

Active Member


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

PostPosted: Thu Mar 17, 2011 12:30 am
Reply with quote

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
View user's profile Send private message
chatterjesis

New User


Joined: 31 Aug 2008
Posts: 31
Location: hyderabad

PostPosted: Thu Mar 17, 2011 7:54 am
Reply with quote

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 icon_confused.gif
Somehow the PARM data is notpassed at all and length comes 10 always...
Back to top
View user's profile Send private message
chatterjesis

New User


Joined: 31 Aug 2008
Posts: 31
Location: hyderabad

PostPosted: Thu Mar 17, 2011 7:58 am
Reply with quote

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
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Thu Mar 17, 2011 11:04 am
Reply with quote

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
View user's profile Send private message
chatterjesis

New User


Joined: 31 Aug 2008
Posts: 31
Location: hyderabad

PostPosted: Thu Mar 17, 2011 11:32 am
Reply with quote

used that too,after you said.... no luck icon_sad.gif
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: Thu Mar 17, 2011 5:50 pm
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu Mar 17, 2011 6:05 pm
Reply with quote

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
View user's profile Send private message
Jose Mateo

Active User


Joined: 29 Oct 2010
Posts: 121
Location: Puerto Rico

PostPosted: Thu Mar 17, 2011 7:15 pm
Reply with quote

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
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Thu Mar 17, 2011 7:20 pm
Reply with quote

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
View user's profile Send private message
Jose Mateo

Active User


Joined: 29 Oct 2010
Posts: 121
Location: Puerto Rico

PostPosted: Fri Mar 18, 2011 12:41 am
Reply with quote

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
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 Goto page 1, 2  Next

 


Similar Topics
Topic Forum Replies
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts JCL EXEC PARM data in C Java & MQSeries 2
No new posts Need to specify PARM='POSIX(ON) Java & MQSeries 4
No new posts How to pass the PARM value to my targ... COBOL Programming 8
Search our Forums:

Back to Top