销售订单创建(BAPI_SALESORDER_CREATEFROMDAT2)

 DATA: ls_header_in      TYPE bapisdhd1,
        ls_header_inx     TYPE bapisdhd1x,
        ls_item_in        TYPE bapisditm,
        lt_item_in        TYPE TABLE OF bapisditm,
        ls_item_inx       TYPE bapisditmx,
        lt_item_inx       TYPE TABLE OF bapisditmx,
        ls_partners       TYPE bapiparnr,
        lt_partners       TYPE TABLE OF bapiparnr,
        ls_schedules_in   TYPE bapischdl,
        lt_schedules_in   TYPE TABLE OF bapischdl,
        ls_schedules_inx  TYPE bapischdlx,
        lt_schedules_inx  TYPE TABLE OF bapischdlx,
        ls_conditions_in  TYPE bapicond,
        lt_conditions_in  TYPE TABLE OF bapicond,
        ls_conditions_inx TYPE bapicondx,
        lt_conditions_inx TYPE TABLE OF bapicondx,
        ls_return         TYPE bapiret2,
        lt_return         TYPE TABLE OF bapiret2.
  DATA: ls_extensionin TYPE bapiparex,
        lt_extensionin TYPE TABLE OF bapiparex.
  DATA: ls_bape_vbap  TYPE bape_vbap,
        lt_bape_vbap  TYPE TABLE OF bape_vbap,
        ls_bape_vbapx TYPE bape_vbapx,
        lt_bape_vbapx TYPE TABLE OF bape_vbapx.

  DATA: l_item TYPE bapisditm-itm_number.
  DATA: l_swith TYPE bapisdls.
  DATA:lv_vbeln TYPE vbeln.

  CLEAR:            ls_header_in,ls_header_inx,lt_item_in,lt_item_inx,lt_partners,lt_schedules_in,lt_schedules_inx,
  lt_conditions_in,lt_conditions_inx,lt_return.
  LOOP AT gt_tab  INTO gs_tab  WHERE checkbox = 'X' AND zjsjs IS INITIAL .

    ls_header_in-doc_type = 'ZKE2'."销售凭证类型
    ls_header_in-sales_org = gs_tab-vkorg."销售组织
    ls_header_in-distr_chan = gs_tab-vtweg."销售渠道
    ls_header_in-division = gs_tab-spart."产品组
    ls_header_in-sales_off  = gs_tab-vkbur."销售部门

    ls_header_in-doc_date = p_audat."凭证日期
    ls_header_in-req_date_h  = p_audat."要求的交货日期
    ls_header_in-ord_reason = gs_tab-augru."订单原因

    ls_header_inx-doc_type = 'X'."销售凭证类型
    ls_header_inx-sales_org  = 'X'."销售组织
    ls_header_inx-distr_chan = 'X'."销售渠道
    ls_header_inx-division   = 'X'."产品组
    ls_header_inx-sales_off  = 'X'."销售部门
    ls_header_inx-doc_date   = 'X'."凭证日期
    ls_header_inx-req_date_h  = 'X'."要求的交货日期
    ls_header_inx-ord_reason  = 'X'."订单原因
    ls_header_inx-updateflag  = 'I'."

    "行项目
    l_item = l_item + 10.
    ls_item_in-itm_number = l_item.

    ls_item_in-material    = gs_tab-matnr.
    ls_item_in-target_qty = gs_tab-zmeng.
    ls_item_in-sales_unit = gs_tab-vrkme.
    ls_item_in-plant      = gs_tab-werks.
    ls_item_in-store_loc  = gs_tab-lgort.
    ls_item_in-ship_point  = '2103'.
    APPEND ls_item_in TO lt_item_in.
    CLEAR ls_item_in.

    ls_item_inx-itm_number = l_item.
    ls_item_inx-updateflag = 'I'.
    ls_item_inx-material = 'X'.
    ls_item_inx-target_qty = 'X'.
    ls_item_inx-sales_unit = 'X'.
    ls_item_inx-plant = 'X'.
    ls_item_inx-store_loc = 'X'.
    ls_item_inx-ship_point = 'X'.
    APPEND ls_item_inx TO lt_item_inx.
    CLEAR ls_item_inx.

    ls_schedules_in-itm_number = l_item.
    ls_schedules_in-sched_line = 1.
    ls_schedules_in-req_qty = gs_tab-zmeng.
    ls_schedules_in-req_date = sy-datum.
    APPEND ls_schedules_in TO lt_schedules_in.
    CLEAR ls_schedules_in.

    ls_schedules_inx-itm_number = l_item.
    ls_schedules_inx-sched_line = 1.
    ls_schedules_inx-updateflag = 'I'.
    ls_schedules_inx-req_qty = 'X'.
    ls_schedules_inx-req_date = 'X'.
    APPEND ls_schedules_inx TO lt_schedules_inx.
    CLEAR ls_schedule

你可能感兴趣的:(BAPI,linux,运维,服务器)