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 对象触发 ...
随机推荐
- Python函数 dict()
dict() 作用:dict() 函数用于创建一个字典.返回一个字典. 语法: class dict(**kwarg) class dict(mapping, **kwarg) class dict( ...
- php实现cookie加密解密
1.加密解密类 class Mcrypt { /** * 解密 * * @param string $encryptedText 已加密字符串 * @param string $key 密钥 * @r ...
- 查看 linux cpu 、内存、服务器型号和序列号、磁盘、raid 的信息
yum -y install dmidecode 查看cpu的型号: 查看cpu的颗数:dmidecode -t processor |grep "Version"dmidecod ...
- bisect维持已排序的序列
如下: import bisect # 用来处理已排序的序列,用来维持已排序的序列,升序 # 基于二分查找 li = [] bisect.insort(li, 2) bisect.insort(li, ...
- PHP $_SERVER 祥细解读(有事例)
为了看的更明白,添加上了事例 例如 'www.ceshiyuming.com/ceshi.php?p=123';Array( [HOSTNAME] => [PATH] => ...
- 关于Jquery 插件开发,写的很清楚了。。。
转自:http://blog.jobbole.com/30550/ 本文由 伯乐在线 - 戴嘉华 翻译.未经许可,禁止转载!英文出处:Extraordinarythoughts.欢迎加入翻译小组. 如 ...
- [转]Outlook HTML渲染
转自:http://www.cnblogs.com/dolphinX/p/4081828.html 是不是很讨厌为Email代码兼容Outlook? 太遗憾了!虽然光都有尽头,但Outlook始终存在 ...
- linux 下 rpc python 实例之使用XML-RPC进行远程文件共享
这是个不错的练习,使用python开发P2P程序,或许通过这个我们可以自己搞出来一个P2P下载工具,类似于迅雷.XML-RPC是一个远程过程调用(remote procedure call,RPC)的 ...
- 将ESXI所有的端口组迁移到分布式交换机的步骤
1.如果是DELL服务器,一般有2-4个网口,那么所有的网口都把网线插到交换机上:2.DELL安装ESXI系统,根据不同的DELL硬件,要安装不同的ESXI版本.原则上越高版本,支持的硬件越多向下兼容 ...
- ubuntu18.04修改时区
运行如下命令: sudo tzselect 然后选择亚洲Asia,继续选择中国China,最后选择北京Beijing. 然后创建时区软链 sudo ln -sf /usr/share/zoneinfo ...