cancel
Showing results for 
Search instead for 
Did you mean: 

RAP unmannaged scenario - Create Sales Order with EML

alvaro-achin
Explorer
0 Kudos

Hello everyone, I'm attempting to create a sales order from a RAP application using an unmanaged scenario with draft functionality. I make the EML to create the sales order call in the 'finalize' method, and the sales order is created successfully. However, I'm unable to retrieve the created order number to store it in a table within the 'save' method.

Success messages are appearing automatically at the end of the process, even without me triggering or sending the message.

This section of the code is where I invoke the EML.

DATA: sales_orders TYPE TABLE FOR CREATE i_salesordertp,

sales_order LIKE LINE OF sales_orders,

sales_order_items TYPE TABLE FOR CREATE i_salesordertp\_item,

sales_order_item LIKE LINE OF sales_order_items.

CHECK NOT gt_header IS INITIAL.

LOOP AT gt_header INTO DATA(ls_header).

sales_order = VALUE #(

%cid = ls_header-header_id

salesordertype = ls_header-doc_type

soldtoparty = ls_header-cust_number

salesorganization = ls_header-sales_org

distributionchannel = ls_header-distr_chan

organizationdivision = ls_header-division

salesoffice = ls_header-sales_off

salesgroup = ls_header-sales_grp

transactioncurrency = ls_header-currency

requesteddeliverydate = ls_header-req_date_h

pricingdate = ls_header-price_date

billingdocumentdate = ls_header-bill_date

customerpurchaseorderdate = ls_header-purch_date

%control = VALUE #(

salesordertype = cl_abap_behv=>flag_changed

soldtoparty = cl_abap_behv=>flag_changed

salesorganization = cl_abap_behv=>flag_changed

distributionchannel = cl_abap_behv=>flag_changed

organizationdivision = cl_abap_behv=>flag_changed

salesoffice = cl_abap_behv=>flag_changed

salesgroup = cl_abap_behv=>flag_changed

transactioncurrency = cl_abap_behv=>flag_changed

requesteddeliverydate = cl_abap_behv=>flag_changed

pricingdate = cl_abap_behv=>flag_changed

billingdocumentdate = cl_abap_behv=>flag_changed

customerpurchaseorderdate = cl_abap_behv=>flag_changed

)

).

APPEND sales_order TO sales_orders.

ENDLOOP.

LOOP AT gt_detail INTO DATA(ls_detail).

sales_order_item = VALUE #(

%cid_ref = ls_detail-header_id

%target = VALUE #( (

%cid = ls_detail-detail_id

product = ls_detail-material

requestedquantity = ls_detail-req_qty

storagelocation = ls_detail-store_loc

plant = ls_detail-plant

%control = VALUE #(

product = cl_abap_behv=>flag_changed

requestedquantity = cl_abap_behv=>flag_changed

storagelocation = cl_abap_behv=>flag_changed

plant = cl_abap_behv=>flag_changed

) ) ) ).

APPEND sales_order_item TO sales_order_items.

ENDLOOP.

MODIFY ENTITIES OF i_salesordertp

ENTITY salesorder

CREATE FROM sales_orders

CREATE BY \_item

FROM sales_order_items

MAPPED DATA(lo_create_mapped)

FAILED DATA(lo_create_failed)

REPORTED DATA(lo_create_reported).

Accepted Solutions (0)

Answers (0)