您的位置:首页 > 运维架构

采购订单确认视图维护

2016-05-25 10:31 519 查看
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.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ME_CONFIRMATION_UPDA