cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Problem using BAPI_ACC_CO_DOCUMENT_FIND

Former Member
0 Kudos
600

I am attempting to use this BAPI to retrieve accounting documents filtered by controlling area, cost center, fiscal year, and fiscal period. When I run the BAPI by function module testing inside SAP it works fine. However, when I send the identical paramteters to the BAPI from MII it returns no results. I am using the JCo connector to execute the BAPI.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Is the connection to SAP successful using JCo action block? Are you using correct server details, user name, passowrd, etc?

Best Regards,

Kedar

Former Member
0 Kudos

Yes, the server details are correct. The JCo block is reporting back that it successfully executed the BAPI, I just don't get any results in the response XML.

Former Member
0 Kudos

Hi,

there are differences between the JCo test and the SE37 test.

Try a test after removing the nodes from the INPUT and INPUT / DOCUMENT that you do not need in your selection, using the Link Type "Remove XML". Maybe this helps.

Michael

Former Member
0 Kudos

Absolutely right. As Mike said, JCo test and SE37 code test is not same in all aspects.

Please check Input table values for JCo and Response XML tables.

By the way, which MII version you are using?

Best Regards,

Kedar

Former Member
0 Kudos

MII 12.0.11 Build 14

I had already stripped all unnecessary XML from the RequestXML file. This did not seems to make any difference.

John

Former Member
0 Kudos

Hi John,

If you don't mind, can you share the input parameters?

Best Regards,

Kedar

agentry_src
Active Contributor
0 Kudos

Check for leading zeroes in your input fields. SE37 will prepend them, but generally BAPIs and RFCs will not when executed from MII (and probably any external implementation). You may also want to check the other input formats to make sure they are correct.

Regards,

Mike

Edited by: Michael Appleby on Oct 20, 2010 12:34 PM

Former Member
0 Kudos

Right, as Mike said, input formats may create these type of problems. MII and SAP data type input formats are different in some cases.

I faced one problem way back when I tried to execute a BAPI via MII. I had to add 7 leading zeros in my input parameter in MII JCo to match the string length that is defined in SAP.

Hope this is useful. If it won't work, can you share the input values?

Best Regards,

Kedar

Former Member
0 Kudos

Thanks for sticking with this one guys. I looked through the data structures, and it does look like the COSTCENTER field needs to have 10 characters and I was only giving it 8, so I added 2 leading zeros to it. I re-ran the transaction, and it took longer to run (similar in time to what it takes in SE37), so I got excited and thought "problem solved", but only to be disappointed again. The ResponseXML still contained no items. Here is the request and response for you as requested.

Request:

BAPI_ACC_CO_DOCUMENT_FIND>

- <INPUT>

- <DOCUMENT>

<CO_AREA>5000</CO_AREA>

<PERIOD>001</PERIOD>

<FISC_YEAR>2000</FISC_YEAR>

</DOCUMENT>

<RETURN_COSTS>X</RETURN_COSTS>

<RETURN_ITEMS>X</RETURN_ITEMS>

<RETURN_VALID_ONLY>X</RETURN_VALID_ONLY>

</INPUT>

- <TABLES>

- <SELECT_CRITERIA>

- <item>

<FIELD>COSTCENTER</FIELD>

<SIGN>I</SIGN>

<OPTION>EQ</OPTION>

<LOW>00MUS80902</LOW>

<HIGH />

</item>

</SELECT_CRITERIA>

</TABLES>

</BAPI_ACC_CO_DOCUMENT_FIND>

Response:

- <BAPI_ACC_CO_DOCUMENT_FIND>

- <INPUT>

- <DOCUMENT>

<CO_AREA>5000</CO_AREA>

<DOC_NO />

<PSTNG_DATE>0000-00-00</PSTNG_DATE>

<PERIOD>001</PERIOD>

<FISC_YEAR>2000</FISC_YEAR>

<OBJ_TYPE />

<ORIG_TRANSAC />

</DOCUMENT>

<RETURN_COSTS>X</RETURN_COSTS>

<RETURN_ITEMS>X</RETURN_ITEMS>

<RETURN_QTY />

<RETURN_SKF />

<RETURN_VALID_ONLY>X</RETURN_VALID_ONLY>

