알 수 없는 이유로 데이터가 꼬여서 덤프 에러 Exception condition "NO_KEY" triggered 발생하곤 합니다.

가비지 데이터 정리 프로그램 만들어 보았습니다.

 

코드:

 

*&---------------------------------------------------------------------*
*& Report ZMDP_ADJUST_STAGING
*&---------------------------------------------------------------------*
*& MDG staging table 가비지 데이터 삭제 처리 프로그램
*&---------------------------------------------------------------------*
REPORT zmdp_adjust_staging LINE-SIZE 250.

DATA : lt_message           TYPE usmd_t_message,
       ls_message           TYPE usmd_s_message,
       lt_model             TYPE TABLE OF usmd_model,
       lv_model             TYPE usmd_model,
       lo_model_gen_adapter TYPE REF TO if_usmd_model_gen_adapter,
       ls_log_phys_name     TYPE if_usmd_model_gen_adapter=>s_log_phys_name,
       lt_log_phys_name     TYPE if_usmd_model_gen_adapter=>t_log_phys_name,
       lv_entity            TYPE string,
       lv_select            TYPE string,
       lv_table             TYPE string,
       lv_key_field         TYPE string,
*       lt_range_key_value   TYPE RANGE OF usmd_tech_key,
       lt_key_value         TYPE TABLE OF usmd_tech_key,
       lv_key_value         TYPE usmd_tech_key,
       lv_usmd_value        TYPE usmd_value,
       lt_cr                TYPE TABLE OF usmd_crequest,
       lv_cr                TYPE usmd_crequest,
       lt_usmd1213          TYPE TABLE OF usmd1213,
       ls_usmd1213          TYPE usmd1213,
       lv_flag_del          TYPE flag,
       lv_where             TYPE string,
       lv_key_json          TYPE string,
       lr_data              TYPE REF TO data,
       lv_error             TYPE char1,
       lv_index             TYPE i.

FIELD-SYMBOLS: <lt_data> TYPE tabel,
               <ls_data> TYPE data,
               <lv_data> TYPE data.

*--------------------------------------------------------------------*
" 모델 검색
SELECT-OPTIONS so_model FOR lv_model MATCHCODE OBJECT zmdph_model.



*--------------------------------------------------------------------*
START-OF-SELECTION.

*--------------------------------------
  " 활성 상태의 모델정보 검색
  SELECT usmd_model
    INTO TABLE lt_model
    FROM usmd001c
   WHERE usmd_model IN so_model
     AND usmd_objstat = 'A'.
  "
  IF sy-subrc NE 0.
    " 레코드 검색 실패
    MESSAGE s000(oo) WITH 'Data not found.' DISPLAY LIKE 'E'.
    " 작업 종료
    STOP.
  ENDIF.

*--------------------------------------
  " 모델별 작업
  LOOP AT lt_model INTO lv_model.
    "
    WRITE:/ ' *** ' , lv_model COLOR 7, ' *** '.

    "*----------------------------
    " 모델 정보로 활성된 테이블 정보 검색
    CALL METHOD cl_usmd_adapter_provider=>get_model_generation_adapter
      EXPORTING
        i_usmd_model         = lv_model
      IMPORTING
        eo_model_gen_adapter = lo_model_gen_adapter
        et_message           = lt_message.

    CLEAR lv_error.
    "
    LOOP AT lt_message TRANSPORTING NO FIELDS WHERE msgty CA 'AEX'.
      "*----------------------------
      " 오륲 메세지 처리
      MESSAGE ID ls_message-msgid TYPE 'S' NUMBER ls_message-msgno DISPLAY LIKE ls_message-msgty
        WITH ls_message-msgv1 ls_message-msgv2 ls_message-msgv3 ls_message-msgv4.
      " 오류 발생
      lv_error = abap_true.
    ENDLOOP.

    "*----------------------------
    " 오류 없을시 작업 진행
    CHECK lv_error IS INITIAL.

    "*----------------------------
    " 활성 테이블 정보 검색
    CALL METHOD lo_model_gen_adapter->get_generated_objects
      EXPORTING
        if_mdf_hry_tab   = abap_false
      IMPORTING
        et_message       = lt_message
        et_log_phys_name = lt_log_phys_name.    " 활성 테이블 정보

    "*----------------------------
    "
    LOOP AT lt_log_phys_name INTO ls_log_phys_name.

      CASE ls_log_phys_name-sub_kind.
        WHEN usmd1_cs_tabl_kind-check.
          "
          lv_entity    = ls_log_phys_name-entity.
          lv_table     = ls_log_phys_name-phys_name.
          lv_key_field = 'USMDK' && lv_model && lv_entity.

          "
          WRITE:/ '*', lv_entity, lv_table.

          TRY .
              "*----------------------------
              " 테이블 키 밸류 검색
              SELECT (lv_key_field)
                FROM (lv_table)
                INTO TABLE @lt_key_value.
            CATCH cx_sy_dynamic_osql_semantics.
              CONTINUE.
          ENDTRY.

          "*----------------------------
          " 키 중복 제거
          SORT lt_key_value.
          DELETE ADJACENT DUPLICATES FROM lt_key_value.

          "*----------------------------
          " 키 밸류별 작업
          LOOP AT lt_key_value INTO lv_key_value.
            "
            CLEAR: lv_flag_del.
            "
            lv_usmd_value = lv_key_value.

            " 키에 매핑된 Change Request 정보 검색
            SELECT usmd_crequest
              INTO TABLE lt_cr
              FROM usmd1213
             WHERE usmd_entity     = lv_entity
               AND usmd_entity_obj = lv_entity
               AND usmd_value      = lv_usmd_value.
            IF sy-subrc <> 0.
              " 삭제 대상 설정
              lv_flag_del = abap_true.
            ENDIF.

            " Change Request 별 상태 검색
            LOOP AT lt_cr INTO lv_cr.
              SELECT SINGLE mandt
                INTO sy-mandt
                FROM usmd120c
               WHERE usmd_crequest = lv_cr
                 AND usmd_creq_status NOT IN (usmd0_cs_crequest_status-finally_approved,  " 05: 승인완료
                                              usmd0_cs_crequest_status-finally_rejected). " 06: 반려완료.
              IF sy-subrc <> 0.
                " 삭제 대상 설정
                lv_flag_del = abap_true.
                " 루프 종료
                EXIT.
              ENDIF.
            ENDLOOP. " LOOP AT lt_cr INTO lv_cr.

            "*----------------------------
            " 삭제 대상인 경우
            IF lv_flag_del EQ abap_true.
              "
              lv_where = |{ lv_key_field } = lv_key_value|.

*              lv_table = lt_log_phys_name[ entity   = lv_entity
*                                           sub_kind = usmd1_cs_tabl_kind-map ]-phys_name.
              READ TABLE lt_log_phys_name INTO ls_log_phys_name
               WITH KEY entity = lv_entity sub_kind = usmd1_cs_tabl_kind-map.
              lv_table = ls_log_phys_name-phys_name.
              "
              CREATE DATA lr_data TYPE (lv_table).
              ASSIGN lr_data->* TO <ls_data>.
              "
              lv_key_json = lv_usmd_value.
              SELECT SINGLE * INTO <ls_data>
                FROM (lv_table)
               WHERE (lv_where).
              "
              lv_key_json = /ui2/cl_json=>serialize( <ls_data> ).
              "
              WRITE:/ lv_key_json.

              "*----------------------------
              " 테이블별 레코드 삭제
              " 엔티티별 매핑 테이블이 아닌 테이블에 대해 작업
              LOOP AT lt_log_phys_name INTO ls_log_phys_name
                                      WHERE kind     = 'TABL'
                                        AND entity   = lv_entity
                                        AND sub_kind <> usmd1_cs_tabl_kind-map.
                "*----------------------------
                " 테이블 아이디 설정
                lv_table = ls_log_phys_name-phys_name.
                "*----------------------------
                " 테이블 레코드 삭제 처리
                DELETE FROM (lv_table) WHERE (lv_where).
              ENDLOOP.
            ENDIF.
          ENDLOOP. " LOOP AT lt_key_value INTO lv_key_value.


        WHEN usmd1_cs_tabl_kind-map.
          "
          lv_entity    = ls_log_phys_name-entity.
          lv_table     = ls_log_phys_name-phys_name.
          lv_key_field = 'USMDK' && lv_model && lv_entity.

          "
          WRITE:/ '*', lv_entity, lv_table, 'USMD1213'.

          TRY .
              "*----------------------------
              " 테이블 키 밸류 검색
*              lv_select = |'I' AS SIGN, 'EQ' AS OPTION, { lv_key_field } AS LOW|.
              lv_select = lv_key_field.
              SELECT (lv_select)
                FROM (lv_table)
*                INTO TABLE @lt_range_key_value.
                INTO TABLE @lt_key_value.
              SORT lt_key_value.
            CATCH cx_sy_dynamic_osql_semantics.
              CONTINUE.
          ENDTRY.

          " 키에 매핑 안된 Change Request 정보 검색
          SELECT *
            INTO TABLE lt_usmd1213
            FROM usmd1213
           WHERE usmd_entity     = lv_entity
             AND usmd_entity_obj = lv_entity.
*             AND usmd_value      NOT IN lt_range_key_value.

          LOOP AT lt_usmd1213 INTO ls_usmd1213.
            READ TABLE lt_key_value TRANSPORTING NO FIELDS WITH KEY table_line = ls_usmd1213-usmd_value BINARY SEARCH.
            IF sy-subrc EQ 0.
              DELETE lt_usmd1213.
            ELSE.
              lv_key_json = /ui2/cl_json=>serialize( ls_usmd1213 ).
              WRITE:/ lv_key_json.
            ENDIF.
          ENDLOOP.

          DELETE usmd1213 FROM TABLE lt_usmd1213.

        WHEN OTHERS.
      ENDCASE.

    ENDLOOP. " LOOP AT lt_log_phys_name INTO ls_log_phys_name

  ENDLOOP. " LOOP AT lt_model INTO lv_model.

*--------------------------------------
  " 커밋
  COMMIT WORK.

'ABAP > MDG 기준정보' 카테고리의 다른 글

ZCL_MDP_READ_HELPER  (0) 2021.12.15
MDG BP 생성/수정 CR 만드는 로직  (0) 2021.12.15

MDG read helper

for BP model

for MM model

 

코드:

 

