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_CHECK

Former Member
0 Kudos

I'm using BAPI_ACC_DOCUMENT_CHECK to check the GL accounts If there are any error records it is writing into tb_return

Now I got a requirement to pass those errored records errors into Inbound IDOC

can anybody help me how to proceed

I got the partner number ..I'm using the FM IDOC_INBOUND_SINGLE but the data is not updating ... I would be thankful for anykind of help..

9 REPLIES 9

Former Member
0 Kudos

Bapi will do the job.

What I can advice if you want to check / Test .

Just create a p_test parameter ( checkbox ).

Then in your code put a logic like this :

  • call BAPI-function in this system

CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST'

EXPORTING

documentheader = documentheader

IMPORTING

obj_type = l_type

obj_key = l_key

obj_sys = l_sys

TABLES

accountgl = accountgl

accountpayable = accountpayable

currencyamount = currencyamount

accounttax = accounttax

extension1 = extension1

return = return.

IF p_test EQ 'X'.

  • TEST

CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.

ELSE.

  • COMMIT

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.

ENDIF.

Reward point please

0 Kudos

I dont want to post the BAPI if return in BAPI...CHECK has errors so I'm skipping the process everything is going fine till there but my new requirement is to send an INBOUND IDOC for the error records

Do u mean to say if it is errored the IDOC can be created thru BAPI itself without using any FM or any code..

I'm confused ..

Former Member
0 Kudos

Hi,

What data is not updating, are you not able to see the idoc that is generated?

0 Kudos

I'm not able to send the data to the idoc any of the segments I got that the

The ACC_DOCUMENT Idoc is structured the same way as the table parameters of the bapi accounting document post/check and the field names do seem to match between the tables of the BAPI and the Idoc segments :

BAPI table -> Idoc segment

DOCUMENTHEADER-> E1BPACHE09

ACCOUNTGL -> E1BPACGL09

ACCOUNTRECEIVABLE-> E1BPACAR09

CURRENCYAMOUNT -> E1BPACCR09

CRITERIA -> E1BPACKEC9

VALUEFIELD -> E1BPACKEV09

I'm trying to pass the bapi internal tables to the segments...

0 Kudos

Are you building the control record also, and what is happening after you call IDOC_INBOUND_SINGLE, are you getting an exception?

0 Kudos

it is creating IDOC with errors and when went thru debug I got that the structurs didnot match...

Yes I'm creating control record

0 Kudos

can you paste the part of the code where you are populating the idoc segments.

0 Kudos

I tried with few segments if it goes thru but somewhere its going wrong

below is my code:

FORM BUILD_CONTROL_RECORD .

EDIDC-MESTYP = C_MESTYP.

EDIDC-IDOCTYP = C_IDOCTP.

EDIDC-DIRECT = C_2.

EDIDC-SNDPRN = C_PARTN.

EDIDC-SNDPRT = C_LS.

APPEND EDIDC.

ENDFORM. " BUILD_CONTROL_RECORD

FORM BUILD_DATA_RECORD .

data: l_itemno(10) type c.

wa_SEG-SEGNAM = 'E1BPACHE09'.

append wa_SEG to tb_seg.

clear wa_seg.

wa_SEG-SEGNAM = 'E1BPACGL09'.

append wa_SEG to tb_seg.

clear wa_seg.

wa_SEG-SEGNAM = 'E1BPACAR09'.

append wa_SEG to tb_seg.

clear wa_seg.

delete adjacent duplicates from tb_docheader.

LOOP AT TB_SEG INTO WA_SEG.

LOOP AT TB_DOCHEADER INTO WA_DOCHEADER.

move wa_docheader to WA_seg-SDATA.

EDIDD-MANDT = SY-MANDT.

EDIDD-SEGNAM = WA_SEG-SEGNAM.

EDIDD-SDATA = WA_seg-SDATA.

APPEND EDIDD.

clear wa_docheader.

endloop.

clear wa_seg.

if wa_SEG-SEGNAM = 'E1BPACGL09'.

LOOP AT tb_accgl into wa_accgl.

l_itemno = wa_accgl-ITEMNO_ACC.

move wa_accgl+0(10) to WA_seg-SDATA.

concatenate l_itemno WA_seg-SDATA into WA_seg-SDATA.

EDIDD-MANDT = SY-MANDT.

EDIDD-SEGNAM = WA_SEG-SEGNAM.

EDIDD-SDATA = WA_seg-SDATA.

APPEND EDIDD.

clear wa_seg.

endloop.

endif.

similarly I'm trying to append

CALL FUNCTION 'IDOC_INBOUND_SINGLE'

EXPORTING

PI_IDOC_CONTROL_REC_40 = edidc

  • PI_DO_COMMIT = 'X'

  • IMPORTING

  • PE_IDOC_NUMBER =

  • PE_ERROR_PRIOR_TO_APPLICATION =

TABLES

PT_IDOC_DATA_RECORDS_40 = edidd

EXCEPTIONS

IDOC_NOT_SAVED = 1

OTHERS = 2

.

0 Kudos

I appended the control record but want some help to append the rest of the segments ...i'm trying to loop each segment and pass each field in each segment to the EDIDD table Is there anyother way like any easy way other than looping each segment and appending ..any kind of help will be lot helpful..