FBL5N query customer outstanding items
Clearing method
Standard clearing: all outstanding lines have been cleared
Partially cleared: the line that is partially cleared is still pending, and the other lines are cleared, and an uncleared line is generated. Refer to the partially cleared line
Remaining clearing: all the original line items become cleared, and a new uncleared item voucher is generated
There are two ways for customers to pay
Normal receipt of payment offset: invoice to the customer, the customer directly pays, in doing so, the accounting vouchers will be automatically cleared. Clear the account in fb05 first, and then enter the manual subject line.
Temporary payment offset: offset with advance payment (use advance payment accounting vouchers and invoices when clearing accounts).
Bookkeeping at the time of advance receipt, debit customers (fixed bill customers) special general ledger- acceptance bills, credit advance receipt;
Special General Ledger for Debiting Customers-Accounts Received in Advance
Other clearing
Customer receivables and payables
The customer should be receivable and the supplier should be paid
Clear with BDC
If you want to fill in the line item in the clearing, the screen of the line item may be different. You can use NEXT_DYNPRO_SEARCH to determine the screen. There are 4 additional screens in total, which can also be calculated. Refer to the function ZFM_AR_03_16.
You can locate the open voucher line item, refer to ZFM_AR_03_16.
For dynamic screens, required fields, etc., alternative processing can be used
BDC DEMO
form frm_acc_clear_bdc .
data:begin of lt_alv_c occurs 0,
bukrs like gt_alv-bukrs,
waers like gt_alv-waers,
partner like gt_alv-partner,
dimension like gt_alv-dimension,
wrbtr like gt_alv-wrbtr,
wrbtr_s like gt_alv-wrbtr,
wrbtr_h like gt_alv-wrbtr,
augbl like gt_alv-augbl,
rtype like gt_alv-rtype,
rtmsg like gt_alv-rtmsg,
end of lt_alv_c.
data:
* lt_ztfi048b like table of ztfi048b with header line,
lv_blart like bkpf-blart,
lv_wrbtr_s like gt_alv-wrbtr,
lv_wrbtr_h like gt_alv-wrbtr,
lv_abpos type abpos_f05a, "the item number to start to display
lv_s, "S line has reached the target amount
lv_h. "Line H has reached the target amount
* if p_d = 'X'..
* lv_blart = 'Z1'.
* else.
* lv_blart = 'Z2'.
* endif.
lv_blart = 'AB'.
loop at gt_alv where sel = 'X'.
clear:lt_alv_c.
lt_alv_c-bukrs = gt_alv-bukrs.
lt_alv_c-partner = gt_alv-partner.
lt_alv_c-waers = gt_alv-waers.
lt_alv_c-dimension = gt_alv-dimension.
if gt_alv-shkzg = 'S'.
lt_alv_c-wrbtr_s = gt_alv-wrbtr.
elseif gt_alv-shkzg = 'H'.
lt_alv_c-wrbtr_h = gt_alv-wrbtr.
endif.
collect lt_alv_c.
endloop.
if sy-subrc ne 0.
message e001(00) with'Select at least one row'.
endif.
delete lt_alv_c where wrbtr_s is initial or wrbtr_h is initial.
loop at lt_alv_c.
if lt_alv_c-wrbtr_s <= lt_alv_c-wrbtr_h.
lt_alv_c-wrbtr = lt_alv_c-wrbtr_s.
else.
lt_alv_c-wrbtr = lt_alv_c-wrbtr_h.
endif.
clear: lv_wrbtr_s, lv_wrbtr_h, lv_abpos, lv_s, lv_h.
perform frm_bdc_init.
* look up
perform frm_bdc_dynnr using 'SAPMF05A' '0122'.
perform frm_bdc_field using 'DATS' 'BKPF-BLDAT' sy-datum.
perform frm_bdc_field using space 'BKPF-BLART' lv_blart.
perform frm_bdc_field using space 'BKPF-BUKRS' lt_alv_c-bukrs .
perform frm_bdc_field using 'DATS' 'BKPF-BUDAT' sy-datum.
perform frm_bdc_field using space 'BKPF-WAERS' lt_alv_c-waers.
* perform frm_bdc_field using space'BKPF-BKTXT' is_head-bktxt. "The work order number is written into the header text
* if is_head-kursf is not initial.
* perform frm_bdc_field using 'NUM' 'BKPF-KURSF' is_head-kursf. " 汇率
* endif.
* if is_head-wwert is not initial.
* perform frm_bdc_field using'DATS''BKPF-WWERT' is_head-wwert. "Conversion date
* endif.
perform frm_bdc_field using space'BDC_OKCODE''=SL'. "Select open items
loop at gt_alv where partner = lt_alv_c-partner and dimension = lt_alv_c-dimension and sel = 'X'.
lv_abpos = lv_abpos + 1.
data(lv_str) = gt_alv-belnr && gt_alv-gjahr && gt_alv-buzei.
if gt_alv-shkzg = 'S'.
lv_wrbtr_s = lv_wrbtr_s + gt_alv-wrbtr.
else.
lv_wrbtr_h = lv_wrbtr_h + gt_alv-wrbtr.
endif.
*Select the cut-off bank for outstanding loans
if ( lv_s = 'X' and gt_alv-shkzg = 'S' ) or ( lv_h = 'X' and gt_alv-shkzg = 'H' ).
continue.
endif.
if (lv_wrbtr_s >= lt_alv_c-wrbtr_h and gt_alv-shkzg ='S' ). "After marking this line, it cannot be cleared
lv_s = 'X'.
endif.
if ( lv_wrbtr_h >= lt_alv_c-wrbtr_s and gt_alv-shkzg = 'H' ).
lv_h = 'X'.
endif.
*Select open items
perform frm_bdc_dynnr using 'SAPMF05A' '0710'.
perform frm_bdc_field using space'RF05A-AGKOA' gv_agkoa. "Account type
perform frm_bdc_field using space'RF05A-AGUMS' gt_alv-umskz. "Special General Ledger ID
*select
perform frm_bdc_field using space 'BDC_OKCODE' '/05'. "选择
perform frm_bdc_dynnr using'SAPMF05A' '0733'. "Select credentials in the pop-up box
perform frm_bdc_field using space 'RF05A-FELDN(01)' 'BELNR'.
perform frm_bdc_field using space 'RF05A-SEL01(01)' lv_str.
perform frm_bdc_field using space'BDC_OKCODE''=PA'. "Process outstanding items
*Calculate to the last line and start clearing
if lt_alv_c-wrbtr_s < lt_alv_c-wrbtr_h.
if lv_wrbtr_s = lt_alv_c-wrbtr_s and lv_wrbtr_s < lv_wrbtr_h.
data(lv_exit) = 'X'.
endif.
elseif lt_alv_c-wrbtr_s > lt_alv_c-wrbtr_h.
if lv_wrbtr_h = lt_alv_c-wrbtr_h and lv_wrbtr_s > lv_wrbtr_h.
lv_exit = 'X'.
endif.
elseif lt_alv_c-wrbtr_s = lt_alv_c-wrbtr_h.
if lv_wrbtr_h = lt_alv_c-wrbtr_h and lv_wrbtr_s = lv_wrbtr_h.
lv_exit = 'X'.
endif.
endif.
if lv_exit = 'X'.
*Partial/Remaining Clearing Bank
if lv_wrbtr_s ne lv_wrbtr_h.
* if p_d ='X'. "Partially cleared
data(lv_okcode) = '=PART'.
data(lv_fname) = 'DF05B-PSZAH(01)'.
* elseif p_k ='X'. "Remaining clearing
lv_okcode = 'REST'.
lv_fname = 'DF05B-PSDIF(01)'.
* endif.
*Handle open items
perform frm_bdc_dynnr using 'SAPDF05X' '3100'.
perform frm_bdc_field using space 'BDC_OKCODE' lv_okcode.
perform frm_bdc_dynnr using 'SAPDF05X' '3100'.
perform frm_bdc_field using space 'RF05A-ABPOS' lv_abpos. "定位
perform frm_bdc_field using space 'BDC_OKCODE' '=/00'.
perform frm_bdc_dynnr using 'SAPDF05X' '3100'.
perform frm_bdc_field using space 'BDC_CURSOR' lv_fname.
perform frm_bdc_field using space 'BDC_OKCODE' '=PI'. "双击
endif.
*Standard clearing
exit.
endif.
*Overview
perform frm_bdc_dynnr using 'SAPDF05X' '3100'.
perform frm_bdc_field using space 'BDC_OKCODE' '=AB'. "概览
perform frm_bdc_dynnr using 'SAPMF05A' '0700'.
perform frm_bdc_field using space'BDC_OKCODE''=SL'. "Select open items
endloop.
*Overview
perform frm_bdc_dynnr using 'SAPDF05X' '3100'.
perform frm_bdc_field using space 'BDC_OKCODE' '=AB'. "概览
perform frm_bdc_dynnr using 'SAPMF05A' '0700'.
perform frm_bdc_field using space 'BDC_OKCODE' '=BU'. "保存
perform frm_bdc_call using 'FB05' 'F5' '312' changing lt_alv_c-rtype lt_alv_c-rtmsg.
lt_alv_c-augbl = gt_messtab-msgv1.
modify lt_alv_c.
endloop.
loop at gt_alv where sel = 'X'.
read table lt_alv_c with key partner = gt_alv-partner dimension = gt_alv-dimension.
if sy-subrc = 0.
gt_alv-augbl = lt_alv_c-augbl.
gt_alv-rtype = lt_alv_c-rtype.
gt_alv-rtmsg = lt_alv_c-rtmsg.
modify gt_alv.
endif.
endloop.
endform.
Clear with function (abandoned, BDC solves all problems)
Only standard and remaining clearing can be done, not partial clearing (not sure)
form frm_posting_interface_clearing using uv_hkont changing us_alv like gt_alv .
data: it_blntab type table of blntab with header line,
it_ftclear type table of ftclear with header line,
it_ftpost type table of ftpost with header line,
it_fttax type table of fttax with header line.
export ebr_id from us_alv-ebr_id to memory id 'EBR_POST'.
call function 'POSTING_INTERFACE_START'
exporting
i_function = 'C' "B= BDC, C= Call Trans.
i_keep ='X' "The queue delete flag for the processed session
i_mode = 'N'
exceptions
client_incorrect = 1
function_invalid = 2
group_name_missing = 3
mode_invalid = 4
update_invalid = 5
others = 6.
*Date processing
write sy-datum to sy-datum.
write us_alv-bank_date to us_alv-bank_date.
populated_ftpost:
'K' 1 'BKPF-BUKRS' us_alv-bukrs, "Company code
'K' 1 'BKPF-BLART' 'AB',
'K' 1 'BKPF-BLDAT' sy-datum,
'K' 1 'BKPF-BUDAT' us_alv-bank_date,
'K' 1 'BKPF-WAERS' us_alv-currency,
* 'K' 1 'BKPF-XBLNR' 'Test',
'P' 1 'RF05A-NEWBS' '40',
'P' 1'BSEG-HKONT' uv_hkont, "Bank Account
'P' 1'BSEG-SGTXT'': Cash received from selling goods and providing labor services',
'P' 1'BSEG-VBUND' '1000', "For testing
'P' 1 'COBL-PRCTR' us_alv-prctr.
if us_alv-rstgr is not initial.
populate_ftpost'P' 1'BSEG-RSTGR' us_alv-rstgr. "Reason code
endif.
* 'P' 1 'BSEG-WRBTR' us_alv-amt_claimed,
*Bdc processing of the amount
it_ftpost-fnam = 'BSEG-WRBTR'.
write us_alv-amt_claimed to it_ftpost-fval(16).
append it_ftpost.
*Open items
loop at gt_epic_ebr_seg into data (ls_epic_ebr_seg) where ebr_id = us_alv-ebr_id.
data(lv_str) = ls_epic_ebr_seg-belnr && ls_epic_ebr_seg-gjahr && ls_epic_ebr_seg-buzei.
if ls_epic_ebr_seg-part_type = 'K'.
select single umskz
into @data(lv_umskz)
from bsik
where gjahr = @ ls_epic_ebr_seg-gjahr and bukrs = @ ls_epic_ebr_seg-bukrs
and belnr = @ ls_epic_ebr_seg-belnr and buzei = @ ls_epic_ebr_seg-buzei.
elseif ls_epic_ebr_seg-part_type = 'D'.
select single umskz
into lv_umskz
from bsid
where gjahr = ls_epic_ebr_seg-gjahr and bukrs = ls_epic_ebr_seg-bukrs
and belnr = ls_epic_ebr_seg-belnr and buzei = ls_epic_ebr_seg-buzei.
endif.
populate_ftclear lv_str us_alv-bukrs lv_umskz ls_epic_ebr_seg-part_type. "concatenate doc number + fiscal year + line number
endloop.
call function 'POSTING_INTERFACE_CLEARING'
exporting
* i_auglv = 'REBOOKING'
i_auglv = 'AUSGZAHL'
i_tcode = 'FB05'
* i_sgfunct = 'C'
importing
e_msgid = sy-msgid
e_msgno = sy-msgno
e_msgty = sy-msgty
e_msgv1 = sy-msgv1
e_msgv2 = sy-msgv2
e_msgv3 = sy-msgv3
e_msgv4 = sy-msgv4
* E_SUBRC = SY-SUBRC
tables
t_blntab = it_blntab
t_ftclear = it_ftclear
t_ftpost = it_ftpost
t_fttax = it_fttax
exceptions
clearing_procedure_invalid = 1
clearing_procedure_missing = 2
table_t041a_empty = 3
transaction_code_invalid = 4
amount_format_error = 5
too_many_line_items = 6
company_code_invalid = 7
screen_not_found = 8
no_authorization = 9
others = 10.
if sy-msgty = 'S' and sy-msgid = 'F5' and sy-msgno = '312'.
us_alv-rtype = 'S'.
* us_alv-belnr_clearing = sy-msgv1.
us_alv-belnr = sy-msgv1.
us_alv-rtmsg = us_alv-rtmsg &&'Clearing successfully:' &&';'.
us_alv-status_desc ='Posted'.
elseif sy-subrc <> 0 or sy-msgty = 'E'.
us_alv-rtype = 'E'.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 into data (lv_msg).
us_alv-rtmsg = us_alv-rtmsg && '清账失败:' && lv_msg && ';'.
endif.
call function 'POSTING_INTERFACE_END'
exceptions
session_not_processable = 1
others = 2.
if us_alv-rtype = 'S'.
*Partially claimed and then do an advance receipt
if us_alv-status = '025'.
perform frm_acc_post_advance_receipt using uv_hkont changing gt_alv.
endif.
endif.
endform.
Function remaining clearing
Enhanced position
The main program SAPLFIPI include LFIPIF00 form transaktion_beenden
FORM end_transaction USING p_no_auth TYPE c.
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""$"$\SE:(1) Form TRANSAKTION_BEENDEN, Start A
*$*$-Start: (1)---------------------------------------------------------------------------------$*$*
ENHANCEMENT 1 ZFI_DOC_POST_CLEAR. "active version
"Partial clearing logic
DATA:GV_ID TYPE CHAR20. "MEMORY ID
DATA: LT_BDCDATA TYPE TABLE OF BDCDATA.
DATA: LS_BDCDATA TYPE BDCDATA.
CLEAR:LT_BDCDATA,GV_ID.
CONCATENATE SY-UNAME 'ADD_SCR' INTO GV_ID.
IMPORT LT_BDCDATA to LT_BDCDATA FROM MEMORY ID GV_ID. "Supplementary screen data
IF LT_BDCDATA IS NOT INITIAL.
APPEND LINES OF lt_bdcdata to ft.
LOOP AT FT WHERE FVAL = '/11'.
FT-FVAL = '=PA'.
MODIFY FT.
ENDLOOP.
ENDIF.
ENDENHANCEMENT.
minth demo