cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI/FM/User exit for F-27

karuna_gangireddy
Contributor
0 Kudos

Hi All,

I am looking for a either a BAPI/FM or a user exit which is similar to tcode F-27. The reason being is i want to run this tcode in background.

I have been looking around in SDN but did not find any helpful posts for F-27. Anyone out there has any idea or workaround that would really be helpful. Or is it possible for me to create a custom function module to achieve the same?

Thanks in advance,

Karuna.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

This Bapi BAPI_ACC_DOCUMENT_POST, posts all types of accounting documents. FB01 is the mother transaction for almost all F-* transactions.

Cheers.

karuna_gangireddy
Contributor
0 Kudos

Hi,

Thank you very much. I am trying to use it. this is how i am using:

________________________________________________________________________________________

DATA: ZFISCAL_PERIOD TYPE BAPI0002_4-FISCAL_PERIOD.

data: obj_type like bapiache02-obj_type,

obj_key like bapiache02-obj_key,

obj_sys like bapiache02-obj_sys,

documentheader like bapiache09,

accountgl like bapiacgl09 occurs 0 with header line,

currencyamount like bapiaccr09 occurs 0 with header line,

return like bapiret2 occurs 0 with header line,

extension1 like bapiextc occurs 0 with header line.

documentheader-username = sy-uname.

documentheader-header_txt = 'Test using BAPI'.

documentheader-comp_code = '0010'.

documentheader-doc_date = sy-datum.

documentheader-pstng_date = sy-datum.

documentheader-doc_type = 'DG'.

documentheader-ref_doc_no = 'Test using BAPI'.

documentheader-BUS_ACT = 'RFBU'.

documentheader-FISC_YEAR = '2009'.

documentheader-FIS_PERIOD = ZFISCAL_PERIOD.

currencyamount-itemno_acc = '1'.

currencyamount-currency = 'USD'.

currencyamount-amt_doccur = '101.00'.

append currencyamount.

currencyamount-itemno_acc = '2'.

currencyamount-currency = 'USD'.

currencyamount-amt_doccur = '-101.00'.

append currencyamount.

CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'

EXPORTING

DOCUMENTHEADER = documentheader

  • CUSTOMERCPD =

  • CONTRACTHEADER =

  • IMPORTING

  • OBJ_TYPE =

  • OBJ_KEY =

  • OBJ_SYS =

TABLES

  • ACCOUNTGL = accountgl

  • ACCOUNTRECEIVABLE =

  • ACCOUNTPAYABLE =

  • ACCOUNTTAX =

CURRENCYAMOUNT = currencyamount

  • CRITERIA =

  • VALUEFIELD =

  • EXTENSION1 =

RETURN = return

  • PAYMENTCARD =

  • CONTRACTITEM =

  • EXTENSION2 =

  • REALESTATE =

  • ACCOUNTWT =

.

if sy-subrc = 0.

WRITE 'SUCESS'.

else.

write 'NOT SUCCESS'.

endif.

_______________________________________________________________________________

When i am executing this i am getting 2 errors in RETURN:

1. Error in document: BKPFF $ ESRCLNT200

2. FI/CO interface: Inconsistent FI/CO document header data for updating

Can you please help me, if i am missing anything?

Thanks,

Karuna.

Former Member
0 Kudos

Hi,

The best way to determine the values needed to be sent to the BAPI is to first try and post a document using SE37 to execute the BAPI in test mode.

I am not sure if you will be able to post to a customer as in F-27 with this BAPI. I think you will only be able to post to GLs directly or with ref to a sales document. You can test this out as outlined above. will see if there is any other BAPI for this.

Your code is missing out on a lot things in terms of line item details for accounts codes etc.

You may also try the BAPI BAPI_ACC_REVENUES_POST. A quicker way would be to record F-27 in SHDB and write a BDC around it.

Cheers.

karuna_gangireddy
Contributor
0 Kudos

Yes. I realised this after reading couple of SDN posts.

I need to send posting keys 15(Customer Account) and 40 (G/l posting). I think i need to use EXTENSION2 for this. Also i need to send customer account thru ACCOUNT RECEIVABLE.

