`
jgtang82
  • 浏览: 409538 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Upload and Download ABAP Source Code

    博客分类:
  • ABAP
阅读更多

This is a program that I have had kicking around for a couple of years in various incarnations. I really liked the file format that Wolfgang Morgenthaler had, that I updated my program to use the same format. The one thing that this program does, that Wolfgang's does not is to up/download the program documentation as well as source code and program texts. Wolfgang's Home Page -


Source Code Listing
*----------------------------------------------------------------------*
* 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


Program Texts

DIR             File Download Options (File Selection)
FIL             File Options      
FNA             Enter filename below (under File Options)
H01             Prog Name
H03             Program Description
SNG             Upload a single file
UDL             Upload to SAP/Download from SAP
UPL             File Upload Options
R               Backup/Restore program source code with texts
P_PATH          Path to save programs to
RB_DOS          Files on local computer
RB_DOWN         Download Programs
RB_FILE         Upload a single file
RB_LIST         Select program(s) from a list           
RB_UNIX         Files on remote computer                
RB_UP           Upload Programs to SAP                  
S_CDAT          Date Created        
S_CNAM          Created by UserID   
S_NAME          Program Name        
S_SUBC          Program Type        
S_UDAT          Date Changed        
S_UNAM          Last Changed by UserID  
分享到:
评论

相关推荐

    SAP BEST Excel Upload and Download Class:用于在内部表中上传/下载 Excel 文件的 ABAP 类-开源

    它有两种主要方法:EXCEL_FILE_UPLOAD 和 EXCEL_FILE_DOWNLOAD。 在我看来,这是迄今为止我遇到的最灵活、最稳定、速度最快的一种。 特别有用的是该类能够正确处理包含 CR、LF 和 TAB 的字符字段的上传和下载。 我...

    ABAP Program Tips.pdf

    3.8.8 HIDING ABAP SOURCE CODE.................32 2.1.4 IDOC_TYPE_COMPLETE_READ.........7 3.8.9 WHERE IN IMG IS A TABLE CONFIGURED..32 3.8.10 EDITOR TIPS (*EJECT AND *$*$)............32 2.2 PROGRAMS---...

    洛谷愚人节比赛.pdf

    洛谷愚人节比赛.pdf

    ### 文章总结:北京迅为 iTOP-3568 开发板 Linux 系统开发和应用开发手册. **文档概述

    内容概要:本文档是北京迅为电子有限公司针对iTOP-3568开发板的Linux系统开发和应用开发手册,详细介绍了开发板在Linux系统下的配置与开发方法。手册涵盖Buildroot、Debian、Ubuntu等多个Linux发行版的系统开发笔记,涉及屏幕设置、待机和锁屏、显示颜色格式、分辨率和缩放、静态IP设置、Qt程序操作、开机自启、音频视频和摄像头开发、VNC和ToDesk远程控制软件安装等内容。同时,手册还提供了关于Buildroot编译常见问题的解决方案、U-Boot和内核开发细节,以及IO电源域的配置方法。手册不仅适用于初次接触嵌入式Linux系统的开发者,也适合有一定经验的研发人员深入学习。 适合人群:具备一定编程基础,尤其是对Linux系统和嵌入式开发有一定了解的研发人员,工作1-3年的工程师,以及希望深入了解嵌入式Linux系统开发的爱好者。 使用场景及目标:①帮助用户掌握iTOP-3568开发板在Linux系统下的基本配置与高级开发技巧;②指导用户解决Linux系统开发中遇到的常见问题;③为用户提供详细的编译和调试指南,确保开发板能

    基于MATLAB2020b的CNN-LSTM与GTO算法优化的电力负荷预测研究

    内容概要:本文探讨了基于MATLAB2020b平台,采用CNN-LSTM模型结合人工大猩猩部队(GTO)算法进行电力负荷预测的方法。首先介绍了CNN-LSTM模型的基本结构及其在处理多变量输入(如历史负荷和气象数据)方面的优势。随后详细解释了模型各层的功能,包括卷积层、池化层、LSTM层和全连接层的作用。接着讨论了超参数选择的重要性,并引入GTO算法来进行超参数优化,提高模型预测精度。文中展示了具体的MATLAB代码示例,涵盖了数据预处理、模型构建、训练配置等方面的内容。此外,还分享了一些实践经验,如卷积核配置、LSTM节点数设定等。 适合人群:从事电力系统数据分析的研究人员和技术人员,尤其是对深度学习应用于电力负荷预测感兴趣的读者。 使用场景及目标:适用于需要精确预测未来电力负荷的场合,旨在帮助电力公司更好地规划发电计划,优化资源配置,保障电网安全稳定运行。通过本篇文章的学习,读者可以掌握如何使用MATLAB实现CNN-LSTM模型,并学会运用GTO算法优化超参数,从而提升预测准确性。 其他说明:文章强调了数据质量和预处理步骤的重要性,指出高质量的输入数据能够显著改善预测效果。同时提醒读者注意模型训练过程中的一些常见陷阱,如避免过度拟合等问题。

    TIG焊接工艺中二维电弧仿真的理论与程序实现

    内容概要:本文详细介绍了TIG(钨极惰性气体保护焊)二维电弧仿真的理论基础和程序实现。首先阐述了TIG电弧的本质及其在二维仿真中的数学描述,主要采用磁流体动力学(MHD)方程进行建模。接着展示了如何使用Python生成仿真所需的网格,并初始化温度场、速度场和电场强度等物理参数。随后,通过迭代求解MHD方程,逐步更新各物理量,最终得到电弧内部的温度、速度和电场分布情况。通过对仿真结果的分析,能够深入了解焊接过程中熔化和凝固的现象,从而优化焊接参数,提高焊接质量。 适合人群:从事焊接工程、材料科学及相关领域的研究人员和技术人员,尤其是对TIG焊接工艺感兴趣的学者。 使用场景及目标:适用于希望深入了解TIG焊接过程并希望通过仿真手段优化焊接参数的研究人员。目标是通过仿真更好地理解电弧行为,进而改善焊接质量和效率。 其他说明:文中还提到了一些实用技巧,如网格划分、边界条件设置、求解器选择等方面的注意事项,以及如何使用不同软件工具(如MATLAB、ParaView)进行数据可视化。此外,强调了多语言混合编程的优势,并提供了一些常见的调试和优化建议。

    jenkins操作诶udrtyui897t86r5drctvghuiyft

    jenkins操作诶udrtyui897t86r5drctvghuiyft

    帆软本地打印插件FinePrint 8.0版本

    帆软本地打印插件FinePrint 8.0版本,适用于FineReport8

    基于TMS320F2812的光伏并网逆变器设计与MATLAB仿真及DSP代码实现

    内容概要:本文详细介绍了基于TMS320F2812 DSP芯片的光伏并网逆变器设计方案,涵盖了主电路架构、控制算法、锁相环实现、环流抑制等多个关键技术点。首先,文中阐述了双级式结构的主电路设计,前级Boost升压将光伏板输出电压提升至约600V,后级采用三电平NPC拓扑的IGBT桥进行逆变。接着,深入探讨了核心控制算法,如电流PI调节器、锁相环(SOFGI)、环流抑制等,并提供了详细的MATLAB仿真模型和DSP代码实现。此外,还特别强调了PWM死区时间配置、ADC采样时序等问题的实际解决方案。最终,通过实验验证,该方案实现了THD小于3%,MPPT效率达98.7%,并有效降低了并联环流。 适合人群:从事光伏并网逆变器开发的电力电子工程师和技术研究人员。 使用场景及目标:适用于光伏并网逆变器的研发阶段,帮助工程师理解和实现高效稳定的逆变器控制系统,提高系统的性能指标,减少开发过程中常见的错误。 其他说明:文中提供的MATLAB仿真模型和DSP代码可以作为实际项目开发的重要参考资料,有助于缩短开发周期,提高成功率。

    基于鲸鱼优化算法与深度极限学习机的回归预测模型(WOA-DELM)及其应用

    内容概要:本文详细介绍了如何结合鲸鱼优化算法(WOA)和深度极限学习机(DELM)构建回归预测模型。首先,文章解释了鲸鱼优化算法的基本原理,这是一种受座头鲸群体狩猎行为启发的元启发式优化算法。接着,阐述了深度极限学习机的工作机制,它结合了极限学习机的快速学习能力和深度学习的层次结构。随后,文章展示了如何使用时间窗法处理数据,并构建自动编码器和极限学习机的具体步骤。特别地,文中详细描述了如何利用鲸鱼优化算法优化自动编码器的输入权重与偏置,从而提高模型的预测性能。最后,给出了完整的代码实现,包括数据预处理、模型构建、优化和预测等环节。 适合人群:具备一定机器学习基础的研究人员和技术开发者,尤其是对时间序列预测感兴趣的从业者。 使用场景及目标:适用于需要高精度回归预测的任务,如金融数据分析、能源消耗预测等领域。主要目标是通过优化模型参数,提高预测的准确性。 其他说明:本文提供的代码示例详尽且易于修改,用户只需替换自己的数据路径即可复现实验结果。同时,文中还提供了调参的小技巧,有助于进一步提升模型表现。

    ### 标题:【电动船舶充电通信协议】基于CAN的非船载传导式充电机与电动船舶间数字通信协议设计及应用

    内容概要:T/CIN 029—2024标准规定了非船载传导式充电机与电动船舶之间的数字通信协议,涵盖了一般要求、通信物理层、数据链路层、应用层、充电总体流程、报文分类、格式和内容等方面。该标准旨在确保电动船舶连接到直流电网时,充电机与电池管理系统(BMS)或船舶管理系统(SMS)之间的稳定通信。标准详细定义了各层的通信要求,如物理层的ISO 11898-1和SAE J1939-11规范,数据链路层的CAN扩展帧格式,以及应用层的参数组编号和传输协议。此外,还详细描述了充电的六个阶段(物理连接、低压辅助上电、充电握手、参数配置、充电和结束)的具体流程和涉及的报文格式,确保了充电过程的安全性和可靠性。 适用人群:从事电动船舶充电系统设计、开发、维护的技术人员及工程师;相关行业的研究人员;对电动船舶充电通信协议感兴趣的学者和专业人士。 使用场景及目标:① 为电动船舶充电系统的开发和优化提供技术依据;② 确保充电机与BMS/SMS之间的高效、可靠通信;③ 保障充电过程的安全性和稳定性,防止因通信故障导致的充电中断或事故。 其他说明:本标准由中国航海学会发布,适用于电动船舶连接到直流电网时的充电通信,为电动船舶行业的标准化发展提供了重要支持。标准中还包含了详细的故障诊断代码和报文格式,帮助技术人员快速定位和解决问题。

    vue 基础语法使用心得

    vue 基础语法使用心得

    根据“意见”创新银发经济新模式.pptx

    根据“意见”创新银发经济新模式.pptx

    机械故障诊断中盲反卷积与周期估计的MATLAB实现及应用

    内容概要:本文详细介绍了用于机械故障诊断的盲反卷积方法及其周期估计技术。首先探讨了利用自相关函数和包络谐波乘积谱(EHPS)进行周期估计的方法,提供了具体的MATLAB代码实现。接着阐述了如何将这两种方法集成到盲反卷积框架(如MCKD和CYCBD)中,形成迭代优化的解决方案。文中通过多个实际案例展示了这些方法的有效性和优越性,尤其是在转速波动较大情况下,能够显著提高故障识别率并减少计算时间。 适合人群:从事机械设备状态监测与故障诊断的研究人员和技术人员,尤其是有一定MATLAB编程基础的工程师。 使用场景及目标:适用于各种旋转机械设备(如风力发电机、压缩机、齿轮箱等)的状态监测和故障诊断。主要目标是在缺乏精确转速信息的情况下,通过盲反卷积技术和周期估计方法,从复杂背景噪声中提取出有用的故障特征信号,从而实现高效精准的故障检测。 其他说明:文中不仅提供了详细的理论解释和技术实现步骤,还包括了许多实用的经验技巧,如参数选择、算法优化等方面的内容。此外,作者还强调了不同方法之间的互补性和组合使用的必要性,为读者提供了一个完整的解决方案视角。

    腰髋疼痛医案解析与经典学习.pptx

    腰髋疼痛医案解析与经典学习.pptx

    scipy-0.12.0.tar.gz

    该资源为scipy-0.12.0.tar.gz,欢迎下载使用哦!

    基于Python的二手车爬虫数据可视化分析设计(毕业设计源码)

    用Python开发的爬取二手车网站数据及其分析的程序,爬取的时候采用selenium驱动google浏览器进行数据的抓取,抓取的网页内容传入lxml模块的etree对象HTML方法通过xpath解析DOM树,不过二手车的关键数据比如二手车价格,汽车表显里程数字采用了字体文件加密。据的展示采用pyecharts,它是一个用于生成 Echarts 图表的类库。爬取的数据插入mysql数据库和分析数据读取mysql数据库表都是通过pymysql模块操作。

    机器学习(预测模型):一个包含职员考试结果的数据集

    “Clerk Exam result”数据集是关于职员考试结果的集合,它为研究职员招聘与选拔提供了丰富的数据资源。该数据集可能包含了众多考生的基本信息,如姓名、性别、年龄、学历等,这些信息有助于分析不同背景考生的考试表现差异。考试成绩是数据集的核心部分,它可能涵盖了笔试、面试等多个环节的分数,通过这些分数可以直观地看出考生在专业知识、综合能力等方面的掌握程度。此外,数据集还可能标注了考生是否通过考试,这为研究考试的选拔标准和通过率提供了依据。 从数据的来源来看,它可能是由某个或多个组织在进行职员招聘考试后整理而成,具有一定的权威性和实用性。通过对该数据集的分析,可以发现考试过程中存在的问题,比如某些题目的难度是否过高或过低,以及不同地区、不同岗位的考试难度是否均衡等。同时,它也能为后续的招聘考试提供参考,帮助优化考试流程和内容,提高招聘的科学性和有效性。 然而,需要注意的是,此类数据集可能涉及考生的隐私信息,因此在使用时必须严格遵守相关法律法规,确保数据的安全和合法使用。同时,由于考试内容和标准可能会随着时间、地区和岗位的不同而有所变化,因此在分析数据时也需要考虑到这些因素,避免得出片面或不准确的结论。

    基于Matlab/Simulink的5MW海上永磁直驱风电系统与1200V并网控制策略研究

    内容概要:本文详细介绍了基于Matlab/Simulink平台的5MW海上永磁直驱风电系统及其1200V并网应用。文章首先阐述了系统的整体架构,包括机侧变流器的矢量控制和网侧变流器的直流电压外环+电网电压定向控制。特别强调了滑动平均滤波在功率分配中的应用,以及混合储能系统(超级电容和锂电池)的设计与优化。文中还讨论了关键参数的选择依据,如PI参数整定、PLL模块参数设置等,并展示了仿真过程中遇到的问题及解决方案。此外,文章分享了风速数据处理方法、故障穿越性能测试结果以及模型的实际应用情况。 适合人群:从事风电系统设计、控制工程、电力电子领域的研究人员和技术人员。 使用场景及目标:适用于希望深入了解海上风电系统控制策略的研究人员和技术人员,旨在提高对直驱永磁风电系统的理解和掌握,特别是在复杂工况下的稳定性和效率优化方面。 其他说明:文章提供了详细的代码片段和仿真结果,便于读者复现实验并进行进一步研究。同时,作者提到了一些实用的经验和技巧,有助于解决实际项目中可能遇到的技术难题。

    使用 workerMan 搭建一个简单的聊天室 本项目,实现了聊天室的基础功能,目的就是演示 workerMan 的使用

    使用 workerMan 搭建一个简单的聊天室 本项目,实现了聊天室的基础功能,目的就是演示 workerMan 的使用

Global site tag (gtag.js) - Google Analytics