Skip to Content
avatar image
Former Member

Give me some clarification about BAPI's

Hai All,

Here i am creating a sales order through BAPI_SALESORDER_CREATEFROMDAT2 function module. In this i am passing TARGET_QTY field through tables parameter ORDER_ITEMS_IN. Here it is creating sales order number. And aslo it is giving a warning message that sales order not created completely. When i am checking the sales order through va02 transaction the target quantity which i have passed is not reflecting to ORDER QTY of the sales order. Please clarify this problem

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Best Answer
    avatar image
    Former Member
    Oct 08, 2007 at 04:39 AM

    Hi

    May be Something wrong when passing the Qty field to the BAPI structure

    see the sample code and do accordingly

    PARAMETERS: p_auart TYPE auart OBLIGATORY.

    PARAMETERS: p_vkorg TYPE vkorg OBLIGATORY.

    PARAMETERS: p_vtweg TYPE vtweg OBLIGATORY.

    PARAMETERS: p_spart TYPE vtweg OBLIGATORY.

    PARAMETERS: p_sold TYPE kunnr OBLIGATORY.

    PARAMETERS: p_ship TYPE kunnr OBLIGATORY.

    *ITEM

    PARAMETERS: p_matnr TYPE matnr OBLIGATORY.

    PARAMETERS: p_menge TYPE kwmeng OBLIGATORY.

    PARAMETERS: p_plant TYPE werks_d OBLIGATORY.

    PARAMETERS: p_itcat TYPE pstyv OBLIGATORY.

    • DATA DECLARATIONS.

    DATA: v_vbeln LIKE vbak-vbeln.

    DATA: header LIKE bapisdhead1.

    DATA: headerx LIKE bapisdhead1x.

    DATA: item LIKE bapisditem OCCURS 0 WITH HEADER LINE.

    DATA: itemx LIKE bapisditemx OCCURS 0 WITH HEADER LINE.

    DATA: partner LIKE bapipartnr OCCURS 0 WITH HEADER LINE.

    DATA: return LIKE bapiret2 OCCURS 0 WITH HEADER LINE.

    DATA: lt_schedules_inx TYPE STANDARD TABLE OF bapischdlx

    WITH HEADER LINE.

    DATA: lt_schedules_in TYPE STANDARD TABLE OF bapischdl

    WITH HEADER LINE.

    • HEADER DATA

    header-doc_type = p_auart.

    headerx-doc_type = 'X'.

    header-sales_org = p_vkorg.

    headerx-sales_org = 'X'.

    header-distr_chan = p_vtweg.

    headerx-distr_chan = 'X'.

    header-division = p_spart.

    headerx-division = 'X'.

    headerx-updateflag = 'I'.

    • PARTNER DATA

    partner-partn_role = 'AG'.

    partner-partn_numb = p_sold.

    APPEND partner.

    partner-partn_role = 'WE'.

    partner-partn_numb = p_ship.

    APPEND partner.

    • ITEM DATA

    itemx-updateflag = 'I'.

    item-itm_number = '000010'.

    itemx-itm_number = 'X'.

    item-material = p_matnr.

    itemx-material = 'X'.

    item-plant = p_plant.

    itemx-plant = 'X'.

    item-target_qty = p_menge.

    itemx-target_qty = 'X'.

    item-target_qu = 'EA'.

    itemx-target_qu = 'X'.

    item-item_categ = p_itcat.

    itemx-item_categ = 'X'.

    APPEND item.

    APPEND itemx.

    • Fill schedule lines

    lt_schedules_in-itm_number = '000010'.

    lt_schedules_in-sched_line = '0001'.

    lt_schedules_in-req_qty = p_menge.

    APPEND lt_schedules_in.

    • Fill schedule line flags

    lt_schedules_inx-itm_number = '000010'.

    lt_schedules_inx-sched_line = '0001'.

    lt_schedules_inx-updateflag = 'X'.

    lt_schedules_inx-req_qty = 'X'.

    APPEND lt_schedules_inx.

    • Call the BAPI

    CALL FUNCTION 'BAPI_SALESDOCU_CREATEFROMDATA1'

    EXPORTING

    sales_header_in = header

    sales_header_inx = headerx

    IMPORTING

    salesdocument_ex = v_vbeln

    TABLES

    return = return

    sales_items_in = item

    sales_items_inx = itemx

    sales_schedules_in = lt_schedules_in

    sales_schedules_inx = lt_schedules_inx

    sales_partners = partner.

    • Check the return table.

    LOOP AT return WHERE type = 'E' OR type = 'A'.

    EXIT.

    ENDLOOP.

    IF sy-subrc = 0.

    WRITE: / 'Error in creating document'.

    ELSE.

    COMMIT WORK AND WAIT.

    WRITE: / 'Document ', v_vbeln, ' created'.

    ENDIF.

    Regards

    Anji

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 08, 2007 at 04:40 AM

    ve u appended ur internal table?

    Add comment
    10|10000 characters needed characters exceeded