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

BAPI FOR FB50

Former Member
0 Likes
1,279

HI FREINDS,

CAN BODY PLEASE GIVE SOME EXAMPLE CODE CONTAINS BAPI OR BDC FOR FB50 TCODE.........

REGARDS,

IMRAN

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
788

HI FREINDS,

i want reports using BAPi ot BDC for tcode FB50.......................

Regards,

Imran

5 REPLIES 5
Read only

Former Member
0 Likes
789

HI FREINDS,

i want reports using BAPi ot BDC for tcode FB50.......................

Regards,

Imran

Read only

0 Likes
788

Hi,

i think u can use the bapi 'BAPI_ACC_GL_POSTING_POST'.

and i think you can also write a bdc in your own bapi too.

<b>Reward points</b>

Regards

Read only

0 Likes
788

hi skk,

but please give me sample report if u have.......

Regards,

Imran

Read only

0 Likes
788

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.

Look at the example code for that.......

<b>Reward points</b>

Regards