改往BTE去處理,用event1120替換科目。找到1120的interface之後,copy至ZPROCESS_00001120。發現structure BSEG_SUBST並沒有提供科目的field HKONT。直接append structure把field加進去,之後再寫code。
以下範例僅供參考:
FIELD-SYMBOLS: , TYPE BSEG_SUBST.
DATA: VAR_NAME(30).
**MIRO
DATA: XEKBE LIKE EKBE OCCURS 10 WITH HEADER LINE,
XEKPO LIKE EKPO OCCURS 10 WITH HEADER LINE,
TMP_EKPO LIKE EKPO.
**billing
DATA: XVBRPVB LIKE VBRPVB OCCURS 10 WITH HEADER LINE.
**Logic
READ TABLE T_BKPF INDEX 1.
CASE T_BKPF-BLART.
WHEN 'RE'.
VAR_NAME = '(SAPLMRMP)XEKBE[]'.
ASSIGN (VAR_NAME) TO.
CHECK SY-SUBRC = 0.
XEKBE[] =.
LOOP AT XEKBE.
SELECT * FROM EKPO WHERE EBELN = XEKBE-EBELN
AND EBELP = XEKBE-EBELP
AND ( KNTTP = 'A' OR KNTTP = 'K' ).
APPEND EKPO TO XEKPO.
ENDSELECT.
ENDLOOP.
CHECK XEKPO[] IS NOT INITIAL.
LOOP AT XEKPO.
IF XEKPO-NETWR > TMP_EKPO-NETWR.
TMP_EKPO = XEKPO.
ENDIF.
ENDLOOP.
CLEAR LFA1.
LOOP AT T_BSEG WHERE KOART = 'K'.
READ TABLE T_BSEGSUB WITH KEY TABIX = SY-TABIX ASSIGNING.
SELECT SINGLE * FROM LFA1 WHERE LIFNR = T_BSEG-LIFNR
AND KTOKK = 'Z101'.
IF SY-SUBRC = 0. "關係人
CASE TMP_EKPO-KNTTP.
WHEN 'A'.
-HKONT = '0021460001'.
WHEN 'K'.
-HKONT = '0021901001'.
ENDCASE.
ELSE. "非關係人
CASE TMP_EKPO-KNTTP.
WHEN 'A'.
-HKONT = '0021450001'.
WHEN 'K'.
-HKONT = '0021700002'.
ENDCASE.
ENDIF.
ENDLOOP.
WHEN 'RV'.
VAR_NAME = '(SAPMV60A)XVBRP[]'.
ASSIGN (VAR_NAME) TO.
CHECK SY-SUBRC = 0.
XVBRPVB[] =.
READ TABLE XVBRPVB INDEX 1.
CHECK SY-SUBRC = 0.
SELECT SINGLE * FROM VBAK WHERE VBELN = XVBRPVB-AUBEL
AND AUART = 'ZSLA'.
CHECK SY-SUBRC = 0.
SELECT SINGLE * FROM KNA1 WHERE KUNNR = VBAK-KUNNR AND KTOKD = 'Z005'.
IF SY-SUBRC = 0.
LOOP AT T_BSEG WHERE KOART = 'D'.
READ TABLE T_BSEGSUB WITH KEY TABIX = SY-TABIX ASSIGNING.
IF SY-SUBRC = 0.
-HKONT = '0011550001'.
ENDIF.
ENDLOOP.
ELSE.
LOOP AT T_BSEG WHERE KOART = 'D'.
READ TABLE T_BSEGSUB WITH KEY TABIX = SY-TABIX ASSIGNING.
IF SY-SUBRC = 0.
-HKONT = '0011460001'.
ENDIF.
ENDLOOP.
ENDIF.
ENDCASE.
DATA: VAR_NAME(30).
**MIRO
DATA: XEKBE LIKE EKBE OCCURS 10 WITH HEADER LINE,
XEKPO LIKE EKPO OCCURS 10 WITH HEADER LINE,
TMP_EKPO LIKE EKPO.
**billing
DATA: XVBRPVB LIKE VBRPVB OCCURS 10 WITH HEADER LINE.
**Logic
READ TABLE T_BKPF INDEX 1.
CASE T_BKPF-BLART.
WHEN 'RE'.
VAR_NAME = '(SAPLMRMP)XEKBE[]'.
ASSIGN (VAR_NAME) TO
CHECK SY-SUBRC = 0.
XEKBE[] =
LOOP AT XEKBE.
SELECT * FROM EKPO WHERE EBELN = XEKBE-EBELN
AND EBELP = XEKBE-EBELP
AND ( KNTTP = 'A' OR KNTTP = 'K' ).
APPEND EKPO TO XEKPO.
ENDSELECT.
ENDLOOP.
CHECK XEKPO[] IS NOT INITIAL.
LOOP AT XEKPO.
IF XEKPO-NETWR > TMP_EKPO-NETWR.
TMP_EKPO = XEKPO.
ENDIF.
ENDLOOP.
CLEAR LFA1.
LOOP AT T_BSEG WHERE KOART = 'K'.
READ TABLE T_BSEGSUB WITH KEY TABIX = SY-TABIX ASSIGNING
SELECT SINGLE * FROM LFA1 WHERE LIFNR = T_BSEG-LIFNR
AND KTOKK = 'Z101'.
IF SY-SUBRC = 0. "關係人
CASE TMP_EKPO-KNTTP.
WHEN 'A'.
WHEN 'K'.
ENDCASE.
ELSE. "非關係人
CASE TMP_EKPO-KNTTP.
WHEN 'A'.
WHEN 'K'.
ENDCASE.
ENDIF.
ENDLOOP.
WHEN 'RV'.
VAR_NAME = '(SAPMV60A)XVBRP[]'.
ASSIGN (VAR_NAME) TO
CHECK SY-SUBRC = 0.
XVBRPVB[] =
READ TABLE XVBRPVB INDEX 1.
CHECK SY-SUBRC = 0.
SELECT SINGLE * FROM VBAK WHERE VBELN = XVBRPVB-AUBEL
AND AUART = 'ZSLA'.
CHECK SY-SUBRC = 0.
SELECT SINGLE * FROM KNA1 WHERE KUNNR = VBAK-KUNNR AND KTOKD = 'Z005'.
IF SY-SUBRC = 0.
LOOP AT T_BSEG WHERE KOART = 'D'.
READ TABLE T_BSEGSUB WITH KEY TABIX = SY-TABIX ASSIGNING
IF SY-SUBRC = 0.
ENDIF.
ENDLOOP.
ELSE.
LOOP AT T_BSEG WHERE KOART = 'D'.
READ TABLE T_BSEGSUB WITH KEY TABIX = SY-TABIX ASSIGNING
IF SY-SUBRC = 0.
ENDIF.
ENDLOOP.
ENDIF.
ENDCASE.
沒有留言:
張貼留言