Skip to Content
Technical Articles
Author's profile photo Ravish Shetty R

How to replicate Location from SAP ERP to SAP Logistics Business Network

Introduction

In SAP ERP systems the location objects are not unified.  Location information resides in individual data object such as Customer, Plant, Business Partner, Shipping Point, Vendor and many more. For SAP Logistics Business Network Global Track and Trace option , the location master data from S/4 can synchronised out of the box since the location object is unified and extraction of location data via web service in already delivered. However, in SAP ERP  it is not case. If you still have a need to replicate location in SAP ERP, you may utilise the information mentioned in this blog to do so.

 

Location replication is achieved via SOAP webservice LocationBulkReplicateRequest_Out. This service is available in SAP ERP Since EHP7 onwards. By utilizing this interface and DRF replication framework, you can still replicate all necessary objects. In this blog we will provide information on location objects for below listed master data

  • Plant
  • Shipping Point
  • Business Partner
  • Vendor
  • Customer

Replication Plant and Shipping Point

Plant and shipping point, the implementation of DRF already exists. You may follow the steps already documented in the configuration guide here https://help.sap.com/viewer/b4724b2f483e439782b60cab4407c25a/LBN/en-US/86120107c3004203a5ff0c79643199a9.html Within manage location section.
However, use below listed BO Type and Outbound implementation for respecitive objects

Plant:

  •  BO Type:  464
  • Outbound Implementation: 464_L

Shipping Point:

  •  BO Type: DRF_0045
  •  Outbound Implementation:  DRF_0045

 

Replication of Business Partner

To achieve Business Partner replication, additional ABAP development needs to be done. Below objects must be created to achieve it.

Structure

  • ZDRF_S_BP_OUTBOUND

Table Type

  • ZDRF_T_BP_OUTBOUND

Class:

  • ZCL_BP_LOC_DRF_OUTBOUND
  • ZCL_BP_LOC_DRF_EXPL_FILTER

 Structure: ZDRF_S_BP_OUTBOUND

 

 

Table Type: ZDRF_T_BP_OUTBOUND

 

Creation of Classes

Go to transaction  se24 and create a new class with name as mentioned above(You might use any name. But make sure you adjust name in the source code as well). Use the default options while creating the class. Switch the editor to “Source Code-Based” by clicking on the corresponding button in the tool bar. Copy below source code and paste it to the class source code based-editor.

Class: ZCL_BP_LOC_DRF_OUTBOUND

class ZCL_BP_LOC_DRF_OUTBOUND definition
  public
  final
  create public .

public section.

  interfaces IF_DRF_OUTBOUND .
PROTECTED SECTION.

  TYPES:
    BEGIN OF tys_bp_data,
      partner    TYPE bu_partner,
      bu_langu   TYPE bu_langu,
      addrnumber TYPE ad_addrnum,
    END OF tys_bp_data .
  TYPES:
    tt_bp_data TYPE STANDARD TABLE OF tys_bp_data .
  TYPES:
    BEGIN OF tys_bp_data_txt,
      spras   TYPE spras,
      partner TYPE bu_partner,
      vtext   TYPE vtext,
    END OF tys_bp_data_txt .
  TYPES:
    tt_bp_data_txt TYPE STANDARD TABLE OF tys_bp_data_txt .
  TYPES:
    BEGIN OF tys_partner,
      partner TYPE bu_partner,
    END OF tys_partner .

  DATA mt_bp_address TYPE szadr_addr1_table .
  DATA mt_bp_data TYPE tt_bp_data .
  DATA mt_bp_data_txt TYPE tt_bp_data_txt .
  DATA ms_runtime_parameter TYPE drf_s_runtime_parameter_ext .
  DATA ms_loc_bulk_repl_req TYPE loc_bulk_replication_req .
  CONSTANTS mc_t_drf_loc_outb TYPE string VALUE 'ZDRF_T_BP_OUTBOUND'  ##NO_TEXT.
  CONSTANTS mc_s_drf_loc_outbound TYPE string VALUE 'ZDRF_S_BP_OUTBOUND' ##NO_TEXT.
  DATA mv_sender_bussystem_id TYPE sapplco_business_system_id .
  DATA mv_receiver_bussystem_id TYPE sapplco_business_system_id .
private section.

  methods FILL_MESSAGE_HEADER
    exporting
      !ES_MESSAGE_HEADER type SAPPLCO_BUS_DOC_MESSAGE_HEADER .
ENDCLASS.



CLASS ZCL_BP_LOC_DRF_OUTBOUND IMPLEMENTATION.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Private Method ZCL_BP_LOC_DRF_OUTBOUND->FILL_MESSAGE_HEADER
* +-------------------------------------------------------------------------------------------------+
* | [<---] ES_MESSAGE_HEADER              TYPE        SAPPLCO_BUS_DOC_MESSAGE_HEADER
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD FILL_MESSAGE_HEADER.
    DATA:
      lv_uuid                TYPE char32,
      lv_timestamp           TYPE timestampl.

    CLEAR es_message_header.

    GET TIME STAMP FIELD lv_timestamp.

    cl_gdt_conversion=>date_time_outbound(
      EXPORTING
        im_value_long = lv_timestamp
      IMPORTING
        ex_value       = es_message_header-creation_date_time               " Time Stamp According to ISO 8601
    ).

    es_message_header-sender_business_system_id    = mv_sender_bussystem_id.
    es_message_header-recipient_business_system_id = mv_receiver_bussystem_id.

    TRY.
        lv_uuid  = cl_system_uuid=>create_uuid_x16_static( ).
      CATCH cx_uuid_error.
        "Should never occur
        ASSERT 1 = 0.
    ENDTRY.
    es_message_header-id-content = lv_uuid.
    cl_gdt_conversion=>guid_outbound(
      EXPORTING
        im_guid_c = lv_uuid                                        " GUID in Character Display
      IMPORTING
        ex_value  = es_message_header-uuid-content                 " GUID / UUID in XML Display
    ).

  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_BP_LOC_DRF_OUTBOUND->IF_DRF_OUTBOUND~ANALYZE_CHANGES_BY_CHG_POINTER
* +-------------------------------------------------------------------------------------------------+
* | [--->] IT_CHANGE_POINTER              TYPE        DRF_T_BDCP
* | [<---] ES_STAT_INFO                   TYPE        DRF_S_STAT_INFO
* | [<-->] CT_CHANGED_OBJECTS             TYPE        SORTED TABLE
* | [!CX!] CX_DRF_ANALYZE_CHANGES
* | [!CX!] CX_DRF_EXCEPTION
* +--------------------------------------------------------------------------------------</SIGNATURE>
  method IF_DRF_OUTBOUND~ANALYZE_CHANGES_BY_CHG_POINTER.

  endmethod.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_BP_LOC_DRF_OUTBOUND->IF_DRF_OUTBOUND~ANALYZE_CHANGES_BY_MDG_CP
* +-------------------------------------------------------------------------------------------------+
* | [--->] IT_CHANGE_POINTER              TYPE        MDG_CP_T_CP
* | [<---] ES_STAT_INFO                   TYPE        DRF_S_STAT_INFO
* | [<-->] CT_CHANGED_OBJECTS             TYPE        SORTED TABLE
* | [!CX!] CX_DRF_ANALYZE_CHANGES
* | [!CX!] CX_DRF_EXCEPTION
* +--------------------------------------------------------------------------------------</SIGNATURE>
  method IF_DRF_OUTBOUND~ANALYZE_CHANGES_BY_MDG_CP.
  endmethod.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_BP_LOC_DRF_OUTBOUND->IF_DRF_OUTBOUND~ANALYZE_CHANGES_BY_OTHERS
* +-------------------------------------------------------------------------------------------------+
* | [<---] ES_STAT_INFO                   TYPE        DRF_S_STAT_INFO
* | [<-->] CT_CHANGED_OBJECTS             TYPE        SORTED TABLE
* | [!CX!] CX_DRF_ANALYZE_CHANGES
* | [!CX!] CX_DRF_EXCEPTION
* +--------------------------------------------------------------------------------------</SIGNATURE>
  method IF_DRF_OUTBOUND~ANALYZE_CHANGES_BY_OTHERS.

  endmethod.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_BP_LOC_DRF_OUTBOUND->IF_DRF_OUTBOUND~APPLY_NODE_INST_FILTER_MULTI
* +-------------------------------------------------------------------------------------------------+
* | [--->] IT_EXTERNAL_CRITERIA           TYPE        RSDS_TRANGE
* | [--->] IT_FOBJ                        TYPE        DRF_T_FOBJ_IMPL
* | [--->] IV_IGNORE_FILTER               TYPE        ABAP_BOOL (default =' ')
* | [<-->] CT_RELEVANT_OBJECTS            TYPE        SORTED TABLE
* | [!CX!] CX_DRF_PROCESS_MESSAGES
* | [!CX!] CX_DRF_EXCEPTION
* +--------------------------------------------------------------------------------------</SIGNATURE>
  method IF_DRF_OUTBOUND~APPLY_NODE_INST_FILTER_MULTI.

  endmethod.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_BP_LOC_DRF_OUTBOUND->IF_DRF_OUTBOUND~APPLY_NODE_INST_FILTER_SINGLE
* +-------------------------------------------------------------------------------------------------+
* | [--->] IT_EXTERNAL_CRITERIA           TYPE        RSDS_TRANGE
* | [--->] IT_FOBJ                        TYPE        DRF_T_FOBJ_IMPL
* | [--->] IV_IGNORE_FILTER               TYPE        ABAP_BOOL (default =' ')
* | [<---] EV_SKIP_OBJECT                 TYPE        ABAP_BOOL
* | [<-->] CR_RELEVANT_OBJECT             TYPE REF TO DATA
* | [!CX!] CX_DRF_PROCESS_MESSAGES
* | [!CX!] CX_DRF_EXCEPTION
* +--------------------------------------------------------------------------------------</SIGNATURE>
  method IF_DRF_OUTBOUND~APPLY_NODE_INST_FILTER_SINGLE.

  endmethod.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_BP_LOC_DRF_OUTBOUND->IF_DRF_OUTBOUND~BUILD_PARALLEL_PACKAGE
* +-------------------------------------------------------------------------------------------------+
* | [--->] IR_PREPARE_DATA                TYPE        DATA
* | [<---] ER_PACKAGE_DATA                TYPE        DATA
* | [<---] ES_TASK_PARAM                  TYPE        DRF_S_PARALLEL_TASK_PARAM
* | [<---] EV_ALL_TASKS_DONE              TYPE        ABAP_BOOL
* +--------------------------------------------------------------------------------------</SIGNATURE>
  method IF_DRF_OUTBOUND~BUILD_PARALLEL_PACKAGE.

  endmethod.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_BP_LOC_DRF_OUTBOUND->IF_DRF_OUTBOUND~ENRICH_FILTER_CRITERIA
* +-------------------------------------------------------------------------------------------------+
* | [--->] IT_EXTERNAL_CRITERIA           TYPE        RSDS_TRANGE
* | [<---] ET_ADD_EXTERNAL_CRITERIA       TYPE        RSDS_TRANGE
* | [<---] ES_STAT_INFO                   TYPE        DRF_S_STAT_INFO
* | [!CX!] CX_DRF_ENRICH_FILTER_PARAMETER
* | [!CX!] CX_DRF_EXCEPTION
* +--------------------------------------------------------------------------------------</SIGNATURE>
  method IF_DRF_OUTBOUND~ENRICH_FILTER_CRITERIA.


  endmethod.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_BP_LOC_DRF_OUTBOUND->IF_DRF_OUTBOUND~FINALIZE
* +-------------------------------------------------------------------------------------------------+
* | [--->] IT_RELEVANT_OBJECTS            TYPE        SORTED TABLE
* | [--->] IT_ERRONEOUS_OBJECTS           TYPE        SORTED TABLE
* | [--->] IV_REPEATED_INITIAL_RUN        TYPE        BOOLE_D
* | [<---] EV_DELETE_CHANGE_POINTER       TYPE        BOOLE_D
* +--------------------------------------------------------------------------------------</SIGNATURE>
  method IF_DRF_OUTBOUND~FINALIZE.

  endmethod.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Static Public Method ZCL_BP_LOC_DRF_OUTBOUND=>IF_DRF_OUTBOUND~INITIALIZE
* +-------------------------------------------------------------------------------------------------+
* | [--->] IS_RUNTIME_PARAM               TYPE        DRF_S_RUNTIME_PARAMETER_EXT
* | [<---] EO_IF_DRF_OUTBOUND             TYPE REF TO IF_DRF_OUTBOUND
* | [<---] ES_RUNTIME_PARAM_OUT_IMPL      TYPE        DRF_S_RUNTIME_PARAM_OUT_IMPL
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD IF_DRF_OUTBOUND~INITIALIZE.
**********************************************************************
*   Initialization of the DRF Outbound Implementation for Location
*   Replication
**********************************************************************
    DATA: ls_runtime_parameter TYPE drf_s_runtime_param_out_impl,
          lr_drf_loc_outbound  TYPE REF TO zcl_bp_loc_drf_outbound.

**********************************************************************
*   Initialize the exporting parameter
**********************************************************************
    CLEAR: eo_if_drf_outbound,
           es_runtime_param_out_impl.

**********************************************************************
*   Create an instance of myself in order to remember the runtime
*   parameters for all subsequent methods and pass it to the framework
**********************************************************************
    TRY.
        CREATE OBJECT lr_drf_loc_outbound.
      CATCH cx_sy_create_object_error.
        RETURN.
    ENDTRY.

    IF lr_drf_loc_outbound IS BOUND.
      lr_drf_loc_outbound->ms_runtime_parameter = is_runtime_param.
    ENDIF.

**********************************************************************
*   Set own runtime parameter
**********************************************************************
    ls_runtime_parameter-table_type_name = mc_t_drf_loc_outb.
    es_runtime_param_out_impl = ls_runtime_parameter.

**********************************************************************
*   Set Outbound Implementation
**********************************************************************
    eo_if_drf_outbound = lr_drf_loc_outbound.

  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_BP_LOC_DRF_OUTBOUND->IF_DRF_OUTBOUND~MAP_DATA2MESSAGE
* +-------------------------------------------------------------------------------------------------+
* | [--->] IR_RELEVANT_OBJECT             TYPE REF TO DATA
* | [--->] IS_BUS_SYS_TECH                TYPE        MDG_S_BUS_SYS_TECH(optional)
* | [!CX!] CX_DRF_PROCESS_MESSAGES
* | [!CX!] CX_DRF_EXCEPTION
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD IF_DRF_OUTBOUND~MAP_DATA2MESSAGE.
    DATA:
      lr_rel_obj         TYPE REF TO zdrf_s_bp_outbound,
      lv_timezone        TYPE tznzone,
      ls_loc_bulk        TYPE sapplco_loc_blk_repl_req_msg,
      ls_loc_repl_mess   TYPE sapplco_loc_repl_req_msg,
      lt_loc_repl_mess   TYPE sapplco_loc_repl_req_msg_tab,
      ls_loc_description TYPE sapplco_short_description,
      lv_loc_form_name   TYPE sapplco_languageindependent_me,
      ls_loc_tel         TYPE sapplco_telephone,
      ls_loc_facs        TYPE sapplco_facsimile,
      ls_loc_email       TYPE sapplco_nosc_email,
      ls_loc_web         TYPE sapplco_nosc_web,
      ls_loc_address     TYPE sapplco_nosc_address.

    FIELD-SYMBOLS:
      <ls_bp_addr1_data> TYPE addr1_data.

    lr_rel_obj ?= ir_relevant_object.

*   Fill Message Header for Bulk Service
    fill_message_header(
     IMPORTING
       es_message_header =  ls_loc_bulk-message_header ).

    READ TABLE mt_bp_data ASSIGNING FIELD-SYMBOL(<ls_bp_data>)
      WITH KEY partner = lr_rel_obj->partner.
    IF sy-subrc NE 0.
      RETURN.
    ENDIF.

*   Fill Message Header for Location Replication
    fill_message_header(
     IMPORTING
       es_message_header =  ls_loc_repl_mess-message_header ).

    CONCATENATE 'BP_' <ls_bp_data>-partner INTO ls_loc_repl_mess-location-location_internal_id.

*   Location Type Code for bpomer Location
    ls_loc_repl_mess-location-location_type_code = '1021'.

**********************************************************************
*   Address and Description
**********************************************************************
    READ TABLE mt_bp_address ASSIGNING FIELD-SYMBOL(<ls_bp_addr_data>)
      WITH KEY addrnumber = <ls_bp_data>-addrnumber.
    IF sy-subrc <> 0.
*     Error -> No Address found for the plant
    ELSE.
      LOOP AT <ls_bp_addr_data>-addr1_tab ASSIGNING FIELD-SYMBOL(<ls_bp_addr1>).
        ASSIGN <ls_bp_addr1>-data TO <ls_bp_addr1_data>.
        IF NOT ( <ls_bp_addr1_data>-date_from <= sy-datum AND
                 <ls_bp_addr1_data>-date_to >= sy-datum ).
