How can I call a COBOL subroutine that attaches to DB2 with VISION:Results?

Document ID : KB000026054
Last Modified Date : 14/02/2018
Show Technical Document Details

You can use either TSO ATTACH or CALL ATTACH to connect to DB2 from a COBOL subroutine that is subordinate to VISION:Results rather than directly to DB2 from the VISION:Results DB2 interface. The connection to use depends on what attachment module was link-edited to the COBOL module. If this is not set up correctly -927 errors will be issued by DB2.


You can run AMBLIST to determine the connection that was used:

//LIST    EXEC    PGM=AMBLIST     DB2 CONNECTION                        
//SYSPRINT DD  SYSOUT=*                                                 
//SYSLIB   DD  DSN=your.user.loadlib,DISP=SHR                       
//SYSIN    DD  *                                                        
  LISTIDR MEMBER=yourCOBOLroutine           

CALL ATTACH:
If the COBOL module was link-edited with DSNALI, DB2 assumes the implicit connection of CALL ATTACH is going to be used. DB2 assumes a DB2 BIND has been executed with the plan name being the same name as the COBOL module name.

Use PGM=DYL280 on the EXEC statement.

The CALL ATTACH job must also include the PRIVATE.SDSNEXIT library in the loadlib concatenation. This is required to determine the DB2 Subsystem ID. Each DB2 Subsystem ID or DB2 Group Server ID has it own unique PRIVATE SDSNEXIT library.

TSO ATTACH:
If the COBOL module was link-edited with DSNELI, then TSO ATTACH must be used.

When DSNELI is link-edited, the DB2 BIND can use any plan name; it does not have to be the COBOL module name.
It is specified in the SYSTSIN input.

On the EXEC statement use PGM=IKJEFT01.
Add

//SYSTSPRT DD SYSOUT=* 
//SYSTSIN DD *                  
   DSN SYSTEM(your DB2 SSID)                                                  
     RUN PROGRAM(DYL280) PLAN(planname)              
   END                                                                        
/*