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 to PARK accounting document

Former Member
0 Kudos

Does anyone know conclusively whether BAPI BAPI_ACC_DOCUMENT_POST can be used to PARK an accounting document as well as POST one? Or if not this BAPI, is there another one? (I am trying to perform the PARK function of FB50.)

I am creating a posting interface and the specification requires to park documents for later review and posting, rather than posting them. From other posts on SDN I know I can use a BDC but would prefer a single interface.

Thank you for any comments,

Bob

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Answer to my OSS message:

25.05.2007 - 11:38:41

A parked document with ACC-Bapis (bapi_acc_*) is not possible.

This interface is for posting only. It is completely different from

the manual posting and parking transactions, and its functionality

is limited in comparison.

In the documentation for this BAPI, there is also a reference to:

More informationen is available in the Interfaces to Accounting documentation in the R/3 Library (under Cross Application Functions ->

Interfaces to External Systems).

xxxxxxx

Support Consultant

Global Support - Financials

-


Hope this helps some other person who wants to know.

(Maybe I'm only one of a few people that would like to use a BAPI to park accounting documents, but it would probably be helpful to know if there are more. If you ever needed or now need this functionality please post a reply to this message.)

Bob

30 REPLIES 30

Former Member
0 Kudos

Answer to my OSS message:

25.05.2007 - 11:38:41

A parked document with ACC-Bapis (bapi_acc_*) is not possible.

This interface is for posting only. It is completely different from

the manual posting and parking transactions, and its functionality

is limited in comparison.

In the documentation for this BAPI, there is also a reference to:

More informationen is available in the Interfaces to Accounting documentation in the R/3 Library (under Cross Application Functions ->

Interfaces to External Systems).

xxxxxxx

Support Consultant

Global Support - Financials

-


Hope this helps some other person who wants to know.

(Maybe I'm only one of a few people that would like to use a BAPI to park accounting documents, but it would probably be helpful to know if there are more. If you ever needed or now need this functionality please post a reply to this message.)

Bob

0 Kudos

You are not unique. We have exactly the same need.

0 Kudos

I haven't tried it but the documentation for RFBIBL00 says that it supports parking documents.

Rob

0 Kudos

Hey Bob,

I am facing the same scenario here where in i have to park the FI document using BAPI_ACC_GL_POSTING_POST...i did some tweaking around and found if we change the BSTAT field to 'V' in the user exit EXIT_SAPLACC4_001 and activate it..it might work...but i need your suggestions on this...because BSTAT = V signifies that the document is parked...right

Please correct me if i am wrong...

Reagrds:

Sam

Former Member
0 Kudos

Thanks, I had run across RFBIBL00 in my original search., but RFBIBL00 does not use a BAPI to effect a parked document.

Bob

0 Kudos

Hi,

I have search exhaustedly as well for an Idoc or BAPI that will park documents.

You can using Idoc FIDCCP02 but this is really not recommended as it is a very old idoc and has been around a long time. <b>I opened a message related to this and SAP themselves recommended BDC for parking documents</b>. This is what i have done. This is not ideal but i could not find any other way.

If any new development come about in this area, please keep me informed.

Rory

Former Member
0 Kudos

Sam, I will do some further checking. What I am most concerned about is the document might actually be posted but only the status is overridden to indicate parked. And then posting the parked document may result in a double posting. Have you checked out the resulting document?

In any case, you may be onto something.

Bob

0 Kudos

Hey Bob,

Thanks for the reply...

So what shud i try and look for...what do u suggest..becoz i have to do this by some way or the other...please give suggestions...

Thanks

0 Kudos

Hi Sam,

I had already completed this using FBV1 with a BDC. In some other recent posts, it seems other people also are parking by setting BSTAT to 'V' in T_ACCIT in the user exit. I can't check further without creating the user exit. If I have a chance I will try.

I would check is to be sure account balances do not change when you post with BSTAT set to V.

Bob

0 Kudos

I decided to try this and have several issues.... My userexit is not being called when I execute the BAPI_ACC_DOCUMENT_POST. Review of the documentation indicates neither it nor BAPI_ACC_GL_POSTING_POST is in the list of update BAPIs containing the exit. I am also concerned that BSTAT is in the T_ACCIT line item table rather than the ACCHD table.

Since the userexit did not trigger, I interrupted the program at the place where the BAPI calls the customer function using debug, and forced the T_ACCIT-BSTAT value to V for each of the accounting lines in a test entry. The document posted, “hit my budget”, and shows in BKPF with a status V but now cannot be displayed with FB03, says parked document cannot be displayed, FBV0 says document does not exist…

Seems changing the status this way is playing with fire. Does someone know something I don’t that makes this work?

Thanks,

Bob

0 Kudos

Hey Bob,

Thanks for the reply...Are u sure that the user exit EXIT_SAPLACC4_001 does not get called with in the BAPI BAPI_ACC_GL_POSTING_POST...if that is the case then how did u do it thru FBV1 BDC...do u have any sample code that i can look at for that BDC...because I have to park the FI document and have the same requirement that u have..

truly appreciate ur effort...

Thanks

Cheers: Sam

0 Kudos

Hi Sam, Yes, I did it through a BDC call transaction FBV1, and found code I started with here on SDN at But modified extensively for our account structures...

I can't copy all my code, but will give you some things to look for:

1) if you do your dates like this, they will format correctly for the users date settings in Sustem->User profile->Own data , otherwise the call transaction may fail due to invalid date formats...

*document date

  • reformat date for input

WRITE p_je_hdr-bldat TO h_date.

CONDENSE h_date NO-GAPS.

PERFORM bdc_field TABLES t_bdcdata

USING 'BKPF-BLDAT'

h_date.

2a) Watch out for fields in Standard SAP but hidden in your implementation

