cancel
Showing results for 
Search instead for 
Did you mean: 

An exception was raised when create Purchase Order with EML

Neil_Lee_057
Explorer
0 Kudos

Dear Experts,

I tried to create Purchase Order by EML, and it work as below code.

DATA: purchase_orders      TYPE TABLE FOR CREATE i_purchaseordertp_2,
purchase_order LIKE LINE OF purchase_orders,
purchase_order_items TYPE TABLE FOR CREATE i_purchaseordertp_2\_purchaseorderitem,
purchase_order_item LIKE LINE OF purchase_order_items.
DATA(n1) = 0.
DATA(n2) = 0.
* DO 2 TIMES.
n1 += 1.
purchase_order = VALUE #( %cid = |My%CID_{ n1 }|
purchaseordertype = 'NB'
companycode = '2000'
purchasingorganization = '2000'
purchasinggroup = '001'
supplier = '0000100003'
%control = VALUE #(
purchaseordertype = cl_abap_behv=>flag_changed
companycode = cl_abap_behv=>flag_changed
purchasingorganization = cl_abap_behv=>flag_changed
purchasinggroup = cl_abap_behv=>flag_changed
supplier = cl_abap_behv=>flag_changed
) ).
APPEND purchase_order TO purchase_orders.
n2 += 1.
"Purchase Order Item Data 1
purchase_order_item = VALUE #( %cid_ref = |My%CID_{ n1 }|
%target = VALUE #( ( %cid = |My%CID_ITEM{ n2 }|
material = '000000000000010004'
plant = '2001'
orderquantity = '5'
purchaseorderitem = '00010'
netpriceamount = '5'
%control = VALUE #( material = cl_abap_behv=>flag_changed
plant = cl_abap_behv=>flag_changed
orderquantity = cl_abap_behv=>flag_changed
purchaseorderitem = cl_abap_behv=>flag_changed
netpriceamount = cl_abap_behv=>flag_changed
) ) ) ).
APPEND purchase_order_item TO purchase_order_items.
* ENDDO.
"Purchase Order Header Data
MODIFY ENTITIES OF i_purchaseordertp_2
ENTITY purchaseorder
CREATE FROM purchase_orders
CREATE BY \_purchaseorderitem
FROM purchase_order_items
MAPPED DATA(mapped_po_headers)
REPORTED DATA(reported_po_headers)
FAILED DATA(failed_po_headers).
LOOP AT reported_po_headers-purchaseorderitem ASSIGNING FIELD-SYMBOL(<ls_so_reported_1>).
DATA(lv_result1) = <ls_so_reported_1>-%msg->if_message~get_text( ).
out->write( 'Item' ).
out->write( lv_result1 ).
ENDLOOP.
LOOP AT reported_po_headers-purchaseorder ASSIGNING FIELD-SYMBOL(<ls_so_reported_2>).
DATA(lv_result2) = <ls_so_reported_2>-%msg->if_message~get_text( ).
out->write( 'Order' ).
out->write( lv_result2 ).
ENDLOOP.
COMMIT ENTITIES BEGIN
RESPONSE OF i_purchaseordertp_2
FAILED DATA(lt_commit_failed)
REPORTED DATA(lt_commit_reported).
LOOP AT mapped_po_headers-purchaseorder ASSIGNING FIELD-SYMBOL(<fs_so_mapped>).
CONVERT KEY OF I_PurchaseOrderTP_2 FROM <fs_so_mapped>-%pid TO DATA(ls_so_key).
out->write( 'Purchase Order:' && ls_so_key-PurchaseOrder ).
ENDLOOP.
COMMIT ENTITIES END.
ENDMETHOD.

but if I add "do 2 times" to want create 2 Purchase Order at same time.

"An Exception happen" without no more detailed description that I got.

How can I do to fixed this issue.

Thank you in advance for your help.

View Entire Topic
duckys
Explorer
0 Kudos

Hi Neil, have you solved this error yet? If yes, can you share me some details. Thank you.