Skip to Content
author's profile photo Former Member
Former Member

Set value in a table, from Bapi

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...

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

6 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Sep 26, 2005 at 07:58 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 26, 2005 at 01:56 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 26, 2005 at 04:30 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 26, 2005 at 02:37 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      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

  • author's profile photo Former Member
    Former Member
    Posted on Sep 26, 2005 at 07:33 AM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 28, 2005 at 10:53 PM

    Thanks by the help!

    It´s Ok with the table

    Thanks Nibu! and all ... 😀

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.