*         Not Valid Address
          CONTINUE.
        ENDIF.

*       Description (NAME1 from Address is used as text) -> Here Description of Business Partner.
        LOOP AT mt_bp_data_txt ASSIGNING FIELD-SYMBOL(<ls_bp_data_txt>) WHERE partner = <ls_bp_data>-partner.
          CLEAR ls_loc_description.
          ls_loc_description-language_code = <ls_bp_data_txt>-spras.
          ls_loc_description-content       = <ls_bp_data_txt>-vtext.
          INSERT ls_loc_description INTO TABLE ls_loc_repl_mess-location-description.
        ENDLOOP.

*       Time Zone
        IF  <ls_bp_addr1_data>-time_zone IS NOT INITIAL.
          ls_loc_repl_mess-location-time_zone_code = <ls_bp_addr1_data>-time_zone.
        ELSE.
          CALL FUNCTION 'TZON_LOCATION_TIMEZONE'
            EXPORTING
              if_country        = <ls_bp_addr1_data>-country
              if_region         = <ls_bp_addr1_data>-region
            IMPORTING
              ef_timezone       = lv_timezone
            EXCEPTIONS
              no_timezone_found = 1
              OTHERS            = 2.
          IF sy-subrc <> 0.
            CLEAR ls_loc_repl_mess-location-time_zone_code.
          ELSE.
            ls_loc_repl_mess-location-time_zone_code = lv_timezone.
          ENDIF.
        ENDIF.

**********************************************************************
*       Organization formatted Name
**********************************************************************
        ls_loc_address-organisation_form_of_address-code = <ls_bp_addr1_data>-title.
        IF <ls_bp_addr1_data>-name1 IS NOT INITIAL.
          lv_loc_form_name = <ls_bp_addr1_data>-name1.
          INSERT lv_loc_form_name INTO TABLE ls_loc_address-organisation_formatted_name.
        ENDIF.
        IF <ls_bp_addr1_data>-name2 IS NOT INITIAL.
          lv_loc_form_name = <ls_bp_addr1_data>-name2.
          INSERT lv_loc_form_name INTO TABLE ls_loc_address-organisation_formatted_name.
        ENDIF.
        IF <ls_bp_addr1_data>-name3 IS NOT INITIAL.
          lv_loc_form_name = <ls_bp_addr1_data>-name3.
          INSERT lv_loc_form_name INTO TABLE ls_loc_address-organisation_formatted_name.
        ENDIF.
        IF <ls_bp_addr1_data>-name4 IS NOT INITIAL.
          lv_loc_form_name = <ls_bp_addr1_data>-name4.
          INSERT lv_loc_form_name INTO TABLE ls_loc_address-organisation_formatted_name.
        ENDIF.
        IF <ls_bp_addr1_data>-name_txt IS NOT INITIAL.
          lv_loc_form_name = <ls_bp_addr1_data>-name_txt.
          INSERT lv_loc_form_name INTO TABLE ls_loc_address-organisation_formatted_name.
        ENDIF.

**********************************************************************
*       Physical Address
**********************************************************************
        ls_loc_address-physical_address-country_code               = <ls_bp_addr1_data>-country.
        ls_loc_address-physical_address-country_name-language_code = <ls_bp_addr1_data>-langu.
        ls_loc_address-physical_address-region_code                = <ls_bp_addr1_data>-region.
        ls_loc_address-physical_address-city_name                  = <ls_bp_addr1_data>-city1.
        ls_loc_address-physical_address-additional_city_name       = <ls_bp_addr1_data>-home_city.
        ls_loc_address-physical_address-pobox_country_code         = <ls_bp_addr1_data>-po_box_cty.
        ls_loc_address-physical_address-pobox_region_code          = <ls_bp_addr1_data>-po_box_reg.
        ls_loc_address-physical_address-pobox_id                   = <ls_bp_addr1_data>-po_box.

        cl_gdt_conversion=>indicator_outbound(
          EXPORTING
            im_value = <ls_bp_addr1_data>-po_box_num            " ABAP Flag: 'X' ="true, ' ' = false
          IMPORTING
            ex_value = ls_loc_address-physical_address-pobox_indicator ).                " XSD:Indicator
        ls_loc_address-physical_address-street_postal_code         = <ls_bp_addr1_data>-post_code1.
        ls_loc_address-physical_address-pobox_postal_code          = <ls_bp_addr1_data>-post_code2.
        ls_loc_address-physical_address-company_postal_code        = <ls_bp_addr1_data>-post_code3.
        ls_loc_address-physical_address-house_id                   = <ls_bp_addr1_data>-house_num1.
        ls_loc_address-physical_address-additional_house_id        = <ls_bp_addr1_data>-house_num2.
        ls_loc_address-physical_address-district_name              = <ls_bp_addr1_data>-city2.
        ls_loc_address-physical_address-building_id                = <ls_bp_addr1_data>-building.
        ls_loc_address-physical_address-floor_id                   = <ls_bp_addr1_data>-floor.
        ls_loc_address-physical_address-room_id                    = <ls_bp_addr1_data>-roomnumber.
        ls_loc_address-physical_address-street_name                = <ls_bp_addr1_data>-street.

        IF <ls_bp_addr1_data>-str_suppl1 IS NOT INITIAL OR <ls_bp_addr1_data>-str_suppl2 IS NOT INITIAL.
          INSERT <ls_bp_addr1_data>-str_suppl1 INTO TABLE ls_loc_address-physical_address-street_prefix_name.
          INSERT <ls_bp_addr1_data>-str_suppl2 INTO TABLE ls_loc_address-physical_address-street_prefix_name.
        ENDIF.
        IF <ls_bp_addr1_data>-str_suppl3 IS NOT INITIAL OR <ls_bp_addr1_data>-location IS NOT INITIAL.
          INSERT <ls_bp_addr1_data>-str_suppl3 INTO TABLE ls_loc_address-physical_address-street_suffix_name.
          INSERT <ls_bp_addr1_data>-location   INTO TABLE ls_loc_address-physical_address-street_suffix_name.
        ENDIF.

*       Office
        ls_loc_address-office-building_id = <ls_bp_addr1_data>-building.
        ls_loc_address-office-floor_id    = <ls_bp_addr1_data>-floor.
        ls_loc_address-office-room_id     = <ls_bp_addr1_data>-roomnumber.

*       Communication
        ls_loc_address-communication-correspondence_language_code = <ls_bp_addr1_data>-langu.

*       Phone
        LOOP AT <ls_bp_addr_data>-adtel_tab ASSIGNING FIELD-SYMBOL(<ls_bp_addr_adtel_data>).
          CLEAR ls_loc_tel.
          ls_loc_tel-number-country_code      = <ls_bp_addr_adtel_data>-adtel-country.
          ls_loc_tel-number-subscriber_id     = <ls_bp_addr_adtel_data>-adtel-tel_number.
          ls_loc_tel-number-extension_id      = <ls_bp_addr_adtel_data>-adtel-tel_extens.
          ls_loc_tel-number-country_code      = <ls_bp_addr_adtel_data>-adtel-country.

          cl_gdt_conversion=>indicator_outbound(
            EXPORTING
              im_value = <ls_bp_addr_adtel_data>-adtel-flgdefault            " ABAP Flag: 'X' ="true, ' ' = false
            IMPORTING
              ex_value = ls_loc_tel-number_default_indicator ).                " XSD:Indicator

          cl_gdt_conversion=>indicator_outbound(
            EXPORTING
              im_value = <ls_bp_addr_adtel_data>-adtel-dft_receiv           " ABAP Flag: 'X' ="true, ' ' = false
            IMPORTING
              ex_value = ls_loc_tel-smsenabled_indicator ).                   " XSD:Indicator
          INSERT ls_loc_tel INTO TABLE ls_loc_address-communication-telephone.
        ENDLOOP.

*       Fax
        LOOP AT <ls_bp_addr_data>-adfax_tab ASSIGNING FIELD-SYMBOL(<ls_bp_addr_adfax_data>).
          ls_loc_facs-number-country_code      = <ls_bp_addr_adfax_data>-adfax-country.
          ls_loc_facs-number-subscriber_id     = <ls_bp_addr_adfax_data>-adfax-fax_number.
          ls_loc_facs-number-extension_id      = <ls_bp_addr_adfax_data>-adfax-fax_extens.
          ls_loc_facs-number-country_code      = <ls_bp_addr_adfax_data>-adfax-country.
          cl_gdt_conversion=>indicator_outbound(
            EXPORTING
              im_value = <ls_bp_addr_adfax_data>-adfax-flgdefault           " ABAP Flag: 'X' ="true, ' ' = false
            IMPORTING
              ex_value = ls_loc_facs-number_default_indicator ).                " XSD:Indicator

          INSERT ls_loc_facs INTO TABLE ls_loc_address-communication-facsimile.
        ENDLOOP.

*       E-mail
        LOOP AT <ls_bp_addr_data>-adsmtp_tab ASSIGNING FIELD-SYMBOL(<ls_bp_addr_adsmtp_data>).
          CLEAR ls_loc_email.
          ls_loc_email-uri                  = <ls_bp_addr_adsmtp_data>-adsmtp-smtp_addr.
          cl_gdt_conversion=>indicator_outbound(
            EXPORTING
              im_value = <ls_bp_addr_adsmtp_data>-adsmtp-dft_receiv        " ABAP Flag: 'X' ="true, ' ' = false
            IMPORTING
              ex_value = ls_loc_email-uridefault_indicator ).                " XSD:Indicator

          INSERT ls_loc_email INTO TABLE ls_loc_address-communication-email.
        ENDLOOP.

*       Web
        LOOP AT <ls_bp_addr_data>-aduri_tab ASSIGNING FIELD-SYMBOL(<ls_bp_addr_aduri>).
          IF <ls_bp_addr_aduri>-aduri-uri_type = 'HPG' . " Location Type HPG(Homepage) is transffered only
            CLEAR ls_loc_web.
            ls_loc_web-uri = <ls_bp_addr_aduri>-aduri-uri_addr.
            cl_gdt_conversion=>indicator_outbound(
              EXPORTING
                im_value = <ls_bp_addr_aduri>-aduri-flgdefault          " ABAP Flag: 'X' ="true, ' ' = false
              IMPORTING
                ex_value = ls_loc_web-uridefault_indicator ).             " XSD:Indicator

            INSERT ls_loc_web INTO TABLE ls_loc_address-communication-web.
          ENDIF.
        ENDLOOP.
*       Only one valid address
        ls_loc_repl_mess-location-address = ls_loc_address.
        EXIT.
      ENDLOOP.
    ENDIF.

    ms_loc_bulk_repl_req-location_bulk_replication_req-message_header = ls_loc_bulk-message_header.
    INSERT ls_loc_repl_mess INTO TABLE lt_loc_repl_mess.
    INSERT LINES OF lt_loc_repl_mess INTO TABLE ms_loc_bulk_repl_req-location_bulk_replication_req-loc_repl_req_msg.

  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_BP_LOC_DRF_OUTBOUND->IF_DRF_OUTBOUND~READ_COMPLETE_DATA
* +-------------------------------------------------------------------------------------------------+
* | [<-->] CT_RELEVANT_OBJECTS            TYPE        SORTED TABLE
* | [!CX!] CX_DRF_PROCESS_MESSAGES
* | [!CX!] CX_DRF_EXCEPTION
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD IF_DRF_OUTBOUND~READ_COMPLETE_DATA.
**********************************************************************
*   Read the data of all records that shall be replicated later on
*   via the new Location Service.
**********************************************************************

    DATA:
      lt_bus_sys_tech        TYPE mdg_t_bus_sys_tech,
      lv_own_business_system TYPE text60,
      ls_partner               TYPE tys_partner,
      lt_partner               TYPE TABLE OF tys_partner,
      lt_adrc                TYPE szadr_adrc_table,
      ls_adrc                TYPE szadr_st_adrc,
      lt_addr_error          TYPE szadr_error_table.

    FIELD-SYMBOLS:
      <ls_bp_data>       TYPE tys_bp_data,
      <ls_loc_drf_outbound> TYPE any,
      <lv_comp>             TYPE any.


**********************************************************************
*   Get Business System Data
**********************************************************************

*   Get own Logical System
    CALL FUNCTION 'LCR_GET_OWN_BUSINESS_SYSTEM'
      IMPORTING
        bs_key_name            = lv_own_business_system
      EXCEPTIONS
        no_business_system     = 1
        no_rfc_destination     = 2
        no_landscape_directory = 3
        illegal_arguments      = 4
        communication_error    = 5
        ld_error               = 6
        sld_api_exception      = 7
        OTHERS                 = 8.
    IF sy-subrc NE 0.
      RETURN. " RAISE no_business_system.
    ENDIF.

    mv_sender_bussystem_id = lv_own_business_system.

    CALL METHOD cl_drf_access_cust_data=>select_business_sys_for_appl
      EXPORTING
        iv_appl         = ms_runtime_parameter-appl
        iv_outb_impl    = ms_runtime_parameter-outb_impl
      IMPORTING
        et_bus_sys_tech = lt_bus_sys_tech.

    READ TABLE lt_bus_sys_tech ASSIGNING FIELD-SYMBOL(<ls_bus_sys_tech>) INDEX 1. "#EC CI_NOORDER

    mv_receiver_bussystem_id = <ls_bus_sys_tech>-business_system.

**********************************************************************
*   Build up table lt_partner
**********************************************************************
    LOOP AT ct_relevant_objects ASSIGNING <ls_loc_drf_outbound>.
      CLEAR ls_partner.
      UNASSIGN <lv_comp>.

      ASSIGN COMPONENT 'partner' OF STRUCTURE <ls_loc_drf_outbound> TO <lv_comp>.
      IF sy-subrc = 0 AND <lv_comp> IS ASSIGNED.
        ls_partner = <lv_comp>.
        INSERT ls_partner INTO TABLE lt_partner.
      ENDIF.
    ENDLOOP.

**********************************************************************
*   Retrieve Data of bpier general data
**********************************************************************
    IF lt_partner IS NOT INITIAL.
      SELECT a~partner a~bu_langu b~addrnumber
        FROM but000 as a
        LEFT OUTER JOIN but020 as b
        on a~partner = b~partner
        INTO CORRESPONDING FIELDS OF TABLE mt_bp_data
        FOR ALL ENTRIES IN lt_partner
        WHERE a~partner = lt_partner-partner.
      IF sy-subrc <> 0.
        RAISE EXCEPTION TYPE cx_drf_process_messages.
      ENDIF.
    ELSE.
      RAISE EXCEPTION TYPE cx_drf_process_messages.
    ENDIF.

**********************************************************************
*   Retrieve Text Data of bpier general data ( not existing)
**********************************************************************
*    IF lt_partner IS NOT INITIAL.
*      SELECT spras vstel vtext FROM tvstt
*        INTO CORRESPONDING FIELDS OF TABLE mt_bp_data_txt
*        FOR ALL ENTRIES IN lt_partner
*        WHERE partner = lt_partner-partner.
*      IF sy-subrc <> 0.
*        RAISE EXCEPTION TYPE cx_drf_process_messages.
*      ENDIF.
*    ELSE.
*      RAISE EXCEPTION TYPE cx_drf_process_messages.
*    ENDIF.
*
**********************************************************************
*   Retrieve Addresses of the bpier
**********************************************************************
    CLEAR lt_adrc.
    LOOP AT mt_bp_data ASSIGNING <ls_bp_data>.
      IF <ls_bp_data>-addrnumber IS NOT INITIAL.
        ls_adrc-addrnumber = <ls_bp_data>-addrnumber.
        INSERT ls_adrc INTO TABLE lt_adrc.
      ENDIF.
    ENDLOOP.
    IF lt_adrc IS NOT INITIAL.
      CALL FUNCTION 'ADDR_GET_COMPLETE_DB_MASS'
        EXPORTING
          iv_current_comm_data = 'X'
        TABLES
          address_selection    = lt_adrc
          sz_addr1_complete    = mt_bp_address
          sz_error_table       = lt_addr_error.

    ENDIF.

  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_BP_LOC_DRF_OUTBOUND->IF_DRF_OUTBOUND~SEND_MESSAGE
