ZMMR104-预留单批量删除及恢复

***********************************************************************
* Title : ZMMR104 *
* Application : MM   *
* Subject : 预留单删除及恢复 *
* Requested by : MC *
* Execution : any time *
* Ref no: : B219 *
* Author : rainy *
* Req Date : 20150630 *
***********************************************************************
* Production Order Variance Report *
***********************************************************************
***********************************************************************
*1.取数:
*2.输出: *
***********************************************************************
* MODIFICATIONS (latest entry at the top) *
* ------------------------------------------------------------------- *
* REL DATE NAME (COMPANY) DESCRIPTION TASK-NO *
* --- ---- ---- --------- ----------- ------- *
* *
***********************************************************************
REPORT zmmr104 MESSAGE-ID zmm_001.

TABLES:zmmt001,
sscrfields.

DATA:BEGIN OF it_text,
rsnum LIKE resb-rsnum,
rspos LIKE resb-rspos,
xloek LIKE resb-xloek,"删除标记
erfme LIKE resb-erfme,"单位

END OF it_text.

DATA:gt_text LIKE TABLE OF it_text WITH HEADER LINE,
wa_text LIKE gt_text.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE t1.

PARAMETERS: so_file(300).

SELECTION-SCREEN END OF BLOCK b1.

SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE t2."no display.
PARAMETERS:rb_01 NO-DISPLAY DEFAULT ‘X‘,
rb_02 NO-DISPLAY.
SELECTION-SCREEN END OF BLOCK b2.
SELECTION-SCREEN FUNCTION KEY 1.

*----------------------------------------------------------------------
* INITIALIZATION
*----------------------------------------------------------------------
INITIALIZATION.
t1 = ‘导入数据‘.
sscrfields-functxt_01 = ‘下载导入模板‘.

*----------------------------------------------------------------------
* AT SELECTION-SCREEN.
*----------------------------------------------------------------------
AT SELECTION-SCREEN.
*&下载模板
PERFORM frm_download_template.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR so_file.
PERFORM getdata USING so_file.

*----------------------------------------------------------------------
* START-OF-SELECTION.
*----------------------------------------------------------------------
START-OF-SELECTION.

*&S1.upload data.
PERFORM frm_upload.
* CHECK gt_text[] IS NOT INITIAL.
*&write text
IF rb_01 EQ ‘X‘.
PERFORM frm_exeupdate.
ELSE.
PERFORM frm_clear_flag.
ENDIF.

*&---------------------------------------------------------------------*
*& Form getdata
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->SO_FILE text
*----------------------------------------------------------------------*
FORM getdata USING so_file.
* Data for open dialog
DATA: l_filetab TYPE filetable,
l_rc TYPE i.
CLEAR l_filetab.
REFRESH l_filetab.

* Open dialog
CALL METHOD cl_gui_frontend_services=>file_open_dialog
EXPORTING
* WINDOW_TITLE = ‘SAP Custom - Open File‘
* DEFAULT_EXTENSION =
default_filename = ‘*.xls‘
* FILE_FILTER = ‘*.xls‘
initial_directory = ‘d:\‘
multiselection = ‘‘
CHANGING
file_table = l_filetab
rc = l_rc
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4.
* Get file path
CHECK l_rc EQ 1.
READ TABLE l_filetab INDEX 1 INTO so_file.

ENDFORM. "getdata
*&---------------------------------------------------------------------*
*& Form FRM_UPLOAD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_upload .
DATA:BEGIN OF i_excel OCCURS 0.
INCLUDE STRUCTURE alsmex_tabline.
DATA:END OF i_excel.
DATA:l_answer(1) TYPE c,
l_culumn TYPE i,
l_pathname LIKE rlgrap-filename.
FIELD-SYMBOLS:<fs>.
DATA:it_raw TYPE truxs_t_text_data.

*&文件名赋值l_pathname.
MOVE so_file TO l_pathname.

