Quantity update into sales order using BAPI_SALESORDER_CREATEFROMDAT2

Hi All,
I am able to create a sales order using the BAPI "BAPI_SALESORDER_CREATEFROMDAT2".
But even after assinging the Target_quntity and the Target_quantity_units, the values are not getting updated into the Sales order, but the sales order gets created .
Did anyone of you had a similare problem, how was it solved.
cold some one please help me out on this.
Regards

Hi
I had used below code (using <b>BAPI_SALESORDER_CREATEFROMDAT1</b>)..but never faced any problem.. you can try the same...
Regards,
Raj
REPORT  z_sd_salesorder_create
        NO STANDARD PAGE HEADING
        LINE-SIZE 150
        MESSAGE-ID zz.
              S T R U C T U R E  D E C L A R A T I O N S             *
TYPES: BEGIN OF x_ppl,
        ppl_order(18),   " ppl Orderno
        auart(4),         " Sales Doc Type
        vkorg(4),         " Sales Organization
        vtweg(2),         " Distribution Channel
        spart(2),         " Division
        div(3),           " Division
        kunnr(10),        " Sold-to Party
        date(10),         " Doc Dt
        matnr(18),        " Item Matnr#
        uom(3),           " UOM
        qty(15),          " Qty
       kschl(4),         " Pricing condiiton type
       kbetr(11),        " Rate
       END OF x_ppl.
TYPES: BEGIN OF x_file,
        loc(30),          " Location
        div(3),           " Division
        ppl_order(18),   " ppl Orderno
        kunnr(10),        " Sold-to Party
        date(10),         " Doc Dt
        matnr(20),        " Item Matnr#
        qty(15),          " Qty
        uom(3),           " UOM
       kbetr(11),        " Rate
       discount(5),      " Discount
       END OF x_file.
TYPES: BEGIN OF x_output,
        ppl_order(18),       " ppl Orderno
        mesg(130),            " Mesg Success/Error
       END OF x_output.
TYPES: BEGIN OF x_werks,
        name2(30),                " Location
        werks TYPE werks_ext,     " Plant
       END OF x_werks.
TYPES: BEGIN OF x_info,
        vkorg TYPE vkorg ,   " Sales org
        vtweg TYPE vtweg,    " Dist channel
        werks TYPE werks_ext," Plant
        spart TYPE spart,    " Storage Loc
       END OF x_info.
TYPES: BEGIN OF x_material,
        ppl_prdid(20),      " ppl Prd id
        matnr TYPE matnr,    " Material (SAP)
       END OF x_material.
       I N T E R N A L    T A B L E    D E C L A R A T I O N S       *
DATA: it_file  TYPE STANDARD TABLE OF x_file  WITH HEADER LINE." File Data
DATA: it_data  TYPE STANDARD TABLE OF x_ppl  WITH HEADER LINE." ppl File
DATA: it_out TYPE STANDARD TABLE OF x_output WITH HEADER LINE. " Outcome
DATA: it_werks TYPE STANDARD TABLE OF x_werks WITH HEADER LINE.    " Plant
DATA: it_info TYPE STANDARD TABLE OF x_info WITH HEADER LINE.      " Othr Info
DATA: it_matnr TYPE STANDARD TABLE OF x_material WITH HEADER LINE. " Material Info
DATA: it_item TYPE STANDARD TABLE OF bapiitemin WITH HEADER LINE.  "Order Itm data
DATA: it_partner TYPE STANDARD TABLE OF bapipartnr WITH HEADER LINE. "Order Partner data
           V A R I A B L E S      D E C L A R A T I O N S            *
DATA  : v_correct  TYPE i,
        v_error    TYPE i,
        v_total    TYPE i,
        v_return   LIKE bapireturn1,
        v_index    LIKE sy-tabix.
*- Return values
DATA: it_orderh TYPE bapisdhead, "Order Hdr data
      order TYPE bapivbeln-vbeln,
      soldto TYPE bapisoldto,
      shipto TYPE bapishipto,
      return TYPE bapireturn1.
DATA: hdate   TYPE sy-datum.
                U S E R   I N P U T S   S C R E E N                  *
SELECTION-SCREEN: BEGIN OF BLOCK blk01 WITH FRAME TITLE text-t01.
PARAMETERS: p_file TYPE rlgrap-filename OBLIGATORY. " File name
SELECTION-SCREEN END OF BLOCK blk01.
                  S E L E C T I O N    S C R E E N                   *
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
  PERFORM get_file.
                S t a r t    o f    S e l e c t i o n                *
START-OF-SELECTION.
  PERFORM get_upload.
  PERFORM validate_data.        " Validate the data
  PERFORM data_swap.            " Prepare the data for processing
  IF NOT it_data[] IS INITIAL.
    PERFORM get_update.           " Create SalesOrders
  ELSE.
    MESSAGE i001(zz) WITH text-001.
    STOP.
  ENDIF.
                E n d    o f    S e l e c t i o n                    *
END-OF-SELECTION.
  IF NOT it_data[] IS INITIAL.
    PERFORM get_write.
  ENDIF.
*&      Form  get_file
      Get File name
FORM get_file .
  CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
    EXPORTING
      program_name  = syst-repid
      mask          = '*'
    CHANGING
      file_name     = p_file
    EXCEPTIONS
      mask_too_long = 1
      OTHERS        = 2.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
ENDFORM.                    " get_file
*&      Form  get_upload
      to upload the file
FORM get_upload .
  DATA l_file TYPE string.
  CLEAR: it_file, it_file[].
  l_file = p_file.
  CALL FUNCTION 'GUI_UPLOAD'
    EXPORTING
      filename                = l_file
      filetype                = 'ASC'
      has_field_separator     = 'X'
    TABLES
      data_tab                = it_file
    EXCEPTIONS
      file_open_error         = 1
      file_read_error         = 2
      no_batch                = 3
      gui_refuse_filetransfer = 4
      invalid_type            = 5
      no_authority            = 6
      unknown_error           = 7
      bad_data_format         = 8
      header_not_allowed      = 9
      separator_not_allowed   = 10
      header_too_long         = 11
      unknown_dp_error        = 12
      access_denied           = 13
      dp_out_of_memory        = 14
      disk_full               = 15
      dp_timeout              = 16
      OTHERS                  = 17.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ELSEIF sy-subrc = 0.
    SORT it_file BY loc ppl_order.
  ENDIF.
ENDFORM.                    " get_upload
*&      Form  get_update
      Creating mapping Data in Z table
FORM get_update .
  DATA: l_itemno(2) TYPE n,
        l_partner TYPE parvw,
        l_kunnr TYPE kunnr,
        l_matnr TYPE matnr,
        l_mesg TYPE string,
        l_kbetr TYPE p DECIMALS 2.
  DATA: l_in_qty LIKE vbap-zmeng,
        l_meins LIKE mara-meins,
        l_qty   LIKE vbap-zmeng.
  CLEAR: v_correct, v_error, v_total.
  SORT it_data BY ppl_order.
  LOOP AT it_data.
    CLEAR v_index.
    v_index = sy-tabix.
*- New SalesOrder
    AT NEW ppl_order.
      READ TABLE it_data INDEX v_index.
      CLEAR: it_orderh, it_item, it_partner,
             order, soldto, shipto, return,
             it_item[], it_partner[].
      v_total = v_total + 1.  "Increment Total SalesOrders counter
      CLEAR l_itemno.
      l_itemno = '10'.
