Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

'BAPI_SALESORDER_CREATEFROMDAT2' Comp_quant.

Former Member
0 Likes
441

Hello, there.

I'm trying to create order, with some positions. I've populated field comp_quant as follows, but after sucessfull returning, Quantity field stays null. Please give me some direction to solve this problem.

**************************************************************************

LOOP AT it_bapi.

CLEAR gt_order_items_inx.

CLEAR gt_order_items_in.

gt_order_items_inx-updateflag = 'I'.

*Matnr

CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'

EXPORTING

input = it_bapi-mabnr

IMPORTING

output = gt_order_items_in-material.

gt_order_items_inx-material = 'X'.

*Item Position

gt_order_items_in-itm_number = sy-tabix * 10.

gt_order_schedules_in-itm_number = gt_order_items_in-itm_number.

gt_order_items_inx-itm_number = 'X'.

gt_order_schedules_inx-itm_number = 'X'.

*Quantity

gt_order_items_in-comp_quant = it_bapi-kwmeng.

gt_order_items_inx-comp_quant = 'X'.

gt_order_items_inx-target_qty = 'X'.

APPEND gt_order_items_in.

APPEND gt_order_items_inx.

ENDLOOP.

**************************************************************************

*Description

gt_order_text-itm_number = ''.

gt_order_text-text_id = '0002'.

gt_order_text-langu = sy-langu.

gt_order_text-format_col = '*'.

gt_order_text-text_line = ctext.

APPEND gt_order_text.

**************************************************************************

CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'

EXPORTING

order_header_in = gs_order_header_in

testrun = testrun

IMPORTING

salesdocument = gv_salesdocument

TABLES

return = messtab[]

order_items_in = gt_order_items_in[]

order_items_inx = gt_order_items_inx[]

order_partners = gt_order_partners[]

order_text = gt_order_text[].

3 REPLIES 3
Read only

Former Member
0 Likes
400

Long,

Set the RE_QTY in the SCHEDULE LINE table.

Your_Sched_Line-REQ_QTY = Some_tab-QTY.

Read only

0 Likes
400

Do mean smth like this? It take no effect actualy.

**************************************************************************
  loop at it_bapi.
    clear gt_order_items_inx.
    clear gt_order_items_in.
    gt_order_items_inx-updateflag = 'I'.
    gt_order_schedules_inx-updateflag = 'I'.
*Matnr
    call function 'CONVERSION_EXIT_MATN1_INPUT'
      exporting
        input  = it_bapi-mabnr
      importing
        output = gt_order_items_in-material.
    gt_order_items_inx-material = 'X'.
*Item_pos
    gt_order_items_in-itm_number  = sy-tabix * 10.
    gt_order_schedules_in-itm_number = gt_order_items_in-itm_number.
    gt_order_items_inx-itm_number = gt_order_items_in-itm_number.
    gt_order_schedules_inx-itm_number = gt_order_items_in-itm_number.
*Quantity

    gt_order_items_in-target_qty = it_bapi-kwmeng.
    gt_order_schedules_in-req_qty = it_bapi-kwmeng.
    gt_order_schedules_inx-req_qty = 'X'.
    gt_order_items_inx-target_qty = 'X'.

    append gt_order_schedules_in.
    append gt_order_schedules_inx.
    append gt_order_items_in.
    append gt_order_items_inx.
  endloop.

**************************************************************************

  call function 'BAPI_SALESORDER_CREATEFROMDAT2'
    exporting
      order_header_in     = gs_order_header_in
      testrun             = testrun
    importing
      salesdocument       = gv_salesdocument
    tables
      return              = messtab[]
      order_items_in      = gt_order_items_in[]
      order_items_inx     = gt_order_items_inx[]
      order_schedules_in  = gt_order_schedules_in[]
      order_schedules_inx = gt_order_schedules_inx[]
      order_partners      = gt_order_partners[]
      order_text          = gt_order_text[].

Message was edited by:

Long Nguyen

Message was edited by:

Long Nguyen

Read only

0 Likes
400

Yes... the REQ_QTY field of the Sched line table is what is REALLY used to set the qty value in the order.