* +-------------------------------------------------------------------------------------------------+
* | [--->] IS_FILE_INFO                   TYPE        DRF_S_FILE_INFO(optional)
* | [--->] IV_OBJECT_COUNT                TYPE        DRF_PACKAGE_SIZE(optional)
* | [--->] IS_BUS_SYS_TECH                TYPE        MDG_S_BUS_SYS_TECH(optional)
* | [<---] ET_FILE_DATA                   TYPE        DRF_T_FILE_OI_CONTENT
* | [<---] ET_MESSAGE                     TYPE        DRF_T_MESSAGE
* | [<-->] CT_OBJ_REP_STA                 TYPE        DRF_T_OBJ_REP_STA_FULL(optional)
* | [!CX!] CX_DRF_PROCESS_MESSAGES
* | [!CX!] CX_DRF_EXCEPTION
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD IF_DRF_OUTBOUND~SEND_MESSAGE.
**********************************************************************
* The method calls the servcice LocationBulkReplicationRequest_Out
*   Class: CO_LOC_LOC_BULK_REPL_REQ_OUT
*   Method: LOC_BULK_REPLICATION_REQ_OUT
* Parameter OUTPUT Type LOC_BULK_REPLICATION_REQ
**********************************************************************
* The service will be called under the followinng circumstances:
* Attribute MS_LOC_BULK_REPL_REQ is not initial
* Attribute MS_RUNTIME_PARAMETER-TESTRUN is not abap_false
* That means, location data for replication are available and
* the DRFOUT wasn't called in test mode.
**********************************************************************

    TYPES: BEGIN OF ty_object_id,
             prefix TYPE char3,
             id     TYPE char4,
           END OF ty_object_id.

    DATA:
      ls_message_data_outbound     TYPE loc_bulk_replication_req, "TYPE sapplco_loc_blk_repl_req_msg,
      lv_path_message_header       TYPE string,
      lv_path_sequence_fields      TYPE string,
      lv_default_service_group     TYPE xflag,
      lv_service_group             TYPE srt_wsp_dt_obj_name,
      lv_recipient_business_system TYPE sld_bskey,
      lv_application_id            TYPE bs_soa_appl_id,
      lv_tech_seq_context          TYPE bs_soa_asyncprx_cntxt,
      lv_appl_seq_context          TYPE bs_soa_inappseq_cntxt,
      lv_reference_message_id      TYPE bs_soa_rspnsrcvr_msg_id,
      lv_correlation_id            TYPE bs_soa_rspnsrcvr_corel_id,
      lv_reconciliation_requested  TYPE xflag,
      ls_lrd_filter                TYPE lrd_sld_bskey,
      lo_bs_soa_exception          TYPE REF TO cx_bs_soa_exception,
      lt_outbound_proxy            TYPE bssoa_asyncprx_instance_t ##needed.


    DATA:
      lo_xi_error                  TYPE REF TO cx_ai_system_fault,
      lv_error_txt                 TYPE string,
      lv_error_long_txt            TYPE string,
      lv_object_id                 TYPE ty_object_id,
      ls_loc_repl_req_msg          TYPE sapplco_loc_repl_req_msg.

    FIELD-SYMBOLS:
          <ls_obj_rep_sta>       TYPE drf_s_obj_rep_sta_attr.

***********************************************************************
**   Initialize the exporting parameter
***********************************************************************
    CLEAR: et_file_data,    "Not used
           et_message.

**********************************************************************
*   Check if the service could be triggerd
*   Location Data for replication are available and Test Mode OFF
**********************************************************************
    IF ms_runtime_parameter-testrun = abap_true.
      "Test Mode --> No Service Call
      RETURN.
    ENDIF.

    IF ms_loc_bulk_repl_req IS NOT INITIAL.
      "Replication data available

      "Update Replication Status Object with the message_header-UUID (Message Link)
      "to be able to identify the message later on in the inbound
      LOOP AT ms_loc_bulk_repl_req-location_bulk_replication_req-loc_repl_req_msg
              INTO ls_loc_repl_req_msg.
        lv_object_id = ls_loc_repl_req_msg-location-location_internal_id.
        READ TABLE ct_obj_rep_sta ASSIGNING <ls_obj_rep_sta>
             WITH KEY object_id = lv_object_id-id.
        IF sy-subrc = 0.
          "Entry found --> Set the message_header-UUID
          <ls_obj_rep_sta>-msg_link = ls_loc_repl_req_msg-message_header-id-content.
        ENDIF.
      ENDLOOP.

      ls_message_data_outbound = ms_loc_bulk_repl_req.
      lv_path_message_header  = 'LOCATION_BULK_REPLICATION_REQ-MESSAGE_HEADER'.
      lv_path_sequence_fields = 'LOCATION_BULK_REPLICATION_REQ-LOC_REPL_REQ_MSG'.
      lv_service_group        = 'LOCATION_REPLICATE_REQ'.
      lv_recipient_business_system = mv_receiver_bussystem_id.
      ls_lrd_filter-bskey          = lv_recipient_business_system.

*   Context Build
      CONCATENATE sy-sysid sy-mandt 'LOC_REPL_REQ'
         INTO lv_tech_seq_context.

      lv_appl_seq_context = 'LOCREQ'.

      TRY.
          CALL METHOD cl_bs_soa_asyncprx_out=>execute
            EXPORTING
              iv_proxy_class               = 'CO_LOC_LOC_BULK_REPL_REQ_OUT'
              iv_method                    = 'LOC_BULK_REPLICATION_REQ_OUT'
              iv_obj_type                  = 'BUS10002'
              iv_path_msg_header           = lv_path_message_header
              iv_path_of_seq_fields        = lv_path_sequence_fields
              iv_service_group             = lv_service_group
              iv_logical_receiver_det_struc = ls_lrd_filter
              iv_default_service_group     = lv_default_service_group
              iv_recipient_business_system = lv_recipient_business_system
              iv_application_id            = lv_application_id
              iv_tech_seq_context          = lv_tech_seq_context
              iv_appl_seq_context          = lv_appl_seq_context
              iv_reference_message_id      = lv_reference_message_id
              iv_correlation_id            = lv_correlation_id
              iv_reconciliation_requested  = lv_reconciliation_requested
            IMPORTING
              et_proxy_instances           = lt_outbound_proxy
            CHANGING
              cs_message_data_outbound     = ls_message_data_outbound.

        CATCH cx_bs_soa_exception INTO lo_bs_soa_exception .
          "Communication Error
          "Get Error Text
          CALL METHOD lo_bs_soa_exception->get_text
            RECEIVING
              result = lv_error_txt.
          "Get Long Text
          CALL METHOD lo_bs_soa_exception->get_longtext
            RECEIVING
              result = lv_error_long_txt.
          "Write Message to the BAL
          "DRF_OUTBOUND 015 - Error during proxy call (&1: &2, &3)
          "ADD_MSG_RE --> Add Message and Raise Exception
          CALL METHOD ms_runtime_parameter-bal->add_msg_re
            EXPORTING
              iv_msgno = '015'
              iv_msgid = 'DRF_OUTBOUND'
              iv_msgv1 = 'CO_LOC_LOC_BULK_REPL_REQ_OUT'
              iv_msgv2 = lv_error_txt
              iv_msgv3 = lv_error_long_txt.

        CATCH cx_ai_system_fault INTO lo_xi_error.
          "Application Integration: Technical Error
          "Write BAL - DRF_OUTBOUND 013 - Error while creating the &1 proxy instance
          CALL METHOD ms_runtime_parameter-bal->add_msg_re
            EXPORTING
              iv_msgno             = '013'
              iv_msgid             = 'DRF_OUTBOUND'
              iv_msgv1             = 'CO_LOC_LOC_BULK_REPL_REQ_OUT'
              ix_exception_catched = lo_xi_error.

      ENDTRY.
    ELSE.
      "No Replication data available
      "Add Message to the BAL
      "DRF_OUTBOUND 322 - System does not send blank messages
      CALL METHOD ms_runtime_parameter-bal->add_msg_re
        EXPORTING
          iv_msgno = '322'
          iv_msgid = 'DRF_OUTBOUND'.
    ENDIF.
*   Clear Message for new Message Run
    CLEAR ms_loc_bulk_repl_req.
  ENDMETHOD.
ENDCLASS.

 

Class: ZCL_BP_LOC_DRF_EXPL_FILTER

class ZCL_BP_LOC_DRF_EXPL_FILTER definition
  public
  final
  create public .

public section.

  interfaces IF_DRF_FILTER .
protected section.
private section.
ENDCLASS.



CLASS ZCL_BP_LOC_DRF_EXPL_FILTER IMPLEMENTATION.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_BP_LOC_DRF_EXPL_FILTER->IF_DRF_FILTER~APPLY_FILTER
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_APPL                        TYPE        DRF_APPL
* | [--->] IV_BUSINESS_SYSTEM             TYPE        MDG_BUSINESS_SYSTEM
* | [--->] IS_C_FOBJ                      TYPE        DRF_S_C_FOBJ_RUNTIME
* | [--->] IV_OUTB_IMPL                   TYPE        DRF_OUTB_IMPL
* | [--->] IV_DLMOD                       TYPE        DRF_DLMOD
* | [--->] IV_RUNMOD                      TYPE        DRF_RUNMOD
* | [--->] IS_FILT                        TYPE        DRF_S_C_FILT_RUNTIME
* | [--->] IO_BAL                         TYPE REF TO CL_DRF_BAL
* | [--->] IT_EXTERNAL_CRITERIA           TYPE        RSDS_TRANGE
* | [--->] IT_UNFILTERED_OBJECTS          TYPE        SORTED TABLE
* | [--->] IS_ADDITIONAL_PARAMETER        TYPE        DRF_S_RTIME_PARAM_ADDITIONAL(optional)
* | [<---] ET_FILTERED_OBJECTS            TYPE        SORTED TABLE
* | [!CX!] CX_DRF_FILTER_OBJECT
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD IF_DRF_FILTER~APPLY_FILTER.
**********************************************************************
* Explicit Filter implementation for the DRF Outbound for Shipping Points
* The following filter structure is assigned to the explicit filter
* in the customizing:
* The filter structure contains the following components:

**********************************************************************
    DATA:
      ls_selopt            TYPE rsdsselopt,
      lt_bp_range        TYPE rsds_selopt_t,
      lt_bp_range_unf    TYPE rsds_selopt_t,
      lt_bp_drf_outbound TYPE ZDRF_T_bp_OUTBOUND.

    FIELD-SYMBOLS:
      <ls_ext_criteria>       TYPE rsds_range,
      <ls_filter_range>       TYPE rsds_frange,
      <ls_unfiltered_objects> TYPE ZDRF_S_bp_OUTBOUND.

**********************************************************************
*   Initialize the exporting parameters
**********************************************************************
    CLEAR et_filtered_objects.

**********************************************************************
*   Process the external filter criteria and split them into the
*   corresponding component range tables
**********************************************************************
    LOOP AT it_external_criteria ASSIGNING <ls_ext_criteria>.
      LOOP AT <ls_ext_criteria>-frange_t ASSIGNING <ls_filter_range>.
        CASE <ls_filter_range>-fieldname.
          WHEN 'PARTNER'.
            INSERT LINES OF <ls_filter_range>-selopt_t INTO TABLE lt_bp_range.
        ENDCASE.
      ENDLOOP.
    ENDLOOP.

**********************************************************************
*   Take care of the unfiltered objects and add them to the corresponding
*   Range Select Options
**********************************************************************
    LOOP AT it_unfiltered_objects ASSIGNING <ls_unfiltered_objects>.
      IF <ls_unfiltered_objects>-partner IS NOT INITIAL.
        CLEAR ls_selopt.
        ls_selopt-sign = if_drf_const=>range_sign_inclusive. "'I'
        ls_selopt-option = if_drf_const=>range_option_equal. "'EQ'
        ls_selopt-low = <ls_unfiltered_objects>-partner.
        INSERT ls_selopt INTO TABLE lt_bp_range_unf.
      ENDIF.
    ENDLOOP.

    "Add the unfiltered object to the affected range for the selection
    IF lt_bp_range_unf IS NOT INITIAL.
      INSERT LINES OF lt_bp_range_unf INTO TABLE lt_bp_range.
    ENDIF.

**********************************************************************
*   Select LOCNO and LOCTYPE from /SAPAPO/LOC
**********************************************************************
    SELECT partner FROM but000
           INTO CORRESPONDING FIELDS OF TABLE lt_bp_drf_outbound
           WHERE partner IN lt_bp_range.

**********************************************************************
*   Fill the exporting parameters
**********************************************************************
    INSERT LINES OF lt_bp_drf_outbound INTO TABLE et_filtered_objects.

  ENDMETHOD.
ENDCLASS.

 

Save and activate all the objects

Replication of Vendor

Follow the similar steps as above below is the list of objects you have to create.

Structure:

ZDRF_S_SUPPL_OUTBOUND

Table Type:

ZDRF_T_SUPPL_OUTBOUND ( with sorted key and Primary key)

Class:

ZCL_SUPPL_LOC_DRF_EXPL_FILTER

ZCL_SUPPL_LOC_DRF_OUTBOUND

 

Structure: ZDRF_S_SUPPL_OUTBOUND

 

Table Type: ZDRF_T_SUPPL_OUTBOUND

 

Implement Classes

Class : ZCL_SUPPL_LOC_DRF_EXPL_FILTER

class ZCL_SUPPL_LOC_DRF_EXPL_FILTER definition
  public
  final
  create public .

public section.

  interfaces IF_DRF_FILTER .
protected section.
private section.
ENDCLASS.



CLASS ZCL_SUPPL_LOC_DRF_EXPL_FILTER IMPLEMENTATION.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_SUPPL_LOC_DRF_EXPL_FILTER->IF_DRF_FILTER~APPLY_FILTER
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_APPL                        TYPE        DRF_APPL
* | [--->] IV_BUSINESS_SYSTEM             TYPE        MDG_BUSINESS_SYSTEM
* | [--->] IS_C_FOBJ                      TYPE        DRF_S_C_FOBJ_RUNTIME
* | [--->] IV_OUTB_IMPL                   TYPE        DRF_OUTB_IMPL
* | [--->] IV_DLMOD                       TYPE        DRF_DLMOD
* | [--->] IV_RUNMOD                      TYPE        DRF_RUNMOD
* | [--->] IS_FILT                        TYPE        DRF_S_C_FILT_RUNTIME
* | [--->] IO_BAL                         TYPE REF TO CL_DRF_BAL
* | [--->] IT_EXTERNAL_CRITERIA           TYPE        RSDS_TRANGE
* | [--->] IT_UNFILTERED_OBJECTS          TYPE        SORTED TABLE
* | [--->] IS_ADDITIONAL_PARAMETER        TYPE        DRF_S_RTIME_PARAM_ADDITIONAL(optional)
* | [<---] ET_FILTERED_OBJECTS            TYPE        SORTED TABLE
* | [!CX!] CX_DRF_FILTER_OBJECT
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD IF_DRF_FILTER~APPLY_FILTER.
**********************************************************************
* Explicit Filter implementation for the DRF Outbound for Shipping Points
* The following filter structure is assigned to the explicit filter
* in the supplomizing: DRF_S_suppl_LOC_EXPL_FILTER
* The filter structure contains the following components:
*    lifnr   TYPE lifnr
**********************************************************************
    DATA:
      ls_selopt            TYPE rsdsselopt,
      lt_suppl_range        TYPE rsds_selopt_t,
      lt_suppl_range_unf    TYPE rsds_selopt_t,
      lt_suppl_drf_outbound TYPE ZDRF_T_SUPPL_OUTBOUND.

    FIELD-SYMBOLS:
      <ls_ext_criteria>       TYPE rsds_range,
      <ls_filter_range>       TYPE rsds_frange,
      <ls_unfiltered_objects> TYPE ZDRF_S_SUPPL_OUTBOUND.

**********************************************************************
*   Initialize the exporting parameters
**********************************************************************
    CLEAR et_filtered_objects.

**********************************************************************
*   Process the external filter criteria and split them into the
*   corresponding component range tables
**********************************************************************
    LOOP AT it_external_criteria ASSIGNING <ls_ext_criteria>.
      LOOP AT <ls_ext_criteria>-frange_t ASSIGNING <ls_filter_range>.
        CASE <ls_filter_range>-fieldname.
          WHEN 'LIFNR'.
            INSERT LINES OF <ls_filter_range>-selopt_t INTO TABLE lt_suppl_range.
        ENDCASE.
      ENDLOOP.
    ENDLOOP.

**********************************************************************
*   Take care of the unfiltered objects and add them to the corresponding
*   Range Select Options
**********************************************************************
    LOOP AT it_unfiltered_objects ASSIGNING <ls_unfiltered_objects>.
      IF <ls_unfiltered_objects>-lifnr IS NOT INITIAL.
        CLEAR ls_selopt.
        ls_selopt-sign = if_drf_const=>range_sign_inclusive. "'I'
        ls_selopt-option = if_drf_const=>range_option_equal. "'EQ'
        ls_selopt-low = <ls_unfiltered_objects>-lifnr.
        INSERT ls_selopt INTO TABLE lt_suppl_range_unf.
      ENDIF.
    ENDLOOP.

    "Add the unfiltered object to the affected range for the selection
    IF lt_suppl_range_unf IS NOT INITIAL.
      INSERT LINES OF lt_suppl_range_unf INTO TABLE lt_suppl_range.
    ENDIF.

**********************************************************************
*   Select LOCNO and LOCTYPE from /SAPAPO/LOC
**********************************************************************
    SELECT lifnr FROM lfa1
           INTO CORRESPONDING FIELDS OF TABLE lt_suppl_drf_outbound
           WHERE lifnr IN lt_suppl_range.

**********************************************************************
*   Fill the exporting parameters
**********************************************************************
    INSERT LINES OF lt_suppl_drf_outbound INTO TABLE et_filtered_objects.

  ENDMETHOD.
