ABAP-动态创建DATABASE/FUNCTION(风险)
警告:此程序仅供研究,请谨慎操作,切勿对系统标准数据表及功能函数进行测试(可能无法修复)。
程序:EWUCINS
REPORT EWUCINS MESSAGE-ID US NO STANDARD PAGE HEADING. * Administrieren Cluster und parallele Tasks PARAMETERS: TESTRUN DEFAULT 'X', "test B(reak), C(alled) P_FKT() DEFAULT 'SIZ'."SIZ,INS,DEL TABLES: TAORA, TAINF. DATA: H_RUNTI TYPE F. DATA: BEGIN OF T_DBAFREE OCCURS , NAME(), BYTES TYPE I, END OF T_DBAFREE, H_TABNAME LIKE DD02L-TABNAME VALUE 'EWUCLU'. DATA: BEGIN OF T_DBAONLINE OCCURS , NAME(), STATUS(), END OF T_DBAONLINE. DATA: RC LIKE SY-SUBRC. AT SELECTION-SCREEN OUTPUT. *f sy-subty = '04'. "dialog IF TESTRUN <> 'C'. "dialog P_FKT = 'SIZ'. ENDIF. START-OF-SELECTION. ******************************************************* * Write out Parameters ******************************************************* PERFORM WRITE_PARMS. GET RUN TIME FIELD H_RUNTI. ************************************************************************ * functions ************************************************************************ CASE P_FKT. * available freespace in db ------------------------------------------* WHEN 'SIZ'. IF SY-DBSYS = 'ORACLE' OR SY-DBSYS = 'INFORMIX'. PERFORM SEL_DBAFREE. ELSE. * installation --------------------------------------------------------* * when 'INS'. TAORA-TABART = 'APPL0'. PERFORM CREATE_TABLE. PERFORM CREATE_FUNCTION. ENDIF. * drop ewuclu --------------------------------------------------------* WHEN 'DEL'. PERFORM DELETE_TABLE. ENDCASE. GET RUN TIME FIELD H_RUNTI. * IF testrun = 'B'. BREAK-POINT. ENDIF. WRITE: / 'runtime:', H_RUNTI, / 'endtime:', SY-UZEIT. COMMIT WORK. IF TESTRUN = 'C'. LEAVE PROGRAM. ENDIF. "called STOP. *----------------------------------------------------------------------* AT LINE-SELECTION. T_DBAFREE-name = SY-LISEL(). WRITE: / T_DBAFREE-NAME, 'wurde ausgewählt'(). PERFORM FIND_TABLE_DETAIL. PERFORM CREATE_TABLE. PERFORM CREATE_FUNCTION. *----------------------------------------------------------------------* FORM APPEND_DBAFREE. IF SY-SUBRC = . APPEND T_DBAFREE. ENDIF. ENDFORM. FORM APPEND_DBAONLINE. IF SY-SUBRC = . APPEND T_DBAONLINE. ENDIF. ENDFORM. *----------------------------------------------------------------------* FORM SEL_DBAFREE. CASE SY-DBSYS. WHEN 'ORACLE'. EXEC SQL PERFORMING APPEND_DBAFREE. SELECT TABLESPACE_NAME, SUM(NVL(BYTES,))/ FROM DBA_FREE_SPACE GROUP BY TABLESPACE_NAME INTO :T_DBAFREE ENDEXEC. EXEC SQL PERFORMING APPEND_DBAONLINE. SELECT TABLESPACE_NAME, STATUS FROM DBA_TABLESPACES INTO :T_DBAONLINE ENDEXEC. LOOP AT T_DBAONLINE. IF T_DBAONLINE-STATUS = 'OFFLINE'. DELETE T_DBAFREE WHERE NAME = T_DBAONLINE-NAME. ENDIF. ENDLOOP. WHEN 'INFORMIX'. PERFORM LISTE_DBSPACES_CREATE. WHEN OTHERS. WRITE: / 'DB not implemented'. STOP. ENDCASE. SORT T_DBAFREE BY BYTES DESCENDING. IF TESTRUN <> 'C'. LOOP AT T_DBAFREE. IF SY-TABIX = . WRITE: / 'Tablespace', 'Freespace(KB)'. ENDIF. WRITE: / T_DBAFREE-NAME, T_DBAFREE-BYTES. ENDLOOP. * automatically find biggest freespace ELSE. LOOP AT T_DBAFREE. IF T_DBAFREE-NAME() <> 'PSAPROLL' AND T_DBAFREE-NAME() <> 'PSAPTEMP' AND T_DBAFREE-NAME() <> 'SYSTEM'. PERFORM FIND_TABLE_DETAIL. PERFORM CREATE_TABLE. PERFORM CREATE_FUNCTION. EXIT. ENDIF. ENDLOOP. ENDIF. ENDFORM. *----------------------------------------------------------------------* FORM FIND_TABLE_DETAIL. * tabellenart (appl0) bestimmt tablespace/dbspace CASE SY-DBSYS. WHEN 'ORACLE'. SELECT SINGLE * FROM TAORA WHERE TABSPACE = T_DBAFREE-NAME. WHEN 'INFORMIX'. TAINF-DBSPACES = T_DBAFREE-NAME. TRANSLATE TAINF-DBSPACES TO UPPER CASE. "#EC TRANSLANG SELECT SINGLE * FROM TAINF WHERE DBSPACES = TAINF-DBSPACES. TAORA-TABART = TAINF-TABART. ENDCASE. IF SY-SUBRC <> . * write: / 'tabart not found'. * exit. TAORA-TABART = 'APPL0'. IF SY-DBSYS = 'ORACLE'. DATA: PROG() OCCURS WITH HEADER LINE. TABLES: DD02L. PROG = 'report x. '. APPEND PROG. PROG = 'tables: dd02ora. '. APPEND PROG. IF SY-SAPRL >= '31I'. PROG = 'tables: ddstorage. '. APPEND PROG. ENDIF. PROG = 'form insert_dd02ora. '. APPEND PROG. CONCATENATE 'dd02ora-tabname = ''' H_TABNAME '''.' INTO PROG. APPEND PROG. CONCATENATE 'delete from dd02ora where tabname = ''' H_TABNAME '''.' INTO PROG. APPEND PROG. PROG = 'dd02ora-source = ''USR''. '. APPEND PROG. PROG = 'dd02ora-useflag = ''X''. '. APPEND PROG. CONCATENATE 'dd02ora-tabspace = ''' T_DBAFREE-NAME '''.' INTO PROG. APPEND PROG. PROG = 'dd02ora-init = ''''. '. APPEND PROG. PROG = 'dd02ora-next = ''''. '. APPEND PROG. PROG = 'dd02ora-minext = ''''. '. APPEND PROG. PROG = 'dd02ora-maxext = ''''. '. APPEND PROG. PROG = 'dd02ora-pctinc = ''''. '. APPEND PROG. PROG = 'dd02ora-ofreelist = ''''. '. APPEND PROG. PROG = 'dd02ora-ofreegroup = ''''. '. APPEND PROG. PROG = 'dd02ora-opctfree = ''''. '. APPEND PROG. PROG = 'dd02ora-opctused = ''''. '. APPEND PROG. PROG = 'insert dd02ora. '. APPEND PROG. PROG = 'endform. '. APPEND PROG. DATA: H_GENPROG LIKE TRDIR-NAME. * break-point. GENERATE SUBROUTINE POOL PROG NAME H_GENPROG MESSAGE PROG. PERFORM INSERT_DD02ORA IN PROGRAM (H_GENPROG). ENDIF. ENDIF. ENDFORM. *----------------------------------------------------------------------* FORM CREATE_TABLE. DATA: I_DD02V_WA LIKE DD02V, I_DD09L_WA LIKE DD09L, I_DD03P_TAB LIKE DD03P OCCURS WITH HEADER LINE. * Header I_DD02V_WA-TABNAME = H_TABNAME. I_DD02V_WA-DDLANGUAGE = 'D'. I_DD02V_WA-DDTEXT = '_conv_ Cluster'. I_DD02V_WA-TABCLASS = 'TRANSP'. I_DD02V_WA-CONTFLAG = 'L'. * Technical Settings I_DD09L_WA-TABNAME = H_TABNAME. I_DD09L_WA-TABKAT = ''. I_DD09L_WA-TABART = TAORA-TABART. *_dd09l_wa-bufalow = 'N'. * Fields I_DD03P_TAB-TABNAME = H_TABNAME. I_DD03P_TAB-DDLANGUAGE = 'D'. I_DD03P_TAB-FIELDNAME = 'MANDT'. I_DD03P_TAB-POSITION = ''. I_DD03P_TAB-KEYFLAG = 'X'. I_DD03P_TAB-DATATYPE = 'CLNT'. I_DD03P_TAB-LENG = ''. APPEND I_DD03P_TAB. I_DD03P_TAB-FIELDNAME = 'RELID'. I_DD03P_TAB-POSITION = ''. I_DD03P_TAB-KEYFLAG = 'X'. I_DD03P_TAB-DATATYPE = 'CHAR'. I_DD03P_TAB-LENG = ''. APPEND I_DD03P_TAB. I_DD03P_TAB-FIELDNAME = 'UMSID'. I_DD03P_TAB-POSITION = ''. I_DD03P_TAB-KEYFLAG = 'X'. I_DD03P_TAB-DATATYPE = 'CHAR'. I_DD03P_TAB-LENG = ''. APPEND I_DD03P_TAB. I_DD03P_TAB-FIELDNAME = 'PAGENO'. I_DD03P_TAB-POSITION = ''. I_DD03P_TAB-KEYFLAG = 'X'. I_DD03P_TAB-DATATYPE = 'INT4'. I_DD03P_TAB-LENG = ''. APPEND I_DD03P_TAB. I_DD03P_TAB-FIELDNAME = 'CLUSTR'. I_DD03P_TAB-POSITION = ''. I_DD03P_TAB-KEYFLAG = ' '. I_DD03P_TAB-DATATYPE = 'INT2'. I_DD03P_TAB-LENG = ''. APPEND I_DD03P_TAB. I_DD03P_TAB-FIELDNAME = 'CLUSTD'. I_DD03P_TAB-POSITION = ''. I_DD03P_TAB-KEYFLAG = ' '. I_DD03P_TAB-DATATYPE = 'LRAW'. I_DD03P_TAB-LENG = ''. APPEND I_DD03P_TAB. CALL FUNCTION 'DDIF_TABL_PUT' EXPORTING NAME = H_TABNAME DD02V_WA = I_DD02V_WA DD09L_WA = I_DD09L_WA TABLES DD03P_TAB = I_DD03P_TAB * DD05M_TAB = * DD08V_TAB = EXCEPTIONS TABL_NOT_FOUND = NAME_INCONSISTENT = TABL_INCONSISTENT = PUT_FAILURE = PUT_REFUSED = OTHERS = . IF SY-SUBRC <> . MESSAGE e306(mq) WITH text-. "'Table create error'. ENDIF. CALL FUNCTION 'DDIF_TABL_ACTIVATE' EXPORTING NAME = H_TABNAME AUTH_CHK = 'X' * PRID = -1 IMPORTING RC = RC EXCEPTIONS NOT_FOUND = PUT_FAILURE = OTHERS = . IF SY-SUBRC <> OR RC = . MESSAGE E341(MQ). LEAVE PROGRAM. ENDIF. CALL FUNCTION 'TRINT_TADIR_INSERT' EXPORTING * AUTHOR = SY-UNAME * MASTERLANG = ' ' DEVCLASS = 'ECLU' * GENFLAG = ' ' OBJECT = 'TABL' OBJ_NAME = 'EWUCLU' PGMID = 'R3TR' SRCSYSTEM = 'SAP' * IMPORTING * ES_TADIR = EXCEPTIONS OBJECT_EXISTS_GLOBAL = OBJECT_EXISTS_LOCAL = OTHERS = . IF SY-SUBRC = . MESSAGE e306(mq) WITH text-. "'tadir insert error' ENDIF. * SUBMIT EWUCADM * WITH TESTRUN = 'X' * WITH P_FKT = 'DIR' * WITH P_MAXTSK = ' ' * WITH P_PROG = ' ' * WITH P_BATCH = ' ' * WITH P_RELID = ' ' * WITH P_CLUSIZ = ' '. ENDFORM. *----------------------------------------------------------------------* FORM DELETE_TABLE. CALL FUNCTION 'DB_DROP_TABLE' EXPORTING * DBSYS = SY-DBSYS * NO_EXEC = ' ' * PRID = 0 * PROGNAME = ' ' TABNAME = 'EWUCLU' * DB_CHECK_FLAG = ' ' * IMPORTING * GENPROG = * SUBRC = EXCEPTIONS PROGRAM_NOT_GENERATED = PROGRAM_NOT_WRITTEN = TABLE_NOT_DROPPED = OTHERS = . IF SY-SUBRC <> . MESSAGE e306(mq) WITH text-. ENDIF. CALL FUNCTION 'DD_TABL_DEL' EXPORTING TABNAME = 'EWUCLU' DEL_STATE = 'A' * PRID = 0 EXCEPTIONS OTHERS = . IF SY-SUBRC <> . MESSAGE e306(mq) WITH text-. ENDIF. CALL FUNCTION 'TRINT_TADIR_DELETE' EXPORTING OBJECT = 'TABL' OBJ_NAME = 'EWUCLU' PGMID = 'R3TR' EXCEPTIONS TADIR_ENTRY_NOT_EXISTING = OBJECT_EXISTS = OTHERS = . IF SY-SUBRC = . MESSAGE e306(mq) WITH text- . ENDIF. ENDFORM. *----------------------------------------------------------------------* FORM CREATE_FUNCTION. CALL FUNCTION 'FUNCTION_POOL_CREATE' EXPORTING POOL_NAME = 'ZCNV' * RESPONSIBLE = SY-UNAME SHORT_TEXT = '_conversion_' * NAMESPACE = ' ' EXCEPTIONS NAME_ALREADY_EXISTS = NAME_NOT_CORRECT = OTHERS = . IF SY-SUBRC <> AND SY-SUBRC <> . MESSAGE e306(mq) WITH text-. "Function pool error ENDIF. DATA: I_RSEXC LIKE RSEXC OCCURS WITH HEADER LINE. DATA: I_RSEXP LIKE RSEXP OCCURS WITH HEADER LINE. DATA: I_RSIMP LIKE RSIMP OCCURS WITH HEADER LINE. DATA: I_RSFSO LIKE RSFSO OCCURS WITH HEADER LINE. DATA: I_RSTBL LIKE RSTBL OCCURS WITH HEADER LINE. DATA: I_RSCHA LIKE RSCHA OCCURS WITH HEADER LINE. TABLES: RS38L. I_RSIMP-PARAMETER = 'TESTRUN'. I_RSIMP-DBFIELD = 'TRDIR-SQLX'. APPEND I_RSIMP. I_RSIMP-PARAMETER = 'PROGNAME'. I_RSIMP-DBFIELD = 'TRDIR-NAME'. APPEND I_RSIMP. I_RSIMP-PARAMETER = 'FUNKTION'. I_RSIMP-DBFIELD = 'TRDIR-TYPE'. APPEND I_RSIMP. I_RSIMP-PARAMETER = 'UMSID'. I_RSIMP-DBFIELD = 'EWUCLU-UMSID'. APPEND I_RSIMP. I_RSIMP-PARAMETER = 'UMSI2'. I_RSIMP-DBFIELD = 'EWUCLU-UMSID'. APPEND I_RSIMP. I_RSIMP-PARAMETER = 'TSKNO'. I_RSIMP-DBFIELD = 'EWUCLU-RELID'. APPEND I_RSIMP. I_RSIMP-PARAMETER = 'RELID'. I_RSIMP-DBFIELD = 'EWUCLU-RELID'. APPEND I_RSIMP. I_RSIMP-PARAMETER = 'CLUSIZ'. I_RSIMP-DBFIELD = 'TRDIR-NAME'. APPEND I_RSIMP. CALL FUNCTION 'FUNCTION_CREATE' EXPORTING * CORRNUM = ' ' FUNCNAME = 'Z_SUB_PROG' FUNCTION_POOL = 'ZCNV' * INTERFACE_GLOBAL = ' ' REMOTE_CALL = 'X' SHORT_TEXT = '_conversion_' * SUPPRESS_CORR_CHECK = 'X' * UPDATE_TASK = ' ' IMPORTING FUNCTION_INCLUDE = RS38L-INCLUDE TABLES EXCEPTION_LIST = I_RSEXC EXPORT_PARAMETER = I_RSEXP IMPORT_PARAMETER = I_RSIMP PARAMETER_DOCU = I_RSFSO TABLES_PARAMETER = I_RSTBL CHANGING_PARAMETER = I_RSCHA EXCEPTIONS DOUBLE_TASK = ERROR_MESSAGE = FUNCTION_ALREADY_EXISTS = INVALID_FUNCTION_POOL = INVALID_NAME = TOO_MANY_FUNCTIONS = OTHERS = . IF SY-SUBRC <> . IF SY-SUBRC <> . * write: / 'Irgendwas ist beim FUBA anlegen schiefgegangen', sy-subrc. MESSAGE e306(mq) WITH text-. ENDIF. EXIT. ENDIF. DATA: BEGIN OF PROG OCCURS , LINE(), END OF PROG. * break-point. READ REPORT RS38L-INCLUDE INTO PROG. LOOP AT PROG. IF PROG-LINE = ' '. PROG-LINE = 'submit (progname)'. INSERT PROG INTO PROG. PROG-LINE = 'with testrun = testrun '. INSERT PROG INTO PROG. PROG-LINE = 'with p_fkt = funktion'. INSERT PROG INTO PROG. PROG-LINE = 'with p_umsid = umsid '. INSERT PROG INTO PROG. PROG-LINE = 'with p_umsi2 = umsi2 '. INSERT PROG INTO PROG. PROG-LINE = 'with p_tskno = tskno '. INSERT PROG INTO PROG. PROG-LINE = 'with p_relid = relid '. INSERT PROG INTO PROG. PROG-LINE = 'with p_clusiz = clusiz '. INSERT PROG INTO PROG. PROG-LINE = 'to sap-spool '. INSERT PROG INTO PROG. PROG-LINE = 'without spool dynpro '. INSERT PROG INTO PROG. PROG-LINE = 'and return. '. INSERT PROG INTO PROG. EXIT. ENDIF. ENDLOOP. INSERT REPORT RS38L-INCLUDE FROM PROG. ENDFORM. *----------------------------------------------------------------------* FORM LISTE_DBSPACES_CREATE. DATA: BUFSIZE TYPE I. PERFORM GET_DB_PARAMETER(RSINF000) USING 'BUFFSIZE' BUFSIZE. BUFSIZE = BUFSIZE / . * exec sql performing makedbspaces. * c.dbsnum, * sum(c.chksize) * :bufsize , * into :dbspaces_chunks EXEC SQL PERFORMING APPEND_DBAFREE. SELECT D.NAME, SUM(C.NFREE) * :BUFSIZE FROM SYSMASTER:SYSDBSPACES D, SYSMASTER:SYSCHUNKS C WHERE C.DBSNUM = D.DBSNUM GROUP BY C.DBSNUM, D.NAME INTO :T_DBAFREE ENDEXEC. ENDFORM. *---------------------------------------------------------------------* FORM WRITE_PARMS. WRITE: / 'testrun:', TESTRUN, / 'funktion:', P_FKT(), / 'time:', SY-UZEIT, / '--------------------------------------------------'. ENDFORM.
ABAP-动态创建DATABASE/FUNCTION(风险)的更多相关文章
- bootstrap-multiselect 的简单使用,样式修改,动态创建option
1.bootstrap-multiselect 顾名思义基于bootstrap,bootstrap基于jquery,所以第一步,引入文件 bootstrap.css/ juery.js /bootst ...
- js动态创建和删除option
1.动态创建select function createSelect(){ var mySelect = document.createElement("select&q ...
- 动态创建selectjs 操作select和option
1.动态创建select function createSelect(){ var mySelect = document.createElement("select"); myS ...
- [SAP ABAP开发技术总结]反射,动态创建内表、结构、变量
声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...
- ASP.NET实现二维码 ASP.Net上传文件 SQL基础语法 C# 动态创建数据库三(MySQL) Net Core 实现谷歌翻译ApI 免费版 C#发布和调试WebService ajax调用WebService实现数据库操作 C# 实体类转json数据过滤掉字段为null的字段
ASP.NET实现二维码 using System;using System.Collections.Generic;using System.Drawing;using System.Linq;us ...
- js动态创建style节点(js文件中添加css)
ie6 不能 document.createElement('style') 然后append到head标签里.所以就找到这样个好文章 --------------------- 有很多提供动态创建 ...
- Unity进阶技巧 - 动态创建UGUI
前言 项目中有功能需要在代码中动态创建UGUI对象,但是在网上搜索了很久都没有找到类似的教程,最后终于在官方文档中找到了方法,趁着记忆犹新,写下动态创建UGUI的方法,供需要的朋友参考 你将学到什么? ...
- jQuery 绑定事件到动态创建的元素上
在进入主题之前,我们先来看一个前台页面经常用到的功能:点击页面输入框时自动选择其中文本. 很容易想到利用输入框的focus事件,当输入框获得焦点时,再调用jQuery的select()方法. Okay ...
- javascript学习笔记(四):事件处理函数和动态创建html标记。
1 HTML的事件属性 全局事件属性:HTML 4 增加了使事件在浏览器中触发动作的能力,比如当用户点击元素时启动 JavaScript. a. Window 事件属性,针对 window 对象触发 ...
随机推荐
- android 学习过程中登陆失效的个人理解
今天在学习的过程中,要做登陆失效的功能,所以就找了些资料.好好看了一下.研究了一番,慢慢的做出来了! 比方:你在一个手机端登陆了账号,在另外的一个手机端也登陆了账号,此时.前一个手机端的账号会提示登陆 ...
- Windows 上 Nginx 路径的陷阱
第一次用 Nginx 配置 Vhosts. 使用了 Windows 路径 C:\ww\fa\public,没有问题. 我以为 Nginx 的高级特性. 后来要建了一个 Vhosts,发现死活进不了. ...
- 【转】linux下终端命令快捷键
原文网址:http://daaoao.blog.51cto.com/2329117/554177 linux下使用终端不可避免. 使用终端快捷键,当然会使你如虎添翼.记住他们吧 终端快捷键 tab=补 ...
- oracle之 变更OS时间对数据库的影响
本文:说明提供了操作系统日期变更对数据库.应用程序数据和作业的影响. 1.它将会影响插入的任何记录,如果涉及到sysdate,则更改日期.2.它还会影响在那个日期运行的任何调度器作业. 如果将系统时间 ...
- Oracle 存储过程发送邮件
CREATE OR REPLACE PROCEDURE PROCSENDEMAIL(P_TXT VARCHAR2, ...
- PHP中的11个魔术方法总结:__construct,、__destruct、__call等
PHP中的魔术方法总结 :__construct, __destruct , __call, __callStatic,__get, __set, __isset, __unset , __sleep ...
- Hadoop和云计算
什么是Hadoop? Hadoop代表的就是基于异步存储(HDFS)的并行计算(Map-Reduce). 首先Hdsf/ Kudu他的存储是分布式的存储,hive(map-reduce).impala ...
- Windows10安装.net3.5
1.装载windows10映像 2.运行如下命令(注意修改盘符): Dism /online /enable-feature /featurename:NetFX3 /All /Source:F:\s ...
- appium API记录
1,滑动屏幕 driver.swipe(start_x=720, start_y=1000, end_x=0, end_y=1000,duration=1000) ,注意开始坐标不能是最大值 2,获取 ...
- 服务注册发现consul之五:Consul移除失效服务的正确姿势
spring cloud微服务不定期会出现网络请求失败的错误.于是看了下后台日志,发现有几个请求会报如下的异常: Caused by: feign.RetryableException: Connec ...