Quantcast
Channel: SAP ERP Sales and Distribution (SAP SD)
Viewing all articles
Browse latest Browse all 69

Create Sales Order using BAPI with Variant Configuration

$
0
0

The purpose of this Blog is to describe the Variant Configuration in Sales Order Creation. Before posting this blog, I have referred many SDN blogs, threads and other sites for any sort of help ....But no success.


Variant Configuration:

         

      It is a tool which helps to simplify the complex manufacturing of final product with more varieties and Variation of the input Material.


Example of industries relevant to SAP VC:  Auto mobile Manufacturing, Furniture Manufacturing, Aircraft Manufacturing, Personal Computers,Elevator Systems,Bicycle,Cars, Motor Cycles, Pumps etc.

 

Variant Configuration is for manufacturing complex products in which customer determines the features of the product and it also helps the customers or salespersons to put together specification for the product. Objective of variant configuration is to react quickly to customers’ requirements.

                   

         Here it needs not to create separate Material for each variant of a product. When companies introduce variant configuration this often goes beyond a business process re-engineering project.

 

Variant Configuration offers an opportunity to restructure product structures for which then processes are defined. This has a direct impact to the core areas such as marketing and product data management.


               Variant configuration is useful if you have large number of combination of parts that go into a product. It means different Permutations and Combinations of the parts for same material.

                   

For Examples:

  • In a business involving steel manufacturing, the customer may order steel involving different physical properties like tensile strength, diameter, colour etc.
  • A Customer ordering a Motor Bike can choose different combination of accessories and colour.

 

To define the features of a configurable material, you use Characteristics. To enable you to use Characteristics to configure material, you allocate the material to a class of class type 300. Each Configurable object must have a configuration profile. The configuration profile for a material controls the configuration process in the Sales Order.

                

          You use Dependencies to ensure that only allowed combination of features are selected. Dependencies also select exactly the right BOM (Bill ofMaterial) components and operations to produce a variant.


I have a requirement to create sales order with variant configuration materials, in this scenario I am used function module BAPI_SALESORDER_CREATEFROMDAT2.


          The usage of this BAPI is very simple when used to create sales order that do not used configurable materials. But when it comes to creating sales order using variant configuration materials, the logic of filling the structures of this BAPI is a little bit complicated.


There is a SAP note549563- BAPI: Filling configuration structures which explains how the Configuration structures in the BAPI need to be filled?


              For updating variant configuration (VC) data for sales order item, we need to populate below tables of standard function module or BAPI (e.g. BAPI_SALESORDER_CREATEFROMDAT2).


Sales Order Item Data


ls_item-itm_number       = '000001'.
ls_item
-po_itm_no        = '000001'.
"Should be fill this field
ls_item
-target_qty       = '1'.
ls_item
-material         = 'MAT12'.
APPEND ls_item TO lt_item.


Why the PO_ITM_NO field should be filled because the field POSEX (PO_ITM_NO) to define the connection between the sales order item and the configuration (BAPICUFG-POSEX) (ls_item-po_itm_no = w_sales_cfgs_ref-posex).


     If the item number is 000001, for example ls_item-po_itm_no = 000001 and ls_itemx-po_itm_no = 'X'. so that the configuration is called.


Sales Order Item Data Flags


ls_itemx-itm_number           = '000001'.
ls_itemx
-po_itm_no            = 'X'.
ls_itemx
-target_qty           = 'X'.
ls_itemx
-material             = 'X'.
APPEND ls_itemx TO lt_itemx
.


Schedule Line structure


ls_schedules-itm_number = '000001'.
ls_schedules
-sched_line = '0001'.
ls_schedules
-req_qty    = '1'.   
ls_schedules
-req_date   = '20160120'.
APPEND ls_schedules TO lt_schedules
.


Fill schedule line flags


ls_schedulesx-itm_number      = '000001'.
ls_schedulesx
-sched_line      = '0001'.
ls_schedulesx
-updateflag      = 'X'.
ls_schedulesx
-req_qty         = 'X'.
ls_schedulesx
-req_date        = 'X'.
APPEND ls_schedulesx TO lt_schedulesx
.


The Mandatory Structures filling for Variant Configuration in BAPI are:


    1. ORDER_CFGS_REF
    2. ORDER_CFGS_INST
    3. ORDER_CFGS_VALUE
    4. SALES_CFGS_VK