Non of the posts helped me to understand the whole flow. Like How we can send values in extension2, sending posting keys,sending customer account......I also read the documentation on this BAPI but that seems to be vague too.

Would appreciate if you can refer me to any links or docs in this regards.

Thanks,

Karuna.

karuna_gangireddy
Contributor
0 Kudos

Hi Neeraj,

AS you mentioned i tried running the BAPI in SE37. I made some progress. Now i am not getting any errors and also the BAPI is saying that the 'Document is posted along with the Doc#'. But when i am trying to find the record for this Doc# in table BSEG and BKPF i do not see nay entries. But the Doc# the BAPI is returning is the next number from the number range?

Where can i find this entry? What do i hav to do to make it show up in BSEG and BKPF tables? Would appreciate if you can please let me know if you have any idea?

Thanks in advance,

Karuna.

Former Member
0 Kudos

Hi,

Such BAPIs do not have a commit work. Now that you know the inputs needed, wrap this bapi in a Z FM and commit work. You should be then able to see the document.

In the current state, the document number is generated, but tables are not updated due to lack of commit.

Cheers.

uygur_burak
Active Contributor
0 Kudos

Hello Karuna,

You must use BAPI_TRANSACTION_COMMIT function for update standart FI tables.


    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' 
      EXPORTING
        wait = 'X'.

Regards,

Edited by: Burak Uygur on Jun 27, 2009 2:49 PM

uygur_burak
Active Contributor
0 Kudos

Hello Karuna,

You can change posting key while posting FI document via EXTENSION1 as you said.


DATA:gt_extension   LIKE TABLE OF bapiacextc WITH HEADER LINE.

FORM fill_posting_key.
  CLEAR: gt_extension.
  gt_extension+0(3)    = 'Your Item Number'
  gt_extension+3(2) = 'Posting Key'.
  APPEND gt_extension.
ENDFORM.                    " fill_posting_key

Then you must use Business transaction event for the new posting key assignment.

Copy SAMPLE_INTERFACE_RWBAPI01 to Z FM like ZFI_BAPIACCPOST_EXIT.

Write a sample code like below into ZFI_BAPIACCPOST_EXIT.


IF extension[] IS NOT INITIAL.
  LOOP AT extension.
    READ TABLE it_accit WITH KEY posnr = extension+0(3).
    IF sy-subrc EQ 0.
      it_accit-bschl = extension+3(2).
      MODIFY it_accit INDEX sy-tabix.
    ENDIF.
  ENDLOOP.
ENDIF.

Then go to FIBF -> Settings -> Products -> ... of a customer

Create a new product like ZFI and then check active checkbox.

Then go to FIBF -> Settings -> Process Modules -> ... of a customer

Process : RWBAPI01

Function Module : ZFI_BAPIACCPOST_EXIT

Product : ZFI

Then save this customizing and run your program, it will work correctly.

Regards,

Burak

karuna_gangireddy
Contributor
0 Kudos

Thanks Neeraj and Burak.

I was able to see the Doc# after i called BAPI for commit with 01 and 50 posting keys though. I did exactly as you mentioned for changing the posting keys. The BTE FM does get triggered and also the posting jeys are getting changed to 15 and 40 but i am getting error 'Inconsistent Amounts'.

But the document is getting posted with the same test data if i am not going thru BTE FM but with 01 and 50 posting keys. So, i don't think i am passing wrong data. But again i am not sure why it is complaining about 'Inconsistent amounts' when i use thw BTE FM for changing posting keys.

Please let me know if you have nay idea as whats wrong.

Thanks,

Karuna.

uygur_burak
Active Contributor
0 Kudos

Hello Karuna,

You shouldn't change posting key from 01-50 to 15-40 . It's inconsistant, system right.

01 posting key is debit, but 15 posting key is credit.

You must give a negative amount on customer line item. System will give 11 posting key(credit posting key). Then you can change posting key from 11 to 15 with BAPI exit which I explained above.

Regards,

Burak