File Download Program In Abap

0101
File Download Program In Abap 4,4/5 1758 reviews
  1. How To Debug Abap Program

Download and Upload your ABAP program from Local Harddisk Download and Upload your ABAP program from Local Harddisk. Download and Upload your ABAP program from/to your local harddisk. Allows individual or mass transfering of ABAP program. Before using, create a folder c: abap. REPORT ZDOWNUPLOAD NO STANDARD PAGE HEADING LINE-SIZE 255.-. Declare Database Objects.- tables: DOKIL, TRDIR.-.

Constants CONSTANTS: MCTRDIRIDENTIFIER(72) TYPE C VALUE '%&%& RDIR', MCREPORTIDENTIFIER(72) TYPE C VALUE '%&%& REPO', MCTEXTIDENTIFIER(72) TYPE C VALUE '%&%& TEXP', MCTHEADIDENTIFIER(72) TYPE C VALUE '%&%& HEAD', MCDOCIDENTIFIER(72) TYPE C VALUE '%&%& DOKL', MCTRDIRSHORT(4) TYPE C VALUE 'RDIR', MCREPORTSHORT(4) TYPE C VALUE 'REPO', MCTEXTSHORT(4) TYPE C VALUE 'TEXP', MCTHEADSHORT(4) TYPE C VALUE 'HEAD', MCDOCSHORT(4) TYPE C VALUE 'DOKP'.-.-. Declare Module level data structures.- DATA: BEGIN OF MTABPROGRAMSOURCE OCCURS 0, LINE(72) TYPE C, END OF MTABPROGRAMSOURCE. DATA: MTABPROGRAMTRDIR LIKE TRDIR OCCURS 0 WITH HEADER LINE. DATA: MTABPROGRAMTEXTS LIKE TEXTPOOL OCCURS 0 WITH HEADER LINE. DATA: MSTRTHEAD LIKE THEAD. DATA: BEGIN OF MTABPROGRAMFILE OCCURS 0, LINE(275) TYPE C, END OF MTABPROGRAMFILE. DATA: BEGIN OF MTABDIRECTORY OCCURS 0, NAME LIKE TRDIR-NAME, DESC(72) TYPE C, SAVENAME LIKE RLGRAP-FILENAME, END OF MTABDIRECTORY.

DATA: BEGIN OF MTABPROGRAMDOCUMENTATION OCCURS 0, LINE(255) TYPE C, END OF MTABPROGRAMDOCUMENTATION.-. Selection Screen.-.- Options for upload/download of programs SELECTION-SCREEN BEGIN OF BLOCK FRMOPTIONS WITH FRAME TITLE TEXT-UDL.

PARAMETERS: RBDOWN RADIOBUTTON GROUP UDL DEFAULT 'X'. ' Download reports SELECTION-SCREEN BEGIN OF BLOCK FRMTRDIR WITH FRAME TITLE TEXT-DIR. SELECT-OPTIONS: SNAME FOR TRDIR-NAME, ' Program Name SSUBC FOR TRDIR-SUBC ' Program Type DEFAULT 'F' OPTION EQ SIGN E,' Exclude Functions by default SCNAM FOR TRDIR-CNAM ' Created by DEFAULT SY-UNAME, SUNAM FOR TRDIR-UNAM, ' Last Changed by SCDAT FOR TRDIR-CDAT, ' Creation date SUDAT FOR TRDIR-UDAT. ' Last update date SELECTION-SCREEN END OF BLOCK FRMTRDIR.- Options for uploading programs PARAMETERS: RBUP RADIOBUTTON GROUP UDL. ' Upload reports SELECTION-SCREEN BEGIN OF BLOCK FRMUPLOAD WITH FRAME TITLE TEXT-UPL.

SELECTION-SCREEN BEGIN OF LINE. SELECTION-SCREEN COMMENT 1(29) TEXT-SNG.

How To Debug Abap Program

PARAMETERS: RBFILE RADIOBUTTON GROUP HOW DEFAULT 'X'. SELECTION-SCREEN COMMENT 33(42) TEXT-FNA. SELECTION-SCREEN END OF LINE.

PARAMETERS: RBLIST RADIOBUTTON GROUP HOW. SELECTION-SCREEN END OF BLOCK FRMUPLOAD.