CALL FUNCTION ‘TEXT_CONVERT_XLS_TO_SAP‘
EXPORTING
* I_FIELD_SEPERATOR =
i_line_header = ‘X‘
i_tab_raw_data = it_raw
i_filename = l_pathname
TABLES
i_tab_converted_data = gt_text
* EXCEPTIONS
* CONVERSION_FAILED = 1
* OTHERS = 2
.
* CALL FUNCTION ‘TEXT_CONVERT_XLS_TO_SAP‘
* EXPORTING
** I_FIELD_SEPERATOR =
** I_LINE_HEADER =
* i_tab_raw_data =
* i_filename =
* TABLES
* i_tab_converted_data =
** EXCEPTIONS
** CONVERSION_FAILED = 1
** OTHERS = 2
* .

IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
IF gt_text[] IS INITIAL.
CALL FUNCTION ‘POPUP_TO_CONFIRM_WITH_MESSAGE‘
EXPORTING
* DEFAULTOPTION = ‘Y‘
diagnosetext1 = ‘No data in excel‘
* DIAGNOSETEXT2 = ‘ ‘
* DIAGNOSETEXT3 = ‘ ‘
textline1 = ‘No data in excel‘
* TEXTLINE2 = ‘ ‘
titel = ‘Confirm‘
* START_COLUMN = 25
* START_ROW = 6
* CANCEL_DISPLAY = ‘X‘
IMPORTING
answer = l_answer.
*&OUT
EXIT.
ENDIF.
ENDIF.

*&删除标题行
* DELETE gt_text FROM 1 TO 1.

ENDFORM. " FRM_UPLOAD
*&---------------------------------------------------------------------*
*& Form FRM_DOWNLOAD_TEMPLATE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_download_template .
DATA: ls_key TYPE wwwdatatab,
lv_temp TYPE c,
lv_file TYPE string VALUE ‘\ZM104.xlsx‘,
lv_filepath TYPE rlgrap-filename,
lv_result TYPE abap_bool,
lv_path TYPE string,
lv_msg TYPE string.
DATA:l_rc TYPE sy-subrc.

CASE sscrfields-ucomm.
WHEN ‘FC01‘.

CALL METHOD cl_gui_frontend_services=>directory_browse
EXPORTING
window_title = ‘选择文件目录‘
* initial_folder = ‘C:\TEMP‘
CHANGING
selected_folder = lv_path
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
CONCATENATE lv_path lv_file INTO lv_file.

CALL METHOD cl_gui_frontend_services=>file_exist
EXPORTING
file = lv_file
RECEIVING
result = lv_result
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
wrong_parameter = 3
not_supported_by_gui = 4
OTHERS = 5.
IF lv_result = ‘X‘.
CONCATENATE ‘模板‘ lv_file ‘已存在!‘ INTO lv_msg.
MESSAGE lv_msg TYPE ‘S‘.
STOP.
ELSE.
ls_key-relid = ‘MI‘.
ls_key-objid = ‘ZM104‘. "SMW0定义的对象名称
lv_filepath = lv_file.
CALL FUNCTION ‘DOWNLOAD_WEB_OBJECT‘
EXPORTING
key = ls_key
destination = lv_filepath
IMPORTING
rc = l_rc.
IF l_rc <> 0.
MESSAGE ‘下载模板失败!‘ TYPE ‘E‘.
ELSE.
MESSAGE s000 WITH ‘成功下载模板至目录:‘ lv_filepath.
ENDIF.
ENDIF.
ENDIF.

ENDCASE.
ENDFORM. " FRM_DOWNLOAD_TEMPLATE
*&---------------------------------------------------------------------*
*& Form FRM_EXEUPDATE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_exeupdate .
FIELD-SYMBOLS:<fs_text> LIKE LINE OF gt_text.
DATA: lv_upd(1).
DATA:lv_date LIKE sy-datum,
lv_day(2) TYPE n,
lv_month(2) TYPE n,
lv_year(4) TYPE n,
lv_calc_date TYPE d.
DATA:l_line TYPE string.

