Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member184551
Contributor


Creating sales orders via ‘BAPI_SALESORDER_CREATEFROMDAT2’ using variant configured materials


SAP Product Id: LO-VC

SAP Provides a BAPI viz ‘BAPI_SALESORDER_CREATEFROMDAT2’ in order to create Sales Orders.

The usage of this BAPI is quite simple when used to create sales orders that do not used configured materials. But when it comes to creating sales orders that use variant material configurations, the logic of filling the pre-requisite structures of this BAPI is a little complicated and therefore this blog.

First things first, there is an SAP note which explains how the prerequisite structures should be filled. That note is 0000549563.

The four mandatory structures to be filled are;

1. ORDER_CFGS_REF

2. ORDER_CFGS_INST

3. ORDER_CFGS_PART_OF

4. ORDER_CFGS_VALUE

The first & the second are pretty much self explanatory; it’s the third and the fourth that require some explanation.

1. ORDER_CFGS_PART_OF:


Note 549563 says;

PART_OF_NO is the item number from the BOM

But please keep in mind that you will get the right PART_OF_NO if you use the sales BOM & not the production BOM

CONFIG_IDPARENT_IDINST_IDPART_OF_NOOBJ_KEY
00000100000001000000020010PROD112
00000200000003000000040010PROD122

Here is how you find the item number for a material from a Bill of Material (BOM) ;

2. ORDER_CFGS_VALUE:

This is the tricky part since there are a lot of dynamics involved here, for instance,

    a)  There could be default characteristics for a particular class, and that might or might not appear in your order

    b)  The value range supplied could be over and above than that maintained in characteristics maintenance (Maintained by transaction CT04)

So how do you take care of that? We will get to those questions in a moment but first, here is the logic for populating this parameter.

The tables to be used are INOB, KSSK, KSML and CAWN

     a)  First pass your material in the table INOB ( Link between Internal Number and Object ) where INOB-OBJEK = your material number and fetch the           object number CUOBJ (Also enter your class type, KLART & name of the database table for object OBTAB, for variants this class will be 300)

     b)  Then pass the object number ( CUOBJ ) in the KSSK table where KSSK-OBJEK = INOB-CUOBJ to fetch the Internal class number ( CLINT )

     c)  Pass the Internal class number (CLINT) into the KSML table such that KSSK-CLINT = KSML-CLINT to finally fetch the Internal characteristic                     (IMERK). Put the results of the steps a), b), & c) in an internal table, say table A.

          Now since a picture speaks a thousand words for those who can see, here is what we have done so far in a nutshell

     d)  Now select the characteristics & its values from the master table CAWN by passing the material numbers that you are using to create the order.                     Put the results of step d) in another internal table B.

          The idea here is that since we have arrived at table A by querying with the material & class, and the result of the material B by passing just the                           materials, the results of table B should be in table A. so we loop at table B and read table A. Here is the code below;

          After this you need to separate the characteristics from the quantity, and you do that like the way shown below (of course you can code in                     whatever way you want to)

  Now back to the questions that we asked at the beginning

     a) There could be default characteristics for a particular class, and that might or might not appear in your order

         This could be checked by inquiring the value ATSTD of the table CAWN

         Here is a screenshot below;

             b) The value range supplied could be over and above than that maintained in characteristics maintenance (Maintained by transaction CT04)

     Use the code n box3, reproduced below

Finally call your BAPI

Don’t worry about the object dependencies; the BAPI takes care of it.

That's all folks !

Thanks

3 Comments