SELECTION-SCREEN END OF BLOCK FRMOPTIONS.- Options for up/downloading programs SELECTION-SCREEN BEGIN OF BLOCK FRMFILEN WITH FRAME TITLE TEXT-FIL. PARAMETERS: RBDOS RADIOBUTTON GROUP FIL DEFAULT 'X', ' Save to local RBUNIX RADIOBUTTON GROUP FIL, ' Save to UNIX PPATH LIKE RLGRAP-FILENAME ' Path to save files to DEFAULT 'c: abap '. SELECTION-SCREEN END OF BLOCK FRMFILEN. AT SELECTION-SCREEN ON VALUE-REQUEST FOR SNAME-LOW. CALL FUNCTION 'F4PROGRAM' EXPORTING OBJECT = SNAME-LOW SUPPRESSSELECTION = 'X' IMPORTING RESULT = SNAME-LOW EXCEPTIONS OTHERS = 1.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR SNAME-HIGH. CALL FUNCTION 'F4PROGRAM' EXPORTING OBJECT = SNAME-HIGH SUPPRESSSELECTION = 'X' IMPORTING RESULT = SNAME-HIGH EXCEPTIONS OTHERS = 1.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR SUNAM-LOW. PERFORM GETNAME USING 'SUNAM-LOW' CHANGING SUNAM-LOW. AT SELECTION-SCREEN ON VALUE-REQUEST FOR SUNAM-HIGH. PERFORM GETNAME USING 'SUNAM-HIGH' CHANGING SUNAM-HIGH. AT SELECTION-SCREEN ON VALUE-REQUEST FOR SCNAM-LOW. PERFORM GETNAME USING 'SCNAM-LOW' CHANGING SCNAM-LOW.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR SCNAM-HIGH. PERFORM GETNAME USING 'SCNAM-HIGH' CHANGING SCNAM-HIGH. IF RBLIST = 'X'.

FORMAT COLOR COLHEADING. WRITE: AT 3 TEXT-H01, AT 15 TEXT-H03. FORMAT COLOR OFF. AT LINE-SELECTION. CHECK RBLIST = 'X'. ' only do in list mode READ LINE SY-CUROW FIELD VALUE MTABDIRECTORY-SAVENAME.- Read file into an internal table PERFORM READREPORTFROMDISK TABLES MTABPROGRAMFILE USING MTABDIRECTORY-SAVENAME.- Split table into TADIR entry, report lines, and report text PERFORM SPLITINCOMINGFILE TABLES MTABPROGRAMFILE MTABPROGRAMSOURCE MTABPROGRAMTEXTS MTABPROGRAMDOCUMENTATION CHANGING TRDIR MSTRTHEAD.- Save all of the data PERFORM INSERTNEWREPORT TABLES MTABPROGRAMSOURCE MTABPROGRAMTEXTS MTABPROGRAMDOCUMENTATION USING TRDIR MSTRTHEAD.-. Start of processing.- START-OF-SELECTION.

FORMAT COLOR COLNORMAL. IF RBDOWN = 'X'. PERFORM DOWNLOADREPORTS. ELSEIF RBUP = 'X'. PERFORM UPLOADREPORTS. IF RBDOWN = 'X'.

CONCATENATE PPATH 'directory.txt' INTO PPATH. PERFORM SAVETABLETOFILE TABLES MTABDIRECTORY USING PPATH.-.

FORM UPLOADREPORTS.-. FORM UPLOADREPORTS.- 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 RBFILE = 'X'.

' Upload single program from a file.- Read file into an internal table PERFORM READREPORTFROMDISK TABLES MTABPROGRAMFILE USING PPATH.- Split table into TADIR entry, report lines, and report text PERFORM SPLITINCOMINGFILE TABLES MTABPROGRAMFILE MTABPROGRAMSOURCE MTABPROGRAMTEXTS MTABPROGRAMDOCUMENTATION CHANGING TRDIR MSTRTHEAD.- Save all of the data PERFORM INSERTNEWREPORT TABLES MTABPROGRAMSOURCE MTABPROGRAMTEXTS MTABPROGRAMDOCUMENTATION USING TRDIR MSTRTHEAD. ELSEIF RBLIST = 'X'. ' Show list for user to choose from.- get list of report names/descriptions from directory text CONCATENATE PPATH 'directory.txt' INTO PPATH.

PERFORM READREPORTFROMDISK TABLES MTABDIRECTORY USING PPATH. SORT MTABDIRECTORY.- Write out list of report names/descriptions LOOP AT MTABDIRECTORY. WRITE: / MTABDIRECTORY-NAME UNDER TEXT-H01, MTABDIRECTORY-DESC UNDER TEXT-H03, MTABDIRECTORY-SAVENAME.- Process user selections for reports to upload. ' uploadreports.-. FORM DOWNLOADREPORTS.-. From the user selections, get all programs that meet the.

