How to populate the quantity field of S/4HANA sales order line items with code
This article is about how to use the code to fill in the quantity field of S/4HANA sales order line items, the editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article.
My task is to generate the line items of the S/4HANA sales order (Sales Order) with code and populate the corresponding quantity (quantity) value.
At first, I used the following code to write the value of quantity into the item field target_qty:
Ls_order_items_in-item_categ = 'TAN'.ls_order_items_in-material =' REDUCER_A'.ls_order_items_in-target_qty = 999.ls_order_items_in-itm_number = 10.ls_order_item_x-item_categ = 'X'.ls_order_item_x-material =' X'.ls_order_item_x-target_qty = 'X'.ls_order_item_x-itm_number =' X '. Ls_order_item_x-updateflag =' I'.APPEND ls_order_item_x TO lt_order_item_x.APPEND ls_order_items_in TO lt_order_items_in.
Found that it does not work after execution.
After studying a line item that maintains the correct quantity, it is found that the quantity field is actually maintained on the schedule line of item:
And the order quantity that we see on item, which is clearly seen in the F1 help documentation, is a cumulative value, the sum of all the quantity of schedule line.
So the correct code would also be to create a schedule line for item:
Ls_schdlin-itm_number = 10.ls_schdlin-req_qty = 3.ls_schdlinx-itm_number = 'X'.ls_schdlinx-itm_number =' X'.ls_schdlinx-updateflag = 'X'.APPEND ls_schdlin TO lt_schdlin.APPEND ls_schdlinx TO lt_schdlinx.
The complete code is shown in the following figure:
The above is how to use the code to fill in the quantity field of S/4HANA sales order line items, and the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.