您的位置:首页 > 其它

用ME_CONFIRMATION_UPDATE处理采购订单行项目确认视图

2016-05-08 10:52 393 查看
用function module: ME_CONFIRMATION_UPDATE ,可以处理采购订单行项目确认视图,实现增删改操作。

 

      CALL FUNCTION 'ME_CONFIRMATION_UPDATE'

        EXPORTING

          I_EBELN =    " 采购订单号

        TABLES

          XEKES   =    "对应新增和修改

          YEKES   =    "对应删除

 

因为没有找到读取采购订单行项目确认视图的函数,所以自己写了一个:

 

    CALL FUNCTION 'ZPP142_GET_EKES'

      EXPORTING

        I_EBELN =    " 采购订单号     

        I_EBELP = '00010'   " 采购订单行项目

      TABLES

         T_ekes  =   "读取的确认视图表

 

 

ZPP142_GET_EKES 的代码:

 

  data t_ebelp type ebelp.

 CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

   EXPORTING

     INPUT         = i_ebelp

  IMPORTING

    OUTPUT        = t_ebelp

           .

  select * from ekes into table t_ekes

       where ebeln = i_ebeln

         and ebelp = i_ebelp.

 

 

对确认视图做增删改的代码例子如下:

 

REPORT  ZTEST0.

data: lt_xuekes type table of UEKES,

      ls_xuekes type UEKES.

data: lt_ekes type table of ekes,

      ls_ekes type ekes.

data op type c.

op = 'U'.    "修改
*op = 'D'.   "新增
*op = 'I'.   "删除

case op.

  when 'U'.

*读取确认

    CALL FUNCTION 'ZPP142_GET_EKES'

      EXPORTING

        I_EBELN = '4900177648'

        I_EBELP = '00010'

      TABLES

        T_ekes  = lt_ekes.

    .
*准备修改现有条目

    loop at lt_ekes into ls_ekes.

      MOVE-CORRESPONDING ls_ekes to ls_xuekes.

      ls_xuekes-eindt = '20180303'.

      ls_xuekes-kz = 'U'.

      append ls_xuekes to lt_xuekes.

      clear: ls_ekes.

    endloop.

    if lt_xuekes is not INITIAL.

      CALL FUNCTION 'ME_CONFIRMATION_UPDATE'

        EXPORTING

          I_EBELN       = '4900177648'

        TABLES

          XEKES         =  lt_xuekes
*    YEKES         =

                .

      if sy-subrc = 0.

        commit WORK AND WAIT.

        write 'update ok'.

      else.

        write 'update not ok'.

      endif.

    endif.

  when 'I'.
*准备添加新条目

    clear:ls_xuekes,lt_xuekes.

    ls_xuekes-ebeln = '4900177648'.

    ls_xuekes-ebelp = '00010'.

    sort lt_ekes DESCENDING by ebeln ebelp etens.

    read table lt_ekes into ls_ekes index 1.

    if sy-subrc = 0.

      ls_xuekes-etens = ls_ekes-etens + 1.

    else.

      ls_xuekes-etens = '0001'.

    endif.

    ls_xuekes-ebtyp = 'LA'.

    ls_xuekes-eindt = '20160707'.

    ls_xuekes-lpein = '1'.

    ls_xuekes-erdat = sy-datum.

    ls_xuekes-ezeit = sy-uzeit.

    ls_xuekes-menge = '22.222'.

    ls_xuekes-estkz = '1'.

    ls_xuekes-kzdis = 'X'.

    ls_xuekes-xblnr = 'A-LJC-SB'.

    ls_xuekes-kz = 'I'.

    append ls_xuekes to lt_xuekes.

    BREAK-POINT.

    if lt_xuekes is not INITIAL.

      CALL FUNCTION 'ME_CONFIRMATION_UPDATE'

        EXPORTING

          I_EBELN       = '4900177648'

        TABLES

          XEKES         =  lt_xuekes
*    YEKES         =

                .

      if sy-subrc = 0.

        commit WORK AND WAIT.

        write 'insert ok'.

      else.

        write 'insert not ok'.

      endif.

    endif.

  when 'D'.

    clear:ls_xuekes,lt_xuekes.

    data: lt_yuekes type table of UEKES,

          ls_yuekes type UEKES.
*读取确认

    CALL FUNCTION 'ZPP142_GET_EKES'

      EXPORTING

        I_EBELN = '4900177648'

        I_EBELP = '00010'

      TABLES

        T_ekes  = lt_ekes.

    .
*准备删除现有条目

    loop at lt_ekes into ls_ekes.

      MOVE-CORRESPONDING ls_ekes to ls_yuekes.

      ls_yuekes-kz = 'D'.

      append ls_yuekes to lt_yuekes.

      clear: ls_ekes.

    endloop.

    if lt_yuekes is not INITIAL.

      CALL FUNCTION 'ME_CONFIRMATION_UPDATE'

        EXPORTING

          I_EBELN = '4900177648'

        TABLES

          XEKES   = lt_xuekes

          YEKES   = lt_yuekes.

      if sy-subrc = 0.

        commit WORK AND WAIT.

        write 'Delete ok'.

      else.

        write 'Delete not ok'.

      endif.

    endif.
endcase.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息