</INPUT>

- <TABLES>

<DOC_HEADERS />

<LINE_ITEMS />

<LINE_ITEMS_ACTIVITY />

<LINE_ITEMS_STAT_KEY_FIG />

<RETURN />

- <SELECT_CRITERIA>

- <item>

<FIELD>COSTCENTER</FIELD>

<SIGN>I</SIGN>

<OPTION>EQ</OPTION>

<LOW>00MUS80902</LOW>

<HIGH />

</item>

</SELECT_CRITERIA>

</TABLES>

</BAPI_ACC_CO_DOCUMENT_FIND>

Former Member
0 Kudos

Hi,

thanks for sharing the XML.

I am just wondering about the Response part. When I look at the Response part in my test, I only see this:


- <BAPI_ACC_CO_DOCUMENT_FIND>
- <TABLES>
<DOC_HEADERS />
<LINE_ITEMS />
<LINE_ITEMS_ACTIVITY />
<LINE_ITEMS_STAT_KEY_FIG />
<RETURN />
<SELECT_CRITERIA>
</TABLES>
</BAPI_ACC_CO_DOCUMENT_FIND>

I do not see an "INPUT" node. Can you please check this? I would also expect the "RETURN" node of the Response to be filled (TYPE, ID, NUMBER, MESSAGE_V1 and so on).

Michael

Former Member
0 Kudos

Not sure what you mean for me to check on the input node? The ResponseXML that I posted is exactly what the MII transaction returned.

I am using a JCo connector if that makes any difference. I have tried the JRA connector also, I have included the request/response for that below:

Request:

- <BAPI_ACC_CO_DOCUMENT_FIND Description="">

- <TABLES>

- <SELECT_CRITERIA>

- <item>

<FIELD>COSTCENTER</FIELD>

<SIGN>I</SIGN>

<OPTION>EQ</OPTION>

<LOW>00MUS80902</LOW>

<HIGH />

</item>

</SELECT_CRITERIA>

</TABLES>

- <INPUT>

- <DOCUMENT Description="">

- <INPUT>

<CO_AREA>5000</CO_AREA>

<PERIOD>001</PERIOD>

<FISC_YEAR>2000</FISC_YEAR>

</INPUT>

</DOCUMENT>

<RETURN_COSTS>X</RETURN_COSTS>

<RETURN_ITEMS>X</RETURN_ITEMS>

<RETURN_VALID_ONLY>X</RETURN_VALID_ONLY>

</INPUT>

</BAPI_ACC_CO_DOCUMENT_FIND>

Response:

- <BAPI_ACC_CO_DOCUMENT_FIND Description="">

- <TABLES>

- <DOC_HEADERS>

- <item>

<CO_AREA />

<DOC_NO />

<FISC_YEAR />

<PERIOD />

<VERSION />

<CO_TRANSAC />

<DOCDATE />

<POSTGDATE />

<DOC_HDR_TX />

<USERNAME />

<REVERSEDOC />

<REVERSED />

<VARIANT />

<OBJ_KEY />

<OBJ_TYPE />

<OBJ_SYS />

<OBJ_KEY_R />

<ORIG_TRANSAC />

<CO_AREA_CURR />

<CO_AREA_CURR_ISO />

</item>

</DOC_HEADERS>

- <LINE_ITEMS>

- <item>

<CO_AREA />

<DOC_NO />

<COSTCENTER />

<ACTTYPE />

<ORDERID />

<WBS_ELEM />

<SALES_ORD />

<S_ORD_ITEM />

<COST_OBJ />

<CO_BUSPROC />

<NETWORK />

<OPERATION />

<RUNSCHD_HD />

<MATERIAL />

<PROD_VERSN />

<PLANT />

<PROFIT_SEGM_NO />

<COST_ELEM />

<VALUE_TCUR />

<TRANS_CURR />

<TRANS_CURR_ISO />

<VALUE_OCUR />

<OBJECT_CURRENCY />

<OBJ_CURR_ISO />

<VALUE_COCUR />

<QUANTITY />

<POSTQUUN />

<POSTQUUN_ISO />

<DR_CR_IND />

<VALUE_TYPE />

<VERSION />

<SEG_TEXT />

