APPC (Advanced Program-to-Program Communication), also known as LU 6.2, is an IBM Systems Network Architecture (SNA) protocol that enables programs running on different systems to communicate with each other. In CICS, APPC provides the foundation for distributed transaction processing, allowing CICS applications to communicate with other CICS systems or non-CICS systems over a network.
APPC is an implementation of the SNA LU 6.2 protocol that allows peer-to-peer communication between application programs. Unlike traditional hierarchical SNA networks, APPC enables programs on different systems to communicate directly, making it ideal for distributed computing environments.
Key characteristics of APPC:
Understanding APPC requires familiarity with several key concepts:
A Logical Unit (LU) is an SNA addressable unit that manages data exchange between end users and the network. LU 6.2 is specifically designed for program-to-program communication:
A session is a logical connection established between two LUs. Sessions provide the physical pathway for conversations:
A conversation is the logical communication between two transaction programs (TPs). Unlike sessions, conversations are temporary and exist only while programs are exchanging data:
Transaction Programs are application programs that use APPC to communicate:
CICS supports APPC communication through several methods:
DTP allows CICS transactions to communicate synchronously with transactions in other systems:
123456789101112131415161718192021222324252627282930313233343536373839404142434445WORKING-STORAGE SECTION. 01 WS-CONVERSATION-ID PIC S9(8) COMP. 01 WS-RESPONSE PIC S9(8) COMP. 01 WS-DATA-BUFFER PIC X(100). 01 WS-DATA-LENGTH PIC S9(4) COMP. PROCEDURE DIVISION. * Allocate a conversation for DTP EXEC CICS ALLOCATE SYNCLEVEL(2) MODENAME('APPC01') CONVID(WS-CONVERSATION-ID) RESP(WS-RESPONSE) END-EXEC. IF WS-RESPONSE NOT EQUAL DFHRESP(NORMAL) EXEC CICS RETURN END-EXEC END-IF. * Send data to partner transaction MOVE 'Transaction data' TO WS-DATA-BUFFER MOVE 18 TO WS-DATA-LENGTH EXEC CICS SEND CONVID(WS-CONVERSATION-ID) FROM(WS-DATA-BUFFER) LENGTH(WS-DATA-LENGTH) RESP(WS-RESPONSE) END-EXEC. * Receive response EXEC CICS RECEIVE CONVID(WS-CONVERSATION-ID) INTO(WS-DATA-BUFFER) LENGTH(WS-DATA-LENGTH) RESP(WS-RESPONSE) END-EXEC. * Free the conversation EXEC CICS FREE CONVID(WS-CONVERSATION-ID) RESP(WS-RESPONSE) END-EXEC. EXEC CICS RETURN END-EXEC.
Key Points:
DPL allows a CICS program to call another program in a remote CICS region:
123456789101112131415161718192021222324252627WORKING-STORAGE SECTION. 01 WS-PROGRAM-NAME PIC X(8) VALUE 'REMOTEPG'. 01 WS-COMMAREA PIC X(100). 01 WS-COMMAREA-LENGTH PIC S9(4) COMP VALUE 100. 01 WS-RESPONSE PIC S9(8) COMP. PROCEDURE DIVISION. * Initialize commarea MOVE SPACES TO WS-COMMAREA MOVE 'Request data' TO WS-COMMAREA * Link to remote program EXEC CICS LINK PROGRAM(WS-PROGRAM-NAME) COMMAREA(WS-COMMAREA) LENGTH(WS-COMMAREA-LENGTH) RESP(WS-RESPONSE) END-EXEC. IF WS-RESPONSE NOT EQUAL DFHRESP(NORMAL) EXEC CICS RETURN END-EXEC END-IF. * Process response in COMMAREA * Remote program has updated COMMAREA with results EXEC CICS RETURN END-EXEC.
Transaction routing allows terminals connected to one CICS system to run transactions in another CICS system:
APPC conversations exist in specific states that determine what operations are allowed:
APPC supports three synchronization levels, each providing different guarantees:
No synchronization or confirmation:
Confirmation required for data delivery:
Full transaction synchronization with syncpoint coordination:
To use APPC in CICS, several resources must be defined:
Connections define the link between local and partner LUs:
Modes define the characteristics of conversations:
Transaction programs must be defined to handle inbound conversations:
Here's a complete example demonstrating APPC communication between two CICS systems:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495IDENTIFICATION DIVISION. PROGRAM-ID. APPCCONV01. AUTHOR. Mainframe Master. DATE-WRITTEN. 2024. ENVIRONMENT DIVISION. DATA DIVISION. WORKING-STORAGE SECTION. 01 WS-CONVERSATION-ID PIC S9(8) COMP. 01 WS-RESPONSE PIC S9(8) COMP. 01 WS-RESPONSE2 PIC S9(8) COMP. 01 WS-SYNCLEVEL PIC S9(4) COMP VALUE 2. 01 WS-MODE-NAME PIC X(8) VALUE 'APPC01'. 01 WS-DATA-BUFFER PIC X(200). 01 WS-DATA-LENGTH PIC S9(4) COMP. 01 WS-END-OF-CONVERSATION PIC X(1) VALUE 'N'. PROCEDURE DIVISION. MAIN-PROCESSING. * Step 1: Allocate APPC conversation EXEC CICS ALLOCATE SYNCLEVEL(WS-SYNCLEVEL) MODENAME(WS-MODE-NAME) CONVID(WS-CONVERSATION-ID) RESP(WS-RESPONSE) RESP2(WS-RESPONSE2) END-EXEC. IF WS-RESPONSE NOT EQUAL DFHRESP(NORMAL) PERFORM ALLOCATION-ERROR EXEC CICS RETURN END-EXEC END-IF. * Step 2: Send request to partner transaction MOVE 'Customer inquiry request' TO WS-DATA-BUFFER MOVE 25 TO WS-DATA-LENGTH EXEC CICS SEND CONVID(WS-CONVERSATION-ID) FROM(WS-DATA-BUFFER) LENGTH(WS-DATA-LENGTH) RESP(WS-RESPONSE) END-EXEC. IF WS-RESPONSE NOT EQUAL DFHRESP(NORMAL) PERFORM SEND-ERROR EXEC CICS RETURN END-EXEC END-IF. * Step 3: Receive response from partner EXEC CICS RECEIVE CONVID(WS-CONVERSATION-ID) INTO(WS-DATA-BUFFER) LENGTH(WS-DATA-LENGTH) RESP(WS-RESPONSE) END-EXEC. IF WS-RESPONSE NOT EQUAL DFHRESP(NORMAL) PERFORM RECEIVE-ERROR EXEC CICS RETURN END-EXEC END-IF. * Step 4: Process the response * WS-DATA-BUFFER now contains the response from partner * Step 5: Issue syncpoint for level 2 conversations IF WS-SYNCLEVEL = 2 EXEC CICS SYNCPOINT RESP(WS-RESPONSE) END-EXEC END-IF. * Step 6: Free the conversation EXEC CICS FREE CONVID(WS-CONVERSATION-ID) RESP(WS-RESPONSE) END-EXEC. EXEC CICS RETURN END-EXEC. ALLOCATION-ERROR. EXEC CICS WRITE OPERATOR TEXT('APPC ALLOCATE failed') END-EXEC. SEND-ERROR. EXEC CICS WRITE OPERATOR TEXT('APPC SEND failed') END-EXEC. RECEIVE-ERROR. EXEC CICS WRITE OPERATOR TEXT('APPC RECEIVE failed') END-EXEC.
Proper error handling is critical for robust APPC applications:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960WORKING-STORAGE SECTION. 01 WS-CONVERSATION-ID PIC S9(8) COMP. 01 WS-RESPONSE PIC S9(8) COMP. 01 WS-RESPONSE2 PIC S9(8) COMP. 01 WS-ERROR-MESSAGE PIC X(80). PROCEDURE DIVISION. EXEC CICS ALLOCATE SYNCLEVEL(2) MODENAME('APPC01') CONVID(WS-CONVERSATION-ID) RESP(WS-RESPONSE) RESP2(WS-RESPONSE2) END-EXEC. EVALUATE WS-RESPONSE WHEN DFHRESP(NORMAL) * Success - continue processing CONTINUE WHEN DFHRESP(INVREQ) * Invalid request - check parameters MOVE 'Invalid APPC request' TO WS-ERROR-MESSAGE PERFORM ERROR-HANDLER WHEN DFHRESP(NOTFND) * Connection or mode not found MOVE 'APPC connection not found' TO WS-ERROR-MESSAGE PERFORM ERROR-HANDLER WHEN DFHRESP(CONVFAILURE) * Conversation failure MOVE 'APPC conversation failure' TO WS-ERROR-MESSAGE PERFORM ERROR-HANDLER WHEN DFHRESP(NOSPACE) * No session available MOVE 'No APPC session available' TO WS-ERROR-MESSAGE PERFORM ERROR-HANDLER WHEN OTHER * Unexpected error MOVE 'Unexpected APPC error' TO WS-ERROR-MESSAGE PERFORM ERROR-HANDLER END-EVALUATE. ERROR-HANDLER. EXEC CICS WRITE OPERATOR TEXT(WS-ERROR-MESSAGE) END-EXEC. * Attempt to free conversation if allocated IF WS-CONVERSATION-ID NOT = 0 EXEC CICS FREE CONVID(WS-CONVERSATION-ID) RESP(WS-RESPONSE) END-EXEC END-IF. EXEC CICS RETURN END-EXEC.
Understanding when to use APPC versus other CICS communication methods:
Imagine you want to send a message to your friend who lives in another city:
First, you need to know their address (that's like the Partner LU - you need to know which computer system to talk to). Then you call them on the phone (that's like establishing a session - creating a connection between the two computers).
Once they answer, you start talking (that's like allocating a conversation - setting up the communication). You take turns talking and listening (that's like SEND and RECEIVE - exchanging information). Sometimes you ask "Did you hear me?" to make sure they got your message (that's like confirmation - checking that everything worked).
When you're done talking, you say "Goodbye" and hang up (that's like freeing the conversation - ending the communication and freeing up resources). The phone line stays connected (the session) so you can call again later without setting up the phone line again.
APPC Communication is like having a phone conversation between two computers. The computers need to know each other's addresses, establish a connection, have a conversation, make sure everything worked, and then end the conversation properly when they're done!
Write a COBOL program that:
Hint: Use the ALLOCATE, SEND, RECEIVE, ISSUE CONFIRMATION, and FREE commands. Check RESP codes after each command.
Enhance your APPC program to:
Compare the three APPC synchronization levels:
Answer: Level 0 for non-critical high-volume data (logging, monitoring), Level 1 for most business applications needing confirmation (order processing, inquiries), Level 2 for critical operations requiring full transaction integrity (financial transactions, inventory updates).
Research and explain:
1. What does APPC stand for?
2. What is the difference between a session and a conversation in APPC?
3. Which synchronization level provides the fastest data transfer?
4. What should you always do after an APPC conversation completes or encounters an error?
5. What is LU 6.2?
6. When would you use APPC instead of MRO?