您好,登錄后才能下訂單哦!
這篇文章主要介紹如何使用ABAP代碼創建S/4HANA里的Sales Order,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!
下圖是使用ABAP代碼創建的S/4HANA的Sales Order的截圖:
其中紅色區域的值是我代碼里硬編碼的,而藍色是函數SD_SALESDOCUMENT_CREATE自己創建的。
來看下代碼:
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'. “銷售訂單的類型 ls_header-comp_cde_b = '0001'. ” 公司代碼 ls_headerx-comp_cde_b = 'X'. ls_headerx-doc_type = 'X'. ls_headerx-updateflag = 'I'. “ 指定修改模式為I-創建 ls_partners-partn_role = 'WE'. "ship to party ls_partners-partn_numb = '0000000001'. ”這個客戶主數據在數據庫表KNA1里必須存在 APPEND ls_partners TO lt_partners. ls_partners-partn_role = 'AG'. " sold to party ls_partners-partn_numb = '0000000001'. APPEND ls_partners TO lt_partners. “調用BAPI: CALL FUNCTION 'SD_SALESDOCUMENT_CREATE'EXPORTING sales_header_in = ls_header sales_header_inx = ls_headerx int_number_assignment = 'X'IMPORTING salesdocument_ex = po_order_number TABLESreturn = lt_bapiret2 sales_partners = lt_partners. LOOP AT lt_bapiret2 ASSIGNING FIELD-SYMBOL(<return>) WHERE type = 'E'. WRITE:/ 'Error:', <return>-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.
以上是“如何使用ABAP代碼創建S/4HANA里的Sales Order”這篇文章的所有內容,感謝各位的閱讀!希望分享的內容對大家有幫助,更多相關知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。