函数使用二:采购申请BAPI_PR_CREATE详解编程语言

REPORT YTEST01. 
***************************采购申请创建*****************************begin 
DATA:LV_BANFN TYPE EBAN-BANFN . 
DATA:LV_BNFPO TYPE EBAN-BNFPO . 
DATA:GW_PRITEM TYPE BAPIMEREQITEMIMP . 
DATA:GW_PRITEMX TYPE BAPIMEREQITEMX . 
DATA:GT_PRITEM TYPE TABLE OF BAPIMEREQITEMIMP . 
DATA:GT_PRITEMX TYPE TABLE OF BAPIMEREQITEMX . 
DATA:GW_HEAD TYPE BAPIMEREQHEADER  . 
DATA:GW_HEADX TYPE BAPIMEREQHEADERX. 
DATA:GT_BAPIRETURN TYPE TABLE OF BAPIRET2 . 
GW_HEAD-PR_TYPE = '901'."订单类型 
GW_HEADX-PR_TYPE = 'X' . 
LV_BNFPO  = LV_BNFPO  + 10 ."项目号 
GW_PRITEM-PREQ_ITEM = LV_BNFPO . 
GW_PRITEM-PREQ_NAME = SY-UNAME. 
GW_PRITEM-TRACKINGNO = 'TRACKNO'. 
GW_PRITEM-MATERIAL =  '000000000018007349'. 
GW_PRITEM-PLANT    =  '1010'. 
GW_PRITEM-QUANTITY =  10. 
GW_PRITEM-DELIV_DATE = SY-DATUM. 
GW_PRITEM-FIXED = 'X' . 
GW_PRITEM-PUR_GROUP = 'A03'. 
APPEND GW_PRITEM TO GT_PRITEM . 
GW_PRITEMX-PREQ_ITEM = LV_BNFPO . 
GW_PRITEMX-MATERIAL =   'X'. 
GW_PRITEMX-PLANT    =   'X'. 
GW_PRITEMX-QUANTITY =   'X'. 
GW_PRITEMX-DELIV_DATE = 'X'. 
GW_PRITEMX-FIXED = 'X' . 
GW_PRITEMX-PREQ_NAME = 'X'. 
GW_PRITEMX-TRACKINGNO = 'X' . 
IF GW_PRITEM-PUR_GROUP <> '' . 
GW_PRITEMX-PUR_GROUP = 'X'. 
ENDIF . 
APPEND GW_PRITEMX TO GT_PRITEMX . 
CALL FUNCTION 'BAPI_PR_CREATE' 
EXPORTING 
PRHEADER  = GW_HEAD 
PRHEADERX = GW_HEADX 
IMPORTING 
NUMBER    = LV_BANFN 
TABLES 
RETURN    = GT_BAPIRETURN 
PRITEM    = GT_PRITEM 
PRITEMX   = GT_PRITEMX. 
IF LV_BANFN IS NOT INITIAL. 
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' 
EXPORTING 
WAIT = 'X'. 
WRITE:LV_BANFN. 
ELSE. 
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. 
ENDIF. 
***************************采购申请创建*****************************end

 审批:BAPI_REQUISITION_RELEASE

反审:BAPI_REQUISITION_RESET_RELEASE

单号+项目号+批准标识

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/18605.html

(0)
上一篇 2021年7月19日
下一篇 2021年7月19日

相关推荐

发表回复

登录后才能评论