*batch input document ID - hidden at FCS

  • PERFORM bdc_field tables t_bdcdata

  • USING 'FS006-DOCID'

  • '*'.

2b) watch out for fields hidden by settings for transaction FB00 --> this is user dependent. Find out your site's FB00 defaults

*removed from screen by settings in FB00

**doc currency

  • PERFORM bdc_field TABLES t_bdcdata

  • USING 'BKPF-WAERS'

  • p_je_hdr-waers.

3) watch out for screens based on posting key

  • screen depends on posting key

  • if posting key is for a Vendor

IF p_t_je_lin-bschl = '40' OR

p_t_je_lin-bschl = '50'.

scrn_id = '0300'.

  • if posting key is for a Vendor

ELSEIF p_t_je_lin-bschl = '31' OR

p_t_je_lin-bschl = '22'.

scrn_id = '0302'.

ENDIF.

PERFORM bdc_dynpro TABLES t_bdcdata

USING 'SAPLF040' scrn_id.

4) you may have to set and clear the FMORE field for the account assignment sub screen.

  • in the batch input, there is a check box to

  • activate the account assignment subscreen.

  • but this field is not on vendor screen0302

IF p_t_je_lin-bschl = '40' OR

p_t_je_lin-bschl = '50'.

PERFORM bdc_field TABLES t_bdcdata

USING 'DKACB-FMORE'

'X'.

ENDIF.

5) watch out for account dependent screen required fields, and available fields... In the example below, Business area is derived from cost center, unless cost center input field is not available. And the cost center field is not available if the account field status group is one of the indicated ones, so I had to fill business area instead.

  • if Field status group is Z001, etc. - look up in SKB1

  • cost center and functional area fields are

  • not present on input subscreen

  • otherwise cost center required, also

  • functional area, if not defaulted from cost ctr.

n_10chr = p_t_je_lin-hkont.

SELECT SINGLE fstag FROM skb1 INTO h_fstag

WHERE bukrs = p_je_hdr-bukrs AND

saknr = n_10chr.

IF h_fstag = 'Z001' OR

h_fstag = 'Z007' OR

h_fstag = 'Z011'.

  • business area - required for asset BS accts

  • if business area entry is populated use it, otherwise

  • construct from cost center-- first 4 chars

  • if cost center is present. Otherwise will be blank

IF p_t_je_lin-gsber <> space.

PERFORM bdc_field TABLES t_bdcdata

USING 'COBL-GSBER'

p_t_je_lin-gsber.

ELSE.

PERFORM bdc_field TABLES t_bdcdata

USING 'COBL-GSBER'

p_t_je_lin-kostl(4).

ENDIF.

ELSE.

(cost center is filled)