<DOC_ITEM />

<PERSON_NO />

<MATERIAL_EXTERNAL />

<MATERIAL_GUID />

<MATERIAL_VERSION />

</item>

</LINE_ITEMS>

- <LINE_ITEMS_ACTIVITY>

- <item>

<CO_AREA />

<DOC_NO />

<COSTCENTER />

<ACTTYPE />

<CO_BUSPROC />

<ACTVTY_QTY />

<ACTIVITYUN />

<ACTIVITYUN_ISO />

<POS_OUTQTY />

<POSTOUTUN />

<POSTOUTUN_ISO />

<ACT_SCHLD />

<SEG_TEXT />

<DOC_ITEM />

</item>

</LINE_ITEMS_ACTIVITY>

- <LINE_ITEMS_STAT_KEY_FIG>

- <item>

<CO_AREA />

<DOC_NO />

<COSTCENTER />

<ACTTYPE />

<ORDERID />

<WBS_ELEM />

<SALES_ORD />

<S_ORD_ITEM />

<COST_OBJ />

<CO_BUSPROC />

<NETWORK />

<OPERATION />

<STATKEYFIG />

<STAT_QTY />

<STAT_UNIT />

<STAT_UNIT_ISO />

<PERSON_NO />

<SEG_TEXT />

<DOC_ITEM />

</item>

</LINE_ITEMS_STAT_KEY_FIG>

- <RETURN>

- <item>

<TYPE />

<ID />

<NUMBER />

<MESSAGE />

<LOG_NO />

<LOG_MSG_NO />

<MESSAGE_V1 />

<MESSAGE_V2 />

<MESSAGE_V3 />

<MESSAGE_V4 />

<PARAMETER />

<ROW />

<FIELD />

<SYSTEM />

</item>

</RETURN>

- <SELECT_CRITERIA>

- <item>

<FIELD>COSTCENTER</FIELD>

<SIGN>I</SIGN>

<OPTION>EQ</OPTION>

<LOW>00MUS80902</LOW>

<HIGH />

</item>

</SELECT_CRITERIA>

</TABLES>

</BAPI_ACC_CO_DOCUMENT_FIND>

agentry_src
Active Contributor
0 Kudos

Since we are not having great success, I am going to suggest some, possibly very obvious, other things to check.

What is the response xml when executing in SE37? It looks like we are only seeing the empty responses from executing in MII.

There was a problem with the JRA connection and certain BAPI/RFCs in 12.0.11 build 14. Patch 1 was released to correct for that problem and would take you to build 19. I don't think this is the cause of your problem, but worth looking into.

In your configuration, are you using the SAP JCo Interface action block by itself or are you using SAP JCo Start Session, SAP JCo Function, etc.? (I would try using both). How are they configured? Execute Function should be checked (in SAP JCo Interface, and SAP JCo Function) and I would go ahead and check Automatically Commit Transaction as well (In SAP JCo Interface. It shouldn't matter, but also doesn't hurt).

Use a small range of cost centers instead of a single value.

Use a more recent year (last year, perhaps?).

Deselect ReturnValidOnly.

Once I see valid xml response, some other tests may suggest themselves.

Good luck,

Mike

Former Member
0 Kudos

I am fairly new to using SE37. How do I extract the response XML so that I can post it here?

I have tried JRA, the single JCo action block and the JCo version with start session, etc, all with the same result. "Execute function" and "commit" are always checked in both versions of JCo that I tried.

Tried a range of Cost Centers with the same result.

Unfortunately, I can't use a more recent year because I am in our development system, which doesn't have any more current data.

Tried both with and without ReturnValidOnly, and it did not make a difference.

John

Former Member
0 Kudos

This ended up being a security access problem. The account MII was using to access the BAPI did not have the correct privileges. The strange thing is that the BAPI did not return an error indicating that there was an access restriction, it just didn't return anything at all.

agentry_src
Active Contributor
0 Kudos

Hi John,

That usually means that the BAPI did not handle the error properly. Normally it should pass the error through back to MII (in the RETURN segment as Michael Otto pointed out). Unfortunately there is a lot of variation in BAPI programming.

And thank you for finishing your thread with the end result.

Regards,

Mike