Application Development 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: 

BAPI in FI

Former Member
0 Kudos

Hi all,

Please provide me any sample code available for upload of any FI module data through BAPI.Also, provide any good links for study..

Responses will be be immediately rewarded..

thanks

3 REPLIES 3

Former Member
0 Kudos

Hi,

Look at the following link you will find the other links and BAPI sample code for posting Accounting documents.

Thanks,

If this helps you reward with poinys.

Former Member
0 Kudos

hello Arun

hope this helps...

DATA :

ac LIKE bapiacgl09 OCCURS 0 WITH HEADER LINE,

ar LIKE bapiacar09 OCCURS 0 WITH HEADER LINE,

ca LIKE bapiaccr09 OCCURS 0 WITH HEADER LINE,

return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.

DATA :

dh LIKE bapiache09,

time LIKE sy-uzeit,

xx LIKE ca-amt_doccur.

DATA : BEGIN OF xdocuments OCCURS 0.

INCLUDE STRUCTURE acc_doc.

DATA : END OF xdocuments.

DATA : aworg LIKE acchd-aworg ,

awref LIKE acchd-awref .

DATA : answer.

CLEAR : dh, ac[], ca[].

CLEAR : xdocuments[].

CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'

EXPORTING

defaultoption = 'Y'

textline1 = text-009

textline2 = text-001

titel = text-003

IMPORTING

answer = answer.

CHECK answer EQ 'J'.

PERFORM popup_for_date.

CALL METHOD gv_grid1->get_selected_rows

IMPORTING

et_index_rows = rw_01.

LOOP AT rw_01 INTO ws_01.

READ TABLE gt_head INDEX ws_01-index .

CHECK gt_head-status EQ 'X' .

CHECK gv_answ NE 'C'.

PERFORM call_bapi.

CHECK dh IS NOT INITIAL AND ar[] IS NOT INITIAL AND

ca[] IS NOT INITIAL.

PERFORM belge_olustur.

PERFORM belege_modify.

ENDLOOP.

ENDFORM. " kayit_yarat

&----


*& Form popup_for_date

&----


FORM popup_for_date .

CALL FUNCTION 'POPUP_TO_GET_DATE'

EXPORTING

fieldname = 'BUDAT'

tabname = 'BKPF'

titel = ''

valuein = sy-datum

IMPORTING

answer = gv_answ

valueout = gv_recdate.

ENDFORM. " popup_for_date

&----


*& Form call_bapi

&----


FORM call_bapi .

*p_rdate = sy-datum.

REFRESH : ar[].

time = sy-uzeit.

CONCATENATE sy-repid '__' INTO awref.

CONCATENATE sy-datum(4) time INTO aworg .

CONCATENATE awref p_gjahr time INTO dh-obj_key .

  • CONCATENATE 'MYT' sy-mandt INTO dh-obj_sys.

CALL FUNCTION 'OWN_LOGICAL_SYSTEM_GET'

IMPORTING

own_logical_system = dh-obj_sys

EXCEPTIONS

own_logical_system_not_defined = 1

OTHERS = 2.

dh-obj_type = 'ZBKPF'.

dh-bus_act = 'RFBU'.

dh-username = sy-uname.

dh-comp_code = p_bukrs.

dh-doc_date = gv_recdate.

dh-pstng_date = gv_recdate.

dh-doc_type = 'MA'.

    • BAPI item bilgileri

ar-itemno_acc = 1.

ar-customer = gt_head-kunnr.

ar-comp_code = p_bukrs.

ar-item_text = text-011.

ar-tax_code = 'A3'.

APPEND ar.

CLEAR ar.

xx = gt_head-vftut.

ca-itemno_acc = 1.

ca-currency = p_waers

ca-amt_doccur = xx.

APPEND ca.

CLEAR ca.

  • 2. kisim....

ac-itemno_acc = 2.

ac-comp_code = dh-comp_code.

ac-pstng_date = dh-pstng_date.

ac-gl_account = '6020020001'.

ac-item_text = text-900.

ac-tax_code = 'A3'.

APPEND ac.

CLEAR ac.

xx = xx * -1 .

ca-itemno_acc = 2.

ca-currency = p_waers.

ca-amt_doccur = xx.

APPEND ca.

CLEAR ca.

ENDFORM. " call_bapi

&----


*& Form belge_olustur

&----


FORM belge_olustur .

CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'

EXPORTING

documentheader = dh

IMPORTING

obj_type = dh-obj_type

obj_key = dh-obj_key

obj_sys = dh-obj_sys

TABLES

accountgl = ac

currencyamount = ca

accountreceivable = ar

return = return.

LOOP AT return WHERE type = 'E'.

IF sy-tabix EQ 1.

LEAVE TO LIST-PROCESSING.

WRITE : / 'BELGE YARATILIRKEN OLUSAN HATALAR'

COLOR COL_NEGATIVE.

SKIP 1.

ENDIF.

WRITE : / return-message COLOR COL_NEGATIVE.

ENDLOOP.

IF sy-subrc NE 0 .

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = 'X'

IMPORTING

return = return.

ENDIF.

ENDFORM. " belge_olustur

&----


*& Form belege_modify

&----


  • text

----


FORM belege_modify .

  • Yaratilan FI belgesinin ekrana yazdirilmasi

CALL FUNCTION 'AC_DOCUMENT_RECORD'

EXPORTING

i_awtyp = 'ZBKPF'

i_awref = awref

i_aworg = aworg

x_dialog = ' '

TABLES

t_documents = xdocuments

EXCEPTIONS

no_reference = 1

no_document = 2

OTHERS = 3.

LOOP AT xdocuments .

SELECT SINGLE * FROM bkpf WHERE bukrs = xdocuments-bukrs

AND belnr = xdocuments-docnr

AND gjahr = xdocuments-ac_gjahr

AND usnam = sy-uname .

CHECK sy-subrc EQ 0 .

gt_head-belege = xdocuments-docnr.

EXIT.

ENDLOOP .

ENDFORM. " belege_modify

Former Member
0 Kudos

hi

good

go through this link

http://www.planetsap.com/LIST_ALL_BAPIs.htm

thanks

mrutyun

Message was edited by: Mrutyunjaya Tripathy