criteria, and save them in ftabprogramdirectory. Also save the report to disk.-. FORM DOWNLOADREPORTS. DATA: LCFULLFILENAME 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 MTABPROGRAMTRDIR WHERE NAME IN SNAME AND SUBC IN SSUBC AND CNAM IN SCNAM AND UNAM IN SUNAM AND CDAT IN SCDAT AND UDAT IN SUDAT. LOOP AT MTABPROGRAMTRDIR.- Clear out text and source code tables CLEAR: MTABPROGRAMFILE, MTABPROGRAMSOURCE, MTABPROGRAMTEXTS, MTABPROGRAMDOCUMENTATION. REFRESH: MTABPROGRAMFILE, MTABPROGRAMSOURCE, MTABPROGRAMTEXTS, MTABPROGRAMDOCUMENTATION.- Get the report READ REPORT MTABPROGRAMTRDIR-NAME INTO MTABPROGRAMSOURCE.- Get the text for the report READ TEXTPOOL MTABPROGRAMTRDIR-NAME INTO MTABPROGRAMTEXTS.- Get the documentation for the report CLEAR DOKIL.

SELECT. UP TO 1 ROWS FROM DOKIL WHERE ID = 'RE' AND OBJECT = MTABPROGRAMTRDIR-NAME AND LANGU = SY-LANGU AND TYP = 'E' ORDER BY VERSION DESCENDING.- Documentation exists for this object IF SY-SUBRC = 0. CALL FUNCTION 'DOCUREAD' EXPORTING ID = DOKIL-ID LANGU = DOKIL-LANGU OBJECT = DOKIL-OBJECT TYP = DOKIL-TYP VERSION = DOKIL-VERSION IMPORTING HEAD = MSTRTHEAD TABLES LINE = MTABPROGRAMDOCUMENTATION EXCEPTIONS OTHERS = 1.- 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 MCTRDIRIDENTIFIER MTABPROGRAMTRDIR-NAME INTO MTABPROGRAMFILE-LINE. APPEND MTABPROGRAMFILE.- Add the TRDIR line MTABPROGRAMFILE-LINE = MTABPROGRAMTRDIR. APPEND MTABPROGRAMFILE.- Put the identifier line in so that the start of the report code.- is marked CONCATENATE MCREPORTIDENTIFIER MTABPROGRAMTRDIR-NAME INTO MTABPROGRAMFILE-LINE. APPEND MTABPROGRAMFILE.- Add the report code LOOP AT MTABPROGRAMSOURCE. MTABPROGRAMFILE = MTABPROGRAMSOURCE.

APPEND MTABPROGRAMFILE.- Put the identifier line in so that the start of the report text.- is marked CONCATENATE MCTEXTIDENTIFIER MTABPROGRAMTRDIR-NAME INTO MTABPROGRAMFILE-LINE. APPEND MTABPROGRAMFILE.- Add the report texts LOOP AT MTABPROGRAMTEXTS.

MTABPROGRAMFILE = MTABPROGRAMTEXTS. APPEND MTABPROGRAMFILE.- Put the identifier line in so that the start of the THEAD record.- is marked CONCATENATE MCTHEADIDENTIFIER MTABPROGRAMTRDIR-NAME INTO MTABPROGRAMFILE-LINE. APPEND MTABPROGRAMFILE. MTABPROGRAMFILE = MSTRTHEAD. APPEND MTABPROGRAMFILE.- Put the identifier line in so that the start of the report.- documentation is marked CONCATENATE MCDOCIDENTIFIER MTABPROGRAMTRDIR-NAME INTO MTABPROGRAMFILE-LINE. APPEND MTABPROGRAMFILE.- Add the report documentation LOOP AT MTABPROGRAMDOCUMENTATION.

MTABPROGRAMFILE = MTABPROGRAMDOCUMENTATION. APPEND MTABPROGRAMFILE.- Make the fully pathed filename that report will be saved to CONCATENATE PPATH MTABPROGRAMTRDIR-NAME '.txt' INTO LCFULLFILENAME. PERFORM SAVETABLETOFILE TABLES MTABPROGRAMFILE USING LCFULLFILENAME.- Write out message with Program Name/Description READ TABLE MTABPROGRAMTEXTS WITH KEY ID = 'R'. IF SY-SUBRC = 0. MTABDIRECTORY-NAME = MTABPROGRAMTRDIR-NAME. MTABDIRECTORY-DESC = MTABPROGRAMTEXTS-ENTRY. MTABDIRECTORY-SAVENAME = LCFULLFILENAME.

