BAdIs to handle synchronized declarations

These BAdIs are called every time a declaration is received from the International Customs Integration service. A declaration is synchronized every time it has been changed.

Document typeBAdI
Delivery/AEB/AES_ET_SYNC_04
Shipment/AEB/AES_ET_SYNC_05
Invoice/AEB/AES_ET_SYNC_06
Purchase document/AEB/AES_ET_SYNC_07
Incoming Invoice/AEB/AES_ET_SYNC_08
Freight order/AE1/AES_ET_SYNC_09
Other collectors (for manual created consignments)/AEB/AES_ET_SYNC_09
Material document/AEB/AES_ET_SYNC_10

A typical use case for this BAdI is to populate additional database fields in your SAP system with the customs registration number. The example below illustrates how to store this value in the "External ID 2"-field of a shipment (German: Transport).

  DATA:
    mrn_number        TYPE exti2,
    mrn_number_object TYPE REF TO /aeb/cl_01_char_35_nv.

*Read the MRN object from synchronized data. The object is of type /AEB/CL_01_CHAR_35_NV
  mrn_number_object = im_declaration->get_customs_registration_numbe( ).

 "Assign value of the MRN number to a variable
  IF NOT mrn_number_object IS INITIAL.
    mrn_number = mrn_number_object->v.

  "Define your own logic here according to your requirements
    UPDATE vttk SET exti2 = mrn_number WHERE tknum = im_tknum.

  ENDIF.

ID numbers of the SAP documents and items

If consignments are created manually in ICI, the link to the SAP document is established at item level. Consequently, the client system IDs can be accessed at item level within the synchronization BAdIs.

In addition, the public class /AEB/CL_01_PB_TID_DEF_BC (or /AE1/CL_01_PB_TID_DEF_BC for SAP S/4HANA–specific objects such as freight orders) is available. This class enables conversion of the client system ID into the corresponding SAP document number, thereby allowing access to the SAP document.

METHOD /aeb/if_ex_aes_et_sync_09~hdl_declaration_synchronized.
    DATA: items       TYPE /aeb/if_aes_pb_decl_item_do=>tt_decl_item_do,
          curr_item   TYPE REF TO /aeb/if_aes_pb_decl_item_do,
          ids         TYPE /aeb/01_char255s,
          curr_id     TYPE /aeb/01_char255,
          curr_id_str TYPE string,
          vbeln       TYPE vbeln,
          likp        TYPE likp,
          vbrk        TYPE vbrk.

    items = im_declaration->get_items( ).
    LOOP AT items INTO curr_item.
      ids = curr_item->get_client_system_ids_v1( ).
      LOOP AT ids INTO curr_id.
        curr_id_str = curr_id.
        vbeln = /aeb/cl_01_pb_tid_def_bc=>new( )->get_sap_doc_no_from_tid( curr_id_str ).
        IF /aeb/cl_01_pb_tid_def_bc=>new( )->is_tid_from_likp( curr_id_str ) = 'X'.
          SELECT SINGLE * FROM likp WHERE vbeln = @vbeln INTO @likp.
        ELSEIF /aeb/cl_01_pb_tid_def_bc=>new( )->is_tid_from_vbrk( curr_id_str ) = 'X'.
          SELECT SINGLE * FROM vbrk WHERE vbeln = @vbeln INTO @vbrk.
        ENDIF.
      ENDLOOP.
    ENDLOOP.
  ENDMETHOD.

Exceptions

All listed BAdIs support raising the exception /AEB/CX_AES_PB_ET_SYNC_SC as documented at Handle exceptions. When this exception is raised, the entire handling of the customs declaration—including standard processing—is treated as failed, resulting in an entry in the Function Call Monitor (FCC). Provided the relevant configuration is in place, this entry can be reprocessed automatically using the report /AEB/01_FCC_RETRY. Upon reprocessing (whether triggered automatically by the report or manually via the Function Call Monitor), the complete customs declaration is retransferred from the engine and processed again, and the BAdI is invoked once more.

List of fields

The folllowing fields are returned in the synchronization per declaration:

Technical field nameDescription
DECL_PROCEDURE_TYPE_CODEDeclaration procedure type
CLIENT_SPECIFIC_FIELDSCustomer-specific fields
ADDITIONAL_REFERENCE1Additional reference
AMOUNTS_OF_MONEYAmounts of money
ATTACHMENTSDocuments
BUSINESS_OBJECT_IDBusiness object ID
CLIENT_SYSTEM_IDInstallation ID
COMMERCIAL_REFERENCE_NUMBECommercial reference number
CONSIGNMENT_ID_CLIENT_SYSTHost system ID
CONSIGNMENT_NUMBERConsignment number
CUSTOMS_OFFICESCustoms offices
CUSTOMS_PROCESS_CODEE-customs system
CUSTOMS_REGISTRATION_NUMBECustoms registration number
DATESDates
DECISIVE_DATEDecisive date
DECLARATION_TYPECODEType of customs declaration
DECLARATION_VERSIONCustoms declaration version
DELIVERY_NUMBERDelivery number
DELIVERY_REFERENCESReference numbers of the deliveries in the declaration
DESTINATION_COUNTRY_CODEDestination country code
DISPATCH_COUNTRY_CODECountry of dispatch code
INVOICE_NUMBERInvoice number
IS_DELETEDDeleted flag
IS_VALIDValidity flag
ITEMSList of items
LOCAL_REFERENCELocal reference number (LRN)
ORG_UNITOrganizational unit
PARTIESList of parties
PERSON_IN_CHARGEContact
STATUSStatus
TOTAL_GROSSMASSGross weight
TOTAL_INVOICE_PRICEInvoice total amnount
TOTAL_NETMASSNet weight
TRANSPORT_MEANSModes of transport
INTERNAL_REFERENCE_V1Internal reference

The folllowing fields are returned in the synchronization per declaration item:

Technical field nameDescription
CUSTOMS_SPECIAL_PROCEDURESCustoms special procedures
CUSTOMS_PROCEDURESCustoms procedures
CLIENT_SPECIFIC_FIELDSList of client specific fields
AMOUNTS_OF_MONEYAmounts of money
CLASSIFICATIONSList of classifications
GOODS_DESCRIPTIONGoods description
GROSSMASSGross weight
NETMASSNet weight
PARTIESList of parties
QUANTITIESQuantities
SEQUENCE_NUMBERDeclaration item number
STATUSStatus
CLIENT_SYSTEM_IDS_V1Client system IDs of items in SAP