AB类会计凭证 计提
*&---------------------------------------------------------------------* *& Form FRM_CREATE_JT_BELNR *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM FRM_CREATE_JT_BELNR . DATA: L_INDEX TYPE I, L_DMBTR1 TYPE BSEG-DMBTR, L_DMBTR2 TYPE BSEG-DMBTR, L_DMBTR3 TYPE BSEG-DMBTR, L_DMBTR4 TYPE BSEG-DMBTR. CLEAR L_INDEX. *调用BAPI生成类型为AB的会计凭证 DOCUMENTHEADER-DOC_TYPE = 'AB'. DOCUMENTHEADER-DOC_DATE = P_BLDAT. DOCUMENTHEADER-PSTNG_DATE = P_BUDAT. DOCUMENTHEADER-FIS_PERIOD = P_BUDAT+4(2). DOCUMENTHEADER-COMP_CODE = P_BUKRS. DOCUMENTHEADER-USERNAME = SY-UNAME. DOCUMENTHEADER-BUS_ACT = 'RFBU'. DOCUMENTHEADER-HEADER_TXT = '珠宝工资分配'. SORT IT_OUTPUT_ITAB BY KOSTL. LOOP AT IT_OUTPUT_ITAB. MOVE IT_OUTPUT_ITAB TO WA_OUTPUT_LINE. AT NEW KOSTL. CLEAR: L_DMBTR1, L_DMBTR2. ENDAT. L_DMBTR1 = L_DMBTR1 + WA_OUTPUT_LINE-DMBTR1. * l_dmbtr2 = l_dmbtr1 + wa_output_line-dmbtr9. L_DMBTR2 = L_DMBTR2 + WA_OUTPUT_LINE-DMBTR2 + WA_OUTPUT_LINE-DMBTR3 + WA_OUTPUT_LINE-DMBTR4 + WA_OUTPUT_LINE-DMBTR5 + WA_OUTPUT_LINE-DMBTR6 + WA_OUTPUT_LINE-DMBTR7 + WA_OUTPUT_LINE-DMBTR8. AT END OF KOSTL. ADD 1 TO L_INDEX. ACCOUNTGL-ITEMNO_ACC = L_INDEX. IF WA_OUTPUT_LINE-KOSTL EQ 'C2I000012I'."Change By Ly 20150323 * IF wa_output_line-kostl EQ 'C202000006'. ACCOUNTGL-GL_ACCOUNT = '5001030000'. * ELSEif wa_output_line-kostl eq 'C202000005'.“DELETE BY LY 20150304 * accountgl-gl_account = '5101010000'. ELSE. ACCOUNTGL-GL_ACCOUNT = '6601010000'. ENDIF. ACCOUNTGL-COSTCENTER = WA_OUTPUT_LINE-KOSTL. ACCOUNTGL-ITEM_TEXT = '珠宝工资分配'. APPEND ACCOUNTGL. CLEAR ACCOUNTGL. CURRENCYAMOUNT-ITEMNO_ACC = L_INDEX. CURRENCYAMOUNT-AMT_DOCCUR = L_DMBTR1. CURRENCYAMOUNT-CURRENCY = 'CNY'. APPEND CURRENCYAMOUNT. CLEAR CURRENCYAMOUNT. CLEAR: ZACC_DOCUMENT. ZACC_DOCUMENT-POSNR = L_INDEX. * zacc_document-bschl = '40'.Changed By Ly 20150323 IF L_DMBTR1 < 0. "更改 shirumeng 20150506 ZACC_DOCUMENT-BSCHL = '50'. ZACC_DOCUMENT-XNEGP = 'X'. ELSE. ZACC_DOCUMENT-BSCHL = '40'. ENDIF. EXTENSION2-STRUCTURE = 'ZACC_DOCUMENT'. EXTENSION2-VALUEPART1 = ZACC_DOCUMENT. APPEND EXTENSION2. CLEAR EXTENSION2. ADD 1 TO L_INDEX. ACCOUNTGL-ITEMNO_ACC = L_INDEX. ACCOUNTGL-GL_ACCOUNT = '2211010100'. "更改 shiruemng 20150429 ACCOUNTGL-COSTCENTER = WA_OUTPUT_LINE-KOSTL. ACCOUNTGL-ITEM_TEXT = '珠宝工资分配'. APPEND ACCOUNTGL. CLEAR ACCOUNTGL. CURRENCYAMOUNT-ITEMNO_ACC = L_INDEX. CURRENCYAMOUNT-AMT_DOCCUR = L_DMBTR2. CURRENCYAMOUNT-CURRENCY = 'CNY'. APPEND CURRENCYAMOUNT. CLEAR CURRENCYAMOUNT. CLEAR: ZACC_DOCUMENT. ZACC_DOCUMENT-POSNR = L_INDEX. * zacc_document-bschl = '40'. IF L_DMBTR2 < 0. ZACC_DOCUMENT-BSCHL = '50'. ZACC_DOCUMENT-XNEGP = 'X'. ELSE. ZACC_DOCUMENT-BSCHL = '40'. ENDIF. EXTENSION2-STRUCTURE = 'ZACC_DOCUMENT'. EXTENSION2-VALUEPART1 = ZACC_DOCUMENT. APPEND EXTENSION2. CLEAR EXTENSION2. ADD 1 TO L_INDEX. ACCOUNTGL-ITEMNO_ACC = L_INDEX. ACCOUNTGL-GL_ACCOUNT = '2211010100'. "更改 shiruemng 20150429 ACCOUNTGL-COSTCENTER = WA_OUTPUT_LINE-KOSTL. ACCOUNTGL-ITEM_TEXT = '珠宝工资分配'. APPEND ACCOUNTGL. CLEAR ACCOUNTGL. CURRENCYAMOUNT-ITEMNO_ACC = L_INDEX. CURRENCYAMOUNT-AMT_DOCCUR = L_DMBTR1 * -1. CURRENCYAMOUNT-CURRENCY = 'CNY'. APPEND CURRENCYAMOUNT. CLEAR CURRENCYAMOUNT. CLEAR: ZACC_DOCUMENT. ZACC_DOCUMENT-POSNR = L_INDEX. * 和 6601010000 效果相反。 IF L_DMBTR1 < 0. ZACC_DOCUMENT-BSCHL = '40'. ZACC_DOCUMENT-XNEGP = 'X'. ELSE. ZACC_DOCUMENT-BSCHL = '50'. ENDIF. " ZACC_DOCUMENT-BSCHL = '50'. EXTENSION2-STRUCTURE = 'ZACC_DOCUMENT'. EXTENSION2-VALUEPART1 = ZACC_DOCUMENT. APPEND EXTENSION2. CLEAR EXTENSION2. ENDAT. ENDLOOP. READ TABLE IT_TOTAL_ITAB INDEX 1. ADD 1 TO L_INDEX. PERFORM FRM_FILL_ITEM USING L_INDEX '2241010100' IT_TOTAL_ITAB-DMBTR2. ADD 1 TO L_INDEX. PERFORM FRM_FILL_ITEM USING L_INDEX '2241010200' IT_TOTAL_ITAB-DMBTR3. ADD 1 TO L_INDEX. PERFORM FRM_FILL_ITEM USING L_INDEX '2241010300' IT_TOTAL_ITAB-DMBTR4. ADD 1 TO L_INDEX. PERFORM FRM_FILL_ITEM USING L_INDEX '2241010500' IT_TOTAL_ITAB-DMBTR5. ADD 1 TO L_INDEX. PERFORM FRM_FILL_ITEM USING L_INDEX '2241010600' IT_TOTAL_ITAB-DMBTR7. ADD 1 TO L_INDEX. PERFORM FRM_FILL_ITEM USING L_INDEX '2241019900' IT_TOTAL_ITAB-DMBTR8. "更改 shiruemng 20150429 ADD 1 TO L_INDEX. PERFORM FRM_FILL_ITEM USING L_INDEX '2221110000' IT_TOTAL_ITAB-DMBTR6. CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST' EXPORTING DOCUMENTHEADER = DOCUMENTHEADER TABLES ACCOUNTRECEIVABLE = ACCOUNTRECEIVABLE ACCOUNTPAYABLE = ACCOUNTPAYABLE ACCOUNTGL = ACCOUNTGL CURRENCYAMOUNT = CURRENCYAMOUNT EXTENSION2 = EXTENSION2 RETURN = RETURN. ENDFORM. " FRM_CREATE_JT_BELNR
*&---------------------------------------------------------------------* *& Form FRM_FILL_ITEM *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_L_INDEX text * -->P_1149 text * -->P_IT_TOTAL_ITAB_DMBTR4 text *----------------------------------------------------------------------* FORM FRM_FILL_ITEM USING P_L_INDEX VALUE(P_1149) P_IT_TOTAL_ITAB_DMBTR4. ACCOUNTGL-ITEMNO_ACC = P_L_INDEX. ACCOUNTGL-GL_ACCOUNT = P_1149. ACCOUNTGL-ITEM_TEXT = '珠宝工资分配'. APPEND ACCOUNTGL. CLEAR ACCOUNTGL. CURRENCYAMOUNT-ITEMNO_ACC = P_L_INDEX. CURRENCYAMOUNT-AMT_DOCCUR = P_IT_TOTAL_ITAB_DMBTR4 * -1. CURRENCYAMOUNT-CURRENCY = 'CNY'. APPEND CURRENCYAMOUNT. CLEAR CURRENCYAMOUNT. CLEAR: ZACC_DOCUMENT. ZACC_DOCUMENT-POSNR = P_L_INDEX. IF P_IT_TOTAL_ITAB_DMBTR4 < 0. ZACC_DOCUMENT-BSCHL = '40'. ZACC_DOCUMENT-XNEGP = 'X'. ELSE. ZACC_DOCUMENT-BSCHL = '50'. ENDIF. EXTENSION2-STRUCTURE = 'ZACC_DOCUMENT'. EXTENSION2-VALUEPART1 = ZACC_DOCUMENT. APPEND EXTENSION2. CLEAR EXTENSION2. ENDFORM. " FRM_FILL_ITEM
创建类型为SK的会计凭证
*&---------------------------------------------------------------------* *& Form FRM_CREATE_FF_BELNR *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-- p2 text *----------------------------------------------------------------------* FORM FRM_CREATE_FF_BELNR . DATA: L_INDEX TYPE I, L_DMBTR1 TYPE BSEG-DMBTR, L_DMBTR2 TYPE BSEG-DMBTR, L_DMBTR3 TYPE BSEG-DMBTR, L_DMBTR4 TYPE BSEG-DMBTR. DATA:LV_DMBTR5 TYPE BSEG-DMBTR. CLEAR L_INDEX. *调用BAPI生成类型为SK会计凭证 DOCUMENTHEADER-DOC_TYPE = 'SK'. DOCUMENTHEADER-DOC_DATE = P_BLDAT. DOCUMENTHEADER-PSTNG_DATE = P_BUDAT. DOCUMENTHEADER-FIS_PERIOD = P_BUDAT+4(2). DOCUMENTHEADER-COMP_CODE = P_BUKRS. DOCUMENTHEADER-USERNAME = SY-UNAME. DOCUMENTHEADER-BUS_ACT = 'RFBU'. DOCUMENTHEADER-HEADER_TXT = '珠宝工资发放'. CHECK IT_TOTAL_ITAB[] IS NOT INITIAL. SORT IT_TOTAL_ITAB[] BY KOSTL. LOOP AT IT_TOTAL_ITAB. ADD 1 TO L_INDEX. * read table it_total_itab index 1. ACCOUNTGL-ITEMNO_ACC = L_INDEX."1. ACCOUNTGL-GL_ACCOUNT = '2211010100'. "更改 shiruemng 20150429 ACCOUNTGL-COSTCENTER = IT_TOTAL_ITAB-KOSTL. ACCOUNTGL-ITEM_TEXT = '珠宝工资发放'. APPEND ACCOUNTGL. CLEAR ACCOUNTGL. CURRENCYAMOUNT-ITEMNO_ACC = L_INDEX."1. CURRENCYAMOUNT-AMT_DOCCUR = IT_TOTAL_ITAB-DMBTR1 - IT_TOTAL_ITAB-DMBTR2 - IT_TOTAL_ITAB-DMBTR3 - IT_TOTAL_ITAB-DMBTR4 - IT_TOTAL_ITAB-DMBTR5 - IT_TOTAL_ITAB-DMBTR6 - IT_TOTAL_ITAB-DMBTR7 - IT_TOTAL_ITAB-DMBTR8. CURRENCYAMOUNT-CURRENCY = 'CNY'. APPEND CURRENCYAMOUNT. CLEAR: ZACC_DOCUMENT. ZACC_DOCUMENT-POSNR = L_INDEX."1. IF CURRENCYAMOUNT-AMT_DOCCUR < 0. ZACC_DOCUMENT-BSCHL = '50'. ZACC_DOCUMENT-XNEGP = 'X'. ELSE. ZACC_DOCUMENT-BSCHL = '40'. ENDIF. * zacc_document-bschl = '40'. ZACC_DOCUMENT-RSTGR = '-07'. EXTENSION2-STRUCTURE = 'ZACC_DOCUMENT'. EXTENSION2-VALUEPART1 = ZACC_DOCUMENT. APPEND EXTENSION2. CLEAR EXTENSION2. CLEAR CURRENCYAMOUNT. "20150506 * add 1 to l_index. * accountgl-itemno_acc = l_index. * accountgl-gl_account = p_saknr. * accountgl-item_text = '珠宝工资发放'. * append accountgl. * clear accountgl. * * currencyamount-itemno_acc = l_index. ** currencyamount-amt_doccur = it_total_itab-dmbtr1 * -1. * currencyamount-amt_doccur = ( it_total_itab-dmbtr1 - it_total_itab-dmbtr2 - it_total_itab-dmbtr3 - it_total_itab-dmbtr4 * - it_total_itab-dmbtr5 - it_total_itab-dmbtr6 - it_total_itab-dmbtr7 - it_total_itab-dmbtr8 ) * -1. LV_DMBTR5 = IT_TOTAL_ITAB-DMBTR1 - IT_TOTAL_ITAB-DMBTR2 - IT_TOTAL_ITAB-DMBTR3 - IT_TOTAL_ITAB-DMBTR4 - IT_TOTAL_ITAB-DMBTR5 - IT_TOTAL_ITAB-DMBTR6 - IT_TOTAL_ITAB-DMBTR7 - IT_TOTAL_ITAB-DMBTR8 + LV_DMBTR5. * currencyamount-currency = 'CNY'. * append currencyamount. * clear currencyamount. * * clear: zacc_document. * zacc_document-posnr = l_index. * zacc_document-bschl = '50'. * extension2-structure = 'ZACC_DOCUMENT'. * extension2-valuepart1 = zacc_document. * append extension2. * clear extension2. * clear it_total_itab. ENDLOOP. "Changed by ly 20150311 ADD 1 TO L_INDEX. ACCOUNTGL-ITEMNO_ACC = L_INDEX. ACCOUNTGL-GL_ACCOUNT = P_SAKNR. ACCOUNTGL-ITEM_TEXT = '珠宝工资发放'. APPEND ACCOUNTGL. CLEAR ACCOUNTGL. CURRENCYAMOUNT-ITEMNO_ACC = L_INDEX. CURRENCYAMOUNT-AMT_DOCCUR = LV_DMBTR5 * -1. * currencyamount-amt_doccur = ( it_total_itab-dmbtr1 - it_total_itab-dmbtr2 - it_total_itab-dmbtr3 - it_total_itab-dmbtr4 * - it_total_itab-dmbtr5 - it_total_itab-dmbtr6 - it_total_itab-dmbtr7 - it_total_itab-dmbtr8 ) * -1. CURRENCYAMOUNT-CURRENCY = 'CNY'. APPEND CURRENCYAMOUNT. CLEAR: ZACC_DOCUMENT. ZACC_DOCUMENT-POSNR = L_INDEX. IF LV_DMBTR5 < 0. ZACC_DOCUMENT-BSCHL = '40'. " ZACC_DOCUMENT-XNEGP = 'X'. ELSE. ZACC_DOCUMENT-BSCHL = '50'. ENDIF. " ZACC_DOCUMENT-BSCHL = '50'. EXTENSION2-STRUCTURE = 'ZACC_DOCUMENT'. EXTENSION2-VALUEPART1 = ZACC_DOCUMENT. APPEND EXTENSION2. CLEAR EXTENSION2. CLEAR IT_TOTAL_ITAB. CLEAR CURRENCYAMOUNT. "20150506 "Changed by ly 20150311 CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST' EXPORTING DOCUMENTHEADER = DOCUMENTHEADER TABLES ACCOUNTRECEIVABLE = ACCOUNTRECEIVABLE ACCOUNTPAYABLE = ACCOUNTPAYABLE ACCOUNTGL = ACCOUNTGL CURRENCYAMOUNT = CURRENCYAMOUNT EXTENSION2 = EXTENSION2 RETURN = RETURN. ENDFORM. " FRM_CREATE_FF_BELNR
会计凭证增强:
BADI:ACC_DOCUMENT
IF:IF_EX_ACC_DOCUMENT
属性:多次使用,过滤器相关 过滤器类型 AWTYP
过滤器值:BKPFF
METH:IF_EX_ACC_DOCUMENT~CHANGE
method if_ex_acc_document~change. data: wa_extension type bapiparex, ext_value(960) type c, wa_accit type accit, l_ref type ref to data. field-symbols: <l_struc> type any, <l_field> type any. sort c_extension2 by structure. loop at c_extension2 into wa_extension. at new structure. create data l_ref type (wa_extension-structure). assign l_ref->* to <l_struc>. endat. concatenate wa_extension-valuepart1 wa_extension-valuepart2 wa_extension-valuepart3 wa_extension-valuepart4 into ext_value. move ext_value to <l_struc>. assign component 'POSNR' of structure <l_struc> to <l_field>. read table c_accit with key posnr = <l_field> into wa_accit. if sy-subrc is initial. move-corresponding <l_struc> to wa_accit. modify c_accit from wa_accit index sy-tabix. endif. endloop. endmethod.
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/18698.html