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: 

BDC or BAPI of F-02

Former Member
0 Kudos

Hi all,

I need to prepare a BDC of transaction F-02 where the screens changed depending upon Gl accounts. As GL accounts are not fixed thus I am not able to record one. I have tried BAPIs also but they don't have posting key field, thus no success. Does any one have aly idea how can I transfer data using F-02 transaction screen?

Note : Special GL indicator is not used as it is not an advance payment. Some GL accounts require tax code also.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hey,

Actually it is possible to specify posting key using BAPIs.

BAPI_ACC_GL_POSTING_POST uses User Exit thus giving the possibility to alter more fields than only those specified as parameters.

Use CMOD, prepare project for extension ACBAPI01 go to components you should have a function exit there(EXIT_SAPLACC4_001), activate it, dbl click on its name.

Inside you'll have information about tables passed to user exit(t_accit - posting data, extension - the table you fill inside your code) and 'INCLUDE ZXACCU15' piece of text.

Edit/create include ZXACCU15. It's the place where you put your own code handling posting details before they are actually posted.

data:
  extension1 LIKE bapiextc
              OCCURS 0 WITH HEADER LINE,

  MOVE  '1' TO extension1-field1.  " this is row index 
  MOVE '50' TO extension1-field2.  " this is posting key
  APPEND extension1.

Inside ZXACCU15 use:

LOOP AT extension.
  READ TABLE t_accit INDEX extension-field1. " read specified row
  MOVE extension-field2 TO t_accit-bschl.    " update posting key
  MODIFY t_accit TRANSPORTING bschl.
ENDLOOP.

As User Exit might be called not only by your program, it is advisable to somehow mark the extension(eg. extension1-field3='BLAH') and check for 'BLAH' in UserExit so your code will only work with your program and leave other extensions alone.

Hope it helps a bit.

3 REPLIES 3

Former Member
0 Kudos

Hey,

Actually it is possible to specify posting key using BAPIs.

BAPI_ACC_GL_POSTING_POST uses User Exit thus giving the possibility to alter more fields than only those specified as parameters.

Use CMOD, prepare project for extension ACBAPI01 go to components you should have a function exit there(EXIT_SAPLACC4_001), activate it, dbl click on its name.

Inside you'll have information about tables passed to user exit(t_accit - posting data, extension - the table you fill inside your code) and 'INCLUDE ZXACCU15' piece of text.

Edit/create include ZXACCU15. It's the place where you put your own code handling posting details before they are actually posted.

data:
  extension1 LIKE bapiextc
              OCCURS 0 WITH HEADER LINE,

  MOVE  '1' TO extension1-field1.  " this is row index 
  MOVE '50' TO extension1-field2.  " this is posting key
  APPEND extension1.

Inside ZXACCU15 use:

LOOP AT extension.
  READ TABLE t_accit INDEX extension-field1. " read specified row
  MOVE extension-field2 TO t_accit-bschl.    " update posting key
  MODIFY t_accit TRANSPORTING bschl.
ENDLOOP.

As User Exit might be called not only by your program, it is advisable to somehow mark the extension(eg. extension1-field3='BLAH') and check for 'BLAH' in UserExit so your code will only work with your program and leave other extensions alone.

Hope it helps a bit.

Former Member
0 Kudos

Hi,

Go with BDC you might have held with any mistake in your code.

Post the code so that if any mistake we will try to resolve.

Cheers!!

Former Member
0 Kudos

Hi BDC will not work for F-02

go with BAPI

I have used the following code for it

CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'

EXPORTING

documentheader = w_head

TABLES

accountgl = t_gl

currencyamount = t_cr

return = p_return.

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

this has worked for me...

good luck