Special Linkage for DB2 Stored Procedure

I try to learn COBOL  a little bit more deeply with VISUAL COBOL,  But I feel hard to understand someone's code like this:

******************************************************

       identification division.
       program-id. gip2trbl.

       environment division.
       configuration section.

       data division.
       working-storage section.
       01 TRBLINP-TYPE          PIC  X(01).  
       01 TRBLINP-SEARCH-DATA   PIC  X(40).

       
       LINKAGE SECTION.                                 
       01 TRBLINP.                                       
           05 TRBLINP-IO-LEN      PIC S9(04) COMP-5.   
           05 TRBLINP-IO-TEXT     PIC X(41).       
       01 OUTDATA PIC X(41).

       PROCEDURE DIVISION USING  TRBLINP, OUTDATA  .
      

        UNSTRING  TRBLINP-IO-TEXT (1:TRBLINP-IO-LEN)
       DELIMITED BY '><'                        
       INTO  TRBLINP-TYPE ,
       TRBLINP-SEARCH-DATA .       
                       
       
        move  TRBLINP-IO-TEXT  to  OUTDATA.    
   
           goback.
           
       end program gip2trbl.

**************************************************************

Then I created DB2 stored procedure on DB2 V10.5

I passed "1><611016007800011"  into stored procedure. 

I expected  TRBLINP-IO-LEN having the real length of the string which I passed  and TRBLINP-IO-TEXT has original string value.

I use out parameter to verify TRBLINP-IO-TEXT.  but I only get "<611016007800011",   not "1><611016007800011"


Could someone explain to me how to make it working correctly ?

Really appreciated.

Parents
  • Verified Answer

    Thank you Chris,

    I figured it out --

    //////////////////////////////////////////////////////////////////////

          LINKAGE SECTION.                                

          01 TRBLINP.                                      

              05 TRBLINP-IO-LEN      PIC S9(04) COMP-5.  

              05 TRBLINP-IO-TEXT     PIC X(41).      

          01 OUTDATA PIC X(41).

          PROCEDURE DIVISION USING  TRBLINP, OUTDATA  .

          UNSTRING  TRBLINP-IO-TEXT (1:TRBLINP-IO-LEN)

          DELIMITED BY '><'                        

          INTO  TRBLINP-TYPE ,

          TRBLINP-SEARCH-DATA .                          

           move  TRBLINP-IO-TEXT  to  OUTDATA.    

    /////////////////////////////////////////////////////////////////////////////////////

    CREATE PROCEDURE "GIP2TRBL" (INOUT TRBLINP VARCHAR(41),

    OUT OUTDATA  CHAR(41) )

    Tested ON  Z/OS mainframe , DB2 V10.1

    Tested with Visual COBOL,  ON WINDOWS 10 , DB2 V10.5 (EXPRESS-C)

    I got the same result:

    At beginning,  I make a mistake as:

    CREATE PROCEDURE "GIP2TRBL" (INOUT TRBLINP CHAR(41), OUT OUTDATA  CHAR(41) )

    Now,  correct it as:

    CREATE PROCEDURE "GIP2TRBL" (INOUT TRBLINP VARCHAR(41), OUT OUTDATA  CHAR(41) )

    Thank you again,

    -Jack

Reply
  • Verified Answer

    Thank you Chris,

    I figured it out --

    //////////////////////////////////////////////////////////////////////

          LINKAGE SECTION.                                

          01 TRBLINP.                                      

              05 TRBLINP-IO-LEN      PIC S9(04) COMP-5.  

              05 TRBLINP-IO-TEXT     PIC X(41).      

          01 OUTDATA PIC X(41).

          PROCEDURE DIVISION USING  TRBLINP, OUTDATA  .

          UNSTRING  TRBLINP-IO-TEXT (1:TRBLINP-IO-LEN)

          DELIMITED BY '><'                        

          INTO  TRBLINP-TYPE ,

          TRBLINP-SEARCH-DATA .                          

           move  TRBLINP-IO-TEXT  to  OUTDATA.    

    /////////////////////////////////////////////////////////////////////////////////////

    CREATE PROCEDURE "GIP2TRBL" (INOUT TRBLINP VARCHAR(41),

    OUT OUTDATA  CHAR(41) )

    Tested ON  Z/OS mainframe , DB2 V10.1

    Tested with Visual COBOL,  ON WINDOWS 10 , DB2 V10.5 (EXPRESS-C)

    I got the same result:

    At beginning,  I make a mistake as:

    CREATE PROCEDURE "GIP2TRBL" (INOUT TRBLINP CHAR(41), OUT OUTDATA  CHAR(41) )

    Now,  correct it as:

    CREATE PROCEDURE "GIP2TRBL" (INOUT TRBLINP VARCHAR(41), OUT OUTDATA  CHAR(41) )

    Thank you again,

    -Jack

Children
No Data