‎2007 Aug 30 8:41 PM
I am trying to post documents in FBS1 transaction using the Function module "<b>POSTING_INTERFACE_DOCUMENT</b>".
However every time it is reading only the first line item and not proceeding further...
Let me know how to fix this one. thank you. Below is my code.
loop at gt_document into wa_document.
refresh gt_ftpost.
perform start_posting_interface.
* ****** Header Data
gt_ftpost-stype = 'K'.
gt_ftpost-count = 1.
clear: l_bldat,
l_stodt.
write wa_document-bldat to l_bldat mm/dd/yyyy.
write wa_document-stodt to l_stodt mm/dd/yyyy.
perform set_fields using: 'BKPF-BLDAT' l_bldat,
'BKPF-BLART' wa_document-blart,
'BKPF-BUKRS' wa_document-bukrs,
'BKPF-BUDAT' l_bldat,
'BKPF-WAERS' wa_document-waers,
'BKPF-KURSF' wa_document-kursf,
'BKPF-XBLNR' wa_document-belnr,
'BKPF-BKTXT' 'TEST',
'BKPF-STODT' l_stodt,
'BKPF-STGRD' wa_document-stgrd.
gt_ftpost-stype = 'P' .
gt_ftpost-count = 1.
perform set_fields using: 'RF05A-NEWBS' wa_document-bschl,
'RF05A-NEWKO' wa_document-hkont,
'BSEG-WRBTR' wa_items-wrbtr,
'COBL-GSBER' wa_items-gsber,
'COBL-PRCTR' wa_items-prctr,
'BSEG-DMBTR' wa_items-dmbtr,
'BSEG-ZUONR' wa_items-zuonr,
'BSEG-SGTXT' 'Test'.
gt_ftpost-stype = 'P' .
gt_ftpost-count = 3.
perform set_fields using: 'RF05A-NEWBS' wa_document-bschl,
'RF05A-NEWKO' wa_document-hkont,
'BSEG-WRBTR' wa_items-wrbtr,
'COBL-GSBER' wa_items-gsber,
'COBL-PRCTR' wa_items-prctr,
'BSEG-DMBTR' wa_items-dmbtr,
'BSEG-ZUONR' wa_items-zuonr,
'BSEG-SGTXT' 'Test'.
call function 'POSTING_INTERFACE_DOCUMENT'
exporting
i_tcode = pv_tcode
i_sgfunct = 'C'
importing
e_msgid = gv_msgid
e_msgno = gv_msgno
e_msgty = gv_msgty
e_msgv1 = gv_msgv1
e_msgv2 = gv_msgv2
e_msgv3 = gv_msgv3
e_msgv4 = gv_msgv4
e_subrc = gv_subrc
tables
t_blntab = gt_blntab
t_ftpost = gt_ftpost
t_fttax = gt_fttax
exceptions
account_missing = 1
company_code_missing = 2
posting_key_invalid = 3
posting_key_missing = 4
record_type_invalid = 5
transaction_code_invalid = 6
amount_format_error = 7
too_many_line_items = 8
company_code_invalid = 9
screen_not_found = 10
no_authorization = 11
others = 12.
perform end_posting_interface.
endloop.
‎2007 Aug 30 8:59 PM
Is the count in the line item 2 making any error.It was supoosed to be 2 instead of 3 to field gt_ftpost-count .
Also check the test data.
-Kriss
‎2007 Aug 30 10:18 PM
Try sticking a break-point in before the first "call function" and then break > at statement > call transaction ... when it hits the call (a) see what's in the BDCDATA internal table and, if OK, (b) change the call mode to "A" (if you can) in order to watch the FBS1 screens come up. And, as noted above, the "gt_ftpost-count = 3." line looks like it should be "gt_ftpost-count = 2.".