Statically Linking a COBOL Routine with a PL/I Main Program

The following example demonstrates a PL/I CICS program, and COBOL subroutine being compiled and statically linked together.

Source Program (T23652P.pli):

 T23652P: PROC() OPTIONS(MAIN);                                                 
  DCL 1 COBPARM,                                                                
        2 COBCODE   CHAR(3),                                                    
        2 COBNAME   CHAR(30),                                                   
        2 COBSTAT   FIXED BIN(15);                                              
  DCL T23652C ENTRY OPTIONS(COBOL);                                             
    EXEC CICS WRITE OPERATOR TEXT('T23652P starts');                            
    COBCODE = "AAA";                                                            
    EXEC CICS WRITE OPERATOR TEXT('T23652P - T23652C');                         
    CALL T23652C (COBPARM);                                                     
    EXEC CICS WRITE OPERATOR TEXT(COBNAME);                                     
    EXEC CICS WRITE OPERATOR TEXT('T23652P end');                               
  END T23652P;      

Source Program (T23652C.cbl ):

       working-storage section.                                                 
       linkage section.                                                         
       01  lk-params.                                                           
           05 lk-code pic X(3).                                                 
           05 lk-name pic X(30).                                                
           05 lk-stat pic S9(4) COMP.                                           
       procedure division using lk-params.                                      
           evaluate lk-code                                                     
           when "AAA" move "T23652C is called with AAA" to lk-name              
           when "BBB" move "T23652C is called with BBB" to lk-name              
           when "CCC" move "T23652C is called with CCC" to lk-name              
           when other move spaces to lk-name                                    
           end-evaluate.                                                        
           goback.     

Commands:

export 
COBMODE=32                                                               
mfplx -cics -c T23652P.pli -o 
T23652P.o                                         
cob -xc 
T23652C.cbl                                                             
cob -z,PLI T23652P.o T23652C.o $COBDIR/lib/32/systemcics.o