*- Covert date fields into Internal format
      CALL FUNCTION 'CONVERT_DATE_TO_INTERN_FORMAT'
        EXPORTING
          datum = it_data-date
          dtype = 'DATS'
        IMPORTING
          idate = it_data-date.
*- Populate SalesOrder header data.
      CALL FUNCTION 'CONVERSION_EXIT_AUART_INPUT'
        EXPORTING
          input  = it_data-auart
        IMPORTING
          output = it_data-auart.
      it_orderh-doc_type   = it_data-auart.
      it_orderh-sales_org  = it_data-vkorg.
      it_orderh-distr_chan = it_data-vtweg.
      it_orderh-division   = it_data-spart.
      it_orderh-purch_no   = 'DEPOT'.
      it_orderh-price_date = it_data-date.      "Doc Dt
      it_orderh-req_date_h = it_data-date.      "Del.Dt
      it_orderh-purch_no_s = it_data-ppl_order.
*- Partner data
      CLEAR: l_partner, l_kunnr.
*- Convert Partner type into internal format
      l_partner = 'SP'.  "SoldTo Party
      CALL FUNCTION 'CONVERSION_EXIT_PARVW_INPUT'
        EXPORTING
          input  = l_partner
        IMPORTING
          output = l_partner.
*- Convert Customer into internal format
      l_kunnr = it_data-kunnr.
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
        EXPORTING
          input  = l_kunnr
        IMPORTING
          output = l_kunnr.
      it_partner-partn_role = l_partner.
      it_partner-partn_numb = l_kunnr.
      APPEND it_partner.
      CLEAR it_partner.
    ENDAT.
*- Item data
    it_item-itm_number = l_itemno.
*- Convert material number into internal format
    CLEAR l_matnr.
    l_matnr = it_data-matnr.
    CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
      EXPORTING
        input        = l_matnr
      IMPORTING
        output       = l_matnr
      EXCEPTIONS
        length_error = 1
        OTHERS       = 2.
    IF sy-subrc <> 0.
      MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
              WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    it_item-material  = l_matnr.
*- Call FM to get new qty based on SAP UOM
    CLEAR: l_meins, l_qty, l_in_qty.
    l_in_qty = it_data-qty.
    CALL FUNCTION 'Z_GET_QTY_FROM_UOM'
      EXPORTING
        matnr     = it_item-material
        in_meins  = it_data-uom
        in_qty    = l_in_qty
      IMPORTING
        out_meins = l_meins
        quantity  = l_qty.
    IF sy-subrc = 0.
      it_data-qty = l_qty.
      it_data-uom = l_meins.
    ENDIF.
    it_data-qty = it_data-qty * 1000.
    it_item-req_qty = it_data-qty.
    it_item-sales_unit = it_data-uom.
    it_item-req_date   = it_data-date.
*- Pricing data
   it_item-cond_type = it_data-kschl.  "Pricing condition
   CLEAR l_kbetr.
   l_kbetr = it_data-kbetr / 10. "Price (Rate)
   it_item-cond_value = l_kbetr.
    APPEND it_item.
    CLEAR  it_item.
*- Increment Item counter.
    l_itemno = l_itemno + 10.
*- At end of SalesOrder
    AT END OF ppl_order.
      READ TABLE it_data INDEX v_index.
*- Call the BAPI for SalesOrder creation
      CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT1'
        EXPORTING
          order_header_in = it_orderh
        IMPORTING
          salesdocument   = order
          sold_to_party   = soldto
          ship_to_party   = shipto
          return          = return
        TABLES
          order_items_in  = it_item
          order_partners  = it_partner.
      IF sy-subrc = 0.
        COMMIT WORK.
      ENDIF.
      v_return = return+0(1).
      IF v_return = 'E'.
        v_error = v_error + 1.
        CLEAR l_mesg.
        l_mesg = return.
        CONDENSE l_mesg.
      ELSE.
        v_correct = v_correct + 1.
        CLEAR l_mesg.
        CONCATENATE 'Salesorder'(007) order 'successfully created.'(008)
        INTO l_mesg SEPARATED BY space.
        CONDENSE l_mesg.
      ENDIF.
*- Populate the output table
      CLEAR it_out.
      it_out-ppl_order = it_data-ppl_order.
      it_out-mesg = l_mesg.
      APPEND it_out.
      CLEAR it_out.
    ENDAT.
  ENDLOOP.
ENDFORM.                    " get_update
*&      Form  get_write
      Write the results
FORM get_write .
  WRITE:/ 'Total Number of Records :'(002), v_total COLOR 1.
  WRITE:/ 'Total Correct Records   :'(003), v_correct COLOR 3.
  WRITE:/ 'Total Error Records     :'(004), v_error COLOR 6.
  SKIP 3.
  IF NOT it_out[] IS INITIAL.
    WRITE:/5 'ppl Order #'(005),
          28 'Message'(006).
  ENDIF.
  SKIP 1.
  LOOP AT it_out.
    WRITE:/5  it_out-ppl_order,
           28 it_out-mesg.
  ENDLOOP.
ENDFORM.                    " get_write
*&      Form  validate_data
      Validate the data
FORM validate_data .
  DATA: l_bstkde TYPE bstkd_e.
  LOOP AT it_file.
    SELECT bstkd_e INTO l_bstkde
     UP TO 1 ROWS
     FROM vbkd
     WHERE bstkd_e = it_file-ppl_order.
    ENDSELECT.
    IF sy-subrc = 0.  " This ppl Order is already been created in SAP, so delete record
      DELETE it_file.
    ENDIF.
  ENDLOOP.
  SORT it_file BY ppl_order.
ENDFORM.                    " validate_data
*&      Form  data_swap
      Prepare the data for processing
FORM data_swap .
  CLEAR: it_werks, it_info, it_matnr, it_data,
         it_werks[], it_info[], it_matnr[], it_data[].
  IF NOT it_file[] IS INITIAL.
*- Get the plant from location
    SELECT name2
           werks
      INTO CORRESPONDING FIELDS OF TABLE it_werks
    FROM t001w FOR ALL ENTRIES IN it_file
    WHERE name2 = it_file-loc.
    IF sy-subrc = 0.
      SORT it_werks BY name2 werks.
*- Get the Sales Org, Division and Distribution Channel
      IF NOT it_werks[] IS INITIAL.
        SELECT vkorg
               vtweg
               werks
        INTO CORRESPONDING FIELDS OF TABLE it_info
        FROM tvkwz FOR ALL ENTRIES IN it_werks
        WHERE werks = it_werks-werks.
        IF sy-subrc =  0.
          LOOP AT it_info.
            it_info-spart = '99'.
            MODIFY it_info INDEX sy-tabix.
          ENDLOOP.
          SORT it_info BY vkorg vtweg werks.
        ENDIF.
      ENDIF.
    ENDIF.
*- Get material from ppl material
    SELECT ppl_prdid
           matnr
      FROM zppl_master
      INTO TABLE it_matnr FOR ALL ENTRIES IN it_file
      WHERE ppl_prdid = it_file-matnr.
    IF sy-subrc = 0.
      SORT it_matnr BY ppl_prdid matnr.
    ENDIF.
  ENDIF.
