ABAP-銷售訂單BAPI

創(chuàng)建

  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.
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

友情鏈接更多精彩內容