Posted: Sun Nov 04, 2007 3:31 pm Post subject: Upload und download any report with text-symbols
Upload und download any report with text-symbols.
Code:
REPORT ZUPDOWNALL LINE-SIZE 80 NO STANDARD PAGE HEADING.
*
********************** HEADER **************
* 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.
*//////////////////////////////////////////////////////////////////////*
PARAMETERS P_REPID LIKE TRDIR-NAME DEFAULT 'Z*'.
PARAMETERS P_UPLOAD AS CHECKBOX.
SELECTION-SCREEN ULINE.
SELECT-OPTIONS: S_CNAM FOR TRDIR-CNAM DEFAULT SY-UNAME,
S_UNAM FOR TRDIR-UNAM DEFAULT SY-UNAME.
PARAMETERS: P_DATUM LIKE TRDIR-UDAT DEFAULT SY-DATUM OBLIGATORY.
PARAMETERS P_PFAD LIKE RLGRAP-FILENAME DEFAULT
'c:\*'.
PARAMETERS P_EXT(3) DEFAULT 'txt'
LOWER CASE OBLIGATORY.
*----------------------------------------------------------------------*
DATA: BEGIN OF REPPU OCCURS 1000,
PU(72),
END OF REPPU.
*
DATA: BEGIN OF XTEXTPOOL OCCURS 100.
INCLUDE STRUCTURE TEXTPOOL.
DATA: END OF XTEXTPOOL.
*
DATA: BEGIN OF XTRDIR OCCURS 1000.
INCLUDE STRUCTURE TRDIR.
DATA: END OF XTRDIR.
*
DATA: BEGIN OF REPORTS OCCURS 100,
REPID(08),
SPACE2(02),
TEXT(70),
END OF REPORTS.
*----------------------------------------------------------------------*
DATA:
EXT(04) VALUE '.',
FOUND(1) TYPE C,
INHALT(12) VALUE 'Inhalt',
MARK TYPE C VALUE ' ',
ANSWER(1) TYPE C,
STRING(60) TYPE C,
FIRST(1) VALUE 'X'.
DATA:
PFAD LIKE P_PFAD,
I TYPE I,
TITLE LIKE TEXTPOOL-ENTRY.
IF SY-UNAME <> 'IBM-BC'. " <-------------> Username
SKIP 2.
FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
WRITE: / 'Abbruch wegen Berechtigungsproblem !!! '(002).
CHECK 1 = 2.
ENDIF.
WRITE: P_EXT TO EXT+1.
WRITE: EXT TO INHALT+6.
PERFORM READ_DIR TABLES REPORTS.
*
IF P_UPLOAD = 'X'.
PERFORM UPLOAD.
ELSE.
PERFORM DOWNLOAD.
MARK = ''.
PERFORM REPORTS_ANZEIGEN TABLES XTRDIR USING MARK.
ENDIF.
AT LINE-SELECTION.
IF P_UPLOAD = 'X'.
PERFORM REPORT_ANZEIGEN.
ELSE.
PERFORM REPORTS_MERKEN.
ENDIF.
END-OF-SELECTION.
TOP-OF-PAGE.
PERFORM KOPF_ZEILE.
TOP-OF-PAGE DURING LINE-SELECTION.
PERFORM KOPF_ZEILE.
*----------------------------------------------------------------------*
FORM UPLOAD.
DATA:
PFAD LIKE P_PFAD,
TITLE LIKE TEXTPOOL-ENTRY.
*
PFAD = P_PFAD.
REPLACE '*' WITH P_REPID INTO PFAD.
CONDENSE PFAD NO-GAPS.
CONCATENATE PFAD EXT INTO PFAD.
SELECT SINGLE * FROM TRDIR
WHERE NAME = P_REPID.
IF SY-SUBRC = 0.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
TITLEBAR = 'Report already exists'
TEXT_QUESTION = 'Overwrite?'
IMPORTING
ANSWER = ANSWER
EXCEPTIONS
TEXT_NOT_FOUND = 1
OTHERS = 2.
IF ANSWER <> '1'.
STOP.
ENDIF.
REFRESH XTEXTPOOL.
LOOP AT REPPU.
IF REPPU(06) <> '*$*$IO'.
EXIT.
ENDIF.
DELETE REPPU.
*
XTEXTPOOL = REPPU.
SHIFT XTEXTPOOL BY 06 PLACES LEFT.
APPEND XTEXTPOOL.
*
IF XTEXTPOOL-ID = 'R'.
TITLE = XTEXTPOOL-ENTRY.
ENDIF.
ENDLOOP.
*
IF P_REPID(01) = 'Y' OR P_REPID(01) = 'Z'.
INSERT REPORT P_REPID FROM REPPU.
INSERT TEXTPOOL P_REPID FROM XTEXTPOOL LANGUAGE SY-LANGU.
CONCATENATE P_REPID(20) TITLE(40)
INTO STRING
SEPARATED BY SPACE.
WRITE: /3 STRING, 'has imported' INTENSIFIED OFF.
XTRDIR-NAME = P_REPID.
HIDE:
XTRDIR-NAME.
ENDIF.
ENDFORM.
*----------------------------------------------------------------------*
FORM DOWNLOAD.
*
DO.
REPLACE '+' WITH '_' INTO P_REPID.
IF SY-SUBRC <> 0.
EXIT.
ENDIF.
ENDDO.
REPLACE '*' WITH '%' INTO P_REPID.
*
SELECT * FROM TRDIR
INTO TABLE XTRDIR
WHERE NAME LIKE P_REPID
AND CNAM IN S_CNAM
AND UNAM IN S_UNAM
AND UDAT GE P_DATUM.
*
ENDFORM.
*----------------------------------------------------------------------*
FORM READ_DIR
TABLES REPORTS STRUCTURE REPORTS.
DATA:
PFAD LIKE P_PFAD.
*
PFAD = P_PFAD.
IF NOT PFAD CS '*'.
WRITE:/
'Please insert ''*'' into path'.
STOP.
ENDIF.
REPLACE '*' WITH INHALT INTO PFAD.
CONDENSE PFAD NO-GAPS.
*
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
FILENAME = PFAD
FILETYPE = 'ASC'
TABLES
DATA_TAB = REPORTS
EXCEPTIONS
CONVERSION_ERROR = 01
FILE_OPEN_ERROR = 02
FILE_READ_ERROR = 03
INVALID_TABLE_WIDTH = 04
INVALID_TYPE = 05
NO_BATCH = 06
UNKNOWN_ERROR = 07.
CASE SY-SUBRC.
WHEN 0.
WHEN 2.
REFRESH REPORTS.
WHEN OTHERS.
WRITE:/
'Error reading file SY-SUBRC=' NO-GAP,
SY-SUBRC.
STOP.
ENDCASE.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form REPORTS_ANZEIGEN
*&---------------------------------------------------------------------*
FORM REPORTS_ANZEIGEN TABLES XTRDIR STRUCTURE TRDIR USING MARK.
LOOP AT XTRDIR.
WRITE: / MARK AS CHECKBOX,
XTRDIR-NAME(20),
XTRDIR-CNAM, "Ersteller
XTRDIR-CDAT, "Erstellungsdatum
XTRDIR-UNAM, "Änderer
XTRDIR-UDAT, "Änderungsdatum
XTRDIR-VERN. "Version
ENDLOOP.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form REPORTS_MERKEN
*&---------------------------------------------------------------------*
FORM REPORTS_MERKEN.
CHECK P_UPLOAD = ' '.
DATA: REPORT LIKE TRDIR-NAME,
INDEX TYPE I VALUE 1.
CLEAR: FOUND.
SY-LSIND = 0.
DO.
CLEAR: MARK, REPORT.
READ LINE INDEX FIELD VALUE MARK XTRDIR-NAME INTO REPORT.
IF SY-SUBRC NE 0.
EXIT.
ENDIF.
IF NOT MARK IS INITIAL.
FOUND = 'X'.
PERFORM REPORT_DOWNLOAD USING REPORT.
ENDIF.
ADD 1 TO INDEX.
ENDDO.
IF FOUND IS INITIAL.
MESSAGE E300(M1) WITH TEXT-001.
ELSE.
*...Verzeichnis schreiben
PFAD = P_PFAD.
REPLACE '*' WITH INHALT INTO PFAD.
SORT REPORTS.
PERFORM WS_DOWNLOAD TABLES REPORTS USING PFAD.
MARK = ''.
PERFORM REPORTS_ANZEIGEN TABLES XTRDIR USING MARK.
ENDIF.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form REPORT_DOWNLOAD
*&---------------------------------------------------------------------*
FORM REPORT_DOWNLOAD USING REPORT LIKE TRDIR-NAME.
READ REPORT REPORT INTO REPPU.
* Textelemente lesen
READ TEXTPOOL REPORT INTO XTEXTPOOL LANGUAGE SY-LANGU.
DESCRIBE TABLE XTEXTPOOL LINES I.
WHILE I > 0.
READ TABLE XTEXTPOOL INDEX I.
IF XTEXTPOOL-ID = 'R'.
REPORTS-TEXT = XTEXTPOOL-ENTRY(70).
ENDIF.
*
SUBTRACT 1 FROM I.
SHIFT XTEXTPOOL BY 06 PLACES RIGHT.
XTEXTPOOL(06) = '*$*$IO'.
REPPU = XTEXTPOOL.
INSERT REPPU INDEX 1.
ENDWHILE.
*
REPORTS-REPID = REPORT.
COLLECT REPORTS.
*
PFAD = P_PFAD.
REPLACE '*' WITH '**' INTO PFAD.
REPLACE '*' WITH REPORT INTO PFAD.
CONDENSE PFAD NO-GAPS.
REPLACE '*' WITH EXT INTO PFAD.
PERFORM WS_DOWNLOAD TABLES REPPU USING PFAD.
*
ENDFORM.
*&---------------------------------------------------------------------*
*& Form WS_DOWNLOAD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_PFAD text *
* -->P_TABELLE text *
*----------------------------------------------------------------------*
FORM WS_DOWNLOAD TABLES TABELLE
USING PFAD LIKE RLGRAP-FILENAME.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form KOPF_ZEILE
*&---------------------------------------------------------------------*
FORM KOPF_ZEILE.
ENDFORM.
*&---------------------------------------------------------------------*
*& Form REPORT_ANZEIGEN
*&---------------------------------------------------------------------*
FORM REPORT_ANZEIGEN.
READ REPORT XTRDIR-NAME INTO REPPU.
EDITOR-CALL FOR REPPU TITLE REPORTS-REPID DISPLAY-MODE.
ENDFORM.
************************************************************************
*************** END OF PROGRAM ****************************************
************************************************************************
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.