'BAPI_QUOTATION_CREATEFROMDATA2'导入数据时,订单数量为0
*&---------------------------------------------------------------------**& Report ZSD_TEST
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zsd_test.
DATA:
header LIKE bapisdhd1,
headerx LIKE bapisdhd1x,
g_vbeln LIKE vbak-vbeln,
it_retmsg LIKE TABLE OF bapiret2 WITH HEADER LINE,
it_item LIKE TABLE OF bapisditm WITH HEADER LINE,
it_itemx LIKE TABLE OF bapisditmx WITH HEADER LINE,
it_partners LIKE TABLE OF bapiparnr WITH HEADER LINE,
it_sch LIKE TABLE OF bapischdl WITH HEADER LINE,
it_condition LIKE TABLE OF bapicond WITH HEADER LINE.
headerx-updateflag = 'I'.
headerx-doc_type = 'X'.
headerx-sales_org = 'X'.
headerx-distr_chan = 'X'.
headerx-division = 'X'.
headerx-req_date_h = 'X'.
headerx-qt_valid_f = 'X'.
headerx-qt_valid_t = 'X'.
header-doc_type = 'ZQTC'.
header-sales_org = '1060'.
header-distr_chan = 'ET'.
header-division = '60'.
*header-war_date = sy-datum."销售里担保.
header-req_date_h = sy-datum + 15."请求交货日期
header-qt_valid_f = sy-datum. "报价/询价有效从
header-qt_valid_t = '99991231'. "投标/报价截止的日期(有效日)
*header-ref_1 = '货到付款'.
*header-telephone = '110'.
*header-pmnttrms = 'Y000'.
*header-currency = 'CNY'.
*header-price_date = sy-datum + 2.
it_partners-partn_role = 'AG'.
it_partners-partn_numb = '0000000086'."售达方
APPEND it_partners.
*& 初始化项目
it_itemx-updateflag = 'I'.
it_itemx-itm_number = 10.
it_itemx-material = 'X'.
it_itemx-plant = 'X'.
it_itemx-target_qty = 'X'.
it_itemx-target_qu = 'X'.
it_item-itm_number = '10'.
it_item-material = '12303700370000000D'.
it_item-plant = '1000'.
it_item-target_qty = '11'.
it_item-target_qu = 'PCS'.
*it_item-store_loc = 'R950'.
APPEND it_item.
*it_itemx-updateflag = 'I'.
*it_itemx-itm_number = 20.
*it_itemx-material = 'X'.
*it_itemx-plant = 'X'.
*it_itemx-target_qty = 'X'.
*it_itemx-target_qu = 'X'.
*
*it_item-itm_number = '20'.
*it_item-material = '123070204600000010'.
*it_item-plant = '1000'.
*it_item-target_qty = '21'.
**it_item-target_qu = 'PCS'.
**it_item-store_loc = 'R950'.
*APPEND it_item.
**& 首日起,订单数量
*it_sch-itm_number = '000010'.
*it_sch-req_date = sy-datum.
*it_sch-dlv_date = sy-datum.
*it_sch-req_qty = '11'."数量
*APPEND it_sch.
*
*it_sch-itm_number = '000020'.
*it_sch-req_date = sy-datum.
*it_sch-dlv_date = sy-datum.
*it_sch-req_qty = '21'."数量
*APPEND it_sch.
*
**& 抬头的条件价格
*it_condition-currency = 'CNY'.
*it_condition-cond_type = 'ZP00'.
*it_condition-cond_value = '11'.
*APPEND it_condition.
*
**&项目的金额,一定要加上货币,否则会乘以10倍
*it_condition-itm_number = '000010'.
*it_condition-cond_type = 'ZP00'.
*it_condition-roundoffdi = '1.000'.
*it_condition-currency = 'CNY'.
*APPEND it_condition.
*
*it_condition-itm_number = '000020'.
*it_condition-cond_type = 'ZP00'.
*it_condition-roundoffdi = '22.000'.
*it_condition-currency = 'CNY'.
*APPEND it_condition.
CALL FUNCTION 'BAPI_QUOTATION_CREATEFROMDATA2'
EXPORTING
quotation_header_in = header
quotation_header_inx = headerx
IMPORTING
salesdocument = g_vbeln
TABLES
return = it_retmsg
quotation_items_in = it_item
quotation_items_inx = it_itemx
quotation_partners = it_partners
* quotation_schedules_in = it_sch
* quotation_conditions_in = it_condition
.
IF sy-subrc = 0.
READ TABLE it_retmsg WITH KEY type = 'E'.
IF sy-subrc <> 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' .
WRITE: 'sale order document:',g_vbeln.
*取意向订单对应的状态对象编号
DATA:g_objnr LIKE vbak-objnr.
SELECT SINGLE objnr INTO g_objnr
FROM vbak
WHERE vbeln = g_vbeln.
* IF sy-subrc = 0.
*
* CALL FUNCTION 'STATUS_CHANGE_EXTERN'
* EXPORTING
* objnr = g_objnr
* user_status = 'E0004'.
* ENDIF.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
ENDIF.
ENDIF.
详细内容请看:
http://blog.csdn.net/ericdzhang/archive/2009/12/07/4958341.aspx --------------------编程问答-------------------- 各位,我用上面的程序导入报价(VA21)数据时已经导入了。但是报价的数量为0.不知是哪里没有传递参数?还是缺少什么条件??
--------------------编程问答-------------------- 这个问题搞定了。
具体原因是一定需要it_sch这个数据。
*&---------------------------------------------------------------------*
*& Report ZSD_TEST
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zsd_test.
DATA:
header LIKE bapisdhd1,
* headerx LIKE bapisdhd1x,
g_vbeln LIKE vbak-vbeln,
it_retmsg LIKE TABLE OF bapiret2 WITH HEADER LINE,
it_item LIKE TABLE OF bapisditm WITH HEADER LINE,
* it_itemx LIKE TABLE OF bapisditmx WITH HEADER LINE,
it_partners LIKE TABLE OF bapiparnr WITH HEADER LINE,
it_sch LIKE TABLE OF bapischdl WITH HEADER LINE,
it_condition LIKE TABLE OF bapicond WITH HEADER LINE.
*headerx-updateflag = 'I'.
*headerx-doc_type = 'X'.
*headerx-sales_org = 'X'.
*headerx-distr_chan = 'X'.
*headerx-division = 'X'.
*headerx-req_date_h = 'X'.
*headerx-qt_valid_f = 'X'.
*headerx-qt_valid_t = 'X'.
header-doc_type = 'ZQTC'.
header-sales_org = '1060'.
header-distr_chan = 'ET'.
header-division = '60'.
header-req_date_h = sy-datum + 2. "请求交货日期
header-qt_valid_f = sy-datum. "报价/询价有效从
header-qt_valid_t = '99991231'. "投标/报价截止的日期(有效日)
it_partners-partn_role = 'AG'.
it_partners-partn_numb = '0000000086'."售达方
APPEND it_partners.
it_partners-partn_role = 'WE'.
it_partners-partn_numb = '0000000086'."售达方
APPEND it_partners.
*& 初始化项目
*it_itemx-updateflag = 'I'.
*it_itemx-itm_number = '000010'.
*it_itemx-material = 'X'.
*it_itemx-plant = 'X'.
*it_itemx-target_qty = 'X'.
*it_itemx-target_qu = 'X'.
*it_itemx-salqtynum = 'X'.
*it_itemx-salqtyden = 'X'.
*APPEND it_itemx.
it_item-itm_number = '000010'.
it_item-material = '12303700370000000D'.
it_item-plant = '1000'.
*it_item-target_qty = '1100'. "这个数量可以不要传递
*it_item-target_qu = 'PCS'.
*it_item-salqtynum = '1'.
*it_item-salqtyden = '1'.
*& 计划行数量
it_sch-itm_number = '000010'.
*it_sch-req_date = sy-datum.
*it_sch-dlv_date = sy-datum.
it_sch-req_qty = '11000'. "数量 这个数量一定要有,否则报价单上的"订单数量"为0
APPEND it_sch. "这里的Append的顺序不知是否有影响,原来APPEND it_item.是在 it_item后就新增了
APPEND it_item.
**& 抬头的条件价格
**it_condition-currency = 'HKD'.
**it_condition-cond_type = 'ZP00'.
**it_condition-cond_value = '12'.
**APPEND it_condition.
*
**&项目的金额,一定要加上货币,否则会乘以10倍
*it_condition-itm_number = '000010'.
*it_condition-cond_type = 'ZP00'.
*it_condition-roundoffdi = '1.000'.
*it_condition-currency = 'HKD'.
*APPEND it_condition.
**it_condition-itm_number = '000020'.
**it_condition-cond_type = 'ZP00'.
**it_condition-roundoffdi = '22.000'.
**it_condition-currency = 'CNY'.
**APPEND it_condition.
CALL FUNCTION 'BAPI_QUOTATION_CREATEFROMDATA2'
EXPORTING
quotation_header_in = header
* quotation_header_inx = headerx
testrun = ' '
IMPORTING
salesdocument = g_vbeln
TABLES
return = it_retmsg
quotation_items_in = it_item
* quotation_items_inx = it_itemx
quotation_partners = it_partners
quotation_schedules_in = it_sch "这里一定要传递,否则数量为0
* quotation_conditions_in = it_condition
.
IF sy-subrc = 0.
READ TABLE it_retmsg WITH KEY type = 'E'.
IF sy-subrc <> 0.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' .
WRITE: 'sale order document:',g_vbeln.
*取意向订单对应的状态对象编号
DATA:g_objnr LIKE vbak-objnr.
SELECT SINGLE objnr INTO g_objnr
FROM vbak
WHERE vbeln = g_vbeln.
* IF sy-subrc = 0.
*
* CALL FUNCTION 'STATUS_CHANGE_EXTERN'
* EXPORTING
* objnr = g_objnr
* user_status = 'E0004'.
* ENDIF.
* CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
* EXPORTING
* wait = 'X'.
ENDIF.
ENDIF.
补充:企业软件 , ERP/CRM