Skip to Content
Author's profile photo Former Member

Differnce between add and bind method for passing elements to a bapi from webdynpro

We’ve already seen a blog on handling structure and table using Bapi’s in webdynpro by Perumal Kanthan
I’ve come across another problem when I wanted to send multiple rows from a table to a bapi
Let’s take a purchase requisition creation as an example.
I used BAPI called Bapi_Requisition_Create_Input.

This handles data for creation of new purchase requisition. Now if I have to pass multiple element from a table in webdynpro to table Requisitin_Items in the above BAPI which is nothing but a structure following steps have to be followed

    • Creating corresponding Value node in Custom controller

After creating corresponding node in custom controller do context mapping from view context to custom controller context

After importing structures to the model in webdynpro and mapping it to the corresponding field in the table of webdynpro screen, we should go through this code in on clicking of an event or triggering of a button event

Where Bapiebanc is the class corresponding to Requisitin_Items table in webdynpro generated during model creation for Bapi_Requisition_Create_Input

After that we will be dynamically setting values in Bapiebanc class from ValueNode Object by getter and setter methods.

As we have multiple rows in our table so we have to take size of the node to pass all the elements to bapi.
For this we would use a loop to node size, in our case this is TableNode which holds all the elements which have to pass to the corresponding table of the bapi Bapi_Requisition_Item.
Here after putting loop we set all the elements and then after that we add items to the node of the Requisition_Items by using addRequisitin_Items method by passing the object of “Bapiebanc” class “re” by getting values from the TableNode “tn” which holds elements have to be passed to the table.

.addRequisition_Items(re);//multiple element binding to the object

<u>Use of  add<node name>(node object) method over bind(node object) method</u>

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member
      There is an overloaded bind(Collection c) method available for every node. In my opinion this method can be used to add multiple elements to the node. For eg. if we have a parent "Root" node and child "Child" node this piece of code can be written to pass multiple data :-

      IRootElement rootElem =

      Collection collect = new ArrayList();
      for (int iLoop = 0; iLoop<10; iLoop++) {
      IChildElement childElem =
           * Add the data

      I have not had the oppurtunity to see the output of this hence would like to know your comments on this piece of code.


      Author's profile photo Former Member
      Former Member
      Blog Post Author
      HI Sidharth,
        I'm not sure abt the error as our r/3 servers are down.I'll get back to u when our servers will be up.
      I'm not sure but in case of BAPI it didn't work.
        Niharika Jeena
      Author's profile photo Former Member
      Former Member
      Hi Hiharika,
      This will not work in case of a BAPI because the element is added to the "context". The idea is to add the elements to the model "object". What I have observed is that the object picks up data from the context only if the corresponding object exists in the model itself. i.e. if you created a number of elements in the model, those would be available in the context through binding and any changes there would be referenced to the element object in the object too. So as far as input fields are concerned, you have to create the corresponding elements in the "object" and not in the context.
      Author's profile photo Former Member
      Former Member
      Blog Post Author
      Hi Nirav,
        I agree with in case of BAPI's if we do it with model object it will work fine and it take all the values but when u've to edit u'r tables in u'r dynpro screen then u need to create value node and have to add it to context and in this way u can transfer data from TABLE to BAPI using context handling.Because when u use model object then u 've to set its cardinality as per my knowledge which u have set in model object and which restrict cardinality of object in view to 0..n which makes the table uneditable from where the problem arise.