通用函数接口日志详解编程语言

即插即用^_^

通用函数接口日志详解编程语言

 使用时:

ZLYLOG ‘ZLYTEST01’ ’01’.”FM开头

ZLYLOG ‘ZLYTEST01’ ’02’.”FM结尾

TABLE:ZLOGDATA(此表是来存储所有LOG,字段可自由调整,此处只留有日期,时间,函数名)

通用函数接口日志详解编程语言

INCLUDE ZLYLOG,复制,激活(此INCLUDE是LOG主要部分,用来处理函数参数并记录Log以及log展示)

 在函数中使用时,需要将此INCLUDE加入函数主程序的最前方。如果有命名冲突,可修改。

TABLES:TFDIR,TRDIR,ENLFDIR,RS38L,RFCDES,T100,TLIBG. 
"BEGIN 
DATA:BEGIN OF LS_HEAD, 
NAME   TYPE RS38L_FNAM, 
ERDAT  TYPE ERDAT, 
ZEIT   TYPE UZEIT, 
INDX   TYPE NUMC2, 
FDNAME TYPE RS38L_PAR_, 
AREA   TYPE RS38L_AREA, 
ERNAM  TYPE UNAME, 
RTYPE  TYPE BAPI_MTYPE, 
*       TCODE  TYPE TCODE, 
*       ADDR   TYPE NI_NODEADDR, 
END OF LS_HEAD. 
DATA:BEGIN OF CELL_HEADER OCCURS 0, 
HTEXT     TYPE STRING, 
WIDTH     TYPE I, 
NO_OUT, 
NO_ZERO, 
JUSTIFIED, 
END OF CELL_HEADER. 
DATA:  LV_PNAME_GD         TYPE TFDIR-PNAME, 
LS_HEADER_GD        TYPE HEADER_FB, 
LT_TABLES_GD        TYPE RSFB_PARA, 
LT_IMPORT_GD        TYPE RSFB_PARA, 
LT_EXPORT_GD        TYPE RSFB_PARA, 
LT_CHANGE_GD        TYPE RSFB_PARA, 
LV_PROGNAME_GD      TYPE TRDIR-NAME, 
LV_PARANAME_GD(100). 
FIELD-SYMBOLS: <LS_PARA>    TYPE RSFBPARA, 
<LV_PARAFLD> TYPE ANY, 
<LV_PARAVAL> TYPE ANY, 
<DYN_TABLE>  TYPE STANDARD TABLE, 
<LT_PARAFLD> TYPE ANY TABLE, 
<LT_PARAVAL> TYPE ANY TABLE. 
DATA:LV_HEAD TYPE ZLOGDATA. 
DATA:GT_TAB TYPE TABLE OF ZLOGDATA, 
GV_TAB LIKE LINE OF GT_TAB, 
GW_TAB LIKE LINE OF GT_TAB. 
DATA:DY_TABLE TYPE REF TO DATA, 
DY_LINE  TYPE REF TO DATA. 
INCLUDE MS38LCOM. 
DATA: DOCUMENTATION LIKE FUNCT OCCURS 0 WITH HEADER LINE. 
DATA: TESTSTEP(3) VALUE 'PBO'. 
DATA : BEGIN OF FDESC OCCURS 10, 
NAME(30),                     "Feldname 
TABLE(40),                    "Tabellenname 
TYPE(1),                      "Datentyp 
LENGTH(5),                    "Länge 
ILENGTH(5),                   "Eingabelänge 
HLENGTH    TYPE P,               "Eingabelänge 
FTYPE(3),                     "Typ fdt_... 
VALUE      TYPE STRING, 
"I IMPORT 
"E EXPORT 
"C CHANGING 
"S STRUCTURE 
"Y TYPE 
"T TABLE 
NUMBER     TYPE I,                "Referenz, wessen Struktur 
END OF FDESC. 
DATA: MAX_FIELD_LENGTH_PAI TYPE I, 
MAX_FIELD_LENGTH     TYPE I,         " Maximale Feldlaenge 
FDESC_INDEX          LIKE SY-TABIX, 
PARAM_VALUE(220), 
V_PARAM_VALUE(220), 
D100_IOHIDE. 
DATA: STRUC_INFO_TABLE_ENTRY TYPE NF2TY_STRUC_INFO_TABLE_ENTRY, 
STRUC_INFO_TABLE       TYPE NF2TY_STRUC_INFO_TABLE, 
STRUC_INFO_TABLE_COPY  TYPE NF2TY_STRUC_INFO_TABLE. 
INCLUDE: <ICON>. 
FIELD-SYMBOLS: <F>. 
DATA:GV_FLAG TYPE C. 
*&---------------------------------------------------------------------* 
*&      Form  IN_DESCRIBE_FIELDS 
*&---------------------------------------------------------------------* 
*       text 
*----------------------------------------------------------------------* 
*  -->  p1        text 
*  <--  p2        text 
*----------------------------------------------------------------------* 
FORM IN_DESCRIBE_INTERFACE USING P_FNAME. 
REFRESH FDESC. 
CLEAR: MAX_FIELD_LENGTH, MAX_FIELD_LENGTH_PAI. 
* --Importfelder : Name, Länge und Typ bestimmen 
LOOP AT IF_IMPORT. 
AT LAST . 
GV_FLAG = 'X'. 
ENDAT. 
*    perform prm_write_header using text-130. 
PERFORM IN_DESCRIBE_FIELDS USING P_FNAME 
IF_IMPORT-PARAMETER 
IF_IMPORT-TYP 
IF_IMPORT-DBFIELD 
'I' 
TEXT-130. 
ENDLOOP. 
* --Changefelder : Name, Länge und Typ bestimmen 
LOOP AT IF_CHANGE. 
AT LAST . 
GV_FLAG = 'X'. 
ENDAT. 
PERFORM IN_DESCRIBE_FIELDS USING P_FNAME 
IF_CHANGE-PARAMETER 
IF_CHANGE-TYP 
IF_CHANGE-DBFIELD 
'C' 
TEXT-132. 
ENDLOOP. 
* --Exportfelder : Name, Länge und Typ bestimmen 
IF GV_TAB-INDX = '02'. 
LOOP AT IF_EXPORT.                   "keine neue Beschreibung wenn 
AT LAST . 
GV_FLAG = 'X'. 
ENDAT. 
READ TABLE FDESC WITH KEY IF_EXPORT-PARAMETER.  "schon IMPORT 
IF SY-SUBRC = 0.                   "Schon Input-Parameter ? 
IF FDESC-FTYPE = 'I'.            "nur Typ entsprechend ändern 
FDESC-FTYPE = 'IO'. 
ELSEIF FDESC-FTYPE = 'IS'. 
FDESC-FTYPE = 'IOS'. 
ENDIF. 
MODIFY FDESC INDEX SY-TABIX. 
ELSE. 
PERFORM IN_DESCRIBE_FIELDS USING P_FNAME 
IF_EXPORT-PARAMETER 
IF_EXPORT-TYP 
IF_EXPORT-DBFIELD 
'O' 
TEXT-140. 
ENDIF. 
ENDLOOP. 
ENDIF. 
* --Tablesfelder : Name, Länge und Typ bestimmen 
LOOP AT IF_TABLES. 
AT LAST . 
GV_FLAG = 'X'. 
ENDAT. 
PERFORM IN_DESCRIBE_FIELDS USING P_FNAME 
IF_TABLES-PARAMETER 
IF_TABLES-TYP 
IF_TABLES-DBSTRUCT 
'T' 
TEXT-160. 
ENDLOOP. 
* --Exceptions : Nix zu Bestimmen 
LOOP AT IF_EXCEPT. 
CLEAR FDESC. 
FDESC-NAME = IF_EXCEPT-EXCEPTION. 
APPEND FDESC. 
ENDLOOP. 
* Abtrennen 
CLEAR FDESC. 
FDESC-NAME = '*'. 
APPEND FDESC. 
MAX_FIELD_LENGTH = MAX_FIELD_LENGTH + 35. 
IF MAX_FIELD_LENGTH < 80. 
MAX_FIELD_LENGTH = 80. 
ENDIF. 
MAX_FIELD_LENGTH_PAI = MAX_FIELD_LENGTH_PAI + 35. 
IF MAX_FIELD_LENGTH_PAI < 80. 
MAX_FIELD_LENGTH_PAI = 80. 
ENDIF. 
ENDFORM.                               " IN_DESCRIBE_FIELDS 
*---------------------------------------------------------------------* 
*       FORM IN_DESCRIBE_FIELDS                                       * 
*---------------------------------------------------------------------* 
*       ........                                                      * 
*---------------------------------------------------------------------* 
*  -->  P_PARAMETER                                                   * 
*  -->  P_TYP                                                         * 
*  -->  P_STRUC                                                       * 
*  -->  P_KIND                                                        * 
*---------------------------------------------------------------------* 
FORM IN_DESCRIBE_FIELDS USING    P_FNAME 
P_PARAMETER 
P_TYP 
P_STRUC 
P_KIND 
P_TEXT. 
DATA: L_SLINE TYPE NF2TY_INFO_ENTRY. 
DATA: OFFSET    LIKE SY-FDPOS, 
D_TYPE(1) TYPE C VALUE 'I'. 
DATA: O_PARAM_VALUE    LIKE PARAM_VALUE, 
RESULT_TEXT(250). 
FIELD-SYMBOLS: <F>, <F1>. 
CASE P_KIND. 
WHEN 'I'. 
READ TABLE LT_IMPORT_GD ASSIGNING <LS_PARA> WITH KEY PARAMETER = P_PARAMETER. 
WHEN 'O'. 
READ TABLE LT_EXPORT_GD ASSIGNING <LS_PARA> WITH KEY PARAMETER = P_PARAMETER. 
WHEN 'C'. 
READ TABLE LT_CHANGE_GD ASSIGNING <LS_PARA> WITH KEY PARAMETER = P_PARAMETER. 
WHEN 'T'. 
READ TABLE LT_TABLES_GD ASSIGNING <LS_PARA> WITH KEY PARAMETER = P_PARAMETER. 
WHEN OTHERS. 
ENDCASE. 
IF <LS_PARA>-STRUCTURE IS INITIAL. 
ASSIGN <LS_PARA>-PARAMETER TO <LV_PARAFLD>. 
ELSE. 
CREATE DATA DY_TABLE TYPE TABLE OF (<LS_PARA>-STRUCTURE). 
ASSIGN DY_TABLE->* TO <DYN_TABLE>. 
IF P_KIND = 'T'. 
ASSIGN DY_TABLE->* TO <LV_PARAFLD>. 
ELSE. 
CREATE DATA DY_LINE LIKE LINE OF <DYN_TABLE>. 
ASSIGN DY_LINE->* TO <LV_PARAFLD>. 
ENDIF. 
ENDIF. 
CHECK <LV_PARAFLD> IS ASSIGNED. 
LOOP AT GT_TAB INTO GW_TAB WHERE NAME = GV_TAB-NAME AND ERDAT = GV_TAB-ERDAT 
AND   ZEIT = GV_TAB-ZEIT AND ERNAM = GV_TAB-ERNAM 
AND   AREA = GV_TAB-AREA AND FDNAME = <LS_PARA>-PARAMETER. 
MOVE-CORRESPONDING GW_TAB TO LS_HEAD. 
TRY . 
IMPORT LS_HEAD-FDNAME = <LV_PARAFLD> FROM DATABASE ZLOGDATA(FL) ID LS_HEAD IGNORING CONVERSION ERRORS . 
CATCH CX_SY_IMPORT_MISMATCH_ERROR. 
*        MESSAGE '参数有变更' TYPE 'S'. 
MESSAGE S101(ZCRM_MSG). 
*        EXIT. 
ENDTRY. 
ENDLOOP. 
CLEAR FDESC. 
PERFORM CB_CALLBACK_DESCRIBE USING <LV_PARAFLD> P_PARAMETER P_KIND. 
FDESC-NAME = P_PARAMETER. 
IF NOT P_TYP IS INITIAL. 
FDESC-TABLE = P_TYP. 
CASE P_TYP. 
WHEN 'I' OR 'C' OR 'N' OR 'P' OR 'F' OR 'b' OR 's' OR 'T' 
OR 'D' OR 'X' OR 'STRING' OR 'XSTRING'. 
FDESC-VALUE = <LV_PARAFLD>. 
CONCATENATE '''' P_TYP '''' INTO FDESC-TABLE. 
WHEN 'TABLE' OR 'STANDARD TABLE' OR 'HASHED TABLE' OR 
'SORTED TABLE' OR 'INDEX TABLE'. 
WHEN 'ANY'. 
CLEAR FDESC-TABLE. 
WHEN OTHERS. 
ENDCASE. 
ELSE. 
FDESC-TABLE = P_STRUC. 
ENDIF. 
READ TABLE STRUC_INFO_TABLE_ENTRY-TYPE_INFO INDEX 1 INTO L_SLINE. 
FDESC-TYPE = L_SLINE-STRUC_TYPE. 
IF L_SLINE-VLENGTH > 200. 
L_SLINE-VLENGTH = 200. 
ENDIF. 
IF FDESC-TYPE = 'y' OR FDESC-TYPE = 'g'. 
*   Strings auf char 200 
L_SLINE-VLENGTH = 200. 
ENDIF. 
FDESC-LENGTH = L_SLINE-VLENGTH. 
FDESC-HLENGTH = L_SLINE-VLENGTH. 
FDESC-ILENGTH = L_SLINE-VLENGTH. 
IF L_SLINE-VLENGTH > MAX_FIELD_LENGTH. 
MAX_FIELD_LENGTH = L_SLINE-VLENGTH. 
MAX_FIELD_LENGTH_PAI = L_SLINE-VLENGTH. 
ENDIF. 
IF P_STRUC IS INITIAL. 
CASE FDESC-TYPE. 
***JR 14.9.98 
WHEN 'h' OR 'v' OR IF_WB_CONSTANTS=>FLAG_STRUC OR 'u'. 
*      when 'h' or 'v' or 'T' or IF_WB_CONSTANTS=>flag_struc or 'u'. 
CONCATENATE P_KIND FDESC-TYPE INTO FDESC-FTYPE. 
WHEN OTHERS. 
FDESC-FTYPE = P_KIND. 
ENDCASE. 
ELSE. 
CONCATENATE P_KIND 'S' INTO FDESC-FTYPE. 
ENDIF. 
IF FDESC-VALUE IS INITIAL. 
IF FDESC-TYPE CA '%hvu'. 
FDESC-VALUE = '?'. 
ELSE. 
FDESC-VALUE = <LV_PARAFLD>. 
ENDIF. 
ENDIF. 
APPEND FDESC. 
IF GV_FLAG = 'X'. 
FORMAT COLOR 1 INTENSIFIED ON. 
ASSIGN SY-ULINE(MAX_FIELD_LENGTH) TO <F>. 
WRITE:/ <F>. 
WRITE :/ SY-VLINE, P_TEXT, 34 SY-VLINE, 
35 TEXT-131. 
POSITION MAX_FIELD_LENGTH. 
WRITE SY-VLINE. 
WRITE:/ <F>. 
GV_FLAG = ''. 
LOOP AT FDESC WHERE FTYPE(1) = P_KIND. 
CHECK NOT FDESC-TYPE = 'l'.        "Datenreferenz 
FDESC_INDEX = SY-TABIX.            "wird für Zugriff gehided 
D100_IOHIDE = 'I'.                 "Hide für späteren Zugriff 
CLEAR PARAM_VALUE. CLEAR O_PARAM_VALUE. 
IF P_KIND = 'T' OR P_KIND = 'C'. 
D_TYPE = 'O'. 
ENDIF. 
IF FDESC-VALUE = '?'. 
ELSE. 
O_PARAM_VALUE = PARAM_VALUE = FDESC-VALUE. 
ENDIF. 
IF PARAM_VALUE CO ' '. ENDIF.      ".+-E1234567890' AND 
IF ( FDESC-TYPE = 'I' OR           " Integer 
FDESC-TYPE = 'F' OR           " Float 
FDESC-TYPE = 'h' ).           " Tabelle 
* Die schreib er nämlich hinten hin 
*        offset = sy-fdpos.             "219 - FDESC-ILENGTH. 
SHIFT PARAM_VALUE LEFT BY SY-FDPOS PLACES. 
IF O_PARAM_VALUE CO ' '. ENDIF. 
SHIFT O_PARAM_VALUE LEFT BY SY-FDPOS PLACES. 
ELSE. 
OFFSET = 0. 
ENDIF. 
IF FDESC-ILENGTH > 0. 
ASSIGN PARAM_VALUE+OFFSET(FDESC-ILENGTH) TO <F1>. 
ENDIF. 
*   perform te_set_input_prompter using <f1>. 
FORMAT RESET. 
IF FDESC-TYPE = 'u' OR FDESC-TYPE = 'h' OR FDESC-TYPE = 'v' OR 
FDESC-TYPE = 'S' OR FDESC-TYPE = IF_WB_CONSTANTS=>FLAG_STRUC OR 
FDESC-TYPE = 'r' OR 
FDESC-FTYPE(1) = 'T'.                            " ec ftype = T 
* Nicht eingabebereit, da sowieso nicht komplett oder Typgerecht pflegb. 
IF FDESC-TYPE = 'h' OR FDESC-FTYPE(1) = 'T'. 
*       Sonst gibt es bei 5 Byte Tabellen '0 Eint' 
*          ASSIGN PARAM_VALUE+OFFSET(25) TO <F1>. 
ASSIGN FDESC-VALUE TO <F1>. 
WRITE : / SY-VLINE, 3 FDESC-NAME, 34 SY-VLINE, 
35 ICON_LIST AS ICON QUICKINFO TEXT-010 HOTSPOT ON, 
38  <F1> HOTSPOT ON. 
ELSEIF FDESC-TYPE = 'r'. 
IF FDESC-TABLE(7) = 'REF TO '.                    "#EC NOTEXT 
ASSIGN PARAM_VALUE TO <F1>. 
WRITE : / SY-VLINE, 3 FDESC-NAME, 34 SY-VLINE, 
35 ICON_OO_CLASS AS ICON QUICKINFO TEXT-010 HOTSPOT ON, 
38  <F1> HOTSPOT ON. 
ELSE. 
WRITE : / SY-VLINE, 3 FDESC-NAME, 34 SY-VLINE, 
35 ICON_OO_CLASS AS ICON QUICKINFO TEXT-158, 
38  <F1>. 
ENDIF. 
ELSE. 
WRITE : / SY-VLINE, 3 FDESC-NAME, 34 SY-VLINE, 
35 ICON_DETAIL AS ICON QUICKINFO TEXT-010 HOTSPOT ON, 
38  <F1> HOTSPOT ON. 
ENDIF. 
ELSE. 
WRITE : / SY-VLINE, 3 FDESC-NAME, 34 SY-VLINE, 
35  <F1> INPUT ON. 
ENDIF. 
HIDE : FDESC_INDEX, D100_IOHIDE. 
POSITION MAX_FIELD_LENGTH. 
WRITE SY-VLINE. 
ENDLOOP. 
WRITE:/ <F>. 
FORMAT RESET. 
ENDIF. 
ENDFORM.                               " IN_DESCRIBE_FIELDS 
*&---------------------------------------------------------------------* 
*&      Form  IN_IMPORT_INTERFACE 
*&---------------------------------------------------------------------* 
*       text 
*----------------------------------------------------------------------* 
*  -->  p1        text 
*  <--  p2        text 
*----------------------------------------------------------------------* 
FORM IN_IMPORT_INTERFACE USING P_FUNCNAME. 
DATA ENHA_IMP TYPE RSFB_IMP. 
DATA ENHA_EXP TYPE RSFB_EXP. 
DATA ENHA_CHA TYPE RSFB_CHA. 
DATA ENHA_TBL TYPE RSFB_TBL. 
DATA ENHA_DOCU TYPE TABLE OF RSFDO. 
REFRESH: IF_IMPORT, IF_EXPORT, IF_CHANGE, IF_TABLES, IF_EXCEPT, 
DOCUMENTATION. 
*ec Sept. 2004 wg. SFW, Switches sollen noch berücksichtigt werden 
CALL FUNCTION 'FUNCTION_IMPORT_DOKU' 
EXPORTING 
FUNCNAME           = P_FUNCNAME 
WITH_ENHANCEMENTS  = 'X' 
TABLES 
EXCEPTION_LIST     = IF_EXCEPT 
EXPORT_PARAMETER   = IF_EXPORT 
IMPORT_PARAMETER   = IF_IMPORT 
CHANGING_PARAMETER = IF_CHANGE 
TABLES_PARAMETER   = IF_TABLES 
DOKUMENTATION      = DOCUMENTATION 
EXCEPTIONS 
ERROR_MESSAGE      = 1 
FUNCTION_NOT_FOUND = 2 
INVALID_NAME       = 3 
OTHERS             = 4. 
LOOP AT DOCUMENTATION. 
MOVE-CORRESPONDING DOCUMENTATION TO PARAM_DOCU. 
APPEND PARAM_DOCU. 
ENDLOOP. 
ENDFORM.                               " IN_IMPORT_INTERFACE 
*---------------------------------------------------------------------* 
*       FORM CB_CALLBACK_DESCRIBE                                     * 
*---------------------------------------------------------------------* 
*       ........                                                      * 
*---------------------------------------------------------------------* 
*  -->  P_VALUE                                                       * 
*  -->  P_NAME                                                        * 
*---------------------------------------------------------------------* 
FORM CB_CALLBACK_DESCRIBE USING P_VALUE 
P_NAME 
P_KIND. 
DATA: L_TYPE_INFO TYPE  NF2TY_STRUC_INFO. 
DATA:S_TYPE_INFO LIKE LINE OF L_TYPE_INFO. 
DATA:LV_I TYPE N. 
FIELD-SYMBOLS:<F1> TYPE ANY TABLE. 
CALL FUNCTION 'RS_COMPLEX_OBJECT_TYPEINFO_GET' 
EXPORTING 
OBJECT_NAME = P_NAME 
OBJECT      = P_VALUE 
IMPORTING 
TYPE_INFO   = L_TYPE_INFO 
EXCEPTIONS 
OTHERS      = 0. 
STRUC_INFO_TABLE_ENTRY-PARAM_NAME = P_NAME. 
STRUC_INFO_TABLE_ENTRY-TYPE_INFO  = L_TYPE_INFO. 
APPEND STRUC_INFO_TABLE_ENTRY TO STRUC_INFO_TABLE. 
READ TABLE L_TYPE_INFO INDEX 1 INTO S_TYPE_INFO. 
IF SY-SUBRC = 0 . 
FDESC-TYPE = S_TYPE_INFO-STRUC_TYPE. 
IF ( FDESC-TYPE = 'h' OR FDESC-FTYPE(1) = 'T' ) OR ( P_KIND = 'T' AND FDESC-TYPE = '%' ). 
ASSIGN P_VALUE TO <F1>. 
DESCRIBE TABLE <F1> LINES LV_I. 
CONCATENATE LV_I '条目' INTO FDESC-VALUE. 
ENDIF. 
ENDIF. 
ENDFORM.                    "cb_callback_describe 
DEFINE ZLYLOG. 
LS_HEAD-NAME = &1. 
LS_HEAD-ERDAT = SY-DATUM. 
LS_HEAD-ZEIT = SY-UZEIT. 
LS_HEAD-INDX = &2. 
LS_HEAD-RTYPE = &3. 
LS_HEAD-ERNAM = SY-UNAME. 
LS_HEADER_GD-NAME = &1. 
*  IF &1 = 'AUTH_CHECK_TCODE'. 
*    LS_HEAD-TCODE = SY-TCODE. 
*    CALL FUNCTION 'TH_USER_INFO' 
*     IMPORTING 
*       ADDRSTR   =  LS_HEAD-ADDR. 
*  ENDIF. 
*  read function-pool 
SELECT SINGLE PNAME 
FROM TFDIR 
INTO  LV_PNAME_GD 
WHERE FUNCNAME =  LS_HEADER_GD-NAME. 
CALL FUNCTION 'FUNCTION_INCLUDE_SPLIT' 
EXPORTING 
PROGRAM   = LV_PNAME_GD 
IMPORTING 
GROUP     = LS_HEADER_GD-AREA 
NAMESPACE = LS_HEADER_GD-NAMESPACE. 
LS_HEAD-AREA = LS_HEADER_GD-AREA. 
*  insert namespace (e.g. /AFS/) 
CONCATENATE LS_HEADER_GD-NAMESPACE LS_HEADER_GD-AREA 
INTO LS_HEADER_GD-AREA. 
*  read parameter of function module 
CALL METHOD CL_FB_PARAMETER_DB=>READ 
IMPORTING 
TABLES = LT_TABLES_GD[] 
IMPORT = LT_IMPORT_GD[] 
EXPORT = LT_EXPORT_GD[] 
CHANGE = LT_CHANGE_GD[] 
CHANGING 
HEADER = LS_HEADER_GD. 
LV_PROGNAME_GD =  LS_HEADER_GD-NAME. 
TRANSLATE  LV_PROGNAME_GD USING ' ='. 
LV_PROGNAME_GD+30 = 'FT'. 
LOOP AT  LT_IMPORT_GD ASSIGNING <LS_PARA>. 
CONCATENATE '(' LV_PROGNAME_GD ')%_I' <LS_PARA>-PARAMETER 
INTO LV_PARANAME_GD. 
ASSIGN (LV_PARANAME_GD) TO <LV_PARAFLD>. 
CHECK SY-SUBRC = 0. 
LS_HEAD-FDNAME = <LS_PARA>-PARAMETER. 
MOVE-CORRESPONDING LS_HEAD TO LV_HEAD. 
EXPORT LS_HEAD-FDNAME = <LV_PARAFLD> TO DATABASE ZLOGDATA(FL) FROM LV_HEAD ID LS_HEAD. 
ENDLOOP. 
IF &2 = '02'. 
LOOP AT  LT_EXPORT_GD ASSIGNING <LS_PARA>. 
CONCATENATE '(' LV_PROGNAME_GD ')%_O' <LS_PARA>-PARAMETER 
INTO LV_PARANAME_GD. 
ASSIGN (LV_PARANAME_GD) TO <LV_PARAFLD>. 
CHECK SY-SUBRC = 0. 
LS_HEAD-FDNAME = <LS_PARA>-PARAMETER. 
MOVE-CORRESPONDING LS_HEAD TO LV_HEAD. 
EXPORT LS_HEAD-FDNAME = <LV_PARAFLD> TO DATABASE ZLOGDATA(FL) FROM LV_HEAD ID LS_HEAD. 
ENDLOOP. 
ENDIF. 
LOOP AT  LT_CHANGE_GD ASSIGNING <LS_PARA>. 
CONCATENATE '(' LV_PROGNAME_GD ')%_I' <LS_PARA>-PARAMETER 
INTO LV_PARANAME_GD. 
ASSIGN (LV_PARANAME_GD) TO <LV_PARAFLD>. 
CHECK SY-SUBRC = 0. 
LS_HEAD-FDNAME = <LS_PARA>-PARAMETER. 
MOVE-CORRESPONDING LS_HEAD TO LV_HEAD. 
EXPORT LS_HEAD-FDNAME = <LV_PARAFLD> TO DATABASE ZLOGDATA(FL) FROM LV_HEAD ID LS_HEAD. 
ENDLOOP. 
LOOP AT  LT_TABLES_GD ASSIGNING <LS_PARA>. 
CONCATENATE '(' LV_PROGNAME_GD ')%_I' 
<LS_PARA>-PARAMETER '[]' 
INTO LV_PARANAME_GD. 
IF &2 = '02'. 
CONCATENATE '(' LV_PROGNAME_GD ')%_O' 
<LS_PARA>-PARAMETER '[]' 
INTO LV_PARANAME_GD. 
ENDIF. 
ASSIGN (LV_PARANAME_GD) TO <LT_PARAFLD>. 
CHECK SY-SUBRC = 0. 
LS_HEAD-FDNAME = <LS_PARA>-PARAMETER. 
MOVE-CORRESPONDING LS_HEAD TO LV_HEAD. 
EXPORT LS_HEAD-FDNAME = <LT_PARAFLD> TO DATABASE ZLOGDATA(FL) FROM LV_HEAD ID LS_HEAD. 
CONCATENATE <LS_PARA>-PARAMETER '[]' INTO LV_PARANAME_GD. 
ENDLOOP. 
END-OF-DEFINITION. 
FORM ZLYLOG USING GV_FM LV_C LV_T. 
DATA:  LV_PNAME_GD         TYPE TFDIR-PNAME, 
LS_HEADER_GD        TYPE HEADER_FB, 
LT_TABLES_GD        TYPE RSFB_PARA, 
LT_IMPORT_GD        TYPE RSFB_PARA, 
LT_EXPORT_GD        TYPE RSFB_PARA, 
LT_CHANGE_GD        TYPE RSFB_PARA, 
LV_PROGNAME_GD      TYPE TRDIR-NAME, 
LV_PARANAME_GD(100). 
FIELD-SYMBOLS: <LS_PARA>    TYPE RSFBPARA, 
<LV_PARAFLD> TYPE ANY, 
<LV_PARAVAL> TYPE ANY, 
<LT_PARAFLD> TYPE ANY TABLE, 
<LT_PARAVAL> TYPE ANY TABLE. 
*  DATA:LS_HEAD TYPE TY_HEAD. 
LS_HEAD-NAME = GV_FM. 
LS_HEAD-ERDAT = SY-DATUM. 
LS_HEAD-ZEIT = SY-UZEIT. 
LS_HEAD-INDX = LV_C. 
LS_HEAD-RTYPE = LV_T. 
LS_HEAD-ERNAM = SY-UNAME. 
DATA:LV_HEAD TYPE ZLOGDATA. 
LS_HEADER_GD-NAME = GV_FM. 
 
