Tips and Tricks for the ABAP® Programming Language
ZZENNO01: Downloading selected Functiongroups with all function modules
Downloading all selected Functiongroups with all modules and subroutines in one file. It does not export the automatically generated function modules for table views!
ABAP™-Source-Code
You can copy and paste the source code directly into the ABAP™-Workbench.
REPORT ZZENNO01 LINE-SIZE 250. "Rel. 3.1, 4.5 * ********************** HEADER ************** * * Copyright (c) 1999 by Enno Wulff, * Hommola & Wulff Unternehmensberatung GmbH * http://www.hommola-wulff.de * * You can use or modify this report for your own work as long * as you don't try to sell or republish it. * In no event will the author be liable for indirect, special, * Incidental, or consequental damages (if any) arising out of * the use of this report. *//////////////////////////////////////////////////////////////////////* TABLES: TFDIR, TRDIR, TLIBG. SELECT-OPTIONS: FUNKTGRP FOR TLIBG-AREA, USER FOR TLIBG-UNAME. PARAMETERS: DOWNLOAD AS CHECKBOX, FILENAME LIKE RLGRAP-FILENAME. DATA: BEGIN OF T OCCURS 500, "Report für DOWNLOAD LINE(72), END OF T, BEGIN OF ALL OCCURS 500, "Report für DOWNLOAD LINE(72), END OF ALL, XTRDIR LIKE TRDIR OCCURS 100 WITH HEADER LINE, FUNK_MAIN(8), X_FILENAME LIKE RLGRAP-FILENAME, ZINCLUDE(8). INITIALIZATION. USER-SIGN = 'I'. USER-OPTION = 'EQ'. USER-LOW = SY-UNAME. APPEND USER. FUNKTGRP-SIGN = 'I'. FUNKTGRP-OPTION = 'BT'. FUNKTGRP-LOW = 'Z000'. FUNKTGRP-HIGH = 'ZZZZ'. APPEND FUNKTGRP. CONCATENATE 'C:\ABAP\' SY-UNAME '\FUNKTBST' INTO FILENAME. START-OF-SELECTION. SELECT * FROM TLIBG WHERE AREA IN FUNKTGRP. CONCATENATE 'SAPL' TLIBG-AREA INTO FUNK_MAIN. SELECT SINGLE * FROM TRDIR WHERE NAME = FUNK_MAIN AND ( CNAM IN USER OR UNAM IN USER ). CHECK SY-SUBRC = 0. APPEND TRDIR TO XTRDIR. ENDSELECT. LOOP AT XTRDIR. TRDIR = XTRDIR. REFRESH T. REFRESH ALL. ALL = '** Funktionsbausteine: **'. APPEND ALL. SELECT * FROM TFDIR WHERE PNAME = TRDIR-NAME. CONCATENATE '**' TFDIR-FUNCNAME INTO ALL. APPEND ALL. ENDSELECT. "TFDIR READ REPORT TRDIR-NAME INTO T. LOOP AT T. IF T(10) CS 'INCLUDE'. PERFORM DO_EXCLUDE USING T. ELSE. ALL = T. APPEND ALL. ENDIF. ENDLOOP. FORMAT COLOR 5. WRITE: / '*********************'. WRITE: TRDIR-NAME. WRITE: '*********************'. FORMAT COLOR OFF. LOOP AT ALL. WRITE: / ALL. ENDLOOP. CHECK DOWNLOAD = 'X'. CONCATENATE FILENAME '\' TRDIR-NAME '.FUN' INTO X_FILENAME. CALL FUNCTION 'WS_DOWNLOAD' EXPORTING FILENAME = X_FILENAME FILETYPE = 'ASC' TABLES DATA_TAB = ALL EXCEPTIONS FILE_OPEN_ERROR = 1 FILE_WRITE_ERROR = 2 INVALID_FILESIZE = 3 INVALID_TABLE_WIDTH = 4 INVALID_TYPE = 5 NO_BATCH = 6 UNKNOWN_ERROR = 7 OTHERS = 8. ENDLOOP. *---------------------------------------------------------------------* * FORM DO_EXCLUDE * *---------------------------------------------------------------------* FORM DO_EXCLUDE USING STRING. DATA: NAME(8), FALSCHER_ALARM, ZEILE(72), BEGIN OF INC OCCURS 500, "Report für DOWNLOAD LINE(72), END OF INC. ZEILE = STRING. IF ZEILE(1) <> '*'. IF ZEILE CS 'TABLEFRAME' OR ZEILE CS 'TABLEPROC' OR ZEILE CS 'LSVIM'. " OR * ZEILE CS 'STRUCTURE'. ALL = ZEILE. APPEND ALL. IF NOT ZEILE CS 'INCLUDE STRUCTURE'. ALL = '*=->> Automatisch generiert - Include wird übersprungen'. APPEND ALL. EXIT. ENDIF. ENDIF. CLEAR FALSCHER_ALARM. DO. IF ZEILE(7) = 'INCLUDE'. EXIT. ELSEIF ZEILE(1) = '"'. FALSCHER_ALARM = 'X'. EXIT. ELSE. SHIFT ZEILE. ENDIF. IF SY-INDEX > 100. FALSCHER_ALARM = 'X'. EXIT. ENDIF. ENDDO. IF FALSCHER_ALARM = SPACE. NAME = ZEILE+8(8). CONCATENATE '*$*$ Start of Include ' NAME INTO ALL SEPARATED BY SPACE. APPEND ALL. REFRESH INC. READ REPORT NAME INTO INC. LOOP AT INC. IF INC CS 'INCLUDE'. PERFORM DO_EXCLUDE USING INC. ELSE. ALL = INC. APPEND ALL. ENDIF. ENDLOOP. CONCATENATE '*$*$ End of Include ' NAME INTO ALL SEPARATED BY SPACE. ELSE. ALL = ZEILE. ENDIF. ELSE. ALL = ZEILE. ENDIF. APPEND ALL. ENDFORM.