这篇文章主要介绍如何使用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进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。