ENDCLASS.

Class : ZCL_SUPPL_LOC_DRF_OUTBOUND

class ZCL_SUPPL_LOC_DRF_OUTBOUND definition
  public
  final
  create public .

public section.

  interfaces IF_DRF_OUTBOUND .
PROTECTED SECTION.

  TYPES:
    BEGIN OF tys_suppl_data,
      lifnr TYPE lifnr,
      spras TYPE spras,
      adrnr TYPE adrnr,
    END OF tys_suppl_data .
  TYPES:
    tt_suppl_data TYPE STANDARD TABLE OF tys_suppl_data .
  TYPES:
    BEGIN OF tys_suppl_data_txt,
      spras TYPE spras,
      lifnr TYPE lifnr,
      vtext TYPE vtext,
    END OF tys_suppl_data_txt .
  TYPES:
    tt_suppl_data_txt TYPE STANDARD TABLE OF tys_suppl_data_txt .
  TYPES:
    BEGIN OF tys_lifnr,
      lifnr TYPE lifnr,
    END OF tys_lifnr .

  DATA mt_suppl_address TYPE szadr_addr1_table .
  DATA mt_suppl_data TYPE tt_suppl_data .
  DATA mt_suppl_data_txt TYPE tt_suppl_data_txt .
  DATA ms_runtime_parameter TYPE drf_s_runtime_parameter_ext .
  DATA ms_loc_bulk_repl_req TYPE loc_bulk_replication_req .
  CONSTANTS mc_t_drf_loc_outb TYPE string VALUE 'ZDRF_T_SUPPL_OUTBOUND'  ##NO_TEXT.
  CONSTANTS mc_s_drf_loc_outbound TYPE string VALUE 'ZDRF_S_SUPPL_OUTBOUND' ##NO_TEXT.
  DATA mv_sender_bussystem_id TYPE sapplco_business_system_id .
  DATA mv_receiver_bussystem_id TYPE sapplco_business_system_id .
private section.

  methods FILL_MESSAGE_HEADER
    exporting
      !ES_MESSAGE_HEADER type SAPPLCO_BUS_DOC_MESSAGE_HEADER .
ENDCLASS.



CLASS ZCL_SUPPL_LOC_DRF_OUTBOUND IMPLEMENTATION.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Private Method ZCL_SUPPL_LOC_DRF_OUTBOUND->FILL_MESSAGE_HEADER
* +-------------------------------------------------------------------------------------------------+
* | [<---] ES_MESSAGE_HEADER              TYPE        SAPPLCO_BUS_DOC_MESSAGE_HEADER
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD FILL_MESSAGE_HEADER.
    DATA:
      lv_uuid                TYPE char32,
      lv_timestamp           TYPE timestampl.

    CLEAR es_message_header.

    GET TIME STAMP FIELD lv_timestamp.

    cl_gdt_conversion=>date_time_outbound(
      EXPORTING
        im_value_long = lv_timestamp
      IMPORTING
        ex_value       = es_message_header-creation_date_time               " Time Stamp According to ISO 8601
    ).

    es_message_header-sender_business_system_id    = mv_sender_bussystem_id.
    es_message_header-recipient_business_system_id = mv_receiver_bussystem_id.

    TRY.
        lv_uuid  = cl_system_uuid=>create_uuid_x16_static( ).
      CATCH cx_uuid_error.
        "Should never occur
        ASSERT 1 = 0.
    ENDTRY.
    es_message_header-id-content = lv_uuid.
    cl_gdt_conversion=>guid_outbound(
      EXPORTING
        im_guid_c = lv_uuid                                        " GUID in Character Display
      IMPORTING
        ex_value  = es_message_header-uuid-content                 " GUID / UUID in XML Display
    ).

  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_SUPPL_LOC_DRF_OUTBOUND->IF_DRF_OUTBOUND~ANALYZE_CHANGES_BY_CHG_POINTER
* +-------------------------------------------------------------------------------------------------+
* | [--->] IT_CHANGE_POINTER              TYPE        DRF_T_BDCP
* | [<---] ES_STAT_INFO                   TYPE        DRF_S_STAT_INFO
* | [<-->] CT_CHANGED_OBJECTS             TYPE        SORTED TABLE
* | [!CX!] CX_DRF_ANALYZE_CHANGES
* | [!CX!] CX_DRF_EXCEPTION
* +--------------------------------------------------------------------------------------</SIGNATURE>
  method IF_DRF_OUTBOUND~ANALYZE_CHANGES_BY_CHG_POINTER.

  endmethod.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_SUPPL_LOC_DRF_OUTBOUND->IF_DRF_OUTBOUND~ANALYZE_CHANGES_BY_MDG_CP
* +-------------------------------------------------------------------------------------------------+
* | [--->] IT_CHANGE_POINTER              TYPE        MDG_CP_T_CP
* | [<---] ES_STAT_INFO                   TYPE        DRF_S_STAT_INFO
* | [<-->] CT_CHANGED_OBJECTS             TYPE        SORTED TABLE
* | [!CX!] CX_DRF_ANALYZE_CHANGES
* | [!CX!] CX_DRF_EXCEPTION
* +--------------------------------------------------------------------------------------</SIGNATURE>
  method IF_DRF_OUTBOUND~ANALYZE_CHANGES_BY_MDG_CP.
  endmethod.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_SUPPL_LOC_DRF_OUTBOUND->IF_DRF_OUTBOUND~ANALYZE_CHANGES_BY_OTHERS
* +-------------------------------------------------------------------------------------------------+
* | [<---] ES_STAT_INFO                   TYPE        DRF_S_STAT_INFO
* | [<-->] CT_CHANGED_OBJECTS             TYPE        SORTED TABLE
* | [!CX!] CX_DRF_ANALYZE_CHANGES
* | [!CX!] CX_DRF_EXCEPTION
* +--------------------------------------------------------------------------------------</SIGNATURE>
  method IF_DRF_OUTBOUND~ANALYZE_CHANGES_BY_OTHERS.

  endmethod.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_SUPPL_LOC_DRF_OUTBOUND->IF_DRF_OUTBOUND~APPLY_NODE_INST_FILTER_MULTI
* +-------------------------------------------------------------------------------------------------+
* | [--->] IT_EXTERNAL_CRITERIA           TYPE        RSDS_TRANGE
* | [--->] IT_FOBJ                        TYPE        DRF_T_FOBJ_IMPL
* | [--->] IV_IGNORE_FILTER               TYPE        ABAP_BOOL (default =' ')
* | [<-->] CT_RELEVANT_OBJECTS            TYPE        SORTED TABLE
* | [!CX!] CX_DRF_PROCESS_MESSAGES
* | [!CX!] CX_DRF_EXCEPTION
* +--------------------------------------------------------------------------------------</SIGNATURE>
  method IF_DRF_OUTBOUND~APPLY_NODE_INST_FILTER_MULTI.

  endmethod.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_SUPPL_LOC_DRF_OUTBOUND->IF_DRF_OUTBOUND~APPLY_NODE_INST_FILTER_SINGLE
* +-------------------------------------------------------------------------------------------------+
* | [--->] IT_EXTERNAL_CRITERIA           TYPE        RSDS_TRANGE
* | [--->] IT_FOBJ                        TYPE        DRF_T_FOBJ_IMPL
* | [--->] IV_IGNORE_FILTER               TYPE        ABAP_BOOL (default =' ')
* | [<---] EV_SKIP_OBJECT                 TYPE        ABAP_BOOL
* | [<-->] CR_RELEVANT_OBJECT             TYPE REF TO DATA
* | [!CX!] CX_DRF_PROCESS_MESSAGES
* | [!CX!] CX_DRF_EXCEPTION
* +--------------------------------------------------------------------------------------</SIGNATURE>
  method IF_DRF_OUTBOUND~APPLY_NODE_INST_FILTER_SINGLE.

  endmethod.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_SUPPL_LOC_DRF_OUTBOUND->IF_DRF_OUTBOUND~BUILD_PARALLEL_PACKAGE
* +-------------------------------------------------------------------------------------------------+
* | [--->] IR_PREPARE_DATA                TYPE        DATA
* | [<---] ER_PACKAGE_DATA                TYPE        DATA
* | [<---] ES_TASK_PARAM                  TYPE        DRF_S_PARALLEL_TASK_PARAM
* | [<---] EV_ALL_TASKS_DONE              TYPE        ABAP_BOOL
* +--------------------------------------------------------------------------------------</SIGNATURE>
  method IF_DRF_OUTBOUND~BUILD_PARALLEL_PACKAGE.

  endmethod.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_SUPPL_LOC_DRF_OUTBOUND->IF_DRF_OUTBOUND~ENRICH_FILTER_CRITERIA
* +-------------------------------------------------------------------------------------------------+
* | [--->] IT_EXTERNAL_CRITERIA           TYPE        RSDS_TRANGE
* | [<---] ET_ADD_EXTERNAL_CRITERIA       TYPE        RSDS_TRANGE
* | [<---] ES_STAT_INFO                   TYPE        DRF_S_STAT_INFO
* | [!CX!] CX_DRF_ENRICH_FILTER_PARAMETER
* | [!CX!] CX_DRF_EXCEPTION
* +--------------------------------------------------------------------------------------</SIGNATURE>
  method IF_DRF_OUTBOUND~ENRICH_FILTER_CRITERIA.


  endmethod.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_SUPPL_LOC_DRF_OUTBOUND->IF_DRF_OUTBOUND~FINALIZE
* +-------------------------------------------------------------------------------------------------+
* | [--->] IT_RELEVANT_OBJECTS            TYPE        SORTED TABLE
* | [--->] IT_ERRONEOUS_OBJECTS           TYPE        SORTED TABLE
* | [--->] IV_REPEATED_INITIAL_RUN        TYPE        BOOLE_D
* | [<---] EV_DELETE_CHANGE_POINTER       TYPE        BOOLE_D
* +--------------------------------------------------------------------------------------</SIGNATURE>
  method IF_DRF_OUTBOUND~FINALIZE.

  endmethod.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Static Public Method ZCL_SUPPL_LOC_DRF_OUTBOUND=>IF_DRF_OUTBOUND~INITIALIZE
* +-------------------------------------------------------------------------------------------------+
* | [--->] IS_RUNTIME_PARAM               TYPE        DRF_S_RUNTIME_PARAMETER_EXT
* | [<---] EO_IF_DRF_OUTBOUND             TYPE REF TO IF_DRF_OUTBOUND
* | [<---] ES_RUNTIME_PARAM_OUT_IMPL      TYPE        DRF_S_RUNTIME_PARAM_OUT_IMPL
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD IF_DRF_OUTBOUND~INITIALIZE.
**********************************************************************
*   Initialization of the DRF Outbound Implementation for Location
*   Replication
**********************************************************************
    DATA: ls_runtime_parameter TYPE drf_s_runtime_param_out_impl,
          lr_drf_loc_outbound  TYPE REF TO zcl_suppl_loc_drf_outbound.

**********************************************************************
*   Initialize the exporting parameter
**********************************************************************
    CLEAR: eo_if_drf_outbound,
           es_runtime_param_out_impl.

**********************************************************************
*   Create an instance of myself in order to remember the runtime
*   parameters for all subsequent methods and pass it to the framework
**********************************************************************
    TRY.
        CREATE OBJECT lr_drf_loc_outbound.
      CATCH cx_sy_create_object_error.
        RETURN.
    ENDTRY.

    IF lr_drf_loc_outbound IS BOUND.
      lr_drf_loc_outbound->ms_runtime_parameter = is_runtime_param.
    ENDIF.

**********************************************************************
*   Set own runtime parameter
**********************************************************************
    ls_runtime_parameter-table_type_name = mc_t_drf_loc_outb.
    es_runtime_param_out_impl = ls_runtime_parameter.

**********************************************************************
*   Set Outbound Implementation
**********************************************************************
    eo_if_drf_outbound = lr_drf_loc_outbound.

  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_SUPPL_LOC_DRF_OUTBOUND->IF_DRF_OUTBOUND~MAP_DATA2MESSAGE
* +-------------------------------------------------------------------------------------------------+
* | [--->] IR_RELEVANT_OBJECT             TYPE REF TO DATA
* | [--->] IS_BUS_SYS_TECH                TYPE        MDG_S_BUS_SYS_TECH(optional)
* | [!CX!] CX_DRF_PROCESS_MESSAGES
* | [!CX!] CX_DRF_EXCEPTION
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD if_drf_outbound~map_data2message.
    DATA:
      lr_rel_obj         TYPE REF TO zdrf_s_suppl_outbound,
      lv_timezone        TYPE tznzone,
      ls_loc_bulk        TYPE sapplco_loc_blk_repl_req_msg,
      ls_loc_repl_mess   TYPE sapplco_loc_repl_req_msg,
      lt_loc_repl_mess   TYPE sapplco_loc_repl_req_msg_tab,
      ls_loc_description TYPE sapplco_short_description,
      lv_loc_form_name   TYPE sapplco_languageindependent_me,
      ls_loc_tel         TYPE sapplco_telephone,
      ls_loc_facs        TYPE sapplco_facsimile,
      ls_loc_email       TYPE sapplco_nosc_email,
      ls_loc_web         TYPE sapplco_nosc_web,
      ls_loc_address     TYPE sapplco_nosc_address.

    FIELD-SYMBOLS:
      <ls_suppl_addr1_data> TYPE addr1_data.

    lr_rel_obj ?= ir_relevant_object.

*   Fill Message Header for Bulk Service
    fill_message_header(
     IMPORTING
       es_message_header =  ls_loc_bulk-message_header ).

    READ TABLE mt_suppl_data ASSIGNING FIELD-SYMBOL(<ls_suppl_data>)
      WITH KEY lifnr = lr_rel_obj->lifnr.
    IF sy-subrc NE 0.
      RETURN.
    ENDIF.

*   Fill Message Header for Location Replication
    fill_message_header(
     IMPORTING
       es_message_header =  ls_loc_repl_mess-message_header ).

    CONCATENATE 'VE_' <ls_suppl_data>-lifnr INTO ls_loc_repl_mess-location-location_internal_id.

*   Location Type Code for SUPPLomer Location
    ls_loc_repl_mess-location-location_type_code = '1011'.

**********************************************************************
*   Address and Description
**********************************************************************
    READ TABLE mt_suppl_address ASSIGNING FIELD-SYMBOL(<ls_suppl_addr_data>)
      WITH KEY addrnumber = <ls_suppl_data>-adrnr.
    IF sy-subrc <> 0.
*     Error -> No Address found for the plant
    ELSE.
      LOOP AT <ls_suppl_addr_data>-addr1_tab ASSIGNING FIELD-SYMBOL(<ls_suppl_addr1>).
        ASSIGN <ls_suppl_addr1>-data TO <ls_suppl_addr1_data>.
        IF NOT ( <ls_suppl_addr1_data>-date_from <= sy-datum AND
                 <ls_suppl_addr1_data>-date_to >= sy-datum ).
*         Not Valid Address
          CONTINUE.
        ENDIF.

*       Description (NAME1 from Address is used as text) -> Here Description of Shipping/Receiving Point.
        LOOP AT mt_suppl_data_txt ASSIGNING FIELD-SYMBOL(<ls_suppl_data_txt>) WHERE lifnr = <ls_suppl_data>-lifnr.
          CLEAR ls_loc_description.
          ls_loc_description-language_code = <ls_suppl_data_txt>-spras.
          ls_loc_description-content       = <ls_suppl_data_txt>-vtext.
          INSERT ls_loc_description INTO TABLE ls_loc_repl_mess-location-description.
        ENDLOOP.

*       Time Zone
        IF  <ls_suppl_addr1_data>-time_zone IS NOT INITIAL.
          ls_loc_repl_mess-location-time_zone_code = <ls_suppl_addr1_data>-time_zone.
        ELSE.
          CALL FUNCTION 'TZON_LOCATION_TIMEZONE'
            EXPORTING
              if_country        = <ls_suppl_addr1_data>-country
              if_region         = <ls_suppl_addr1_data>-region
            IMPORTING
              ef_timezone       = lv_timezone
            EXCEPTIONS
              no_timezone_found = 1
              OTHERS            = 2.
          IF sy-subrc <> 0.
            CLEAR ls_loc_repl_mess-location-time_zone_code.
          ELSE.
            ls_loc_repl_mess-location-time_zone_code = lv_timezone.
          ENDIF.
        ENDIF.

