cancel
Showing results for 
Search instead for 
Did you mean: 

BAPI for Creating Sales Order For Variant Configuration Materials

former_member1091983
Active Contributor
0 Kudos

Dear Gurus,

Before posting this thread, we have referred many SDN threads, OSS notes and other sites for any sort of help..but no success..All threads and other referrals are not much of help as they are kind of incomplete( Perhaps, we are unable to understand them..no offense).

Few checked threads on this subjects are:

http://scn.sap.com/thread/34590

http://scn.sap.com/thread/851070

http://scn.sap.com/community/abap/blog/2014/04/23/update-vc-variant-configuration-data-using-standar...

http://scn.sap.com/community/abap/blog/2014/07/15/creating-orders-with-variant-configured-items-usin...

http://scn.sap.com/community/abap/blog/2014/04/23/update-vc-variant-configuration-data-using-standar...

http://scn.sap.com/thread/120144

OSS: 549563

Well, we're using the BAPI (BAPI_SALESORDER_CREATEFROMDAT2) which creates the sales order successfully but without the characteristic values in line items.

We're passing data to the following parameters - ORDER_CFGS_REF, ORDER_CFGS_INST, ORDER_CFGS_VALUE to create the variant config but not able to see it getting created.

Pls find attached BAPI coding document for your reference.

If you could throw any light on this issue will be of great help for us.

Thank You in Advance!!!

Reg,

Jagan-SD.

Accepted Solutions (1)

Accepted Solutions (1)

former_member200027
Active Participant
0 Kudos

Hi,

Firstly, I would like to emphasize following information mentioned in note 549563:

==================================================================================

"Use the field POSEX (PO_ITM_NO) to define the connection between the sales order item
and the configuration (BAPICUFG-POSEX) ( ORDER_ITEMS_IN-PO_ITM_NO = ORDER_CFGS_REF-POSEX ).
If the item number is 000010, for example, fill ORDER_ITEMS_IN-PO_ITM_NO = 000010 and
ORDER_ITEM_INX-PO_ITM_NO = X so that the configuration is called. "

==================================================================================

So, please make sure field POSEX has been fulfilled correctly.


Secondly, please also check following notes:

900380     Configurable items in the SD process (idocs & bapis)
900869 - Filling configuration for EDI/BAPI


At last, in some cases, item with characteristic values is not created due to some other
messages, such as message V1 114. So, please also check whether there are some problematic
messages issued in rerturn table.


Best regards,
Crystal Lin

Answers (2)

Answers (2)

Ritz
Active Contributor
0 Kudos

Jagan nath

Try below.

you would need miimum of 3 segments to pass variant config data using this bapi

ORDER_CFGS_REF for each configurable item

POSEX = ITEM #

CONFIG_id , root_id - Start with 1 and increment it for each configurable line item

ORDER_CFGS_INST

CONFIG_ID - from above

INST_ID - Start with 1 and increment it for each configurable line item

OBJ_TYPE = "MARA'

CLASS_TYPE = '300'

OBJ_KEY = material #

ORDER_CFGS_VALUE

CONFIG_ID for the item, INST_ID for the item

charc for characteristic value

VALUE for characteristic value

Reference thread

How to Fill Configuration Data in BAPI BAPI_SALESORDER_CREATEFROMDAT2

Hope it will solve your issue.

Thanks

Ritesh

former_member1091983
Active Contributor
0 Kudos

Dear All,

The issue has been resolved. Thank you for your suggestions.

However, most of them are referred by me already. Still they were helpful..

I will post a separate solution document soon on this topic for others benefit in future.

Thank you once again!

Jagan.

harikrishna_malladi
Active Participant
0 Kudos

Hi Jagan,

can you please help me out as im also stuck in same thing.

I have following characteristics maintain

*ORDER_CFGS_REF

wa_ORDER_CFGS_REF-posex         = '000010'.

wa_ORDER_CFGS_REF-CONFIG_ID     = '000001'.

wa_ORDER_CFGS_REF-ROOT_ID       = '00000001'.

wa_ORDER_CFGS_REF-SCE           = '1'.

wa_ORDER_CFGS_REF-COMPLETE      = 'T'.

wa_ORDER_CFGS_REF-CONSISTENT    = 'T'.

wa_ORDER_CFGS_REF-CBASE_ID_TYPE = '1'.

APPEND wa_ORDER_CFGS_REF TO it_ORDER_CFGS_REF.

****Filling ORDER_CFGS_INST

wa_ORDER_CFGS_INST-CONFIG_ID        = '000001'.

wa_ORDER_CFGS_INST-INST_ID          = '00000001'.

wa_ORDER_CFGS_INST-OBJ_TYPE         = 'MARA'.

wa_ORDER_CFGS_INST-CLASS_TYPE       = '300'.

wa_ORDER_CFGS_INST-OBJ_KEY          = '1901'.       "MATNR value

wa_ORDER_CFGS_INST-QUANTITY         = '10'.            "Quantity value

wa_ORDER_CFGS_INST-QUANTITY_UNIT    = '10'.            "Quantity Unit

wa_ORDER_CFGS_INST-COMPLETE         = 'T'.

wa_ORDER_CFGS_INST-CONSISTENT       = 'T'.

wa_ORDER_CFGS_INST-OBJECT_GUID      = '1300-100'.       "MATNR value

wa_ORDER_CFGS_INST-PERSIST_ID_TYPE  = 'G'.

APPEND wa_ORDER_CFGS_INST TO it_ORDER_CFGS_INST.

*ORDER_CFGS_VALUE

wa_ORDER_CFGS_VALUE-CONFIG_ID     = '000001'.