CLASS zcl_mdp_read_helper DEFINITION
  PUBLIC
  CREATE PUBLIC .

  PUBLIC SECTION.

    TYPES ts_bp_key TYPE /mdgbp/_s_bp_ky_bp_header .
    TYPES:
      tt_bp_key TYPE SORTED TABLE OF /mdgbp/_s_bp_ky_bp_header WITH NON-UNIQUE KEY bp_header .
    TYPES ts_bp_bp_header TYPE mdg_bs_bp_bp_header .
    TYPES:
      tt_bp_bp_header TYPE SORTED TABLE OF mdg_bs_bp_bp_header WITH NON-UNIQUE KEY bp_header .
    TYPES ts_bp_ad_email TYPE mdg_bs_bp_ad_email .
    TYPES:
      tt_bp_ad_email TYPE SORTED TABLE OF mdg_bs_bp_ad_email WITH NON-UNIQUE KEY bp_header addrno ad_consno .
    TYPES ts_bp_ad_fax TYPE mdg_bs_bp_ad_fax .
    TYPES:
      tt_bp_ad_fax TYPE SORTED TABLE OF mdg_bs_bp_ad_fax WITH NON-UNIQUE KEY bp_header addrno ad_consno .
    TYPES ts_bp_ad_name_o TYPE mdg_bs_bp_ad_name_o .
    TYPES:
      tt_bp_ad_name_o TYPE SORTED TABLE OF mdg_bs_bp_ad_name_o WITH NON-UNIQUE KEY bp_header addrno ad_nation .
    TYPES ts_bp_ad_name_p TYPE mdg_bs_bp_ad_name_p .
    TYPES:
      tt_bp_ad_name_p TYPE SORTED TABLE OF mdg_bs_bp_ad_name_p WITH NON-UNIQUE KEY bp_header addrno ad_nation .
    TYPES ts_bp_ad_postal TYPE mdg_bs_bp_ad_postal .
    TYPES:
      tt_bp_ad_postal TYPE SORTED TABLE OF mdg_bs_bp_ad_postal WITH NON-UNIQUE KEY bp_header addrno ad_nation .
    TYPES ts_bp_ad_tel TYPE mdg_bs_bp_ad_tel .
    TYPES:
      tt_bp_ad_tel TYPE SORTED TABLE OF mdg_bs_bp_ad_tel WITH NON-UNIQUE KEY bp_header addrno ad_consno .
    TYPES ts_bp_ad_url TYPE mdg_bs_bp_ad_url .
    TYPES:
      tt_bp_ad_url TYPE SORTED TABLE OF mdg_bs_bp_ad_url WITH NON-UNIQUE KEY bp_header addrno ad_consno .
    TYPES ts_bp_address TYPE mdg_bs_bp_address .
    TYPES:
      tt_bp_address TYPE SORTED TABLE OF mdg_bs_bp_address WITH NON-UNIQUE KEY bp_header addrno .
    TYPES ts_bp_bp_addr TYPE mdg_bs_bp_bp_addr .
    TYPES:
      tt_bp_bp_addr TYPE SORTED TABLE OF mdg_bs_bp_bp_addr WITH NON-UNIQUE KEY bp_header addrno .
    TYPES ts_bp_bp_addusg TYPE mdg_bs_bp_bp_addusg .
    TYPES:
      tt_bp_bp_addusg TYPE SORTED TABLE OF mdg_bs_bp_bp_addusg WITH NON-UNIQUE KEY bp_header addrno bp_adrknd .
    TYPES ts_bp_bp_bkdtl TYPE mdg_bs_bp_bp_bkdtl .
    TYPES:
      tt_bp_bp_bkdtl TYPE SORTED TABLE OF mdg_bs_bp_bp_bkdtl WITH NON-UNIQUE KEY bp_header bank_id .
    TYPES ts_bp_bp_ccdtl TYPE mdg_bs_bp_bp_ccdtl .
    TYPES:
      tt_bp_bp_ccdtl TYPE SORTED TABLE OF mdg_bs_bp_bp_ccdtl WITH NON-UNIQUE KEY bp_header card_id .
    TYPES ts_bp_bp_centrl TYPE mdg_bs_bp_bp_centrl .
    TYPES:
      tt_bp_bp_centrl TYPE SORTED TABLE OF mdg_bs_bp_bp_centrl WITH NON-UNIQUE KEY bp_header .
    TYPES ts_bp_bp_idnum TYPE mdg_bs_bp_bp_idnum .
    TYPES:
      tt_bp_bp_idnum TYPE SORTED TABLE OF mdg_bs_bp_bp_idnum WITH NON-UNIQUE KEY bp_header bp_idtype bp_id_num .
    TYPES ts_bp_bp_indstr TYPE mdg_bs_bp_bp_indstr .
    TYPES:
      tt_bp_bp_indstr TYPE SORTED TABLE OF mdg_bs_bp_bp_indstr WITH NON-UNIQUE KEY bp_header bp_indsct bp_indsys .
    TYPES ts_bp_bp_role TYPE mdg_bs_bp_bp_role .
    TYPES:
      tt_bp_bp_role TYPE SORTED TABLE OF mdg_bs_bp_bp_role WITH NON-UNIQUE KEY bp_header bp_rol_id .
    TYPES ts_bp_bp_taxnum TYPE mdg_bs_bp_bp_taxnum .
    TYPES:
      tt_bp_bp_taxnum TYPE SORTED TABLE OF mdg_bs_bp_bp_taxnum WITH NON-UNIQUE KEY bp_header bp_tx_typ .
    TYPES ts_bp_bp_mlt_as TYPE /mdgbpx/_s_bp_pp_bp_mlt_as .
    TYPES:
      tt_bp_bp_mlt_as TYPE SORTED TABLE OF /mdgbpx/_s_bp_pp_bp_mlt_as WITH NON-UNIQUE KEY bp_header assgnm_id .
    TYPES ts_bp_bp_mlt_ad TYPE /mdgbpx/_s_bp_pp_bp_mlt_ad .
    TYPES:
      tt_bp_bp_mlt_ad TYPE SORTED TABLE OF /mdgbpx/_s_bp_pp_bp_mlt_ad WITH NON-UNIQUE KEY bp_header assgnm_id addrno .
    TYPES ts_bp_bp_cus_cc TYPE mdg_bs_cust_bp_cus_cc .
    TYPES:
      tt_bp_bp_cus_cc TYPE SORTED TABLE OF mdg_bs_cust_bp_cus_cc WITH NON-UNIQUE KEY bp_header assgnm_id company .
    TYPES ts_bp_bp_cuscla TYPE mdg_bs_cust_bp_cuscla .
    TYPES:
      tt_bp_bp_cuscla TYPE SORTED TABLE OF mdg_bs_cust_bp_cuscla WITH NON-UNIQUE KEY bp_header assgnm_id class classtype ecocntr .
    TYPES ts_bp_bp_cusddb TYPE mdg_bs_cust_bp_cusddb .
    TYPES:
      tt_bp_bp_cusddb TYPE SORTED TABLE OF mdg_bs_cust_bp_cusddb WITH NON-UNIQUE KEY bp_header assgnm_id cus_dokar cus_doknr cus_doktl cus_dokvr .
    TYPES ts_bp_bp_cusdun TYPE mdg_bs_cust_bp_cusdun .
    TYPES:
      tt_bp_bp_cusdun TYPE SORTED TABLE OF mdg_bs_cust_bp_cusdun WITH NON-UNIQUE KEY bp_header assgnm_id company maber .
    TYPES ts_bp_bp_cusfcn TYPE mdg_bs_cust_bp_cusfcn .
    TYPES:
      tt_bp_bp_cusfcn TYPE SORTED TABLE OF mdg_bs_cust_bp_cusfcn WITH NON-UNIQUE KEY bp_header assgnm_id spart vkorg vtweg parvw parza .
    TYPES ts_bp_bp_cusgen TYPE mdg_bs_cust_bp_cusgen .
    TYPES:
      tt_bp_bp_cusgen TYPE SORTED TABLE OF mdg_bs_cust_bp_cusgen WITH NON-UNIQUE KEY bp_header assgnm_id .
    TYPES ts_bp_bp_custax TYPE mdg_bs_cust_bp_custax .
    TYPES:
      tt_bp_bp_custax TYPE SORTED TABLE OF mdg_bs_cust_bp_custax WITH NON-UNIQUE KEY bp_header assgnm_id aland tatyp .
    TYPES ts_bp_bp_cusulp TYPE mdg_bs_cust_bp_cusulp .
    TYPES:
      tt_bp_bp_cusulp TYPE SORTED TABLE OF mdg_bs_cust_bp_cusulp WITH NON-UNIQUE KEY bp_header assgnm_id ablad .
    TYPES ts_bp_bp_cusval TYPE mdg_bs_cust_bp_cusval .
    TYPES:
      tt_bp_bp_cusval TYPE SORTED TABLE OF mdg_bs_cust_bp_cusval WITH NON-UNIQUE KEY bp_header assgnm_id charid classtype ecocntr valcnt .
    TYPES ts_bp_bp_cuswht TYPE mdg_bs_cust_bp_cuswht .
    TYPES:
      tt_bp_bp_cuswht TYPE SORTED TABLE OF mdg_bs_cust_bp_cuswht WITH NON-UNIQUE KEY bp_header assgnm_id company witht .
    TYPES ts_bp_bp_sales TYPE mdg_bs_cust_bp_sales .
    TYPES:
      tt_bp_bp_sales TYPE SORTED TABLE OF mdg_bs_cust_bp_sales WITH NON-UNIQUE KEY bp_header assgnm_id spart vkorg vtweg .
    TYPES ts_bp_cuscctxt TYPE mdg_bs_cust_cuscctxt .
    TYPES:
      tt_bp_cuscctxt TYPE SORTED TABLE OF mdg_bs_cust_cuscctxt WITH NON-UNIQUE KEY bp_header assgnm_id company cuslangu cus_tdid .
    TYPES ts_bp_cusgentxt TYPE mdg_bs_cust_cusgentxt .
    TYPES:
      tt_bp_cusgentxt TYPE SORTED TABLE OF mdg_bs_cust_cusgentxt WITH NON-UNIQUE KEY bp_header assgnm_id cuslangu cus_tdid .
    TYPES ts_bp_cussaltxt TYPE mdg_bs_cust_cussaltxt .
    TYPES:
      tt_bp_cussaltxt TYPE SORTED TABLE OF mdg_bs_cust_cussaltxt WITH NON-UNIQUE KEY bp_header assgnm_id spart vkorg vtweg cuslangu cus_tdid .
    TYPES ts_bp_bp_compny TYPE mdg_bs_suppl_bp_compny .
    TYPES:
      tt_bp_bp_compny TYPE SORTED TABLE OF mdg_bs_suppl_bp_compny WITH NON-UNIQUE KEY bp_header assgnm_id company .
    TYPES ts_bp_bp_dunn TYPE mdg_bs_suppl_bp_dunn .
    TYPES:
      tt_bp_bp_dunn TYPE SORTED TABLE OF mdg_bs_suppl_bp_dunn WITH NON-UNIQUE KEY bp_header assgnm_id company maber .
    TYPES ts_bp_bp_porg TYPE mdg_bs_suppl_bp_porg .
    TYPES:
      tt_bp_bp_porg TYPE SORTED TABLE OF mdg_bs_suppl_bp_porg WITH NON-UNIQUE KEY bp_header assgnm_id prch_org .
    TYPES ts_bp_bp_porg2 TYPE mdg_bs_suppl_bp_porg2 .
    TYPES:
      tt_bp_bp_porg2 TYPE SORTED TABLE OF mdg_bs_suppl_bp_porg2 WITH NON-UNIQUE KEY bp_header assgnm_id prch_org ltsnr werks_d .
    TYPES ts_bp_bp_taxgrp TYPE mdg_bs_suppl_bp_taxgrp .
    TYPES:
      tt_bp_bp_taxgrp TYPE SORTED TABLE OF mdg_bs_suppl_bp_taxgrp WITH NON-UNIQUE KEY bp_header assgnm_id koart taxgr .
    TYPES ts_bp_bp_vencla TYPE mdg_bs_suppl_bp_vencla .
    TYPES:
      tt_bp_bp_vencla TYPE SORTED TABLE OF mdg_bs_suppl_bp_vencla WITH NON-UNIQUE KEY bp_header assgnm_id class classtype ecocntr .
    TYPES ts_bp_bp_venddb TYPE mdg_bs_suppl_bp_venddb .
    TYPES:
      tt_bp_bp_venddb TYPE SORTED TABLE OF mdg_bs_suppl_bp_venddb WITH NON-UNIQUE KEY bp_header assgnm_id ven_dokar ven_doknr ven_doktl ven_dokvr .
    TYPES ts_bp_bp_venfcn TYPE mdg_bs_suppl_bp_venfcn .
    TYPES:
      tt_bp_bp_venfcn TYPE SORTED TABLE OF mdg_bs_suppl_bp_venfcn WITH NON-UNIQUE KEY bp_header assgnm_id prch_org ltsnr parvw parza werks_d .
    TYPES ts_bp_bp_vengen TYPE mdg_bs_suppl_bp_vengen .
    TYPES:
      tt_bp_bp_vengen TYPE SORTED TABLE OF mdg_bs_suppl_bp_vengen WITH NON-UNIQUE KEY bp_header assgnm_id .
    TYPES ts_bp_bp_vensub TYPE mdg_bs_suppl_bp_vensub .
    TYPES:
      tt_bp_bp_vensub TYPE SORTED TABLE OF mdg_bs_suppl_bp_vensub WITH NON-UNIQUE KEY bp_header assgnm_id ltsnr ven_langu .
    TYPES ts_bp_bp_venval TYPE mdg_bs_suppl_bp_venval .
    TYPES:
      tt_bp_bp_venval TYPE SORTED TABLE OF mdg_bs_suppl_bp_venval WITH NON-UNIQUE KEY bp_header assgnm_id charid classtype ecocntr valcnt .
    TYPES ts_bp_bp_whtax TYPE mdg_bs_suppl_bp_whtax .
    TYPES:
      tt_bp_bp_whtax TYPE SORTED TABLE OF mdg_bs_suppl_bp_whtax WITH NON-UNIQUE KEY bp_header assgnm_id company land_1 witht .
    TYPES ts_bp_vencctxt TYPE mdg_bs_suppl_vencctxt .
    TYPES:
      tt_bp_vencctxt TYPE SORTED TABLE OF mdg_bs_suppl_vencctxt WITH NON-UNIQUE KEY bp_header assgnm_id company venlangu ven_tdid .
    TYPES ts_bp_vengentxt TYPE mdg_bs_suppl_vengentxt .
    TYPES:
      tt_bp_vengentxt TYPE SORTED TABLE OF mdg_bs_suppl_vengentxt WITH NON-UNIQUE KEY bp_header assgnm_id venlangu ven_tdid .
    TYPES ts_bp_venpotxt TYPE mdg_bs_suppl_venpotxt .
    TYPES:
      tt_bp_venpotxt TYPE SORTED TABLE OF mdg_bs_suppl_venpotxt WITH NON-UNIQUE KEY bp_header assgnm_id prch_org venlangu ven_tdid .
    TYPES ts_mm_key TYPE /mdgmm/_s_mm_kf_material .
    TYPES:
      tt_mm_key TYPE SORTED TABLE OF /mdgmm/_s_mm_kf_material WITH NON-UNIQUE KEY material .
    TYPES ts_mm_txt TYPE /mdgmm/_st_mm_pp_material .
    TYPES:
      tt_mm_txt TYPE SORTED TABLE OF /mdgmm/_st_mm_pp_material WITH NON-UNIQUE KEY material langu .
    TYPES ts_mm_material TYPE /mdgmm/_s_mm_pp_material .
    TYPES:
      tt_mm_material TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_material WITH NON-UNIQUE KEY material .
    TYPES ts_mm_bscdattxt TYPE /mdgmm/_s_mm_pp_bscdattxt .
    TYPES:
      tt_mm_bscdattxt TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_bscdattxt WITH NON-UNIQUE KEY material langucode .
    TYPES ts_mm_classasgn TYPE /mdgmm/_s_mm_pp_classasgn .
    TYPES:
      tt_mm_classasgn TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_classasgn WITH NON-UNIQUE KEY material changeno class classtype ecocntr guid .
    TYPES ts_mm_intcmnt TYPE /mdgmm/_s_mm_pp_intcmnt .
    TYPES:
      tt_mm_intcmnt TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_intcmnt WITH NON-UNIQUE KEY material langucode .
    TYPES ts_mm_marapurch TYPE /mdgmm/_s_mm_pp_marapurch .
    TYPES:
      tt_mm_marapurch TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_marapurch WITH NON-UNIQUE KEY material .
    TYPES ts_mm_maraqtmng TYPE /mdgmm/_s_mm_pp_maraqtmng .
    TYPES:
      tt_mm_maraqtmng TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_maraqtmng WITH NON-UNIQUE KEY material .
    TYPES ts_mm_marasales TYPE /mdgmm/_s_mm_pp_marasales .
    TYPES:
      tt_mm_marasales TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_marasales WITH NON-UNIQUE KEY material .
    TYPES ts_mm_maraspm TYPE /mdgmm/_s_mm_pp_maraspm .
    TYPES:
      tt_mm_maraspm TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_maraspm WITH NON-UNIQUE KEY material .
    TYPES ts_mm_marastor TYPE /mdgmm/_s_mm_pp_marastor .
    TYPES:
      tt_mm_marastor TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_marastor WITH NON-UNIQUE KEY material .
    TYPES ts_mm_marcatp TYPE /mdgmm/_s_mm_pp_marcatp .
    TYPES:
      tt_mm_marcatp TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_marcatp WITH NON-UNIQUE KEY material werks .
    TYPES ts_mm_marcbasic TYPE /mdgmm/_s_mm_pp_marcbasic .
    TYPES:
      tt_mm_marcbasic TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_marcbasic WITH NON-UNIQUE KEY material werks .
    TYPES ts_mm_marccstng TYPE /mdgmm/_s_mm_pp_marccstng .
    TYPES:
      tt_mm_marccstng TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_marccstng WITH NON-UNIQUE KEY material werks .
    TYPES ts_mm_marcfrcst TYPE /mdgmm/_s_mm_pp_marcfrcst .
    TYPES:
      tt_mm_marcfrcst TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_marcfrcst WITH NON-UNIQUE KEY material werks .
    TYPES ts_mm_marcfrgtr TYPE /mdgmm/_s_mm_pp_marcfrgtr .
    TYPES:
      tt_mm_marcfrgtr TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_marcfrgtr WITH NON-UNIQUE KEY material werks .
    TYPES ts_mm_marcfrpar TYPE /mdgmm/_s_mm_pp_marcfrpar .
    TYPES:
      tt_mm_marcfrpar TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_marcfrpar WITH NON-UNIQUE KEY material werks .
    TYPES ts_mm_marcmrpfc TYPE /mdgmm/_s_mm_pp_marcmrpfc .
    TYPES:
      tt_mm_marcmrpfc TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_marcmrpfc WITH NON-UNIQUE KEY material werks .
    TYPES ts_mm_marcmrpls TYPE /mdgmm/_s_mm_pp_marcmrpls .
    TYPES:
      tt_mm_marcmrpls TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_marcmrpls WITH NON-UNIQUE KEY material werks .
    TYPES ts_mm_marcmrpmi TYPE /mdgmm/_s_mm_pp_marcmrpmi .
    TYPES:
      tt_mm_marcmrpmi TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_marcmrpmi WITH NON-UNIQUE KEY material werks .
    TYPES ts_mm_marcmrppp TYPE /mdgmm/_s_mm_pp_marcmrppp .
    TYPES:
      tt_mm_marcmrppp TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_marcmrppp WITH NON-UNIQUE KEY material werks .
    TYPES ts_mm_marcmrpsp TYPE /mdgmm/_s_mm_pp_marcmrpsp .
    TYPES:
      tt_mm_marcmrpsp TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_marcmrpsp WITH NON-UNIQUE KEY material werks .
    TYPES ts_mm_marcprt TYPE /mdgmm/_s_mm_pp_marcprt .
    TYPES:
      tt_mm_marcprt TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_marcprt WITH NON-UNIQUE KEY material werks .
    TYPES ts_mm_marcpurch TYPE /mdgmm/_s_mm_pp_marcpurch .
    TYPES:
      tt_mm_marcpurch TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_marcpurch WITH NON-UNIQUE KEY material werks .
    TYPES ts_mm_marcqtmng TYPE /mdgmm/_s_mm_pp_marcqtmng .
    TYPES:
      tt_mm_marcqtmng TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_marcqtmng WITH NON-UNIQUE KEY material werks .
    TYPES ts_mm_marcsales TYPE /mdgmm/_s_mm_pp_marcsales .
    TYPES:
      tt_mm_marcsales TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_marcsales WITH NON-UNIQUE KEY material werks .
    TYPES ts_mm_marcstore TYPE /mdgmm/_s_mm_pp_marcstore .
    TYPES:
      tt_mm_marcstore TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_marcstore WITH NON-UNIQUE KEY material werks .
    TYPES ts_mm_marcwrksd TYPE /mdgmm/_s_mm_pp_marcwrksd .
    TYPES:
      tt_mm_marcwrksd TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_marcwrksd WITH NON-UNIQUE KEY material werks .
    TYPES ts_mm_mardmrp TYPE /mdgmm/_s_mm_pp_mardmrp .
    TYPES:
      tt_mm_mardmrp TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_mardmrp WITH NON-UNIQUE KEY material werks lgort .
    TYPES ts_mm_mardstor TYPE /mdgmm/_s_mm_pp_mardstor .
    TYPES:
      tt_mm_mardstor TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_mardstor WITH NON-UNIQUE KEY material werks lgort .
    TYPES ts_mm_mbewactng TYPE /mdgmm/_s_mm_pp_mbewactng .
    TYPES:
      tt_mm_mbewactng TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_mbewactng WITH NON-UNIQUE KEY material bwkey bwtar .
    TYPES ts_mm_mbewcstng TYPE /mdgmm/_s_mm_pp_mbewcstng .
    TYPES:
      tt_mm_mbewcstng TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_mbewcstng WITH NON-UNIQUE KEY material bwkey .
    TYPES ts_mm_mbewmlac TYPE /mdgmm/_s_mm_pp_mbewmlac .
    TYPES:
      tt_mm_mbewmlac TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_mbewmlac WITH NON-UNIQUE KEY material bwkey bwtar curtp .
    TYPES ts_mm_mbewmlval TYPE /mdgmm/_s_mm_pp_mbewmlval .
    TYPES:
      tt_mm_mbewmlval TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_mbewmlval WITH NON-UNIQUE KEY material bwkey bwtar curtp .
    TYPES ts_mm_mbewvalua TYPE /mdgmm/_s_mm_pp_mbewvalua .
    TYPES:
      tt_mm_mbewvalua TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_mbewvalua WITH NON-UNIQUE KEY material bwkey bwtar .
    TYPES ts_mm_mdmabasic TYPE /mdgmm/_s_mm_pp_mdmabasic .
    TYPES:
      tt_mm_mdmabasic TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_mdmabasic WITH NON-UNIQUE KEY material werks berid .
    TYPES ts_mm_mean_gtin TYPE /mdgmm/_s_mm_pp_mean_gtin .
    TYPES:
      tt_mm_mean_gtin TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_mean_gtin WITH NON-UNIQUE KEY material qteunit ean .
    TYPES ts_mm_mlanpurch TYPE /mdgmm/_s_mm_pp_mlanpurch .
    TYPES:
      tt_mm_mlanpurch TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_mlanpurch WITH NON-UNIQUE KEY material aland .
    TYPES ts_mm_mlansales TYPE /mdgmm/_s_mm_pp_mlansales .
    TYPES:
      tt_mm_mlansales TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_mlansales WITH NON-UNIQUE KEY material aland tatyp .
    TYPES ts_mm_mlgnstor TYPE /mdgmm/_s_mm_pp_mlgnstor .
    TYPES:
      tt_mm_mlgnstor TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_mlgnstor WITH NON-UNIQUE KEY material lgnum .
    TYPES ts_mm_mlgtstor TYPE /mdgmm/_s_mm_pp_mlgtstor .
    TYPES:
      tt_mm_mlgtstor TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_mlgtstor WITH NON-UNIQUE KEY material lgnum lgtyp .
    TYPES ts_mm_mpgdprodg TYPE /mdgmm/_s_mm_pp_mpgdprodg .
    TYPES:
      tt_mm_mpgdprodg TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_mpgdprodg WITH NON-UNIQUE KEY material werks .
    TYPES ts_mm_mrptxt TYPE /mdgmm/_s_mm_pp_mrptxt .
    TYPES:
      tt_mm_mrptxt TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_mrptxt WITH NON-UNIQUE KEY material werks .
    TYPES ts_mm_mvkegrpng TYPE /mdgmm/_s_mm_pp_mvkegrpng .
    TYPES:
      tt_mm_mvkegrpng TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_mvkegrpng WITH NON-UNIQUE KEY material vkorg vtweg .
    TYPES ts_mm_mvkesales TYPE /mdgmm/_s_mm_pp_mvkesales .
    TYPES:
      tt_mm_mvkesales TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_mvkesales WITH NON-UNIQUE KEY material vkorg vtweg .
    TYPES ts_mm_purchtxt TYPE /mdgmm/_s_mm_pp_purchtxt .
    TYPES:
      tt_mm_purchtxt TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_purchtxt WITH NON-UNIQUE KEY material langucode .
    TYPES ts_mm_qinsptxt TYPE /mdgmm/_s_mm_pp_qinsptxt .
    TYPES:
      tt_mm_qinsptxt TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_qinsptxt WITH NON-UNIQUE KEY material langucode .
    TYPES ts_mm_qmatbasic TYPE /mdgmm/_s_mm_pp_qmatbasic .
    TYPES:
      tt_mm_qmatbasic TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_qmatbasic WITH NON-UNIQUE KEY material werks art .
    TYPES ts_mm_salestxt TYPE /mdgmm/_s_mm_pp_salestxt .
    TYPES:
      tt_mm_salestxt TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_salestxt WITH NON-UNIQUE KEY material vkorg vtweg langucode .
    TYPES ts_mm_unitofmsr TYPE /mdgmm/_s_mm_pp_unitofmsr .
    TYPES:
      tt_mm_unitofmsr TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_unitofmsr WITH NON-UNIQUE KEY material qteunit .
    TYPES ts_mm_valuation TYPE /mdgmm/_s_mm_pp_valuation .
    TYPES:
      tt_mm_valuation TYPE SORTED TABLE OF /mdgmm/_s_mm_pp_valuation WITH NON-UNIQUE KEY material changeno charid classtype ecocntr guid valcnt .

    CLASS-DATA gv_debug_mode TYPE flag .

    CLASS-METHODS get_cr_from_key
      IMPORTING
        !iv_model       TYPE usmd_model
        !iv_main_entity TYPE usmd_entity
        !is_key         TYPE data
      RETURNING
        VALUE(rv_cr)    TYPE usmd_crequest .
    CLASS-METHODS get_t_sel_from_conv_api
      RETURNING
        VALUE(rt_sel) TYPE usmd_ts_sel .
    CLASS-METHODS read_entity
      IMPORTING
        !iv_entity TYPE clike
      EXPORTING
        !et_data   TYPE ANY TABLE .
    CLASS-METHODS read_bp
      IMPORTING
        !iv_key           TYPE bu_partner OPTIONAL
        !it_key           TYPE rpm_tt_bupa OPTIONAL
        !iv_read_inactive TYPE flag OPTIONAL
      EXPORTING
        !es_bp_header     TYPE ts_bp_bp_header
        !et_key           TYPE tt_bp_key
        !et_bp_header     TYPE tt_bp_bp_header
        !et_ad_email      TYPE tt_bp_ad_email
        !et_ad_fax        TYPE tt_bp_ad_fax
        !et_ad_name_o     TYPE tt_bp_ad_name_o
        !et_ad_name_p     TYPE tt_bp_ad_name_p
        !et_ad_postal     TYPE tt_bp_ad_postal
        !et_ad_tel        TYPE tt_bp_ad_tel
        !et_ad_url        TYPE tt_bp_ad_url
        !et_address       TYPE tt_bp_address
        !et_bp_addr       TYPE tt_bp_bp_addr
        !et_bp_addusg     TYPE tt_bp_bp_addusg
        !et_bp_bkdtl      TYPE tt_bp_bp_bkdtl
        !et_bp_ccdtl      TYPE tt_bp_bp_ccdtl
        !et_bp_centrl     TYPE tt_bp_bp_centrl
        !et_bp_idnum      TYPE tt_bp_bp_idnum
        !et_bp_indstr     TYPE tt_bp_bp_indstr
        !et_bp_role       TYPE tt_bp_bp_role
        !et_bp_taxnum     TYPE tt_bp_bp_taxnum
        !et_bp_mlt_as     TYPE tt_bp_bp_mlt_as
        !et_bp_mlt_ad     TYPE tt_bp_bp_mlt_ad
        !et_bp_cus_cc     TYPE tt_bp_bp_cus_cc
        !et_bp_cuscla     TYPE tt_bp_bp_cuscla
        !et_bp_cusddb     TYPE tt_bp_bp_cusddb
        !et_bp_cusdun     TYPE tt_bp_bp_cusdun
        !et_bp_cusfcn     TYPE tt_bp_bp_cusfcn
        !et_bp_cusgen     TYPE tt_bp_bp_cusgen
        !et_bp_custax     TYPE tt_bp_bp_custax
        !et_bp_cusulp     TYPE tt_bp_bp_cusulp
        !et_bp_cusval     TYPE tt_bp_bp_cusval
        !et_bp_cuswht     TYPE tt_bp_bp_cuswht
        !et_bp_sales      TYPE tt_bp_bp_sales
        !et_cuscctxt      TYPE tt_bp_cuscctxt
        !et_cusgentxt     TYPE tt_bp_cusgentxt
        !et_cussaltxt     TYPE tt_bp_cussaltxt
        !et_bp_compny     TYPE tt_bp_bp_compny
        !et_bp_dunn       TYPE tt_bp_bp_dunn
        !et_bp_porg       TYPE tt_bp_bp_porg
        !et_bp_porg2      TYPE tt_bp_bp_porg2
        !et_bp_taxgrp     TYPE tt_bp_bp_taxgrp
        !et_bp_vencla     TYPE tt_bp_bp_vencla
        !et_bp_venddb     TYPE tt_bp_bp_venddb
        !et_bp_venfcn     TYPE tt_bp_bp_venfcn
        !et_bp_vengen     TYPE tt_bp_bp_vengen
        !et_bp_vensub     TYPE tt_bp_bp_vensub
        !et_bp_venval     TYPE tt_bp_bp_venval
        !et_bp_whtax      TYPE tt_bp_bp_whtax
        !et_vencctxt      TYPE tt_bp_vencctxt
        !et_vengentxt     TYPE tt_bp_vengentxt
        !et_venpotxt      TYPE tt_bp_venpotxt .
    CLASS-METHODS read_mm
      IMPORTING
        !iv_key           TYPE matnr OPTIONAL
        !it_key           TYPE matnr_tab OPTIONAL
        !iv_read_inactive TYPE flag OPTIONAL
      EXPORTING
        !es_material      TYPE ts_mm_material
        !et_key           TYPE tt_mm_key
        !et_txt           TYPE tt_mm_txt
        !et_material      TYPE tt_mm_material
        !et_bscdattxt     TYPE tt_mm_bscdattxt
        !et_classasgn     TYPE tt_mm_classasgn
        !et_intcmnt       TYPE tt_mm_intcmnt
        !et_marapurch     TYPE tt_mm_marapurch
        !et_maraqtmng     TYPE tt_mm_maraqtmng
        !et_marasales     TYPE tt_mm_marasales
        !et_maraspm       TYPE tt_mm_maraspm
        !et_marastor      TYPE tt_mm_marastor
        !et_marcatp       TYPE tt_mm_marcatp
        !et_marcbasic     TYPE tt_mm_marcbasic
        !et_marccstng     TYPE tt_mm_marccstng
        !et_marcfrcst     TYPE tt_mm_marcfrcst
        !et_marcfrgtr     TYPE tt_mm_marcfrgtr
        !et_marcfrpar     TYPE tt_mm_marcfrpar
        !et_marcmrpfc     TYPE tt_mm_marcmrpfc
        !et_marcmrpls     TYPE tt_mm_marcmrpls
        !et_marcmrpmi     TYPE tt_mm_marcmrpmi
        !et_marcmrppp     TYPE tt_mm_marcmrppp
        !et_marcmrpsp     TYPE tt_mm_marcmrpsp
        !et_marcprt       TYPE tt_mm_marcprt
        !et_marcpurch     TYPE tt_mm_marcpurch
        !et_marcqtmng     TYPE tt_mm_marcqtmng
        !et_marcsales     TYPE tt_mm_marcsales
        !et_marcstore     TYPE tt_mm_marcstore
        !et_marcwrksd     TYPE tt_mm_marcwrksd
        !et_mardmrp       TYPE tt_mm_mardmrp
        !et_mardstor      TYPE tt_mm_mardstor
        !et_mbewactng     TYPE tt_mm_mbewactng
        !et_mbewcstng     TYPE tt_mm_mbewcstng
        !et_mbewmlac      TYPE tt_mm_mbewmlac
        !et_mbewmlval     TYPE tt_mm_mbewmlval
        !et_mbewvalua     TYPE tt_mm_mbewvalua
        !et_mdmabasic     TYPE tt_mm_mdmabasic
        !et_mean_gtin     TYPE tt_mm_mean_gtin
        !et_mlanpurch     TYPE tt_mm_mlanpurch
        !et_mlansales     TYPE tt_mm_mlansales
        !et_mlgnstor      TYPE tt_mm_mlgnstor
        !et_mlgtstor      TYPE tt_mm_mlgtstor
        !et_mpgdprodg     TYPE tt_mm_mpgdprodg
        !et_mrptxt        TYPE tt_mm_mrptxt
        !et_mvkegrpng     TYPE tt_mm_mvkegrpng
        !et_mvkesales     TYPE tt_mm_mvkesales
        !et_purchtxt      TYPE tt_mm_purchtxt
        !et_qinsptxt      TYPE tt_mm_qinsptxt
        !et_qmatbasic     TYPE tt_mm_qmatbasic
        !et_salestxt      TYPE tt_mm_salestxt
        !et_unitofmsr     TYPE tt_mm_unitofmsr
        !et_valuation     TYPE tt_mm_valuation .
  PROTECTED SECTION.
  PRIVATE SECTION.
