cancel
Showing results for 
Search instead for 
Did you mean: 

Material List in BAPI_SALESORDER_CREATEFROMDAT2

Former Member
0 Kudos

Hi!

I´m developing a WD app to create a sales order using BAPI_SALESORDER_CREATEFROMDAT2. In the app I want to insert various materials in the sales order, but I don't know how the BAPI stores it, can anybody explain me how can I do this or how the BAPI works with this?

Regards

Juan Jimenez

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Juan,

You need two BAPIs for that. One is to display the input and output and the other one is to save the data which is BAPI_TRANSACTION_COMMIT.

You use the input node of the BAPI for sending the input from Web dynpro and to display the data from BAPI, you will use the output node of the input BAPI.

For all this, you need to import your model first. Then create Custom controller, create context for it. Bind the model data with the controller.

Then create context for views and map the view context with controller context. Bind the UI elements with the context.

Please follow this tutorial, it has info what you are looking for:

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webdynpro/handling transactions with bapis in web dynpro.pdf

Thanks,

Raj.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Raj,

I've already done the import of the model with the two BAPIs that I need, but the problem I have is with the structure of this BAPI in particular, I mean, I know it has an import parameter Order_Items_In for inserting the material data (item) of the sales order, but I want to insert various materials and i don't know how to do this with Order_Items_In.

Am I being clear with my question? If I don't please tell me. Thx for the link

Juan Jimenez

Former Member
0 Kudos

Hi Juan,

In that case you need to add the fields whatever you want to the BAPI Order_Items_In structure. for that you need to go to SE37, open the BAPI, and switch to IMPORT tab of it.

You can add fields to the BAPI by two methods, one is you can add the fields directly, otherone is through .append strcuture, this method is better as it is adaptable during runtime, and you dont need to restart the J2EE Server.

Once you add the fields to your BAPI, you reimport the model and you need to restart the server.

You also need to add the context fields in controller/view contexts and bind respectively.

Thanks,

Raj.

Former Member
0 Kudos

Hi Raj,

Maybe I'm being misunderstood. The fields I need are included on the structure and I don't need to add more,as far as I am understanding (I could be wrong, my english is not perfect), the structure Order_Items_In represents ONE material.

Suppose I want to create a sales order with materials "pencil" and "eraser", if I add the pencil first in Order_Items_In, how I add the eraser next? The BAPI can store various Order_Items_In or it overwrites? If that is the case, how can I solve it?

Thx

Former Member
0 Kudos

HI Juan,

If it is a single field, then it takes only one field at a time. If you want to create the items mutiple times...you need to send the data mutiple times.

If you want to do it at a single time, then u need to insert a structure in your BAPI, in the structure, you can have several variables like item1, item2, item3.

And also you need to send multiple variable from the web dynpro front end.

I hope you are clear now.

Thanks,

Raj.

Former Member
0 Kudos

Hi Juan,

I think Raj is misunderstanding your question a bit...

For starters, to get an idea of how to use some of the standard SAP BAPI's go to transaction BAPI on your SAP system, find the BAPI you are interested in check out the Documentation tab. There is quite a useful description for the SalesOrder.CreateFromDat2 object.

If you then view the actual module in SE37 you can see that ORDER_ITEMS_IN is actually a table and not an import parameter. This means it can have 0...n entries.

Coming back to WD and your example this means that yuor model should have a node with cardinality of 0..n for the ORDER_ITEMS_IN structure. So for every material you want to add to your sales order you add an element to the ORDER_ITEMS_IN node.

For example, if your model node is called BAPI_CREATEFROMDAT2_INPUT it will have a node under it called ORDER_ITEMS_IN and this will have cardinality set to 0..n and it will have a modelClass of say SDModel.BAPISDITM. So when yuo want to add an element to this node you could do something like:

BAPISDITM orderItem = new BAPISDITM();
orderItem.setMatnr("pencil"); etc...
then wdContext.nodeORDER_ITEMS_IN.bind(orderItem);

Hope this is some help - I'm sure there's bits I've missed or got wrong but this should be a good start!

Gareth.

Former Member
0 Kudos

Hi Gareth,

Thx a lot for your answer, that's what I want to do in my app and it gaves me an idea of what to do...Do you know where i can find some sample code or reading about this with more detail?

Regards,

Juan

Former Member
0 Kudos

Hi Juan,

If you go to Application Server on the left of this site and go to the Web Dynpro sample applications and tutorials there is one specifically relating to calling BAPI's from Web Dynpro applications. This is a good start although it doesn't go into passing multiple entries inside tables it does give you the basics.

Good luck!

Gareth.

Former Member
0 Kudos

Hi Juan,

Here is the link for the Webdynpro tutorials. In that follow the tutorial for the RFC models.

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/49f2ea90-0201-0010-ce8e-de1...

Regards,

Bhavik