ORDER_CFGS_REF and ORDER_CFGS_INST tables should have one record per item and combination of CONFIG_ID and ROOT_ID should be unique across line items.


* Filling Configuration Reference Data SALES_CFGS_REF Table
w_sales_cfgs_ref
-posex      = '000001'.”ItemNumber
w_sales_cfgs_ref
-config_id  = '000001'.
w_sales_cfgs_ref
-root_id    = '00000001'.
w_sales_cfgs_ref
-complete   = 'T'.                “GeneralIndicator
w_sales_cfgs_ref
-consistent = 'T'
.  

   APPEND w_sales_cfgs_ref TO lt_sales_cfgs_ref.
CLEAR w_sales_cfgs_ref.


* Filling Configuration Instances SALES_CFGS_INST Table
w_sales_cfgs_inst
-config_id       = '000001'.
w_sales_cfgs_inst
-inst_id         = '00000001'.
w_sales_cfgs_inst
-obj_type        = 'MARA'.
w_sales_cfgs_inst
-class_type      = '300'.
w_sales_cfgs_inst
-obj_key         = 'KL'.         “MaterialNumber
w_sales_cfgs_inst
-quantity_unit   = 'LF'.
APPEND w_sales_cfgs_inst TO lt_sales_cfgs_inst.
CLEAR w_sales_cfgs_inst
.


ORDER_CFGS_VALUE and SALES_CFGS_VK tables we can have multiple characteristics for a material, in that case appropriate records should be inserted and combination of CONFIG_ID and ROOT_ID should be unique across line items.


*Characteristics Values Filling

* ColorCode
ls_sales_cfgs_value_in
-config_id = '000001'.
ls_sales_cfgs_value_in
-inst_id   = '00000001'.
ls_sales_cfgs_value_in
-charc     = 'ZCOLOR'. “Characteristic Name
ls_sales_cfgs_value_in
-value             = 'CHBC'.   “Characteristic Value 
APPEND ls_sales_cfgs_value_in TO lt_sales_cfgs_value.
CLEAR ls_sales_cfgs_value_in
.


* Gauge
ls_sales_cfgs_value_in
-config_id    = '000001'.
ls_sales_cfgs_value_in
-inst_id        = '00000001'.
ls_sales_cfgs_value_in
-charc          = 'ZGAUGE'.        “Characteristic Name
ls_sales_cfgs_value_in
-value          = '24'.           “Characteristic Value
APPEND ls_sales_cfgs_value_in TO lt_sales_cfgs_value.
CLEAR ls_sales_cfgs_value_in
.


*---Filling Configuration Variant Condition Key SALES_CFGS_VK

* ColorCode
         ls_sales_cfgs_vk-config_id    = '000001'.
          ls_sales_cfgs_vk-inst_id        = '00000001'.

           ls_sales_cfgs_vk-vkey           =  'ZCOLOR'.               “Characteristic Name
APPEND ls_sales_cfgs_vk TO ex_cfgs_vk.
CLEAR : ls_sales_cfgs_vk.

 

* Gauge
ls_sales_cfgs_vk
-config_id       = '000001'.
ls_sales_cfgs_vk
-inst_id          = '00000001'.
ls_sales_cfgs_vk
-vkey             = 'ZGAUGE'.    “Characteristic Name
APPEND ls_sales_cfgs_vk TO ex_cfgs_vk.
CLEAR : ls_sales_cfgs_vk.


Finally call your BAPI


  CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
EXPORTING
      order_header_in    
= ls_header
      behave_when_error  
= 'P'
IMPORTING
      salesdocument      
= lv_vbeln
TABLES
     
return                                  = lt_return
      order_items_in     
= lt_item
      order_items_inx    
= lt_itemx
      order_partners     
= lt_partner
      order_schedules_in 
= lt_schedules
      order_schedules_inx
= lt_schedulesx
      order_cfgs_ref     
= lt_sales_cfgs_ref
      order_cfgs_inst    
= lt_sales_cfgs_inst
      order_cfgs_value   
= lt_sales_cfgs_value
      order_cfgs_vk      
= lt_sales_cfgs_vk
.


It will very helpful for those, who are struggling with Variant Configuration while creating a Sales order using BAPI.


Thanks,

Harikrishna          


Viewing all articles
Browse latest Browse all 69

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>