Page 1 of 1

COBOL-DB2 program is processing SYSTSIN passed PARM.

PostPosted: Sat Aug 18, 2018 4:32 pm
by rahulkrddd
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

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

PostPosted: Sat Aug 18, 2018 10:28 pm
by enrico-sorichetti
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

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

PostPosted: Sun Aug 19, 2018 3:35 pm
by NicC
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'<'

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

PostPosted: Sun Aug 19, 2018 3:50 pm
by enrico-sorichetti
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