APPEND MTABDIRECTORY. WRITE: / MTABPROGRAMTRDIR-NAME, MTABPROGRAMTEXTS-ENTRY(65) COLOR COLHEADING. MTABDIRECTORY-NAME = MTABPROGRAMTRDIR-NAME. MTABDIRECTORY-DESC = 'No description available'. MTABDIRECTORY-SAVENAME = LCFULLFILENAME. APPEND MTABDIRECTORY.

File Download Program In Abap

WRITE: / MTABPROGRAMTRDIR-NAME. ' BUILDPROGRAMDIRECTORY.-. FORM SAVETABLETOFILE.-.-. FTABTABLE. FFILENAME.-. FORM SAVETABLETOFILE TABLES FTABTABLE USING FFILENAME. IF RBDOS = 'X'.

' Save file to presentation server CALL FUNCTION 'WSDOWNLOAD' EXPORTING FILENAME = FFILENAME FILETYPE = 'ASC' TABLES DATATAB = FTABTABLE EXCEPTIONS OTHERS = 4. IF SY-SUBRC NE 0. WRITE: / 'Error opening dataset' COLOR COLNEGATIVE, FFILENAME COLOR COLNEGATIVE. ' Save file to application serve OPEN DATASET FFILENAME FOR OUTPUT IN TEXT MODE. IF SY-SUBRC = 0.

LOOP AT FTABTABLE. TRANSFER FTABTABLE TO FFILENAME. IF SY-SUBRC NE 0. WRITE: / 'Error writing record to file;' COLOR COLNEGATIVE, FFILENAME COLOR COLNEGATIVE. WRITE: / 'Error opening dataset' COLOR COLNEGATIVE, FFILENAME COLOR COLNEGATIVE. ' End RBDOS ENDFORM. ' SAVEPROGRAM.-.

FORM READREPORTFROMDISK.-. Read report into internal table. Can read from local or. remote computer.-. FORM READREPORTFROMDISK TABLES FTABTABLE USING FFILENAME.

DATA: LCMESSAGE(128) TYPE C. CLEAR FTABTABLE. REFRESH FTABTABLE.

IF RBDOS = 'X'. TRANSLATE FFILENAME USING '/ '. ' correct slash for Dos PC file CALL FUNCTION 'WSUPLOAD' EXPORTING FILENAME = FFILENAME FILETYPE = 'ASC' TABLES DATATAB = FTABTABLE EXCEPTIONS CONVERSIONERROR = 1 FILEOPENERROR = 2 FILEREADERROR = 3 INVALIDTABLEWIDTH = 4 INVALIDTYPE = 5 NOBATCH = 6 UNKNOWNERROR = 7 OTHERS = 8.

