*&---------------------------------------------------------------------* *& Report ZPOST_DOCUMENT *&---------------------------------------------------------------------* *& *&---------------------------------------------------------------------* REPORT zpost_document. DATA: lw_documentheader LIKE bapiache09, lw_customercpd LIKE bapiacpa09, lw_contractheader LIKE bapiaccahd. DATA: lt_accountgl LIKE STANDARD TABLE OF bapiacgl09, "S总帐/A资产 lt_accountreceivable LIKE STANDARD TABLE OF bapiacar09, "D客户 lt_accountpayable LIKE STANDARD TABLE OF bapiacap09, "K供应商 lt_accounttax LIKE STANDARD TABLE OF bapiactx09, lt_currencyamount LIKE STANDARD TABLE OF bapiaccr09, lt_criteria LIKE STANDARD TABLE OF bapiackec9, lt_valuefield LIKE STANDARD TABLE OF bapiackev9, "CO 获利字段 lt_extension1 LIKE STANDARD TABLE OF bapiacextc, lt_return LIKE STANDARD TABLE OF bapiret2, lt_paymentcard LIKE STANDARD TABLE OF bapiacpc09, lt_contractitem LIKE STANDARD TABLE OF bapiaccait, lt_extension2 LIKE STANDARD TABLE OF bapiparex, " lt_realestate LIKE STANDARD TABLE OF bapiacre09, lt_accountwt LIKE STANDARD TABLE OF bapiacwt09. DATA: lw_accountgl LIKE bapiacgl09, lw_accountreceivable LIKE bapiacar09, lw_accountpayable LIKE bapiacap09, lw_accounttax LIKE bapiactx09, lw_currencyamount LIKE bapiaccr09, lw_criteria LIKE bapiackec9, lw_valuefield LIKE bapiackev9, lw_extension1 LIKE bapiacextc, lw_return LIKE bapiret2, lw_paymentcard LIKE bapiacpc09, lw_contractitem LIKE bapiaccait, lw_extension2 LIKE bapiparex, lw_realestate LIKE bapiacre09, lw_accountwt LIKE bapiacwt09. DATA: wa_zexten LIKE yfs0006."增强 DATA: lv_obj_type LIKE bapiache09-obj_type, lv_obj_key LIKE bapiache09-obj_key, lv_obj_sys LIKE bapiache09-obj_sys. CLEAR lw_documentheader. lw_documentheader-username = sy-uname. *lw_documentheader-fisc_year = '2022'. lw_documentheader-doc_date = '20230310'."Document Date lw_documentheader-pstng_date = '20230306'."Posting Date *lw_documentheader-fis_period = '12'. lw_documentheader-doc_type = 'RV'."Document Type lw_documentheader-comp_code = 'A101'."Company code *lw_documentheader-ref_doc_no = ''."Reference "D CLEAR:lw_accountreceivable. lw_accountreceivable-itemno_acc = 10. lw_accountreceivable-customer = 'A110000916' . lw_accountreceivable-comp_code = 'A101' . lw_accountreceivable-gl_account = '110202ZZZZ'. lw_accountreceivable-item_text = '37111791'. APPEND lw_accountreceivable TO lt_accountreceivable. "S CLEAR: lw_accountgl. lw_accountgl-itemno_acc = 20. lw_accountreceivable-comp_code = 'A101' . lw_accountgl-gl_account = '23040102ZZ'. lw_accountgl-item_text = '37111791'. APPEND lw_accountgl TO lt_accountgl. CLEAR: lw_accountgl. lw_accountgl-itemno_acc = 30. lw_accountreceivable-comp_code = 'A101' . lw_accountgl-gl_account = '51010401ZZ'. lw_accountgl-profit_ctr = 'U1CS1030'. lw_accountgl-doc_type = 'RV'. lw_accountgl-pstng_date = '20230306'. lw_accountgl-item_text = '37111791'. CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT' EXPORTING input = lw_accountgl-costcenter IMPORTING output = lw_accountgl-costcenter. APPEND lw_accountgl TO lt_accountgl. CLEAR: lw_currencyamount. lw_currencyamount-itemno_acc = 10. lw_currencyamount-curr_type = '00'. lw_currencyamount-currency = 'CNY'. "货币 lw_currencyamount-amt_doccur = '100'. "金额 APPEND lw_currencyamount TO lt_currencyamount. CLEAR: lw_currencyamount. lw_currencyamount-itemno_acc = 20. lw_currencyamount-curr_type = '00'. lw_currencyamount-currency = 'CNY'. "货币 lw_currencyamount-amt_doccur = '-50'. "金额 APPEND lw_currencyamount TO lt_currencyamount. CLEAR: lw_currencyamount. lw_currencyamount-itemno_acc = 30. lw_currencyamount-curr_type = '00'. lw_currencyamount-currency = 'CNY'. "货币 lw_currencyamount-amt_doccur = '-50'. "金额 APPEND lw_currencyamount TO lt_currencyamount. CLEAR lw_criteria . lw_criteria-itemno_acc = 30 . lw_criteria-fieldname = 'PRCTR'. lw_criteria-character = 'U1CS1030'. APPEND lw_criteria TO lt_criteria . CLEAR lw_criteria . lw_criteria-itemno_acc = 30 . lw_criteria-fieldname = 'KNDNR'. lw_criteria-character = 'A110000916'. APPEND lw_criteria TO lt_criteria . CLEAR lw_criteria . lw_criteria-itemno_acc = 30 . lw_criteria-fieldname = 'ARTNR'. lw_criteria-character = 'A71V782'. APPEND lw_criteria TO lt_criteria . CLEAR lw_criteria . lw_criteria-itemno_acc = 30 . lw_criteria-fieldname = 'FKART'. lw_criteria-character = 'ZD01'. APPEND lw_criteria TO lt_criteria . CLEAR: wa_zexten. wa_zexten-posnr = 10. "行号 wa_zexten-bschl = '01'. "记帐码 lw_extension2-structure = 'YFS0006'. lw_extension2-valuepart1 = wa_zexten. APPEND lw_extension2 TO lt_extension2. CLEAR: wa_zexten. wa_zexten-posnr = 20. "行号 wa_zexten-bschl = '50'. "记帐码 lw_extension2-structure = 'YFS0006'. lw_extension2-valuepart1 = wa_zexten. APPEND lw_extension2 TO lt_extension2. CLEAR: wa_zexten. wa_zexten-posnr = 30. "行号 wa_zexten-bschl = '50'. "记帐码 lw_extension2-structure = 'YFS0006'. lw_extension2-valuepart1 = wa_zexten. APPEND lw_extension2 TO lt_extension2. CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST' EXPORTING documentheader = lw_documentheader * customercpd = lw_customercpd * contractheader = lw_contractheader IMPORTING obj_type = lv_obj_type obj_key = lv_obj_key obj_sys = lv_obj_sys TABLES accountgl = lt_accountgl accountreceivable = lt_accountreceivable accountpayable = lt_accountpayable * accounttax = lt_accounttax currencyamount = lt_currencyamount criteria = lt_criteria valuefield = lt_valuefield * extension1 = lt_extension1 return = lt_return * paymentcard = lt_paymentcard * contractitem = lt_contractitem extension2 = lt_extension2. * realestate = lt_realestate * accountwt = lt_accountwt. *IF lv_obj_key = '$'. * lv_obj_key = ''. * CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. * *ELSE. * * CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' * EXPORTING * wait = 'X'. * *ENDIF. * *LOOP AT lt_return INTO lw_return. * *ENDLOOP. *冲销FB08 DATA: lt_bdcdata TYPE TABLE OF bdcdata, ls_bdcdata TYPE bdcdata, lt_messtab TYPE TABLE OF bdcmsgcoll, ls_messtab TYPE bdcmsgcoll, lt_return1 TYPE TABLE OF bapiret2. DATA lv_mode TYPE char4 VALUE 'N'. DATA lv_update TYPE char4 VALUE 'S'. DATA lv_message TYPE string. REFRESH: lt_bdcdata,lt_messtab,lt_return1. CLEAR:ls_bdcdata,ls_messtab. PERFORM bdc_dynpro USING 'SAPMF05A' '0105'. PERFORM bdc_field USING 'BDC_CURSOR' 'RF05A-BELNS'. PERFORM bdc_field USING 'BDC_OKCODE' '=BU'. PERFORM bdc_field USING 'RF05A-BELNS' '2100000009'. PERFORM bdc_field USING 'BKPF-BUKRS' 'A101'. PERFORM bdc_field USING 'RF05A-GJAHS' '2023'. PERFORM bdc_field USING 'UF05A-STGRD' '02'. PERFORM bdc_field USING 'BSIS-BUDAT' sy-datum. CALL TRANSACTION 'FB08' USING lt_bdcdata MODE lv_mode UPDATE lv_update MESSAGES INTO lt_messtab. CALL FUNCTION 'CONVERT_BDCMSGCOLL_TO_BAPIRET2' TABLES imt_bdcmsgcoll = lt_messtab ext_return = lt_return1. READ TABLE lt_messtab INTO ls_messtab WITH KEY msgtyp = 'S'. IF sy-subrc = 0. * READ TABLE lt_return1 INTO ls_return1 INDEX 1. ELSE. * LOOP AT lt_return1 INTO DATA(ls_return1) WHERE type = 'E'. * gs_info-icon_light_info = 'E'. * gs_info-message_info = '失败!' && ls_bapi_return-MESSAGE. * ENDLOOP. ENDIF. BREAK-POINT. *----------------------------------------------------------------------* * Start new screen * *----------------------------------------------------------------------* FORM bdc_dynpro USING program dynpro. CLEAR ls_bdcdata. ls_bdcdata-program = program. ls_bdcdata-dynpro = dynpro. ls_bdcdata-dynbegin = 'X'. APPEND ls_bdcdata TO lt_bdcdata. ENDFORM. *----------------------------------------------------------------------* * Insert field * *----------------------------------------------------------------------* FORM bdc_field USING fnam fval. * IF FVAL <> NODATA. CLEAR ls_bdcdata. ls_bdcdata-fnam = fnam. ls_bdcdata-fval = fval. APPEND ls_bdcdata TO lt_bdcdata. * ENDIF. ENDFORM.
标签:02,会计凭证,lw,lt,冲销,criteria,currencyamount,accountgl,LIKE From: https://www.cnblogs.com/Anyohh233/p/17431586.html