赞
踩
资产跨公司代码转移批量过账调用BDC无法检查,而且BDC无法返回生成的凭证编号,所以调用bapi
DATA:ls_GENERALPOSTINGDATA TYPE BAPIFAPO_GEN_INFO,
ls_TRANSFERTODATA TYPE BAPIFAPO_TRANSFER_TO,
ls_TRANSFERPOSTINGDATA TYPE BAPIFAPO_TRANSFER_REV_DISTR,
ls_FURTHERPOSTINGDATA TYPE BAPIFAPO_ADD_INFO,
lt_RETURN_ALL TYPE STANDARD TABLE OF BAPIRET2,
ls_RETURN_ALL TYPE BAPIRET2.
* 往来变式
L_RAIFP1-TRAVA = 'Z001'.
* Intracompany transfer
L_RAIFP1-gsvor = 'UMBU'.
* For intracompany transfer
L_RAIFP1-vorgn = 'UMAI'."UMAI
* 凭证日期
L_RAIFP1-BLDAT = F_BUDAT.
* 过账日期
L_RAIFP1-BUDAT = F_BUDAT.
* 资产日期
L_RAIFP1-BZDAT = F_BUDAT.
* 公司代码
LREC_RAIFP2-BUKRS = f_vbukr.
LREC_RAIFP3-BUKRS = f_vbukr.
* 项目文本
LREC_RAIFP2-SGTXT = '正式转资'.
LOOP AT TAB_out7 INTO REC_out7 WHERE chkbx = 'X'.
L_TABIX = SY-TABIX.
* 货币
IF REC_out7-WAERS IS INITIAL.
L_RAIFP1-WAERS = 'CNY'.
ELSE.
L_RAIFP1-WAERS = REC_out7-WAERS.
ENDIF.
* 以前年度价值
IF NOT REC_out7-ZZJZ2 IS INITIAL.
* ERP upgrade modify for S/4 HANA(Grammar correction)
CLEAR:
ls_GENERALPOSTINGDATA,
ls_TRANSFERTODATA,
ls_TRANSFERPOSTINGDATA,
ls_FURTHERPOSTINGDATA,
lt_RETURN_ALL.
ls_GENERALPOSTINGDATA-DOC_DATE = F_BUDAT. "凭证日期
ls_GENERALPOSTINGDATA-PSTNG_DATE = F_BUDAT. "过账日期
* ls_GENERALPOSTINGDATA-TRANS_DATE = F_BUDAT. "资产价值日期
ls_GENERALPOSTINGDATA-COMP_CODE = F_VBUKR. "公司代码
ls_GENERALPOSTINGDATA-ASSETMAINO = REC_out7-ANLN3. "预转固资产号
ls_GENERALPOSTINGDATA-ASSETSUBNO = REC_out7-ANLN4. "预转固资产子号
ls_TRANSFERPOSTINGDATA-VALUEDATE = F_BUDAT. "资产价值日期
ls_TRANSFERTODATA-PART_COMCO = F_VBUKR. "公司代码
ls_TRANSFERTODATA-PART_ASSET = REC_out7-ANLN1."正式资产号
ls_TRANSFERTODATA-PART_SUBNO = REC_out7-ANLN1."正式资产子号
ls_FURTHERPOSTINGDATA-HEADER_TXT = '正式转资'. "凭证抬头文本
ls_TRANSFERPOSTINGDATA-TRANSVAR = 'Z001'. "往来变式
ls_TRANSFERPOSTINGDATA-AMOUNT = REC_out7-ZZJZ2. "本年度价值
ls_TRANSFERPOSTINGDATA-CURRENCY = L_RAIFP1-WAERS. "货币
ls_TRANSFERPOSTINGDATA-NEW_ACQ_IN = ''.
CALL FUNCTION 'BAPI_ASSET_TRANSFER_CHECK'
EXPORTING
GENERALPOSTINGDATA = ls_GENERALPOSTINGDATA
TRANSFERTODATA = ls_TRANSFERTODATA
TRANSFERPOSTINGDATA = ls_TRANSFERPOSTINGDATA
FURTHERPOSTINGDATA = ls_FURTHERPOSTINGDATA
TABLES
RETURN_ALL = lt_RETURN_ALL.
READ TABLE lt_RETURN_ALL INTO ls_RETURN_ALL WITH KEY TYPE = 'E'.
IF SY-SUBRC <> 0.
CALL FUNCTION 'BAPI_ASSET_TRANSFER_POST'
EXPORTING
GENERALPOSTINGDATA = ls_GENERALPOSTINGDATA
TRANSFERTODATA = ls_TRANSFERTODATA
TRANSFERPOSTINGDATA = ls_TRANSFERPOSTINGDATA
FURTHERPOSTINGDATA = ls_FURTHERPOSTINGDATA
TABLES
RETURN_ALL = lt_RETURN_ALL.
READ TABLE lt_RETURN_ALL INTO ls_RETURN_ALL WITH KEY TYPE = 'S' ID = 'FAA_POST' .
IF SY-SUBRC = 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
WAIT = 'X'.
REC_out7-GDATUM1 = F_BUDAT.
REC_out7-BELNR1 = ls_RETURN_ALL-MESSAGE_V2 .
MOVE-CORRESPONDING REC_out7 TO REC_ZFI0067T.
MODIFY TAB_out7 FROM REC_out7 INDEX L_TABIX.
MODIFY ZFI0067T FROM REC_ZFI0067T.
MOVE-CORRESPONDING REC_out7 TO REC_ZFI0068T.
MODIFY ZFI0068T FROM REC_ZFI0068T.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ENDIF.
ELSE.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
ENDIF.
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。