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
ZMMR104-预留单批量删除及恢复的更多相关文章
- Vue-表单验证-全选-反选-删除-批量删除
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- 自定义表单SQL命令行批量删除垃圾留言
1.每天被恶意留言困扰,花费大量的时间去清理却效果不理想,对于没有能力做二次开发并且靠纯手工删除留言的菜鸟来讲是一个大麻烦. 2.大家都知道织梦的留言内容是存在数据库里的,而数据库的内容是可以批量删除 ...
- jq全选、全不选、反选、单删、批量删除
<!DOCTYPE html><html> <head> <meta charset="utf-8" /> <title> ...
- vue的表单编辑删除,保存取消功能
过年回来第一篇博客,可能说的不是很清楚,而且心情可能也不是特别的high,虽然今天是元宵,我还在办公室11.30在加班,但就是想把写过的代码记下来,怕以后可能真的忘了.(心将塞未塞,欲塞未满) VUE ...
- php批量删除
php批量删除可以实现多条或者全部数据一起删除 新建php文件 显示数据库中内容: <table width="100%" border="1" cell ...
- php链接数据库 批量删除 和 注册审核
理解 : hiden value session name="a[]" 1. form 表单上传的 value=" "值 ...
- jdbc-批量插入、批量删除、批量更新
一.JDBC的批量插入 JDBC批量插入主要用于数据导入和日志记录因为日志一般都是先写在文件下的等. 我用Mysql5.1.5的JDBC driver 分别对三种比较常用的方法做了测试 方法 ...
- php数据访问(批量删除)
批量删除: 首先给每一行加上复选框,也就是在自增长列内加入checkbox.因为这里可以多选,也可以单选,所以在传值的时候需要传一个数组来进行处理,所以复选框name的值设定一个数组.传值都是传的va ...
- 【git】删除某个文件的所有历史记录,批量删除远程分支
删除git某个文件的所有历史记录 git的目的就是版本控制,记录每一个版本的变动.然而有的时候我们往往希望从版本库中彻底删除某个文件,不再显示在历史记录中.例如不小心上传了一堆错误的文件,或者不小心上 ...
随机推荐
- 基于SOCK4网络协议的代理服务器端代码示例
//********************************************************************** #include <stdio.h> #i ...
- php pthreads 多线程扩展的使用:一个较为稳定例子。
今天研究了worker stackable的配合方法,写了两种形式,虽然能工作,但是都会出现内存不听增长的问题: 于是把第一个方法的代码邮件给了作者,到现在他没有回复我. 我最后放弃两者配合的方式,直 ...
- ubuntu下 GCC编译程序出现 undefined reference to `std::ios_base::Init::Init()'问题
网上的解释是:“ you need to add -lstdc++, or use 'g++' rather than 'gcc' as your driver program.”,也就是说如果想要使 ...
- IBatis.net动态SQL语句(六)
在学习动态SQL语句之前,首先必须对条件查询有一定了解,先来学习如何向IBatis.Net的映射文件里传入参数. 一.条件查询 1.传递单个参数 如根据Id查询: <select id=&quo ...
- HTML5中canvas的save和restore方法
canvas的save和restore方法: save() 方法把当前绘画状态的一份拷贝压入到一个保存图像状态的栈中.这里的绘画状态指坐标原点.变形时的变化矩阵(该矩阵是调用 rotate().sca ...
- outlook新邮件到达提醒设置以及outlook最小化到托盘设置
有些邮件是需要马上处理的,因此希望能在收到邮件之后马上就知道,但是有不希望频繁的去检查有没有.outlook可以帮我们轻松做到新邮件到达提醒. 一 .设置outlook新邮件到达提醒:选项->电 ...
- 操作无效:已关闭 Lob。 ERRORCODE=-4470, SQLSTATE=null
解决方式: 1.jdbc URL链接为:jdbc.url=jdbc:db2://(ip):50000/(数据库名称):driverType=4;fullyMaterializeLobData=true ...
- JVM-class文件完全解析-魔数
魔数(Magic Number) 魔数和Class文件的版本. 一个文件能否被Java虚拟机接受,不是通过文件的扩展名来进行识别的,而是通过魔数来进行识别.这主要是基于安全方面的考虑,因为文件的扩展名 ...
- Android开发-开发前的配置
一.JDK (不用安装) JDK是 java 语言的软件开发工具,主要用于移动设备.嵌入式设备上的java应用程序. JDK是整个java开发的核心,它包含了JAVA的运行环境,JAVA工具和JA ...
- 2013年7月份第3周51Aspx源码发布详情
批量重命名文件工具源码 2013-7-19 [VS2010]功能介绍:这是一个新型的文件重命名,主要用了TreeView(树形视图)来选择文件夹,批量进行文件重命名.其中,有"编号在前,编 ...