cancel
Showing results for 
Search instead for 
Did you mean: 

Set value in a table, from Bapi

Former Member
0 Kudos

Hi, I have a little Problem, I hope that you can help me.

i have the following structure (in the View)

->Zbapi_Requisition_Change_Input (Model Node, from bapi, RFC)

--> Requisition_Items_Change (Model Node, table in the Bapi)

-


> Currenci (Model Atribut, from table, in bapi)

-


> Prq_No (Model Atribut, from table, in bapi)

-


> Preq_Item (Model Atribut, from table, in bapi)

-


> Etc...

--> Number (Model Atribut, import from bapi)

now, i Have another structure, a Value Node

-> GetDetailData (value Node)

---> Currenci (Value Atribut)

---> Prq_No (Value Atribut)

---> Preq_Item (Value Atribut)

---> Number (Value Atribut)

---> etc...

this Value node is populate from OVS, but this is not a problems.

The Value node have the value that i need for execute the Bapi Requisition Change (not all).

Then, i need populate de Zbapi_Requisition_Change_Input , whit the GetDetailData value ( the user can change this, via inputfield, in Form)

I write the following sentence in the view:

wdContext.currentZbapi_Requisition_Change_InputElement().setNumber(wdContext.currentGetDetailDataElement().getPreq_No());

this work fine, it populate de input field "Number", because the Number is "Import" form bapi, is not a "table".

My problem, is when i need populate the table "Requisition_Items_Change" (Necessary to execute the Bapi), i put this:

wdContext.nodeZbapi_Requisition_Change_Input().nodeRequisition_Items_Change().currentRequisition_Items_ChangeElement().setPreq_Item(wdContext.currentGetDetailDataElement().getPreq_Item());

this have the same logical that anterior, but don't work, result a "JaVaNullPoint Exception"

why happens this??? to set a value in a table, I need another procedure???

Please help me, i need your knowledge...

regards...

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Antonio,

I feel, your code should look some thing similar to the below:

Assume that BAPI 'Zbapi_Requisition_Change' uses a table 'Requisition_Items_Change' of some type 'ZTAB' .

Zbapi_Requisition_Change_Input input = new Zbapi_Requisition_Change_Input () // create an instance of the Input class;

ZTAB table = new ZTAB();

//if you do not know table type of 'Requisition_Items_Change' , check the function input.addRequisition_Items_Change(<table type>)

table.set<property1>(<your-value>);

.

.

table.set<propertyn>(<your-value>););

input.addRequisition_Items_Change(table);

wdcontext.currentZbapi_Requisition_Change_InputElement.bind(input);

Now execute the BAPI using the following line

wdContext.currentZbapi_Requisition_Change_InputElement().modelObject().execute();

wdContext.nodeOutput.invalidate()

// clears the old value in the output node

Hope this helps,

Best Regards,

Nibu.

Message was edited by: Nibu Wilson

Answers (5)

Answers (5)

Former Member
0 Kudos

Thanks by the help!

It´s Ok with the table

Thanks Nibu! and all ...

Former Member
0 Kudos

Hello, thanks for its answers.

Some Considerations:

I cannot do "model.setRequisition_Items_Change(new ());"

Because de Structure type for setRequisition_Items_Change is "Abstract", and it does not allow to assign it.

The other opcion, to create a table, perhaps can work, but i have a problem.

This sentence, I have to execute from "Custom Controller":

Zbapi_Requisition_Change_Input input = new Zbapi_Requisition_Change_Input();

ZTAB table = new ZTAB(); (ZTAB is ZBapiebanv)

table.set), is in the view...

then ¿How i cant invocate this value, which are storage in "view", from "Custom controller"???

another thinks.. the option

wdcontext.currentZbapi_Requisition_Change_InputElement.bind(input); does not appear

is the same that wdContext.nodeZbapi_Requisition_Change_Input().bind(input); ???

thanks a lot for your help

Message was edited by: Antonio Villagran

Former Member
0 Kudos

Hi Antonio,

1)

I'm very sorry. I had intended to write wdContext.nodeZbapi_Requisition_Change_Input().bind(input);

Hope this helps,

Best Regards,

Nibu.

Former Member
0 Kudos

Hi Antonio,

Do one thing.

Write following code before your code for setting Preq_Item()

ele = wdcontext.createRequisition_Items_ChangeElement();

wdcontext.nodeRequisition_Items_Change().addelement(ele);

Now, write following code.

wdContext.nodeZbapi_Requisition_Change_Input().nodeRequisition_Items_Change().currentRequisition_Items_ChangeElement().setPreq_Item(wdContext.currentGetDetailDataElement().getPreq_Item());

Regards,

Bhavik

Former Member
0 Kudos

helo Antonio,

i think here u want to send an internal table to the Bapi. for that u have to create Objects of table ie.

Requisition_Items_Change obj = new Requisition_Items_Change();

obj.set<attribute>(" ");

model.add(obj);

create n number of obj that u want to pass to Bapi.

hope this might help u.

Regards,

Piyush.

Former Member
0 Kudos

Hi Antonio,

At the time of initialization of your model structure you also need to initialize your Requisition_Items_Change structure.

Like,

Zbapi_Requisition_Change_Input model = new Zbapi_Requisition_Change_Input();

model.setRequisition_Items_Change(new <structure type>());

wdcontext.nodeZbapi_Requisition_Change_Input().bind(model);

Regards,

Bhavik

Former Member
0 Kudos

Hi Antonio,

I think the null pointer is because the node Requisition_Items_Change is not there. So when you are trying to set a value to the attribute its throwing the null pointer exception. Try creating a new element of the Requisition_Items_Change node and then set the value to the node.

Regards

Prakash