这篇文章主要介绍如何使用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 partyls_partners-partn_numb = '0000000001'. ”这个客户主数据在数据库表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.“调用BAPI:CALL FUNCTION 'SD_SALESDOCUMENT_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(<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”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注编程网行业资讯频道!