点击此处---> 群内免费提供SAP练习系统(在群公告中)
加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)
由于FIELD-SYMBOLS不能用'<>' 在新浪博客表示,去掉了,程序员自行分辨.
FIELD-SYMBOLS FS_BSEGSUB TYPE BSEG_SUBST.
FIELD-SYMBOLS FS_BSEG TYPE BSEG.
FIELD-SYMBOLS FS_MSEG TYPE MSEG.
DATA: BEGIN OF ICOKA OCCURS 0.
INCLUDE STRUCTURE COKA.
DATA: STATUS,
END OF ICOKA.
FIELD-SYMBOLS FST_ICOKA LIKE ICOKA[].
FIELD-SYMBOLS FSS_ICOKA LIKE ICOKA.
DATA LS_COBL TYPE COBL.
DATA LS_COKEY_IS TYPE COKEY_IS.
DATA LV_ORD_HRKFT TYPE CO_SUBKEY.
DATA LV_OLD_HKONT TYPE HKONT.
DATA LV_OBJNR TYPE J_OBJNR.
CONSTANTS CON_KOSTS_ON LIKE TKA00-KOSTS VALUE '1'. "Stellen aktiv
READ TABLE T_BKPF INDEX 1.
LOOP AT T_BSEGSUB ASSIGNING FS_BSEGSUB .
"取对照表对照逻辑"
CHECK SY-SUBRC = 0.
LV_OLD_HKONT = FS_BSEGSUB-HKONT.
FS_BSEGSUB-HKONT = "替换科目".
CLEAR LS_COBL.
READ TABLE T_BSEG ASSIGNING FS_BSEG INDEX FS_BSEGSUB -TABIX.
FS_BSEG-HKONT = FS_BSEGSUB-HKONT.
MOVE-CORRESPONDING T_BKPF TO LS_COBL.
MOVE-CORRESPONDING FS_BSEG TO LS_COBL.
MOVE-CORRESPONDING FS_BSEGSUB TO LS_COBL.
ASSIGN ('(SAPMM07M)MSEG') TO FS_MSEG.
IF SY-SUBRC = 0.
CLEAR LS_COBL.
MOVE-CORRESPONDING FS_MSEG TO LS_COBL.
LS_COBL-BUDAT = T_BKPF-BUDAT.
LS_COBL-BLDAT = T_BKPF-BLDAT.
LS_COBL-HKONT = FS_BSEGSUB-HKONT.
ENDIF.
ASSIGN ('(SAPLKCOA)ICOKA[] ') TO FST_ICOKA.
IF SY-SUBRC = 0.
IF FS_BSEG-KOSTL IS NOT INITIAL.
CLEAR LV_OBJNR.
CALL FUNCTION 'RK_KOSTL_READ'
EXPORTING
DATUM = T_BKPF-BUDAT
KOKRS = FS_BSEG-KOKRS
KOSTL = FS_BSEG-KOSTL
KOSTS = CON_KOSTS_ON
IMPORTING
OBJNR = LV_OBJNR
EXCEPTIONS
KOSTL_NOT_FOUND = 01
KOSTL_NOT_COMPLETE = 01.
IF SY-SUBRC = 0 OR LV_OBJNR NE SPACE.
LOOP AT FST_ICOKA ASSIGNING FSS_ICOKA
WHERE KSTAR = LV_OLD_HKONT
AND OBJNR = LV_OBJNR.
FSS_ICOKA-KSTAR = FS_BSEGSUB-HKONT.
ENDLOOP.
ENDIF.
ELSE.
LOOP AT FST_ICOKA ASSIGNING FSS_ICOKA
WHERE KSTAR = LV_OLD_HKONT
.
FSS_ICOKA-KSTAR = FS_BSEGSUB-HKONT.
ENDLOOP.
ENDIF.
SORT FST_ICOKA..
ENDIF.
IF LS_COBL-AUFPL IS NOT INITIAL.
SELECT SINGLE VORNR INTO LS_COBL-VORNR FROM AFVC
WHERE AUFPL = LS_COBL-AUFPL
AND APLZL = LS_COBL-APLZL.
ENDIF.
CALL FUNCTION 'K_COBL_CHECK'
EXPORTING
I_COBL = LS_COBL.
ENDLOOP.
转载请注明出处,请尊重知识产权!