ENDCLASS.



CLASS ZCL_MDP_READ_HELPER IMPLEMENTATION.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Static Public Method ZCL_MDP_READ_HELPER=>GET_CR_FROM_KEY
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_MODEL                       TYPE        USMD_MODEL
* | [--->] IV_MAIN_ENTITY                 TYPE        USMD_ENTITY
* | [--->] IS_KEY                         TYPE        DATA
* | [<-()] RV_CR                          TYPE        USMD_CREQUEST
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD get_cr_from_key.
    DATA: lt_crequest_id TYPE usmd_cr_ts_root_node_id.

*IV_OBJECT_TYPE	TYPE USMD_OBJECT
*IS_OBJECT_KEY  TYPE DATA
*IV_MODEL	TYPE USMD_MODEL
*value( RT_CREQUEST_ID )  TYPE USMD_CR_TS_ROOT_NODE_ID
    cl_usmd_cr_factory=>get_cr_service_provider( )->if_usmd_cr_sp_query~retrieve_open_cr_by_object_key(
      EXPORTING
        iv_object_type = iv_main_entity
        is_object_key  = is_key
        iv_model       = iv_model
      RECEIVING
        rt_crequest_id = lt_crequest_id
    ).
*    CATCH cx_usmd_cr_root_no_model_insta. " no model instance for model name
*    CATCH cx_usmd_cr_root_bad_entity_typ. " Illegal entity typ
*    CATCH cx_usmd_cr_root_emp_entity_key. " Initial entity key.

    CHECK: lt_crequest_id IS NOT INITIAL.
    rv_cr = lt_crequest_id[ 1 ]-usmd_crequest.

  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Static Public Method ZCL_MDP_READ_HELPER=>GET_T_SEL_FROM_CONV_API
