05-19-2006 5:38 PM
I'm using BAPI BAPI_ACC_DOCUMENT_POST to post FI documents.
After posting I went to FB03 to see the Posted document.
When we double click the Posted Line item it takes us to a detail screen where we have a button "More" on the main screen and not on the Tool Bar. This more option pops up a screen that has more details like Asset, Profit Center, Cost center, Personnel Number.
What field shall I populate whil calling the Bapi so that I can see the Personnel Number field filled up. Right now I'm trying to pass GL, Accounts Receivable & Accounts Payable internal tables... Any help is appreciate...
05-19-2006 5:55 PM
Vinod,
The 'More Data' button shows data specific to the line item in the posting document.You need to link the item number ITEMNO_ACC passed through the ACCOUNTGL uniquely in the additional table structures provided which are CONTRACTITEM,CRITERIA and VALUEFIELD.
What i suggest is that use the Where used list on the FM BAPI_ACC_DOCUMENT_POST and see a case in which these are populated to get an idea of how this can be done.
<i>Reward helpful answers</i>
Cheers
Nishanth
05-19-2006 5:49 PM
That more button is related to 'COPA' and you need to fill 'CRITERIA' and 'VALUEFIELD' structures for that. Read the documentation for these two tables parameters.
05-19-2006 5:55 PM
Vinod,
The 'More Data' button shows data specific to the line item in the posting document.You need to link the item number ITEMNO_ACC passed through the ACCOUNTGL uniquely in the additional table structures provided which are CONTRACTITEM,CRITERIA and VALUEFIELD.
What i suggest is that use the Where used list on the FM BAPI_ACC_DOCUMENT_POST and see a case in which these are populated to get an idea of how this can be done.
<i>Reward helpful answers</i>
Cheers
Nishanth
05-19-2006 7:35 PM
I tried to find as such but of no use...
Posting that I'm doing contains just 2 line items and of which only line item 1 would have pernr value...
so I tried to populate the Criteria table like this
i_crit-itemno_acc = '0000000001'.
i_crit-fieldname = 'PERNR'.
i_crit-character = '00000005'.
APPEND i_value.
CLEAR i_value.
and BAPI is returning error message
Characteristic PERNR is not known in line item 0000000001
Error in document: BKPFF $ SAPD10900
Any suggestions....
05-19-2006 7:59 PM
Hi Vinod,
Would this PERNR line item have an amount?
If so, it is necessary to fill also the CURRENCYAMT internal table and the ITEMNO_ACC should be the same as in the I_CRIT Internal Table.
I hope I had helped you.
Daniel Carvalho.
05-19-2006 8:15 PM
Yes PERNR has some cost to it ... so we are filling CURRENCYAMT internal table too..
Loop at main internal table.
ITEMNO_ACC = counter.
Populated, GL,Customer,Vendor, Currency & finally Criteria Tables with same counter.
incrimented the counter
Endloop.
BAPI to post account docuement
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
documentheader = k_head
TABLES
accountgl = i_glitm
accountreceivable = i_cusitm
accountpayable = i_venitm
currencyamount = i_curitm
criteria = i_crit
return = i_ret2.
06-02-2006 11:55 AM
Vinod,
For each entry (that will be related to a line item in the final document), you need to assign a different counter. For example, a customer invoice can be seen in FB03 transaction like this:
Item PostKey Account Amount
01 01 <Customer No.> N.NN
02 50 <GL Acc. N.NN
So, you need to:
a) Start counter = 1
b) Populate CUSTOMER,
c) Populate CURRENCY,
d) Increment counter
b) Populate GL ACCOUNT,
c) Populate CURRENCY.
I hope I had helped you.
Daniel.
05-19-2006 6:06 PM
Hi,
Look at the sample code................
LOOP at podoc_it.
CLEAR: offset_it, it_gl, it_curr, er_podoc,
act_rec, tracc_it, pdoc_it, doc_it.
ON CHANGE of podoc_it-belnr.
line_item = 0.
ENDON.
READ TABLE offset_it with key bukrs = podoc_it-bukrs
saknr = podoc_it-hkont.
READ TABLE tracc_it with key bukrs = podoc_it-bukrs
belnr = podoc_it-belnr
gjahr = podoc_it-gjahr
binary search.
IF NOT offset_it-osaknr is initial and
tracc_it-obelnr = ''.
SELECT single * from SKB1
where bukrs = podoc_it-bukrs and
saknr = offset_it-osaknr.
IF sy-subrc = 0.
MOVE: podoc_it-bukrs to doc_it-bukrs,
podoc_it-belnr to doc_it-belnr,
podoc_it-gjahr to doc_it-gjahr,
v_blart to doc_it-blart,
pdoc_it-blart to doc_it-blart,
podoc_it-shkzg to doc_it-shkzg,
podoc_it-waers to doc_it-waers,
podoc_it-wrbtr to doc_it-wrbtr,
podoc_it-hkont to doc_it-hkont,
offset_it-osaknr to doc_it-osaknr,
podoc_it-error to doc_it-error.
pdoc_it-bukrs = podoc_it-bukrs.
pdoc_it-belnr = podoc_it-belnr.
pdoc_it-gjahr = podoc_it-gjahr.
pdoc_it-blart = podoc_it-blart.
pdoc_it-xblnr = podoc_it-xblnr.
pdoc_it-buzei = podoc_it-buzei.
pdoc_it-koart = podoc_it-koart.
pdoc_it-sgtxt = podoc_it-sgtxt.
pdoc_it-hkont = podoc_it-hkont.
pdoc_it-kunnr = podoc_it-kunnr.
pdoc_it-shkzg = podoc_it-shkzg.
pdoc_it-mwskz = podoc_it-mwskz.
pdoc_it-waers = podoc_it-waers.
pdoc_it-wrbtr = podoc_it-wrbtr.
APPEND: pdoc_it, doc_it.
line_item = line_item + 1.
CLEAR v_bktxt.
CONCATENATE podoc_it-belnr podoc_it-bukrs
podoc_it-gjahr into v_bktxt.
Header Data " Sending comp code
it_hdr-comp_code = podoc_it-bukrs.
it_hdr-doc_date = p_podt.
it_hdr-pstng_date = p_podt.
it_hdr-doc_type = v_blart.
it_hdr-ref_doc_no = podoc_it-belnr.
it_hdr-username = sy-uname.
it_hdr-HEADER_TXT = v_bktxt.
it_hdr-bus_act = 'RFBU'.
APPEND it_hdr.
IF podoc_it-koart = 'D'.
CLEAR: v_sgtxt.
CONCATENATE pdoc_it-belnr pdoc_it-buzei into v_sgtxt.
IF podoc_it-shkzg = 'S'.
line_item = line_item + 1.
First Item
Account receivable
act_rec-itemno_acc = line_item.
act_rec-CUSTOMER = podoc_it-kunnr.
act_rec-gl_account = podoc_it-hkont.
act_rec-BUS_AREA = podoc_it-gsber.
act_rec-item_text = v_sgtxt.
APPEND act_rec.
Set amount
it_curr-itemno_acc = line_item.
it_curr-currency = podoc_it-waers.
it_curr-amt_doccur = podoc_it-wrbtr.
it_curr-amt_doccur = it_curr-amt_doccur * -1.
APPEND it_curr.
ELSE.
line_item = line_item + 1.
First Item
Account number
act_rec-itemno_acc = line_item.
act_rec-CUSTOMER = podoc_it-kunnr.
act_rec-gl_account = podoc_it-hkont.
act_rec-BUS_AREA = podoc_it-gsber.
act_rec-item_text = v_sgtxt.
APPEND act_rec.
it_curr-itemno_acc = line_item.
it_curr-currency = podoc_it-waers.
it_curr-amt_doccur = podoc_it-wrbtr.
APPEND it_curr.
ENDIF.
ELSE.
CLEAR: v_sgtxt.
CONCATENATE pdoc_it-belnr pdoc_it-buzei into v_sgtxt.
IF podoc_it-shkzg = 'S'.
line_item = line_item + 1.
First Item
Account number
it_gl-itemno_acc = line_item.
it_gl-gl_account = offset_it-osaknr.
it_gl-item_text = v_sgtxt.
it_gl-fis_period = v_monat.
it_gl-fisc_year = v_gjahr.
it_gl-tax_code = podoc_it-mwskz.
it_gl-acct_key = 'A00'.
APPEND it_gl.
Set amount
it_curr-itemno_acc = line_item.
it_curr-currency = podoc_it-waers.
it_curr-amt_doccur = podoc_it-wrbtr.
it_curr-amt_doccur = it_curr-amt_doccur * -1.
APPEND it_curr.
ELSE.
line_item = line_item + 1.
First Item
Account number
it_gl-itemno_acc = line_item.
it_gl-gl_account = offset_it-osaknr.
it_gl-item_text = v_sgtxt.
it_gl-fis_period = v_monat.
it_gl-fisc_year = v_gjahr.
it_gl-tax_code = podoc_it-mwskz.
it_gl-acct_key = 'A00'.
APPEND it_gl.
it_curr-itemno_acc = line_item.
it_curr-currency = podoc_it-waers.
it_curr-amt_doccur = podoc_it-wrbtr.
APPEND it_curr.
ENDIF.
ENDIF.
ELSE.
eflag = 'X'.
MOVE: podoc_it-bukrs to doc_it-bukrs,
podoc_it-belnr to doc_it-belnr,
podoc_it-gjahr to doc_it-gjahr,
v_blart to doc_it-blart,
pdoc_it-blart to doc_it-blart,
podoc_it-shkzg to doc_it-shkzg,
podoc_it-waers to doc_it-waers,
podoc_it-wrbtr to doc_it-wrbtr,
podoc_it-hkont to doc_it-hkont,
offset_it-osaknr to doc_it-osaknr.
doc_it-er_gl = 'X'.
MOVE: podoc_it-belnr to er_podoc-belnr.
er_podoc-er_doc = 'X'.
APPEND doc_it.
COLLECT er_podoc.
ENDIF.
ELSE.
eflag = 'X'.
MOVE: podoc_it-bukrs to doc_it-bukrs,
podoc_it-belnr to doc_it-belnr,
podoc_it-gjahr to doc_it-gjahr,
v_blart to doc_it-blart,
pdoc_it-blart to doc_it-blart,
podoc_it-shkzg to doc_it-shkzg,
podoc_it-waers to doc_it-waers,
podoc_it-wrbtr to doc_it-wrbtr,
podoc_it-hkont to doc_it-hkont,
offset_it-osaknr to doc_it-osaknr.
doc_it-error = 'X'.
MOVE: podoc_it-belnr to er_podoc-belnr.
er_podoc-er_doc = 'X'.
APPEND doc_it.
COLLECT er_podoc.
ENDIF.
AT END OF belnr.
IF eflag = ''.
REFRESH t_result. CLEAR t_result.
IF NOT it_gl[] is initial and
NOT it_curr[] is initial and
NOT it_hdr[] is initial.
check posting
CALL FUNCTION 'BAPI_ACC_DOCUMENT_CHECK'
EXPORTING
documentheader = it_hdr
TABLES
accountgl = it_gl
ACCOUNTRECEIVABLE = act_rec
currencyamount = it_curr
return = t_result.
LOOP AT t_result WHERE ( type = 'E' OR
type = 'A' ).
EXIT.
ENDLOOP.
IF sy-subrc <> 0.
REFRESH t_result.
CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'
EXPORTING
documentheader = it_hdr
TABLES
accountgl = it_gl
ACCOUNTRECEIVABLE = act_rec
currencyamount = it_curr
return = t_result.
*
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
ENDIF.
Print Message
LOOP AT t_result.
READ TABLE pdoc_it with key bukrs = podoc_it-bukrs
gjahr = podoc_it-gjahr
belnr = podoc_it-belnr.
Get Doc Number / Error msg
IF t_result-type = 'S' and
t_result-id = 'RW' AND
t_result-number = '605'.
pdoc_it-obelnr = t_result-message_v2(10).
pdoc_it-ogjahr = t_result-message_v2+14(4).
pdoc_it-msg = t_result-message.
pdoc_it-val_rec = 'X'.
CLEAR flag.
ELSE.
flag = 'X'.
ENDIF.
MODIFY pdoc_it transporting obelnr ogjahr msg
er_rec val_rec
where bukrs = podoc_it-bukrs and
gjahr = podoc_it-gjahr and
belnr = podoc_it-belnr.
ENDLOOP.
IF flag = 'X'.
CLEAR t_result.
READ TABLE t_result INDEX 2.
pdoc_it-msg = t_result-message.
pdoc_it-er_rec = 'X'.
pdoc_it-val_rec = 'X'.
append doc_it.
ENDIF.
MODIFY pdoc_it transporting obelnr ogjahr msg
er_rec val_rec
where bukrs = podoc_it-bukrs and
gjahr = podoc_it-gjahr and
belnr = podoc_it-belnr.
APPEND doc_it.
ENDLOOP.
ENDIF.
CLEAR: pdoc_it, it_hdr, it_gl, it_curr, act_rec, t_result, eflag.
REFRESH: it_hdr, it_gl, it_curr, act_rec, t_result.
ENDAT.
CLEAR: podoc_it.
ENDLOOP.
Thanks.
If this helps you reward with points.