*  read function-pool 
SELECT SINGLE PNAME 
FROM TFDIR 
INTO  LV_PNAME_GD 
WHERE FUNCNAME =  LS_HEADER_GD-NAME. 
CALL FUNCTION 'FUNCTION_INCLUDE_SPLIT' 
EXPORTING 
PROGRAM   = LV_PNAME_GD 
IMPORTING 
GROUP     = LS_HEADER_GD-AREA 
NAMESPACE = LS_HEADER_GD-NAMESPACE. 
LS_HEAD-AREA = LS_HEADER_GD-AREA. 
*  insert namespace (e.g. /AFS/) 
CONCATENATE LS_HEADER_GD-NAMESPACE LS_HEADER_GD-AREA 
INTO LS_HEADER_GD-AREA. 
*  read parameter of function module 
CALL METHOD CL_FB_PARAMETER_DB=>READ 
IMPORTING 
TABLES = LT_TABLES_GD[] 
IMPORT = LT_IMPORT_GD[] 
EXPORT = LT_EXPORT_GD[] 
CHANGE = LT_CHANGE_GD[] 
CHANGING 
HEADER = LS_HEADER_GD. 
LV_PROGNAME_GD =  LS_HEADER_GD-NAME. 
TRANSLATE  LV_PROGNAME_GD USING ' ='. 
LV_PROGNAME_GD+30 = 'FT'. 
LOOP AT  LT_IMPORT_GD ASSIGNING <LS_PARA>. 
CONCATENATE '(' LV_PROGNAME_GD ')%_I' <LS_PARA>-PARAMETER 
INTO LV_PARANAME_GD. 
ASSIGN (LV_PARANAME_GD) TO <LV_PARAFLD>. 
CHECK SY-SUBRC = 0. 
LS_HEAD-FDNAME = <LS_PARA>-PARAMETER. 
MOVE-CORRESPONDING LS_HEAD TO LV_HEAD. 
EXPORT LS_HEAD-FDNAME = <LV_PARAFLD> TO DATABASE ZLOGDATA(FL) FROM LV_HEAD ID LS_HEAD. 
ENDLOOP. 
IF LV_C = '02'. 
LOOP AT  LT_EXPORT_GD ASSIGNING <LS_PARA>. 
CONCATENATE '(' LV_PROGNAME_GD ')%_O' <LS_PARA>-PARAMETER 
INTO LV_PARANAME_GD. 
ASSIGN (LV_PARANAME_GD) TO <LV_PARAFLD>. 
CHECK SY-SUBRC = 0. 
LS_HEAD-FDNAME = <LS_PARA>-PARAMETER. 
MOVE-CORRESPONDING LS_HEAD TO LV_HEAD. 
EXPORT LS_HEAD-FDNAME = <LV_PARAFLD> TO DATABASE ZLOGDATA(FL) FROM LV_HEAD ID LS_HEAD. 
ENDLOOP. 
ENDIF. 
LOOP AT  LT_CHANGE_GD ASSIGNING <LS_PARA>. 
CONCATENATE '(' LV_PROGNAME_GD ')%_I' <LS_PARA>-PARAMETER 
INTO LV_PARANAME_GD. 
ASSIGN (LV_PARANAME_GD) TO <LV_PARAFLD>. 
CHECK SY-SUBRC = 0. 
LS_HEAD-FDNAME = <LS_PARA>-PARAMETER. 
MOVE-CORRESPONDING LS_HEAD TO LV_HEAD. 
EXPORT LS_HEAD-FDNAME = <LV_PARAFLD> TO DATABASE ZLOGDATA(FL) FROM LV_HEAD ID LS_HEAD. 
ENDLOOP. 
LOOP AT  LT_TABLES_GD ASSIGNING <LS_PARA>. 
CONCATENATE '(' LV_PROGNAME_GD ')%_I' 
<LS_PARA>-PARAMETER '[]' 
INTO LV_PARANAME_GD. 
IF LV_C = '02'. 
CONCATENATE '(' LV_PROGNAME_GD ')%_O' 
<LS_PARA>-PARAMETER '[]' 
INTO LV_PARANAME_GD. 
ENDIF. 
ASSIGN (LV_PARANAME_GD) TO <LT_PARAFLD>. 
CHECK SY-SUBRC = 0. 
LS_HEAD-FDNAME = <LS_PARA>-PARAMETER. 
MOVE-CORRESPONDING LS_HEAD TO LV_HEAD. 
EXPORT LS_HEAD-FDNAME = <LT_PARAFLD> TO DATABASE ZLOGDATA(FL) FROM LV_HEAD ID LS_HEAD. 
CONCATENATE <LS_PARA>-PARAMETER '[]' INTO LV_PARANAME_GD. 
ENDLOOP. 
ENDFORM. 
*&---------------------------------------------------------------------* 
*&      Form  PRM_SELECT_DETAIL 
*&---------------------------------------------------------------------* 
*       text 
*----------------------------------------------------------------------* 
*  -->  p1        text 
*  <--  p2        text 
*----------------------------------------------------------------------* 
FORM PRM_SELECT_DETAIL . 
READ TABLE FDESC INDEX FDESC_INDEX. 
CHECK FDESC-TYPE = '%' OR FDESC-TYPE = 'h' OR FDESC-TYPE = 'T'. 
CASE FDESC-FTYPE+0(1). 
WHEN 'I'. 
READ TABLE LT_IMPORT_GD ASSIGNING <LS_PARA> WITH KEY PARAMETER = FDESC-NAME.. 
WHEN 'C'. 
READ TABLE LT_CHANGE_GD ASSIGNING <LS_PARA> WITH KEY PARAMETER = FDESC-NAME.. 
WHEN 'O'. 
READ TABLE LT_EXPORT_GD ASSIGNING <LS_PARA> WITH KEY PARAMETER = FDESC-NAME.. 
WHEN 'T'. 
READ TABLE LT_TABLES_GD ASSIGNING <LS_PARA> WITH KEY PARAMETER = FDESC-NAME.. 
WHEN OTHERS. 
ENDCASE. 
CHECK <LS_PARA> IS ASSIGNED. 
CREATE DATA DY_TABLE TYPE TABLE OF (<LS_PARA>-STRUCTURE). 
ASSIGN DY_TABLE->* TO <DYN_TABLE>. 
IF FDESC-FTYPE+0(1) = 'T'. 
ASSIGN <DYN_TABLE> TO <LV_PARAFLD>. 
ELSE. 
CREATE DATA DY_LINE LIKE LINE OF <DYN_TABLE>. 
ASSIGN DY_LINE->* TO <LV_PARAFLD>. 
ENDIF. 
LOOP AT GT_TAB INTO GW_TAB WHERE NAME = GV_TAB-NAME AND ERDAT = GV_TAB-ERDAT 
AND   ZEIT = GV_TAB-ZEIT AND INDX = GV_TAB-INDX 
AND   ERNAM = GV_TAB-ERNAM AND AREA = GV_TAB-AREA AND FDNAME = <LS_PARA>-PARAMETER. 
MOVE-CORRESPONDING GW_TAB TO LS_HEAD. 
TRY . 
IMPORT LS_HEAD-FDNAME = <LV_PARAFLD> FROM DATABASE ZLOGDATA(FL) ID LS_HEAD IGNORING CONVERSION ERRORS . 
CATCH CX_SY_IMPORT_MISMATCH_ERROR. 
MESSAGE '函数结构已变更' TYPE 'S'. 
ENDTRY. 
ENDLOOP. 
CALL FUNCTION 'RS_COMPLEX_OBJECT_EDIT' 
EXPORTING 
OBJECT_NAME          = FDESC-NAME 
MODE                 = ' ' 
INSERT_TAB           = 'X' 
UPPER_CASE           = 'X' 
POPUP                = ' ' 
*     DISPLAY_ACCESSIBLE   = ' ' 
CHANGING 
OBJECT               = <LV_PARAFLD> 
EXCEPTIONS 
OBJECT_NOT_SUPPORTED = 1. 
ENDFORM. 
*&---------------------------------------------------------------------* 
*&      Form  PRM_GET_INTERFACE_PARA 
*&---------------------------------------------------------------------* 
*       text 
*----------------------------------------------------------------------* 
*      -->P_GV_TAB_NAME  text 
*----------------------------------------------------------------------* 
FORM PRM_GET_INTERFACE_PARA  USING    P_GV_TAB_NAME. 
LS_HEADER_GD-NAME = P_GV_TAB_NAME. 
SELECT SINGLE PNAME 
FROM TFDIR 
INTO  LV_PNAME_GD 
WHERE FUNCNAME =  LS_HEADER_GD-NAME. 
CALL FUNCTION 'FUNCTION_INCLUDE_SPLIT' 
EXPORTING 
PROGRAM   = LV_PNAME_GD 
IMPORTING 
GROUP     = LS_HEADER_GD-AREA 
NAMESPACE = LS_HEADER_GD-NAMESPACE. 
LS_HEAD-AREA = LS_HEADER_GD-AREA. 
*  insert namespace (e.g. /AFS/) 
CONCATENATE LS_HEADER_GD-NAMESPACE LS_HEADER_GD-AREA 
INTO LS_HEADER_GD-AREA. 
CALL METHOD CL_FB_PARAMETER_DB=>READ 
IMPORTING 
TABLES = LT_TABLES_GD[] 
IMPORT = LT_IMPORT_GD[] 
EXPORT = LT_EXPORT_GD[] 
CHANGE = LT_CHANGE_GD[] 
CHANGING 
HEADER = LS_HEADER_GD. 
LV_PROGNAME_GD =  LS_HEADER_GD-NAME. 
ENDFORM. 
FORM APPENDHEAD USING TEXT WIDTH NO_OUT NO_ZERO JUSTIFIED. 
CELL_HEADER-HTEXT = TEXT. 
CELL_HEADER-WIDTH = WIDTH. 
CELL_HEADER-NO_OUT = NO_OUT. 
CELL_HEADER-NO_ZERO = NO_ZERO. 
CELL_HEADER-JUSTIFIED = JUSTIFIED. 
APPEND CELL_HEADER. 
ENDFORM. 
FORM WRITE_CELL TABLES HEADER STRUCTURE CELL_HEADER 
ITEM TYPE STANDARD TABLE 
USING   FISRTCOL. 
DATA:ULENGTH TYPE I, 
COL_NUM TYPE I. 
DATA:STR(1000), 
STR_IDX   TYPE STRING, 
F_INDEX   TYPE I. 
FIELD-SYMBOLS:<F_FIELD>. 
DESCRIBE TABLE HEADER LINES COL_NUM. 
LOOP AT HEADER WHERE NO_OUT = '' OR NO_OUT = 'Z'. 
ULENGTH = ULENGTH + HEADER-WIDTH + 1. 
ENDLOOP. 
ULENGTH = ULENGTH + 1. 
WRITE AT /FISRTCOL(ULENGTH) SY-ULINE. 
NEW-LINE.POSITION FISRTCOL. 
LOOP AT HEADER WHERE NO_OUT = '' OR NO_OUT = 'Z'. 
WRITE '|' NO-GAP. 
WRITE : AT (HEADER-WIDTH) HEADER-HTEXT CENTERED NO-GAP. 
ENDLOOP. 
WRITE '|' NO-GAP. 
WRITE AT /FISRTCOL(ULENGTH) SY-ULINE. 
LOOP AT ITEM. 
NEW-LINE.POSITION FISRTCOL. 
DO COL_NUM TIMES. 
READ TABLE HEADER INDEX SY-INDEX. 
ASSIGN COMPONENT SY-INDEX OF STRUCTURE ITEM TO <F_FIELD>. 
IF SY-SUBRC <> 0. 
EXIT. 
ELSE. 
STR_IDX = SY-INDEX. 
CONDENSE STR_IDX. 
F_INDEX = SY-INDEX - 1. 
IF HEADER-NO_OUT = ''. 
IF HEADER-NO_ZERO = 'X'. 
WRITE <F_FIELD> TO STR LEFT-JUSTIFIED. 
ENDIF. 
IF HEADER-JUSTIFIED = 'R'. 
WRITE : '|' NO-GAP,AT (HEADER-WIDTH) STR RIGHT-JUSTIFIED NO-GAP. 
ELSE. 
WRITE : '|' NO-GAP,AT (HEADER-WIDTH) STR LEFT-JUSTIFIED NO-GAP. 
ENDIF. 
ENDIF. 
ENDIF. 
ENDDO. 
WRITE '|' NO-GAP. 
WRITE AT /FISRTCOL(ULENGTH) SY-ULINE. 
ENDLOOP. 
ENDFORM.

