Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

posting key

Former Member
0 Likes
681

Hi,

I've a problem creating a FI-DOCUMENT using BAPI_ACC_DOUMENT_POST I can't find BSCHL ( posting key )

and I need to pass that parameter.

Can you help me?

Thanks

Alice

4 REPLIES 4
Read only

Former Member
0 Likes
632

Hi,

Look at the sample code....................

loop at podoc_it.

clear: offset_it, it_hdr, it_gl, it_curr.

refresh: it_hdr, it_gl, it_curr.

read table offset_it with key bukrs = podoc_it-bukrs

saknr = podoc_it-hkont.

  • Header Data

it_hdr-comp_code = podoc_it-bukrs.

it_hdr-doc_date = sy-datum.

it_hdr-pstng_date = sy-datum.

it_hdr-doc_type = podoc_it-blart.

it_hdr-ref_doc_no = bkpf_it-xblnr.

it_hdr-username = sy-uname.

it_hdr-bus_act = 'RFBU'.

IF podoc_it-shkzg = 'S'.

  • First Item

  • Account number

it_gl-itemno_acc = '1'.

it_gl-gl_account = podoc_it-hkont.

it_gl-item_text = podoc_it-sgtxt.

it_gl-fis_period = v_monat.

it_gl-fisc_year = v_gjahr.

it_gl-acct_key = 'A00'.

APPEND it_gl.

  • Second Item

  • Account number

it_gl-itemno_acc = '2'.

it_gl-gl_account = offset_it-osaknr.

it_gl-item_text = podoc_it-sgtxt.

it_gl-fis_period = v_monat.

it_gl-fisc_year = v_gjahr.

it_gl-acct_key = 'A00'.

APPEND it_gl.

  • Set amount

it_curr-itemno_acc = '1'.

it_curr-currency = podoc_it-waers.

it_curr-amt_doccur = podoc_it-wrbtr.

APPEND it_curr.

it_curr-itemno_acc = '2'.

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.

  • First Item

  • Account number

it_gl-itemno_acc = '1'.

it_gl-gl_account = podoc_it-hkont.

it_gl-item_text = podoc_it-sgtxt.

it_gl-fis_period = v_monat.

it_gl-fisc_year = v_gjahr.

it_gl-acct_key = 'A00'.

APPEND it_gl.

  • Second Item

  • Account number

it_gl-itemno_acc = '2'.

it_gl-gl_account = offset_it-osaknr.

it_gl-item_text = podoc_it-sgtxt.

it_gl-fis_period = v_monat.

it_gl-fisc_year = v_gjahr.

it_gl-acct_key = 'A00'.

APPEND it_gl.

  • Set amount

it_curr-itemno_acc = '1'.

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.

it_curr-itemno_acc = '2'.

it_curr-currency = podoc_it-waers.

it_curr-amt_doccur = podoc_it-wrbtr.

APPEND it_curr.

ENDIF.

  • check posting

CALL FUNCTION 'BAPI_ACC_DOCUMENT_CHECK'

EXPORTING

documentheader = it_hdr

TABLES

accountgl = it_gl

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

currencyamount = it_curr

return = t_result.

*

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

move: podoc_it-bukrs to doc_it-bukrs,

podoc_it-belnr to doc_it-belnr,

podoc_it-gjahr to doc_it-gjahr,

podoc_it-shkzg to doc_it-shkzg,

podoc_it-hkont to doc_it-hkont,

offset_it-osaknr to doc_it-osaknr.

ENDIF.

  • Print Message

LOOP AT t_result.

  • WRITE: t_result-message.

  • Get Number

IF t_result-id = 'RW' AND

t_result-number = '605'.

belnr = t_result-message_v2(10).

gjahr = t_result-message_v2+14(4).

ENDIF.

move: belnr to doc_it-obelnr,

gjahr to doc_it-ogjahr.

ENDLOOP.

append doc_it.

clear: doc_it, podoc_it.

endloop.

loop at doc_it.

write:/ doc_it-bukrs,

doc_it-belnr,

doc_it-gjahr,

doc_it-shkzg,

doc_it-hkont,

doc_it-osaknr,

doc_it-obelnr,

doc_it-ogjahr.

endloop.

Thanks.

If this helps you reward with points.

Read only

0 Likes
632

So I should use bapi field :

<b>accountgl-acct_key</b>

But it's different from BSEG-BSCHL ,

I mean that is char 3, while this is char 2.

Thanks

a.

Read only

Former Member
0 Likes
632

I think this BAPI determines the posting keys based on the parameters passed to it (AR, AP or GL postings).

Rob

Read only

Former Member
0 Likes
632

Bapi determines the posting key internally. If you are trying to post keys for debit or credit memo's etc then i dont think the BAPI is a good choice. BDC would be the best way to post the posting keys but have to check for all the dynamic screens.