Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Configure Materials using BAPI

Hi,

I am trying to create a quotation in our system using the BAPI: BAPI_QUOTATION_CREATEFROMDATA2. Everything works fine when I use materials which don't have to be configured. Unfortunately I have only materials which need a configuration. So I took a look at the function module documentation but it is not very helpful. It just states that I have to fill the tables QUOTATION_CFGS_REF, QUOTATION_CFGS_INST, QUOTATION_CFGS_PART_OF and QUOTATION_CFGS_VALUE. I did some testing but wasn't able to get it working. The quotation gets created but without my item and the BAPI doesn't return any error messages. Does anybody know how I have to fill these tables? Example code would be great.

At the moment I fill the tables like this:

wa_item-itm_number = 10.

wa_item-material = 'MYMATERIAL'.

wa_item-SALES_UNIT = 'ST'.

wa_item-inst_id = 1.

wa_item-config_id = 1.

insert wa_item into table tab_items.

wa_items_sched-itm_number = 10.

wa_items_sched-req_qty = 1.

insert wa_items_sched into table tab_items_sched.

wa_quote_ref-posex = 10.

wa_quote_ref-root_id = 1.

wa_quote_ref-config_id = 1.

insert wa_quote_ref into table tab_quote_ref.

wa_quote_inst-inst_id = 1.

wa_quote_inst-config_id = 1.

wa_quote_inst-obj_type = 'MARA'.

wa_quote_inst-class_type = 300.

wa_quote_inst-obj_key = 'MYMATERIAL'.

wa_quote_inst-quantity = 1.

insert wa_quote_inst into table tab_quote_inst.

wa_quote_value-config_id = 1.

wa_quote_value-inst_id = 1.

wa_quote_value-charc = 'XXXXX'.

wa_quote_value-value = 10.

wa_quote_value-author = 7.

insert wa_quote_value into table tab_quote_value.

call function 'BAPI_QUOTATION_CREATEFROMDATA2'

EXPORTING

quotation_HEADER_IN = t_order_header_in

IMPORTING

SALESDOCUMENT = quotationnumber

TABLES

QUOTATION_ITEMS_IN = tab_items

QUOTATION_SCHEDULES_IN = tab_items_sched

QUOTATION_PARTNERS = tab_order_partnr

QUOTATION_CFGS_REF = tab_quote_ref

QUOTATION_CFGS_INST = tab_quote_inst

QUOTATION_CFGS_PART_OF = tab_quote_partof

QUOTATION_CFGS_VALUE = tab_quote_value

return = return.

regards

Thomas

Tags:
Former Member replied

I copied your code into my system and made a few changes and got it to work. You are right, you don't need the 'x' structures. The main thing that made it work, was removing inst_id and config from wa_item. Here is the code.

  data: tab_items_inx type table of BAPISDITMX,
        wa_items_inx type BAPISDITMX.

  data: tab_schedules_inx type table of BAPISCHDLX,
        wa_schedules_inx type BAPISCHDLX.

  data: t_quote_header_in type BAPISDHD1.

  data: tab_items type table of BAPISDITM,
        wa_item type BAPISDITM.

  data: tab_items_sched type table of BAPISCHDL,
        wa_items_sched type BAPISCHDL.

  data: tab_quote_ref type table of BAPICUCFG,
        wa_quote_ref like line of tab_quote_ref.

  data: tab_quote_refinst type table of BAPICUREF,
        wa_quote_refinst type BAPICUREF.

  data: tab_quote_inst type table of BAPICUINS,
        wa_quote_inst like line of tab_quote_inst.

  data: tab_quote_partof type table of BAPICUPRT,
        wa_quote_partof like line of tab_quote_partof.

  data: tab_quote_value type table of BAPICUVAL,
        wa_quote_value like line of tab_quote_value.

  data: wa_quote_partnr type BAPIPARNR,
        tab_quote_partnr type table of BAPIPARNR.

  data return type table of BAPIRET2.

  data: conf_id type char6 value '000010',
        inst_id type char8 value '00000001',
        salesordernumber type vbeln.

  t_quote_header_in-sales_org = '1000'.
  t_quote_header_in-division = '00'.
  t_quote_header_in-distr_chan = '05'.
  t_quote_header_in-purch_date = sy-datum.
  t_quote_header_in-doc_type = 'AG'.