REPORT ZLYLOGP,显示:

" 
REPORT ZLYLOGP NO STANDARD PAGE HEADING. 
INCLUDE ZLYLOG. 
DATA:GT_SHOW TYPE TABLE OF ZLOGDATA. 
DATA:GT_FIELDCAT TYPE LVC_T_FCAT. 
DATA GS_FIELDCAT LIKE LINE OF GT_FIELDCAT. 
DATA LS_LAYOUT TYPE LVC_S_LAYO. 
DEFINE APPEND_FIELDCAT . 
CLEAR GS_FIELDCAT. 
GS_FIELDCAT-FIELDNAME = &1. 
GS_FIELDCAT-SCRTEXT_L = &2. 
GS_FIELDCAT-OUTPUTLEN = &3. 
GS_FIELDCAT-NO_ZERO = &4. 
APPEND GS_FIELDCAT TO GT_FIELDCAT."GT_FIELDCAT. 
END-OF-DEFINITION. 
SELECTION-SCREEN:BEGIN OF BLOCK BLK01 WITH FRAME TITLE TEXT-001. 
SELECT-OPTIONS:S_NAME FOR ZLOGDATA-NAME. 
SELECT-OPTIONS:S_ERDAT FOR ZLOGDATA-ERDAT. 
SELECT-OPTIONS:S_ZEIT FOR ZLOGDATA-ZEIT. 
SELECT-OPTIONS:S_AREA FOR ZLOGDATA-AREA. 
SELECT-OPTIONS:S_ERNAM FOR ZLOGDATA-ERNAM. 
SELECTION-SCREEN END OF BLOCK BLK01. 
START-OF-SELECTION. 
SELECT * INTO CORRESPONDING FIELDS OF TABLE GT_TAB 
FROM ZLOGDATA 
WHERE NAME IN S_NAME 
AND   ERDAT IN S_ERDAT 
AND   ZEIT  IN S_ZEIT 
AND   AREA  IN S_AREA 
AND   ERNAM IN S_ERNAM. 
CHECK GT_TAB[] IS NOT INITIAL. 
GT_SHOW[] = GT_TAB[]. 
SORT GT_SHOW BY RELID AREA NAME ERDAT ZEIT INDX ERNAM. 
DELETE ADJACENT DUPLICATES FROM GT_SHOW COMPARING RELID AREA NAME ERDAT ZEIT INDX ERNAM. 
PERFORM PRM_SHOW. 
END-OF-SELECTION. 
AT LINE-SELECTION. 
PERFORM PRM_SELECT_DETAIL. 
TOP-OF-PAGE." DURING LINE-SELECTION. 
DATA:GV_STR TYPE STRING. 
DATA:GV_C(8) TYPE C. 
IF GV_TAB-INDX = '01'. 
GV_C = '传入参数'. 
ELSE. 
GV_C = '传出参数'. 
ENDIF. 
CONCATENATE '函数组:' GV_TAB-AREA '函数:' GV_TAB-NAME '用户' GV_TAB-ERNAM INTO GV_STR SEPARATED BY ' '. 
WRITE:GV_STR,GV_TAB-ERDAT,GV_TAB-ZEIT, SPACE, GV_C. 
ULINE /0(135). 
*&---------------------------------------------------------------------* 
*&      Form  PRM_SHOW 
*&---------------------------------------------------------------------* 
*       text 
*----------------------------------------------------------------------* 
*  -->  p1        text 
*  <--  p2        text 
*----------------------------------------------------------------------* 
FORM PRM_SHOW . 
PERFORM PRM_SET_FIELD. 
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC' 
EXPORTING 
I_CALLBACK_PROGRAM       = SY-REPID 
IS_LAYOUT_LVC            = LS_LAYOUT 
IT_FIELDCAT_LVC          = GT_FIELDCAT[] 
I_CALLBACK_PF_STATUS_SET = 'PRM_SET_STATUS' 
I_CALLBACK_USER_COMMAND  = 'PRM_USER_COMMAND' 
*     I_STRUCTURE_NAME         = 'ZLOGDATA' 
I_DEFAULT                = 'X' 
I_SAVE                   = 'A' 
TABLES 
T_OUTTAB                 = GT_SHOW 
EXCEPTIONS 
PROGRAM_ERROR            = 1 
OTHERS                   = 2. 
IF SY-SUBRC <> 0. 
* Implement suitable error handling here 
ENDIF. 
ENDFORM. 
*&---------------------------------------------------------------------* 
*&      Form  PRM_SET_FIELD 
*&---------------------------------------------------------------------* 
*       text 
*----------------------------------------------------------------------* 
*  -->  p1        text 
*  <--  p2        text 
*----------------------------------------------------------------------* 
FORM PRM_SET_FIELD . 
REFRESH GT_FIELDCAT. 
*  LS_LAYOUT-CWIDTH_OPT    = 'X'. "优化列宽选项是否设置 
LS_LAYOUT-ZEBRA         = 'X'. 
APPEND_FIELDCAT: 
'NAME'               '函数名称'             30      'X', 
'AREA'               '函数组'               26     '', 
'ERDAT'              '日期'                 10     'X', 
'ZEIT'               '时间'                 8     'X', 
'ERNAM'              '用户名'               16     'X', 
'RTYPE'              '消息类型'             8     '', 
'INDX'               '序号'                 5     'X', 
'RTMSG'              '消息内容'             60     ''. 
ENDFORM. 
FORM PRM_SET_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.. 
SET PF-STATUS 'ZSTAT' EXCLUDING RT_EXTAB. 
ENDFORM.                    "PRM_SET_STATUS 
FORM PRM_USER_COMMAND USING P_UCOMM    LIKE SY-UCOMM 
P_SELFIELD TYPE SLIS_SELFIELD. 
*  DATA:LV_DYN TYPE SY-DYNNR VALUE SY-DYNNR. 
IF P_UCOMM = '&IC1'. 
READ TABLE GT_SHOW INTO GV_TAB INDEX P_SELFIELD-TABINDEX. 
IF SY-SUBRC = 0. 
PERFORM PRM_GET_INTERFACE_PARA USING GV_TAB-NAME. 
PERFORM IN_IMPORT_INTERFACE USING GV_TAB-NAME."GET IMPORT INTERFACE 
*      PERFORM IN_DESCRIBE_INTERFACE USING GV_TAB-NAME."GET IDESC INTERFACE 
CALL SCREEN 9000."这个屏幕需要创建,空屏幕只包含一个PBO 
SET SCREEN 0500."这个是alv屏幕^_^ 
ENDIF. 
ENDIF. 
ENDFORM.                    "PRM_USER_COMMAND 
*&---------------------------------------------------------------------* 
*&      Module  STATUS_9000  OUTPUT 
*&---------------------------------------------------------------------* 
*       text 
*----------------------------------------------------------------------* 
MODULE STATUS_9000 OUTPUT. 
*  SET PF-STATUS 'xxxxxxxx'. 
*  SET TITLEBAR 'xxx'. 
LEAVE TO LIST-PROCESSING AND RETURN TO SCREEN 0. 
SET PF-STATUS SPACE. 
SUPPRESS DIALOG. 
PERFORM IN_DESCRIBE_INTERFACE USING GV_TAB-NAME."GET IDESC INTERFACE 
ENDMODULE.

T-code使用日志

IT虾米网

原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/18675.html

(0)
上一篇 2021年7月19日
下一篇 2021年7月19日

相关推荐

发表回复

登录后才能评论