wa_ORDER_CFGS_VALUE-INST_ID       = '00000001'.

wa_ORDER_CFGS_VALUE-CHARC         = 'Material characteristics'.

wa_ORDER_CFGS_VALUE-VALUE         = 'Material characteristics value'.

APPEND wa_ORDER_CFGS_VALUE TO IT_ORDER_CFGS_VALUE.

*ORDER_CFGS_VK

wa_ORDER_CFGS_VK-CONFIG_ID        = '000001'.

wa_ORDER_CFGS_VK-INST_ID          = '00000001'.

wa_ORDER_CFGS_VK-VKEY             = 'Material characteristics'.

APPEND wa_ORDER_CFGS_VK TO IT_ORDER_CFGS_VK.

CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'

   EXPORTING

*   SALESDOCUMENTIN               =

     order_header_in               = ls_header1

*   ORDER_HEADER_INX              =

*   SENDER                        =

*   BINARY_RELATIONSHIPTYPE       =

*   INT_NUMBER_ASSIGNMENT         =

*   BEHAVE_WHEN_ERROR             =

*   LOGIC_SWITCH                  =

*   TESTRUN                       =

*   CONVERT                       = ' '

  IMPORTING

    salesdocument                  lv_order

   TABLES

    return                         lt_return1

     order_items_in                lt_item1

*   ORDER_ITEMS_INX               =

     order_partners                lt_partner1

     order_schedules_in            lt_schedule1

*   ORDER_SCHEDULES_INX           =

*   ORDER_CONDITIONS_IN           =

*   ORDER_CONDITIONS_INX          =

    ORDER_CFGS_REF                 = it_ORDER_CFGS_REF

    ORDER_CFGS_INST                = it_ORDER_CFGS_INST

*   ORDER_CFGS_PART_OF            =

    ORDER_CFGS_VALUE               = IT_ORDER_CFGS_VALUE

*   ORDER_CFGS_BLOB               =

    ORDER_CFGS_VK                  = IT_ORDER_CFGS_VK

*   ORDER_CFGS_REFINST             = it_ORDER_CFGS_REFINST

*   ORDER_CCARD                   =

*   ORDER_TEXT                    =

*   ORDER_KEYS                    =

*   EXTENSIONIN                   =

*   PARTNERADDRESSES              =

       .

*  Commit the FM

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

* EXPORTING

*   WAIT          =

* IMPORTING

*   RETURN        =

.

unable to update the material item configuration details.

Am I missing anything..Please guide me how to update the VC values..

Thanks&Regards,

Harikrishna.

joe_pokrifka1
Discoverer
0 Kudos

Have you posted the solution document?

I have been unable to find your solution.

Please advise.

harikrishna_malladi
Active Participant
0 Kudos

Hi Joe,

Try below.

*Sales Order Header data

ls_header-doc_type          = 'DOCTYPE'.

ls_header-sales_org         = 'ORG'.

ls_header-division            = 'DIV'.

ls_header-doc_date         = sy-datum.

ls_header-purch_no_c      = 'TEST'.  

*Partner Data

*Sold to party data

  IF ls_partner-partn_role IS INITIAL.

    ls_partner-partn_role = 'AG'.

  ENDIF.

  CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

    EXPORTING

      input            = '7000010'

    IMPORTING

      output          = ls_partner-partn_numb.

  APPEND ls_partner TO lt_partner.

*Ship to party data

CLEAR ls_partner.

  IF ls_partner-partn_role IS INITIAL.

    ls_partner-partn_role = 'WE'.

  ENDIF.

  IF ls_salesorder-shiptopartnerid IS NOT INITIAL.

    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

      EXPORTING

        input  = '70000215'

      IMPORTING

        output = ls_partner-partn_numb.

  APPEND ls_partner TO lt_partner.

*Sales Order Item Data

ls_item-itm_number      =  '000001'.

ls_item-po_itm_no        = '000001'.

ls_item-purch_no_c      = 'TEST'.

ls_item-plant                = 'PLANT'. "Plant name

ls_item-ship_point        = '1000'.

ls_item-target_qty        = '1'.

ls_item-material           = 'MAT12'.  "Material Name

ls_item-sales_unit        =  'EA'.

APPEND ls_item TO lt_item.

*Sales Order Item Data Flags

ls_itemx-itm_number  = '000001'.

ls_itemx-po_itm_no    = 'X'.

ls_itemx-purch_no_c  = 'X'.

ls_itemx-plant            = 'X'.

ls_itemx-ship_point    = 'X'.

ls_itemx-target_qty    = 'X'.

ls_itemx-material       = 'X'.

ls_itemx-sales_unit    = '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'.               "Target Quantity

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.

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

*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     = c_za_ccode. “Characteristic Name

    ls_sales_cfgs_value_in-value     = 'CHBC'.

    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          = c_za_gauge. “Characteristic Name

         ls_sales_cfgs_value_in-value   = '24'.

         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                =  c_za_ccode. “Characteristic Name

          APPEND ls_sales_cfgs_vk TO lt_sales_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                = c_za_gauge. “Characteristic Name

          APPEND ls_sales_cfgs_vk TO lt_sales_cfgs_vk.

          CLEAR : ls_sales_cfgs_vk.

* Call BAPI to create Sales Order

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.

  

Hope it will solve your issue..

Regards,

Harikrishna

joe_pokrifka1
Discoverer
0 Kudos

thanks.  this helps.

I was missing the PO_ITEM_NO -

Cheryl Lin also mentioned this above.

Thanks all.

Lakshmipathi
Active Contributor
0 Kudos

Moved from SAP ERP Sales and Distribution (SAP SD) to SAP ERP PLM - Classification and Variant Configuration