Skip to Content
avatar image
Former Member

FM SD_SALESDOCUMENT_CREATE

Hi experts,

I'm using SD_SALESDOCUMENT_CREATE function module and I need to also create the header text of the created sales order, however it is not working.

Here the code:

  • wa_textheaders-sd_doc = wa_alv_output_dummy-vbeln.

  • wa_textheaders-itm_number = space.

  • wa_textheaders-applobject = c_vbbk.

  • wa_textheaders-text_id = 'ZNFO'.

  • wa_textheaders-text_name = wa_line.

  • wa_textheaders-langu = sy-langu.

  • APPEND wa_textheaders TO i_textheaders.

  • Function module to create new sales order

CALL FUNCTION 'SD_SALESDOCUMENT_CREATE'

EXPORTING

sales_header_in = wa_hdr_in

sales_header_inx = wa_hdr_inx

IMPORTING

salesdocument_ex = v_sales_order

TABLES

return = i_return

sales_items_in = i_items

sales_items_inx = i_itemsx

sales_partners = i_partners

sales_conditions_in = i_cond

sales_conditions_inx = i_condx

textheaders_ex = i_textheaders. " I - SIR 115839

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Best Answer
    Oct 22, 2008 at 07:57 AM

    what is the error message in the return table..? and also use BAPI_TRANSACTION_COMMIT after checking the success of the function module.

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi,

      Populate data as in my early example and pass to parameter table: SALES_TEXT of FM: SD_SALESDOCUMENT_CREATE.

      call function 'SD_SALESDOCUMENT_CREATE'
          exporting
      *      SALESDOCUMENT                 =
            sales_header_in               = ibapisdhd1
            sales_header_inx              = ibapisdhd1x
      *      BUSINESS_OBJECT               = ' '
         importing
            salesdocument_ex              = ibapivbeln
         tables
            return                        = ibapiret2
            sales_items_in                = ibapisditm
            sales_items_inx               = ibapisditmx
            sales_partners                = ibapiparnr
            sales_schedules_in            = ibapischdl
            sales_schedules_inx           = ibapischdlx
            sales_conditions_in           = ibapicond
            sales_conditions_inx          = ibapicondx
            sales_text                    = ibapisdtext
            partneraddresses              = ibapiparadr.

      Regards

      Eswar

  • avatar image
    Former Member
    Oct 22, 2008 at 07:41 AM

    Hello,

    Check this FM

    we have to fill all the data according to u r requirements then only this Fm will work check it.

    CALL FUNCTION 'SD_SALESDOCUMENT_CREATE'

    EXPORTING

    sales_header_in = y_wa_header

    sales_header_inx = y_wa_headerx

    int_number_assignment = y_wa_bapiflag

    logic_switch = y_wa_logswitch

    testrun = p_return

    IMPORTING

    salesdocument_ex = y_v_sorder

    TABLES

    return = y_i_return

    sales_items_in = y_i_item

    sales_items_inx = y_i_itemx

    sales_partners = y_i_partner

    sales_schedules_in = y_i_schedule

    sales_schedules_inx = y_i_schedulex

    sales_conditions_in = y_i_cond

    sales_conditions_inx = y_i_condx

    sales_text = y_i_ordtxt

    extensionin = y_i_bapiex.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 22, 2008 at 07:42 AM

    Hi,

    Assuming your sales order number is following internal number assignment, check below routine to add sales order header texts.

    *&---------------------------------------------------------------------*
    *&      Form  ADD_TEXT
    *&---------------------------------------------------------------------*
    form add_text  using    p_tid   like thead-tdid
                            p_text  like s023_header-text1.
    
    *** Sales Document Header Texts
      clear: ibapisdtext.
      ibapisdtext-text_id   = p_tid.
      ibapisdtext-langu     = sy-langu.
      ibapisdtext-text_line = p_text.
      append ibapisdtext.
    
    endform.                    " ADD_TEXT

    Regards

    Eswar

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 22, 2008 at 07:43 AM

    Hi,

    You need to use the parameter TEXTLINES_EX set the name, text ID and language on each row and add the text you require to the LINE parameter of the structure BAPITEXTLI.

    Darren

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 22, 2008 at 07:54 AM

    Hi Marc,

    There might be some problem in your data declaration part.

    Please check it.

    Hope this code might be a help.

    DATA: order_header_in LIKE bapisdhd1.

    DATA: order_items_in TYPE STANDARD TABLE OF bapisditm WITH HEADER LINE.

    DATA: order_schedules_in

    TYPE STANDARD TABLE OF bapischdl WITH HEADER LINE.

    DATA: order_partners TYPE STANDARD TABLE OF bapiparnr WITH HEADER LINE.

    DATA: return TYPE STANDARD TABLE OF bapiret2 WITH HEADER LINE.

    data: itemx like bapisditmx occurs 10 with header line.

    order_header_in-doc_type = 'ZWV'.

    order_header_in-sales_org = '1000'.

    order_header_in-distr_chan = '10'.

    order_header_in-division = '10'.

    order_header_in-purch_date = sy-datum.

    order_header_in-purch_no_c = 'BAPITEST'.

    order_partners-partn_role = 'AG'.

    order_partners-partn_numb = '0001000005'.

    APPEND order_partners.

    order_partners-partn_role = 'ZS'.

    order_partners-partn_numb = '1046'.

    APPEND order_partners.

    IF ORDER_HEADER_IN-DOC_TYPE = 'ZWV'.

    ORDER_PARTNERS-ITM_NUMBER = '10'.

    order_partners-partn_role = 'ZO'.

    order_partners-partn_numb = '0001000005'.

    APPEND order_partners.

    ENDIF.

    • add next line with more than one item

    order_items_in-itm_number = '000010'.

    order_items_in-material = '000000000000111111'.

    order_items_in-target_qty = '1.000'.

    order_items_in-target_qu = 'ST'.

    order_items_in-sales_unit = 'ST'.

    APPEND order_items_in.

    order_schedules_in-req_qty = '1.000'.

    APPEND order_schedules_in.

    *Add following lines with more than one line

    itemx-itm_number = '000010'.

    itemx-updateflag = 'I'.

    itemx-material = 'X'.

    itemx-target_qty = 'X'.

    append itemx.

    order_items_in-itm_number = '000020'.

    order_items_in-material = '000000000000111111'.

    order_items_in-target_qty = '1.000'.

    order_items_in-target_qu = 'ST'.

    order_items_in-sales_unit = 'ST'.

    APPEND order_items_in.

    order_schedules_in-req_qty = '1.000'.

    APPEND order_schedules_in.

    itemx-itm_number = '000020'.

    itemx-updateflag = 'I'.

    itemx-material = 'X'.

    itemx-target_qty = 'X'.

    append itemx.

    *stop add more lines

    REFRESH return.

    BREAK-POINT.

    CALL FUNCTION 'SD_SALESDOCUMENT_CREATE'

    EXPORTING

    sales_header_in = order_header_in

    TABLES

    return = return

    sales_items_in = order_items_in

    sales_items_inx = itemx

    sales_partners = order_partners

    sales_schedules_in = order_schedules_in.

    COMMIT WORK AND WAIT.

    LOOP AT return.

    WRITE: / return.

    ENDLOOP.

    Regards,

    Amit.

    Add comment
    10|10000 characters needed characters exceeded