cancel
Showing results for 
Search instead for 
Did you mean: 

Problem Calling a BAPI with a Table as an input parameter from MII

former_member198480
Participant
0 Kudos

Hi,

I am very new to SAP MII and I am trying to call our custom BAPI with JCo Interface which takes a PLANT_LIST as an input parameter and returns a list of PLANT_STATUS for all those plants.

I have followed the following two blogs and made sure that every thing is in place.

[http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/6688] [original link is broken] [original link is broken] [original link is broken];

[http://www.sdn.sap.com/irj/scn/weblogs?blog=/cs/blank/view/wlg/13519%3fpage%3dlast%26x-showcontent%3doff%26x-t%3dblank.view]

Following is the request structure for my input parameter in MII


<INPUT>
<PLANT_LIST>
<item>
<WERKS/>
...
</item>
</PLANT_LIST>
</INPUT>

I only need to assign the WERKS property of the item in order to get the results.Now when i assign the value to WERKS property of the PLANT_LIST it works fine and returns me the required data but if i add more items to <PLANT_LIST> or remove the old item (<item>) and add multiple items from my repeater, it behaves as if i have passed a blank row as an input.

I confirmed that my <item> structure is same as the <item> structure of the input table. I also confirmed that PLANT_LIST conatins multiple values before calling the JCo function.

Any help would be highly appreciated.

Edited by: Muhammad Umer Farooq on Dec 22, 2010 8:44 AM

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

As per my understanding you have a custom BAPI in which you will pass list of plants (ex. 5 plants P1,P2....P5)

than you will get status of above plants.

Have you checked your BAPI in SAP tcode se37 with multiple plants?

Please check your BAPI input xml structure by tracer.

Thanks & Regards,

Manoj Bilthare

former_member198480
Participant
0 Kudos

Thank you Manoj for your instant response.

Yes, In se37 transaction, the BAPI is able to take a list of multiple plants e.g. P1, P2, P3 ... and for each plant it returns 5 records so let us suppose for 2 plants it returns 10 records according to one business scenario.

I checked the input xml structure in MII when system generated Request and Response Document in JCo and its the same as my xml structure but How can i check the BAPI input xml tracer in SAP?

Former Member
0 Kudos

Hi,

How can i check the BAPI input xml tracer in SAP?

in SAP MII.

Please look into following XML structure for example.

I want to add pass two items in FIELDS node

XML which I am assigining to BAPI Input:

<TABLES>

<DATA>

<item>

<WA/>

</item>

</DATA>

<FIELDS>

<item>

<FIELDNAME>ARBPL</FIELDNAME>

<OFFSET/>

<LENGTH/>

<TYPE/>

<FIELDTEXT/>

</item>

<item>

<FIELDNAME>OBJID</FIELDNAME>

<OFFSET/>

<LENGTH/>

<TYPE/>

<FIELDTEXT/>

</item>

</FIELDS>

<OPTIONS>

<item>

<TEXT> </TEXT>

</item>

</OPTIONS>

</TABLES>

BAPI Input Structure:

<TABLES>

<DATA>

<item>

<WA/>

</item>

</DATA>

<FIELDS>

<item>

<FIELDNAME/>

<OFFSET/>

<LENGTH/>

<TYPE/>

<FIELDTEXT/>

</item>

</FIELDS>

<OPTIONS>

<item>

<TEXT/>

</item>

</OPTIONS>

</TABLES>

Actually i have passed multiple row structure to BAPI and it works fine for me.

Hope this helps you.

Regards,

Manoj Bilthare

former_member198480
Participant
0 Kudos

Yes you are right.

But I am doing the same as well.

Following is my BAPI Structure and i am appending same multiple item structure to PLANT_LIST node for multiple plants.

<ZPROJECT_PLANT_GETSTATUS>

<INPUT>

<PLANT_LIST>

<item>

<MANDT/>

<WERKS>P001</WERKS>

<NAME1/>

<BWKEY/>

<KUNNR/>

<LIFNR/>

<FABKL/>

<NAME2/>

<STRAS/>

<PFACH/>

<PSTLZ/>

<ORT01/>

<EKORG/>

<VKORG/>

<CHAZV/>

<KKOWK/>

<KORDB/>

<BEDPL/>

<LAND1/>

<REGIO/>

<COUNC/>

<CITYC/>

<ADRNR/>

<IWERK/>

<TXJCD/>

<VTWEG/>

<SPART/>

<SPRAS/>

<WKSOP/>

<AWSLS/>

<CHAZV_OLD/>

<VLFKZ/>

<BZIRK/>

<ZONE1/>

<TAXIW/>

<BZQHL/>

<LET01/>

<LET02/>

<LET03/>

<TXNAM_MA1/>

<TXNAM_MA2/>

<TXNAM_MA3/>

<BETOL/>

<J_1BBRANCH/>

<VTBFI/>

<FPRFW/>

<ACHVM/>

<DVSART/>

<NODETYPE/>

<NSCHEMA/>

<PKOSA/>

<MISCH/>

<MGVUPD/>

<VSTEL/>

<MGVLAUPD/>

<SOURCING/>

<OILIVAL/>

<OIHVTYPE/>

<OIHCREDIPI/>

<STORETYPE/>

<DEP_STORE/>

</item>

</PLANT_LIST>

</INPUT>

<TABLES>

<PLANT_STATUS>

<item>

<WERKS/>

<PLANT_STATUS_OVERALL/>

<PLANT_KPI/>

<KPI_STATUS/>

</item>

</PLANT_STATUS>

</TABLES>

</ZPROJECT_PLANT_GET_STATUS>

I created a Local xml property of <item> object with complete structure, populate it and then append it to the input table.

I am only populating the WERKS property. The problem i am facing is that in MII, the request input table <PLANT_LIST> already contains one empty <item> object. If i update the WERKS property of that object it works fine but if i add similar item objects (with different plant IDs) to that list it returns empty record.

jcgood25
Active Contributor
0 Kudos

Your XML structure is not valid, it starts with

<ZPROJECT_PLANT_GETSTATUS>

but ends with

</ZPROJECT_PLANT_GET_STATUS>

I assume the invalid xml is being ignored.

former_member198480
Participant
0 Kudos

Thanks Jeremy but its a typo. Actual one is

<ZPROJECT_PLANT_GETSTATUS>

</ZPROJECT_PLANT_GETSTATUS>

0 Kudos

Can you manually build the input xml and use that in MII as the input of the BAPI (you may have already done this)?

Have you tested your custom BAPI in ECC (t-codes: SE37 or BAPI) with multiple input Items?

Regards,

Mike

former_member198480
Participant
0 Kudos

Fortunately I am doing the same in MII. I used a Repeater component to loop through a local xml structure and populate my own LOCAL <item> object (whose structure is same as the BAPI input <item> object). The moment i try to add the NEW item object in the <PLANT_LIST> the system behaves strangely. It works like a charm if i only update the WERKS property of already available <item> object in Request Input Table structure.

SE 37 works gr8 and I can get multiple rows for multiple plant entries.

I trace my input and output at every point. Lemme try to show it over here.

Following is the result of output variable that shows the complete Request Structure for my BAPI Input

<ZPROJECT_PLANT_GETSTATUS>

<INPUT>

<PLANT_LIST>

<item>
<MANDT/>
<WERKS>AC02</WERKS>
<NAME1/>
<BWKEY/>
<KUNNR/>
<LIFNR/>
<FABKL/>
<NAME2/>
<STRAS/>
<PFACH/>
<PSTLZ/>
<ORT01/>
<EKORG/>
<VKORG/>
<CHAZV/>
<KKOWK/>
<KORDB/>
<BEDPL/>
<LAND1/>
<REGIO/>
<COUNC/>
<CITYC/>
<ADRNR/>
<IWERK/>
<TXJCD/>
<VTWEG/>
<SPART/>
<SPRAS/>
<WKSOP/>
<AWSLS/>
<CHAZV_OLD/>
<VLFKZ/>
<BZIRK/>
<ZONE1/>
<TAXIW/>
<BZQHL/>
<LET01/>
<LET02/>
<LET03/>
<TXNAM_MA1/>
<TXNAM_MA2/>
<TXNAM_MA3/>
<BETOL/>
<J_1BBRANCH/>
<VTBFI/>
<FPRFW/>
<ACHVM/>
<DVSART/>
<NODETYPE/>
<NSCHEMA/>
<PKOSA/>
<MISCH/>
<MGVUPD/>
<VSTEL/>
<MGVLAUPD/>
<SOURCING/>
<OILIVAL/>
<OIHVTYPE/>
<OIHCREDIPI/>
<STORETYPE/>
<DEP_STORE/>
</item>
</PLANT_LIST>
</INPUT>

<TABLES>

<PLANT_STATUS>

<item>
<WERKS/>
<PLANT_STATUS_OVERALL/>
<PLANT_KPI/>
<KPI_STATUS/>
</item>
</PLANT_STATUS>
</TABLES>
</ZPROJECT_PLANT_GETSTATUS>

If i try to add multiple <item> objects like this,


<ZPROJECT_PLANT_GETSTATUS>
<INPUT>
<PLANT_LIST>
<item>
<MANDT/>
<WERKS>AC02</WERKS>
<NAME1/>
<BWKEY/>
<KUNNR/>
<LIFNR/>
<FABKL/>
<NAME2/>
<STRAS/>
<PFACH/>
<PSTLZ/>
<ORT01/>
<EKORG/>
<VKORG/>
<CHAZV/>
<KKOWK/>
<KORDB/>
<BEDPL/>
<LAND1/>
<REGIO/>
<COUNC/>
<CITYC/>
<ADRNR/>
<IWERK/>
<TXJCD/>
<VTWEG/>
<SPART/>
<SPRAS/>
<WKSOP/>
<AWSLS/>
<CHAZV_OLD/>
<VLFKZ/>
<BZIRK/>
<ZONE1/>
<TAXIW/>
<BZQHL/>
<LET01/>
<LET02/>
<LET03/>
<TXNAM_MA1/>
<TXNAM_MA2/>
<TXNAM_MA3/>
<BETOL/>
<J_1BBRANCH/>
<VTBFI/>
<FPRFW/>
<ACHVM/>
<DVSART/>
<NODETYPE/>
<NSCHEMA/>
<PKOSA/>
<MISCH/>
<MGVUPD/>
<VSTEL/>
<MGVLAUPD/>
<SOURCING/>
<OILIVAL/>
<OIHVTYPE/>
<OIHCREDIPI/>
<STORETYPE/>
<DEP_STORE/>
</item>

<item>
<MANDT/>
<WERKS>4514</WERKS>
<NAME1/>
<BWKEY/>
<KUNNR/>
<LIFNR/>
<FABKL/>
<NAME2/>
<STRAS/>
<PFACH/>
<PSTLZ/>
<ORT01/>
<EKORG/>
<VKORG/>
<CHAZV/>
<KKOWK/>
<KORDB/>
<BEDPL/>
<LAND1/>
<REGIO/>
<COUNC/>
<CITYC/>
<ADRNR/>
<IWERK/>
<TXJCD/>
<VTWEG/>
<SPART/>
<SPRAS/>
<WKSOP/>
<AWSLS/>
<CHAZV_OLD/>
<VLFKZ/>
<BZIRK/>
<ZONE1/>
<TAXIW/>
<BZQHL/>
<LET01/>
<LET02/>
<LET03/>
<TXNAM_MA1/>
<TXNAM_MA2/>
<TXNAM_MA3/>
<BETOL/>
<J_1BBRANCH/>
<VTBFI/>
<FPRFW/>
<ACHVM/>
<DVSART/>
<NODETYPE/>
<NSCHEMA/>
<PKOSA/>
<MISCH/>
<MGVUPD/>
<VSTEL/>
<MGVLAUPD/>
<SOURCING/>
<OILIVAL/>
<OIHVTYPE/>
<OIHCREDIPI/>
<STORETYPE/>
<DEP_STORE/>
</item>
</PLANT_LIST>
</INPUT>

<TABLES>

<PLANT_STATUS>

<item>
<WERKS/>
<PLANT_STATUS_OVERALL/>
<PLANT_KPI/>
<KPI_STATUS/>
</item>
</PLANT_STATUS>
</TABLES>
</ZPROJECT_PLANT_GETSTATUS>

It returns an empty record with no plant ID.

I double checked that values exist for these plants in ECC and it works in SE37 with multiple inputs.

Could there be any other problem with BAPI in ECC ?

Is there any other simple Standard BAPI that i can test with my MII code???

Like the BAPI that can take input table and return a table as well in order to make sure there is no problem on MII side.

Former Member
0 Kudos

Hi,

There is one RFC RFC_READ_TABLE you can get data from your SAP table.

Regards,

Manoj Bilthare

former_member198480
Participant
0 Kudos

Thanks Manoj for your response. It really helped me.

I tested this RFC and it is working fine with me from MII with same implementation.

One thing I noticed is that in my Function Module Following is the Structure of Import parameters and table.

Import Paramaters

PLANT_LIST (Table Input)

Tables

PLANT_STATUS (Table Output)

I populated the PLANT_LIST table of Import parameters and send it back to ECC and get results in PLANT_STATUS

However, in other Function Modules (examples given on SDN and RFC_READ_TABLE) has following kind of structure

Import Paramaters

QUERY_TABLE (Single Input)

...

Tables

OPTIONS (Input/ Output Table)

FIELDS (Input/ Output Table)

DATA (Output Table)

Over here, We are populating the FIELDS table that is defined as a part of TABLE and NOT the Import Parameters.

I don't know the difference of Import parameters and Table as of now.

Am i missing something???

Edited by: Muhammad Umer Farooq on Dec 23, 2010 10:43 AM

Edited by: Muhammad Umer Farooq on Dec 23, 2010 12:47 PM

0 Kudos

While there are many of us here on the MII forum who have some experience with ABAP and coding function modules and BAPIs, you may be better off asking the question on the ABAP forum.

Good luck!

Mike

former_member198480
Participant
0 Kudos

BTW, This is just to inform that I have resolved this problem and here are my findings, probably it would help some other as well.

There are some fields in my PLANT_LIST item that needs to be populated before calling through JCo. They are having '0' value but this is required by Function Module. This was one issue.

Other issue that I was suspecting that IMPORT_PARAMETERS in Function modules take only single values, is true as far as passing values from MII is concerned. If you pass multiple "items/records" to the table and pass it to the Function Module, it returns single record only for the first value, So we need to define the table input under TABLES in function Module.

Hope it helps.

0 Kudos

Many thanks for the follow up and solution. I am sure it will be helpful at some point in the future.

Best Regards,

Mike

Former Member
0 Kudos

Michael,

Your prophecy came true!

BTW, it follows a tip:

In BAPI, to test if the input table is empty, make sure to test over the table itself, like this (with brackets) :

IF p_wa_ytest[] IS NOT INITIAL.

And do not test over the header line, like this:

IF p_wa_ytest IS NOT INITIAL.

Thanks Farooq!

Alexandre Sardinha

HariCS23
Contributor
0 Kudos

Hello Alexandre, You can avoid this issue by using 'remove xml"  for that import/table parameter in link editor .

Thanks

Hari