*  t_quote_header_in-po_method = 'ES'.
  t_quote_header_in-purch_no_c = '123456'.

*Fill partner
  wa_quote_partnr-partn_role = 'AG'.
  wa_quote_partnr-partn_numb = '0001004109'.
  insert wa_quote_partnr into table tab_quote_partnr.

  wa_quote_partnr-partn_role = 'WE'.
  wa_quote_partnr-partn_numb = '0001004109'.
  insert wa_quote_partnr into table tab_quote_partnr.
*Fill items
  wa_item-itm_number = '000010'.
  wa_item-material = 'M5-8'.
  wa_item-SALES_UNIT = 'EA'.
*  wa_item-inst_id = inst_id.
*  wa_item-config_id = conf_id.
  wa_item-PO_ITM_NO = '000010'.
  wa_item-target_qty = 1.
  insert wa_item into table tab_items.

  wa_items_sched-itm_number = '000010'.
  wa_items_sched-req_qty = 1.
  wa_items_sched-sched_line = 1.
  insert wa_items_sched into table tab_items_sched.

*CREATE configuration
  wa_quote_ref-posex = '000010'.
  wa_quote_ref-root_id = inst_id.
  wa_quote_ref-config_id = conf_id.
  insert wa_quote_ref into table tab_quote_ref.
*Refinst
  wa_quote_refinst-posex = '000010'.
  wa_quote_refinst-config_id = conf_id.
  wa_quote_refinst-inst_id = inst_id.
  insert wa_quote_refinst into table tab_quote_refinst.

  wa_quote_inst-inst_id = inst_id.
  wa_quote_inst-config_id = conf_id.
  wa_quote_inst-obj_type = 'MARA'.
  wa_quote_inst-class_type = 300.
  wa_quote_inst-obj_key = '000000000060003030'.
  wa_quote_inst-quantity = 1.
  insert wa_quote_inst into table tab_quote_inst.

*Attribute values
  wa_quote_value-config_id = conf_id.
  wa_quote_value-inst_id = inst_id.
  wa_quote_value-charc = 'DOOR_STYLE'.
  wa_quote_value-value = 'V024SMAP'.
  insert wa_quote_value into table tab_quote_value.

  wa_quote_value-config_id = conf_id.
  wa_quote_value-inst_id = inst_id.
  wa_quote_value-charc = 'FINISH'.
  wa_quote_value-value = 'CDR'.
  insert wa_quote_value into table tab_quote_value.

*  wa_items_inx-itm_number = 'X'.
*  wa_items_inx-material = 'X'.
*  wa_items_inx-SALES_UNIT = 'X'.
*  wa_items_inx-inst_id = 'X'.
*  wa_items_inx-config_id = 'X'.
*  wa_items_inx-PO_ITM_NO = 'X'.
*  insert wa_items_inx into table tab_items_inx.
*
*  wa_schedules_inx-itm_number = 'X'.
*  wa_schedules_inx-sched_line = 'X'.
*  wa_schedules_inx-req_qty    = 'X'.
*  insert wa_schedules_inx into table tab_schedules_inx.

*Call BAPI
  call function 'BAPI_QUOTATION_CREATEFROMDATA2'
    EXPORTING
      quotation_HEADER_IN     = t_quote_header_in
      BEHAVE_WHEN_ERROR       = 'P'
    IMPORTING
      SALESDOCUMENT           = salesordernumber
    TABLES
      QUOTATION_ITEMS_IN      = tab_items
      QUOTATION_SCHEDULES_IN  = tab_items_sched
*      quotation_items_inx     = tab_items_inx
*      quotation_schedules_inx = tab_schedules_inx
      QUOTATION_PARTNERS      = tab_quote_partnr
      QUOTATION_CFGS_REF      = tab_quote_ref
      QUOTATION_CFGS_REFINST  = tab_quote_refinst
      QUOTATION_CFGS_INST     = tab_quote_inst
*      QUOTATION_CFGS_PART_OF  = tab_quote_partof
      QUOTATION_CFGS_VALUE    = tab_quote_value
      return                  = return.
*commit
  if salesordernumber ne ''.
  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
  else.
  CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
  endif.

Hope it works for you,

Brian

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question