Skip to Content
avatar image
Former Member

how can I upload programs to a different system?

hi

I develop on a system which is not my customers.

I can connect to the 2 systems when on my PC but they have no physical connection: i would like to transfer my developed reports which are not in their system, to their test system: any quick way? i do not seem to manage to upload the entire report, screens included!

thanks

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Aug 21, 2007 at 07:05 AM

    [code]----


    • Report: ZKBPROGS *

    ----


    • Function : Up/Download ABAP reports complete with texts *

    ----


    • Change Log : *

    • July 5, 1999 *

    • - Combined existing programs that did the upload and download into*

    • - one program. *

    • - Changed format that the reports are saved in to be compatible *

    • with Wolfgang Morgenthaler's upload/download program(YSTRASN00 *

    • at www.antarcon.de). Major differences between this program and*

    • Wolfgang's are:

    • - this program does not update TRDIR with the *

    • TRDIR entries that are in the program uploaded. Instead, *

    • current users stats are used. *

    • - this program allows selection of reports from a list or *

    • a single report can be tuped in and uploaded *

    • - this program also updates TADIR so that a development class*

    • is assigned to the program *

    • - this program checks to see if the program already has a *

    • TRDIR entry, and if it does, warns the user *

    • - this program will save/restore the program documenation too*

    • *

    • *

    • *

    ----


    REPORT ZKBPROGS

    NO STANDARD PAGE HEADING

    LINE-SIZE 255.

    ----


    • Declare Database Objects *

    ----


    tables:

    DOKIL,

    TRDIR.

    ----


    • Constants*

    CONSTANTS:

    MC_TRDIR_IDENTIFIER(72) TYPE C VALUE '%&%& RDIR',

    MC_REPORT_IDENTIFIER(72) TYPE C VALUE '%&%& REPO',

    MC_TEXT_IDENTIFIER(72) TYPE C VALUE '%&%& TEXP',

    MC_THEAD_IDENTIFIER(72) TYPE C VALUE '%&%& HEAD',

    MC_DOC_IDENTIFIER(72) TYPE C VALUE '%&%& DOKL',

    MC_TRDIR_SHORT(4) TYPE C VALUE 'RDIR',

    MC_REPORT_SHORT(4) TYPE C VALUE 'REPO',

    MC_TEXT_SHORT(4) TYPE C VALUE 'TEXP',

    MC_THEAD_SHORT(4) TYPE C VALUE 'HEAD',

    MC_DOC_SHORT(4) TYPE C VALUE 'DOKP'.

    ----


    ----


    • Declare Module level data structures *

    ----


    DATA: BEGIN OF MTAB_PROGRAM_SOURCE OCCURS 0,

    LINE(72) TYPE C,

    END OF MTAB_PROGRAM_SOURCE.

    DATA: MTAB_PROGRAM_TRDIR LIKE TRDIR OCCURS 0 WITH HEADER LINE.

    DATA: MTAB_PROGRAM_TEXTS LIKE TEXTPOOL OCCURS 0 WITH HEADER LINE.

    DATA: MSTR_THEAD LIKE THEAD.

    DATA: BEGIN OF MTAB_PROGRAM_FILE OCCURS 0,

    LINE(275) TYPE C,

    END OF MTAB_PROGRAM_FILE.

    DATA: BEGIN OF MTAB_DIRECTORY OCCURS 0,

    NAME LIKE TRDIR-NAME,

    DESC(72) TYPE C,

    SAVENAME LIKE RLGRAP-FILENAME,

    END OF MTAB_DIRECTORY.

    DATA: BEGIN OF MTAB_PROGRAM_DOCUMENTATION OCCURS 0,

    LINE(255) TYPE C,

    END OF MTAB_PROGRAM_DOCUMENTATION.

    ----


    • Selection Screen *

    ----


    *-- Options for upload/download of programs

    SELECTION-SCREEN BEGIN OF BLOCK FRM_OPTIONS WITH FRAME TITLE TEXT-UDL.

    PARAMETERS:

    RB_DOWN RADIOBUTTON GROUP UDL DEFAULT 'X'. " Download reports

    SELECTION-SCREEN BEGIN OF BLOCK FRM_TRDIR WITH FRAME TITLE TEXT-DIR.

    SELECT-OPTIONS:

    S_NAME FOR TRDIR-NAME, " Program Name

    S_SUBC FOR TRDIR-SUBC " Program Type

    DEFAULT 'F' OPTION EQ SIGN E," Exclude Functions by default

    S_CNAM FOR TRDIR-CNAM " Created by

    DEFAULT SY-UNAME,

    S_UNAM FOR TRDIR-UNAM, " Last Changed by

    S_CDAT FOR TRDIR-CDAT, " Creation date

    S_UDAT FOR TRDIR-UDAT. " Last update date

    SELECTION-SCREEN END OF BLOCK FRM_TRDIR.

    *-- Options for uploading programs

    PARAMETERS:

    RB_UP RADIOBUTTON GROUP UDL. " Upload reports

    SELECTION-SCREEN BEGIN OF BLOCK FRM_UPLOAD WITH FRAME TITLE TEXT-UPL.

    SELECTION-SCREEN BEGIN OF LINE.

    SELECTION-SCREEN COMMENT 1(29) TEXT-SNG.

    PARAMETERS:

    RB_FILE RADIOBUTTON GROUP HOW DEFAULT 'X'.

    SELECTION-SCREEN COMMENT 33(42) TEXT-FNA.

    SELECTION-SCREEN END OF LINE.

    PARAMETERS:

    RB_LIST RADIOBUTTON GROUP HOW.

    SELECTION-SCREEN END OF BLOCK FRM_UPLOAD.

    SELECTION-SCREEN END OF BLOCK FRM_OPTIONS.

    *-- Options for up/downloading programs

    SELECTION-SCREEN BEGIN OF BLOCK FRM_FILEN WITH FRAME TITLE TEXT-FIL.

    PARAMETERS:

    RB_DOS RADIOBUTTON GROUP FIL DEFAULT 'X', " Save to local

    RB_UNIX RADIOBUTTON GROUP FIL, " Save to UNIX

    P_PATH LIKE RLGRAP-FILENAME " Path to save files to

    DEFAULT 'c:\temp\'.

    SELECTION-SCREEN END OF BLOCK FRM_FILEN.

    AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_NAME-LOW.

    CALL FUNCTION 'F4_PROGRAM'

    EXPORTING

    OBJECT = S_NAME-LOW

    SUPPRESS_SELECTION = 'X'

    IMPORTING

    RESULT = S_NAME-LOW

    EXCEPTIONS

    OTHERS = 1.

    AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_NAME-HIGH.

    CALL FUNCTION 'F4_PROGRAM'

    EXPORTING

    OBJECT = S_NAME-HIGH

    SUPPRESS_SELECTION = 'X'

    IMPORTING

    RESULT = S_NAME-HIGH

    EXCEPTIONS

    OTHERS = 1.

    AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_UNAM-LOW.

    PERFORM GET_NAME USING 'S_UNAM-LOW'

    CHANGING S_UNAM-LOW.

    AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_UNAM-HIGH.

    PERFORM GET_NAME USING 'S_UNAM-HIGH'

    CHANGING S_UNAM-HIGH.

    AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_CNAM-LOW.

    PERFORM GET_NAME USING 'S_CNAM-LOW'

    CHANGING S_CNAM-LOW.

    AT SELECTION-SCREEN ON VALUE-REQUEST FOR S_CNAM-HIGH.

    PERFORM GET_NAME USING 'S_CNAM-HIGH'

    CHANGING S_CNAM-HIGH.

    TOP-OF-PAGE.

    IF RB_LIST = 'X'.

    FORMAT COLOR COL_HEADING.

    NEW-LINE.

    WRITE: AT 3 TEXT-H01,

    AT 15 TEXT-H03.

    FORMAT COLOR OFF.

    ENDIF.

    AT LINE-SELECTION.

    CHECK RB_LIST = 'X'. " only do in list mode

    READ LINE SY-CUROW FIELD VALUE MTAB_DIRECTORY-SAVENAME.

    *-- Read file into an internal table

    PERFORM READ_REPORT_FROM_DISK TABLES MTAB_PROGRAM_FILE

    USING MTAB_DIRECTORY-SAVENAME.

    *-- Split table into TADIR entry, report lines, and report text

    PERFORM SPLIT_INCOMING_FILE TABLES MTAB_PROGRAM_FILE

    MTAB_PROGRAM_SOURCE

    MTAB_PROGRAM_TEXTS

    MTAB_PROGRAM_DOCUMENTATION

    CHANGING TRDIR

    MSTR_THEAD.

    *-- Save all of the data

    PERFORM INSERT_NEW_REPORT TABLES MTAB_PROGRAM_SOURCE

    MTAB_PROGRAM_TEXTS

    MTAB_PROGRAM_DOCUMENTATION

    USING TRDIR

    MSTR_THEAD.

    ----


    • Start of processing *

    ----


    START-OF-SELECTION.

    FORMAT COLOR COL_NORMAL.

    IF RB_DOWN = 'X'.

    PERFORM DOWNLOAD_REPORTS.

    ELSEIF RB_UP = 'X'.

    PERFORM UPLOAD_REPORTS.

    ENDIF.

    END-OF-SELECTION.

    IF RB_DOWN = 'X'.

    CONCATENATE P_PATH

    'directory.txt'

    INTO P_PATH.

    PERFORM SAVE_TABLE_TO_FILE TABLES MTAB_DIRECTORY

    USING P_PATH.

    ENDIF.

    ----


    • FORM UPLOAD_REPORTS *

    ----


    FORM UPLOAD_REPORTS.

    *-- Can upload a reports entered in selection criteria or

    *-- select from a list. List can be from index.txt in same directory

    *-- (created by the download) or by reading the first line of each file

    *-- in the directory.

    IF RB_FILE = 'X'. " Upload single program from a file

    *-- Read file into an internal table

    PERFORM READ_REPORT_FROM_DISK TABLES MTAB_PROGRAM_FILE

    USING P_PATH.

    *-- Split table into TADIR entry, report lines, and report text

    PERFORM SPLIT_INCOMING_FILE TABLES MTAB_PROGRAM_FILE

    MTAB_PROGRAM_SOURCE

    MTAB_PROGRAM_TEXTS

    MTAB_PROGRAM_DOCUMENTATION

    CHANGING TRDIR

    MSTR_THEAD.

    *-- Save all of the data

    PERFORM INSERT_NEW_REPORT TABLES MTAB_PROGRAM_SOURCE

    MTAB_PROGRAM_TEXTS

    MTAB_PROGRAM_DOCUMENTATION

    USING TRDIR

    MSTR_THEAD.

    ELSEIF RB_LIST = 'X'. " Show list for user to choose from

    *-- get list of report names/descriptions from directory text

    CONCATENATE P_PATH

    'directory.txt'

    INTO P_PATH.

    PERFORM READ_REPORT_FROM_DISK TABLES MTAB_DIRECTORY

    USING P_PATH.

    SORT MTAB_DIRECTORY.

    *-- Write out list of report names/descriptions

    LOOP AT MTAB_DIRECTORY.

    WRITE:

    / MTAB_DIRECTORY-NAME UNDER TEXT-H01,

    MTAB_DIRECTORY-DESC UNDER TEXT-H03,

    MTAB_DIRECTORY-SAVENAME.

    ENDLOOP.

    *-- Process user selections for reports to upload.

    ENDIF.

    ENDFORM. " upload_reports

    ----


    • FORM DOWNLOAD_REPORTS *

    ----


    • From the user selections, get all programs that meet the *

    • criteria, and save them in ftab_program_directory. *

    • Also save the report to disk. *

    ----


    FORM DOWNLOAD_REPORTS.

    DATA:

    LC_FULL_FILENAME LIKE RLGRAP-FILENAME.

    *-- The table is put into an internal table because the program will

    *-- abend if multiple transfers to a dataset occur within a SELECT/

    *-- ENDSELCT (tested on 3.1H)

    SELECT * FROM TRDIR

    INTO TABLE MTAB_PROGRAM_TRDIR

    WHERE NAME IN S_NAME

    AND SUBC IN S_SUBC

    AND CNAM IN S_CNAM

    AND UNAM IN S_UNAM

    AND CDAT IN S_CDAT

    AND UDAT IN S_UDAT.

    LOOP AT MTAB_PROGRAM_TRDIR.

    *-- Clear out text and source code tables

    CLEAR:

    MTAB_PROGRAM_FILE,

    MTAB_PROGRAM_SOURCE,

    MTAB_PROGRAM_TEXTS,

    MTAB_PROGRAM_DOCUMENTATION.

    REFRESH:

    MTAB_PROGRAM_FILE,

    MTAB_PROGRAM_SOURCE,

    MTAB_PROGRAM_TEXTS,

    MTAB_PROGRAM_DOCUMENTATION.

    *-- Get the report

    READ REPORT MTAB_PROGRAM_TRDIR-NAME INTO MTAB_PROGRAM_SOURCE.

    *-- Get the text for the report

    READ TEXTPOOL MTAB_PROGRAM_TRDIR-NAME INTO MTAB_PROGRAM_TEXTS.

    *-- Get the documentation for the report

    CLEAR DOKIL.

    SELECT * UP TO 1 ROWS FROM DOKIL

    WHERE ID = 'RE'

    AND OBJECT = MTAB_PROGRAM_TRDIR-NAME

    AND LANGU = SY-LANGU

    AND TYP = 'E'

    ORDER BY VERSION DESCENDING.

    ENDSELECT.

    *-- Documentation exists for this object

    IF SY-SUBRC = 0.

    CALL FUNCTION 'DOCU_READ'

    EXPORTING

    ID = DOKIL-ID

    LANGU = DOKIL-LANGU

    OBJECT = DOKIL-OBJECT

    TYP = DOKIL-TYP

    VERSION = DOKIL-VERSION

    IMPORTING

    HEAD = MSTR_THEAD

    TABLES

    LINE = MTAB_PROGRAM_DOCUMENTATION

    EXCEPTIONS

    OTHERS = 1.

    ENDIF.

    *-- Put the report code and texts into a single file

    *-- Put the identifier line in so that the start of the TRDIR line

    *-- is marked

    CONCATENATE MC_TRDIR_IDENTIFIER

    MTAB_PROGRAM_TRDIR-NAME

    INTO MTAB_PROGRAM_FILE-LINE.

    APPEND MTAB_PROGRAM_FILE.

    *-- Add the TRDIR line

    MTAB_PROGRAM_FILE-LINE = MTAB_PROGRAM_TRDIR.

    APPEND MTAB_PROGRAM_FILE.

    *-- Put the identifier line in so that the start of the report code

    *-- is marked

    CONCATENATE MC_REPORT_IDENTIFIER

    MTAB_PROGRAM_TRDIR-NAME

    INTO MTAB_PROGRAM_FILE-LINE.

    APPEND MTAB_PROGRAM_FILE.

    *-- Add the report code

    LOOP AT MTAB_PROGRAM_SOURCE.

    MTAB_PROGRAM_FILE = MTAB_PROGRAM_SOURCE.

    APPEND MTAB_PROGRAM_FILE.

    ENDLOOP.

    *-- Put the identifier line in so that the start of the report text

    *-- is marked

    CONCATENATE MC_TEXT_IDENTIFIER

    MTAB_PROGRAM_TRDIR-NAME

    INTO MTAB_PROGRAM_FILE-LINE.

    APPEND MTAB_PROGRAM_FILE.

    *-- Add the report texts

    LOOP AT MTAB_PROGRAM_TEXTS.

    MTAB_PROGRAM_FILE = MTAB_PROGRAM_TEXTS.

    APPEND MTAB_PROGRAM_FILE.

    ENDLOOP.

    *-- Put the identifier line in so that the start of the THEAD record

    *-- is marked

    CONCATENATE MC_THEAD_IDENTIFIER

    MTAB_PROGRAM_TRDIR-NAME

    INTO MTAB_PROGRAM_FILE-LINE.

    APPEND MTAB_PROGRAM_FILE.

    MTAB_PROGRAM_FILE = MSTR_THEAD.

    APPEND MTAB_PROGRAM_FILE.

    *-- Put the identifier line in so that the start of the report

    *-- documentation is marked

    CONCATENATE MC_DOC_IDENTIFIER

    MTAB_PROGRAM_TRDIR-NAME

    INTO MTAB_PROGRAM_FILE-LINE.

    APPEND MTAB_PROGRAM_FILE.

    *-- Add the report documentation

    LOOP AT MTAB_PROGRAM_DOCUMENTATION.

    MTAB_PROGRAM_FILE = MTAB_PROGRAM_DOCUMENTATION.

    APPEND MTAB_PROGRAM_FILE.

    ENDLOOP.

    *-- Make the fully pathed filename that report will be saved to

    CONCATENATE P_PATH

    MTAB_PROGRAM_TRDIR-NAME

    '.txt'

    INTO LC_FULL_FILENAME.

    PERFORM SAVE_TABLE_TO_FILE TABLES MTAB_PROGRAM_FILE

    USING LC_FULL_FILENAME.

    *-- Write out message with Program Name/Description

    READ TABLE MTAB_PROGRAM_TEXTS WITH KEY ID = 'R'.

    IF SY-SUBRC = 0.

    MTAB_DIRECTORY-NAME = MTAB_PROGRAM_TRDIR-NAME.

    MTAB_DIRECTORY-DESC = MTAB_PROGRAM_TEXTS-ENTRY.

    MTAB_DIRECTORY-SAVENAME = LC_FULL_FILENAME.

    APPEND MTAB_DIRECTORY.

    WRITE: / MTAB_PROGRAM_TRDIR-NAME,

    MTAB_PROGRAM_TEXTS-ENTRY(65) COLOR COL_HEADING.

    ELSE.

    MTAB_DIRECTORY-NAME = MTAB_PROGRAM_TRDIR-NAME.

    MTAB_DIRECTORY-DESC = 'No description available'.

    MTAB_DIRECTORY-SAVENAME = LC_FULL_FILENAME.

    APPEND MTAB_DIRECTORY.

    WRITE: / MTAB_PROGRAM_TRDIR-NAME.

    ENDIF.

    ENDLOOP.

    ENDFORM. " BUILD_PROGRAM_DIRECTORY

    ----


    • FORM SAVE_TABLE_TO_FILE *

    ----


    • ........ *

    ----


    • --> FTAB_TABLE *

    • --> F_FILENAME *

    ----


    FORM SAVE_TABLE_TO_FILE TABLES FTAB_TABLE

    USING F_FILENAME.

    IF RB_DOS = 'X'. " Save file to presentation server

    CALL FUNCTION 'WS_DOWNLOAD'

    EXPORTING

    FILENAME = F_FILENAME

    FILETYPE = 'ASC'

    TABLES

    DATA_TAB = FTAB_TABLE

    EXCEPTIONS

    OTHERS = 4.

    IF SY-SUBRC NE 0.

    WRITE: / 'Error opening dataset' COLOR COL_NEGATIVE,

    F_FILENAME COLOR COL_NEGATIVE.

    ENDIF.

    ELSE. " Save file to application server

    OPEN DATASET F_FILENAME FOR OUTPUT IN TEXT MODE.

    IF SY-SUBRC = 0.

    LOOP AT FTAB_TABLE.

    TRANSFER FTAB_TABLE TO F_FILENAME.

    IF SY-SUBRC NE 0.

    WRITE: / 'Error writing record to file;' COLOR COL_NEGATIVE,

    F_FILENAME COLOR COL_NEGATIVE.

    ENDIF.

    ENDLOOP.

    ELSE.

    WRITE: / 'Error opening dataset' COLOR COL_NEGATIVE,

    F_FILENAME COLOR COL_NEGATIVE.

    ENDIF.

    ENDIF. " End RB_DOS

    ENDFORM. " SAVE_PROGRAM

    ----


    • FORM READ_REPORT_FROM_DISK *

    ----


    • Read report into internal table. Can read from local or *

    • remote computer *

    ----


    FORM READ_REPORT_FROM_DISK TABLES FTAB_TABLE

    USING F_FILENAME.

    DATA:

    LC_MESSAGE(128) TYPE C.

    CLEAR FTAB_TABLE.

    REFRESH FTAB_TABLE.

    IF RB_DOS = 'X'.

    TRANSLATE F_FILENAME USING '/\'. " correct slash for Dos PC file

    CALL FUNCTION 'WS_UPLOAD'

    EXPORTING

    FILENAME = F_FILENAME

    FILETYPE = 'ASC'

    TABLES

    DATA_TAB = FTAB_TABLE

    EXCEPTIONS

    CONVERSION_ERROR = 1

    FILE_OPEN_ERROR = 2

    FILE_READ_ERROR = 3

    INVALID_TABLE_WIDTH = 4

    INVALID_TYPE = 5

    NO_BATCH = 6

    UNKNOWN_ERROR = 7

    OTHERS = 8.

    IF SY-SUBRC >< 0.

    WRITE: / 'Error reading file from local PC' COLOR COL_NEGATIVE.

    ENDIF.

    ELSEIF RB_UNIX = 'X'.

    TRANSLATE F_FILENAME USING '\/'. " correct slash for unix

    OPEN DATASET F_FILENAME FOR INPUT MESSAGE LC_MESSAGE IN TEXT MODE.

    IF SY-SUBRC = 0.

    DO.

    READ DATASET F_FILENAME INTO FTAB_TABLE.

    IF SY-SUBRC = 0.

    APPEND FTAB_TABLE.

    ELSE.

    EXIT.

    ENDIF.

    ENDDO.

    CLOSE DATASET F_FILENAME.

    ELSE.

    WRITE: / 'Error reading file from remote computer'

    COLOR COL_NEGATIVE,

    / LC_MESSAGE,

    / F_FILENAME.

    SY-SUBRC = 4.

    ENDIF.

    ENDIF.

    ENDFORM. " READ_REPORT_FROM_DISK

    ----


    • FORM SPLIT_INCOMING_FILE *

    ----


    • ........ *

    ----


    • --> FTAB_PROGRAM_FILE *

    • --> FTAB_PROGRAM_SOURCE *

    • --> ` *

    • --> FTAB_PROGRAM_TEXTS *

    ----


    FORM SPLIT_INCOMING_FILE TABLES FTAB_PROGRAM_FILE

    STRUCTURE MTAB_PROGRAM_FILE

    FTAB_PROGRAM_SOURCE

    STRUCTURE MTAB_PROGRAM_SOURCE

    FTAB_PROGRAM_TEXTS

    STRUCTURE MTAB_PROGRAM_TEXTS

    FTAB_PROGRAM_DOCUMENTATION

    STRUCTURE MTAB_PROGRAM_DOCUMENTATION

    CHANGING FSTR_TRDIR

    FSTR_THEAD.

    DATA:

    LC_DATATYPE(4) TYPE C, " Type of data, REPO, TEXP, RDIR

    LC_PROGRAM_FILE LIKE MTAB_PROGRAM_FILE.

    LOOP AT FTAB_PROGRAM_FILE.

    LC_PROGRAM_FILE = FTAB_PROGRAM_FILE.

    CASE LC_PROGRAM_FILE(9).

    WHEN MC_TRDIR_IDENTIFIER.

    LC_DATATYPE = MC_TRDIR_SHORT.

    WHEN MC_REPORT_IDENTIFIER.

    LC_DATATYPE = MC_REPORT_SHORT.

    WHEN MC_TEXT_IDENTIFIER.

    LC_DATATYPE = MC_TEXT_SHORT.

    WHEN MC_DOC_IDENTIFIER.

    LC_DATATYPE = MC_DOC_SHORT.

    WHEN MC_THEAD_IDENTIFIER.

    LC_DATATYPE = MC_THEAD_SHORT.

    WHEN OTHERS. " Actual contents of report, trdir, or text

    CASE LC_DATATYPE.

    WHEN MC_TRDIR_SHORT.

    FSTR_TRDIR = FTAB_PROGRAM_FILE.

    WHEN MC_REPORT_SHORT.

    FTAB_PROGRAM_SOURCE = FTAB_PROGRAM_FILE.

    APPEND FTAB_PROGRAM_SOURCE.

    WHEN MC_TEXT_SHORT.

    FTAB_PROGRAM_TEXTS = FTAB_PROGRAM_FILE.

    APPEND FTAB_PROGRAM_TEXTS.

    WHEN MC_THEAD_SHORT.

    FSTR_THEAD = FTAB_PROGRAM_FILE.

    WHEN MC_DOC_SHORT.

    FTAB_PROGRAM_DOCUMENTATION = FTAB_PROGRAM_FILE.

    APPEND FTAB_PROGRAM_DOCUMENTATION.

    ENDCASE.

    ENDCASE.

    ENDLOOP.

    ENDFORM. " SPLIT_INCOMING_FILE

    ----


    • FORM INSERT_NEW_REPORT*

    ----


    • ........ *

    ----


    • --> FTAB_PROGRAM_SOURCE *

    • --> FTAB_PROGRAM_TEXTS *

    • --> F_TRDIR *

    ----


    FORM INSERT_NEW_REPORT TABLES FTAB_PROGRAM_SOURCE

    STRUCTURE MTAB_PROGRAM_SOURCE

    FTAB_PROGRAM_TEXTS

    STRUCTURE MTAB_PROGRAM_TEXTS

    FTAB_PROGRAM_DOCUMENTATION

    STRUCTURE MTAB_PROGRAM_DOCUMENTATION

    USING FSTR_TRDIR LIKE TRDIR

    FSTR_THEAD LIKE MSTR_THEAD.

    DATA:

    LC_OBJ_NAME LIKE E071-OBJ_NAME,

    LC_LINE2(40) TYPE C,

    LC_ANSWER(1) TYPE C.

    *-- read trdir to see if the report already exists, if it does, prompt

    *-- user to overwrite or abort.

    SELECT SINGLE * FROM TRDIR WHERE NAME = FSTR_TRDIR-NAME.

    IF SY-SUBRC = 0. " Already exists

    CONCATENATE 'want to overwrite report'

    FSTR_TRDIR-NAME

    INTO LC_LINE2 SEPARATED BY SPACE.

    CONCATENATE LC_LINE2

    '?'

    INTO LC_LINE2.

    CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'

    EXPORTING

    DEFAULTOPTION = 'N'

    TEXTLINE1 = 'The selected report already exists, do you'

    TEXTLINE2 = LC_LINE2

    TITEL = 'Report already exists'

    CANCEL_DISPLAY = SPACE

    IMPORTING

    ANSWER = LC_ANSWER

    EXCEPTIONS

    OTHERS = 1.

    ELSE.

    LC_ANSWER = 'J'.

    ENDIF.

    IF LC_ANSWER = 'J'.

    *-- Create the TADIR entry. (TRDIR entry created by INSERT REPORT)

    LC_OBJ_NAME = TRDIR-NAME.

    CALL FUNCTION 'TR_TADIR_POPUP_ENTRY_E071'

    EXPORTING

    WI_E071_PGMID = 'R3TR'

    WI_E071_OBJECT = 'PROG'

    WI_E071_OBJ_NAME = LC_OBJ_NAME

    WI_TADIR_DEVCLASS = '$TMP'

    EXCEPTIONS

    EXIT = 3

    OTHERS = 4.

    IF SY-SUBRC = 0.

    *-- Create Report

    INSERT REPORT FSTR_TRDIR-NAME FROM FTAB_PROGRAM_SOURCE.

    *-- Create Texts

    INSERT TEXTPOOL FSTR_TRDIR-NAME FROM FTAB_PROGRAM_TEXTS

    LANGUAGE SY-LANGU.

    *-- Save Documentation

    CALL FUNCTION 'DOCU_UPDATE'

    EXPORTING

    HEAD = FSTR_THEAD

    STATE = 'A'

    TYP = 'E'

    VERSION = '1'

    TABLES

    LINE = FTAB_PROGRAM_DOCUMENTATION

    EXCEPTIONS

    OTHERS = 1.

    ELSE.

    WRITE: / 'Error updating the TADIR entry' COLOR COL_NEGATIVE,

    'Program' COLOR COL_NEGATIVE INTENSIFIED OFF,

    FSTR_TRDIR-NAME, 'was not loaded into SAP.'

    COLOR COL_NEGATIVE INTENSIFIED OFF.

    ENDIF.

    ELSE.

    WRITE: / FSTR_TRDIR-NAME COLOR COL_NEGATIVE,

    'was not uploaded into SAP. Action cancelled by user'

    COLOR COL_NEGATIVE INTENSIFIED OFF.

    ENDIF.

    ENDFORM. " INSERT_NEW_REPORT

    ----


    • FORM GET_NAME *

    ----


    • ........ *

    ----


    • --> VALUE(F_FIELD) *

    • --> F_NAME *

    ----


    FORM GET_NAME USING VALUE(F_FIELD)

    CHANGING F_NAME.

    DATA: LTAB_FIELDS LIKE DYNPREAD OCCURS 0 WITH HEADER LINE,

    LC_PROG LIKE D020S-PROG,

    LC_DNUM LIKE D020S-DNUM.

    TRANSLATE F_FIELD TO UPPER CASE.

    refresh ltab_fields.

    LTAB_FIELDS-FIELDNAME = F_FIELD.

    append ltab_fields.

    LC_PROG = SY-REPID .

    LC_DNUM = SY-DYNNR .

    CALL FUNCTION 'DYNP_VALUES_READ'

    EXPORTING

    DYNAME = LC_PROG

    DYNUMB = LC_DNUM

    TABLES

    dynpfields = ltab_fields

    EXCEPTIONS

    OTHERS = 01.

    read table ltab_fields index 1.

    IF SY-SUBRC EQ 0.

    F_NAME = LTAB_FIELDS-FIELDVALUE.

    refresh ltab_fields.

    ENDIF.

    CALL FUNCTION 'F4_USER'

    EXPORTING

    OBJECT = F_NAME

    IMPORTING

    RESULT = F_NAME.

    ENDFORM. " GET_NAME[/code]

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 21, 2007 at 01:23 PM

    thanks for the reply

    program can be inserted in one system but the other is a system who is unicode compatible! even if i uncheck the "unicode check" in the attributes, i get an error and the system will not let me continue.

    changing to make the fields compatible seems a very long task in this case....

    also, the program in the system where non unicode can work, does not seem to upload the report....i get an empty file in the designated dir.

    any suggestions?.

    Add comment
    10|10000 characters needed characters exceeded

    • It's an old code, I have check in my system, I have corrected tree lines and it works.

      [code]----


      • Report: ZKBPROGS *

      ----


      • Function : Up/Download ABAP reports complete with texts *

      ----


      • Change Log : *

      • July 5, 1999 *

      • - Combined existing programs that did the upload and download into*

      • - one program. *

      • - Changed format that the reports are saved in to be compatible *

      • with Wolfgang Morgenthaler's upload/download program(YSTRASN00 *

      • at www.antarcon.de). Major differences between this program and*

      • Wolfgang's are:

      • - this program does not update TRDIR with the *

      • TRDIR entries that are in the program uploaded. Instead, *

      • current users stats are used. *

      • - this program allows selection of reports from a list or *

      • a single report can be tuped in and uploaded *

      • - this program also updates TADIR so that a development class*

      • is assigned to the program *

      • - this program checks to see if the program already has a *

      • TRDIR entry, and if it does, warns the user *

      • - this program will save/restore the program documenation too*

      • *

      • *

      • *

      ----


      REPORT zkbprogs

      NO STANDARD PAGE HEADING

      LINE-SIZE 255.

      ----


      • Declare Database Objects *

      ----


      TABLES:

      dokil,

      trdir.

      ----


      • Constants*

      CONSTANTS:

      mc_trdir_identifier(72) TYPE c VALUE '%&%& RDIR',

      mc_report_identifier(72) TYPE c VALUE '%&%& REPO',

      mc_text_identifier(72) TYPE c VALUE '%&%& TEXP',

      mc_thead_identifier(72) TYPE c VALUE '%&%& HEAD',

      mc_doc_identifier(72) TYPE c VALUE '%&%& DOKL',

      mc_trdir_short(4) TYPE c VALUE 'RDIR',

      mc_report_short(4) TYPE c VALUE 'REPO',

      mc_text_short(4) TYPE c VALUE 'TEXP',

      mc_thead_short(4) TYPE c VALUE 'HEAD',

      mc_doc_short(4) TYPE c VALUE 'DOKP'.

      ----


      ----


      • Declare Module level data structures *

      ----


      DATA: BEGIN OF mtab_program_source OCCURS 0,

      line(72) TYPE c,

      END OF mtab_program_source.

      DATA: mtab_program_trdir LIKE trdir OCCURS 0 WITH HEADER LINE.

      DATA: mtab_program_texts LIKE textpool OCCURS 0 WITH HEADER LINE.

      DATA: mstr_thead LIKE thead.

      DATA: BEGIN OF mtab_program_file OCCURS 0,

      line(264) TYPE c,

      END OF mtab_program_file.

      DATA: BEGIN OF mtab_directory OCCURS 0,

      name LIKE trdir-name,

      desc(72) TYPE c,

      savename LIKE rlgrap-filename,

      END OF mtab_directory.

      DATA: BEGIN OF mtab_program_documentation OCCURS 0,

      line(255) TYPE c,

      END OF mtab_program_documentation.

      ----


      • Selection Screen *

      ----


      *-- Options for upload/download of programs

      SELECTION-SCREEN BEGIN OF BLOCK frm_options WITH FRAME TITLE text-udl.

      PARAMETERS:

      rb_down RADIOBUTTON GROUP udl DEFAULT 'X'. " Download reports

      SELECTION-SCREEN BEGIN OF BLOCK frm_trdir WITH FRAME TITLE text-dir.

      SELECT-OPTIONS:

      s_name FOR trdir-name, " Program Name

      s_subc FOR trdir-subc " Program Type

      DEFAULT 'F' OPTION EQ SIGN E," Exclude Functions by default

      s_cnam FOR trdir-cnam " Created by

      DEFAULT sy-uname,

      s_unam FOR trdir-unam, " Last Changed by

      s_cdat FOR trdir-cdat, " Creation date

      s_udat FOR trdir-udat. " Last update date

      SELECTION-SCREEN END OF BLOCK frm_trdir.

      *-- Options for uploading programs

      PARAMETERS:

      rb_up RADIOBUTTON GROUP udl. " Upload reports

      SELECTION-SCREEN BEGIN OF BLOCK frm_upload WITH FRAME TITLE text-upl.

      SELECTION-SCREEN BEGIN OF LINE.

      SELECTION-SCREEN COMMENT 1(29) text-sng.

      PARAMETERS:

      rb_file RADIOBUTTON GROUP how DEFAULT 'X'.

      SELECTION-SCREEN COMMENT 33(42) text-fna.

      SELECTION-SCREEN END OF LINE.

      PARAMETERS:

      rb_list RADIOBUTTON GROUP how.

      SELECTION-SCREEN END OF BLOCK frm_upload.

      SELECTION-SCREEN END OF BLOCK frm_options.

      *-- Options for up/downloading programs

      SELECTION-SCREEN BEGIN OF BLOCK frm_filen WITH FRAME TITLE text-fil.

      PARAMETERS:

      rb_dos RADIOBUTTON GROUP fil DEFAULT 'X', " Save to local

      rb_unix RADIOBUTTON GROUP fil, " Save to UNIX

      p_path LIKE rlgrap-filename " Path to save files to

      DEFAULT 'c:\temp\'.

      SELECTION-SCREEN END OF BLOCK frm_filen.

      AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_name-low.

      CALL FUNCTION 'F4_PROGRAM'

      EXPORTING

      object = s_name-low

      suppress_selection = 'X'

      IMPORTING

      RESULT = s_name-low

      EXCEPTIONS

      OTHERS = 1.

      AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_name-high.

      CALL FUNCTION 'F4_PROGRAM'

      EXPORTING

      object = s_name-high

      suppress_selection = 'X'

      IMPORTING

      RESULT = s_name-high

      EXCEPTIONS

      OTHERS = 1.

      AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_unam-low.

      PERFORM get_name USING 'S_UNAM-LOW'

      CHANGING s_unam-low.

      AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_unam-high.

      PERFORM get_name USING 'S_UNAM-HIGH'

      CHANGING s_unam-high.

      AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_cnam-low.

      PERFORM get_name USING 'S_CNAM-LOW'

      CHANGING s_cnam-low.

      AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_cnam-high.

      PERFORM get_name USING 'S_CNAM-HIGH'

      CHANGING s_cnam-high.

      TOP-OF-PAGE.

      IF rb_list = 'X'.

      FORMAT COLOR COL_HEADING.

      NEW-LINE.

      WRITE: AT 3 text-h01,

      AT 15 text-h03.

      FORMAT COLOR OFF.

      ENDIF.

      AT LINE-SELECTION.

      CHECK rb_list = 'X'. " only do in list mode

      READ LINE sy-curow FIELD VALUE mtab_directory-savename.

      *-- Read file into an internal table

      PERFORM read_report_from_disk TABLES mtab_program_file

      USING mtab_directory-savename.

      *-- Split table into TADIR entry, report lines, and report text

      PERFORM split_incoming_file TABLES mtab_program_file

      mtab_program_source

      mtab_program_texts

      mtab_program_documentation

      CHANGING trdir

      mstr_thead.

      *-- Save all of the data

      PERFORM insert_new_report TABLES mtab_program_source

      mtab_program_texts

      mtab_program_documentation

      USING trdir

      mstr_thead.

      ----


      • Start of processing *

      ----


      START-OF-SELECTION.

      FORMAT COLOR COL_NORMAL.

      IF rb_down = 'X'.

      PERFORM download_reports.

      ELSEIF rb_up = 'X'.

      PERFORM upload_reports.

      ENDIF.

      END-OF-SELECTION.

      IF rb_down = 'X'.

      CONCATENATE p_path

      'directory.txt'

      INTO p_path.

      PERFORM save_table_to_file TABLES mtab_directory

      USING p_path.

      ENDIF.

      ----


      • FORM UPLOAD_REPORTS *

      ----


      FORM upload_reports.

      *-- Can upload a reports entered in selection criteria or

      *-- select from a list. List can be from index.txt in same directory

      *-- (created by the download) or by reading the first line of each file

      *-- in the directory.

      IF rb_file = 'X'. " Upload single program from a file

      *-- Read file into an internal table

      PERFORM read_report_from_disk TABLES mtab_program_file

      USING p_path.

      *-- Split table into TADIR entry, report lines, and report text

      PERFORM split_incoming_file TABLES mtab_program_file

      mtab_program_source

      mtab_program_texts

      mtab_program_documentation

      CHANGING trdir

      mstr_thead.

      *-- Save all of the data

      PERFORM insert_new_report TABLES mtab_program_source

      mtab_program_texts

      mtab_program_documentation

      USING trdir

      mstr_thead.

      ELSEIF rb_list = 'X'. " Show list for user to choose from

      *-- get list of report names/descriptions from directory text

      CONCATENATE p_path

      'directory.txt'

      INTO p_path.

      PERFORM read_report_from_disk TABLES mtab_directory

      USING p_path.

      SORT mtab_directory.

      *-- Write out list of report names/descriptions

      LOOP AT mtab_directory.

      WRITE:

      / mtab_directory-name UNDER text-h01,

      mtab_directory-desc UNDER text-h03,

      mtab_directory-savename.

      ENDLOOP.

      *-- Process user selections for reports to upload.

      ENDIF.

      ENDFORM. " upload_reports

      ----


      • FORM DOWNLOAD_REPORTS *

      ----


      • From the user selections, get all programs that meet the *

      • criteria, and save them in ftab_program_directory. *

      • Also save the report to disk. *

      ----


      FORM download_reports.

      DATA:

      lc_full_filename LIKE rlgrap-filename.

      *-- The table is put into an internal table because the program will

      *-- abend if multiple transfers to a dataset occur within a SELECT/

      *-- ENDSELCT (tested on 3.1H)

      SELECT * FROM trdir

      INTO TABLE mtab_program_trdir

      WHERE name IN s_name

      AND subc IN s_subc

      AND cnam IN s_cnam

      AND unam IN s_unam

      AND cdat IN s_cdat

      AND udat IN s_udat.

      LOOP AT mtab_program_trdir.

      *-- Clear out text and source code tables

      CLEAR:

      mtab_program_file,

      mtab_program_source,

      mtab_program_texts,

      mtab_program_documentation.

      REFRESH:

      mtab_program_file,

      mtab_program_source,

      mtab_program_texts,

      mtab_program_documentation.

      *-- Get the report

      READ REPORT mtab_program_trdir-name INTO mtab_program_source.

      *-- Get the text for the report

      READ TEXTPOOL mtab_program_trdir-name INTO mtab_program_texts.

      *-- Get the documentation for the report

      CLEAR dokil.

      SELECT * UP TO 1 ROWS FROM dokil

      WHERE id = 'RE'

      AND object = mtab_program_trdir-name

      AND langu = sy-langu

      AND typ = 'E'

      ORDER BY version DESCENDING.

      ENDSELECT.

      *-- Documentation exists for this object

      IF sy-subrc = 0.

      CALL FUNCTION 'DOCU_READ'

      EXPORTING

      id = dokil-id

      langu = dokil-langu

      object = dokil-object

      typ = dokil-typ

      version = dokil-version

      IMPORTING

      head = mstr_thead

      TABLES

      line = mtab_program_documentation

      EXCEPTIONS

      OTHERS = 1.

      ENDIF.

      *-- Put the report code and texts into a single file

      *-- Put the identifier line in so that the start of the TRDIR line

      *-- is marked

      CONCATENATE mc_trdir_identifier

      mtab_program_trdir-name

      INTO mtab_program_file-line.

      APPEND mtab_program_file.

      *-- Add the TRDIR line

      mtab_program_file-line = mtab_program_trdir.

      APPEND mtab_program_file.

      *-- Put the identifier line in so that the start of the report code

      *-- is marked

      CONCATENATE mc_report_identifier

      mtab_program_trdir-name

      INTO mtab_program_file-line.

      APPEND mtab_program_file.

      *-- Add the report code

      LOOP AT mtab_program_source.

      mtab_program_file = mtab_program_source.

      APPEND mtab_program_file.

      ENDLOOP.

      *-- Put the identifier line in so that the start of the report text

      *-- is marked

      CONCATENATE mc_text_identifier

      mtab_program_trdir-name

      INTO mtab_program_file-line.

      APPEND mtab_program_file.

      *-- Add the report texts

      LOOP AT mtab_program_texts.

      MOVE mtab_program_texts TO mtab_program_file.

      APPEND mtab_program_file.

      ENDLOOP.

      *-- Put the identifier line in so that the start of the THEAD record

      *-- is marked

      CONCATENATE mc_thead_identifier

      mtab_program_trdir-name

      INTO mtab_program_file-line.

      APPEND mtab_program_file.

      mtab_program_file = mstr_thead.

      APPEND mtab_program_file.

      *-- Put the identifier line in so that the start of the report

      *-- documentation is marked

      CONCATENATE mc_doc_identifier

      mtab_program_trdir-name

      INTO mtab_program_file-line.

      APPEND mtab_program_file.

      *-- Add the report documentation

      LOOP AT mtab_program_documentation.

      mtab_program_file = mtab_program_documentation.

      APPEND mtab_program_file.

      ENDLOOP.

      *-- Make the fully pathed filename that report will be saved to

      CONCATENATE p_path

      mtab_program_trdir-name

      '.txt'

      INTO lc_full_filename.

      PERFORM save_table_to_file TABLES mtab_program_file

      USING lc_full_filename.

      *-- Write out message with Program Name/Description

      READ TABLE mtab_program_texts WITH KEY id = 'R'.

      IF sy-subrc = 0.

      mtab_directory-name = mtab_program_trdir-name.

      mtab_directory-desc = mtab_program_texts-entry.

      mtab_directory-savename = lc_full_filename.

      APPEND mtab_directory.

      WRITE: / mtab_program_trdir-name,

      mtab_program_texts-entry(65) COLOR COL_HEADING.

      ELSE.

      mtab_directory-name = mtab_program_trdir-name.

      mtab_directory-desc = 'No description available'.

      mtab_directory-savename = lc_full_filename.

      APPEND mtab_directory.

      WRITE: / mtab_program_trdir-name.

      ENDIF.

      ENDLOOP.

      ENDFORM. " BUILD_PROGRAM_DIRECTORY

      ----


      • FORM SAVE_TABLE_TO_FILE *

      ----


      • ........ *

      ----


      • --> FTAB_TABLE *

      • --> F_FILENAME *

      ----


      FORM save_table_to_file TABLES ftab_table

      USING f_filename.

      IF rb_dos = 'X'. " Save file to presentation server

      CALL FUNCTION 'WS_DOWNLOAD'

      EXPORTING

      filename = f_filename

      filetype = 'ASC'

      TABLES

      data_tab = ftab_table

      EXCEPTIONS

      OTHERS = 4.

      IF sy-subrc NE 0.

      WRITE: / 'Error opening dataset' COLOR COL_NEGATIVE,

      f_filename COLOR COL_NEGATIVE.

      ENDIF.

      ELSE. " Save file to application server

      OPEN DATASET f_filename FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

      IF sy-subrc = 0.

      LOOP AT ftab_table.

      TRANSFER ftab_table TO f_filename.

      IF sy-subrc NE 0.

      WRITE: / 'Error writing record to file;' COLOR COL_NEGATIVE,

      f_filename COLOR COL_NEGATIVE.

      ENDIF.

      ENDLOOP.

      ELSE.

      WRITE: / 'Error opening dataset' COLOR COL_NEGATIVE,

      f_filename COLOR COL_NEGATIVE.

      ENDIF.

      ENDIF. " End RB_DOS

      ENDFORM. " SAVE_PROGRAM

      ----


      • FORM READ_REPORT_FROM_DISK *

      ----


      • Read report into internal table. Can read from local or *

      • remote computer *

      ----


      FORM read_report_from_disk TABLES ftab_table

      USING f_filename.

      DATA:

      lc_message(128) TYPE c.

      CLEAR ftab_table.

      REFRESH ftab_table.

      IF rb_dos = 'X'.

      TRANSLATE f_filename USING '/\'. " correct slash for Dos PC file

      CALL FUNCTION 'WS_UPLOAD'

      EXPORTING

      filename = f_filename

      filetype = 'ASC'

      TABLES

      data_tab = ftab_table

      EXCEPTIONS

      conversion_error = 1

      file_open_error = 2

      file_read_error = 3

      invalid_table_width = 4

      invalid_type = 5

      no_batch = 6

      unknown_error = 7

      OTHERS = 8.

      IF sy-subrc >< 0.

      WRITE: / 'Error reading file from local PC' COLOR COL_NEGATIVE.

      ENDIF.

      ELSEIF rb_unix = 'X'.

      TRANSLATE f_filename USING '\/'. " correct slash for unix

      OPEN DATASET f_filename FOR INPUT MESSAGE lc_message IN TEXT MODE ENCODING DEFAULT.

      IF sy-subrc = 0.

      DO.

      READ DATASET f_filename INTO ftab_table.

      IF sy-subrc = 0.

      APPEND ftab_table.

      ELSE.

      EXIT.

      ENDIF.

      ENDDO.

      CLOSE DATASET f_filename.

      ELSE.

      WRITE: / 'Error reading file from remote computer'

      COLOR COL_NEGATIVE,

      / lc_message,

      / f_filename.

      sy-subrc = 4.

      ENDIF.

      ENDIF.

      ENDFORM. " READ_REPORT_FROM_DISK

      ----


      • FORM SPLIT_INCOMING_FILE *

      ----


      • ........ *

      ----


      • --> FTAB_PROGRAM_FILE *

      • --> FTAB_PROGRAM_SOURCE *

      • --> ` *

      • --> FTAB_PROGRAM_TEXTS *

      ----


      FORM split_incoming_file TABLES ftab_program_file

      STRUCTURE mtab_program_file

      ftab_program_source

      STRUCTURE mtab_program_source

      ftab_program_texts

      STRUCTURE mtab_program_texts

      ftab_program_documentation

      STRUCTURE mtab_program_documentation

      CHANGING fstr_trdir

      fstr_thead.

      DATA:

      lc_datatype(4) TYPE c, " Type of data, REPO, TEXP, RDIR

      lc_program_file LIKE mtab_program_file.

      LOOP AT ftab_program_file.

      lc_program_file = ftab_program_file.

      CASE lc_program_file(9).

      WHEN mc_trdir_identifier.

      lc_datatype = mc_trdir_short.

      WHEN mc_report_identifier.

      lc_datatype = mc_report_short.

      WHEN mc_text_identifier.

      lc_datatype = mc_text_short.

      WHEN mc_doc_identifier.

      lc_datatype = mc_doc_short.

      WHEN mc_thead_identifier.

      lc_datatype = mc_thead_short.

      WHEN OTHERS. " Actual contents of report, trdir, or text

      CASE lc_datatype.

      WHEN mc_trdir_short.

      fstr_trdir = ftab_program_file.

      WHEN mc_report_short.

      ftab_program_source = ftab_program_file.

      APPEND ftab_program_source.

      WHEN mc_text_short.

      ftab_program_texts = ftab_program_file.

      APPEND ftab_program_texts.

      WHEN mc_thead_short.

      fstr_thead = ftab_program_file.

      WHEN mc_doc_short.

      ftab_program_documentation = ftab_program_file.

      APPEND ftab_program_documentation.

      ENDCASE.

      ENDCASE.

      ENDLOOP.

      ENDFORM. " SPLIT_INCOMING_FILE

      ----


      • FORM INSERT_NEW_REPORT*

      ----


      • ........ *

      ----


      • --> FTAB_PROGRAM_SOURCE *

      • --> FTAB_PROGRAM_TEXTS *

      • --> F_TRDIR *

      ----


      FORM insert_new_report TABLES ftab_program_source

      STRUCTURE mtab_program_source

      ftab_program_texts

      STRUCTURE mtab_program_texts

      ftab_program_documentation

      STRUCTURE mtab_program_documentation

      USING fstr_trdir LIKE trdir

      fstr_thead LIKE mstr_thead.

      DATA:

      lc_obj_name LIKE e071-obj_name,

      lc_line2(40) TYPE c,

      lc_answer(1) TYPE c.

      *-- read trdir to see if the report already exists, if it does, prompt

      *-- user to overwrite or abort.

      SELECT SINGLE * FROM trdir WHERE name = fstr_trdir-name.

      IF sy-subrc = 0. " Already exists

      CONCATENATE 'want to overwrite report'

      fstr_trdir-name

      INTO lc_line2 SEPARATED BY space.

      CONCATENATE lc_line2

      '?'

      INTO lc_line2.

      CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'

      EXPORTING

      defaultoption = 'N'

      textline1 = 'The selected report already exists, do you'

      textline2 = lc_line2

      titel = 'Report already exists'

      cancel_display = space

      IMPORTING

      answer = lc_answer

      EXCEPTIONS

      OTHERS = 1.

      ELSE.

      lc_answer = 'J'.

      ENDIF.

      IF lc_answer = 'J'.

      *-- Create the TADIR entry. (TRDIR entry created by INSERT REPORT)

      lc_obj_name = trdir-name.

      CALL FUNCTION 'TR_TADIR_POPUP_ENTRY_E071'

      EXPORTING

      wi_e071_pgmid = 'R3TR'

      wi_e071_object = 'PROG'

      wi_e071_obj_name = lc_obj_name

      wi_tadir_devclass = '$TMP'

      EXCEPTIONS

      exit = 3

      OTHERS = 4.

      IF sy-subrc = 0.

      *-- Create Report

      INSERT REPORT fstr_trdir-name FROM ftab_program_source.

      *-- Create Texts

      INSERT textpool fstr_trdir-name FROM ftab_program_texts

      LANGUAGE sy-langu.

      *-- Save Documentation

      CALL FUNCTION 'DOCU_UPDATE'

      EXPORTING

      head = fstr_thead

      state = 'A'

      typ = 'E'

      version = '1'

      TABLES

      line = ftab_program_documentation

      EXCEPTIONS

      OTHERS = 1.

      ELSE.

      WRITE: / 'Error updating the TADIR entry' COLOR COL_NEGATIVE,

      'Program' COLOR COL_NEGATIVE INTENSIFIED OFF,

      fstr_trdir-name, 'was not loaded into SAP.'

      COLOR COL_NEGATIVE INTENSIFIED OFF.

      ENDIF.

      ELSE.

      WRITE: / fstr_trdir-name COLOR COL_NEGATIVE,

      'was not uploaded into SAP. Action cancelled by user'

      COLOR COL_NEGATIVE INTENSIFIED OFF.

      ENDIF.

      ENDFORM. " INSERT_NEW_REPORT

      ----


      • FORM GET_NAME *

      ----


      • ........ *

      ----


      • --> VALUE(F_FIELD) *

      • --> F_NAME *

      ----


      FORM get_name USING value(f_field)

      CHANGING f_name.

      DATA: ltab_fields LIKE dynpread OCCURS 0 WITH HEADER LINE,

      lc_prog LIKE d020s-prog,

      lc_dnum LIKE d020s-dnum.

      TRANSLATE f_field TO UPPER CASE.

      REFRESH ltab_fields.

      ltab_fields-fieldname = f_field.

      APPEND ltab_fields.

      lc_prog = sy-repid .

      lc_dnum = sy-dynnr .

      CALL FUNCTION 'DYNP_VALUES_READ'

      EXPORTING

      dyname = lc_prog

      dynumb = lc_dnum

      TABLES

      dynpfields = ltab_fields

      EXCEPTIONS

      OTHERS = 01.

      READ TABLE ltab_fields INDEX 1.

      IF sy-subrc EQ 0.

      f_name = ltab_fields-fieldvalue.

      REFRESH ltab_fields.

      ENDIF.

      CALL FUNCTION 'F4_USER'

      EXPORTING

      object = f_name

      IMPORTING

      RESULT = f_name.

      ENDFORM. " GET_NAME[/code]