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_ACC_DOCUMENT_POST enhancement ACBAPI01 not working properly

Former Member
0 Kudos

We work with SAP Realise ECC 6.0

We use functions BAPI_ACC_DOCUMENT_CHECK and

BAPI_ACC_DOCUMENT_POST to post FI document automatically.

And we need to fill FI document HEADER field BKPF-XREF1_HD.

In BAPIs I don’t see field XREF1_HD in structure DOCUMENTHEADER.

I read note 487722 and created project with enhancement ACBAPI01 as a component.

At implementation (include ZXACCU15) we have code:

DATA: wa_header TYPE acchd.

DATA: wa_extension TYPE bapiextc.

FIELD-SYMBOLS: <fld> TYPE ANY.

LOOP AT extension INTO wa_extension WHERE field1 = 'HEADER'.

ASSIGN COMPONENT wa_extension-field2 OF STRUCTURE t_acchd TO <fld>.

IF sy-subrc = 0.

<fld> = wa_extension-field3.

ENDIF.

Endloop.

I activated project.

Before calling BAPI we have code:

CLEAR wa_extension1.

wa_extension1-FIELD1 = 'HEADER'.

wa_extension1-FIELD2 = 'XREF1_HD'.

IF u_wa_pdata_temp-prime_id IS NOT INITIAL.

wa_extension1-FIELD3 = 'TS korekcija'.

ELSE.

wa_extension1-FIELD3 = 'TS normalus'.

ENDIF.

APPEND wa_extension1 TO it_extension1.

I have a break-point in my exit (include ZXACCU15), but it seems that the exit is not even being performed.

Also I tried to use implement BTE event RWBAPI01.

Buti n SAMPLE_INTERFACE_RWBAPI01 in DOCUMENT_HEADER structure I dont find XREF1_HD field.

How can I fill header field XREF1_HD using BAPIs BAPI_ACC_DOCUMENT_CHECK and

BAPI_ACC_DOCUMENT_POST ????

11 REPLIES 11

Former Member
0 Kudos

Hi all,

I have the same problem: Can anyone solve it?

Regards,

Raffaele.

Former Member
0 Kudos

HI, use SAMPLE_INTERFACE_RWBAPI01. and append structure ACCHD , but you must use the same fieldname of BKPF, such as NUMPG,XREF1_HD.

then you can code the processing of subititution in the BTE function.

Former Member
0 Kudos

Hi Gabita,

Have you checked BADI ACC_DOCUMENT. This BADI will get triggered with BAPI_ACC_DOCUMENT_CHECK and BAPI_ACC_DOCUMENT_POST, I have used this BADI to change the posting keys. Just check once whether you can get your requirement solved.

Thanks & Regards,

Faheem.

Former Member
0 Kudos

Hi,

I too had the same problem and found a solution. Hope it will be useful to someone.


1. Pass field names 'XREF1_HD' & 'XREF2_HD' in valuepart1 of structure 'EXTENSION2' and their corresponding values in valuepart2.

2. Create an implementation for BADI 'ACC_DOCUMENT'.

3. The extension values will be available in 'C_EXTENSION2' parameter of Method 'Change'.

4. The fields XREF1_HD & XREF2_HD are available in ACCIT but not in ACCHD. Modify these fields in ACCIT.

5. Once doc is posted, you should be able to see values in the header.

Regards,

Laxman

0 Kudos

Hi Laxman,

Thanks for sharing the solution. I am new to BADI and would like to seek you help to understand the solution better. How should we pass the values to fields XREF1_HD & XREF2_HD?

Do you mind providing a sample code of the implementation you created for the BADI or screen shot where I could refer to?

Regards,

Jonas

<email address removed by moderator>

Message was edited by: Manish Kumar

0 Kudos

Hi,

Try CHANGE method in bapi. We have sample code there. You need to write code for pbo and pai for this custom fields in screen. Just go through FI_Header_Sub_1300

Madhu.

0 Kudos

Hi Madhu,

Thank you for the reply.

Code should be written in PBO and PAI, only if I need to make the changes for standard transactions/programs rite?

I am trying to pass the data to field XREF1_HD thru BAPI - 'BAPI_ACC_DOCUMENT_POST'

by using a Z* program.

{Documents are getting posted to SAP using this Z* program, and an additional data need to be pass to field XREF1_HD}

I am trying to make it work by following the steps mentioned by Laxman in this post.

What is the value that I should pass to BAPIPAREX-STRUCTURE field

Regards,

Jonas

0 Kudos

Hey,

Here you go.

1. Add the below code in your Z* program before calling the BAPI.

gw_extension2-valuepart1 = 'XREF1_HD'.

gw_extension2-valuepart2 = <insert value here>.

APPEND gw_extension2 TO gt_extension2.

CLEAR gw_extension2.

gw_extension2-valuepart1 = 'XREF2_HD'.

gw_extension2-valuepart2 = <insert value here>.

APPEND gw_extension2 TO gt_extension2.

CLEAR gw_extension2.

2. Add the below code in 'CHANGE' method of your custom implementation for BADI 'ACC_DOCUMENT'.

READ TABLE c_extension2 INTO lw_extension2 WITH KEY valuepart1 = 'XREF1_HD'.

IF sy-subrc EQ 0.

  lv_xref1_hd = lw_extension2-valuepart2.

ENDIF.

READ TABLE c_extension2 INTO lw_extension2 WITH KEY valuepart2 = 'XREF2_HD'.

IF sy-subrc EQ 0.

  lv_xref2_hd = lw_extension2-valuepart2.

ENDIF.


LOOP AT c_accit INTO lw_accit.

      lw_accit-xref1_hd  = lv_xref1_hd.

     lw_accit-xref2_hd = lv_xref2_hd.

     MODIFY c_accit FROM lw_accit INDEX sy-tabix TRANSPORTING xref1_hd xref2_hd.

ENDLOOP.


I don't know if updating only the first line item will always suffice, so I am modifying all the line items with those values.


Hope it is helpful.


Cheers,


Laxman.

0 Kudos

Hi laxman,

Can i know how to get values into the table c_extension2.

can get default structre in after implementing Badi ?

0 Kudos

Hi Suman,

Apologies for the late reply.

If you are still looking for an answer, passing the required values in gt_extension2 ( Step 1 ) will get you the values in c_extension2 of the BADI Implementation.

Cheers,

Laxman