Implementation of a Class for Processing Notifications (Class ZUD_RK_CONF)

Program Blocks

  • Determining the confirmation number from the handle of the notification

  • Reading the operation for the confirmation number

  • Reading the order number of the associated production order from the database

  • Determining the sequence number and operation number

  • Generating the confirmation using the BAPI BAPI_PRODORDCONF_CREATE_TT

  • Updating by calling the function module BAPI_TRANSACTION_COMMIT

ABAP Code of Method EXECUTE (Class ZUD_RK_CONF)

  1. Create the following parameters for the method:

    Parameter

    Type

    Data Type

    Optional

    Description

    IT_ERROR_MSG

    Import

    Type PCO_T_QUERY_MESSAGE_OBJ

    x

    Error messages for notification (object instance)

    IT_EXPR_DATA

    Import

    Type PCO_T_EXPR_DATA

    x

    PCo expression data

    IS_APPL_HANDLE

    Import

    Type PCO_S_APPL_HANDLE

    x

    PCo: Data structure for application handle

    IS_NOTIF_HEADER

    Import

    Type PCO_S_NOTIF_HEADER

    x

    PCo: Header data notification

    IV_TEST_MODE

    Import

    Type BOOLE_D

    x

    'X': Test mode

  2. Assign the exception class CX_PCO_BS_INT (PCo Suite Integration: Exception Class).

  3. Copy the following ABAP code to the method:

    METHOD execute.
      DATA:
        lt_conf        TYPE STANDARD TABLE OF bapi_pp_timeticket.
      DATA:
        ls_appl_handle TYPE pco_s_appl_handle,
        ls_cafko_ru    TYPE cafko_ru,
        ls_cafvc_ru    TYPE cafvc_ru,
        ls_afvc        TYPE afvc,
        ls_conf        TYPE bapi_pp_timeticket,
        ls_expr_data   TYPE pco_s_expr_data.
    
    * Get confirmation number from handle information
      ls_conf-conf_no = is_appl_handle-handle.
    
      CALL FUNCTION 'CO_DB_CAFVC_RU_READ'
        EXPORTING
          rueck_imp    = ls_conf-conf_no
        IMPORTING
          cafvc_ru_exp = ls_cafvc_ru
        EXCEPTIONS
          not_found    = 1
          OTHERS       = 2.
      IF sy-subrc <> 0.
        RAISE EXCEPTION TYPE cx_pco_bs_int
          EXPORTING
            textid      = cx_pco_bs_int=>error_query_exec
            error_cause = 'Error reading order data'.
      ENDIF.
    * Determine order number
      SELECT SINGLE aufnr FROM afko INTO ls_conf-orderid
         WHERE
           aufpl = ls_cafvc_ru-aufpl.
    
    * Determine order operation data for which confirmation shall
    * be executed
      SELECT SINGLE * FROM afvc INTO ls_afvc
        WHERE
          aplzl = ls_cafvc_ru-aplzl AND
          aufpl = ls_cafvc_ru-aufpl.
    
      ls_conf-sequence = ls_afvc-plnfl.
      ls_conf-operation = ls_afvc-vornr.
    
      LOOP AT it_expr_data INTO ls_expr_data.
        CASE ls_expr_data-name.
          WHEN 'UD_CONF_QUANT'.
            ls_conf-yield = ls_expr_data-value.
          WHEN 'UD_CONF_SCRAP'.
            ls_conf-scrap = ls_expr_data-value.
          WHEN 'UD_CONF_REWORK'.
            ls_conf-rework = ls_expr_data-value.
          WHEN 'UD_STATUS'.
            ls_conf-fin_conf = ls_expr_data-value.
        ENDCASE.
      ENDLOOP.
    
      INSERT ls_conf INTO TABLE lt_conf.
    
    * Use BAPI to create confirmation
      CALL FUNCTION 'BAPI_PRODORDCONF_CREATE_TT'
        TABLES
          timetickets = lt_conf.
    
    * Execute COMMIT WORK
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
    ENDMETHOD.