Previous Topic: Sample Cooperative ApplicationNext Topic: Dialog B:  Server listing (Mainframe)


Program A: Client Listing (PC)

!*********************************************************************
    !
    ! This module sends up the employee ID and receives employee
    ! data back from mainframe server dialog A240D1.

            LOCAL  Emp_data_group  DICT.

            SHOW TEXT '&nAccessing. remote server ...'.

    ! Since we are going to use this data in some meaningful fashion we
    ! define a formatted conversation. Note the use of "FORMAT". This
    ! means that all data is automatically translated from PC data types
    ! to mainframe data types. IBM APPC LU 6.2 calls for the use of a return
    ! code to verify the state of a particular APPC verb. We use "Appccode".

(A1)        ALLOCATE CONNECT 'SYSTEM55' TPN 'A240D1' FORMAT.
              AFTER Comm-error CALL SR_Abend.

    ! Note the use of a local subroutine called SR_Abend.
    !
    ! Let's send up the employee ID.
    !

(A2)        SEND-DATA Emp_id.
              AFTER Comm-error CALL SR_Abend.
    !
    ! "Turn the line around" and wait for server to send down
    !  the requested data.  This flushes the communications
    !  buffer and passes control to the server dialog.

(A3)        RECEIVE-AND-WAIT Emp_data_group.
    !
    ! If an employee was not found, then the server's SEND-ERROR
    ! shows PROG-ERROR at the client side of the conversation.
    !
            AFTER Prog-error
             DO.
              ! One more receive to get the deallocate state...
(A4)          RECEIVE-AND-WAIT.
                AFTER Deallocate-normal
                  DO.
(A5)                DEALLOCATE LOCAL.
                      AFTER Comm-error CALL SR_Abend.
                    INITIALIZE ( emp_first_name, emp_last_name,
                                 office_code, emp_street, emp_city,
                                 emp_state, emp_zip_first_five, status ).
                    DISPLAY TEXT '&wEmployee. not on file. Try again.'.
                   END.
             END.
            IF Appccode LT 0 OR What-received NE 'DATA-COMPLETE'
               CALL SR_Abend.
    !
    ! We seem to have received the data ok.
    !
    ! The server is still in control of the conversation, so we
    ! do one more receive-and-wait to receive the fact that the
    ! server has deallocated.  This puts the client in deallocate state,
    ! allowing the client to deallocate normally and regain control.
    !
(A6)        RECEIVE-AND-WAIT.
             AFTER Deallocate-normal
                DO.
(A7)              DEALLOCATE LOCAL.
                  ! Now move data to form fields and display it.
                  Emp_first_name     = Emp_data_group.emp_first_name.
                  Emp_last_name      = Emp_data_group.emp_last_name.
                  Emp_street         = Emp_data_group.emp_street.
                  Emp_city           = Emp_data_group.emp_city.
                  Emp_state          = Emp_data_group.emp_state.
                  Emp_zip_first_five = Emp_data_group.emp_zip_first_five.
                  Status             = Emp_data_group.status.
                  Office_code        = Emp_data_group.office_code.

                  DISPLAY FIELD Emp_id TEXT ' '.
                END.

            AFTER Comm-error CALL SR_Abend.

    !******* Local subroutine  *********

     DEFINE SR_Abend.

         SHOW TEXT '&cComm. Error. APPCCODE='&svb.&svb. Appccode
                    &svb.&svb. ', APPCERC=' &svb.&svb. Appcerc.
(A8)     DEALLOCATE ABEND.
         DISPLAY.
    !