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 对象触发 ...
随机推荐
- 移植RTL8188CUS USB-WIFI(移植失败)
1.主makefile CONFIG_POWER_SAVING = n CONFIG_PLATFORM_I386_PC = n CONFIG_PLATFORM_HI3518E = y ##swann ...
- 【转】linux下终端命令快捷键
原文网址:http://daaoao.blog.51cto.com/2329117/554177 linux下使用终端不可避免. 使用终端快捷键,当然会使你如虎添翼.记住他们吧 终端快捷键 tab=补 ...
- arcgis license manager 10.2服务无法启动
(步骤)1. 用cmd切换到 license manager 安装目录,如 C:\Program Files (x86)\ArcGIS\License10.2\bin,输入: Lmgrd -z -c ...
- Jquery获取元素高度
第一步, 获取你要得到高度的那个div的jQuery对象, 获得方法有很多很多种, 具体你可以看一下jQuery API文档里的选择器部分, 在这里我只跟你说一个最直接的方法, 通过id获得: $(& ...
- java 复制对象 (克隆接口 与 序列化)
关于java对象复制我们在编码过程经常会碰到将一个对象传递给另一个对象,java中对于基本型变量采用的是值传递,而对于对象比如bean传递时采用的是应用传递也就是地址传递,而很多时候对于对象传递我们也 ...
- bzoj 1288: Neighbours
Description 很久以前, 有一个小小的国度, 为了方便, 我们可以把它想象为一个大大的矩形, 矩形的左下角为(0, 0), 右上角为(w, h), 共有(w + 1) * (h + 1)个整 ...
- Java-Runoob-高级教程-实例-数组:06. Java 实例 – 数组获取最大和最小值
ylbtech-Java-Runoob-高级教程-实例-数组:06. Java 实例 – 数组获取最大和最小值 1.返回顶部 1. Java 实例 - 数组获取最大和最小值 Java 实例 以下实例 ...
- 6-3-1appium iOS
环境准备 brew install carthage npm i -g ios-deploy brew install libimobiledevice --HEAD brew install ide ...
- Shell的for和select
环境准备: [root@nodchen-db01-test day07]# mkdir -p /server/scripts/day07/test/{test.txt,oldboy.txt,oldgi ...
- matplot 代码实例
matplot 代码实例 #!/usr/bin/env python # coding=utf-8 import numpy as np import matplotlib.pyplot as plt ...