Coding a CICS online program in assembler language

The following code example in assembler language shows how you define and establish addressability to the UIB.

The numbers to the right of the program refer to the notes that follow the program. This program can run in a CICS® environment using DBCTL.

Sample call-level assembler language program (CICS online)

PGMSTART DSECT                                            						NOTES
UIBPTR   DS    F  
IOAREA   DS    0CL40                                              		 1 
AREA1    DS    CL3
AREA2    DS    CL37
         DLIUIB
         USING UIB,8                                              		 2 
PCBPTRS  DSECT 
*        PSB ADDRESS LIST
PCB1PTR  DS    F
PCB1     DSECT
         USING PCB1,6                                        				 3 
DBPC1DBD DS    CL8
DBPC1LEV DS    CL2
DBPC1STC DS    CL2
DBPC1PRO DS    CL4
DBPC1RSV DS    F
DBPC1SFD DS    CL8
DBPC1MKL DS    F
DBPC1NSS DS    F
DBPC1KFD DS    0CL256
DBPC1NM  DS    0CL12
DBPC1NMA DS    0CL14
DBPC1NMP DS    CL17
ASMUIB   CSECT
         B     SKIP
PSBNAME  DC    CL8'ASMPSB'
PCBFUN   DC    CL4'PCB'
REPLFUN  DC    CL4'REPL'
TERMFUN  DC    CL4'TERM'
GHUFUN   DC    CL4'GHU'
SSA1     DC    CL9'AAAA4444'
GOODRC   DC    XL1'00'
GOODSC   DC    CL2'  '
SKIP     DS    0H                                                  	 4 
*              SCHEDULE PSB AND OBTAIN PCB ADDRESSES
         CALLDLI ASMTDLI,(PCBFUN,PSBNAME,UIBPTR)
         L     8,UIBPTR                                       				 5 
         CLC   UIBFCTR,X'00'
         BNE   ERROR1
*              GET PSB ADDRESS LIST
         L     4,UIBPCBAL
         USING PCBPTRS,4
*              GET ADDRESS OF FIRST PCB IN LIST
         L     6,PCB1PTR
*              ISSUE DL/I CALL: GET A UNIQUE SEGMENT
         CALLDLI ASMTDLI,(GHUFUN,PCB1,IOAREA,SSA1)                		 6 
         CLC   UIBFCTR,GOODRC 
         BNE   ERROR2 
         CLC   DBPC1STC,GOODSC
         BNE   ERROR3                                            		 7 
*              PERFORM SEGMENT UPDATE ACTIVITY
         MVC   AREA1,.......
         MVC   AREA2,.......
*              ISSUE DL/I CALL: REPLACE SEGMENT AT CURRENT POSITION
         CALLDLI ASMTDLI,(REPLFUN,PCB1,IOAREA,SSA1)               		 8 
         CLC   UIBFCTR,GOODRC
         BNE   ERROR4
         CLC   DBPC1STC,GOODSC
         B     TERM
ERROR1   DS    0H
*              INSERT ERROR DIAGNOSTIC CODE
         B     TERM
ERROR2   DS    0H
*              INSERT ERROR DIAGNOSTIC CODE
         B     TERM
ERROR3   DS    0H
*              INSERT ERROR DIAGNOSTIC CODE
         B     TERM
ERROR4   DS    0H
*              INSERT ERROR DIAGNOSTIC CODE
ERROR5   DS    0H
*              INSERT ERROR DIAGNOSTIC CODE
         B     TERM
TERM     DS    0H
*              RELEASE THE PSB
         CALLDLI ASMDLI, (TERMFUN)
         EXEC CICS RETURN
         END   ASMUIB                               								 9,10 
Note:
  1. The program must define an I/O area that is large enough to contain the largest segment it is to retrieve or insert (or the largest path of segments if the program uses the D command code).
  2. The DLIUIB statement copies the UIB DSECT.
  3. A fullword must be defined for each DB PCB. The assembler language program can access status codes after a DL/I call by using the DB PCB base addresses.
  4. This is an unqualified SSA. For qualified SSA, define each part of the SSA separately so that the program can modify the fields of the SSA.
  5. This call schedules the PSB and obtains the PSB address.
  6. This call retrieves a segment from the database.
    CICS online assembler language programs use the CALLDLI macro, instead of the call statement, to access DL/I databases. This macro is similar to the call statement. It looks like this:
    CALLDLI ASMTDLI,(function,PCB-name,ioarea, SSA1,...SSAn),VL
  7. CICS online programs must check the return code in the UIB before checking the status code in the DB PCB.
  8. The REPL call replaces the data in the segment that was retrieved by the most recent Get Hold call. The data is replaced by the contents of the I/O area referenced in the call.
  9. This call releases the PSB.
  10. The RETURN statement loads IMS™ registers and returns control to IMS.

Related reading: For more information on installing CICS application programs, see CICS Transaction Server for z/OS® CICS Application Programming Reference.