COBOL

Expand all | Collapse all

CALL USING dynamic length item

  • 1.  CALL USING dynamic length item

    Posted 4 days ago
    Edited by Frank Swarbrick 4 days ago
    To successfully pass a dynamic length item to a called program you must specify the new "AS FIXED LENGTH" option on the CALL statement.  This works fine.  However the compiler gives no error if you omit the phrase, even though at run time the call (essentially) fails.  Seems like the compiler should not allow this behavior to compile "successfully".

    Also somewhat related.  The CICS co-processor does not give any "compile" error when an attempt is made to use a dynamic length item in an EXEC CICS statement, even though doing so is not supported.  And while I've not tested EXEC SQL, I imagine it has a similar issue.

    Speaking of which, is there anything in the works for CICS and DB2/SQL to support using dynamic length items?  I imagine there would have to be some sort of implicit conversion to/from fixed-length fields.

    ------------------------------
    Frank Swarbrick
    ------------------------------


  • 2.  RE: CALL USING dynamic length item

    Posted 3 days ago
    When you use a dynamic length variable as a host variable to hold the value of a Db2 VARCHAR, are you saying it does not work?

    ------------------------------
    Jon Butler
    ------------------------------



  • 3.  RE: CALL USING dynamic length item

    Posted 3 days ago
    Correct, it does not even compile.
    000013         001700 working-storage section.                                                  
    000014         001800 01  string-1                    pic x dynamic.                            
                                                                                                    
    000015         001900 01  string-80                   pic x(80).                                
    000016         002000 01  group-1.                                                              
    000017         002100     05                          pic x value quote.                        
                                                                                                    
    000018         002200     05  g-string                pic x dynamic length.                     
    000019         002300     05                          pic x value quote.                        
                                                                                                    
    000020         002400                                                                           
    000021         002500 procedure division.                                                       
    000022         002600     exec sql                                                              
                                                                                                    
    000022==> IGYPS0212-S SQL host variable reference "STRING-1" had invalid syntax or the          
                          referenced host variable was an invalid SQL variable type.  The statement 
                          was discarded.                                                            
                                                                                                    
    000023         002700         select 'This is a Db2 test'                                       
    000024         002800         into :string-1                                                    
    000025         002900         from sysibm.sysdummy1                                             
    000026         003000     end-exec                                                              ​


    ------------------------------
    Frank Swarbrick
    ------------------------------



  • 4.  RE: CALL USING dynamic length item

    Posted 3 days ago
    Bummer.  This would seem to be one place the DYNAMIC variables would be very useful, rather than the obtuse 49-level.

    ------------------------------
    Jon Butler
    ------------------------------



  • 5.  RE: CALL USING dynamic length item

    Posted 21 hours ago
    To support this I think they would need to support what's called a "dynamic length structure" in the COBOL 2014 standard.  Something link this:
     special-names.
         dynamic length structure VARCHAR is signed short prefixed.
    
     01  my-varchar  pic x dynamic VARCHAR limit 256.
    ​

    I have brought it up, but I've not received any commitment about it being implemented.



    ------------------------------
    Frank Swarbrick
    ------------------------------



  • 6.  RE: CALL USING dynamic length item

    Posted 19 hours ago
    I sent in the same request about a year ago, along with a request for SMALLINT, INTEGER, and BIGINT rather than the rather cryptic COMP-5 or TRUNC(BIN) compiler option, as well as user defined functions.  I got a reply saying they were considering a number of new features, but the interesting thing... to me...was the reply was from a chap with an IBM China address.

    ------------------------------
    Jon Butler
    ------------------------------



  • 7.  RE: CALL USING dynamic length item

    Posted 14 hours ago
    My communications have been with the compiler development team in Canada.  Some of who read this forum as well, so we'll see.  I agree that the COBOL true binary data types (binary-char, binary-short, binary-long and binary-double) would be preferable to what we have now.  I imagine its not much of a priority since comp-5 or whatever works "well enough" (except no support of one byte binary).  A matter of priorities I guess.

    ------------------------------
    Frank Swarbrick
    ------------------------------