IF SY-SUBRC FTABPROGRAMFILE. FTABPROGRAMSOURCE. `. FTABPROGRAMTEXTS.-. FORM SPLITINCOMINGFILE TABLES FTABPROGRAMFILE STRUCTURE MTABPROGRAMFILE FTABPROGRAMSOURCE STRUCTURE MTABPROGRAMSOURCE FTABPROGRAMTEXTS STRUCTURE MTABPROGRAMTEXTS FTABPROGRAMDOCUMENTATION STRUCTURE MTABPROGRAMDOCUMENTATION CHANGING FSTRTRDIR FSTRTHEAD. DATA: LCDATATYPE(4) TYPE C, ' Type of data, REPO, TEXP, RDIR LCPROGRAMFILE LIKE MTABPROGRAMFILE.

LOOP AT FTABPROGRAMFILE. LCPROGRAMFILE = FTABPROGRAMFILE.

CASE LCPROGRAMFILE(9). WHEN MCTRDIRIDENTIFIER. LCDATATYPE = MCTRDIRSHORT. WHEN MCREPORTIDENTIFIER.

LCDATATYPE = MCREPORTSHORT. WHEN MCTEXTIDENTIFIER. LCDATATYPE = MCTEXTSHORT. WHEN MCDOCIDENTIFIER. LCDATATYPE = MCDOCSHORT. WHEN MCTHEADIDENTIFIER. LCDATATYPE = MCTHEADSHORT.

' Actual contents of report, trdir, or text CASE LCDATATYPE. WHEN MCTRDIRSHORT. FSTRTRDIR = FTABPROGRAMFILE. WHEN MCREPORTSHORT. FTABPROGRAMSOURCE = FTABPROGRAMFILE.

APPEND FTABPROGRAMSOURCE. WHEN MCTEXTSHORT. FTABPROGRAMTEXTS = FTABPROGRAMFILE. APPEND FTABPROGRAMTEXTS. WHEN MCTHEADSHORT. FSTRTHEAD = FTABPROGRAMFILE.

WHEN MCDOCSHORT. FTABPROGRAMDOCUMENTATION = FTABPROGRAMFILE. APPEND FTABPROGRAMDOCUMENTATION.

' SPLITINCOMINGFILE.-. FORM INSERTNEWREPORT.-.-.

FTABPROGRAMSOURCE. FTABPROGRAMTEXTS. FTRDIR.-. FORM INSERTNEWREPORT TABLES FTABPROGRAMSOURCE STRUCTURE MTABPROGRAMSOURCE FTABPROGRAMTEXTS STRUCTURE MTABPROGRAMTEXTS FTABPROGRAMDOCUMENTATION STRUCTURE MTABPROGRAMDOCUMENTATION USING FSTRTRDIR LIKE TRDIR FSTRTHEAD LIKE MSTRTHEAD.

Sap

DATA: LCOBJNAME LIKE E071-OBJNAME, LCLINE2(40) TYPE C, LCANSWER(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 = FSTRTRDIR-NAME.

IF SY-SUBRC = 0. ' Already exists CONCATENATE 'want to overwrite report' FSTRTRDIR-NAME INTO LCLINE2 SEPARATED BY SPACE. CONCATENATE LCLINE2 '?' INTO LCLINE2. CALL FUNCTION 'POPUPTOCONFIRMSTEP' EXPORTING DEFAULTOPTION = 'N' TEXTLINE1 = 'The selected report already exists, do you' TEXTLINE2 = LCLINE2 TITEL = 'Report already exists' CANCELDISPLAY = SPACE IMPORTING ANSWER = LCANSWER EXCEPTIONS OTHERS = 1.

LCANSWER = 'J'. IF LCANSWER = 'J'.- Create the TADIR entry. (TRDIR entry created by INSERT REPORT) LCOBJNAME = TRDIR-NAME. CALL FUNCTION 'TRTADIRPOPUPENTRYE071' EXPORTING WIE071PGMID = 'R3TR' WIE071OBJECT = 'PROG' WIE071OBJNAME = LCOBJNAME WITADIRDEVCLASS = '$TMP' EXCEPTIONS EXIT = 3 OTHERS = 4. IF SY-SUBRC = 0.- Create Report INSERT REPORT FSTRTRDIR-NAME FROM FTABPROGRAMSOURCE.- Create Texts INSERT TEXTPOOL FSTRTRDIR-NAME FROM FTABPROGRAMTEXTS LANGUAGE SY-LANGU.- Save Documentation CALL FUNCTION 'DOCUUPDATE' EXPORTING HEAD = FSTRTHEAD STATE = 'A' TYP = 'E' VERSION = '1' TABLES LINE = FTABPROGRAMDOCUMENTATION EXCEPTIONS OTHERS = 1. WRITE: / 'Error updating the TADIR entry' COLOR COLNEGATIVE, 'Program' COLOR COLNEGATIVE INTENSIFIED OFF, FSTRTRDIR-NAME, 'was not loaded into SAP.'

COLOR COLNEGATIVE INTENSIFIED OFF. WRITE: / FSTRTRDIR-NAME COLOR COLNEGATIVE, 'was not uploaded into SAP. Action cancelled by user' COLOR COLNEGATIVE INTENSIFIED OFF. ' INSERTNEWREPORT.-. FORM GETNAME.-.-. VALUE(FFIELD). FNAME.-.

FORM GETNAME USING VALUE(FFIELD) CHANGING FNAME. DATA: LTABFIELDS LIKE DYNPREAD OCCURS 0 WITH HEADER LINE, LCPROG LIKE D020S-PROG, LCDNUM LIKE D020S-DNUM. TRANSLATE FFIELD TO UPPER CASE. Refresh ltabfields. LTABFIELDS-FIELDNAME = FFIELD.

Append ltabfields. LCPROG = SY-REPID. LCDNUM = SY-DYNNR. CALL FUNCTION 'DYNPVALUESREAD' EXPORTING DYNAME = LCPROG DYNUMB = LCDNUM TABLES dynpfields = ltabfields EXCEPTIONS OTHERS = 01.

Read table ltabfields index 1. IF SY-SUBRC EQ 0.

File download program in abap training

FNAME = LTABFIELDS-FIELDVALUE. Refresh ltabfields. CALL FUNCTION 'F4USER' EXPORTING OBJECT = FNAME IMPORTING RESULT = FNAME.

This entry was posted on 01.01.2020.