‎2009 Mar 21 7:21 AM
Hi All,
I have a problem posting FB05 using POSTING_INTERFACE_CLEARING.My requirement is to select open item based on document number and then create another leg for that open item using GL account,posting key and amount that matches the selected open item amount.
I am not sure whether I am not doing the right thing because I get an error 'Difference is too large for clearing'. If I actually go to FB05 and 'choose open item' for document number and try to hit 'Save' on the list of open items screen,I get the same error. I then select 'Charge off difference' and it takes me to screen that is quite similar to FB01 and I enter the other leg of the entry i.e posting key,acct no,amount etc.I want to replicate the same process using funtion module.I am sending you the code,please help me.
start-of-selection.
i_splitinput-compcode = '0410'.
i_splitinput-currency = 'USD'.
i_splitinput-amount = '299'.
i_splitinput-reference = '90286483'.
i_splitinput-date = '20090320'.
i_splitinput-type = 'D'.
i_splitinput-clearingacct = '101002'.
append i_splitinput.
loop at i_splitinput.
at first.
perform posting_interface_start using 'C'.
endat.
at new currency.
perform f_create_document_header using i_splitinput-compcode
i_splitinput-currency.
endat.
perform f_create_document_items .
at end of currency.
perform f_post_gl_document.
endat.
at last.
perform f_posting_interface_end.
endat.
endloop.
&----
*& Form posting_interface_start
&----
text
----
-->P_P_TYPE text
----
form posting_interface_start using p_type.
data lv_mode type c value 'N'.
if p_type = 'C'.
call function 'POSTING_INTERFACE_START'
exporting
i_function = 'C'
i_mode = lv_mode
i_update = 'S'
exceptions
client_incorrect = 1
function_invalid = 2
group_name_missing = 3
mode_invalid = 4
update_invalid = 5
others = 6.
if sy-subrc <> 0.
message 'Error initializing posting interface'(e05) type 'I'.
endif.
endif.
endform. " posting_interface_start
&----
*& Form f_create_document_header
&----
text
----
--> p1 text
<-- p2 text
----
form f_create_document_header using p_compcode p_currency.
data: l_waers type waers,
l_postdate(10) type c,
l_docdate(10),
l_bktxt type bktxt,
l_blart type blart.
*---Convert dates to proper format MM/DD/YYYY
write p_pstdat to l_postdate mm/dd/yyyy.
write p_docdat to l_docdate mm/dd/yyyy.
i_ftpost-stype = 'K'. "Header
i_ftpost-count = 1.
perform ftpost_field using: 'BKPF-BUKRS' p_compcode, "Company Cd
'BKPF-WAERS' p_currency, "Doc Currency
'BKPF-BLART' p_doctyp, "Doc Type
'BKPF-BLDAT' l_docdate, "Doc Date
'BKPF-BUDAT' l_postdate, "Posting Dt
'BKPF-BKTXT' p_doctxt, "Header Text
'BKPF-XBLNR' p_ref, "Ref Doc
'RF05A-AUGTX' 'Test'. "Clearing item text
*creditnote to your own
*debit to customer but sometimes you post credit
*payor-vendor +ve payee-customer -ve
i_ftpost-count = 0.
endform. " f_create_document_header
&----
*& Form ftpost_field
&----
text
----
-->P_1045 text
-->P_PA_BUKRS text
----
form ftpost_field using field_name type any
field_value type any.
i_ftpost-fnam = field_name.
i_ftpost-fval = field_value.
append i_ftpost.
endform. " ftpost_field
&----
*& Form f_create_document_items
&----
text
----
--> p1 text
<-- p2 text
----
form f_create_document_items .
*concatenate i_splitinput
i_ftclear-agkoa = 'D'."D-cust, v-vend
i_ftclear-agkon = '1041048'."cust/ven acct
i_ftclear-agbuk = i_splitinput-compcode.
i_ftclear-xnops = 'X'.
i_ftclear-xfifo = space.
i_ftclear-agums = space.
i_ftclear-avsid = space.
i_ftclear-selfd = 'BELNR'.
i_ftclear-selvon = i_splitinput-reference.
i_ftclear-selbis = 'Test'.
collect i_ftclear.clear i_ftclear.
i_ftclear-selvon = '101002'.
i_ftclear-selbis = '101002'.
append i_ftclear.
i_ftpost-stype = 'P'. "Details
i_ftpost-count = i_ftpost-count + 1.
perform ftpost_field using: 'RF05A-NEWBS' '15', "Post Key
'RF05A-NEWKO' '1071990', "GL Account
'BSEG-WRBTR' '299', "DC Amount
'BSEG-SGTXT' 'SAN'. "Item Text
'BSEG-ZUONR' i_post-merchant_id.
*lt_ftclear-selvon = p_doc2.
*lt_ftclear-selbis = p_doc2.
*APPEND lt_ftclear.
endform. " f_create_document_items
&----
*& Form f_post_gl_document
&----
text
----
--> p1 text
<-- p2 text
----
form f_post_gl_document .
refresh i_blntab.
clear i_blntab.
call function 'POSTING_INTERFACE_CLEARING'
exporting
i_auglv = 'UMBUCHNG'
i_tcode = 'FB05'
I_SGFUNCT = ' '
I_NO_AUTH = ' '
importing
e_msgid = v_msgid
e_msgno = v_msgno
e_msgty = v_msgty
e_msgv1 = v_msgv1
e_msgv2 = v_msgv2
e_msgv3 = v_msgv3
e_msgv4 = v_msgv4
e_subrc = g_subrc
tables
t_blntab = i_blntab
t_ftclear = i_ftclear
t_ftpost = i_ftpost
t_fttax = i_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-subrc <> 0.
v_message = 'Posting Interface Error.'.
endif.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
id = v_msgid
lang = sy-langu
no = v_msgno
v1 = v_msgv1
v2 = v_msgv2
v3 = v_msgv3
v4 = v_msgv4
IMPORTING
msg = v_message
EXCEPTIONS
not_found = 1
OTHERS = 2.
WRITE : V_MESSAGE.
endform. " f_post_gl_document
&----
*& Form f_posting_interface_end
&----
text
----
--> p1 text
<-- p2 text
----
form f_posting_interface_end .
call function 'POSTING_INTERFACE_END'
exporting
i_bdcimmed = ' '
exceptions
session_not_processable = 1
others = 2.
if sy-subrc <> 0.
endif.
endform. " f_posting_interface_end
Thanks in advance.
‎2009 Mar 22 2:20 PM
Hi.
I think you should consider using this idoc...
[abap-example|https://forums.sdn.sap.com/click.jspa?searchID=-1&messageID=7093839]
‎2009 Mar 23 4:04 AM
Hi Erik,
Thanks for responding,appreciate it.
Does this IDOC do posting with clearing ? I will take a look at it .
Thanks.
‎2009 Mar 24 5:54 AM
Yes, my idoc example (messagetype: ACC_DOCUMENT) post a DZ document. And then you can run a automatic clearing using transaction F.13
‎2009 Mar 22 6:19 PM
- R u sure ur test data is a good data? or try with some other test data.
- if u hv chance, pls. see that, how the SAP is doing bhind the screen for that transaction ( iguess, already u copied the above code from stanadrd SAP transaction!)
- Is this prog. helps to u? RFBIBL00
thanq
‎2009 Mar 23 3:59 AM
Hi Abaper,
Thanks for responding.Truly appreciate it.
what do you think about my code for calling FB05? Have I done the right thing ? I have never used this FM before so a little confused.I also tried to use standard program RFBIBL00 and now I get a new error 'No batch input data for screen SAPDF05X 3100'.I have checked all the forums related to this error but nowhere did I find a good reply.Help me.
Here's my code for program:
*Session header
perform populate_xbgr00.
append xbgr00 to dataset.
write p_docdat to p_docdat mm/dd/yy.
write p_pstdat to p_pstdat mm/dd/yy.
*Document header
perform populate_xbbkpf using
i_splitinput-compcode
p_docdat
p_pstdat
p_doctyp
i_splitinput-currency
sum_inprec_hd_tmp-xblnr
'Test'.
append xbbkpf to dataset.
perform populate_xbbseg .
Edited by: abap78 on Mar 23, 2009 5:05 AM
‎2009 Mar 23 4:09 AM
Hi Abaper,
This is in continuation of my previous email,I am sending you my code.Please take a look and let me know your suggestions.Also can you please share with me your code if you have ever worked with FB05.
Also I have debugged and found that at the end on program SAFM05A screen 0733 ,the code enters document number BELNR and does okcode - /11. This takes to the screen SAPDF05X screen 3100 where it does try to save.I believe 3100 is a final screen according to the FM code but there is something I may not be passing which is not allowing it to save.
*Session header
perform populate_xbgr00.
append xbgr00 to dataset.
write p_docdat to p_docdat mm/dd/yy.
write p_pstdat to p_pstdat mm/dd/yy.
*Document header
perform populate_xbbkpf using
i_splitinput-compcode
p_docdat
p_pstdat
p_doctyp
i_splitinput-currency
sum_inprec_hd_tmp-xblnr
'Test'.
append xbbkpf to dataset.
*bbseg bselk and bselp
perform populate_xbbseg .
*********forms
form populate_xbgr00 .
move '0' to xbgr00-stype.
move 'zsan' to xbgr00-group.
move sy-mandt to xbgr00-mandt.
move sy-uname to xbgr00-usnam.
move 'X' to xbgr00-xkeep.
move space to xbgr00-xkeep.
move '/' to xbgr00-nodata.
endform. " populate_xbgr00
form populate_xbbkpf using p1 p2 p3 p4 p5 p7.
move '1' to xbbkpf-stype.
move 'FB05' to xbbkpf-tcode.
move p2 to xbbkpf-bldat.
move p4 to xbbkpf-blart.
move p1 to xbbkpf-bukrs.
move p3 to xbbkpf-budat.
move '/' to xbbkpf-monat.
move p5 to xbbkpf-waers.
move '/' to xbbkpf-kursf.
move '/' to xbbkpf-belnr.
move '/' to xbbkpf-wwert.
move p6 to xbbkpf-xblnr.
move '/' to xbbkpf-bvorg.
move p7 to xbbkpf-bktxt.
move '/' to xbbkpf-pargb.
move 'UMBUCHNG' to xbbkpf-auglv.
endform.
form populate_xbbseg .
move '2' to xbbseg-stype.
move 'BBSEG' to xbbseg-tbnam.
move '15' to xbbseg-newbs.
move '100' to xbbseg-wrbtr.
move 'Assign' to xbbseg-zuonr.
move 'Itemtext' to xbbseg-sgtxt.
move I_SPLITINPUT-CLEARINGACCT to xbbseg-newko. "G/L
append xbbseg to dataset.
xbselk-stype = '2'.
xbselk-agkon = 'CUST0010'.
xbselk-agbuk = i_splitinput-compcode.
xbselk-agkoa = 'K'.
xbselk-sende = '/'.
xbselk-tbnam = 'BSELK'.
XBSELK-XNOPS = 'X'.
append xbselk to dataset.
xbselp-stype = '2'.
xbselp-feldn_1 = 'BELNR'.
xbselp-slvon_1 = i_splitinput-reference.
xbselp-slbis_1 = 'Test'.
xbselp-tbnam = 'BSELP'.
append xbselp to dataset.
endform
Edited by: abap78 on Mar 23, 2009 5:10 AM
‎2009 Mar 22 7:52 PM
Hello
You may have a look at report RFCCSSTT ( Payment Cards: Execute Settlement ; transaction FCC1 ) which uses the fm POSTING_INTERFACE_CLEARING for the settlement of credit card related open items.
Regards
Uwe