SORT gt_text BY rsnum rspos.

**&S1.处理数据
* LOOP AT gt_text ASSIGNING <fs_text>.
*
* CLEAR:lv_day,
* lv_month,
* lv_year.
* MOVE-CORRESPONDING <fs_text> TO gt_zmmt001.
* IF <fs_text>-zdate1 CS ‘.‘.
**&zdate1 中. 去除
* REPLACE ‘.‘ WITH ‘‘ INTO <fs_text>-zdate1.
* REPLACE ‘.‘ WITH ‘‘ INTO <fs_text>-zdate1.
* CONDENSE <fs_text>-zdate1 NO-GAPS.
* lv_day = <fs_text>-zdate1(2).
* lv_month = <fs_text>-zdate1+2(2).
* lv_year = <fs_text>-zdate1+4(4).
**&换成系统标准 年月日.
* CONCATENATE lv_year lv_month lv_day INTO gt_zmmt001-zdate1.
* ENDIF.
* IF <fs_text>-zdate2 CS ‘.‘.
**&zdate1 中. 去除
* REPLACE ‘.‘ WITH ‘‘ INTO <fs_text>-zdate2.
* REPLACE ‘.‘ WITH ‘‘ INTO <fs_text>-zdate2.
* CONDENSE <fs_text>-zdate2 NO-GAPS.
* lv_day = <fs_text>-zdate2(2).
* lv_month = <fs_text>-zdate2+2(2).
* lv_year = <fs_text>-zdate2+4(4).
* CONCATENATE lv_year lv_month lv_day INTO gt_zmmt001-zdate2.
* ENDIF.
* gt_zmmt001-mandt = sy-mandt.
* APPEND gt_zmmt001.
* CLEAR gt_zmmt001.
* ENDLOOP.
**&S2.创建人信息
* gt_zmmt001-usnam = sy-uname.
* gt_zmmt001-datum = sy-datum.
* gt_zmmt001-time = sy-uzeit.
* gt_zmmt001-mandt = sy-mandt.
* MODIFY gt_zmmt001 TRANSPORTING usnam datum time mandt WHERE ebeln IS NOT INITIAL.

l_line = lines( gt_text[] ).
CLEAR lv_upd.
*&S3.更新数据表
LOOP AT gt_text.

TRY .
*&F1.update 预留单号,
* 更新预留单号,删除标记/条目单位
IF gt_text-erfme IS NOT INITIAL.
UPDATE resb SET xloek = gt_text-xloek
erfme = gt_text-erfme
WHERE rsnum = gt_text-rsnum
AND rspos = gt_text-rspos.
ELSE.
UPDATE resb SET xloek = gt_text-xloek
*erfme = gt_text-erfme
WHERE rsnum = gt_text-rsnum
AND rspos = gt_text-rspos.
ENDIF.

CATCH cx_sy_open_sql_db.
lv_upd = ‘F‘.
ENDTRY.

ENDLOOP.

IF lv_upd EQ ‘ ‘.
COMMIT WORK.
MESSAGE s000 WITH ‘成功修改‘ l_line ‘条数据!‘.
ELSE.
ROLLBACK WORK.
MESSAGE e006.
ENDIF.

ENDFORM. " FRM_EXEUPDATE
*&---------------------------------------------------------------------*
*& Form FRM_CLEAR_FLAG
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM frm_clear_flag .
DATA:lv_upd TYPE c,
l_line TYPE string.

l_line = lines( gt_text[] ).
CLEAR lv_upd.

LOOP AT gt_text.

TRY .
*&update 预留单号,恢复删除标记
IF gt_text-erfme IS NOT INITIAL.
UPDATE resb SET xloek = gt_text-xloek
erfme = gt_text-erfme
WHERE rsnum = gt_text-rsnum
AND rspos = gt_text-rspos.
ELSE.
UPDATE resb SET xloek = gt_text-xloek
*erfme = gt_text-erfme
WHERE rsnum = gt_text-rsnum
AND rspos = gt_text-rspos.
ENDIF.