I had to work through these by recording the BDC's and reworking after the Financial team informed me of the FB00 settings. When recording BDC's, BE SURE TO CHECK THE SIMULATE BACKGROUND MODE check box. This causes the fields to appear the same as will be done when submitting the transaction call.

I'm still looking into the idea about using the BAPI with the BSTAT = 'V' but although people say to try, no one seems to have claimed success.

Hope this helps,

Bob

0 Kudos

Also, I found this:

Re: Uploading Data to FBV1 Transaction - URJENT

not a BAPI but:

you could use the function modules 'POSTING_INFERFACE_START', 'POSTING_INFERFACE_DOCUMENT', 'POSTING_INFERFACE_END'. They do the same as RFBIBL00 and can deal with different posting keys document types and so on.

Regards Wolfgang

In

0 Kudos

Hey Bob,

Thanks for the reply...I will try doing the BDC lets see where i reach with it...but the idea of setting BSTAT = V is really something to think off..I believe if it works then it will be like a custom bapi where in we just pass BSTAT = V in the user exit and the document is parked..also i checked from my end the user exit works...also after calling BAPI_ACC_GL_POSTING_POST u have to call commit work..then only it will display...

But please do correct me if i am wrong...its my first exposure to BAPI's and BDC..so still have a learning curve...

Cheers:

Sam

0 Kudos

Sam, a couple things....

I have tried with BAPI_ACC_DOCUMENT_POST and you are using BAPI_ACC_GL_POSTING_POST That may be my problem. But I can't switch easily.

My CMOD enhancement function from EXIT_SAPLACC4_001 does not execute from BAPI_ACC_DOCUMENT_POST . my breakpoint never triggers, debug did not step through it,.

&----


*& Include ZXACCU15

&----


break ungerr.

READ TABLE extension INDEX 1.

IF extension-field1 = 'BAPI-PARK'. "<<to know it comes from my prog

LOOP AT t_accit.

t_accit-bstat = 'V'.

MODIFY t_accit.

ENDLOOP.

ENDIF.

But while debugging I found the call thru the BTE RWBAPI01 does trigger... the following code in my program sets BSTAT to V

n_10 = 0.

LOOP AT p_t_je_lin. "<- doc lines

ADD 1 TO n_10.

wa_ext1-field1 = n_10.

wa_ext1-field2 = 'BSTAT'.

wa_ext1-field3 = 'V'.

APPEND wa_ext1 TO gt_ext1.

ENDLOOP.

  • Call BAPI for load the data

CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'

EXPORTING

documentheader = wa_dochdr

TABLES

accountgl = gt_gl

accountpayable = gt_vendor

currencyamount = gt_curramt

return = gt_return

extension1 = gt_ext1.

But after posting, the document will not display with FBV3 or FBV0, and FB03 says can't find parked document with that number. But it exists in BKPF and BSEG... with status V. And my budget availability is reduced, indicating the document actually posted.

That is the end of it for me unless I find out something new, and I have to move on to another task.

Bob

0 Kudos

To all:

Function Module Preliminary_posting_fb01 is called internally for parking. I haven't yet rewritten my BDC based code to use this module, but when I do, I will add another post to this thread to advise results.

Bob

.

0 Kudos

Dear Rob,

Really Great work on this, I also need same requirement to park document using abap program. please can you send example code to this id

<removed_by_moderator>

your cooperation highly appreciated.

Sincerely

Edited by: Julius Bussche on Sep 20, 2008 9:33 PM

0 Kudos

Ganesh - please just check the documentation.

Rob

0 Kudos

Ganesh,

I can't (not allowed) to just post my code or I would have... On page one is the link to the source I started with from SDN and some good pointers. Start there....

Also, I am working on rewriting using the function module above (Preliminary_posting_fb01) and will advise results when done. It may be an alternative...

Bob

0 Kudos

Function Module PRELIMINARY_POSTING_FB01 can be used to park an accounting document. It is an internal routine called by the FB01 dialog transaction to create a parked document. I have now created and parked numerous documents with this FM.

I have not yet vetted all the required values required to be passed for all different types of accounting documents so I don't know if it works in all circumstances. Setting the parameters you need for your circumstances will take you some work with debug.