**********************************************************************
*       Organization formatted Name
**********************************************************************
        ls_loc_address-organisation_form_of_address-code = <ls_suppl_addr1_data>-title.
        IF <ls_suppl_addr1_data>-name1 IS NOT INITIAL.
          lv_loc_form_name = <ls_suppl_addr1_data>-name1.
          INSERT lv_loc_form_name INTO TABLE ls_loc_address-organisation_formatted_name.
        ENDIF.
        IF <ls_suppl_addr1_data>-name2 IS NOT INITIAL.
          lv_loc_form_name = <ls_suppl_addr1_data>-name2.
          INSERT lv_loc_form_name INTO TABLE ls_loc_address-organisation_formatted_name.
        ENDIF.
        IF <ls_suppl_addr1_data>-name3 IS NOT INITIAL.
          lv_loc_form_name = <ls_suppl_addr1_data>-name3.
          INSERT lv_loc_form_name INTO TABLE ls_loc_address-organisation_formatted_name.
        ENDIF.
        IF <ls_suppl_addr1_data>-name4 IS NOT INITIAL.
          lv_loc_form_name = <ls_suppl_addr1_data>-name4.
          INSERT lv_loc_form_name INTO TABLE ls_loc_address-organisation_formatted_name.
        ENDIF.
        IF <ls_suppl_addr1_data>-name_txt IS NOT INITIAL.
          lv_loc_form_name = <ls_suppl_addr1_data>-name_txt.
          INSERT lv_loc_form_name INTO TABLE ls_loc_address-organisation_formatted_name.
        ENDIF.

**********************************************************************
*       Physical Address
**********************************************************************
        ls_loc_address-physical_address-country_code               = <ls_suppl_addr1_data>-country.
        ls_loc_address-physical_address-country_name-language_code = <ls_suppl_addr1_data>-langu.
        ls_loc_address-physical_address-region_code                = <ls_suppl_addr1_data>-region.
        ls_loc_address-physical_address-city_name                  = <ls_suppl_addr1_data>-city1.
        ls_loc_address-physical_address-additional_city_name       = <ls_suppl_addr1_data>-home_city.
        ls_loc_address-physical_address-pobox_country_code         = <ls_suppl_addr1_data>-po_box_cty.
        ls_loc_address-physical_address-pobox_region_code          = <ls_suppl_addr1_data>-po_box_reg.
        ls_loc_address-physical_address-pobox_id                   = <ls_suppl_addr1_data>-po_box.

        cl_gdt_conversion=>indicator_outbound(
          EXPORTING
            im_value = <ls_suppl_addr1_data>-po_box_num            " ABAP Flag: 'X' ="true, ' ' = false
          IMPORTING
            ex_value = ls_loc_address-physical_address-pobox_indicator ).                " XSD:Indicator
        ls_loc_address-physical_address-street_postal_code         = <ls_suppl_addr1_data>-post_code1.
        ls_loc_address-physical_address-pobox_postal_code          = <ls_suppl_addr1_data>-post_code2.
        ls_loc_address-physical_address-company_postal_code        = <ls_suppl_addr1_data>-post_code3.
        ls_loc_address-physical_address-house_id                   = <ls_suppl_addr1_data>-house_num1.
        ls_loc_address-physical_address-additional_house_id        = <ls_suppl_addr1_data>-house_num2.
        ls_loc_address-physical_address-district_name              = <ls_suppl_addr1_data>-city2.
        ls_loc_address-physical_address-building_id                = <ls_suppl_addr1_data>-building.
        ls_loc_address-physical_address-floor_id                   = <ls_suppl_addr1_data>-floor.
        ls_loc_address-physical_address-room_id                    = <ls_suppl_addr1_data>-roomnumber.
        ls_loc_address-physical_address-street_name                = <ls_suppl_addr1_data>-street.

        IF <ls_suppl_addr1_data>-str_suppl1 IS NOT INITIAL OR <ls_suppl_addr1_data>-str_suppl2 IS NOT INITIAL.
          INSERT <ls_suppl_addr1_data>-str_suppl1 INTO TABLE ls_loc_address-physical_address-street_prefix_name.
          INSERT <ls_suppl_addr1_data>-str_suppl2 INTO TABLE ls_loc_address-physical_address-street_prefix_name.
        ENDIF.
        IF <ls_suppl_addr1_data>-str_suppl3 IS NOT INITIAL OR <ls_suppl_addr1_data>-location IS NOT INITIAL.
          INSERT <ls_suppl_addr1_data>-str_suppl3 INTO TABLE ls_loc_address-physical_address-street_suffix_name.
          INSERT <ls_suppl_addr1_data>-location   INTO TABLE ls_loc_address-physical_address-street_suffix_name.
        ENDIF.

*       Office
        ls_loc_address-office-building_id = <ls_suppl_addr1_data>-building.
        ls_loc_address-office-floor_id    = <ls_suppl_addr1_data>-floor.
        ls_loc_address-office-room_id     = <ls_suppl_addr1_data>-roomnumber.

*       Communication
        ls_loc_address-communication-correspondence_language_code = <ls_suppl_addr1_data>-langu.

*       Phone
        LOOP AT <ls_suppl_addr_data>-adtel_tab ASSIGNING FIELD-SYMBOL(<ls_suppl_addr_adtel_data>).
          CLEAR ls_loc_tel.
          ls_loc_tel-number-country_code      = <ls_suppl_addr_adtel_data>-adtel-country.
          ls_loc_tel-number-subscriber_id     = <ls_suppl_addr_adtel_data>-adtel-tel_number.
          ls_loc_tel-number-extension_id      = <ls_suppl_addr_adtel_data>-adtel-tel_extens.
          ls_loc_tel-number-country_code      = <ls_suppl_addr_adtel_data>-adtel-country.

          cl_gdt_conversion=>indicator_outbound(
            EXPORTING
              im_value = <ls_suppl_addr_adtel_data>-adtel-flgdefault            " ABAP Flag: 'X' ="true, ' ' = false
            IMPORTING
              ex_value = ls_loc_tel-number_default_indicator ).                " XSD:Indicator

          cl_gdt_conversion=>indicator_outbound(
            EXPORTING
              im_value = <ls_suppl_addr_adtel_data>-adtel-dft_receiv           " ABAP Flag: 'X' ="true, ' ' = false
            IMPORTING
              ex_value = ls_loc_tel-smsenabled_indicator ).                   " XSD:Indicator
          INSERT ls_loc_tel INTO TABLE ls_loc_address-communication-telephone.
        ENDLOOP.

*       Fax
        LOOP AT <ls_suppl_addr_data>-adfax_tab ASSIGNING FIELD-SYMBOL(<ls_suppl_addr_adfax_data>).
          ls_loc_facs-number-country_code      = <ls_suppl_addr_adfax_data>-adfax-country.
          ls_loc_facs-number-subscriber_id     = <ls_suppl_addr_adfax_data>-adfax-fax_number.
          ls_loc_facs-number-extension_id      = <ls_suppl_addr_adfax_data>-adfax-fax_extens.
          ls_loc_facs-number-country_code      = <ls_suppl_addr_adfax_data>-adfax-country.
          cl_gdt_conversion=>indicator_outbound(
            EXPORTING
              im_value = <ls_suppl_addr_adfax_data>-adfax-flgdefault           " ABAP Flag: 'X' ="true, ' ' = false
            IMPORTING
              ex_value = ls_loc_facs-number_default_indicator ).                " XSD:Indicator

          INSERT ls_loc_facs INTO TABLE ls_loc_address-communication-facsimile.
        ENDLOOP.

*       E-mail
        LOOP AT <ls_suppl_addr_data>-adsmtp_tab ASSIGNING FIELD-SYMBOL(<ls_suppl_addr_adsmtp_data>).
          CLEAR ls_loc_email.
          ls_loc_email-uri                  = <ls_suppl_addr_adsmtp_data>-adsmtp-smtp_addr.
          cl_gdt_conversion=>indicator_outbound(
            EXPORTING
              im_value = <ls_suppl_addr_adsmtp_data>-adsmtp-dft_receiv        " ABAP Flag: 'X' ="true, ' ' = false
            IMPORTING
              ex_value = ls_loc_email-uridefault_indicator ).                " XSD:Indicator

          INSERT ls_loc_email INTO TABLE ls_loc_address-communication-email.
        ENDLOOP.

*       Web
        LOOP AT <ls_suppl_addr_data>-aduri_tab ASSIGNING FIELD-SYMBOL(<ls_suppl_addr_aduri>).
          IF <ls_suppl_addr_aduri>-aduri-uri_type = 'HPG' . " Location Type HPG(Homepage) is transffered only
            CLEAR ls_loc_web.
            ls_loc_web-uri = <ls_suppl_addr_aduri>-aduri-uri_addr.
            cl_gdt_conversion=>indicator_outbound(
              EXPORTING
                im_value = <ls_suppl_addr_aduri>-aduri-flgdefault          " ABAP Flag: 'X' ="true, ' ' = false
              IMPORTING
                ex_value = ls_loc_web-uridefault_indicator ).             " XSD:Indicator

            INSERT ls_loc_web INTO TABLE ls_loc_address-communication-web.
          ENDIF.
        ENDLOOP.
*       Only one valid address
        ls_loc_repl_mess-location-address = ls_loc_address.
        EXIT.
      ENDLOOP.
    ENDIF.

    ms_loc_bulk_repl_req-location_bulk_replication_req-message_header = ls_loc_bulk-message_header.
    INSERT ls_loc_repl_mess INTO TABLE lt_loc_repl_mess.
    INSERT LINES OF lt_loc_repl_mess INTO TABLE ms_loc_bulk_repl_req-location_bulk_replication_req-loc_repl_req_msg.

  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_SUPPL_LOC_DRF_OUTBOUND->IF_DRF_OUTBOUND~READ_COMPLETE_DATA
* +-------------------------------------------------------------------------------------------------+
* | [<-->] CT_RELEVANT_OBJECTS            TYPE        SORTED TABLE
* | [!CX!] CX_DRF_PROCESS_MESSAGES
* | [!CX!] CX_DRF_EXCEPTION
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD if_drf_outbound~read_complete_data.
**********************************************************************
*   Read the data of all records that shall be replicated later on
*   via the new Location Service.
**********************************************************************

    DATA:
      lt_bus_sys_tech        TYPE mdg_t_bus_sys_tech,
      lv_own_business_system TYPE text60,
      ls_lifnr               TYPE tys_lifnr,
      lt_lifnr               TYPE TABLE OF tys_lifnr,
      lt_adrc                TYPE szadr_adrc_table,
      ls_adrc                TYPE szadr_st_adrc,
      lt_addr_error          TYPE szadr_error_table.

    FIELD-SYMBOLS:
      <ls_suppl_data>       TYPE tys_suppl_data,
      <ls_loc_drf_outbound> TYPE any,
      <lv_comp>             TYPE any.


**********************************************************************
*   Get Business System Data
**********************************************************************

*   Get own Logical System
    CALL FUNCTION 'LCR_GET_OWN_BUSINESS_SYSTEM'
      IMPORTING
        bs_key_name            = lv_own_business_system
      EXCEPTIONS
        no_business_system     = 1
        no_rfc_destination     = 2
        no_landscape_directory = 3
        illegal_arguments      = 4
        communication_error    = 5
        ld_error               = 6
        sld_api_exception      = 7
        OTHERS                 = 8.
    IF sy-subrc NE 0.
      RETURN. " RAISE no_business_system.
    ENDIF.

    mv_sender_bussystem_id = lv_own_business_system.

    CALL METHOD cl_drf_access_cust_data=>select_business_sys_for_appl
      EXPORTING
        iv_appl         = ms_runtime_parameter-appl
        iv_outb_impl    = ms_runtime_parameter-outb_impl
      IMPORTING
        et_bus_sys_tech = lt_bus_sys_tech.

    READ TABLE lt_bus_sys_tech ASSIGNING FIELD-SYMBOL(<ls_bus_sys_tech>) INDEX 1. "#EC CI_NOORDER

    mv_receiver_bussystem_id = <ls_bus_sys_tech>-business_system.

**********************************************************************
*   Build up table lt_lifnr
**********************************************************************
    LOOP AT ct_relevant_objects ASSIGNING <ls_loc_drf_outbound>.
      CLEAR ls_lifnr.
      UNASSIGN <lv_comp>.

      ASSIGN COMPONENT 'lifnr' OF STRUCTURE <ls_loc_drf_outbound> TO <lv_comp>.
      IF sy-subrc = 0 AND <lv_comp> IS ASSIGNED.
        ls_lifnr = <lv_comp>.
        INSERT ls_lifnr INTO TABLE lt_lifnr.
      ENDIF.
    ENDLOOP.

**********************************************************************
*   Retrieve Data of supplier general data
**********************************************************************
    IF lt_lifnr IS NOT INITIAL.
      SELECT lifnr spras adrnr FROM lfa1
        INTO CORRESPONDING FIELDS OF TABLE mt_suppl_data
        FOR ALL ENTRIES IN lt_lifnr
        WHERE lifnr = lt_lifnr-lifnr.
      IF sy-subrc <> 0.
        RAISE EXCEPTION TYPE cx_drf_process_messages.
      ENDIF.
    ELSE.
      RAISE EXCEPTION TYPE cx_drf_process_messages.
    ENDIF.

**********************************************************************
*   Retrieve Text Data of supplier general data ( not existing)
**********************************************************************
*    IF lt_lifnr IS NOT INITIAL.
*      SELECT spras vstel vtext FROM tvstt
*        INTO CORRESPONDING FIELDS OF TABLE mt_suppl_data_txt
*        FOR ALL ENTRIES IN lt_lifnr
*        WHERE lifnr = lt_lifnr-lifnr.
*      IF sy-subrc <> 0.
*        RAISE EXCEPTION TYPE cx_drf_process_messages.
*      ENDIF.
*    ELSE.
*      RAISE EXCEPTION TYPE cx_drf_process_messages.
*    ENDIF.
*
**********************************************************************
*   Retrieve Addresses of the supplier
**********************************************************************
    CLEAR lt_adrc.
    LOOP AT mt_suppl_data ASSIGNING <ls_suppl_data>.
      IF <ls_suppl_data>-adrnr IS NOT INITIAL.
        ls_adrc-addrnumber = <ls_suppl_data>-adrnr.
        INSERT ls_adrc INTO TABLE lt_adrc.
      ENDIF.
    ENDLOOP.
    IF lt_adrc IS NOT INITIAL.
      CALL FUNCTION 'ADDR_GET_COMPLETE_DB_MASS'
        EXPORTING
          iv_current_comm_data = 'X'
        TABLES
          address_selection    = lt_adrc
          sz_addr1_complete    = mt_suppl_address
          sz_error_table       = lt_addr_error.

    ENDIF.

  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_SUPPL_LOC_DRF_OUTBOUND->IF_DRF_OUTBOUND~SEND_MESSAGE
* +-------------------------------------------------------------------------------------------------+
* | [--->] IS_FILE_INFO                   TYPE        DRF_S_FILE_INFO(optional)
* | [--->] IV_OBJECT_COUNT                TYPE        DRF_PACKAGE_SIZE(optional)
* | [--->] IS_BUS_SYS_TECH                TYPE        MDG_S_BUS_SYS_TECH(optional)
* | [<---] ET_FILE_DATA                   TYPE        DRF_T_FILE_OI_CONTENT
* | [<---] ET_MESSAGE                     TYPE        DRF_T_MESSAGE
* | [<-->] CT_OBJ_REP_STA                 TYPE        DRF_T_OBJ_REP_STA_FULL(optional)
* | [!CX!] CX_DRF_PROCESS_MESSAGES
* | [!CX!] CX_DRF_EXCEPTION
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD IF_DRF_OUTBOUND~SEND_MESSAGE.
**********************************************************************
* The method calls the servcice LocationBulkReplicationRequest_Out
*   Class: CO_LOC_LOC_BULK_REPL_REQ_OUT
*   Method: LOC_BULK_REPLICATION_REQ_OUT
* Parameter OUTPUT Type LOC_BULK_REPLICATION_REQ
**********************************************************************
* The service will be called under the followinng circumstances:
* Attribute MS_LOC_BULK_REPL_REQ is not initial
* Attribute MS_RUNTIME_PARAMETER-TESTRUN is not abap_false
* That means, location data for replication are available and
* the DRFOUT wasn't called in test mode.
**********************************************************************

    TYPES: BEGIN OF ty_object_id,
             prefix TYPE char3,
             id     TYPE char4,
           END OF ty_object_id.

    DATA:
      ls_message_data_outbound     TYPE loc_bulk_replication_req, "TYPE sapplco_loc_blk_repl_req_msg,
      lv_path_message_header       TYPE string,
      lv_path_sequence_fields      TYPE string,
      lv_default_service_group     TYPE xflag,
      lv_service_group             TYPE srt_wsp_dt_obj_name,
      lv_recipient_business_system TYPE sld_bskey,
      lv_application_id            TYPE bs_soa_appl_id,
      lv_tech_seq_context          TYPE bs_soa_asyncprx_cntxt,
      lv_appl_seq_context          TYPE bs_soa_inappseq_cntxt,
      lv_reference_message_id      TYPE bs_soa_rspnsrcvr_msg_id,
      lv_correlation_id            TYPE bs_soa_rspnsrcvr_corel_id,
      lv_reconciliation_requested  TYPE xflag,
      ls_lrd_filter                TYPE lrd_sld_bskey,
      lo_bs_soa_exception          TYPE REF TO cx_bs_soa_exception,
      lt_outbound_proxy            TYPE bssoa_asyncprx_instance_t ##needed.


    DATA:
      lo_xi_error                  TYPE REF TO cx_ai_system_fault,
      lv_error_txt                 TYPE string,
      lv_error_long_txt            TYPE string,
      lv_object_id                 TYPE ty_object_id,
      ls_loc_repl_req_msg          TYPE sapplco_loc_repl_req_msg.

    FIELD-SYMBOLS:
          <ls_obj_rep_sta>       TYPE drf_s_obj_rep_sta_attr.

