创建预制发票BAPI(BAPI_INCOMINGINVOICE_PARK)
*&---------------------------------------------------------------------**& Form ZBAPI*&---------------------------------------------------------------------**& text*&am
*&---------------------------------------------------------------------*
*& Form ZBAPI
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> p1 text
*& <-- p2 text
*&---------------------------------------------------------------------*
FORM ZBAPI .
DATA HEADERDATA TYPE BAPI_INCINV_CREATE_HEADER.
DATA INVOICEDOCNUMBER LIKE BAPI_INCINV_FLD-INV_DOC_NO.
DATA FISCALYEAR LIKE BAPI_INCINV_FLD-FISC_YEAR.
DATA:ITEMDATA TYPE STANDARD TABLE OF BAPI_INCINV_CREATE_ITEM,
LS_ITEMDATA TYPE BAPI_INCINV_CREATE_ITEM.
DATA:TAXDATA TYPE STANDARD TABLE OF BAPI_INCINV_CREATE_TAX,
LS_TAXDATA TYPE BAPI_INCINV_CREATE_TAX.
DATA RETURN TYPE STANDARD TABLE OF BAPIRET2.
DATA:TM_ITEMDATA TYPE STANDARD TABLE OF BAPI_INCINV_CREATE_TM_ITEM,
LS_TM_ITEMDATA TYPE BAPI_INCINV_CREATE_TM_ITEM.
TYPES:BEGIN OF TY_ZDZD_SATNR,
ZDZD TYPE ZTMM_CGDZ-ZDZD,
SATNR TYPE ZTMM_CGDZ-SATNR,
END OF TY_ZDZD_SATNR.
DATA:LT_ZDZD_SATNR TYPE TABLE OF TY_ZDZD_SATNR,
LS_ZDZD_SATNR TYPE TY_ZDZD_SATNR,
LT_ZDZD_SATNR1 TYPE TABLE OF TY_ZDZD_SATNR,
LT_ZDZD_SATNR2 TYPE TABLE OF TY_ZDZD_SATNR,
LT_ZDZD_SATNR_TEMP TYPE TABLE OF TY_ZDZD_SATNR.
DATA:LT_OUTPUT TYPE TABLE OF TY_OUTPUT.
DATA:LT_OUTPUT1 TYPE TABLE OF TY_OUTPUT, "没有补款扣款的放在这里
LT_OUTPUT1_TEMP TYPE TABLE OF TY_OUTPUT, "没有补款扣款的放在这里
LT_OUTPUT2 TYPE TABLE OF TY_OUTPUT, "否则放在这里
LT_OUTPUT2_TEMP TYPE TABLE OF TY_OUTPUT, "否则放在这里
LT_OUTPUT2_LOOP TYPE TABLE OF TY_OUTPUT. "否则放在这里
DATA:LS_OUTPUT1 TYPE TY_OUTPUT,
LS_OUTPUT2 TYPE TY_OUTPUT.
DATA:LT_ZTMM_CGDZ TYPE TABLE OF ZTMM_CGDZ,
LS_ZTMM_CGDZ LIKE LINE OF LT_ZTMM_CGDZ.
DATA:L_TABIX TYPE SY-TABIX,
L_ROWS TYPE I.
DATA:L_ZDZJE TYPE ZZEZDZJE."对账金额
DATA:L_POSNR TYPE BAPI_INCINV_CREATE_TM_ITEM-INVOICE_DOC_ITEM.
DATA:L_CREATE TYPE C."是否创建
DATA:L_ZBKJE TYPE ZTMM_CGDZ-ZBKJE, "补款金额
L_ZZKJE TYPE ZTMM_CGDZ-ZZKJE. "折扣金额
DATA:L_ZITM TYPE ZTMM_CGDZ-ZITM.
CLEAR:HEADERDATA,
INVOICEDOCNUMBER,
FISCALYEAR,
ITEMDATA,
LS_ITEMDATA,
TAXDATA,
LS_TAXDATA,
RETURN,
TM_ITEMDATA,
LS_TM_ITEMDATA,
LT_OUTPUT,
LT_OUTPUT1,
LT_OUTPUT1_TEMP,
LT_OUTPUT2,
LT_OUTPUT2_TEMP,
LT_ZTMM_CGDZ.
*****************有折扣金额和折扣金额的放在一堆(1),没有的放在另一丟(2);接着(1)的按对账单号+款号生成预制发票,(2)是按对账单号生成预制发票
***************** ADD BY HANDLH 20180628
LOOP AT GT_OUTPUT ASSIGNING FIELD-SYMBOL(<FW_GS_OUTPUT>) WHERE CHECKBOX EQ 'X'.
MOVE-CORRESPONDING <FW_GS_OUTPUT> TO LS_ZDZD_SATNR.
SELECT SINGLE *
INTO LS_ZTMM_CGDZ
FROM ZTMM_CGDZ
WHERE ZDZD EQ LS_ZDZD_SATNR-ZDZD
AND SATNR EQ LS_ZDZD_SATNR-SATNR
AND ( ZBKJE NE 0 OR ZZKJE NE 0 OR ZJPF NE 0 OR ZTHFXYF NE 0 OR ZCWRJE NE 0 OR ZCLWTJE NE 0 OR ZQTKK NE 0 ).
IF SY-SUBRC NE 0.
APPEND LS_ZDZD_SATNR TO LT_ZDZD_SATNR1."没有补款扣款的 生成一张
ELSE.
APPEND LS_ZDZD_SATNR TO LT_ZDZD_SATNR2."有补款扣款的
ENDIF.
ENDLOOP.
SORT LT_ZDZD_SATNR1.
DELETE ADJACENT DUPLICATES FROM LT_ZDZD_SATNR1.
SORT LT_ZDZD_SATNR2.
DELETE ADJACENT DUPLICATES FROM LT_ZDZD_SATNR2.
LOOP AT LT_ZDZD_SATNR1 INTO LS_ZDZD_SATNR.
LOOP AT GT_OUTPUT INTO GS_OUTPUT WHERE ZDZD EQ LS_ZDZD_SATNR-ZDZD AND SATNR EQ LS_ZDZD_SATNR-SATNR.
APPEND GS_OUTPUT TO LT_OUTPUT1.
APPEND GS_OUTPUT TO LT_OUTPUT1_TEMP.
ENDLOOP.
ENDLOOP.
"(1)没有补款/折扣 的过账规则
LOOP AT LT_OUTPUT1 ASSIGNING FIELD-SYMBOL(<FW_OUTPUT1>).
AT NEW ZDZD.
MOVE 0 TO L_ROWS.
PERFORM GET_HEAD1 TABLES TAXDATA USING <FW_OUTPUT1> CHANGING HEADERDATA .
ENDAT.
ADD 1 TO L_ROWS.
PERFORM GET_ITEM TABLES TAXDATA ITEMDATA USING <FW_OUTPUT1> HEADERDATA L_ROWS.
"300张对账单生成一张发票
IF L_ROWS EQ 300.
MOVE 'X' TO L_CREATE.
PERFORM CREATE_MBLNR TABLES TAXDATA ITEMDATA RETURN USING HEADERDATA CHANGING INVOICEDOCNUMBER FISCALYEAR.
PERFORM FILL_MESSAGE1 TABLES RETURN LT_ZTMM_CGDZ LT_OUTPUT1_TEMP USING <FW_OUTPUT1>-ZDZD INVOICEDOCNUMBER FISCALYEAR.
CLEAR:HEADERDATA,
INVOICEDOCNUMBER,
FISCALYEAR,
ITEMDATA,
LS_ITEMDATA,
TAXDATA,
LS_TAXDATA,
RETURN,
TM_ITEMDATA,
LS_TM_ITEMDATA,
L_ROWS
.
ENDIF.
"或者是最后一行生成一张发票
AT END OF ZDZD.
CLEAR:L_CREATE.
IF L_CREATE NE 'X'.
PERFORM CREATE_MBLNR TABLES TAXDATA ITEMDATA RETURN USING HEADERDATA CHANGING INVOICEDOCNUMBER FISCALYEAR.
PERFORM FILL_MESSAGE1 TABLES RETURN LT_ZTMM_CGDZ LT_OUTPUT1_TEMP USING <FW_OUTPUT1>-ZDZD INVOICEDOCNUMBER FISCALYEAR.
CLEAR:L_CREATE.
CLEAR:HEADERDATA,
INVOICEDOCNUMBER,
FISCALYEAR,
ITEMDATA,
LS_ITEMDATA,
TAXDATA,
LS_TAXDATA,
RETURN,
TM_ITEMDATA,
LS_TM_ITEMDATA,
L_ROWS
.
ENDIF.
ENDAT.
ENDLOOP.
LOOP AT LT_OUTPUT1_TEMP INTO LS_OUTPUT1.
READ TABLE GT_OUTPUT INTO GS_OUTPUT WITH KEY ZDZD = LS_OUTPUT1-ZDZD ZITM = LS_OUTPUT1-ZITM.
IF SY-SUBRC EQ 0.
MOVE '2' TO LS_OUTPUT1-ZFPZT."预制发票创建日期
MOVE SY-DATUM TO LS_OUTPUT1-ZFPRQ."发票状态
MODIFY GT_OUTPUT FROM LS_OUTPUT1 INDEX SY-TABIX.
ENDIF.
ENDLOOP.
SORT LT_ZDZD_SATNR2.
DELETE ADJACENT DUPLICATES FROM LT_ZDZD_SATNR2.
LOOP AT LT_ZDZD_SATNR2 INTO LS_ZDZD_SATNR.
CLEAR:LT_OUTPUT2,
LT_OUTPUT2_TEMP.
LOOP AT GT_OUTPUT INTO GS_OUTPUT WHERE ZDZD EQ LS_ZDZD_SATNR-ZDZD AND SATNR EQ LS_ZDZD_SATNR-SATNR.
APPEND GS_OUTPUT TO LT_OUTPUT2.
APPEND GS_OUTPUT TO LT_OUTPUT2_TEMP.
MOVE-CORRESPONDING GS_OUTPUT TO LS_ZDZD_SATNR.
ENDLOOP.
"(2)有补款/扣款 的过账规则
CLEAR:LT_OUTPUT2_LOOP.
CLEAR:HEADERDATA,
INVOICEDOCNUMBER,
FISCALYEAR,
ITEMDATA,
LS_ITEMDATA,
TAXDATA,
LS_TAXDATA,
RETURN,
TM_ITEMDATA,
LS_TM_ITEMDATA,
L_ROWS,
LT_OUTPUT2_LOOP .
LOOP AT LT_OUTPUT2 ASSIGNING FIELD-SYMBOL(<FW_OUTPUT2>) WHERE ZDZD EQ LS_ZDZD_SATNR-ZDZD AND SATNR EQ LS_ZDZD_SATNR-SATNR.
APPEND <FW_OUTPUT2> TO LT_OUTPUT2_LOOP.
ENDLOOP.
"对账单 + 款号生成预制发票
LOOP AT LT_OUTPUT2_LOOP ASSIGNING FIELD-SYMBOL(<FW_OUTPUT2_LOOP>).
AT FIRST.
MOVE 0 TO L_ROWS.
PERFORM GET_HEAD2 TABLES TAXDATA CHANGING <FW_OUTPUT2_LOOP> HEADERDATA.
ENDAT.
ADD 1 TO L_ROWS.
PERFORM GET_ITEM TABLES TAXDATA ITEMDATA USING <FW_OUTPUT2_LOOP> HEADERDATA L_ROWS.
"300张对账单生成一张发票
IF L_ROWS EQ 300.
MOVE 'X' TO L_CREATE.
PERFORM CREATE_MBLNR TABLES TAXDATA ITEMDATA RETURN
USING HEADERDATA
CHANGING INVOICEDOCNUMBER FISCALYEAR.
PERFORM FILL_MESSAGE2 TABLES RETURN LT_ZTMM_CGDZ LT_OUTPUT2_TEMP
USING <FW_OUTPUT2_LOOP>-ZDZD <FW_OUTPUT2_LOOP>-SATNR INVOICEDOCNUMBER FISCALYEAR.
CLEAR:HEADERDATA,
INVOICEDOCNUMBER,
FISCALYEAR,
ITEMDATA,
LS_ITEMDATA,
TAXDATA,
LS_TAXDATA,
RETURN,
TM_ITEMDATA,
LS_TM_ITEMDATA,
L_ROWS
.
ENDIF.
"或者是最后一行生成一张发票
AT END OF SATNR.
CLEAR:L_CREATE.
IF L_CREATE NE 'X'.
PERFORM CREATE_MBLNR TABLES TAXDATA ITEMDATA RETURN
USING HEADERDATA
CHANGING INVOICEDOCNUMBER FISCALYEAR.
PERFORM FILL_MESSAGE2 TABLES RETURN LT_ZTMM_CGDZ LT_OUTPUT2_TEMP
USING <FW_OUTPUT2_LOOP>-ZDZD <FW_OUTPUT2_LOOP>-SATNR INVOICEDOCNUMBER FISCALYEAR.
CLEAR:L_CREATE.
CLEAR:HEADERDATA,
INVOICEDOCNUMBER,
FISCALYEAR,
ITEMDATA,
LS_ITEMDATA,
TAXDATA,
LS_TAXDATA,
RETURN,
TM_ITEMDATA,
LS_TM_ITEMDATA,
L_ROWS
.
ENDIF.
ENDAT.
ENDLOOP.
* ENDLOOP.
LOOP AT LT_OUTPUT2_TEMP INTO LS_OUTPUT2.
* MODIFY TABLE GT_OUTPUT FROM LS_OUTPUT2 ."WHERE ZDZD EQ LS_OUTPUT2-ZDZD AND ZITM EQ LS_OUTPUT2-ZITM..
LOOP AT GT_OUTPUT INTO GS_OUTPUT WHERE ZDZD = LS_ZDZD_SATNR-ZDZD AND SATNR = LS_ZDZD_SATNR-SATNR.
MOVE LS_OUTPUT2-MESSAGE TO GS_OUTPUT-MESSAGE."消息
MOVE LS_OUTPUT2-STATUS TO GS_OUTPUT-STATUS."状态灯
MOVE LS_OUTPUT2-BELNR TO GS_OUTPUT-BELNR."发票凭证的凭证编号
MOVE LS_OUTPUT2-GJAHR TO GS_OUTPUT-GJAHR."财年
MOVE '2' TO GS_OUTPUT-ZFPZT."预制发票创建日期
MOVE SY-DATUM TO GS_OUTPUT-ZFPRQ."发票状态
MODIFY GT_OUTPUT FROM GS_OUTPUT.
ENDLOOP.
ENDLOOP.
ENDLOOP.
"更新自建表
IF LT_ZTMM_CGDZ IS NOT INITIAL.
MODIFY ZTMM_CGDZ FROM TABLE LT_ZTMM_CGDZ.
ENDIF.
"刷新ALV
PERFORM REFRESH_ALV.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form CREATE_MBLNR
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> HEADERDATA
*& --> TAXDATA
*& --> RETURN
*& <-- INVOICEDOCNUMBER
*& <-- FISCALYEAR
*&---------------------------------------------------------------------*
FORM CREATE_MBLNR TABLES TAXDATA STRUCTURE BAPI_INCINV_CREATE_TAX
ITEMDATA STRUCTURE BAPI_INCINV_CREATE_ITEM
RETURN STRUCTURE BAPIRET2
USING HEADERDATA
CHANGING INVOICEDOCNUMBER
FISCALYEAR.
CALL FUNCTION 'BAPI_INCOMINGINVOICE_PARK'
EXPORTING
HEADERDATA = HEADERDATA
* ADDRESSDATA = ADDRESSDATA
IMPORTING
INVOICEDOCNUMBER = INVOICEDOCNUMBER
FISCALYEAR = FISCALYEAR
TABLES
ITEMDATA = ITEMDATA
* ACCOUNTINGDATA = ACCOUNTINGDATA
* GLACCOUNTDATA = GLACCOUNTDATA
* MATERIALDATA = MATERIALDATA
TAXDATA = TAXDATA
* WITHTAXDATA = WITHTAXDATA
* VENDORITEMSPLITDATA = VENDORITEMSPLITDATA
RETURN = RETURN
* EXTENSIONIN = EXTENSIONIN
* TM_ITEMDATA = TM_ITEMDATA
* NFMETALLITMS = NFMETALLITMS
* ASSETDATA = ASSETDATA
.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form FILL_MESSAGE
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> RETURN
*&---------------------------------------------------------------------*
FORM FILL_MESSAGE1 TABLES RETURN STRUCTURE BAPIRET2
LT_ZTMM_CGDZ STRUCTURE ZTMM_CGDZ
LT_OUTPUT1_TEMP STRUCTURE GS_OUTPUT
USING P_ZDZD
INVOICEDOCNUMBER
FISCALYEAR.
DATA:LV_MSG TYPE STRING.
DATA:LS_OUTPUT1_TEMP TYPE TY_OUTPUT.
READ TABLE RETURN ASSIGNING FIELD-SYMBOL(<FW_RETURN>) WITH KEY TYPE = 'E'.
IF SY-SUBRC EQ 0."error
ROLLBACK WORK.
CLEAR:LV_MSG.
LOOP AT RETURN ASSIGNING <FW_RETURN> WHERE TYPE = 'E'.
CONCATENATE LV_MSG <FW_RETURN>-MESSAGE ';' INTO LV_MSG.
ENDLOOP.
CONCATENATE '创建失败' LV_MSG INTO LV_MSG.
LOOP AT LT_OUTPUT1_TEMP INTO LS_OUTPUT1_TEMP WHERE ZDZD EQ P_ZDZD.
MOVE LV_MSG TO LS_OUTPUT1_TEMP-MESSAGE.
MOVE GC_LIGHT_R TO LS_OUTPUT1_TEMP-STATUS.
MODIFY LT_OUTPUT1_TEMP FROM LS_OUTPUT1_TEMP.
ENDLOOP.
ELSE."right
COMMIT WORK AND WAIT.
LOOP AT LT_OUTPUT1_TEMP INTO LS_OUTPUT1_TEMP WHERE ZDZD EQ P_ZDZD.
CONCATENATE '预制凭证' INVOICEDOCNUMBER '财年' FISCALYEAR '创建成功' INTO LS_OUTPUT1_TEMP-MESSAGE.
MOVE INVOICEDOCNUMBER TO LS_OUTPUT1_TEMP-BELNR."凭证
MOVE FISCALYEAR TO LS_OUTPUT1_TEMP-GJAHR."财年
MOVE GC_LIGHT_G TO LS_OUTPUT1_TEMP-STATUS.
MODIFY LT_OUTPUT1_TEMP FROM LS_OUTPUT1_TEMP.
"重新取数,因为计算的值不写会自建表
SELECT SINGLE
*
INTO @DATA(LS_ZTMM_CGDZ)
FROM ZTMM_CGDZ
WHERE ZDZD EQ @LS_OUTPUT1_TEMP-ZDZD
AND ZITM EQ @LS_OUTPUT1_TEMP-ZITM.
MOVE 2 TO LS_ZTMM_CGDZ-ZFPZT .
MOVE INVOICEDOCNUMBER TO LS_ZTMM_CGDZ-BELNR."凭证
MOVE FISCALYEAR TO LS_ZTMM_CGDZ-GJAHR."财年
MOVE SY-DATUM TO LS_ZTMM_CGDZ-ZFPRQ ."预制发票创建日期
MOVE SY-UNAME TO LS_ZTMM_CGDZ-UPNAM ."最后更改者
MOVE SY-DATUM TO LS_ZTMM_CGDZ-UPDAT ."最后更改日期
MOVE SY-UZEIT TO LS_ZTMM_CGDZ-UPTIM ."最后更改时间
APPEND LS_ZTMM_CGDZ TO LT_ZTMM_CGDZ. "发票过账状态
ENDLOOP.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form GET_HEAD
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> <FW_OUTPUT>
*& <-- HEADERDATA
*&---------------------------------------------------------------------*
FORM GET_HEAD1 TABLES TAXDATA STRUCTURE BAPI_INCINV_CREATE_TAX
USING FW_OUTPUT TYPE TY_OUTPUT
CHANGING HEADERDATA TYPE BAPI_INCINV_CREATE_HEADER.
DATA: LS_TAXDATA TYPE BAPI_INCINV_CREATE_TAX.
IF FW_OUTPUT-ZYF GT 0.
HEADERDATA-INVOICE_IND = 'X'. "发票
HEADERDATA-DELIV_POSTING = 'S'.
HEADERDATA-RETURN_POSTING = 'H'.
HEADERDATA-GROSS_AMOUNT = FW_OUTPUT-ZYF.
ELSE.
HEADERDATA-INVOICE_IND = ''. "贷项凭证
HEADERDATA-DELIV_POSTING = 'H'.
HEADERDATA-RETURN_POSTING = 'H'.
HEADERDATA-GROSS_AMOUNT = FW_OUTPUT-ZYF * -1.
ENDIF.
HEADERDATA-DOC_DATE = SY-DATUM.
HEADERDATA-PSTNG_DATE = SY-DATUM.
HEADERDATA-BLINE_DATE = SY-DATUM.
** 公司代码取值逻辑
SELECT SINGLE
BUKRS
INTO HEADERDATA-COMP_CODE
FROM T001K
WHERE BWKEY EQ FW_OUTPUT-WERKS.
SELECT SINGLE
WAERS
INTO HEADERDATA-CURRENCY
FROM EKKO
WHERE EBELN EQ FW_OUTPUT-EBELN.
HEADERDATA-DEL_COSTS = 0.
SELECT SINGLE
LIFN2
INTO HEADERDATA-DIFF_INV
FROM WYT3
WHERE LIFNR EQ FW_OUTPUT-LIFNR
AND PARVW EQ 'RS'.
HEADERDATA-REF_DOC_NO = FW_OUTPUT-ZDZD. "对账单号
HEADERDATA-HEADER_TXT = FW_OUTPUT-ZHTBM. "采购合同号
HEADERDATA-ITEM_TEXT = FW_OUTPUT-ZINVOC. "供应商发票号
CASE FW_OUTPUT-MWSKZ.
WHEN 'J0'.
LS_TAXDATA-TAX_CODE = 'J0'.
LS_TAXDATA-TAX_AMOUNT = 0 .
WHEN 'J1'.
LS_TAXDATA-TAX_CODE = 'J1'.
LS_TAXDATA-TAX_AMOUNT = HEADERDATA-GROSS_AMOUNT * 17 / 117.
WHEN 'J2'.
LS_TAXDATA-TAX_CODE = 'J2'.
LS_TAXDATA-TAX_AMOUNT = HEADERDATA-GROSS_AMOUNT * 16 / 116.
WHEN 'J3'.
LS_TAXDATA-TAX_CODE = 'J3'.
LS_TAXDATA-TAX_AMOUNT = HEADERDATA-GROSS_AMOUNT * 11 / 111.
WHEN 'J4'.
LS_TAXDATA-TAX_CODE = 'J4'.
LS_TAXDATA-TAX_AMOUNT = HEADERDATA-GROSS_AMOUNT * 10 / 110.
WHEN 'J5'.
LS_TAXDATA-TAX_CODE = 'J5'.
LS_TAXDATA-TAX_AMOUNT = HEADERDATA-GROSS_AMOUNT * 6 / 106.
WHEN 'J6'.
LS_TAXDATA-TAX_CODE = 'J6'.
LS_TAXDATA-TAX_AMOUNT = HEADERDATA-GROSS_AMOUNT * 5 / 105.
WHEN 'J7'.
LS_TAXDATA-TAX_CODE = 'J6'.
LS_TAXDATA-TAX_AMOUNT = HEADERDATA-GROSS_AMOUNT * 3 / 103.
WHEN OTHERS.
ENDCASE.
APPEND LS_TAXDATA TO TAXDATA.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form GET_ITEM
*&---------------------------------------------------------------------*
*& text
*&---------------------------------------------------------------------*
*& --> TAXDATA
*& --> <FW_OUTPUT>
*&---------------------------------------------------------------------*
FORM GET_ITEM TABLES TAXDATA STRUCTURE BAPI_INCINV_CREATE_TAX
ITEMDATA STRUCTURE BAPI_INCINV_CREATE_ITEM
USING FW_OUTPUT TYPE TY_OUTPUT
HEADERDATA TYPE BAPI_INCINV_CREATE_HEADER
P_L_ROWS
.
DATA:LS_ITEMDATA TYPE BAPI_INCINV_CREATE_ITEM.
DATA:L_ZDZJE TYPE ZZEZDZJE."对账金额
* "ITEM
MOVE P_L_ROWS TO LS_ITEMDATA-INVOICE_DOC_ITEM."行号
MOVE FW_OUTPUT-EBELN TO LS_ITEMDATA-PO_NUMBER.
MOVE FW_OUTPUT-EBELP TO LS_ITEMDATA-PO_ITEM.
MOVE FW_OUTPUT-ZDDZSL TO LS_ITEMDATA-QUANTITY.
LS_ITEMDATA-QUANTITY = ABS( LS_ITEMDATA-QUANTITY )."add by handlh 20180610 行项目存绝对值
MOVE FW_OUTPUT-MWSKZ TO LS_ITEMDATA-TAX_CODE.
LS_ITEMDATA-PO_UNIT = |{ FW_OUTPUT-MEINS ALPHA = IN }|.
CASE FW_OUTPUT-MWSKZ.
WHEN 'J0'.
MOVE ABS( FW_OUTPUT-ZDDZJE ) TO LS_ITEMDATA-ITEM_AMOUNT.
WHEN 'J1'.
L_ZDZJE = ABS( FW_OUTPUT-ZDDZJE ) * 100 / 117 .
MOVE L_ZDZJE TO LS_ITEMDATA-ITEM_AMOUNT.
WHEN 'J2'.
L_ZDZJE = ABS( FW_OUTPUT-ZDDZJE * 100 / 116 ).
MOVE L_ZDZJE TO LS_ITEMDATA-ITEM_AMOUNT.
WHEN 'J3'.
L_ZDZJE = ABS( FW_OUTPUT-ZDDZJE * 100 / 111 ).
MOVE L_ZDZJE TO LS_ITEMDATA-ITEM_AMOUNT.
WHEN 'J4'.
L_ZDZJE = ABS( FW_OUTPUT-ZDDZJE * 100 / 110 ).
MOVE L_ZDZJE TO LS_ITEMDATA-ITEM_AMOUNT.
WHEN 'J5'.
L_ZDZJE = ABS( FW_OUTPUT-ZDDZJE * 100 / 106 ).
MOVE L_ZDZJE TO LS_ITEMDATA-ITEM_AMOUNT.
WHEN 'J6'.
L_ZDZJE = ABS( FW_OUTPUT-ZDDZJE * 100 / 105 ).
MOVE L_ZDZJE TO LS_ITEMDATA-ITEM_AMOUNT.
WHEN 'J7'.
L_ZDZJE = ABS( FW_OUTPUT-ZDDZJE * 100 / 103 ).
MOVE L_ZDZJE TO LS_ITEMDATA-ITEM_AMOUNT.
WHEN OTHERS.
ENDCASE.
APPEND LS_ITEMDATA TO ITEMDATA.
ENDFORM.
更多推荐
所有评论(0)