I created a function module wrapper for it to use the same parameter structure used by the BAPI_ACC_DOCUMENT_POST function module, so that I can call either BAPI_ACC_DOCUMENT_POST or the PRELIMINARY_POSTING_FB01 with the same setup. However, I needed to create an extra line item structure to populate with the posting keys, account types, debit credit indicators and other line by line data expected by the PRELIMINARY_POSTING_FB01 module. This is passed to my wrapper in addition to the structures used by the standard BAPI because I didn't want to reverse engineer all the values from the BAPI values. My wrapper then sets up the parameters for calling PRELIMINARY_POSTING_FB01.

The preliminary posting FM displays an Informational dialog box (message FP 001) at the end of the posting, if successful, with the document number and company code. To suppress this message from requiring user acknowledgement, override the message type to S by creating an entry using SM30 in V_T100C.

I don't know yet how I will handle other error messages.

0 Kudos

Hey Bob,

I hope you are doing great..I am also follwing the same route that you did using FM PRELIMINARY_POSTING_FB01 for parking the FI GL document..But had a few questions with the wrapper...Can you please tell me how to push posting key to the line item...right now i am hard coding the value of the posting key...it works but can i make it better...also what fileds shud i take care of when i call this FM...i jusy want to cross check the values with the ones that i have...

This FM gives a information dialog box once the parking is done...How can i trap this message as i have to send the parked document number to another table...

Can you please provide me some inputs on this and THANK YOU SO MUCH for guiding us in this object...

Really appreciated...

Cheers:

Sam

0 Kudos

Hey Bob,

Can you please provide me some inputs on this...

Cheers:

Sam

0 Kudos

Sam, my input source has the posting key (BSCHL), and whether the line item is a debit or credit (SHKZG) and I can look up the account type (KOART). These are not passed to the BAPI_ACC_DOCUMENT_POST but are needed byt the FM. Because you provide this info by other means to the BAPI, e.g. reverse the sign when creating the gt_curramt entries instead of providing the debit/credit indicator, deciding to put an entry into the gt_gl or gt_vendor table based on the posting key, the work is already done for the BAPI. The FM expects the raw data... So in the module where I populate the gt_xxxx tables to pass to the BAPI, I created an additional structure I called gt_extra to store the above three items for each line.

I created a new FM ZFI_PARK_ACC_DOC. It takes the same parameters as the BAPI, plus the extra table. This is my "wrapper" The user or calling process can select either park or post.

IF p_parkpost = 'POST'.

  • Call BAPI to post the document

CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'

EXPORTING

documentheader = wa_dochdr

TABLES

accountgl = gt_gl

accountpayable = gt_vendor

currencyamount = gt_curramt

return = gt_return

. "period

  • Commit the transaction

call function 'BAPI_TRANSACTION_COMMIT'

EXPORTING

wait = c_wait.

ELSE.

  • call the FB01 function module to park the document

CALL FUNCTION 'ZFI_PARK_ACC_DOC'

EXPORTING

documentheader = wa_dochdr

TABLES

accountgl = gt_gl

currencyamount = gt_curramt

return = gt_return

extralinedata = gt_extra

accountpayable = gt_vendor

EXCEPTIONS

mismatched_tables = 1

parking_error = 2

OTHERS = 3

.

ENDIF.

This wrepper FM then re-sets up the data to call the preliminary posting.

CALL FUNCTION 'PRELIMINARY_POSTING_FB01'

EXPORTING text_update = gvtext_update

text_item_update = gvtext_item_update

i_uf05a = gvi_uf05a

i_xcmpl = gvi_xcmpl

fs006_fb01 = gvfs006_fb01

i_tcode = gvi_tcode

i_pargb = gvi_pargb

IMPORTING xepbbp = gvxepbbp

TABLES: t_bkpf = gt_bkpf

t_bseg = gt_bseg

t_bsec = gt_bsec

t_bset = gt_bset

t_bsez = gt_bsez

t_bkorm = gt_bkorm

t_thead = gt_thead

t_splttab = gt_splttab

t_spltwt = gt_spltwt.

I populate the gt_bkpf, gt_bseg, gt_bsez tables from the BAPI tables. As Ibuild the line items, I add the posting key, etc. from the extra table.

The rest of the tables passed to the preliminary posting FM are not required for my postings.

You will have to decide exactly what header fields and what line item fields are applicable to your customer.

Regarding the dialog message box, the answer is in my previous post.

Sorry I cannot just post my code and save you the work.

Hope this helps,

Bob

0 Kudos