CATCH cx_sy_open_sql_db.
lv_upd = ‘F‘.
ENDTRY.

ENDLOOP.

IF lv_upd EQ ‘ ‘.
COMMIT WORK.
MESSAGE s000 WITH ‘成功修改‘ l_line ‘条数据!‘.
ELSE.
ROLLBACK WORK.
MESSAGE e006.
ENDIF.

ENDFORM. " FRM_CLEAR_FLAG

时间: 2024-08-13 20:23:46

ZMMR104-预留单批量删除及恢复的相关文章

批量删除跟单删

/// <summary> /// 删除 /// </summary> /// <param name="id"></param> /// <returns></returns> public int DeleteId(int id) { int i = bll.Delete(id); if (i > 0) { Response.Write("<script>alert('删除成功!')

vue的表单编辑删除,保存取消功能

过年回来第一篇博客,可能说的不是很清楚,而且心情可能也不是特别的high,虽然今天是元宵,我还在办公室11.30在加班,但就是想把写过的代码记下来,怕以后可能真的忘了.(心将塞未塞,欲塞未满) VUE+ElementUI 的表单编辑,删除,保存,取消功能 VUE的表单 <el-form :label-position="labelPosition" label-width="120px" :model="form" ref="fo

5月21 汽车查询及批量删除----php方法

---恢复内容开始--- 这个与之前不同是在php中实现了页面的查询,引用AJAX实现批量删除及弹窗的显示 作业要求: 页面显示数据代码: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.or

Web前端—表单—批量处理

调试一个网站后台,添加一个批量删除按钮,删除按钮是,用onclick="javascript:this.form.action='URL';" 下方工具条是用JS谢了一个postdo方法,通过传至不同,而进行不同的操作. 测试代码: select.html —>中的表单 <form method="post" action="select.php"> <button id="deleteButton"

删除JS前台校验,后台批量删除

1.功能需求 在一个数据表格中,选中欲删除的记录,点击删除按钮,先触发前台验证,然后调用后台处理逻辑 2.代码实现 HTML代码: <asp:Repeater ID="repInputList" runat="server" DataSourceID="InputsDataSource" EnableViewState="true" > <HeaderTemplate> <table cellpa

PHP数据访问批量删除(10261101)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-

bos 第3天(easyui弹窗边界问题、取派员的添加、修改和批量删除)

BOS项目笔记 第3天 今天内容安排: 1.解决window窗口bug 2.bos项目整体需求分析(基础设置.取派.中转.路由.报表) 3.取派员添加功能 4.jQuery easyUI控件datagrid使用方式 5.基于datagrid实现取派员分页查询 6.取派员批量删除和修改 1. 修复window控件bug 将上面的js文件引入jsp页面中 2. 基础设置部分需求分析 整个基础设置部分对应需求文档2.6章节. 2.1 基础档案设置 在其他的系统中通常称为"数据字典".提供基础

删除功能的实现(单个删除与批量删除)

2.1学生信息删除的实现 因为实体类已经编写好,所以不需要再编写实体类 a.在现有的student_list.html页面创建一个删除按钮,并在Javascript中编写删除方法 该删除是根据ID一个个删除,并非批量删除,因此点击删除按钮的时候会得到该行ID并传给该方法 b.编写子控制器getwaybeans.xml 新加一个关于删除的action c.编写对应的bean类方法 在现有的studentbean类中新建一个删除方法,该方法名为getwaybeans.xml文件中name属性 值得注

夺命雷公狗ThinkPHP项目之----企业网站16之文章批量删除的完成

我们在做一个网站时候经常会遇到批量删除这个选项,其实也很简单,我们之需要用用jq实现出来效果然后通过表单post过去后端即可实现: 我们做这个功能前必须要先引入jq,我的jq版本是1.8.3,方法如下所示: <script> //在 jq 1.8.3测试成功 $("#selall").click(function(){ if($(this).attr("checked")){ $('.selall').attr("checked",&