***********************************************************************
**   Initialize the exporting parameter
***********************************************************************
    CLEAR: et_file_data,    "Not used
           et_message.

**********************************************************************
*   Check if the service could be triggerd
*   Location Data for replication are available and Test Mode OFF
**********************************************************************
    IF ms_runtime_parameter-testrun = abap_true.
      "Test Mode --> No Service Call
      RETURN.
    ENDIF.

    IF ms_loc_bulk_repl_req IS NOT INITIAL.
      "Replication data available

      "Update Replication Status Object with the message_header-UUID (Message Link)
      "to be able to identify the message later on in the inbound
      LOOP AT ms_loc_bulk_repl_req-location_bulk_replication_req-loc_repl_req_msg
              INTO ls_loc_repl_req_msg.
        lv_object_id = ls_loc_repl_req_msg-location-location_internal_id.
        READ TABLE ct_obj_rep_sta ASSIGNING <ls_obj_rep_sta>
             WITH KEY object_id = lv_object_id-id.
        IF sy-subrc = 0.
          "Entry found --> Set the message_header-UUID
          <ls_obj_rep_sta>-msg_link = ls_loc_repl_req_msg-message_header-id-content.
        ENDIF.
      ENDLOOP.

      ls_message_data_outbound = ms_loc_bulk_repl_req.
      lv_path_message_header  = 'LOCATION_BULK_REPLICATION_REQ-MESSAGE_HEADER'.
      lv_path_sequence_fields = 'LOCATION_BULK_REPLICATION_REQ-LOC_REPL_REQ_MSG'.
      lv_service_group        = 'LOCATION_REPLICATE_REQ'.
      lv_recipient_business_system = mv_receiver_bussystem_id.
      ls_lrd_filter-bskey          = lv_recipient_business_system.

*   Context Build
      CONCATENATE sy-sysid sy-mandt 'LOC_REPL_REQ'
         INTO lv_tech_seq_context.

      lv_appl_seq_context = 'LOCREQ'.

      TRY.
          CALL METHOD cl_bs_soa_asyncprx_out=>execute
            EXPORTING
              iv_proxy_class               = 'CO_LOC_LOC_BULK_REPL_REQ_OUT'
              iv_method                    = 'LOC_BULK_REPLICATION_REQ_OUT'
              iv_obj_type                  = 'BUS10002'
              iv_path_msg_header           = lv_path_message_header
              iv_path_of_seq_fields        = lv_path_sequence_fields
              iv_service_group             = lv_service_group
              iv_logical_receiver_det_struc = ls_lrd_filter
              iv_default_service_group     = lv_default_service_group
              iv_recipient_business_system = lv_recipient_business_system
              iv_application_id            = lv_application_id
              iv_tech_seq_context          = lv_tech_seq_context
              iv_appl_seq_context          = lv_appl_seq_context
              iv_reference_message_id      = lv_reference_message_id
              iv_correlation_id            = lv_correlation_id
              iv_reconciliation_requested  = lv_reconciliation_requested
            IMPORTING
              et_proxy_instances           = lt_outbound_proxy
            CHANGING
              cs_message_data_outbound     = ls_message_data_outbound.

        CATCH cx_bs_soa_exception INTO lo_bs_soa_exception .
          "Communication Error
          "Get Error Text
          CALL METHOD lo_bs_soa_exception->get_text
            RECEIVING
              result = lv_error_txt.
          "Get Long Text
          CALL METHOD lo_bs_soa_exception->get_longtext
            RECEIVING
              result = lv_error_long_txt.
          "Write Message to the BAL
          "DRF_OUTBOUND 015 - Error during proxy call (&1: &2, &3)
          "ADD_MSG_RE --> Add Message and Raise Exception
          CALL METHOD ms_runtime_parameter-bal->add_msg_re
            EXPORTING
              iv_msgno = '015'
              iv_msgid = 'DRF_OUTBOUND'
              iv_msgv1 = 'CO_LOC_LOC_BULK_REPL_REQ_OUT'
              iv_msgv2 = lv_error_txt
              iv_msgv3 = lv_error_long_txt.

        CATCH cx_ai_system_fault INTO lo_xi_error.
          "Application Integration: Technical Error
          "Write BAL - DRF_OUTBOUND 013 - Error while creating the &1 proxy instance
          CALL METHOD ms_runtime_parameter-bal->add_msg_re
            EXPORTING
              iv_msgno             = '013'
              iv_msgid             = 'DRF_OUTBOUND'
              iv_msgv1             = 'CO_LOC_LOC_BULK_REPL_REQ_OUT'
              ix_exception_catched = lo_xi_error.

      ENDTRY.
    ELSE.
      "No Replication data available
      "Add Message to the BAL
      "DRF_OUTBOUND 322 - System does not send blank messages
      CALL METHOD ms_runtime_parameter-bal->add_msg_re
        EXPORTING
          iv_msgno = '322'
          iv_msgid = 'DRF_OUTBOUND'.
    ENDIF.
*   Clear Message for new Message Run
    CLEAR ms_loc_bulk_repl_req.
  ENDMETHOD.
ENDCLASS.

 

Replication of Customer

Follow the similar steps as above below is the list of objects you must create.

Structure:

ZDRF_S_CUST_OUTBOUND

Table Type:

ZDRF_T_CUST_OUTBOUND

Class:

ZCL_CUST_LOC_DRF_EXPL_FILTER

ZCL _CUST_LOC_DRF_OUTBOUND

 

Structure: ZDRF_S_CUST_OUTBOUND

 

 

Table Type:      ZDRF_T_CUST_OUTBOUND

 

 

Clas : ZCL_CUST_LOC_DRF_EXPL_FILTER

class ZCL_CUST_LOC_DRF_EXPL_FILTER definition
  public
  final
  create public .

public section.

  interfaces IF_DRF_FILTER .
protected section.
private section.
ENDCLASS.



CLASS ZCL_CUST_LOC_DRF_EXPL_FILTER IMPLEMENTATION.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_CUST_LOC_DRF_EXPL_FILTER->IF_DRF_FILTER~APPLY_FILTER
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_APPL                        TYPE        DRF_APPL
* | [--->] IV_BUSINESS_SYSTEM             TYPE        MDG_BUSINESS_SYSTEM
* | [--->] IS_C_FOBJ                      TYPE        DRF_S_C_FOBJ_RUNTIME
* | [--->] IV_OUTB_IMPL                   TYPE        DRF_OUTB_IMPL
* | [--->] IV_DLMOD                       TYPE        DRF_DLMOD
* | [--->] IV_RUNMOD                      TYPE        DRF_RUNMOD
* | [--->] IS_FILT                        TYPE        DRF_S_C_FILT_RUNTIME
* | [--->] IO_BAL                         TYPE REF TO CL_DRF_BAL
* | [--->] IT_EXTERNAL_CRITERIA           TYPE        RSDS_TRANGE
* | [--->] IT_UNFILTERED_OBJECTS          TYPE        SORTED TABLE
* | [--->] IS_ADDITIONAL_PARAMETER        TYPE        DRF_S_RTIME_PARAM_ADDITIONAL(optional)
* | [<---] ET_FILTERED_OBJECTS            TYPE        SORTED TABLE
* | [!CX!] CX_DRF_FILTER_OBJECT
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD IF_DRF_FILTER~APPLY_FILTER.
**********************************************************************
* Explicit Filter implementation for the DRF Outbound for Shipping Points
* The following filter structure is assigned to the explicit filter
* in the customizing: DRF_S_cust_LOC_EXPL_FILTER
* The filter structure contains the following components:
*    kunnr   TYPE kunnr
**********************************************************************
    DATA:
      ls_selopt            TYPE rsdsselopt,
      lt_cust_range        TYPE rsds_selopt_t,
      lt_cust_range_unf    TYPE rsds_selopt_t,
      lt_cust_drf_outbound TYPE ZDRF_T_CUST_OUTBOUND.

    FIELD-SYMBOLS:
      <ls_ext_criteria>       TYPE rsds_range,
      <ls_filter_range>       TYPE rsds_frange,
      <ls_unfiltered_objects> TYPE ZDRF_S_CUST_OUTBOUND.

**********************************************************************
*   Initialize the exporting parameters
**********************************************************************
    CLEAR et_filtered_objects.

**********************************************************************
*   Process the external filter criteria and split them into the
*   corresponding component range tables
**********************************************************************
    LOOP AT it_external_criteria ASSIGNING <ls_ext_criteria>.
      LOOP AT <ls_ext_criteria>-frange_t ASSIGNING <ls_filter_range>.
        CASE <ls_filter_range>-fieldname.
          WHEN 'KUNNR'.
            INSERT LINES OF <ls_filter_range>-selopt_t INTO TABLE lt_cust_range.
        ENDCASE.
      ENDLOOP.
    ENDLOOP.

**********************************************************************
*   Take care of the unfiltered objects and add them to the corresponding
*   Range Select Options
**********************************************************************
    LOOP AT it_unfiltered_objects ASSIGNING <ls_unfiltered_objects>.
      IF <ls_unfiltered_objects>-kunnr IS NOT INITIAL.
        CLEAR ls_selopt.
        ls_selopt-sign = if_drf_const=>range_sign_inclusive. "'I'
        ls_selopt-option = if_drf_const=>range_option_equal. "'EQ'
        ls_selopt-low = <ls_unfiltered_objects>-kunnr.
        INSERT ls_selopt INTO TABLE lt_cust_range_unf.
      ENDIF.
    ENDLOOP.

    "Add the unfiltered object to the affected range for the selection
    IF lt_cust_range_unf IS NOT INITIAL.
      INSERT LINES OF lt_cust_range_unf INTO TABLE lt_cust_range.
    ENDIF.

**********************************************************************
*   Select LOCNO and LOCTYPE from /SAPAPO/LOC
**********************************************************************
    SELECT kunnr FROM kna1
           INTO CORRESPONDING FIELDS OF TABLE lt_cust_drf_outbound
           WHERE kunnr IN lt_cust_range.

**********************************************************************
*   Fill the exporting parameters
**********************************************************************
    INSERT LINES OF lt_cust_drf_outbound INTO TABLE et_filtered_objects.

  ENDMETHOD.
ENDCLASS.

Class: ZCL _CUST_LOC_DRF_OUTBOUND

class ZCL_CUST_LOC_DRF_OUTBOUND definition
  public
  final
  create public .

public section.

  interfaces IF_DRF_OUTBOUND .
protected section.

  types:
    BEGIN OF tys_cust_data,
      kunnr    TYPE kunnr,
      spras    TYPE spras,
      adrnr    TYPE adrnr,
    END OF tys_cust_data .
  types:
    tt_cust_data TYPE STANDARD TABLE OF tys_cust_data .
  types:
    BEGIN OF tys_cust_data_txt,
      spras    TYPE spras,
      kunnr    TYPE kunnr,
      vtext    TYPE vtext,
    END OF tys_cust_data_txt .
  types:
    tt_cust_data_txt TYPE STANDARD TABLE OF tys_cust_data_txt .
  types:
    BEGIN OF tys_kunnr,
      kunnr TYPE kunnr,
    END OF tys_kunnr .

  data MT_cust_ADDRESS type SZADR_ADDR1_TABLE .
  data MT_cust_DATA type TT_cust_DATA .
  data MT_cust_DATA_TXT type TT_cust_DATA_TXT .
  data MS_RUNTIME_PARAMETER type DRF_S_RUNTIME_PARAMETER_EXT .
  data MS_LOC_BULK_REPL_REQ type LOC_BULK_REPLICATION_REQ .
  constants MC_T_DRF_LOC_OUTB type STRING value 'ZDRF_T_CUST_OUTBOUND'  ##NO_TEXT.
  constants MC_S_DRF_LOC_OUTBOUND type STRING value 'ZDRF_S_CUST_OUTBOUND' ##NO_TEXT.
  data MV_SENDER_BUSSYSTEM_ID type SAPPLCO_BUSINESS_SYSTEM_ID .
  data MV_RECEIVER_BUSSYSTEM_ID type SAPPLCO_BUSINESS_SYSTEM_ID .
private section.

  methods FILL_MESSAGE_HEADER
    exporting
      !ES_MESSAGE_HEADER type SAPPLCO_BUS_DOC_MESSAGE_HEADER .
ENDCLASS.



CLASS ZCL_RAV_CUST_LOC_DRF_OUTBOUND IMPLEMENTATION.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Private Method ZCL_CUST_LOC_DRF_OUTBOUND->FILL_MESSAGE_HEADER
* +-------------------------------------------------------------------------------------------------+
* | [<---] ES_MESSAGE_HEADER              TYPE        SAPPLCO_BUS_DOC_MESSAGE_HEADER
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD FILL_MESSAGE_HEADER.
    DATA:
      lv_uuid                TYPE char32,
      lv_timestamp           TYPE timestampl.

    CLEAR es_message_header.

    GET TIME STAMP FIELD lv_timestamp.

    cl_gdt_conversion=>date_time_outbound(
      EXPORTING
        im_value_long = lv_timestamp
      IMPORTING
        ex_value       = es_message_header-creation_date_time               " Time Stamp According to ISO 8601
    ).

    es_message_header-sender_business_system_id    = mv_sender_bussystem_id.
    es_message_header-recipient_business_system_id = mv_receiver_bussystem_id.

    TRY.
        lv_uuid  = cl_system_uuid=>create_uuid_x16_static( ).
      CATCH cx_uuid_error.
        "Should never occur
        ASSERT 1 = 0.
    ENDTRY.
    es_message_header-id-content = lv_uuid.
    cl_gdt_conversion=>guid_outbound(
      EXPORTING
        im_guid_c = lv_uuid                                        " GUID in Character Display
      IMPORTING
        ex_value  = es_message_header-uuid-content                 " GUID / UUID in XML Display
    ).

  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_RAV_CUST_LOC_DRF_OUTBOUND->IF_DRF_OUTBOUND~ANALYZE_CHANGES_BY_CHG_POINTER
* +-------------------------------------------------------------------------------------------------+
* | [--->] IT_CHANGE_POINTER              TYPE        DRF_T_BDCP
* | [<---] ES_STAT_INFO                   TYPE        DRF_S_STAT_INFO
* | [<-->] CT_CHANGED_OBJECTS             TYPE        SORTED TABLE
* | [!CX!] CX_DRF_ANALYZE_CHANGES
* | [!CX!] CX_DRF_EXCEPTION
* +--------------------------------------------------------------------------------------</SIGNATURE>
  method IF_DRF_OUTBOUND~ANALYZE_CHANGES_BY_CHG_POINTER.

  endmethod.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_RAV_CUST_LOC_DRF_OUTBOUND->IF_DRF_OUTBOUND~ANALYZE_CHANGES_BY_MDG_CP
* +-------------------------------------------------------------------------------------------------+
* | [--->] IT_CHANGE_POINTER              TYPE        MDG_CP_T_CP
* | [<---] ES_STAT_INFO                   TYPE        DRF_S_STAT_INFO
* | [<-->] CT_CHANGED_OBJECTS             TYPE        SORTED TABLE
* | [!CX!] CX_DRF_ANALYZE_CHANGES
* | [!CX!] CX_DRF_EXCEPTION
* +--------------------------------------------------------------------------------------</SIGNATURE>
  method IF_DRF_OUTBOUND~ANALYZE_CHANGES_BY_MDG_CP.
  endmethod.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_RAV_CUST_LOC_DRF_OUTBOUND->IF_DRF_OUTBOUND~ANALYZE_CHANGES_BY_OTHERS
* +-------------------------------------------------------------------------------------------------+
* | [<---] ES_STAT_INFO                   TYPE        DRF_S_STAT_INFO
* | [<-->] CT_CHANGED_OBJECTS             TYPE        SORTED TABLE
* | [!CX!] CX_DRF_ANALYZE_CHANGES
* | [!CX!] CX_DRF_EXCEPTION
* +--------------------------------------------------------------------------------------</SIGNATURE>
  method IF_DRF_OUTBOUND~ANALYZE_CHANGES_BY_OTHERS.

  endmethod.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_RAV_CUST_LOC_DRF_OUTBOUND->IF_DRF_OUTBOUND~APPLY_NODE_INST_FILTER_MULTI
