最开始我用了下面的代码,把quantity的值写入item字段target_qty:
ls_order_items_in-item_categ = 'TAN'. ls_order_items_in-material = 'REDUCER_A'. ls_order_items_in-target_qty = 999. ls_order_items_in-itm_number = 10. ls_order_item_x-item_categ = 'X'. ls_order_item_x-material = 'X'. ls_order_item_x-target_qty = 'X'. ls_order_item_x-itm_number = 'X'. ls_order_item_x-updateflag = 'I'. APPEND ls_order_item_x TO lt_order_item_x. APPEND ls_order_items_in TO lt_order_items_in.
执行后发现不工作。
研究了一个维护有正确quantity的行项目,发现这个quantity字段实际上是维护在item的schedule line上的:
而我们在item上看到的order quantity,从F1帮助文档里已经看得很清楚了,是一个累加值,所有schedule line的quantity的求和。
所以正确的代码应该是还得创建item的schedule line:
ls_schdlin-itm_number = 10. ls_schdlin-req_qty = 3. ls_schdlinx-itm_number = 'X'. ls_schdlinx-itm_number = 'X'. ls_schdlinx-updateflag = 'X'. APPEND ls_schdlin TO lt_schdlin. APPEND ls_schdlinx TO lt_schdlinx.
完整代码下图所示: