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 for f-44

Former Member
0 Kudos

Hi....

I'm using BAPI_ACC_DOCUMENT_POST to clear vendor open items for the T-code f-44.The following is my below code and it seems to be going on fine but the data in the table bsak(Vendor accounts cleared items) is not updated..with the concern vendor number and documnet no....more over when i'm checking this FM the document post perform is displaying an erro RW with number 604.......in the return internal table.....what wud be the problem for this i'm posting my coding below plz suggest me for this......Is the Bapi correct for the concern document......

&----


*& Report Z_TEST_F44 *

*& *

&----


*& *

*& *

&----


REPORT z_test_f44 NO STANDARD PAGE HEADING

LINE-COUNT 65

LINE-SIZE 132

MESSAGE-ID zfi.

*tables: bsik.

TYPES: BEGIN OF tp_tab_bsik,

bukrs TYPE bukrs,

lifnr TYPE lifnr,

gjahr TYPE gjahr,

budat TYPE budat,

bldat TYPE bldat,

blart TYPE blart,

bschl TYPE bschl,

END OF tp_tab_bsik.

DATA: l_tab_bsik TYPE tp_tab_bsik OCCURS 10.

DATA: l_wa_tab_bsik TYPE tp_tab_bsik.

DATA:BEGIN OF it_account_tab OCCURS 0,

line(255),

END OF it_account_tab.

DATA:

g_fis_period(2) TYPE c,

g_clear_date(10) TYPE c,

g_accountno(10) TYPE c,

g_currencytype(3) TYPE c,

g_docno(10) TYPE c,

g_amount(13) TYPE c,

g_sign TYPE c,

g_pstkey(2) TYPE c,

g_companycode(4) TYPE c.

DATA:

it_error_acc_tab LIKE it_account_tab OCCURS 0 WITH HEADER LINE.

*include bdcrecxx.

--


Start of Selection Parameters--

SELECTION-SCREEN:BEGIN OF BLOCK blck01 WITH FRAME TITLE text-001.

PARAMETERS:

p_fname LIKE rlgrap-filename,

p_fserv LIKE rlgrap-filename.

SELECTION-SCREEN:END OF BLOCK blck01.

--


End of Selection Parameters--

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fname.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

program_name = syst-cprog

dynpro_number = syst-dynnr

field_name = 'DATASET'

IMPORTING

file_name = p_fname.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_fserv.

DATA:

l_pfad LIKE ibipparms-path.

CALL FUNCTION 'F4_FILENAME_SERVER'

EXPORTING

pfad = l_pfad

IMPORTING

file_name = p_fserv

EXCEPTIONS

no_file_on_server = 1

OTHERS = 2.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

--


START OF SELECTION--

START-OF-SELECTION.

PERFORM get_data_bsik.

PERFORM get_default_data. "Getting the default data

PERFORM get_input_data. "Uploading the file data

PERFORM format_input_data. "Formating the data

PERFORM process_data. "Posting using F-44(Bapi)

IF it_error_acc_tab[] IS INITIAL.

MESSAGE i001(ztest).

ENDIF.

END-OF-SELECTION.

--


End OF SELECTION--

&----


*& Form get_default_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_default_data.

ENDFORM. " get_default_data

&----


*& Form get_input_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_input_data.

DATA:

l_fname TYPE string,

l_dsn(128) TYPE c,

l_rec(80) TYPE c.

l_fname = p_fname.

IF NOT l_fname IS INITIAL.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = l_fname

filetype = 'ASC'

  • has_field_separator = 'X'

TABLES

data_tab = it_account_tab

EXCEPTIONS

file_open_error = 1

file_read_error = 2

no_batch = 3

gui_refuse_filetransfer = 4

invalid_type = 5

no_authority = 6

unknown_error = 7

bad_data_format = 8

header_not_allowed = 9

separator_not_allowed = 10

header_too_long = 11

unknown_dp_error = 12

access_denied = 13

dp_out_of_memory = 14

disk_full = 15

dp_timeout = 16

OTHERS = 17.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

ELSE.

BREAK-POINT.

l_dsn = p_fserv.

OPEN DATASET l_dsn FOR INPUT IN TEXT MODE ENCODING DEFAULT.

IF sy-subrc <> 0.

EXIT.

ENDIF.

READ DATASET l_dsn INTO l_rec.

APPEND it_account_tab.

WHILE sy-subrc <> 0.

READ DATASET l_dsn INTO l_rec.

APPEND it_account_tab.

ENDWHILE.

CLOSE DATASET l_dsn.

ENDIF.

ENDFORM. " get_input_data

&----


*& Form format_input_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM format_input_data.

SORT it_account_tab.

ENDFORM. " format_input_data

&----


*& Form process_data

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM process_data.

DATA:

l_documentheader LIKE bapiache09,

l_accountgl LIKE bapiacgl09 OCCURS 2 WITH HEADER LINE,