* +-------------------------------------------------------------------------------------------------+
* | [<-()] RT_SEL                         TYPE        USMD_TS_SEL
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD get_t_sel_from_conv_api.
    DATA: lo_conv_api             TYPE REF TO if_usmd_conv_som_gov_api,
          lt_object_list_db_style TYPE usmd_t_crequest_entity,
          ls_object_list_db_style TYPE usmd_s_crequest_entity,
          ls_sel                  TYPE usmd_s_sel.

    TRY.
        lo_conv_api = cl_usmd_conv_som_gov_api=>get_instance( ).
        lo_conv_api->get_object_list(
          IMPORTING
            et_object_list_db_style = lt_object_list_db_style " Change Request, Entity, Table Type
        ).
        ls_sel-sign = 'I'.
        ls_sel-option = 'EQ'.
        LOOP AT lt_object_list_db_style INTO ls_object_list_db_style WHERE usmd_entity = lo_conv_api->mv_main_entity.
          ls_sel-fieldname = ls_object_list_db_style-usmd_entity_obj.
          ls_sel-low = ls_object_list_db_style-usmd_value.
          INSERT ls_sel INTO TABLE rt_sel.
        ENDLOOP.

      CATCH cx_usmd_gov_api.                " General Processing Error GOV_API

    ENDTRY.

  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Static Public Method ZCL_MDP_READ_HELPER=>READ_BP
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_KEY                         TYPE        BU_PARTNER(optional)
* | [--->] IT_KEY                         TYPE        RPM_TT_BUPA(optional)
* | [--->] IV_READ_INACTIVE               TYPE        FLAG(optional)
* | [<---] ES_BP_HEADER                   TYPE        TS_BP_BP_HEADER
* | [<---] ET_KEY                         TYPE        TT_BP_KEY
* | [<---] ET_BP_HEADER                   TYPE        TT_BP_BP_HEADER
* | [<---] ET_AD_EMAIL                    TYPE        TT_BP_AD_EMAIL
* | [<---] ET_AD_FAX                      TYPE        TT_BP_AD_FAX
* | [<---] ET_AD_NAME_O                   TYPE        TT_BP_AD_NAME_O
* | [<---] ET_AD_NAME_P                   TYPE        TT_BP_AD_NAME_P
* | [<---] ET_AD_POSTAL                   TYPE        TT_BP_AD_POSTAL
* | [<---] ET_AD_TEL                      TYPE        TT_BP_AD_TEL
* | [<---] ET_AD_URL                      TYPE        TT_BP_AD_URL
* | [<---] ET_ADDRESS                     TYPE        TT_BP_ADDRESS
* | [<---] ET_BP_ADDR                     TYPE        TT_BP_BP_ADDR
* | [<---] ET_BP_ADDUSG                   TYPE        TT_BP_BP_ADDUSG
* | [<---] ET_BP_BKDTL                    TYPE        TT_BP_BP_BKDTL
* | [<---] ET_BP_CCDTL                    TYPE        TT_BP_BP_CCDTL
* | [<---] ET_BP_CENTRL                   TYPE        TT_BP_BP_CENTRL
* | [<---] ET_BP_IDNUM                    TYPE        TT_BP_BP_IDNUM
* | [<---] ET_BP_INDSTR                   TYPE        TT_BP_BP_INDSTR
* | [<---] ET_BP_ROLE                     TYPE        TT_BP_BP_ROLE
* | [<---] ET_BP_TAXNUM                   TYPE        TT_BP_BP_TAXNUM
* | [<---] ET_BP_MLT_AS                   TYPE        TT_BP_BP_MLT_AS
* | [<---] ET_BP_MLT_AD                   TYPE        TT_BP_BP_MLT_AD
* | [<---] ET_BP_CUS_CC                   TYPE        TT_BP_BP_CUS_CC
* | [<---] ET_BP_CUSCLA                   TYPE        TT_BP_BP_CUSCLA
* | [<---] ET_BP_CUSDDB                   TYPE        TT_BP_BP_CUSDDB
* | [<---] ET_BP_CUSDUN                   TYPE        TT_BP_BP_CUSDUN
* | [<---] ET_BP_CUSFCN                   TYPE        TT_BP_BP_CUSFCN
* | [<---] ET_BP_CUSGEN                   TYPE        TT_BP_BP_CUSGEN
* | [<---] ET_BP_CUSTAX                   TYPE        TT_BP_BP_CUSTAX
* | [<---] ET_BP_CUSULP                   TYPE        TT_BP_BP_CUSULP
* | [<---] ET_BP_CUSVAL                   TYPE        TT_BP_BP_CUSVAL
* | [<---] ET_BP_CUSWHT                   TYPE        TT_BP_BP_CUSWHT
* | [<---] ET_BP_SALES                    TYPE        TT_BP_BP_SALES
* | [<---] ET_CUSCCTXT                    TYPE        TT_BP_CUSCCTXT
* | [<---] ET_CUSGENTXT                   TYPE        TT_BP_CUSGENTXT
* | [<---] ET_CUSSALTXT                   TYPE        TT_BP_CUSSALTXT
* | [<---] ET_BP_COMPNY                   TYPE        TT_BP_BP_COMPNY
* | [<---] ET_BP_DUNN                     TYPE        TT_BP_BP_DUNN
* | [<---] ET_BP_PORG                     TYPE        TT_BP_BP_PORG
* | [<---] ET_BP_PORG2                    TYPE        TT_BP_BP_PORG2
* | [<---] ET_BP_TAXGRP                   TYPE        TT_BP_BP_TAXGRP
* | [<---] ET_BP_VENCLA                   TYPE        TT_BP_BP_VENCLA
* | [<---] ET_BP_VENDDB                   TYPE        TT_BP_BP_VENDDB
* | [<---] ET_BP_VENFCN                   TYPE        TT_BP_BP_VENFCN
* | [<---] ET_BP_VENGEN                   TYPE        TT_BP_BP_VENGEN
* | [<---] ET_BP_VENSUB                   TYPE        TT_BP_BP_VENSUB
* | [<---] ET_BP_VENVAL                   TYPE        TT_BP_BP_VENVAL
* | [<---] ET_BP_WHTAX                    TYPE        TT_BP_BP_WHTAX
* | [<---] ET_VENCCTXT                    TYPE        TT_BP_VENCCTXT
* | [<---] ET_VENGENTXT                   TYPE        TT_BP_VENGENTXT
* | [<---] ET_VENPOTXT                    TYPE        TT_BP_VENPOTXT
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD read_bp.
    DATA: lo_model_ext TYPE REF TO if_usmd_model_ext,
          lt_sel       TYPE usmd_ts_sel,
          ls_sel       TYPE usmd_s_sel,
          lv_readmode  TYPE usmd_readmode_ext  VALUE if_usmd_model_ext=>gc_readmode_default,
          lv_key       LIKE LINE OF it_key.
    FIELD-SYMBOLS: <ls_key> LIKE LINE OF et_key.

    CLEAR: et_key, et_bp_header, es_bp_header.

    cl_usmd_model_ext=>get_instance(
      EXPORTING
        i_usmd_model = 'BP'
      IMPORTING
        eo_instance  = lo_model_ext
    ).
    CHECK: lo_model_ext IS NOT INITIAL.

    ls_sel-fieldname = 'BP_HEADER'.
    ls_sel-sign = 'I'.
    ls_sel-option = 'EQ'.

    IF iv_key IS NOT INITIAL.
      ls_sel-low = iv_key.
      INSERT ls_sel INTO TABLE lt_sel.
    ENDIF.

    IF it_key IS NOT INITIAL.
      LOOP AT it_key INTO lv_key.
        ls_sel-low = lv_key.
        INSERT ls_sel INTO TABLE lt_sel.
      ENDLOOP.
    ENDIF.

    IF lt_sel IS INITIAL.
      lt_sel = get_t_sel_from_conv_api( ).
    ENDIF.

    CHECK: lt_sel IS NOT INITIAL.

    IF iv_read_inactive EQ abap_true.
      lv_readmode = if_usmd_model_ext=>gc_readmode_no_act.

      lo_model_ext->read_char_value(
        EXPORTING
          i_fieldname       = 'BP_HEADER'
          it_sel            = lt_sel
          i_readmode        = lv_readmode
        IMPORTING
          et_data           = et_key
      ).
      CHECK: et_key IS NOT INITIAL.
      IF lines( lt_sel ) <> lines( et_key ).
        CLEAR: lt_sel.
        LOOP AT et_key ASSIGNING <ls_key>.
          ls_sel-low = <ls_key>-bp_header.
          INSERT ls_sel INTO TABLE lt_sel.
        ENDLOOP.
      ENDIF.

      lv_readmode = if_usmd_model_ext=>gc_readmode_all_inact.
    ENDIF.

    lo_model_ext->read_char_value(
      EXPORTING
        i_fieldname       = 'BP_HEADER'
        it_sel            = lt_sel
        i_readmode        = lv_readmode
      IMPORTING
        et_data           = et_bp_header
    ).
    CHECK: et_bp_header IS NOT INITIAL.
    READ TABLE et_bp_header INTO es_bp_header INDEX 1.
    MOVE-CORRESPONDING et_bp_header TO et_key.


