CódigoFULL
METHOD OrderProd.
DATA: lt_header TYPE TABLE FOR CREATE zi_indinternasd.
DATA: lt_item TYPE TABLE FOR CREATE zi_indinternasd\_item.
DATA: ls_item LIKE LINE OF lt_item.
DATA lt_target LIKE ls_item-%target.
DATA ls_target LIKE LINE OF lt_target.
DATA(lt_keys) = keys.
DATA(ls_keys) = VALUE #( lt_keys[ 1 ] OPTIONAL ).
CHECK ls_keys IS NOT INITIAL.
TRY.
DATA(lv_id) = cl_system_uuid=>create_uuid_x16_static( ).
CATCH cx_uuid_error.
RETURN.
ENDTRY.
lt_header = VALUE #( ( %is_draft = if_abap_behv=>mk-on
%cid = ls_keys-%cid
Id = lv_id
Opertyp = c_tipo_op-envio
aufnr = ls_keys-%param-aufnr
%control = value #( Aufnr = if_abap_behv=>mk-on
Opertyp = if_abap_behv=>mk-on
)
) ).
DATA: lt_teste TYPE TABLE OF ztsd_ind_item.
lt_teste = VALUE #(
( matnr = '000000000000000009' menge = '10.11' preco = '1.12' )
( matnr = '000000000000000010' menge = '20.22' preco = '2.22' )
( matnr = '000000000000000011' menge = '30.33' preco = '3.15' )
).
LOOP AT lt_teste INTO DATA(ls_teste).
TRY.
DATA(lv_item_id) = cl_system_uuid=>create_uuid_x16_static( ).
CATCH cx_uuid_error.
RETURN.
ENDTRY.
APPEND INITIAL LINE TO lt_target ASSIGNING FIELD-SYMBOL(<lf_target>).
<lf_target> = VALUE #( %cid = lv_item_id
%is_draft = if_abap_behv=>mk-on
Id = lv_id
ItemId = lv_item_id
Matnr = ls_teste-matnr
Menge = ls_teste-menge
Preco = ls_teste-preco
%control = VALUE #( Docnum = if_abap_behv=>mk-off
Itmnum = if_abap_behv=>mk-off
Matnr = if_abap_behv=>mk-on
Meins = if_abap_behv=>mk-on
Preco = if_abap_behv=>mk-on
Menge = if_abap_behv=>mk-on
)
).
ENDLOOP.
APPEND INITIAL LINE TO lt_item ASSIGNING FIELD-SYMBOL(<lt_item>).
<lt_item> = VALUE #( %cid_ref = ls_keys-%cid
Id = lv_id
%is_draft = if_abap_behv=>mk-on
%target = lt_target ).
MODIFY ENTITIES OF zi_indinternasd IN LOCAL MODE
ENTITY Header
CREATE FROM lt_header
CREATE BY \_item FROM lt_item
MAPPED DATA(lt_item_upd)
FAILED data(lt_failed)
REPORTED data(lt_reported).
mapped-header = lt_item_upd-header.
mapped-item = lt_item_upd-item.
ENDMETHOD.
Nenhum comentário:
Postar um comentário