ABAP-销售订单BAPI

创建

  data:ls_head       type bapisdhd1,
       ls_headx      type bapisdh1x,
       lt_item       type table of bapisditm with header line,
       lt_itemx      type table of bapisditmx with header line,
       lt_schedules  type table of bapischdl with header line,
       lt_schedulesx type table of bapischdlx with header line,
       lt_parnr      type table of bapiparnr with header line,
       lt_conditions type table of bapicond with header line.
  data:lt_return type table of bapiret2 with header line,
       ls_return type bapiret2.
  data:fv_vbeln type bapivbeln-vbeln.

  clear:gt_return[],gt_return.

  ls_head-sales_org  = fs_data-vkorg.
  ls_head-distr_chan = fs_data-vtweg.
  ls_head-division   = fs_data-spart.
  ls_head-doc_type   = fs_data-auart.
  ls_head-pymt_meth  = fs_data-zlsch.
  ls_head-purch_no_c = fs_data-dmsorder.

  lt_item-itm_number = 10.
  lt_item-material   = fs_data-matnr.
  lt_item-target_qty = 1.
  lt_item-route      = 'Z00001'.
  append lt_item.
  clear lt_item.

  lt_itemx-itm_number = 10.
  lt_itemx-updateflag = 'I'.
  lt_itemx-material   = 'X'.
  lt_itemx-route      = 'X'.
  append lt_itemx.
  clear  lt_itemx.

  lt_schedules-itm_number = 10.
  lt_schedules-req_qty    = 1.
  append  lt_schedules.
  clear   lt_schedules.

  lt_schedulesx-itm_number = 10.
  lt_schedulesx-req_qty    = 1.
  append  lt_schedulesx.
  clear   lt_schedulesx.

  "定价条件
  perform frm_get_condition_data.

  loop at gt_cond where kschl is not initial.
    assign component gt_cond-field of structure fs_data to field-symbol(<fs_dmbtr>).
    if <fs_dmbtr> is not initial.
      lt_conditions-itm_number = 10.
      lt_conditions-cond_type = gt_cond-kschl.
      lt_conditions-cond_value = <fs_dmbtr>.
      lt_conditions-currency = 'CNY'.
      append lt_conditions.
      clear  lt_conditions.
      unassign <fs_dmbtr>.
    endif.
  endloop.

  lt_parnr-partn_role = 'AG'. "售达方
  lt_parnr-partn_numb =  fs_data-kunnr.
  append lt_parnr.
  clear  lt_parnr.
  lt_parnr-partn_role = 'WE'."送达方
  lt_parnr-partn_numb =  fs_data-kunn2.
  append lt_parnr.
  clear  lt_parnr.

  call function 'SD_SALESDOCUMENT_CREATE'
    exporting
      sales_header_in     = ls_head
    importing
      salesdocument_ex    = fv_vbeln
    tables
      return              = lt_return
      sales_items_in      = lt_item
      sales_items_inx     = lt_itemx
      sales_partners      = lt_parnr
      sales_schedules_in  = lt_schedules
      sales_schedules_inx = lt_schedulesx
      sales_conditions_in = lt_conditions.
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容