*    IF et_bp_centrl IS SUPPLIED.
*      CLEAR: et_bp_centrl.
*      lo_model_ext->read_char_value(
*        EXPORTING
*          i_fieldname       = 'BP_CENTRL'
*          it_sel            = lt_sel
*          i_readmode        = lv_readmode
*        IMPORTING
*          et_data           = et_bp_centrl
*      ).
*    ENDIF.
    DEFINE __read.
      IF gv_debug_mode EQ abap_true OR et_&1 IS SUPPLIED.
        CLEAR: et_&1.
        lo_model_ext->read_char_value(
          EXPORTING
            i_fieldname       = '&1'
            it_sel            = lt_sel
            i_readmode        = lv_readmode
          IMPORTING
            et_data           = et_&1
        ).
      ENDIF.
    END-OF-DEFINITION.


    __read ad_email.
    __read ad_fax.
    __read ad_name_o.
    __read ad_name_p.
    __read ad_postal.
    __read ad_tel.
    __read ad_url.
    __read address.
    __read bp_addr.
    __read bp_addusg.
    __read bp_bkdtl.
    __read bp_ccdtl.
    __read bp_centrl.
    __read bp_idnum.
    __read bp_indstr.
    __read bp_role.
    __read bp_taxnum.
    __read bp_mlt_as.
    __read bp_mlt_ad.
    __read bp_cus_cc.
    __read bp_cuscla.
    __read bp_cusddb.
    __read bp_cusdun.
    __read bp_cusfcn.
    __read bp_cusgen.
    __read bp_custax.
    __read bp_cusulp.
    __read bp_cusval.
    __read bp_cuswht.
    __read bp_sales.
    __read cuscctxt.
    __read cusgentxt.
    __read cussaltxt.
    __read bp_compny.
    __read bp_dunn.
    __read bp_porg.
    __read bp_porg2.
    __read bp_taxgrp.
    __read bp_vencla.
    __read bp_venddb.
    __read bp_venfcn.
    __read bp_vengen.
    __read bp_vensub.
    __read bp_venval.
    __read bp_whtax.
    __read vencctxt.
    __read vengentxt.
    __read venpotxt.


    IF gv_debug_mode EQ abap_true.
      BREAK-POINT.
    ENDIF.
  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Static Public Method ZCL_MDP_READ_HELPER=>READ_ENTITY
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_ENTITY                      TYPE        CLIKE
* | [<---] ET_DATA                        TYPE        ANY TABLE
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD read_entity.
    DATA: lo_mdg_api   TYPE REF TO if_usmd_conv_som_gov_api,
          lo_model_api TYPE REF TO if_usmd_model_ext,
          lt_sel       TYPE usmd_ts_sel.

    CLEAR: et_data.

    TRY.
        lo_mdg_api = cl_usmd_conv_som_gov_api=>get_instance( ).
      CATCH cx_usmd_gov_api.
        RETURN.
    ENDTRY.
    CHECK: lo_mdg_api IS NOT INITIAL.

    cl_usmd_model_ext=>get_instance(
      EXPORTING
        i_usmd_model = lo_mdg_api->mv_model_name
      IMPORTING
        eo_instance  = lo_model_api
    ).
    CHECK: lo_model_api IS NOT INITIAL.

    lt_sel = get_t_sel_from_conv_api( ).

    lo_model_api->read_char_value(
      EXPORTING
        i_fieldname       = CONV #( iv_entity )
        it_sel            = lt_sel
      IMPORTING
        et_data           = et_data
    ).
  ENDMETHOD.


