cancel
Showing results for 
Search instead for 
Did you mean: 

Transfer posting with clearing

Former Member
0 Kudos

Hi,

I have a requirement where in the transfer posting with clearing is to implemented. I am aware that POSTING_INTERFACE_CLEARING can be used. But my requirement is to use only BAPI. Can BAPI_ACC_DOCUMENT_POST be used for this? I have tried using it, but it isnt working. Any pointers?

Thanks,

Shruti

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Check this links.........

******************************************

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.

Message was edited by: KDeepak