BAPI 'BAPI_QUOTATION_CREATEFROMDATA2'

  REPORT test_bapi_va21.
DATA:header LIKE bapisdhd1,
     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.

header-doc_type   = 'ZYT5'.
header-sales_org  = '2006'.
header-distr_chan = '00'.
header-division  = '00'.
header-war_date   = sy-datum."销售里担保.
header-req_date_h = sy-datum + 15."请求交货日期
header-ref_1  = '货到付款'.
header-telephone = '110'.
header-pmnttrms  = 'Y000'.
header-currency  = 'CNY'.
header-price_date = sy-datum + 2.
*& 初始化项目
it_item-itm_number = '10'.
it_item-material   = '1000-00003'.
it_item-plant = '2000'.
it_item-store_loc = 'R950'.
APPEND it_item.

it_partners-partn_role = 'WE'.
it_partners-partn_numb = '0000110527'."售达方
APPEND it_partners.
*& 首日起,订单数量
it_sch-itm_number = '000010'.
it_sch-req_date   = sy-datum.
*it_sch-dlv_date  = sy-datum.
it_sch-req_qty    = '2'."数量
APPEND it_sch.
*& 抬头的条件价格
it_condition-currency = 'CNY'.
it_condition-cond_type = 'Z027'.
it_condition-cond_value = '1'.


APPEND it_condition.
*&项目的金额,一定要加上货币,否则会乘以10倍
it_condition-itm_number = '000010'.
it_condition-cond_type = 'ZP01'.
it_condition-roundoffdi = '1.000'.
it_condition-currency = 'CNY'.
APPEND it_condition.

CALL FUNCTION 'BAPI_QUOTATION_CREATEFROMDATA2'
  EXPORTING
    quotation_header_in     = header
  IMPORTING
    salesdocument           = g_vbeln
  TABLES
    return                  = it_retmsg
    quotation_items_in      = it_item
    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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值