COBOL-DB2 program is processing SYSTSIN passed PARM.



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

COBOL-DB2 program is processing SYSTSIN passed PARM.

Postby rahulkrddd » Sat Aug 18, 2018 4:32 pm

Dear All,
I have a query, I'm not able to access PARM parameter passed thru SYSTSIN in COBOL-DB2 program. Below is my program-

003120        LINKAGE SECTION.                                                
003130        01 PARM-BUFFER.                                                  
003140           02 PARM-LENGTH          PIC S9(4) COMP.                      
003150           02 PARM-NAME            PIC X(10).                            
003200        PROCEDURE DIVISION USING PARM-BUFFER.                            
003202            DISPLAY 'LENGTH OF THE PARM IS: ' PARM-LENGTH.              
003203            DISPLAY 'VALUE OF PARM PARAMETER IS: 'PARM-NAME.            
003206            INSPECT PARM-NAME TALLYING WS-COUNTER1 FOR CHARACTERS        
003207                                             BEFORE INITIAL SPACE.      
003208            INSPECT PARM-NAME TALLYING WS-COUNTER2 FOR ALL SPACES.      
003209            DISPLAY 'TOTAL WRITTEN CHARACTERS IN PARM = ' WS-COUNTER1.  
003210            DISPLAY 'TOTAL SPACES IN PARM ' PARM-NAME '=' WS-COUNTER2.  
003211            DISPLAY 'TOTAL CHARACTERS = 'WS-COUNTER1 ' + ' WS-COUNTER2.  


And my JCL has below code while running JCL using IKJEFT01 after successful compile and Bind -

000040 //SYSTSIN  DD   *                                                      
000041   DSN SYSTEM(DB2T)                                                      
000042   RUN PROGRAM(PROD7248) PLAN(CMNDBA) -                                      
000043   PARM('SATYA')                                                        
000044   END                                                                  
000045 /*                                                                      


In SYSOUT I'm getting below result-
********************************* TOP OF DATA **********************************
********************************* TOP OF DATA **********************************
LENGTH OF THE PARM IS: 0005                                                    
VALUE OF PARM PARAMETER IS: SATYA                                              
TOTAL WRITTEN CHARACTERS IN PARM = 0                                            
TOTAL SPACES IN PARM SATYA     =0                                              
TOTAL CHARACTERS = 0 + 0                                                                                                      
 


Ideally I should have got -
********************************* TOP OF DATA **********************************
LENGTH OF THE PARM IS: 0005                                                    
VALUE OF PARM PARAMETER IS: SATYA                                              
TOTAL WRITTEN CHARACTERS IN PARM = 5                                            
TOTAL SPACES IN PARM SATYA     =5                                              
TOTAL CHARACTERS = 5 + 5                                                                                                      
 


Please let me know if there is any other alternative to pass the values, kindly note that I can not use SYSIN control card here. I also tried to MOVE the data from PARM-NAME (Linkage variable) to WSS but I'm getting blank. Please help
rahulkrddd
 
Posts: 9
Joined: Sat Jul 28, 2018 3:31 pm
Has thanked: 1 time
Been thanked: 0 time

Re: COBOL-DB2 program is processing SYSTSIN passed PARM.

Postby enrico-sorichetti » Sat Aug 18, 2018 10:28 pm

topic has been cleaned of the useless garbage

the length and the content of the data - for the part corresponding to the length -
are according to the PARM passing specifications


the TS is trying to access/use data beyond the length of the passed data
( using inspect or whatever other programming construct is irrelevant )

the TS should fix the program to use only the data for the length passed

enough time wasted on the issue
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times

Re: COBOL-DB2 program is processing SYSTSIN passed PARM.

Postby NicC » Sun Aug 19, 2018 3:35 pm

You say
I'm not able to access PARM parameter

but the DISPLAYs in your program show
LENGTH OF THE PARM IS: 0005                                                    
VALUE OF PARM PARAMETER IS: SATYA                                              

so you are able to access the parameter.
What you are cofusing yourself with is that although you specify X(10) for PARM in the LINKAGE SECTION the actual length is X(5). There are no trailing bytes. If you move the value into your WORKING-STORAGE then it will be 5, 10 or however many bytes there are in the variable that you move it to.

Try putting delimiters around the variabkle that you are DISPLAYing - always e.g.
DISPLAY 'Value of xyz-var is >'xyz-var'<'
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: COBOL-DB2 program is processing SYSTSIN passed PARM.

Postby enrico-sorichetti » Sun Aug 19, 2018 3:50 pm

the TS problem is that the WS-COUNTERs are defined as PIC 9 ( one digit )
the cobol inspect would have returned 10

the bytes after the 5 chars are binary zeroes
as can be seen ( SDSF - SET HEX ON )

the TS is too busy trying to demonstrate that he is right
rathe than trying to understand the explanations given

If you move the value into your WORKING-STORAGE

the problem is that the TS used a straight move instead of using the byte reference
something like ...
   
MOVE SPACES TO WS-PARM-DATA.
MOVE PARM-DATA(1:PARM-LENGTH) TO WS-PARM-DATA(1:PARM-LENGTH).  
 


might as well lock the topic, will end in a flame war
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2994
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 164 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post