*- Update the data in it_data
  LOOP AT it_file.
    CLEAR it_data.
   it_data-auart = 'OR'.
    it_data-auart = 'OR'.  " CHANGED BY Jo ON 3103005
    READ TABLE it_werks WITH KEY name2 = it_file-loc BINARY SEARCH.
    IF sy-subrc = 0.
      READ TABLE it_info WITH KEY werks = it_werks-werks BINARY SEARCH.
      IF sy-subrc = 0.
        it_data-vkorg = it_info-vkorg.
        it_data-vtweg = it_info-vtweg.
      ENDIF.
    ENDIF.
*- Material
    READ TABLE it_matnr WITH KEY ppl_prdid = it_file-matnr BINARY SEARCH.
    IF sy-subrc = 0.
      it_data-matnr = it_matnr-matnr.
    ENDIF.
    it_data-ppl_order = it_file-ppl_order.
    it_data-date  = it_file-date.
    CONCATENATE it_file-kunnr it_file-loc+1(2) INTO it_data-kunnr.
    it_data-qty   = it_file-qty.
    it_data-uom   = it_file-uom.
   it_data-kbetr = it_file-kbetr.
*- Pricing condition
   it_data-kschl = 'PR00'.
    CASE it_file-div.
      WHEN 'BRN'.
        it_data-div = '04'.
      WHEN 'GEN'.
        it_data-div = '03'.
      WHEN 'IVF'.
        it_data-div = '02'.
      WHEN 'OPH'.
        it_data-div = '01'.
    ENDCASE.
    it_data-spart = it_data-div.
    APPEND it_data.
    CLEAR  it_data.
  ENDLOOP.
ENDFORM.                    " data_swap

