Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use ABAP code to create Sales Order in S/4HANA

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces how to use ABAP code to create Sales Order in S/4HANA. The introduction in this article is very detailed and has certain reference value. Interested friends must read it!

Below is a screenshot of S/4HANA's Sales Order created using ABAP code:

The values in red are hardcoded in my code, and blue are created by the SD_SALESDEVICE_CREATE function itself.

Take a look at the code:

DATA: ls_header TYPE bapisdhd1,ls_headerx TYPE bapisdhd1x,lt_bapiret2 LIKE bapiret2 OCCURS 0 WITH HEADER LINE,po_order_number TYPE bapivbeln-vbeln,lt_partners TYPE TABLE OF bapiparnr,ls_partners LIKE LINE OF lt_partners.ls_header-serv_date = '20200101'.ls_header-doc_type = 'TA'. "Type of sales order ls_header-comp_cde_b = '0001'. "Company Code ls_headerx-comp_cde_b ='X '.ls_headerx-doc_type ='X'.ls_headerx-updateflag ='I '. "Specify modification mode as I-create ls_partners-part_role ='WE '. "ship to partyls_partners-partn_numb = '0000000001'. "This customer master must exist in database table KNA1 APPEND ls_partners TO lt_partners.ls_partners-partn_role ='AG '. " sold to partyls_partners-partn_numb = '0000000001'.APPEND ls_partners TO lt_partners. "Call BAPI: CALL FUNCTION 'SD_SALESDEVICE_CREATE'EXPORTINGsales_header_in = ls_headersales_header_inx = ls_headerxint_number_assignment = 'X'IMPORTINGsalesdocument_ex = po_order_numberTABLESreturn = lt_bapiret2sales_partners = lt_partners.LOOP AT lt_bapiret2 ASSIGNING FIELD-SYMBOL() WHERE type = 'E'.WRITE:/ 'Error:', -message COLOR COL_NEGATIVE.RETURN.ENDLOOP.IF po_order_number IS INITIAL.WRITE:/ 'PO number initial'.RETURN.ENDIF.CLEAR: lt_bapiret2.CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'EXPORTINGwait = 'X'IMPORTINGreturn = lt_bapiret2.

That's all for the article "How to create Sales Order in S/4HANA using ABAP code." Thank you for reading! Hope to share the content to help everyone, more relevant knowledge, welcome to pay attention to the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report