Hi Sam,

I am facing the same trouble as you did, I've narrowed down to FM PRELIMINARY_POSTING_FB01 but I am a little confused about how to populate the tables XBKPF, XBSEG and XBSEZ. I have done lots of debugging to see how these tables are filles but there are some fields of which I have no clue.I have just read this thread and found that you had to face the same problem.

So please can you help me on this and guide how can I populate the tables.

Cheers

Abhishek

0 Kudos

Hi Bob,

Could you please explain for what are the import parameters

TEXT_UPDATE

TEXT_ITEM_UPDATE

are used for?

Also could you suggest how to populate LONG TEXT appearing on the second screen ,using the FM.

0 Kudos

Hi Bob,

Hope you can help me with this!!

When I am trying to park documents using PRELIMINARY_POSTING_FB01, the document is posted when I set i_xcmpl = 'X' but if I am right it should park the document as if we 'SAVE AS COMPLETED' say in FV60 i.e with status Completed.

I tried loads of other ways i.e just park using PRELIMINARY_POSTING_FB01with i_xcmpl = ' ' and BDC to click on Save as Completed, but the document is posted rather than parked with status 'Completed'!!

I tried to use PP_COMPLETE_DOCUMENT_ENJ which SAP uses behind FV60 when we click on Save as Complete, same problem again - Doc gets posted!!!!

when I Save Doc as Complete with same parameters etc using FV60 manually the doc is nicely parked with Completed status!!

I have opened a new thread with the same question.....any input will be much appreciated!!!

thanks

naresh

0 Kudos

Another solution to this which I have seen is to use a WAPI (Workflow Application Program Interface) instead of a BAPI to request a posting subject to approval.

A potential problem however is that in addition to the ID of the creator to be checked for the authority to park (actvt '77' if I remember correctly), the ID name itself should be sent into the workflow and the approval (whatever the actvt value of "post" is to be on the approver side) needs to be taken care of by the approval application - because if the update tasks are in the workflow engine then what you get for it is WF-BATCH instead of the user ID...

Cheers,

Julius

Former Member
0 Kudos

I recorded FBV1. I used a GL account with cost element so the subscreen shows cost center for input. (when recording, click on additional data button, you will see the cost center field.)

It went ok at recording. However, when it runs, the BDC cannot populate the cost center field. It shows error "Field COBL_KOSTL does not exist in thw screen SAPLKACB 0002".

If I comment out the code for filling the cost center, it goes thru fine.

Does this sound familiar to anyone?

Thanks~~

Former Member
0 Kudos

I recorded FBV1. I used a GL account with cost element so the subscreen shows cost center for input. (when recording, click on additional data button, you will see the cost center field.)

It went ok at recording. However, when it runs, the BDC cannot populate the cost center field. It shows error "Field COBL_KOSTL does not exist in thw screen SAPLKACB 0002".

If I comment out the code for filling the cost center, it goes thru fine.

Does this sound familiar to anyone?

Thanks~~

Former Member
0 Kudos

Finally, i was able to find an alternative to BDC suggested here.

SAP does not provide with any Standard BAPI to park an accounting document instead we have function module PRELIMINARY_POSTING_FB01 which parks the document.

I have used Following fields in my case, some fields may not be required.

BKPF table:

BUKRS GJAHR BLART BLDAT BUDAT MONAT CPUDT WWERT USNAM TCODE GLVOR HWAER HWAE2 BASW2 UMRD2 CURT2

KUTY2 AUSBK

BSEG table :

BUKRS GJAHR BUZEI BSCHL KOART SHKZG DMBTR WRBTR KZBTR PSWBT PSWSL VALUT VORGN KOKRS XKRES HKONT

XBILK PAOBJNR PASUBNR

Other issue i faced is that i wanted to POST to COPA too for which we had to generated PAOBJNR number. I made use of function module COPA_PROFITABILITY_SEGMENT.

Following fields were passed in I_COBL structure :

GLVOR VORGN BUDAT BLDAT BUKRS HKONT KOART KOKRS GJAHR BLART BSCHL WWERT WAERS DMBTR SHKZG WRBTR DMBE2 VTWEG KUNNR PAPH1

any extra fields can be populated using IT_COPA internal table.

I hope this answers everyone's question who have been looking to PARK accounting document .

Thanks.

Saurabh