ITPub博客

首页 > Linux操作系统 > Linux操作系统 > BAPI_SALESORDER_CREATEFROMDAT2 BAPI创建VA01 销售订单

BAPI_SALESORDER_CREATEFROMDAT2 BAPI创建VA01 销售订单

原创 Linux操作系统 作者:SAP骑士 时间:2011-06-15 14:18:48 2 删除 编辑
用bapi创建销售订单 VA01 用的bapi如下
关于定价,可能要多做调试,只能传入COND_VALUE定价比率,而定价值是不可以直接修改的,


DATA: header_in            TYPE bapisdhd1,
        header_inx           TYPE bapisdhd1x,
        l_vbeln              LIKE vbak-vbeln,
        l_message            TYPE string,
        lt_return            TYPE TABLE OF bapiret2   WITH HEADER LINE,
        items_in             TYPE TABLE OF bapisditm  WITH HEADER LINE,
        items_inx            TYPE TABLE OF bapisditmx WITH HEADER LINE,
        partners             TYPE TABLE OF bapiparnr  WITH HEADER LINE,
        schedules_in         TYPE TABLE OF bapischdl  WITH HEADER LINE,
        order_conditions_in  TYPE bapicond   OCCURS WITH HEADER LINE,
        order_conditions_inx TYPE bapicondx  OCCURS WITH HEADER LINE,
        logic_switch         TYPE bapisdls   OCCURS WITH HEADER LINE,
        extensionin           TYPE  bapiparex  OCCURS WITH HEADER LINE.

  CLEAR: header_in,
         header_inx,
         order_conditions_in,
         order_conditions_inx,
         l_vbeln,
         items_in[],items_in,
         items_inx[],items_inx,
         partners[],partners,
         schedules_in[],schedules_in,
         g_exit.

* header
  header_in-doc_type    = lt_reslut-auart.
  header_in-sales_org   = lt_reslut-vkorg .
  header_in-distr_chan  = lt_reslut-vtweg.
  header_in-division    = lt_reslut-spart.
  header_in-sales_grp   = lt_reslut-vkgrp.
  header_in-sales_off   = lt_reslut-vkbur.
  header_in-sd_doc_cat  = 'C'.
  header_in-doc_date    = sy-datum.
  header_in-purch_date  = lt_reslut-audat.
  header_in-price_date  = sy-datum.
  header_in-dlvschduse  = l_abrvw.         "审批状态
  header_in-ship_type   = lt_reslut-vsart.  "装运类型
  header_in-s_proc_ind  = lt_reslut-sdabw.  "特殊标识
  header_in-pymt_meth   = lt_reslut-zlsch.  "付款方式

* item
  LOOP AT it_tab100.

    items_in-itm_number = it_tab100-posnr.
    items_in-material   = it_tab100-matnr.
    items_in-plant      = it_tab100-werks.
    items_in-store_loc  = it_tab100-lgort.
    APPEND items_in.
    CLEAR items_in.

    items_inx-itm_number  = it_tab100-posnr.
    items_inx-material    = 'X'.
    items_inx-plant       = 'X'.
    items_inx-store_loc   = 'X'.
    APPEND items_inx.
    CLEAR items_inx.

    schedules_in-itm_number   = it_tab100-posnr.
    schedules_in-req_qty      = it_tab100-kwmeng.
    APPEND schedules_in.
    CLEAR schedules_in.

    order_conditions_in-itm_number = it_tab100-posnr.  "itm_number
    order_conditions_in-cond_type  = 'Z11'.            "定价条件
    order_conditions_in-cond_value = it_tab100-kbetr.
    order_conditions_in-currency   = it_tab100-waerk.    "
    order_conditions_in-cond_unit  = it_tab100-vrkme.  "条件单位

    APPEND order_conditions_in.

    CLEAR order_conditions_inx.
    order_conditions_inx-itm_number = it_tab100-posnr.
    order_conditions_inx-cond_type  = 'Z11'.
    order_conditions_inx-cond_value = 'X'.
    order_conditions_inx-currency   = 'X'.
    order_conditions_inx-cond_unit  = 'X'.
    order_conditions_inx-cond_p_unt = 'X'.
    APPEND order_conditions_inx.

  ENDLOOP.

* partener
  partners-partn_role = 'WE'.
  partners-partn_numb = lt_reslut-kunnr.
  APPEND partners.
  CLEAR partners.

  partners-partn_role = 'RE'.
  partners-partn_numb = lt_reslut-kunnr.
  APPEND partners.
  CLEAR partners.

  logic_switch-pricing = ''.
  APPEND logic_switch.

  CALL FUNCTION 'BAPI_SALESORDER_CREATEFROMDAT2'
    EXPORTING
*      SALESDOCUMENTIN           =
      order_header_in           = header_in
      order_header_inx          = header_inx
*      SENDER                    =
*      BINARY_RELATIONSHIPTYPE   =
*      INT_NUMBER_ASSIGNMENT     =
*      BEHAVE_WHEN_ERROR         =
      logic_switch              = logic_switch
    IMPORTING
      salesdocument             = l_vbeln
    TABLES
      return                    = lt_return
      order_items_in            = items_in
      order_items_inx           = items_inx
      order_partners            = partners
      order_schedules_in        = schedules_in
      order_conditions_in       = order_conditions_in
      order_conditions_inx      = order_conditions_inx
      extensionin               = extensionin.

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/17204926/viewspace-698007/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2009-01-01

  • 博文量
    59
  • 访问量
    313103