* <SIGNATURE>---------------------------------------------------------------------------------------+
* | Static Public Method ZCL_MDP_READ_HELPER=>READ_MM
* +-------------------------------------------------------------------------------------------------+
* | [--->] IV_KEY                         TYPE        MATNR(optional)
* | [--->] IT_KEY                         TYPE        MATNR_TAB(optional)
* | [--->] IV_READ_INACTIVE               TYPE        FLAG(optional)
* | [<---] ES_MATERIAL                    TYPE        TS_MM_MATERIAL
* | [<---] ET_KEY                         TYPE        TT_MM_KEY
* | [<---] ET_TXT                         TYPE        TT_MM_TXT
* | [<---] ET_MATERIAL                    TYPE        TT_MM_MATERIAL
* | [<---] ET_BSCDATTXT                   TYPE        TT_MM_BSCDATTXT
* | [<---] ET_CLASSASGN                   TYPE        TT_MM_CLASSASGN
* | [<---] ET_INTCMNT                     TYPE        TT_MM_INTCMNT
* | [<---] ET_MARAPURCH                   TYPE        TT_MM_MARAPURCH
* | [<---] ET_MARAQTMNG                   TYPE        TT_MM_MARAQTMNG
* | [<---] ET_MARASALES                   TYPE        TT_MM_MARASALES
* | [<---] ET_MARASPM                     TYPE        TT_MM_MARASPM
* | [<---] ET_MARASTOR                    TYPE        TT_MM_MARASTOR
* | [<---] ET_MARCATP                     TYPE        TT_MM_MARCATP
* | [<---] ET_MARCBASIC                   TYPE        TT_MM_MARCBASIC
* | [<---] ET_MARCCSTNG                   TYPE        TT_MM_MARCCSTNG
* | [<---] ET_MARCFRCST                   TYPE        TT_MM_MARCFRCST
* | [<---] ET_MARCFRGTR                   TYPE        TT_MM_MARCFRGTR
* | [<---] ET_MARCFRPAR                   TYPE        TT_MM_MARCFRPAR
* | [<---] ET_MARCMRPFC                   TYPE        TT_MM_MARCMRPFC
* | [<---] ET_MARCMRPLS                   TYPE        TT_MM_MARCMRPLS
* | [<---] ET_MARCMRPMI                   TYPE        TT_MM_MARCMRPMI
* | [<---] ET_MARCMRPPP                   TYPE        TT_MM_MARCMRPPP
* | [<---] ET_MARCMRPSP                   TYPE        TT_MM_MARCMRPSP
* | [<---] ET_MARCPRT                     TYPE        TT_MM_MARCPRT
* | [<---] ET_MARCPURCH                   TYPE        TT_MM_MARCPURCH
* | [<---] ET_MARCQTMNG                   TYPE        TT_MM_MARCQTMNG
* | [<---] ET_MARCSALES                   TYPE        TT_MM_MARCSALES
* | [<---] ET_MARCSTORE                   TYPE        TT_MM_MARCSTORE
* | [<---] ET_MARCWRKSD                   TYPE        TT_MM_MARCWRKSD
* | [<---] ET_MARDMRP                     TYPE        TT_MM_MARDMRP
* | [<---] ET_MARDSTOR                    TYPE        TT_MM_MARDSTOR
* | [<---] ET_MBEWACTNG                   TYPE        TT_MM_MBEWACTNG
* | [<---] ET_MBEWCSTNG                   TYPE        TT_MM_MBEWCSTNG
* | [<---] ET_MBEWMLAC                    TYPE        TT_MM_MBEWMLAC
* | [<---] ET_MBEWMLVAL                   TYPE        TT_MM_MBEWMLVAL
* | [<---] ET_MBEWVALUA                   TYPE        TT_MM_MBEWVALUA
* | [<---] ET_MDMABASIC                   TYPE        TT_MM_MDMABASIC
* | [<---] ET_MEAN_GTIN                   TYPE        TT_MM_MEAN_GTIN
* | [<---] ET_MLANPURCH                   TYPE        TT_MM_MLANPURCH
* | [<---] ET_MLANSALES                   TYPE        TT_MM_MLANSALES
* | [<---] ET_MLGNSTOR                    TYPE        TT_MM_MLGNSTOR
* | [<---] ET_MLGTSTOR                    TYPE        TT_MM_MLGTSTOR
* | [<---] ET_MPGDPRODG                   TYPE        TT_MM_MPGDPRODG
* | [<---] ET_MRPTXT                      TYPE        TT_MM_MRPTXT
* | [<---] ET_MVKEGRPNG                   TYPE        TT_MM_MVKEGRPNG
* | [<---] ET_MVKESALES                   TYPE        TT_MM_MVKESALES
* | [<---] ET_PURCHTXT                    TYPE        TT_MM_PURCHTXT
* | [<---] ET_QINSPTXT                    TYPE        TT_MM_QINSPTXT
* | [<---] ET_QMATBASIC                   TYPE        TT_MM_QMATBASIC
* | [<---] ET_SALESTXT                    TYPE        TT_MM_SALESTXT
* | [<---] ET_UNITOFMSR                   TYPE        TT_MM_UNITOFMSR
* | [<---] ET_VALUATION                   TYPE        TT_MM_VALUATION
* +--------------------------------------------------------------------------------------</SIGNATURE>
  METHOD read_mm.
    DATA: lo_model_ext TYPE REF TO if_usmd_model_ext,
          lt_sel       TYPE usmd_ts_sel,
          ls_sel       TYPE usmd_s_sel,
          lv_readmode  TYPE usmd_readmode_ext  VALUE if_usmd_model_ext=>gc_readmode_default,
          lv_key       LIKE LINE OF it_key.
    FIELD-SYMBOLS: <ls_key> LIKE LINE OF et_key.

    CLEAR: et_key, et_material, es_material.

    cl_usmd_model_ext=>get_instance(
      EXPORTING
        i_usmd_model = 'MM'
      IMPORTING
        eo_instance  = lo_model_ext
    ).
    CHECK: lo_model_ext IS NOT INITIAL.

    ls_sel-fieldname = 'MATERIAL'.
    ls_sel-sign = 'I'.
    ls_sel-option = 'EQ'.

    IF iv_key IS NOT INITIAL.
      ls_sel-low = iv_key.
      INSERT ls_sel INTO TABLE lt_sel.
    ENDIF.

    IF it_key IS NOT INITIAL.
      LOOP AT it_key INTO lv_key.
        ls_sel-low = lv_key.
        INSERT ls_sel INTO TABLE lt_sel.
      ENDLOOP.
    ENDIF.

    IF lt_sel IS INITIAL.
      lt_sel = get_t_sel_from_conv_api( ).
    ENDIF.

    CHECK: lt_sel IS NOT INITIAL.

    IF iv_read_inactive EQ abap_true.
      lv_readmode = if_usmd_model_ext=>gc_readmode_no_act.

      lo_model_ext->read_char_value(
        EXPORTING
          i_fieldname       = 'MATERIAL'
          it_sel            = lt_sel
          i_readmode        = lv_readmode
        IMPORTING
          et_data           = et_key
      ).
      CHECK: et_key IS NOT INITIAL.
      IF lines( lt_sel ) <> lines( et_key ).
        CLEAR: lt_sel.
        LOOP AT et_key ASSIGNING <ls_key>.
          ls_sel-low = <ls_key>-material.
          INSERT ls_sel INTO TABLE lt_sel.
        ENDLOOP.
      ENDIF.

      lv_readmode = if_usmd_model_ext=>gc_readmode_all_inact.
    ENDIF.

    lo_model_ext->read_char_value(
      EXPORTING
        i_fieldname       = 'MATERIAL'
        it_sel            = lt_sel
        i_readmode        = lv_readmode
      IMPORTING
        et_data           = et_material
    ).
    CHECK: et_material IS NOT INITIAL.
    READ TABLE et_material INTO es_material INDEX 1.
    MOVE-CORRESPONDING et_material TO et_key.

    IF et_txt IS SUPPLIED OR gv_debug_mode EQ abap_true.
      lo_model_ext->read_char_value(
        EXPORTING
          i_fieldname       = 'MATERIAL'
          it_sel            = lt_sel
          i_readmode        = lv_readmode
        IMPORTING
          et_data           = et_txt
      ).
    ENDIF.



*    IF et_BSCDATTXT IS SUPPLIED.
*      CLEAR: et_BSCDATTXT.
*      lo_model_ext->read_char_value(
*        EXPORTING
*          i_fieldname       = 'BSCDATTXT'
*          it_sel            = lt_sel
*          i_readmode        = lv_readmode
*        IMPORTING
*          et_data           = et_BSCDATTXT
*      ).
*    ENDIF.
    DEFINE __read.
      IF gv_debug_mode EQ abap_true OR et_&1 IS SUPPLIED.
        CLEAR: et_&1.
        lo_model_ext->read_char_value(
          EXPORTING
            i_fieldname       = '&1'
            it_sel            = lt_sel
            i_readmode        = lv_readmode
          IMPORTING
            et_data           = et_&1
        ).
      ENDIF.
    END-OF-DEFINITION.



    __read bscdattxt.
    __read classasgn.
    __read intcmnt.
    __read marapurch.
    __read maraqtmng.
    __read marasales.
    __read maraspm.
    __read marastor.
    __read marcatp.
    __read marcbasic.
    __read marccstng.
    __read marcfrcst.
    __read marcfrgtr.
    __read marcfrpar.
    __read marcmrpfc.
    __read marcmrpls.
    __read marcmrpmi.
    __read marcmrppp.
    __read marcmrpsp.
    __read marcprt.
    __read marcpurch.
    __read marcqtmng.
    __read marcsales.
    __read marcstore.
    __read marcwrksd.
    __read mardmrp.
    __read mardstor.
    __read mbewactng.
    __read mbewcstng.
    __read mbewmlac.
    __read mbewmlval.
    __read mbewvalua.
    __read mdmabasic.
    __read mean_gtin.
    __read mlanpurch.
    __read mlansales.
    __read mlgnstor.
    __read mlgtstor.
    __read mpgdprodg.
    __read mrptxt.
    __read mvkegrpng.
    __read mvkesales.
    __read purchtxt.
    __read qinsptxt.
    __read qmatbasic.
    __read salestxt.
    __read unitofmsr.
    __read valuation.



    IF gv_debug_mode EQ abap_true.
      BREAK-POINT.
    ENDIF.
  ENDMETHOD.
ENDCLASS.

SAP의 가이드 문서 예제에는 Govenence API 를 사용했는데,

FPM UI에서 주로 사용하는 Convenience API 로 만들어 보았습니다.

 

코드:

 

FUNCTION ZMDP_CREATE_CR_SUPPL1P1.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  EXPORTING
*"     REFERENCE(EV_CR) TYPE  USMD_CREQUEST
*"     REFERENCE(EV_ERROR) TYPE  FLAG
*"     REFERENCE(ET_MESSAGE) TYPE  BAPIRET2_TAB
*"----------------------------------------------------------------------
  DATA: lo_mdg_api         TYPE REF TO if_usmd_conv_som_gov_api,
        lt_entity_data     TYPE usmd_gov_api_ts_ent_data,
        ls_entity_data     TYPE usmd_gov_api_s_ent_data,
        lo_cx_usmd_gov_api TYPE REF TO cx_usmd_gov_api,
        ls_message         TYPE bapiret2,
        lv_key_bp_header   TYPE /mdgbp/_s_bp_pp_bp_header-bp_header,
        lv_key_assgnm_id   TYPE /mdgbpx/_s_bp_pp_bp_mlt_as-assgnm_id,
        lv_key_addrno      TYPE /mdgbp/_s_bp_pp_bp_addr-addrno,
        lt_key_bp_header   TYPE TABLE OF /mdgbp/_s_bp_ky_bp_header,
        ls_key_bp_header   TYPE /mdgbp/_s_bp_ky_bp_header,
        lt_key_addrno      TYPE TABLE OF /mdgbp/_s_bp_ky_addrno,
        ls_key_addrno      TYPE /mdgbp/_s_bp_ky_addrno,
        lt_bp_header       TYPE TABLE OF /mdgbp/_s_bp_pp_bp_header,
        ls_bp_header       TYPE /mdgbp/_s_bp_pp_bp_header,
        lt_bp_role         TYPE TABLE OF /mdgbp/_s_bp_pp_bp_role,
        ls_bp_role         TYPE /mdgbp/_s_bp_pp_bp_role,
        lt_bp_mlt_as       TYPE TABLE OF /mdgbpx/_s_bp_pp_bp_mlt_as,
        ls_bp_mlt_as       TYPE /mdgbpx/_s_bp_pp_bp_mlt_as,
        lt_bp_centrl       TYPE TABLE OF /mdgbp/_s_bp_pp_bp_centrl,
        ls_bp_centrl       TYPE /mdgbp/_s_bp_pp_bp_centrl,
        lt_bp_vengen       TYPE TABLE OF /mdgbpx/_s_bp_pp_bp_vengen,
        ls_bp_vengen       TYPE /mdgbpx/_s_bp_pp_bp_vengen,
        lt_bp_porg         TYPE TABLE OF /mdgbpx/_s_bp_pp_bp_porg,
        ls_bp_porg         TYPE /mdgbpx/_s_bp_pp_bp_porg,
        lt_bp_mlt_ad       TYPE TABLE OF /mdgbpx/_s_bp_pp_bp_mlt_ad,
        ls_bp_mlt_ad       TYPE /mdgbpx/_s_bp_pp_bp_mlt_ad,
        lt_address         TYPE TABLE OF /mdgbp/_s_bp_pp_address,
        ls_address         TYPE /mdgbp/_s_bp_pp_address,
        lt_bp_addr         TYPE TABLE OF /mdgbp/_s_bp_pp_bp_addr,
        ls_bp_addr         TYPE /mdgbp/_s_bp_pp_bp_addr,
        lt_bp_addusg       TYPE TABLE OF /mdgbp/_s_bp_pp_bp_addusg,
        ls_bp_addusg       TYPE /mdgbp/_s_bp_pp_bp_addusg,
        lt_ad_name_o       TYPE TABLE OF /mdgbp/_s_bp_pp_ad_name_o,
        ls_ad_name_o       TYPE /mdgbp/_s_bp_pp_ad_name_o,
        lt_ad_postal       TYPE TABLE OF /mdgbp/_s_bp_pp_ad_postal,
        ls_ad_postal       TYPE /mdgbp/_s_bp_pp_ad_postal,
        lt_ad_tel          TYPE TABLE OF /mdgbp/_s_bp_pp_ad_tel,
        ls_ad_tel          TYPE /mdgbp/_s_bp_pp_ad_tel,
        lt_ad_fax          TYPE TABLE OF /mdgbp/_s_bp_pp_ad_fax,
        ls_ad_fax          TYPE /mdgbp/_s_bp_pp_ad_fax,
        lt_ad_url          TYPE TABLE OF /mdgbp/_s_bp_pp_ad_url,
        ls_ad_url          TYPE /mdgbp/_s_bp_pp_ad_url,
        lv_index           TYPE i.

  CLEAR: ev_cr, ev_error, et_message.

  TRY.
