Posted: Sat Nov 17, 2007 7:35 pm Post subject: Download any table to the desktop
Download any table to the desktop, regardless of maximum number of rows.
Code:
REPORT ZZBGS101 MESSAGE-ID Z1 LINE-COUNT 65 LINE-SIZE 132
NO STANDARD PAGE HEADING.
*----------------------------------------------------------------------*
* Description: Download any tables to the desktop, without dialog. *
* *
* Implementing:This program dynamic build sourcecode for downloading *
* tables to the PC. The download take place for each 1000 *
* records. The program uses authorization checks to secure*
* that only authorized personal can use the program. *
* *
* WARNING! When naming the dynamic abap/4 program, be sure that the*
* name is not used and will not be used in the future. SAP*
* does not warning you but just overwrite existing program*
* *
* Authoriza- S_TABU_DIS, S_PROGRAM *
* tions: *
* *
* Submitting: Via SA38, SA39 or via batch with variant. *
* *
* Parametre: TABLE: = Tablename *
* PATH: = Target path without the filename *
* *
* Output: File downloaded to <PATH><TABLE>.TXT *
* *
* Customizing: Need no customization . *
* *
* Change of Need no changes. *
* release: *
* *
* Programmer: Benny G. Sørensen, *
* Date: September 1995. *
* *
* SAP Release: R/3 2.2x - 3.0x *
* *
*-------------------------------Corrections----------------------------*
* Date Userid Correction *
*----------------------------------------------------------------------*
TABLES: DD02V
,TDDAT " Maintenance areas for tables
.
*----------------------------------------------------------------------*
* Selection screen definition *
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN:
COMMENT 01(70) TEXT-001.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN:
COMMENT 01(70) TEXT-002.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN:
COMMENT 01(70) TEXT-003.
SELECTION-SCREEN:
ULINE.
SELECTION-SCREEN END OF LINE.
*----------------------------------------------------------------------*
* Table declaration *
*----------------------------------------------------------------------*
PARAMETERS: TABLE LIKE RSRD1-OBJNAME OBLIGATORY
,PATH(60) TYPE C DEFAULT 'C:\SAP\' OBLIGATORY.
.
DATA: BEGIN OF SOURCE OCCURS 80,
LINE(72),
END OF SOURCE.
DATA: BEGIN OF ITAB OCCURS 0,
LINE(72) TYPE C,
END OF ITAB.
DATA: FILENAME(40) TYPE C
,RETURNCODE LIKE SY-SUBRC
,WPATH(40) TYPE C
,LENGTH TYPE I
.
FIELD-SYMBOLS: <PTR>.
*----------------------------------------------------------------------*
* Event: At Selection Screen *
*----------------------------------------------------------------------*
AT SELECTION-SCREEN.
SELECT SINGLE * FROM DD02V
WHERE TABNAME = TABLE
AND DDLANGUAGE = SY-LANGU.
IF SY-SUBRC NE 0.
MESSAGE E400.
ENDIF.
SELECT SINGLE * FROM TDDAT
WHERE TABNAME = DD02V-TABNAME.
AUTHORITY-CHECK OBJECT 'S_TABU_DIS'
ID 'ACTVT' FIELD '03'
ID 'DICBERCLS' FIELD TDDAT-CCLASS.
IF SY-SUBRC NE 0.
MESSAGE I100.
ENDIF.
AUTHORITY-CHECK OBJECT 'S_PROGRAM'
ID 'P_GROUP' FIELD 'ZZBCU128'
ID 'P_ACTION' DUMMY.
IF SY-SUBRC NE 0.
MESSAGE I100.
ENDIF.
* ---------------------------------------------------------------------*
* Event Start-of-selection *
* ---------------------------------------------------------------------*
START-OF-SELECTION.
AUTHORITY-CHECK OBJECT 'S_PROGRAM'
ID 'P_GROUP' FIELD 'ZZBCU128'
ID 'P_ACTION' DUMMY.
IF SY-SUBRC NE 0.
MESSAGE E100.
ENDIF.
AUTHORITY-CHECK OBJECT 'S_TABU_DIS'
ID 'ACTVT' FIELD '03'
ID 'DICBERCLS' FIELD TDDAT-CCLASS.
IF SY-SUBRC NE 0.
MESSAGE E100.
ENDIF.
* Validate parameter
CHECK TABLE NE SPACE.
CHECK PATH NE SPACE.
* Asure path ending with a slash
CONDENSE PATH.
LENGTH = STRLEN( PATH ).
SUBTRACT 1 FROM LENGTH.
ASSIGN PATH+LENGTH(1) TO <PTR>.
IF <PTR> NE '\'.
ADD 1 TO LENGTH.
ASSIGN PATH+LENGTH(1) TO <PTR>.
MOVE '\' TO <PTR>.
ENDIF.
SOURCE = 'REPORT ZZBGS### .' . APPEND SOURCE.
SOURCE = 'TABLES: &.'.
REPLACE '&' WITH TABLE INTO SOURCE. APPEND SOURCE.
SOURCE = 'DATA: BEGIN OF TAB OCCURS 0.'. APPEND SOURCE.
SOURCE = ' INCLUDE STRUCTURE &.'.
REPLACE '&' WITH TABLE INTO SOURCE. APPEND SOURCE.
SOURCE = 'DATA: END OF TAB. '. APPEND SOURCE.
SOURCE = 'DATA: BEGIN OF OUT OCCURS 0.'. APPEND SOURCE.
SOURCE = ' INCLUDE STRUCTURE &.'.
REPLACE '&' WITH TABLE INTO SOURCE. APPEND SOURCE.
SOURCE = 'DATA: END OF OUT. ' . APPEND SOURCE.
SOURCE = 'DATA: FILENAME(40) TYPE C.'. APPEND SOURCE.
SOURCE = 'DATA: ROWS TYPE I.'. APPEND SOURCE.
SOURCE = 'DATA: I TYPE I.'. APPEND SOURCE.
SOURCE = 'DATA: MODE TYPE C.'. APPEND SOURCE.
* Look for existence of sourcecode
READ REPORT 'ZZBGS###' INTO ITAB.
IF SY-SUBRC > 0.
INSERT REPORT 'ZZBGS###' FROM SOURCE.
ELSE.
MESSAGE E065 WITH 'Error: Sourcecode exist'.
ENDIF.
SUBMIT ZZBGS### AND RETURN.
DELETE REPORT 'ZZBGS###'.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.