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.