* +-------------------------------------------------------------------------------------------------+
* | [--->] IT_EXTERNAL_CRITERIA           TYPE        RSDS_TRANGE
* | [--->] IT_FOBJ                        TYPE        DRF_T_FOBJ_IMPL
* | [--->] IV_IGNORE_FILTER               TYPE        ABAP_BOOL (default =' ')
* | [<-->] CT_RELEVANT_OBJECTS            TYPE        SORTED TABLE
* | [!CX!] CX_DRF_PROCESS_MESSAGES
* | [!CX!] CX_DRF_EXCEPTION
* +--------------------------------------------------------------------------------------</SIGNATURE>
  method IF_DRF_OUTBOUND~APPLY_NODE_INST_FILTER_MULTI.

  endmethod.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_RAV_CUST_LOC_DRF_OUTBOUND->IF_DRF_OUTBOUND~APPLY_NODE_INST_FILTER_SINGLE
* +-------------------------------------------------------------------------------------------------+
* | [--->] IT_EXTERNAL_CRITERIA           TYPE        RSDS_TRANGE
* | [--->] IT_FOBJ                        TYPE        DRF_T_FOBJ_IMPL
* | [--->] IV_IGNORE_FILTER               TYPE        ABAP_BOOL (default =' ')
* | [<---] EV_SKIP_OBJECT                 TYPE        ABAP_BOOL
* | [<-->] CR_RELEVANT_OBJECT             TYPE REF TO DATA
* | [!CX!] CX_DRF_PROCESS_MESSAGES
* | [!CX!] CX_DRF_EXCEPTION
* +--------------------------------------------------------------------------------------</SIGNATURE>
  method IF_DRF_OUTBOUND~APPLY_NODE_INST_FILTER_SINGLE.

  endmethod.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_RAV_CUST_LOC_DRF_OUTBOUND->IF_DRF_OUTBOUND~BUILD_PARALLEL_PACKAGE
* +-------------------------------------------------------------------------------------------------+
* | [--->] IR_PREPARE_DATA                TYPE        DATA
* | [<---] ER_PACKAGE_DATA                TYPE        DATA
* | [<---] ES_TASK_PARAM                  TYPE        DRF_S_PARALLEL_TASK_PARAM
* | [<---] EV_ALL_TASKS_DONE              TYPE        ABAP_BOOL
* +--------------------------------------------------------------------------------------</SIGNATURE>
  method IF_DRF_OUTBOUND~BUILD_PARALLEL_PACKAGE.

  endmethod.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_RAV_CUST_LOC_DRF_OUTBOUND->IF_DRF_OUTBOUND~ENRICH_FILTER_CRITERIA
* +-------------------------------------------------------------------------------------------------+
* | [--->] IT_EXTERNAL_CRITERIA           TYPE        RSDS_TRANGE
* | [<---] ET_ADD_EXTERNAL_CRITERIA       TYPE        RSDS_TRANGE
* | [<---] ES_STAT_INFO                   TYPE        DRF_S_STAT_INFO
* | [!CX!] CX_DRF_ENRICH_FILTER_PARAMETER
* | [!CX!] CX_DRF_EXCEPTION
* +--------------------------------------------------------------------------------------</SIGNATURE>
  method IF_DRF_OUTBOUND~ENRICH_FILTER_CRITERIA.


  endmethod.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_RAV_CUST_LOC_DRF_OUTBOUND->IF_DRF_OUTBOUND~FINALIZE
* +-------------------------------------------------------------------------------------------------+
* | [--->] IT_RELEVANT_OBJECTS            TYPE        SORTED TABLE
* | [--->] IT_ERRONEOUS_OBJECTS           TYPE        SORTED TABLE
* | [--->] IV_REPEATED_INITIAL_RUN        TYPE        BOOLE_D
* | [<---] EV_DELETE_CHANGE_POINTER       TYPE        BOOLE_D
* +--------------------------------------------------------------------------------------</SIGNATURE>
  method IF_DRF_OUTBOUND~FINALIZE.

  endmethod.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Static Public Method ZCL_RAV_CUST_LOC_DRF_OUTBOUND=>IF_DRF_OUTBOUND~INITIALIZE
* +-------------------------------------------------------------------------------------------------+
* | [--->] IS_RUNTIME_PARAM               TYPE        DRF_S_RUNTIME_PARAMETER_EXT
* | [<---] EO_IF_DRF_OUTBOUND             TYPE REF TO IF_DRF_OUTBOUND
* | [<---] ES_RUNTIME_PARAM_OUT_IMPL      TYPE        DRF_S_RUNTIME_PARAM_OUT_IMPL
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD IF_DRF_OUTBOUND~INITIALIZE.
**********************************************************************
*   Initialization of the DRF Outbound Implementation for Location
*   Replication
**********************************************************************
    DATA: ls_runtime_parameter TYPE drf_s_runtime_param_out_impl,
          lr_drf_loc_outbound  TYPE REF TO zcl_rav_cust_loc_drf_outbound.

**********************************************************************
*   Initialize the exporting parameter
**********************************************************************
    CLEAR: eo_if_drf_outbound,
           es_runtime_param_out_impl.

**********************************************************************
*   Create an instance of myself in order to remember the runtime
*   parameters for all subsequent methods and pass it to the framework
**********************************************************************
    TRY.
        CREATE OBJECT lr_drf_loc_outbound.
      CATCH cx_sy_create_object_error.
        RETURN.
    ENDTRY.

    IF lr_drf_loc_outbound IS BOUND.
      lr_drf_loc_outbound->ms_runtime_parameter = is_runtime_param.
    ENDIF.

**********************************************************************
*   Set own runtime parameter
**********************************************************************
    ls_runtime_parameter-table_type_name = mc_t_drf_loc_outb.    "T_SHPP_LOC_DRF_OUTBOUND
    es_runtime_param_out_impl = ls_runtime_parameter.

**********************************************************************
*   Set Outbound Implementation
**********************************************************************
    eo_if_drf_outbound = lr_drf_loc_outbound.

  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_RAV_CUST_LOC_DRF_OUTBOUND->IF_DRF_OUTBOUND~MAP_DATA2MESSAGE
* +-------------------------------------------------------------------------------------------------+
* | [--->] IR_RELEVANT_OBJECT             TYPE REF TO DATA
* | [--->] IS_BUS_SYS_TECH                TYPE        MDG_S_BUS_SYS_TECH(optional)
* | [!CX!] CX_DRF_PROCESS_MESSAGES
* | [!CX!] CX_DRF_EXCEPTION
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD IF_DRF_OUTBOUND~MAP_DATA2MESSAGE.
    DATA:
      lr_rel_obj         TYPE REF TO ZDRF_S_CUST_OUTBOUND,
      lv_timezone        TYPE tznzone,
      ls_loc_bulk        TYPE sapplco_loc_blk_repl_req_msg,
      ls_loc_repl_mess   TYPE sapplco_loc_repl_req_msg,
      lt_loc_repl_mess   TYPE sapplco_loc_repl_req_msg_tab,
      ls_loc_description TYPE sapplco_short_description,
      lv_loc_form_name   TYPE sapplco_languageindependent_me,
      ls_loc_tel         TYPE sapplco_telephone,
      ls_loc_facs        TYPE sapplco_facsimile,
      ls_loc_email       TYPE sapplco_nosc_email,
      ls_loc_web         TYPE sapplco_nosc_web,
      ls_loc_address     TYPE sapplco_nosc_address.

    FIELD-SYMBOLS:
      <ls_cust_addr1_data> TYPE addr1_data.

    lr_rel_obj ?= ir_relevant_object.

*   Fill Message Header for Bulk Service
    fill_message_header(
     IMPORTING
       es_message_header =  ls_loc_bulk-message_header ).

    READ TABLE mt_cust_data ASSIGNING FIELD-SYMBOL(<ls_cust_data>)
      WITH KEY kunnr = lr_rel_obj->kunnr.
    IF sy-subrc NE 0.
      RETURN.
    ENDIF.

*   Fill Message Header for Location Replication
    fill_message_header(
     IMPORTING
       es_message_header =  ls_loc_repl_mess-message_header ).

    CONCATENATE 'CU_' <ls_cust_data>-kunnr INTO ls_loc_repl_mess-location-location_internal_id.

*   Location Type Code for Customer Location
    ls_loc_repl_mess-location-location_type_code = '1010'.

**********************************************************************
*   Address and Description
**********************************************************************
    READ TABLE mt_cust_address ASSIGNING FIELD-SYMBOL(<ls_cust_addr_data>)
      WITH KEY addrnumber = <ls_cust_data>-adrnr.
    IF sy-subrc <> 0.
*     Error -> No Address found for the plant
    ELSE.
      LOOP AT <ls_cust_addr_data>-addr1_tab ASSIGNING FIELD-SYMBOL(<ls_cust_addr1>).
        ASSIGN <ls_cust_addr1>-data TO <ls_cust_addr1_data>.
        IF NOT ( <ls_cust_addr1_data>-date_from <= sy-datum AND
                 <ls_cust_addr1_data>-date_to >= sy-datum ).
*         Not Valid Address
          CONTINUE.
        ENDIF.

*       Description (NAME1 from Address is used as text) -> Here Description of Shipping/Receiving Point.
        LOOP AT mt_cust_data_txt ASSIGNING FIELD-SYMBOL(<ls_cust_data_txt>) WHERE kunnr = <ls_cust_data>-kunnr.
          CLEAR ls_loc_description.
          ls_loc_description-language_code = <ls_cust_data_txt>-spras.
          ls_loc_description-content       = <ls_cust_data_txt>-vtext.
          INSERT ls_loc_description INTO TABLE ls_loc_repl_mess-location-description.
        ENDLOOP.

*       Time Zone
        IF  <ls_cust_addr1_data>-time_zone IS NOT INITIAL.
          ls_loc_repl_mess-location-time_zone_code = <ls_cust_addr1_data>-time_zone.
        ELSE.
          CALL FUNCTION 'TZON_LOCATION_TIMEZONE'
            EXPORTING
              if_country        = <ls_cust_addr1_data>-country
              if_region         = <ls_cust_addr1_data>-region
            IMPORTING
              ef_timezone       = lv_timezone
            EXCEPTIONS
              no_timezone_found = 1
              OTHERS            = 2.
          IF sy-subrc <> 0.
            CLEAR ls_loc_repl_mess-location-time_zone_code.
          ELSE.
            ls_loc_repl_mess-location-time_zone_code = lv_timezone.
          ENDIF.
        ENDIF.

**********************************************************************
*       Organization formatted Name
**********************************************************************
        ls_loc_address-organisation_form_of_address-code = <ls_cust_addr1_data>-title.
        IF <ls_cust_addr1_data>-name1 IS NOT INITIAL.
          lv_loc_form_name = <ls_cust_addr1_data>-name1.
          INSERT lv_loc_form_name INTO TABLE ls_loc_address-organisation_formatted_name.
        ENDIF.
        IF <ls_cust_addr1_data>-name2 IS NOT INITIAL.
          lv_loc_form_name = <ls_cust_addr1_data>-name2.
          INSERT lv_loc_form_name INTO TABLE ls_loc_address-organisation_formatted_name.
        ENDIF.
        IF <ls_cust_addr1_data>-name3 IS NOT INITIAL.
          lv_loc_form_name = <ls_cust_addr1_data>-name3.
          INSERT lv_loc_form_name INTO TABLE ls_loc_address-organisation_formatted_name.
        ENDIF.
        IF <ls_cust_addr1_data>-name4 IS NOT INITIAL.
          lv_loc_form_name = <ls_cust_addr1_data>-name4.
          INSERT lv_loc_form_name INTO TABLE ls_loc_address-organisation_formatted_name.
        ENDIF.
        IF <ls_cust_addr1_data>-name_txt IS NOT INITIAL.
          lv_loc_form_name = <ls_cust_addr1_data>-name_txt.
          INSERT lv_loc_form_name INTO TABLE ls_loc_address-organisation_formatted_name.
        ENDIF.

**********************************************************************
*       Physical Address
**********************************************************************
        ls_loc_address-physical_address-country_code               = <ls_cust_addr1_data>-country.
        ls_loc_address-physical_address-country_name-language_code = <ls_cust_addr1_data>-langu.
        ls_loc_address-physical_address-region_code                = <ls_cust_addr1_data>-region.
        ls_loc_address-physical_address-city_name                  = <ls_cust_addr1_data>-city1.
        ls_loc_address-physical_address-additional_city_name       = <ls_cust_addr1_data>-home_city.
        ls_loc_address-physical_address-pobox_country_code         = <ls_cust_addr1_data>-po_box_cty.
        ls_loc_address-physical_address-pobox_region_code          = <ls_cust_addr1_data>-po_box_reg.
        ls_loc_address-physical_address-pobox_id                   = <ls_cust_addr1_data>-po_box.

        cl_gdt_conversion=>indicator_outbound(
          EXPORTING
            im_value = <ls_cust_addr1_data>-po_box_num            " ABAP Flag: 'X' ="true, ' ' = false
          IMPORTING
            ex_value = ls_loc_address-physical_address-pobox_indicator ).                " XSD:Indicator
        ls_loc_address-physical_address-street_postal_code         = <ls_cust_addr1_data>-post_code1.
        ls_loc_address-physical_address-pobox_postal_code          = <ls_cust_addr1_data>-post_code2.
        ls_loc_address-physical_address-company_postal_code        = <ls_cust_addr1_data>-post_code3.
        ls_loc_address-physical_address-house_id                   = <ls_cust_addr1_data>-house_num1.
        ls_loc_address-physical_address-additional_house_id        = <ls_cust_addr1_data>-house_num2.
        ls_loc_address-physical_address-district_name              = <ls_cust_addr1_data>-city2.
        ls_loc_address-physical_address-building_id                = <ls_cust_addr1_data>-building.
        ls_loc_address-physical_address-floor_id                   = <ls_cust_addr1_data>-floor.
        ls_loc_address-physical_address-room_id                    = <ls_cust_addr1_data>-roomnumber.
        ls_loc_address-physical_address-street_name                = <ls_cust_addr1_data>-street.

        IF <ls_cust_addr1_data>-str_suppl1 IS NOT INITIAL OR <ls_cust_addr1_data>-str_suppl2 IS NOT INITIAL.
          INSERT <ls_cust_addr1_data>-str_suppl1 INTO TABLE ls_loc_address-physical_address-street_prefix_name.
          INSERT <ls_cust_addr1_data>-str_suppl2 INTO TABLE ls_loc_address-physical_address-street_prefix_name.
        ENDIF.
        IF <ls_cust_addr1_data>-str_suppl3 IS NOT INITIAL OR <ls_cust_addr1_data>-location IS NOT INITIAL.
          INSERT <ls_cust_addr1_data>-str_suppl3 INTO TABLE ls_loc_address-physical_address-street_suffix_name.
          INSERT <ls_cust_addr1_data>-location   INTO TABLE ls_loc_address-physical_address-street_suffix_name.
        ENDIF.

*       Office
        ls_loc_address-office-building_id = <ls_cust_addr1_data>-building.
        ls_loc_address-office-floor_id    = <ls_cust_addr1_data>-floor.
        ls_loc_address-office-room_id     = <ls_cust_addr1_data>-roomnumber.

*       Communication
        ls_loc_address-communication-correspondence_language_code = <ls_cust_addr1_data>-langu.

*       Phone
        LOOP AT <ls_cust_addr_data>-adtel_tab ASSIGNING FIELD-SYMBOL(<ls_cust_addr_adtel_data>).
          CLEAR ls_loc_tel.
          ls_loc_tel-number-country_code      = <ls_cust_addr_adtel_data>-adtel-country.
          ls_loc_tel-number-subscriber_id     = <ls_cust_addr_adtel_data>-adtel-tel_number.
          ls_loc_tel-number-extension_id      = <ls_cust_addr_adtel_data>-adtel-tel_extens.
          ls_loc_tel-number-country_code      = <ls_cust_addr_adtel_data>-adtel-country.

          cl_gdt_conversion=>indicator_outbound(
            EXPORTING
              im_value = <ls_cust_addr_adtel_data>-adtel-flgdefault            " ABAP Flag: 'X' ="true, ' ' = false
            IMPORTING
              ex_value = ls_loc_tel-number_default_indicator ).                " XSD:Indicator

          cl_gdt_conversion=>indicator_outbound(
            EXPORTING
              im_value = <ls_cust_addr_adtel_data>-adtel-dft_receiv           " ABAP Flag: 'X' ="true, ' ' = false
            IMPORTING
              ex_value = ls_loc_tel-smsenabled_indicator ).                   " XSD:Indicator
          INSERT ls_loc_tel INTO TABLE ls_loc_address-communication-telephone.
        ENDLOOP.

*       Fax
        LOOP AT <ls_cust_addr_data>-adfax_tab ASSIGNING FIELD-SYMBOL(<ls_cust_addr_adfax_data>).
          ls_loc_facs-number-country_code      = <ls_cust_addr_adfax_data>-adfax-country.
          ls_loc_facs-number-subscriber_id     = <ls_cust_addr_adfax_data>-adfax-fax_number.
          ls_loc_facs-number-extension_id      = <ls_cust_addr_adfax_data>-adfax-fax_extens.
          ls_loc_facs-number-country_code      = <ls_cust_addr_adfax_data>-adfax-country.
          cl_gdt_conversion=>indicator_outbound(
            EXPORTING
              im_value = <ls_cust_addr_adfax_data>-adfax-flgdefault           " ABAP Flag: 'X' ="true, ' ' = false
            IMPORTING
              ex_value = ls_loc_facs-number_default_indicator ).                " XSD:Indicator

          INSERT ls_loc_facs INTO TABLE ls_loc_address-communication-facsimile.
        ENDLOOP.