l_vendoritem LIKE bapiacap09 OCCURS 2 WITH HEADER LINE,

l_currencyamount LIKE bapiaccr09 OCCURS 2 WITH HEADER LINE,

l_currencytype LIKE bapiaccr09-currency_iso,

l_return LIKE bapiret2 OCCURS 5 WITH HEADER LINE,

l_obj_type LIKE bapiache02-obj_type,

l_obj_key LIKE bapiache02-obj_key,

l_obj_sys LIKE bapiache02-obj_sys.

LOOP AT it_account_tab.

CLEAR:

g_fis_period,

g_clear_date,

g_accountno,

g_amount,

g_sign,

l_documentheader,

l_vendoritem,

l_accountgl,

l_wa_tab_bsik,

l_currencyamount,

l_return.

REFRESH:l_vendoritem,

l_currencyamount,

l_return.

g_accountno = it_account_tab-line+0(10).

g_clear_date = it_account_tab-line+11(10).

g_fis_period = it_account_tab-line+22(2).

g_companycode = it_account_tab-line+25(4).

g_docno = it_account_tab-line+30(10).

g_pstkey = it_account_tab-line+41(2).

g_amount = it_account_tab-line+44(13).

g_currencytype = it_account_tab-line+58(3).

IF sy-subrc <> 0.

MOVE-CORRESPONDING it_account_tab TO it_error_acc_tab.

APPEND it_error_acc_tab.

CLEAR it_error_acc_tab.

CONTINUE.

ENDIF.

READ TABLE l_tab_bsik INTO l_wa_tab_bsik WITH KEY bukrs = g_companycode

lifnr = g_accountno.

l_documentheader-obj_type = 'BKPFF'.

l_documentheader-obj_key = sy-uzeit.

l_documentheader-obj_sys = 'ABAPEML2'.

l_documentheader-bus_act = 'RFBU'.

l_documentheader-ac_doc_no = g_accountno.

l_documentheader-username = sy-uname.

l_documentheader-comp_code = g_companycode.

l_documentheader-fis_period = g_fis_period(2).

l_documentheader-doc_date = g_clear_date.

l_documentheader-pstng_date = g_clear_date.

l_documentheader-fisc_year = l_wa_tab_bsik-gjahr.

l_documentheader-doc_type = l_wa_tab_bsik-blart.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

input = g_accountno

IMPORTING

output = g_accountno.

l_accountgl-itemno_acc = '2'.

l_accountgl-gl_account = g_accountno.

l_accountgl-comp_code = g_companycode.

l_accountgl-pstng_date = sy-datum.

l_accountgl-doc_type = l_wa_tab_bsik-blart.

l_accountgl-ac_doc_no = g_accountno.

APPEND l_accountgl.

l_vendoritem-itemno_acc = '2'.

l_vendoritem-vendor_no = g_accountno.

l_vendoritem-comp_code = g_companycode.

APPEND l_vendoritem.

l_currencyamount-itemno_acc = '2'.

l_currencyamount-currency_iso = g_currencytype.

l_currencyamount-amt_doccur = g_amount.

IF g_sign = '-'.

l_currencyamount-amt_doccur = l_currencyamount-amt_doccur * -1.

ENDIF.

APPEND l_currencyamount.

*CALL FUNCTION 'BAPI_ACC_GL_POSTING_POST'

CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'

EXPORTING

documentheader = l_documentheader

IMPORTING

obj_key = l_obj_key

TABLES

accountgl = l_accountgl

accountpayable = l_vendoritem

currencyamount = l_currencyamount

return = l_return.

IF l_obj_key NE '$'.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

ELSE.

MOVE-CORRESPONDING it_account_tab TO it_error_acc_tab.

APPEND it_error_acc_tab.

CLEAR it_error_acc_tab.

ENDIF.

ENDLOOP.

ENDFORM. "process_data

&----


*& Form get_data_bsik

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM get_data_bsik.

SELECT bukrs

lifnr

gjahr

budat

bldat

blart

bschl

FROM bsik INTO TABLE l_tab_bsik.

ENDFORM. " get_data_bsik

Points wud be surely awarded....................

4 REPLIES 4

Former Member
0 Kudos

hI,

check BAPI_AR_ACC_GETBALANCEDITEMS and its Documentations

<b>Reward points</b>

Regards

0 Kudos

hi kiran....

this bapi will get all the open items from <b>bsik</b> and will show us the open items but i want the bapi for clearing this open items and post it in the<b> bsak</b> table.And more over this is concerned with the Customer side ie bsad and bsid(clear items) tables.........Will this work?????????

Thanks.........

Former Member
0 Kudos

check in SE91 with class RW and numner 604.

its saying ---posting date is missing.

Regards

Prabhu

hstomar
Explorer
0 Kudos

hi Yonus,

I have got same requirement as yours.

Please tell me the solution you used.

My mail id: hstomar05@gmail.com.

Please help me