********************************************************************************************
* 초기화.
********************************************************************************************
      cl_usmd_conv_som_gov_api=>get_instance(
        EXPORTING
          iv_model_name = 'BP'
        RECEIVING
          ro_so_gov_api = lo_mdg_api
      ).

      lo_mdg_api->refresh_buffers( ).
      lo_mdg_api->set_environment(
        EXPORTING
          iv_crequest_type   = 'SUPPL1P1'
          iv_process         = 'SUP1'
          iv_create_crequest = abap_true
      ).
      lo_mdg_api->set_crequest_attributes(
        EXPORTING
          iv_crequest_text   = |공급업체 생성 { sy-datum }|
      ).
      lo_mdg_api->enqueue_crequest( iv_lock_mode = 'E' ).




********************************************************************************************
* BP_HEADER
********************************************************************************************
      lo_mdg_api->create_entity_tmp_key(
        EXPORTING
          iv_entity = 'BP_HEADER'
        IMPORTING
          es_key    = ls_key_bp_header
      ).
      lv_key_bp_header = ls_key_bp_header-bp_header.

      CLEAR: ls_bp_header.
      ls_bp_header-bp_header = lv_key_bp_header.
      ls_bp_header-bp_guid = cl_system_uuid=>create_uuid_x16_static( ).
      ls_bp_header-bu_group = '0001'.
      ls_bp_header-bu_type = '2'.
      ls_bp_header-txtlg = 'test'.
      INSERT ls_bp_header INTO TABLE lt_bp_header.

      PERFORM write_entity USING lo_mdg_api 'BP_HEADER' lt_bp_header.

********************************************************************************************
* BP_ROLE
********************************************************************************************
      CLEAR: ls_bp_role.
      ls_bp_role-bp_header = lv_key_bp_header.
      ls_bp_role-bp_rol_id = 'FLVN01'.
      INSERT ls_bp_role INTO TABLE lt_bp_role.

      PERFORM write_entity USING lo_mdg_api 'BP_ROLE' lt_bp_role.

********************************************************************************************
* BP_MLT_AS
********************************************************************************************
      lv_key_assgnm_id = 1.
      CLEAR: ls_bp_mlt_as.
      ls_bp_mlt_as-bp_header = lv_key_bp_header.
      ls_bp_mlt_as-assgnm_id = lv_key_assgnm_id.
      ls_bp_mlt_as-as_type = 'SUPPL'.
      ls_bp_mlt_as-object_id = lv_key_bp_header.
      ls_bp_mlt_as-standard = abap_true.
      INSERT ls_bp_mlt_as INTO TABLE lt_bp_mlt_as.

      PERFORM write_entity USING lo_mdg_api 'BP_MLT_AS' lt_bp_mlt_as.

*********************************************************************************************
* ADDRNO
*********************************************************************************************
      lo_mdg_api->create_entity_tmp_key(
        EXPORTING
          iv_entity = 'ADDRNO'
        IMPORTING
          es_key    = ls_key_addrno
      ).
      lv_key_addrno = ls_key_addrno-addrno.

      INSERT ls_key_addrno INTO TABLE lt_key_addrno.

      PERFORM write_entity USING lo_mdg_api 'ADDRNO' lt_key_addrno.

*********************************************************************************************
* BP_MLT_AD
*********************************************************************************************
      CLEAR: ls_bp_mlt_ad.
      ls_bp_mlt_ad-addrno = 'XXDEFAULT'.
      ls_bp_mlt_ad-assgnm_id = lv_key_assgnm_id.
      ls_bp_mlt_ad-bp_header = lv_key_bp_header.
      INSERT ls_bp_mlt_ad INTO TABLE lt_bp_mlt_ad.

      PERFORM write_entity USING lo_mdg_api 'BP_MLT_AD' lt_bp_mlt_ad.

*********************************************************************************************
* ADDRESS
*********************************************************************************************
      CLEAR: ls_address.
      ls_address-bp_header = lv_key_bp_header.
      ls_address-addrno = lv_key_addrno.
      ls_address-type = 1.
      INSERT ls_address INTO TABLE lt_address.

      PERFORM write_entity USING lo_mdg_api 'ADDRESS' lt_address.

*********************************************************************************************
* BP_ADDR
*********************************************************************************************
      CLEAR: ls_bp_addr.
      ls_bp_addr-bp_header = lv_key_bp_header.
      ls_bp_addr-addrno = lv_key_addrno.
      ls_bp_addr-addr_guid = cl_system_uuid=>create_uuid_x16_static( ).
      INSERT ls_bp_addr INTO TABLE lt_bp_addr.

      PERFORM write_entity USING lo_mdg_api 'BP_ADDR' lt_bp_addr.

*********************************************************************************************
* BP_ADDUSG
*********************************************************************************************
      CLEAR: ls_bp_addusg.
      ls_bp_addusg-bp_header = lv_key_bp_header.
      ls_bp_addusg-addrno = lv_key_addrno.
      ls_bp_addusg-bp_adrknd = 'XXDEFAULT'.
      INSERT ls_bp_addusg INTO TABLE lt_bp_addusg.

      PERFORM write_entity USING lo_mdg_api 'BP_ADDUSG' lt_bp_addusg.

*********************************************************************************************
* AD_POSTAL
*********************************************************************************************
      CLEAR: ls_ad_postal.
      ls_ad_postal-bp_header = lv_key_bp_header.
      ls_ad_postal-addrno = lv_key_addrno.
      ls_ad_postal-ref_posta = 'KR'.
      ls_ad_postal-langu_com = '3'.
      ls_ad_postal-post_cod1 = '12345'.
      ls_ad_postal-city1 = '주소1'.
      ls_ad_postal-street = '주소2'.
      INSERT ls_ad_postal INTO TABLE lt_ad_postal.

      PERFORM write_entity USING lo_mdg_api 'AD_POSTAL' lt_ad_postal.

*AD_URL 인터넷 주소
*AD_TEL 전화번호
*AD_FAX 팩스번호
*AD_EMAIL 전자메일 주소

********************************************************************************************
* BP_CENTRL
********************************************************************************************
      CLEAR: ls_bp_centrl.
      ls_bp_centrl-bp_header = lv_key_bp_header.
*      ls_bp_centrl-bpkind = 'P001'.
*      ls_bp_centrl-title_bp = '0003'.
      ls_bp_centrl-name_org1 = 'test'.
      INSERT ls_bp_centrl INTO TABLE lt_bp_centrl.

      PERFORM write_entity USING lo_mdg_api 'BP_CENTRL' lt_bp_centrl.

********************************************************************************************
* BP_VENGEN
********************************************************************************************
      CLEAR: ls_bp_vengen.
      ls_bp_vengen-assgnm_id = lv_key_assgnm_id.
      ls_bp_vengen-bp_header = lv_key_bp_header.
      ls_bp_vengen-lifnr = lv_key_bp_header.
      ls_bp_vengen-ktokk = 'A000'.
      INSERT ls_bp_vengen INTO TABLE lt_bp_vengen.

      PERFORM write_entity USING lo_mdg_api 'BP_VENGEN' lt_bp_vengen.

**********************************************************************
*BP_PORG
**********************************************************************
      CLEAR: ls_bp_porg.
      ls_bp_porg-assgnm_id = lv_key_assgnm_id.
      ls_bp_porg-bp_header = lv_key_bp_header.
      ls_bp_porg-prch_org = '1100'.
      INSERT ls_bp_porg INTO TABLE lt_bp_porg.

      CLEAR: ls_bp_porg.
      ls_bp_porg-assgnm_id = lv_key_assgnm_id.
      ls_bp_porg-bp_header = lv_key_bp_header.
      ls_bp_porg-prch_org = '1200'.
      INSERT ls_bp_porg INTO TABLE lt_bp_porg.

      PERFORM write_entity USING lo_mdg_api 'BP_PORG' lt_bp_porg.



*VENGENTXT 텍스트(공급업체 일반 데이터)
*BP_VENVAL 공급업체: 특징 값(분류)
*BP_VENSUB 공급업체 하위 범위
*BP_VENDDB 문서 링크에 대한 기본 데이터
*BP_VENCLA 공급업체: 클래스 지정(분류)
*BP_TAXGRP 세금 그룹화(공급업체)
*BP_COMPNY 회사 코드




********************************************************************************************
* 저장.
********************************************************************************************
      lo_mdg_api->confirm_entity_data( ).
      lo_mdg_api->check( ).
      IF lo_mdg_api->mv_successfully_checked EQ abap_true.
        lo_mdg_api->set_action( cl_usmd_crequest_action=>gc_draft_action-submit ).
        lo_mdg_api->save( ).
        ev_cr = lo_mdg_api->mv_crequest_id.
      ENDIF.

    CATCH cx_uuid_error.
    CATCH cx_usmd_gov_api INTO lo_cx_usmd_gov_api.
      ev_error = abap_true.
  ENDTRY.


  PERFORM get_message USING lo_mdg_api et_message.
  lo_mdg_api->dequeue_entity_all( ).
  lo_mdg_api->dequeue_crequest( ).
  lo_mdg_api->refresh_buffers( ).


ENDFUNCTION.

FUNCTION ZMDP_CREATE_CR_SUPPL2P1.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(IV_BP_ID) TYPE  BU_BUSINESSPARTNER
*"  EXPORTING
*"     REFERENCE(EV_CR) TYPE  USMD_CREQUEST
*"     REFERENCE(EV_ERROR) TYPE  FLAG
*"     REFERENCE(ET_MESSAGE) TYPE  BAPIRET2_TAB
*"----------------------------------------------------------------------
  DATA: lo_mdg_api         TYPE REF TO if_usmd_conv_som_gov_api,
        lo_usmd_model      TYPE REF TO if_usmd_model_ext,
        lt_sel             TYPE usmd_ts_sel,
        lo_cx_usmd_gov_api TYPE REF TO cx_usmd_gov_api,
        ls_message         TYPE bapiret2,
        lv_key_bp_header   TYPE /mdgbp/_s_bp_pp_bp_header-bp_header,
        lv_key_assgnm_id   TYPE /mdgbpx/_s_bp_pp_bp_mlt_as-assgnm_id,
        lv_key_addrno      TYPE /mdgbp/_s_bp_pp_bp_addr-addrno,
        lt_key_bp_header   TYPE TABLE OF /mdgbp/_s_bp_ky_bp_header,
        ls_key_bp_header   TYPE /mdgbp/_s_bp_ky_bp_header,
        lt_key_addrno      TYPE TABLE OF /mdgbp/_s_bp_ky_addrno,
        ls_key_addrno      TYPE /mdgbp/_s_bp_ky_addrno,
        lt_bp_header       TYPE TABLE OF /mdgbp/_s_bp_pp_bp_header,
        ls_bp_header       TYPE /mdgbp/_s_bp_pp_bp_header,
        lt_bp_role         TYPE TABLE OF /mdgbp/_s_bp_pp_bp_role,
        ls_bp_role         TYPE /mdgbp/_s_bp_pp_bp_role,
        lt_bp_mlt_as       TYPE TABLE OF /mdgbpx/_s_bp_pp_bp_mlt_as,
        ls_bp_mlt_as       TYPE /mdgbpx/_s_bp_pp_bp_mlt_as,
        lt_bp_centrl       TYPE TABLE OF /mdgbp/_s_bp_pp_bp_centrl,
        ls_bp_centrl       TYPE /mdgbp/_s_bp_pp_bp_centrl,
        lt_bp_vengen       TYPE TABLE OF /mdgbpx/_s_bp_pp_bp_vengen,
        ls_bp_vengen       TYPE /mdgbpx/_s_bp_pp_bp_vengen,
        lt_bp_porg         TYPE TABLE OF /mdgbpx/_s_bp_pp_bp_porg,
        ls_bp_porg         TYPE /mdgbpx/_s_bp_pp_bp_porg,
        lt_bp_mlt_ad       TYPE TABLE OF /mdgbpx/_s_bp_pp_bp_mlt_ad,
        ls_bp_mlt_ad       TYPE /mdgbpx/_s_bp_pp_bp_mlt_ad,
        lt_address         TYPE TABLE OF /mdgbp/_s_bp_pp_address,
        ls_address         TYPE /mdgbp/_s_bp_pp_address,
        lt_bp_addr         TYPE TABLE OF /mdgbp/_s_bp_pp_bp_addr,
        ls_bp_addr         TYPE /mdgbp/_s_bp_pp_bp_addr,
        lt_bp_addusg       TYPE TABLE OF /mdgbp/_s_bp_pp_bp_addusg,
        ls_bp_addusg       TYPE /mdgbp/_s_bp_pp_bp_addusg,
        lt_ad_name_o       TYPE TABLE OF /mdgbp/_s_bp_pp_ad_name_o,
        ls_ad_name_o       TYPE /mdgbp/_s_bp_pp_ad_name_o,
        lt_ad_postal       TYPE TABLE OF /mdgbp/_s_bp_pp_ad_postal,
        ls_ad_postal       TYPE /mdgbp/_s_bp_pp_ad_postal,
        lt_ad_tel          TYPE TABLE OF /mdgbp/_s_bp_pp_ad_tel,
        ls_ad_tel          TYPE /mdgbp/_s_bp_pp_ad_tel,
        lt_ad_fax          TYPE TABLE OF /mdgbp/_s_bp_pp_ad_fax,
        ls_ad_fax          TYPE /mdgbp/_s_bp_pp_ad_fax,
        lt_ad_url          TYPE TABLE OF /mdgbp/_s_bp_pp_ad_url,
        ls_ad_url          TYPE /mdgbp/_s_bp_pp_ad_url,
        lv_index           TYPE i.

  CLEAR: ev_cr, ev_error, et_message.

  TRY.