*       E-mail
        LOOP AT <ls_cust_addr_data>-adsmtp_tab ASSIGNING FIELD-SYMBOL(<ls_cust_addr_adsmtp_data>).
          CLEAR ls_loc_email.
          ls_loc_email-uri                  = <ls_cust_addr_adsmtp_data>-adsmtp-smtp_addr.
          cl_gdt_conversion=>indicator_outbound(
            EXPORTING
              im_value = <ls_cust_addr_adsmtp_data>-adsmtp-dft_receiv        " ABAP Flag: 'X' ="true, ' ' = false
            IMPORTING
              ex_value = ls_loc_email-uridefault_indicator ).                " XSD:Indicator

          INSERT ls_loc_email INTO TABLE ls_loc_address-communication-email.
        ENDLOOP.

*       Web
        LOOP AT <ls_cust_addr_data>-aduri_tab ASSIGNING FIELD-SYMBOL(<ls_cust_addr_aduri>).
          IF <ls_cust_addr_aduri>-aduri-uri_type = 'HPG' . " Location Type HPG(Homepage) is transffered only
            CLEAR ls_loc_web.
            ls_loc_web-uri = <ls_cust_addr_aduri>-aduri-uri_addr.
            cl_gdt_conversion=>indicator_outbound(
              EXPORTING
                im_value = <ls_cust_addr_aduri>-aduri-flgdefault          " ABAP Flag: 'X' ="true, ' ' = false
              IMPORTING
                ex_value = ls_loc_web-uridefault_indicator ).             " XSD:Indicator

            INSERT ls_loc_web INTO TABLE ls_loc_address-communication-web.
          ENDIF.
        ENDLOOP.
*       Only one valid address
        ls_loc_repl_mess-location-address = ls_loc_address.
        EXIT.
      ENDLOOP.
    ENDIF.

    ms_loc_bulk_repl_req-location_bulk_replication_req-message_header = ls_loc_bulk-message_header.
    INSERT ls_loc_repl_mess INTO TABLE lt_loc_repl_mess.
    INSERT LINES OF lt_loc_repl_mess INTO TABLE ms_loc_bulk_repl_req-location_bulk_replication_req-loc_repl_req_msg.

  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_RAV_CUST_LOC_DRF_OUTBOUND->IF_DRF_OUTBOUND~READ_COMPLETE_DATA
* +-------------------------------------------------------------------------------------------------+
* | [<-->] CT_RELEVANT_OBJECTS            TYPE        SORTED TABLE
* | [!CX!] CX_DRF_PROCESS_MESSAGES
* | [!CX!] CX_DRF_EXCEPTION
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD IF_DRF_OUTBOUND~READ_COMPLETE_DATA.
**********************************************************************
*   Read the data of all records that shall be replicated later on
*   via the new Location Service.
**********************************************************************

    DATA:
      lt_bus_sys_tech        TYPE mdg_t_bus_sys_tech,
      lv_own_business_system TYPE text60,
      ls_kunnr               TYPE tys_kunnr,
      lt_kunnr               TYPE TABLE OF tys_kunnr,
      lt_adrc                TYPE szadr_adrc_table,
      ls_adrc                TYPE szadr_st_adrc,
      lt_addr_error          TYPE szadr_error_table.

    FIELD-SYMBOLS:
      <ls_cust_data>        TYPE tys_cust_data,
      <ls_loc_drf_outbound> TYPE any,
      <lv_comp>             TYPE any.


**********************************************************************
*   Get Business System Data
**********************************************************************

*   Get own Logical System
    CALL FUNCTION 'LCR_GET_OWN_BUSINESS_SYSTEM'
      IMPORTING
        bs_key_name            = lv_own_business_system
      EXCEPTIONS
        no_business_system     = 1
        no_rfc_destination     = 2
        no_landscape_directory = 3
        illegal_arguments      = 4
        communication_error    = 5
        ld_error               = 6
        sld_api_exception      = 7
        OTHERS                 = 8.
    IF sy-subrc NE 0.
      RETURN. " RAISE no_business_system.
    ENDIF.

    mv_sender_bussystem_id = lv_own_business_system.

    CALL METHOD cl_drf_access_cust_data=>select_business_sys_for_appl
      EXPORTING
        iv_appl         = ms_runtime_parameter-appl
        iv_outb_impl    = ms_runtime_parameter-outb_impl
      IMPORTING
        et_bus_sys_tech = lt_bus_sys_tech.

    READ TABLE lt_bus_sys_tech ASSIGNING FIELD-SYMBOL(<ls_bus_sys_tech>) INDEX 1. "#EC CI_NOORDER

    mv_receiver_bussystem_id = <ls_bus_sys_tech>-business_system.

**********************************************************************
*   Build up table lt_kunnr
**********************************************************************
    LOOP AT ct_relevant_objects ASSIGNING <ls_loc_drf_outbound>.
      CLEAR ls_kunnr.
      UNASSIGN <lv_comp>.

      ASSIGN COMPONENT 'KUNNR' OF STRUCTURE <ls_loc_drf_outbound> TO <lv_comp>.
      IF sy-subrc = 0 AND <lv_comp> IS ASSIGNED.
        ls_kunnr = <lv_comp>.
        INSERT ls_kunnr INTO TABLE lt_kunnr.
      ENDIF.
    ENDLOOP.

**********************************************************************
*   Retrieve Data of Customer general data
**********************************************************************
    IF lt_kunnr IS NOT INITIAL.
      SELECT kunnr spras adrnr FROM kna1
        INTO CORRESPONDING FIELDS OF TABLE mt_cust_data
        FOR ALL ENTRIES IN lt_kunnr
        WHERE kunnr = lt_kunnr-kunnr.
      IF sy-subrc <> 0.
        RAISE EXCEPTION TYPE cx_drf_process_messages.
      ENDIF.
    ELSE.
      RAISE EXCEPTION TYPE cx_drf_process_messages.
    ENDIF.

**********************************************************************
*   Retrieve Text Data of Customer general data ( not existing)
**********************************************************************
*    IF lt_kunnr IS NOT INITIAL.
*      SELECT spras vstel vtext FROM tvstt
*        INTO CORRESPONDING FIELDS OF TABLE mt_cust_data_txt
*        FOR ALL ENTRIES IN lt_kunnr
*        WHERE kunnr = lt_kunnr-kunnr.
*      IF sy-subrc <> 0.
*        RAISE EXCEPTION TYPE cx_drf_process_messages.
*      ENDIF.
*    ELSE.
*      RAISE EXCEPTION TYPE cx_drf_process_messages.
*    ENDIF.
*
**********************************************************************
*   Retrieve Addresses of the Shipping/Receiving Points
**********************************************************************
    CLEAR lt_adrc.
    LOOP AT mt_cust_data ASSIGNING <ls_cust_data>.
      IF <ls_cust_data>-adrnr IS NOT INITIAL.
        ls_adrc-addrnumber = <ls_cust_data>-adrnr.
        INSERT ls_adrc INTO TABLE lt_adrc.
      ENDIF.
    ENDLOOP.
    IF lt_adrc IS NOT INITIAL.
      CALL FUNCTION 'ADDR_GET_COMPLETE_DB_MASS'
        EXPORTING
          iv_current_comm_data = 'X'
        TABLES
          address_selection    = lt_adrc
          sz_addr1_complete    = mt_cust_address
          sz_error_table       = lt_addr_error.

    ENDIF.

  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Instance Public Method ZCL_RAV_CUST_LOC_DRF_OUTBOUND->IF_DRF_OUTBOUND~SEND_MESSAGE
* +-------------------------------------------------------------------------------------------------+
* | [--->] IS_FILE_INFO                   TYPE        DRF_S_FILE_INFO(optional)
* | [--->] IV_OBJECT_COUNT                TYPE        DRF_PACKAGE_SIZE(optional)
* | [--->] IS_BUS_SYS_TECH                TYPE        MDG_S_BUS_SYS_TECH(optional)
* | [<---] ET_FILE_DATA                   TYPE        DRF_T_FILE_OI_CONTENT
* | [<---] ET_MESSAGE                     TYPE        DRF_T_MESSAGE
* | [<-->] CT_OBJ_REP_STA                 TYPE        DRF_T_OBJ_REP_STA_FULL(optional)
* | [!CX!] CX_DRF_PROCESS_MESSAGES
* | [!CX!] CX_DRF_EXCEPTION
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD IF_DRF_OUTBOUND~SEND_MESSAGE.
**********************************************************************
* The method calls the servcice LocationBulkReplicationRequest_Out
*   Class: CO_LOC_LOC_BULK_REPL_REQ_OUT
*   Method: LOC_BULK_REPLICATION_REQ_OUT
* Parameter OUTPUT Type LOC_BULK_REPLICATION_REQ
**********************************************************************
* The service will be called under the followinng circumstances:
* Attribute MS_LOC_BULK_REPL_REQ is not initial
* Attribute MS_RUNTIME_PARAMETER-TESTRUN is not abap_false
* That means, location data for replication are available and
* the DRFOUT wasn't called in test mode.
**********************************************************************

    TYPES: BEGIN OF ty_object_id,
             prefix TYPE char3,
             id     TYPE char4,
           END OF ty_object_id.

    DATA:
      ls_message_data_outbound     TYPE loc_bulk_replication_req, "TYPE sapplco_loc_blk_repl_req_msg,
      lv_path_message_header       TYPE string,
      lv_path_sequence_fields      TYPE string,
      lv_default_service_group     TYPE xflag,
      lv_service_group             TYPE srt_wsp_dt_obj_name,
      lv_recipient_business_system TYPE sld_bskey,
      lv_application_id            TYPE bs_soa_appl_id,
      lv_tech_seq_context          TYPE bs_soa_asyncprx_cntxt,
      lv_appl_seq_context          TYPE bs_soa_inappseq_cntxt,
      lv_reference_message_id      TYPE bs_soa_rspnsrcvr_msg_id,
      lv_correlation_id            TYPE bs_soa_rspnsrcvr_corel_id,
      lv_reconciliation_requested  TYPE xflag,
      ls_lrd_filter                TYPE lrd_sld_bskey,
      lo_bs_soa_exception          TYPE REF TO cx_bs_soa_exception,
      lt_outbound_proxy            TYPE bssoa_asyncprx_instance_t ##needed.


    DATA:
      lo_xi_error                  TYPE REF TO cx_ai_system_fault,
      lv_error_txt                 TYPE string,
      lv_error_long_txt            TYPE string,
      lv_object_id                 TYPE ty_object_id,
      ls_loc_repl_req_msg          TYPE sapplco_loc_repl_req_msg.

    FIELD-SYMBOLS:
          <ls_obj_rep_sta>       TYPE drf_s_obj_rep_sta_attr.

***********************************************************************
**   Initialize the exporting parameter
***********************************************************************
    CLEAR: et_file_data,    "Not used
           et_message.

**********************************************************************
*   Check if the service could be triggerd
*   Location Data for replication are available and Test Mode OFF
**********************************************************************
    IF ms_runtime_parameter-testrun = abap_true.
      "Test Mode --> No Service Call
      RETURN.
    ENDIF.

    IF ms_loc_bulk_repl_req IS NOT INITIAL.
      "Replication data available

      "Update Replication Status Object with the message_header-UUID (Message Link)
      "to be able to identify the message later on in the inbound
      LOOP AT ms_loc_bulk_repl_req-location_bulk_replication_req-loc_repl_req_msg
              INTO ls_loc_repl_req_msg.
        lv_object_id = ls_loc_repl_req_msg-location-location_internal_id.
        READ TABLE ct_obj_rep_sta ASSIGNING <ls_obj_rep_sta>
             WITH KEY object_id = lv_object_id-id.
        IF sy-subrc = 0.
          "Entry found --> Set the message_header-UUID
          <ls_obj_rep_sta>-msg_link = ls_loc_repl_req_msg-message_header-id-content.
        ENDIF.
      ENDLOOP.

      ls_message_data_outbound = ms_loc_bulk_repl_req.
      lv_path_message_header  = 'LOCATION_BULK_REPLICATION_REQ-MESSAGE_HEADER'.
      lv_path_sequence_fields = 'LOCATION_BULK_REPLICATION_REQ-LOC_REPL_REQ_MSG'.
      lv_service_group        = 'LOCATION_REPLICATE_REQ'.
      lv_recipient_business_system = mv_receiver_bussystem_id.
      ls_lrd_filter-bskey          = lv_recipient_business_system.

*   Context Build
      CONCATENATE sy-sysid sy-mandt 'LOC_REPL_REQ'
         INTO lv_tech_seq_context.

      lv_appl_seq_context = 'LOCREQ'.

      TRY.
          CALL METHOD cl_bs_soa_asyncprx_out=>execute
            EXPORTING
              iv_proxy_class               = 'CO_LOC_LOC_BULK_REPL_REQ_OUT'
              iv_method                    = 'LOC_BULK_REPLICATION_REQ_OUT'
              iv_obj_type                  = 'BUS10002'
              iv_path_msg_header           = lv_path_message_header
              iv_path_of_seq_fields        = lv_path_sequence_fields
              iv_service_group             = lv_service_group
              iv_logical_receiver_det_struc = ls_lrd_filter
              iv_default_service_group     = lv_default_service_group
              iv_recipient_business_system = lv_recipient_business_system
              iv_application_id            = lv_application_id
              iv_tech_seq_context          = lv_tech_seq_context
              iv_appl_seq_context          = lv_appl_seq_context
              iv_reference_message_id      = lv_reference_message_id
              iv_correlation_id            = lv_correlation_id
              iv_reconciliation_requested  = lv_reconciliation_requested
            IMPORTING
              et_proxy_instances           = lt_outbound_proxy
            CHANGING
              cs_message_data_outbound     = ls_message_data_outbound.

        CATCH cx_bs_soa_exception INTO lo_bs_soa_exception .
          "Communication Error
          "Get Error Text
          CALL METHOD lo_bs_soa_exception->get_text
            RECEIVING
              result = lv_error_txt.
          "Get Long Text
          CALL METHOD lo_bs_soa_exception->get_longtext
            RECEIVING
              result = lv_error_long_txt.
          "Write Message to the BAL
          "DRF_OUTBOUND 015 - Error during proxy call (&1: &2, &3)
          "ADD_MSG_RE --> Add Message and Raise Exception
          CALL METHOD ms_runtime_parameter-bal->add_msg_re
            EXPORTING
              iv_msgno = '015'
              iv_msgid = 'DRF_OUTBOUND'
              iv_msgv1 = 'CO_LOC_LOC_BULK_REPL_REQ_OUT'
              iv_msgv2 = lv_error_txt
              iv_msgv3 = lv_error_long_txt.

        CATCH cx_ai_system_fault INTO lo_xi_error.
          "Application Integration: Technical Error
          "Write BAL - DRF_OUTBOUND 013 - Error while creating the &1 proxy instance
          CALL METHOD ms_runtime_parameter-bal->add_msg_re
            EXPORTING
              iv_msgno             = '013'
              iv_msgid             = 'DRF_OUTBOUND'
              iv_msgv1             = 'CO_LOC_LOC_BULK_REPL_REQ_OUT'
              ix_exception_catched = lo_xi_error.

      ENDTRY.
    ELSE.
      "No Replication data available
      "Add Message to the BAL
      "DRF_OUTBOUND 322 - System does not send blank messages
      CALL METHOD ms_runtime_parameter-bal->add_msg_re
        EXPORTING
          iv_msgno = '322'
          iv_msgid = 'DRF_OUTBOUND'.
    ENDIF.
*   Clear Message for new Message Run
    CLEAR ms_loc_bulk_repl_req.
  ENDMETHOD.
ENDCLASS.

Configuring Cross Client customisation of Data Replication Framework

After creating all the objects below configuration has to be done in the Data Replication Customization . Transaction : drfimg

 

The numbers represent the sequence in which the customisations have to be maintained

 

1.     Define Business Objects

 

2. Define Filter Objects

 

Create 3 filter objects each representing the corresponding object

For each filter object assign filters

 

3. Define Object Identifiers

 

Create object identifier for each of the objects

 

4.     Assign Filter Objects to Business Objects

5.     Define Service Operations Available for Replication

 

6.     Define Outbound Implementations

 

After doing all these configurations, you have to maintain additional configurations as mentioned in the configuration guide https://help.sap.com/viewer/b4724b2f483e439782b60cab4407c25a/LBN/en-US/86120107c3004203a5ff0c79643199a9.html Within manage location section. However, this time you would have to maintain the BO type and Outbound implementation you have created.

 

You may test the replication by running the transaction DRFOUT

 

 

Summary

But doing the above configuration, you will be able to replication locations of Business Partner, Customer , Vendor, Plant and shipping point to SAP Logistics Business Network

 

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.