본문 바로가기
Fiori/Odata

OData (create_deep_entity)

by clode 2023. 2. 21.
728x90
반응형
  METHOD /iwbep/if_mgw_appl_srv_runtime~create_deep_entity.

    DATA lv_entityset_name TYPE string.
    DATA: BEGIN OF str_exp.
            INCLUDE  TYPE zcl_ztest3gw_so_mpc_ext=>ts_soheader.
    DATA:   navi_so_item TYPE  zcl_ztest3gw_so_mpc_ext=>tt_soitem.
    DATA:    END OF str_exp.

    DATA: ls_deep LIKE str_exp,
          ls_item TYPE zcl_ztest3gw_so_mpc=>ts_soitem.
    DATA: ls_head TYPE vbak,
          it_item TYPE TABLE OF vbap.

    lv_entityset_name = io_tech_request_context->get_entity_set_name( ).

    CASE lv_entityset_name.
      WHEN 'POheaderSet'.
        io_data_provider->read_entry_data( IMPORTING es_data = ls_deep ).
        ls_head-vbeln = ls_deep-vbeln.
*        ls_head-carrname = ls_deep-carrname.
*        ls_head-currcode = ls_deep-currcode.
*        ls_head-url = ls_deep-url.
        LOOP AT ls_deep-navi_so_item INTO ls_item.
          APPEND ls_item TO it_item.
        ENDLOOP.
        INSERT vbak FROM ls_head.
        IF sy-subrc EQ 0.
          INSERT vbap FROM TABLE it_item.
          IF sy-subrc EQ 0.
            copy_data_to_ref( EXPORTING is_data = ls_deep
                                       CHANGING  cr_data = er_deep_entity ).
          ENDIF.
        ENDIF.

    ENDCASE.

  ENDMETHOD.
728x90
반응형

'Fiori > Odata' 카테고리의 다른 글

Create Odata  (0) 2023.02.24
OData (get_expanded_entityset)  (0) 2023.02.21

댓글