********************************************************************************************
* 초기화.
********************************************************************************************
      cl_usmd_conv_som_gov_api=>get_instance(
        EXPORTING
          iv_model_name = 'BP'
        RECEIVING
          ro_so_gov_api = lo_mdg_api
      ).
      cl_usmd_model_ext=>get_instance(
        EXPORTING
          i_usmd_model = 'BP'
        IMPORTING
          eo_instance  = lo_usmd_model
      ).
      lv_key_bp_header = iv_bp_id.
      lt_sel = VALUE #( ( fieldname = 'BP_HEADER' sign = 'I' option = 'EQ' low = lv_key_bp_header ) ).

********************************************************************************************
* BP_HEADER
********************************************************************************************
      PERFORM read_entity USING lo_usmd_model 'BP_HEADER' lt_sel lt_bp_header.
      IF lt_bp_header IS INITIAL.
        " IV_BP_ID 에 해당하는 BP가 없음. 에러 처리.
        ev_error = abap_true.
        RETURN.
      ENDIF.

********************************************************************************************
* BP_MLT_AS
********************************************************************************************
      PERFORM read_entity USING lo_usmd_model 'BP_MLT_AS' lt_sel lt_bp_mlt_as.
      READ TABLE lt_bp_mlt_as INTO ls_bp_mlt_as WITH KEY as_type = 'SUPPL'.
      IF sy-subrc EQ 0.
        lv_key_assgnm_id = ls_bp_mlt_as-assgnm_id.
      ELSE.
        " C/V 유형 다름. 에러 처리.
        ev_error = abap_true.
        RETURN.
      ENDIF.


********************************************************************************************
* CR 생성
********************************************************************************************
      lo_mdg_api->refresh_buffers( ).
      lo_mdg_api->set_environment(
        EXPORTING
          iv_crequest_type   = 'SUPPL2P1'
          iv_process         = 'SUP2'
          iv_create_crequest = abap_true
      ).
      lo_mdg_api->set_crequest_attributes(
        EXPORTING
          iv_crequest_text   = |공급업체 변경 { sy-datum }|
      ).
      lo_mdg_api->enqueue_crequest( iv_lock_mode = 'E' ).

      ls_key_bp_header-bp_header = lv_key_bp_header.
      APPEND ls_key_bp_header TO lt_key_bp_header.
      lo_mdg_api->enqueue_entity( VALUE #( ( entity = 'BP_HEADER' tabl = REF #( lt_key_bp_header ) ) ) ).

********************************************************************************************
* BP_ROLE
********************************************************************************************
      PERFORM read_entity USING lo_usmd_model 'BP_ROLE' lt_sel lt_bp_role.
      PERFORM write_entity USING lo_mdg_api 'BP_ROLE' lt_bp_role.

*********************************************************************************************
* BP_ADDR
*********************************************************************************************

      PERFORM read_entity USING lo_usmd_model 'BP_ADDR' lt_sel lt_bp_addr.
      IF lt_bp_addr IS NOT INITIAL.
        READ TABLE lt_bp_addr INTO ls_bp_addr INDEX 1.
        lv_key_addrno = ls_bp_addr-addrno.
        ls_key_addrno-addrno = lv_key_addrno.
        INSERT ls_key_addrno INTO TABLE lt_key_addrno.
      ELSE.
        " 기존에 주소가 없는 경우.
        lo_mdg_api->create_entity_tmp_key(
          EXPORTING
            iv_entity = 'ADDRNO'
          IMPORTING
            es_key    = ls_key_addrno
        ).
        lv_key_addrno = ls_key_addrno-addrno.
        INSERT ls_key_addrno INTO TABLE lt_key_addrno.
        PERFORM write_entity USING lo_mdg_api 'ADDRNO' lt_key_addrno.

        CLEAR: ls_bp_addr.
        ls_bp_addr-bp_header = lv_key_bp_header.
        ls_bp_addr-addrno = lv_key_addrno.
        ls_bp_addr-addr_guid = cl_system_uuid=>create_uuid_x16_static( ).
        INSERT ls_bp_addr INTO TABLE lt_bp_addr.
        PERFORM write_entity USING lo_mdg_api 'BP_ADDR' lt_bp_addr.

        CLEAR: ls_bp_addusg.
        ls_bp_addusg-bp_header = lv_key_bp_header.
        ls_bp_addusg-addrno = lv_key_addrno.
        ls_bp_addusg-bp_adrknd = 'XXDEFAULT'.
        INSERT ls_bp_addusg INTO TABLE lt_bp_addusg.
        PERFORM write_entity USING lo_mdg_api 'BP_ADDUSG' lt_bp_addusg.

        CLEAR: ls_address.
        ls_address-bp_header = lv_key_bp_header.
        ls_address-addrno = lv_key_addrno.
        ls_address-type = 1.
        INSERT ls_address INTO TABLE lt_address.
        PERFORM write_entity USING lo_mdg_api 'ADDRESS' lt_address.

      ENDIF.

*********************************************************************************************
* BP_MLT_AD
*********************************************************************************************
      PERFORM read_entity USING lo_usmd_model 'BP_MLT_AD' lt_sel lt_bp_mlt_ad.
      PERFORM write_entity USING lo_mdg_api 'BP_MLT_AD' lt_bp_mlt_ad.

*********************************************************************************************
* AD_POSTAL
*********************************************************************************************
      PERFORM read_entity USING lo_usmd_model 'AD_POSTAL' lt_sel lt_ad_postal.
      LOOP AT lt_ad_postal INTO ls_ad_postal.
        ls_ad_postal-ref_posta = 'KR'.
        MODIFY lt_ad_postal FROM ls_ad_postal.
      ENDLOOP.
      PERFORM write_entity USING lo_mdg_api 'AD_POSTAL' lt_ad_postal.

*AD_URL 인터넷 주소
*AD_TEL 전화번호
*AD_FAX 팩스번호
*AD_EMAIL 전자메일 주소

********************************************************************************************
* BP_CENTRL
********************************************************************************************
      PERFORM read_entity USING lo_usmd_model 'BP_CENTRL' lt_sel lt_bp_centrl.
      PERFORM write_entity USING lo_mdg_api 'BP_CENTRL' lt_bp_centrl.

********************************************************************************************
* BP_VENGEN
********************************************************************************************
      PERFORM read_entity USING lo_usmd_model 'BP_VENGEN' lt_sel lt_bp_vengen.
      PERFORM write_entity USING lo_mdg_api 'BP_VENGEN' lt_bp_vengen.

**********************************************************************
*BP_PORG
**********************************************************************
      PERFORM read_entity USING lo_usmd_model 'BP_PORG' lt_sel lt_bp_porg.
      PERFORM write_entity USING lo_mdg_api 'BP_PORG' lt_bp_porg.



*VENGENTXT 텍스트(공급업체 일반 데이터)
*BP_VENVAL 공급업체: 특징 값(분류)
*BP_VENSUB 공급업체 하위 범위
*BP_VENDDB 문서 링크에 대한 기본 데이터
*BP_VENCLA 공급업체: 클래스 지정(분류)
*BP_TAXGRP 세금 그룹화(공급업체)
*BP_COMPNY 회사 코드




********************************************************************************************
* 저장.
********************************************************************************************
      lo_mdg_api->confirm_entity_data( ).
      lo_mdg_api->check( ).
      IF lo_mdg_api->mv_successfully_checked EQ abap_true.
        lo_mdg_api->set_action( cl_usmd_crequest_action=>gc_draft_action-submit ).
        lo_mdg_api->save( ).
        ev_cr = lo_mdg_api->mv_crequest_id.
      ENDIF.

    CATCH cx_uuid_error.
    CATCH cx_usmd_gov_api INTO lo_cx_usmd_gov_api.
      ev_error = abap_true.
  ENDTRY.


  PERFORM get_message USING lo_mdg_api et_message.
  lo_mdg_api->dequeue_entity_all( ).
  lo_mdg_api->dequeue_crequest( ).
  lo_mdg_api->refresh_buffers( ).


ENDFUNCTION.


FUNCTION zmdp_conv_usmdmsg_to_bapiret2.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(IS_USMDMSG) TYPE  USMD_S_MESSAGE
*"  EXPORTING
*"     REFERENCE(ES_BAPIRET2) TYPE  BAPIRET2
*"----------------------------------------------------------------------
  CLEAR: es_bapiret2.

  MESSAGE ID is_usmdmsg-msgid TYPE is_usmdmsg-msgty NUMBER is_usmdmsg-msgno
    WITH is_usmdmsg-msgv1 is_usmdmsg-msgv2 is_usmdmsg-msgv3 is_usmdmsg-msgv4
    INTO es_bapiret2-message.


  es_bapiret2-type = sy-msgty.
  es_bapiret2-id = sy-msgid.
  es_bapiret2-number = sy-msgno.
  es_bapiret2-message_v1 = sy-msgv1.
  es_bapiret2-message_v2 = sy-msgv2.
  es_bapiret2-message_v3 = sy-msgv3.
  es_bapiret2-message_v4 = sy-msgv4.
  es_bapiret2-row = is_usmdmsg-row.
  es_bapiret2-field = is_usmdmsg-fieldname.

ENDFUNCTION.



FORM write_entity USING io_mdg_api iv_entity it_data.
  DATA: lo_mdg_api     TYPE REF TO if_usmd_conv_som_gov_api,
        lt_entity_data TYPE usmd_gov_api_ts_ent_data,
        ls_entity_data TYPE usmd_gov_api_s_ent_data.

  lo_mdg_api = io_mdg_api.

  CLEAR: lt_entity_data, ls_entity_data.
  ls_entity_data-entity = iv_entity.
  ls_entity_data-entity_data = REF #( it_data ).
  APPEND ls_entity_data TO lt_entity_data.

  lo_mdg_api->write_entity_data( it_entity_data = lt_entity_data ).
ENDFORM.
FORM read_entity USING io_usmd_model iv_entity it_sel et_data.
  DATA: lo_usmd_model  TYPE REF TO if_usmd_model_ext.

  lo_usmd_model = io_usmd_model.
  lo_usmd_model->read_char_value(
    EXPORTING
      i_fieldname       = iv_entity
      it_sel            = it_sel
      if_no_flush       = abap_true
    IMPORTING
      et_data           = et_data
  ).
ENDFORM.
FORM get_message USING io_mdg_api TYPE REF TO if_usmd_conv_som_gov_api
                       et_message TYPE bapiret2_tab.
  DATA: lt_usmd_msg TYPE usmd_t_message,
        ls_usmd_msg TYPE usmd_s_message,
        ls_bapiret2 TYPE bapiret2.

  lt_usmd_msg = io_mdg_api->get_messages( ).

  LOOP AT lt_usmd_msg INTO ls_usmd_msg.
    IF ls_usmd_msg-msgid EQ 'MDG_BS_BP' AND ls_usmd_msg-msgno EQ '057'.
      " 필요 없는 메시지.
      CONTINUE.
    ENDIF.
    CALL FUNCTION 'ZMDP_CONV_USMDMSG_TO_BAPIRET2'
      EXPORTING
        is_usmdmsg  = ls_usmd_msg
      IMPORTING
        es_bapiret2 = ls_bapiret2.
    APPEND ls_bapiret2 TO et_message.
  ENDLOOP.

ENDFORM.

'ABAP > MDG 기준정보' 카테고리의 다른 글

MDG staging table 가비지 데이터 삭제 처리 프로그램  (0) 2023.06.15
ZCL_MDP_READ_HELPER  (0) 2021.12.15

+ Recent posts