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
 

 

PARM field showing Junk value
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: PARM field showing Junk value
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Wed Mar 16, 2011 3:59 pm    Post subject: Reply to: PARM field showing Junk value
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: 1278
Location: Belgium

PostPosted: Wed Mar 16, 2011 4:37 pm    Post subject:
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    Post subject:
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    Post subject:
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Wed Mar 16, 2011 4:46 pm    Post subject: Reply to: PARM field showing Junk value
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Wed Mar 16, 2011 4:51 pm    Post subject: Reply to: PARM field showing Junk value
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    Post subject:
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Wed Mar 16, 2011 6:05 pm    Post subject: Reply to: PARM field showing Junk value
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    Post subject:
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Wed Mar 16, 2011 9:35 pm    Post subject: Reply to: PARM field showing Junk value
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    Post subject:
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: 2502
Location: Atlanta, Georgia, USA

PostPosted: Wed Mar 16, 2011 10:02 pm    Post subject: Reply to: PARM field showing Junk value
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    Post subject:
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: 7908
Location: Bellevue, IA

PostPosted: Wed Mar 16, 2011 11:44 pm    Post subject:
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: 641
Location: Whitby, ON, Canada

PostPosted: Thu Mar 17, 2011 12:30 am    Post subject:
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    Post subject:
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    Post subject:
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: 1713
Location: UK

PostPosted: Thu Mar 17, 2011 11:04 am    Post subject:
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    Post subject:
Reply with quote

used that too,after you said.... no luck icon_sad.gif
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
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts How to split the records using the am... vnktrrd DFSORT/ICETOOL 24 Fri Oct 28, 2016 7:33 pm
No new posts Sort records based on numeric field. Alks SYNCSORT 2 Wed Oct 19, 2016 10:14 pm
No new posts Amount field is getting corrupted whe... thesumitk SYNCSORT 5 Tue Oct 18, 2016 8:20 pm
No new posts Syncsort - NULL in Integer field chec... nartcr SYNCSORT 4 Thu Oct 06, 2016 6:47 am


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