Similar Messages

  • Update the material quantity in the sales order using LSMW...

    Hi Guru's,
    I created one sales order using BAPI..now i wanted update the material quantity in the sales order using LSMW...
    could you please provide the step by step process....
    if anyone of you provide the program logic similar to requirement that would be helpfull to me...
    thanks in advance
    Srinivas....

    Hi Sri,
    Hope it may help you.
    First do the recording for VA02 transaction, in that give the existing sales order number
    and update the Quantity and save it. Remaining steps are same what we used(LSMW) to upload data to applications.
    Regards,
    Vishvesh
    if helpful, rewards it.

  • Clear WBS field in sales order using bapi_salesorder_createfromdat2.

    Hi,
    Situation is this, I have a sales order, where the WBS element in the line item is populated. I want to clear that field to blank and save the sales order.
    When I try to do that using the bapi_salesorder_createfromdat2, it says that it is successful, but when I go back to the sales order and see that field is still populated and not cleared. But the same field if I clear it through VA02 it works fine.
    Header level update flag is set as 'U'.
    I have tried setting up 'D' 'U' and 'I' for the update flag for the line item. Still no luck.
    Given below is the sample code, did anybody else also faced the same issue.
    Data Section.
    data : sal_t_in type standard table of BAPISDHD1,
           sal_s_in like line of sal_t_in.
    *data : sal_t_in type standard table of BAPISDH1,
    *       sal_s_in like line of sal_t_in.
    data : ret_t type standard table of bapiret2,
           ret_s like line of ret_t.
    data : partner_t type standard table of bapiparnr,
           partner_s like line of partner_t.
    data : item_t type standard table of bapisditm,
           item_s like line of item_t.
    data : item_t_inx type standard table of BAPISDITMX,
           item_s_inx like line of item_t_inx.
    data : schdl_t type standard table of BAPISCHDL,
           schdl_s like line of schdl_t.
    data : schdl_t_inx type standard table of BAPISCHDLX,
           schdl_s_inx like line of schdl_t_inx.
    data : ord_view type order_view.
    data : sal_t_key type standard table of sales_key,
           sal_s_key like line of sal_t_key.
    data : ord_t_hdr type standard table of bapisdhd,
           ord_s_hdr like line of ord_t_hdr.
    data : ord_t_itm type standard table of bapisdit,
           ord_s_itm like line of ord_t_itm.
    data : hdr_inx type BAPISDHD1X.
    data : hdr2_inx type BAPISDH1X.
    data : qty type DZMENG.
    data : logic_switch type BAPISDLS.
    data : sd_doc_out type BAPIVBELN-VBELN.
    data : sd_hdr_out type BAPISDHD.
    data : sd_hdr_stat type BAPISDHDST.
    Logic Section.
    sal_s_in-doc_type = 'ZOR'.
    hdr_inx-updateflag = 'U'.
    ord_view-header = 'X'.
    ord_view-item = 'X'.
    sal_s_key-vbeln = '0000001067'.
    append sal_s_key to sal_t_key.
    call function 'BAPISDORDER_GETDETAILEDLIST'
      exporting
        i_bapi_view                   = ord_view
    *   I_MEMORY_READ                 =
      tables
        sales_documents               = sal_t_key
       ORDER_HEADERS_OUT             = ord_t_hdr
       ORDER_ITEMS_OUT               = ord_t_itm
    *   ORDER_SCHEDULES_OUT           =
    *   ORDER_BUSINESS_OUT            =
    *   ORDER_PARTNERS_OUT            =
    *   ORDER_ADDRESS_OUT             =
    *   ORDER_STATUSHEADERS_OUT       =
    *   ORDER_STATUSITEMS_OUT         =
    *   ORDER_CONDITIONS_OUT          =
    *   ORDER_COND_HEAD               =
    *   ORDER_COND_ITEM               =
    *   ORDER_COND_QTY_SCALE          =
    *   ORDER_COND_VAL_SCALE          =
    *   ORDER_CONTRACTS_OUT           =
    *   ORDER_TEXTHEADERS_OUT         =
    *   ORDER_TEXTLINES_OUT           =
    *   ORDER_FLOWS_OUT               =
    *   ORDER_CFGS_CUREFS_OUT         =
    *   ORDER_CFGS_CUCFGS_OUT         =
    *   ORDER_CFGS_CUINS_OUT          =
    *   ORDER_CFGS_CUPRTS_OUT         =
    *   ORDER_CFGS_CUVALS_OUT         =
    *   ORDER_CFGS_CUBLBS_OUT         =
    *   ORDER_CFGS_CUVKS_OUT          =
    *   ORDER_BILLINGPLANS_OUT        =
    *   ORDER_BILLINGDATES_OUT        =
    *   ORDER_CREDITCARDS_OUT         =
    *   EXTENSIONOUT                  =
    loop at ord_t_itm into ord_s_itm.
    move-corresponding ord_s_itm to item_s.
    call function 'CONVERSION_EXIT_ABPSP_OUTPUT'
      exporting
        input         = item_s-WBS_ELEM
    IMPORTING
       OUTPUT        = item_s-WBS_ELEM
    *move space to item_s-WBS_ELEM.
    append item_s to item_t.
    endloop.
    clear item_s_inx.
    item_s_inx-updateflag = 'D'.
    item_s_inx-wbs_elem = 'X'.
    append item_s_inx to item_t_inx.
    call function 'BAPI_SALESORDER_CREATEFROMDAT2'
      exporting
        SALESDOCUMENTIN               = '0000001067'
        order_header_in               = sal_s_in
        ORDER_HEADER_INX              = hdr_inx
    *   SENDER                        =
    *   BINARY_RELATIONSHIPTYPE       =
    *   INT_NUMBER_ASSIGNMENT         =
    *   BEHAVE_WHEN_ERROR             =
    *   LOGIC_SWITCH                  =
    *   TESTRUN                       =
    *   CONVERT                       = ' '
    * IMPORTING
    *   SALESDOCUMENT                 =
      tables
        RETURN                        = ret_t
       ORDER_ITEMS_IN                = item_t
       ORDER_ITEMS_INX               = item_t_inx
        order_partners                = partner_t
    *   ORDER_SCHEDULES_IN            =
    *   ORDER_SCHEDULES_INX           =
    *   ORDER_CONDITIONS_IN           =
    *   ORDER_CONDITIONS_INX          =
    *   ORDER_CFGS_REF                =
    *   ORDER_CFGS_INST               =
    *   ORDER_CFGS_PART_OF            =
    *   ORDER_CFGS_VALUE              =
    *   ORDER_CFGS_BLOB               =
    *   ORDER_CFGS_VK                 =
    *   ORDER_CFGS_REFINST            =
    *   ORDER_CCARD                   =
    *   ORDER_TEXT                    =
    *   ORDER_KEYS                    =
    *   EXTENSIONIN                   =
    *   PARTNERADDRESSES              =
    call function 'BAPI_TRANSACTION_COMMIT'
    * EXPORTING
    *   WAIT          =
    * IMPORTING
    *   RETURN        =
    Result I get when I execute is
    S     V4     233     SALES_HEADER_IN has been processed successfully     VBAKKOM
    S     V4     233     SALES_ITEM_IN has been processed successfully          VBAPKOM     000001
    S     V1     311     Standard order 1067 has been saved          Standard order     1067
    Which means it says it save successfully..but data is not changed.
    Any Ideas??
    Thanks and Regards,
    Mahesh.

    Hi,
    The problem is fixed. The item inx table I was not passing the item number field, so the bapi was not knowing which line item to update.
    It was a stupid overlook on my part.
    Thanks and Regards,
    Mahesh.

  • Configuration is not updating in sales order using function module SD_SALESDOCUMENT_CREATE

    Hello Experts,
    we are using SD_SALESDOCUMENT_CREATE function module to create sales order.
    Sales order is creating successfully but the configuration for the items are not updating.
    Could any one help me out on this ....we tried in different ways but couldn't ....
    Here is the code....
    *---Filling Configuration data
    *--- Filling Configuration Reference Item / Instance
         w_sales_cfgs_refinst-posex     = w_items-itm_number.
         w_sales_cfgs_refinst-config_id = '000001'.
         w_sales_cfgs_refinst-inst_id   = '00000001'.
         APPEND  w_sales_cfgs_refinst TO  t_sales_cfgs_refinst.
         CLEAR  w_sales_cfgs_refinst.
    *---Filling Configuration Reference Data SALES_CFGS_REF Table
         w_sales_cfgs_ref-posex      = w_items-itm_number.
         w_sales_cfgs_ref-config_id  = '000001'.
         w_sales_cfgs_ref-sce        = '1'.
         w_sales_cfgs_ref-root_id    = '00000001'.
         w_sales_cfgs_ref-complete   = 'T'.
         w_sales_cfgs_ref-consistent = 'T'.
         APPEND w_sales_cfgs_ref TO t_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      = '001'.
         w_sales_cfgs_inst-obj_key         = w_sales_items_in-material.
         w_sales_cfgs_inst-quantity        = w_items-target_qty.
         w_sales_cfgs_inst-quantity_unit   = 'EA'.
         w_sales_cfgs_inst-complete        = 'T'.
         w_sales_cfgs_inst-consistent      = 'T'.
         w_sales_cfgs_inst-OBJECT_GUID     = 'T'.
         w_sales_cfgs_inst-PERSIST_ID_TYPE = w_sales_items_in-material.
         APPEND w_sales_cfgs_inst TO t_sales_cfgs_inst.
         CLEAR w_sales_cfgs_inst.
    *---Filling Configuration Characteristic Values SALES_CFGS_VALUE Table
         LOOP AT w_items-itm_config INTO wa_itm_config.
           w_sales_cfgs_value_in-config_id = '000001'.
           w_sales_cfgs_value_in-inst_id   = '00000001'.
           w_sales_cfgs_value_in-charc     = wa_itm_config-charc_name.
           w_sales_cfgs_value_in-value     = wa_itm_config-charc_value.
           APPEND w_sales_cfgs_value_in TO t_sales_cfgs_value.
    *---Filling Configuration Variant Condition Key SALES_CFGS_VK
           w_sales_cfgs_vk-config_id = '000001'.
           w_sales_cfgs_vk-inst_id   = '00000001'.
           w_sales_cfgs_vk-vkey      = wa_itm_config-charc_name.
           APPEND w_sales_cfgs_vk TO t_sales_cfgs_vk.
           CLEAR : w_sales_cfgs_value_in,w_sales_cfgs_vk.
         ENDLOOP.
    Regards,
    Harsha P

    Hello All,
    Actually there was a bug in my code to update configuration for an item in sales order
    Below is my Updated Code with that i can updated configuration successfully....
    *---Filling Configuration data
    *---Filling Configuration Reference Data SALES_CFGS_REF Table
         w_sales_cfgs_ref-posex      = w_items-itm_number.
         w_sales_cfgs_ref-config_id  = '000001'.
         w_sales_cfgs_ref-sce        = '1'.
         w_sales_cfgs_ref-root_id    = '00000001'.
         w_sales_cfgs_ref-complete   = 'T'.
         w_sales_cfgs_ref-consistent = 'T'.
         APPEND w_sales_cfgs_ref TO t_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         = w_sales_items_in-material.
         w_sales_cfgs_inst-quantity        = w_items-target_qty.
         w_sales_cfgs_inst-quantity_unit   = 'EA'.
         w_sales_cfgs_inst-complete        = 'T'.
         w_sales_cfgs_inst-consistent      = 'T'.
         w_sales_cfgs_inst-object_guid     = w_sales_items_in-material.
         w_sales_cfgs_inst-persist_id_type = 'G'.
         APPEND w_sales_cfgs_inst TO t_sales_cfgs_inst.
         CLEAR w_sales_cfgs_inst.
    *---Filling Configuration Characteristic Values SALES_CFGS_VALUE Table
         LOOP AT w_items-itm_config INTO wa_itm_config.
           w_sales_cfgs_value_in-config_id = '000001'.
           w_sales_cfgs_value_in-inst_id   = '00000001'.
           w_sales_cfgs_value_in-charc     = wa_itm_config-charc_name.
           w_sales_cfgs_value_in-value     = wa_itm_config-charc_value.
           APPEND w_sales_cfgs_value_in TO t_sales_cfgs_value.
    *---Filling Configuration Variant Condition Key SALES_CFGS_VK
           w_sales_cfgs_vk-config_id = '000001'.
           w_sales_cfgs_vk-inst_id   = '00000001'.
           w_sales_cfgs_vk-vkey      = wa_itm_config-charc_name.
           APPEND w_sales_cfgs_vk TO t_sales_cfgs_vk.
           CLEAR : w_sales_cfgs_value_in,w_sales_cfgs_vk.
         ENDLOOP.
         CLEAR : w_sales_items_in,wa_mara,w_items,w_sales_schedules_in,
                 w_items-itm_number.
       ENDLOOP.
    Cheers,
    Harsha

  • Error when creating sales order using BAPI_SALESORDER_CREATEFROMDAT2

    Hello!
    I am using BAPI_SALESORDER_CREATEFROMDAT2 for creating the Sales order. But I have a problem when Iu2019m trying to create configuration. I think that parameter order_items_in-material should be generated before calling BAPI described above. I try to use order_items_in-mat_entrd, but BAPI return error message id = V1, number = 320 (No item category available (Table T184 ZAPC  TEXT )).
    Help me please, How I can solve this problem?

    <P><STRONG>FUNCTION Z_SD_GET_TEH_COST.<BR>"----<BR>"  IMPORTING<BR>"     REFERENCE(IS_COST_ORDER) TYPE  ZWCLIF_COST_ORDER<BR>"  EXPORTING<BR>"     REFERENCE(EV_KBETR) TYPE  KBETR<BR>"----
    </STRONG></P>
    <P><STRONG>  DEFINE fill_prizn.<BR>    IF is_cost_order-&amp;1 IS NOT INITIAL.<BR>      CLEAR: ls_cfgs_value-charc,<BR>             ls_cfgs_value-value.<BR>      ls_cfgs_value-charc = &amp;2.<BR>      ls_cfgs_value-value = is_cost_order-&amp;1.<BR>*      ls_cfgs_value-valcode = '1'.<BR>      APPEND ls_cfgs_value TO lt_cfgs_value.<BR>    ENDIF.<BR>  END-OF-DEFINITION.</STRONG></P>
    <P><STRONG>DATA: ls_header_in TYPE bapisdhd1,<BR>      ls_header_inx TYPE bapisdhd1x,</STRONG></P>
    <P><STRONG>      lt_partners TYPE TABLE OF bapiparnr,<BR>      ls_partners TYPE bapiparnr,</STRONG></P>
    <P><STRONG>      lt_items_in TYPE TABLE OF bapisditm,<BR>      lt_items_inx TYPE TABLE OF bapisditmx,</STRONG></P>
    <P><STRONG>      ls_items_in TYPE bapisditm,<BR>      ls_items_inx TYPE bapisditmx,</STRONG></P>
    <P><STRONG>      ls_cfgs_ref TYPE bapicucfg,<BR>      lt_cfgs_ref TYPE TABLE OF bapicucfg,</STRONG></P>
    <P><STRONG>      lt_cfgs_value TYPE TABLE OF bapicuval,<BR>      ls_cfgs_value TYPE bapicuval,</STRONG></P>
    <P><STRONG>      lt_schedules_in TYPE TABLE OF bapischdl,<BR>      ls_schedules_in TYPE bapischdl,</STRONG></P>
    <P><STRONG>      lt_schedules_inx TYPE TABLE OF bapischdlx,<BR>      ls_schedules_inx TYPE bapischdlx,</STRONG></P>
    <P><STRONG>      lt_cfgs_inst TYPE TABLE OF bapicuins,<BR>      ls_cfgs_inst TYPE bapicuins,<BR>      lt_cfgs_partof TYPE TABLE OF bapicuprt,<BR>      ls_cfgs_partof TYPE bapicuprt,</STRONG></P>
    <P><STRONG>      lv_vbeln TYPE bapivbeln-vbeln,<BR>      lt_return TYPE TABLE OF bapiret2.</STRONG></P>
    <P><STRONG>* fill header<BR>  ls_header_in-doc_type = 'ZAPC'.<BR>  ls_header_in-sales_org = is_cost_order-vkorg.<BR>  ls_header_in-distr_chan = is_cost_order-vtweg.<BR>  ls_header_in-division = '01'.<BR>  ls_header_in-sales_off = '1011'.</STRONG></P>
    <P><STRONG>  ls_header_inx-updateflag = 'I'.<BR>  ls_header_inx-doc_type = 'X'.<BR>  ls_header_inx-sales_org = 'X'.<BR>  ls_header_inx-distr_chan = 'X'.<BR>  ls_header_inx-division = 'X'.<BR>  ls_header_inx-sales_off = 'X'.</STRONG></P>
    <P><STRONG>* fill partners<BR>  ls_partners-partn_role = 'AG'.<BR>  ls_partners-partn_numb = '1000000031'.   " фиктивный заказчик<BR>  APPEND ls_partners TO lt_partners.</STRONG></P>
    <P><STRONG>*  ls_items_in-material = is_cost_order-matnr.<BR>  ls_items_in-mat_entrd = is_cost_order-matnr.<BR>  ls_items_in-target_qty = '1'.<BR>  ls_items_in-itm_number = '000001'.<BR>  ls_items_in-po_itm_no = '000001'.<BR>  ls_items_in-item_categ = 'ZCRM'.<BR>  SELECT SINGLE meins INTO ls_items_in-target_qu<BR>    FROM mara<BR>    WHERE matnr = is_cost_order-matnr.<BR>  APPEND ls_items_in TO lt_items_in.</STRONG></P>
    <P><STRONG>  ls_items_inx-itm_number = '000001'.<BR>  ls_items_inx-item_categ = 'X'.<BR>  ls_items_inx-po_itm_no = 'X'.<BR>*  ls_items_inx-material = 'X'.<BR>  ls_items_inx-mat_entrd = 'X'.<BR>  ls_items_inx-target_qty = 'X'.<BR>  ls_items_inx-target_qu = 'X'.<BR>  ls_items_inx-updateflag = 'I'.<BR>  APPEND ls_items_inx TO lt_items_inx.</STRONG></P>
    <P><STRONG>* fill configuration<BR>  ls_cfgs_ref-posex = '000001'.<BR>  ls_cfgs_ref-config_id = '000001'.<BR>  ls_cfgs_ref-root_id = '00000001'.<BR>  APPEND ls_cfgs_ref TO lt_cfgs_ref.</STRONG></P>
    <P><STRONG> ls_cfgs_value-config_id = '000001'.<BR>  ls_cfgs_value-inst_id = '00000001'.</STRONG></P>
    <P><STRONG>  fill_prizn kod_prod 'KOD_PROD'.<BR>  fill_prizn tlot_min 'TLOT_MIN'.<BR>  fill_prizn tlot_max 'TLOT_MAX'.<BR>  fill_prizn shot_min 'SHOT_MIN'.<BR>  fill_prizn shot_max 'SHOT_MAX'.<BR>  fill_prizn dlot_min 'DLOT_MIN'.<BR>  fill_prizn dlot_max 'DLOT_MAX'.<BR>  fill_prizn marka 'MARKA'.<BR>  fill_prizn stndrt_marka 'STNDRT_MARKA'.<BR>  fill_prizn stndrt_prod  'STNDRT_PROD'.<BR>  fill_prizn tprk 'TPRK'.<BR>  fill_prizn grot 'GROT'.<BR>  fill_prizn vityazhka 'VITYAZHKA'.<BR>  fill_prizn krom 'KROM'.<BR>  fill_prizn chisl_st_pokr 'CHISL_ST_POKR'.<BR>  fill_prizn kls_tol_pokr  'KLS_TOL_POKR'.<BR>  fill_prizn proch_izg_t_lic_max 'PROCH_IZG_T_LIC_MAX'.<BR>  fill_prizn priz_zasch_pov 'PRIZ_ZASCH_POV'.<BR>  fill_prizn vid_pokr  'VID_POKR'.<BR>  fill_prizn mark_pokr 'MARK_POKR'.<BR>  fill_prizn mat_pokr_lic 'MAT_POKR_LIC'.<BR>  fill_prizn plsk 'PLSK'.<BR>  fill_prizn vid_postavki 'VID_POSTAVKI'.<BR>  fill_prizn dressir 'DRESSIR'.<BR>  fill_prizn travl   'TRAVL'.<BR>  fill_prizn fsfr_min 'FSFR_MIN'.<BR>  fill_prizn fsfr_max 'FSFR_MAX'.<BR>  fill_prizn krmn_min 'KRMN_MIN'.<BR>  fill_prizn krmn_max 'KRMN_MAX'.<BR>  fill_prizn mrgn_min 'MRGN_MIN'.<BR>  fill_prizn mrgn_max 'MRGN_MAX'.<BR>  fill_prizn almn_min 'ALMN_MIN'.<BR>  fill_prizn almn_max 'ALMN_MAX'.<BR>  fill_prizn cugl_min 'CUGL_MIN'.<BR>  fill_prizn cugl_max 'CUGL_MAX'.</STRONG></P>
    <P><STRONG>  ls_schedules_in-itm_number = '000001'.<BR>*  ls_schedules_in-req_date = sy-datum.<BR>  ls_schedules_in-sched_line = '0001'.<BR>  ls_schedules_in-req_qty = '1'.<BR>  APPEND ls_schedules_in TO lt_schedules_in.</STRONG></P>
    <P><STRONG>  ls_schedules_inx-itm_number = '000001'.<BR>  ls_schedules_inx-sched_line = '0001'.<BR>*  ls_schedules_inx-req_date = 'X'.<BR>  ls_schedules_inx-req_qty = 'X'.<BR>  ls_schedules_inx-updateflag = 'I'.<BR>  APPEND ls_schedules_inx TO lt_schedules_inx.</STRONG></P>
    <P><STRONG>  ls_cfgs_partof-parent_id = '00000001'.<BR>  ls_cfgs_partof-inst_id = '00000001'.<BR>  ls_cfgs_partof-class_type = '300'.<BR>  ls_cfgs_partof-obj_type = 'MARA'.<BR>  ls_cfgs_partof-obj_key = is_cost_order-matnr.<BR>  APPEND ls_cfgs_partof TO lt_cfgs_partof.</STRONG></P>
    <P><STRONG>  ls_cfgs_inst-config_id = '000001'.<BR>  ls_cfgs_inst-inst_id = '00000001'.<BR>  ls_cfgs_inst-obj_type = 'MARA'.<BR>  ls_cfgs_inst-class_type = '300'.<BR>  ls_cfgs_inst-obj_key = is_cost_order-matnr.<BR>  APPEND ls_cfgs_inst TO lt_cfgs_inst.</STRONG></P>
    <P><STRONG>  CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'<BR>    EXPORTING<BR>      order_header_in               = ls_header_in<BR>      order_header_inx              = ls_header_inx<BR>*      testrun                       =<BR>    IMPORTING<BR>      salesdocument                 = lv_vbeln<BR>    TABLES<BR>      return                        = lt_return<BR>      order_items_in                = lt_items_in<BR>      order_items_inx               = lt_items_inx<BR>      order_partners                = lt_partners<BR>      order_schedules_in            = lt_schedules_in<BR>      order_schedules_inx           = lt_schedules_inx<BR>      order_cfgs_ref                = lt_cfgs_ref<BR>      order_cfgs_inst               = lt_cfgs_inst<BR>      order_cfgs_part_of            = lt_cfgs_partof<BR>      order_cfgs_value              = lt_cfgs_value<BR>            .</STRONG></P>
    <P><STRONG>  READ TABLE lt_return TRANSPORTING NO FIELDS WITH KEY type = 'E'.<BR>  IF sy-subrc = 0.<BR>    CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'<BR>              .<BR>  ELSE.<BR>    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'<BR>      EXPORTING<BR>        wait          = 'X'<BR>              .<BR>  ENDIF.</STRONG></P>
    <P><STRONG>ENDFUNCTION.</STRONG></P>
    <P><STRONG></STRONG> </P>
    <P><STRONG></STRONG> </P>

  • Creating Sales Order using BAPI_SALESORDER_CREATEFROMDAT2

    Hi All,
    I am having problem while creating a SO using the BAPI_SALESORDER_CREATEFROMDAT2, Its returning sales documnet type is not defined. I used to get the error to speciy the ship to party or sold party earlier that has been resloved now I am getting the above specifed error.
    Please help me its very urgent
    Thanks,
    Suma

    Hi Suma
    While populating data for Sales Order Creation, populate PARTNER table with Sold-To or Ship-To as per you business process.
    Minimum two fields are to the fields for this structure:PARTN_ROLE , PARTN_NUMB
    PARTN_ROLE    ---> " Partner Role, which specifies the partner type i.e Sold-To, Ship-To, Bill-To ...
    ARTN_NUMB ---> " Customer Number
    Regards
    Eswar

  • Error in Creating Sales Order Using BAPI_SALESORDER_CREATEFROMDAT2

    Hi Everyone,
    We have a requirement to create sales order from flat file using BAPI. Everything was working well until we encounter a customer with credit control limit setup.
    Using the partners table for BAPi, the sold to customer is enter at header level, and we have this requirement to add the payer at item level. This is where the error is occuring. Upon debugging, I found out that the customer has a credit limit setup at FD33, and has a record found in KNKK, which is giving the error "Credit limit customer differs from credit limit customer in header".
    However, duting manual creation of sales order via VA01, this error is not encountered.
    Any ideas or suggesstions on how we can move forward with SO creation using BAPI with customers where credit management is setup?
    Thanks,
    Louisse

    If thats not working..
    try BAPI_SALESORDER_CREATEFROMDAT2
    If BAPI is not working. try creating a bdc for the same if there's not error on trying from VA01

  • Problem when creating a sales order using BAPI_SALESORDER_CREATEFROMDAT2

    Hello All,
    I am working on a requirement where i  need to create a new sales order from old sales order (Not all the items of the old sales order are to be copied) i am doing this by getting the data using BAPISDORDER_GETDETAILEDLIST to get the old sales order details and send them to BAPI_SALESORDER_CREATEFROMDAT2.
    My problem is that i when i send the condition also the system in addition to the conditions sent to the BAPI is also automatically proposing the condition types . So the final result is that the sales order ends up having the condition types twice .
    For example VPRS AZWR are visible twice in the sales order.
    Any inputs to solve the problem will be definitely rewarded.
    Thanks in advance.
    Regards,
    Sowmya.

    Hello All,
    I am working on a requirement where i  need to create a new sales order from old sales order (Not all the items of the old sales order are to be copied) i am doing this by getting the data using BAPISDORDER_GETDETAILEDLIST to get the old sales order details and send them to BAPI_SALESORDER_CREATEFROMDAT2.
    My problem is that i when i send the condition also the system in addition to the conditions sent to the BAPI is also automatically proposing the condition types . So the final result is that the sales order ends up having the condition types twice .
    For example VPRS AZWR are visible twice in the sales order.
    Any inputs to solve the problem will be definitely rewarded.
    Thanks in advance.
    Regards,
    Sowmya.

  • Create sales order with BAPI_SALESORDER_CREATEFROMDAT2 example

    Hi, does anyone have a working example of how to create a sales order using BAPI_SALESORDER_CREATEFROMDAT2?
    Thanks

    hi Robert,
    Check this code...try to map.
    one order with total sum of effort
    clear: l_order_header,
    l_salesdocument,
    l_order_partners,
    l_order_items,
    l_order_schdl.
    refresh: it_order_items,
    it_order_partners,
    it_order_schdl,
    it_return.
    ???????? get from material ...
    Order header
    l_order_header-doc_type = 'ZQBV'.
    l_order_header-distr_chan = '10'.
    l_order_header-division = '00'.
    if g_qals-werk eq '1100'.
    l_order_header-sales_org = '1000'.
    else.
    if g_qals-werk eq '3100'.
    l_order_header-sales_org = '3000'.
    else.
    message i001(00) with text-005.
    endif.
    endif.
    l_order_header-purch_no_c = g_qals-prueflos. " <= lot
    Partner data
    l_order_partners-partn_role = 'AG'.
    l_order_partners-partn_numb = g_qals-kunnr.
    append l_order_partners to it_order_partners.
    Order items => only one
    l_order_items-itm_number = 10.
    l_order_items-material = g_qals-matnr.
    l_order_items-target_qty = 1.
    append l_order_items to it_order_items.
    Schedules for quantity
    l_order_schdl-itm_number = 10.
    l_order_schdl-req_qty = 1. " <= only 1 !
    append l_order_schdl to it_order_schdl.
    Conditions for value
    l_order_conditions-itm_number = 10.
    l_order_conditions-cond_type = 'PR00'.
    l_order_conditions-cond_value = g_effort_sum.
    l_order_conditions-currency = g_effort_unit.
    append l_order_conditions to it_order_conditions.
    BAPI to create sales order
    CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
    EXPORTING
    SALESDOCUMENTIN =
    ORDER_HEADER_IN = l_order_header
    ORDER_HEADER_INX =
    SENDER =
    BINARY_RELATIONSHIPTYPE =
    INT_NUMBER_ASSIGNMENT =
    BEHAVE_WHEN_ERROR =
    LOGIC_SWITCH =
    TESTRUN =
    CONVERT = ' '
    IMPORTING
    SALESDOCUMENT = l_salesdocument
    TABLES
    RETURN = it_return
    ORDER_ITEMS_IN = it_order_items
    ORDER_ITEMS_INX =
    ORDER_PARTNERS = it_order_partners
    ORDER_SCHEDULES_IN = it_order_schdl
    ORDER_SCHEDULES_INX =
    ORDER_CONDITIONS_IN = it_order_conditions
    ORDER_CONDITIONS_INX =
    ORDER_CFGS_REF =
    ORDER_CFGS_INST =
    ORDER_CFGS_PART_OF =
    ORDER_CFGS_VALUE =
    ORDER_CFGS_BLOB =
    ORDER_CFGS_VK =
    ORDER_CFGS_REFINST =
    ORDER_CCARD =
    ORDER_TEXT =
    ORDER_KEYS =
    EXTENSIONIN =
    PARTNERADDRESSES =
    if not l_salesdocument is initial.
    order successfully created
    message i001(00) with text-001 l_salesdocument.
    endif.
    endif.
    for more info check the below link also
    Problem with BAPI_SALESORDER_CREATEFROMDAT2
    Regards,
    Naveen

  • Create a Sales order with reference to another sales order  using BAPI

    Dear All,
    Can any one tell me what are all the parameters required to create a Sales order with reference to another sales order using BAPI_SALESORDER_CREATEFROMDAT2....
    Thanks in advance

    Hi Madhan
    Thanks a lot for your reply.
    However, I would like to know which parameters need to passed in this BAPI in case of SO creation with reference. I beleive there are only a few parameters that need to passed in ORDER_HEADER_IN, ORDER_ITEMS_IN, etc.
    Need to know exactly which are these parameters.
    Regards
    Mihir Shah.

  • Sale Order Item Quantity Not Populating When Create A Sale Order Using BAPI

    I am having a problem when creating a sale order using BAPI
    BAPI_SALESORDER_CREATEFROMDAT2
    Problem is that sale order item quantity field is not populating
    code is as follows
    ORDER_ITEMS_IN-ITM_NUMBER = '0010'.
    ORDER_ITEMS_IN-MATERIAL = '000000000010000262'.
    ORDER_ITEMS_IN-TARGET_QU = 'LB'.
    ORDER_ITEMS_IN-TARGET_QTY = 1.

    Hi,
    Try populating ORDER_SCHEDULES_IN table in the bapi field REQ_QTY.
    Regds,
    Rudra

  • How to update sales orders using B1WS in SAP 8.8 PL18

    Hello all.
    We are having a problem updating sales orders using Sap Business One Web Service ( B1WS ).
    We are running SBO 8.8 PL18, MS-SQL 2008, and all is fine when using the SBO client.
    But when it comes to updating sales orders through B1WS we just cannot get it to work.
    We can add new orders easily without problems. Updating orders always gives this error:
    \[ORDR.PayDuMonth\]\[line: 0\] , 'Field cannot be updated (ODBC -1029)'
    We have checked and verified multiple times that our setup is correct.
    Also the WDSL files are verified.
    We can update orders just fine using the sboclient.
    And using B1WS we can basically do everything, besides updating.
    We have also tried this on different company db's, so we are quite sure this is not
    something related to some general setting we missed, but who knows?
    We have tried different ways to "assemble" the order before updating, but it always
    ends with the above error.
    Here is an example of one of the tests, where we load an order by docentry,
    increment the quantity of all open lines by '1', and then try to update it.
            protected void Page_Load(object sender, EventArgs e)
                // First we login
                string sessionId = "";
                LoginService.LoginService l_login = new LoginService.LoginService();
                LoginService.LoginDatabaseType l_dbtype = LoginService.LoginDatabaseType.dst_MSSQL2008;
                LoginService.LoginLanguage _lang = LoginService.LoginLanguage.ln_English;
                string _server = "SAP-8_8PL18";
                string _licserver = "SAP-8_8PL18:30000";
                string _db = "my_test_company";
                string _user = "manager";
                string _pass = "********";
                try
                    sessionId = l_login.Login(_server, _db, l_dbtype, true, _user, _pass,
                               _lang, true, _licserver);
                catch (Exception ex)
                    Response.Clear();
                    Response.Write(ex.Message);
                    Response.End();
                if (sessionId == "")
                    Response.Clear();
                    Response.Write("No sessionId");
                    Response.End();
                // We are logged in and have a sessionId
                // Now load a valid open order by docentry
                try
                    OrdersServiceRef.OrdersService orderService = new OrdersServiceRef.OrdersService();
                    orderService.MsgHeaderValue = new OrdersServiceRef.MsgHeader();
                    orderService.MsgHeaderValue.SessionID = sessionId;
                    orderService.MsgHeaderValue.ServiceName = OrdersServiceRef.MsgHeaderServiceName.OrdersService;
                    orderService.MsgHeaderValue.ServiceNameSpecified = true;
                    OrdersServiceRef.DocumentParams docParams = new OrdersServiceRef.DocumentParams();
                    docParams.DocEntry = 31; // Docentry of a known open order
                    docParams.DocEntrySpecified = true;
                    OrdersServiceRef.Document order = orderService.GetByParams(docParams);
                    OrdersServiceRef.DocumentDocumentLine line = null;
                    for (int i = 0; i < order.DocumentLines.Length; i++)
                        line = order.DocumentLines<i>;
                        if (line.LineStatus == OrdersServiceRef.DocumentDocumentLineLineStatus.bost_Open)
                            line.Quantity += 1;
                    orderService.Update(order);
                catch (System.Web.Services.Protocols.SoapException ex)
                    Response.Clear();
                    Response.Write(ex.Message);
                    Response.End();
                catch (Exception ex)
                    Response.Clear();
                    Response.Write(ex.Message);
                    Response.End();
                Response.Clear();
                Response.Write("All OK");
                Response.End();
    I hope that someone has an idea as to why this happens.
    The customer often changes quantity or adds lines on their orders,
    and the only way to solve it so far has been to make a new order and
    close the old one.
    Thanks in advance
    J. Thomsen

    Hi,
    Welcome you post on the forum.
    Have you checked if you only update a specific line instead of a loop?
    Thanks,
    Gordon

  • Confirmation Quantity issue while creating Sales order using BAPI

    Hi SDN,
    Can anyone of you help mein the below issue:
    I have a program to create a sales order using upload file. for this i use "BAPI_SALESORDER_CREATEFROMDAT2" & for changing existing "BAPI_SALESORDER_CHANGE".
    Now If the upload file contains the Same Material, Based on other conditions, it needs to create Multiple sales order.
    When the first Salesorder is created, the Quantity is getting confirmed (Confirmed quantity VBEP-BMENG). But during actual run, since the confirmation is getting done for the same material in the above Sales order, the confirmation is not being done in the subsequent Sales order".
    This poses a problem for business, user need to manual refresh the u201Cconfirmed quantity for each line item in the particular SO where it failed during program upload.
    Also while uploading using the BAPI, if we wait forsometime after creating the first sales order in Debug, then the above material is unlocked & the confirmation quantity is done for the subsequent sales order also.
    But in the actual run, this is creating a problem. Some Refresh or Unlocking problem.
    Can you please suggest a suitable solution for this issue.
    Thanks & regrads,
    Chaitanya LBK

    Have you tried backorder processing?
    V_V1
    V_V2
    V_RA
    V_R1
    V_R2

  • Price is not being updated when creating a sales order using DTW oOrders

    Hello experts,
    When I create a sales Order using DTW (oOrders), the information in the input files document.csv and document_lines.csv is updated with no problem, except the price. The price is being ignored from the input files.
    Is there something that I must considered when trying to update the price of a sales order using the DTW?
    The field "price" was mapped in the source and target fields in DTW.
    Here is the document_lines.csv
    RecordKey,LineNum,AccountCode,Address,ItemCode,LineTotal,Price,Quantity,ShipDate,WarehouseCode,TaxCode
    RecordKey,LineNum,AccountCode,Address,ItemCode,LineTotal,Price,Quantity,ShipDate,WarehouseCode,TaxCode
    1,1,_SYS00000000059, ,30PA08-0360-25,1,11.2,3,20110702,V08,A5
    1,2,_SYS00000000059, ,30PA08-0707-25,1,15.2,3,20110702,V08,A5
    1,3,_SYS00000000059, ,30PA08-0707-22,1,18.3,3,20110702,V08,A5
    And the document.csv:
    RecordKey,DocEntry,CardCode,DocDate,DocDueDate,DocTotal
    RecordKey,DocEntry,CardCode,DocDate,DocDueDate,DocTotal
    1, ,c-6167,20110702,20110702,2
    Thank you for your help
    Jorge Manzo

    Hi,
    Try to re-create your dtw using my template,and use text tab when saving your template.
    SO-Header
    RecordKey     CardCode     CardName     Comments     DocDate     DocDueDate     DocNum
    RecordKey     CardCode     CardName     Comments     DocDate     DocDueDate     DocNum
    1     24-25 MANUFACTU     24-25 MANUFACTURING          4/5/2010     4/15/2010     11142
    SO-LINE
    RecordKey     linenum     itemcode     qty     uom      PriceAfterVAT      Price     SalesPersonCode
    RecordKey     linenum     itemcode     qty     uom      PriceAfterVAT      Price     SalesPersonCode
    1     0     SHAFT HEX 7/8"     1     pc     4536     4050     CRIS
    Note : Line -(LINE NUM and QTY is important upon computation of Price if SO is ITEM TYPE Document.
    hope this will help you!
    Regards,
    Darius

  • Update the sales order ( Quantity ).

    Hi Experts,
    I am using BAPI_SALESORDER_CHANGE. I want to change only Quantity of a sales order for that I pass it in ITEM Table and set the flag for these values in ITEMX table.
    After executing BAPI it runs Successfully so I commit it by using BAPI_TRANSACTION_COMMIT.
    Now my query is after commited BAPI it does not update the  related sales order in database.
    Why is it occurs meantime it is possible manually by VA02.
    Suggess what to do to solve this?
    Points will be sured for helpful answers.
    Thanks & regards
    Alok Vishnoi

    Hi Alok,
    If you want to change the quantity in a sales order item using BAPI_SALESORDER_CHANGE you have to pass the new quantity in the Schedule Lines (SCHEDULE_LINES) table to the BAPI_SALESORDER_CHANGE. Then only the new quantity gets reflected at the item level.
    If u just change the quantity at the Item level it will not get effected.
    I hope it is useful. Please let me know if u need any information.
    Regards,
    Suresh Linga.

Maybe you are looking for

  • Saved PDF files in Illustrator not showing when opened in Reader

    I'm having a problem with files saved as PDFs in Illustrator, which, when opened in Reader reveal only a blank page. Any solutions?

  • AC Adapter cable part#

    I would like to order an AC adapter cable for the Mini 1.42Ghz and an ACD 20'. The AC adapter cable's need to work in Australia. Any ideas of where I could source this from? iBook Dual USB (600Mhz)/640MB, Mini 1.42/1GB   Mac OS X (10.4.6)   Snow Airp

  • How to use GPShells open_sc command for a SC02 option 15 Card (J2A, J3A)?

    Hi, my cards tell me as response to get-data 0066 command, that they are using SC02 option 15: Global Platform version : 2.1.1 Global Platform Secure Channel Protocol: 02 option 15 What are the right parameters for GPShells open_sc command? h3. GPShe

  • Multiple Language Integration

    Hi, We have SMS gateway integrated with our SAP CRM instance,where we have Business Partners of diiferent countries.Requirement is to link the SMS language based on the selection of language at the Business Partner. Need help to know whether this is

  • DataGrid Help needed

    Hi, I am using a dataGrid to display XML material. I have a lot of information in it, so some of the fields are being displayed at the bottom for the selected item only. Similar to this example http://blog.paranoidferret.com/index.php/2007/08/29/flex