FUNCTION ZPR2. DATA GS_HEADER TYPE BAPIMEREQHEADER. "ME51N采购申请凭证抬头 DATA GS_HEADERX TYPE BAPIMEREQHEADERX. GS_HEADER-PR_TYPE = 'NB'. GS_HEADERX-PR_TYPE = 'X'."采购凭证类型 DATA GT_ITEM TYPE TABLE OF BAPIMEREQITEMIMP."ME51N采购申请单行项目 DATA GT_ITEMX TYPE TABLE OF BAPIMEREQITEMX. DATA GS_ITEM TYPE BAPIMEREQITEMIMP. DATA GS_ITEMX TYPE BAPIMEREQITEMX. DATA I TYPE I VALUE 0. WHILE I <= 10. CLEAR GS_ITEM. GS_ITEM-MATERIAL = 'A01'. "物料号 GS_ITEM-PLANT = '8010'. "工厂 GS_ITEM-QUANTITY = '10'. "采购数量 APPEND GS_ITEM TO GT_ITEM. CLEAR GS_ITEMX. GS_ITEMX-MATERIAL = 'X'. "物料号 GS_ITEMX-PLANT = 'X'. "工厂 GS_ITEMX-QUANTITY = 'X'. "采购数量 APPEND GS_ITEMX TO GT_ITEMX. I = I + 1. ENDWHILE. CALL FUNCTION 'BAPI_PR_CREATE' "BAPI ==>创建采购申请单 EXPORTING PRHEADER = GS_HEADER PRHEADERX = GS_HEADERX IMPORTING NUMBER = R_NUMBER "BAPI执行成功返回:采购申请单 如 1000032 TABLES PRITEM = GT_ITEM "行项目 PRITEMX = GT_ITEMX. IF SY-SUBRC = 0 AND R_NUMBER IS NOT INITIAL. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING WAIT = 'X'. COMMIT WORK AND WAIT. ENDIF. ENDFUNCTION.
标签:PR,BAPI,GS,申请单,DATA,TYPE From: https://www.cnblogs.com/hua900822/p/17381939.html