cancel
Showing results for 
Search instead for 
Did you mean: 

Table values not passed to R3

Former Member
0 Kudos

Hi,

I have a BAPI that has 3 importparameters and 1 Input table.

When I execute it, the input parameters are filled but the table is always send initial to R3.

This is my code:

		IPublicInventoryCmp.IIm_T_ItemsElement element = 
                            wdContext.createIm_T_ItemsElement(new Zcab_L_Inv_Items());
		
		wdContext.nodeIm_T_Items().bind(new Zcab_L_Inv_Items());
		wdContext.nodeIm_T_Items().addElement(element);
		
		element.setBatch(wdContext.currentV_Im_ItemsElement().getBatch());
		element.setMaktx("");
		element.setMat_Type("");
		element.setMatnr(wdContext.currentV_Im_ItemsElement().getMatnr());
		
		
		
		wdContext.currentZ_Bapi_Create_Inv_InputElement().modelObject().execute();
		wdContext.nodeOutputCreate().invalidate();

Now there should be 1 row passed to R3 but if It try to run that there will be an table with nothing!

Does anyone have an idea whats wrong?

Thanks and best regards,

Dennis

Accepted Solutions (1)

Accepted Solutions (1)

monalisa_biswal
Contributor
0 Kudos

When you pass table parameters you need to get parent model class reference.

Instead of calling set<parametername>() method for table parameters call add<parametername>() method on the reference.

Z_Bapi_Create_Inv_Input <ref>= new Z_Bapi_Create_Inv_Input ();

wdContext.nodeZ_Bapi_Create_Inv_Input().bind(<ref>);

<tableparameter's class> <ref_table>=new <tableparameter's class>();

<ref>.add<tableparametername>(<ref_table>);

<ref_table>.set<parameter1>("<value>"); .

.

.

<ref_table>.set<parametern>("<value>");

Former Member
0 Kudos

Hi Monalisa,

I tried your hint and now it works!

I don't really understand why I have to get a reference of the model class because there should be already one.

But, it is like it is...

Thanks and best regards!

Dennis

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Dennis,

Try the following coding procedure.

1) Create an instance for the model node.

Z_<> modelNode = new Z_<>;

2) Bind the instance to the node.

wdContext.nodeZ_<>().bind(modelNode);

3) Set the 3 input parameters in ur case.

modelNode.set<>();

modelNode.set<>();

modelNode.set<>();

4) Create an instance for the class that contains the table import parameters.

Z_class() importClass = new Z_class();

5) Set the table values to this instance.

importClass.set<>();

6) Add this element to the node.

wdContext.nodeZ_class().addElement(importClass);

7) Finally add the import table parameter to the model node.

modelNode.add<table parameter>(importClass);

😎 Now Execute the Bapi.

modelNode.execute();

- Nagarajan.

Oops hope u got the solution....

Message was edited by:

Nagarajan Kumarappan

Former Member
0 Kudos

Hi Satyajit and Gopi,

i tried both of your suggestions, but it was the same result

I always get the message back: "Mandatory parameter IM_T_ITEMS of method Z_BAPI_CREATE_INV missing" what means that the table will be delivered initial...

I tried the bapi in R3 and there it works fine!

The R3 system is a 4.6C.

Any other clues?

regards,

Dennis

Former Member
0 Kudos

Hi,

Just a modification to my earlier code:

Zcab_L_Inv_Items() items = new Zcab_L_Inv_Items());
 
items.setBatch(wdContext.currentV_Im_ItemsElement().getBatch());
items.setMaktx("");
items.setMat_Type("");
items.setMatnr(wdContext.currentV_Im_ItemsElement().getMatnr());
 
/* add this to the main BAPI input element.
   You must have created an element like this
   Z_Bapi_Create_Inv_Input input = new Z_Bapi_Create_Inv_Input();
   So add it like
*/
input.setZcab_L_Inv_Items(items);

wdContext.currentZ_Bapi_Create_Inv_InputElement().modelObject().execute();
//...

Regards,

Satyajit.

Former Member
0 Kudos

Dennis,

It's always "safer" to modify model objects of Adaptive RFC model directly rather then via node elements creation. So:

1. Make sure your context mapping to model has all "supplyingRelationRole" properties of nodes set correctly.

2. In your code modify model objects directly:


final <BapiName>_Input query = wdContext.current<BapiName>_InputElement()
  .modelObject();
query.add<TableName>( new <TableName>() );

3. Now your data will be both visible on UI (thanks to supplyingRelationRole) and will be passed correctly during call.

Valery Silaev

SaM Solutions

http://www.sam-solutions.net

Former Member
0 Kudos

hi,

below this statement add the element to the node

element.setMatnr(wdContext.currentV_Im_ItemsElement().getMatnr());

write this

wdContext.nodeIm_T_Items().addElement(element);

check out this thread also.

regards,

Gopi

Message was edited by:

gopi nidjelli

Former Member
0 Kudos

Hi,

Try like this:


Zcab_L_Inv_Items() items = new Zcab_L_Inv_Items());

items.setBatch(wdContext.currentV_Im_ItemsElement().getBatch());
items.setMaktx("");
items.setMat_Type("");
items.setMatnr(wdContext.currentV_Im_ItemsElement().getMatnr());

wdContext.nodeIm_T_Items().bind(items);

wdContext.currentZ_Bapi_Create_Inv_InputElement().modelObject().execute();
//...

Regards,

Satyajit.