How to upload excel file in application server??

Advertisement

Hi,
How to upload an excel file into internal table in background mode from application server?
Thanks

Advertisement

Hi vipin,
check this it may help you...
hope below links helps you
Export the report list to Excel Sheet
http://www.sapdevelopment.co.uk/file/file_updown.htm
or below is a sample programme which helps you upload and download
REPORT ytest5 LINE-SIZE 80
                LINE-COUNT 65
                NO STANDARD PAGE HEADING.
TABLES: dd02l, dd03l.
* selection screen
SELECTION-SCREEN BEGIN OF BLOCK b00 WITH FRAME TITLE text-b00.
SELECTION-SCREEN BEGIN OF BLOCK b01 WITH FRAME TITLE text-b01.
PARAMETERS: tabname     LIKE dd02l-tabname OBLIGATORY.
SELECTION-SCREEN END OF BLOCK b01.
SELECTION-SCREEN BEGIN OF BLOCK b03 WITH FRAME TITLE text-b03.
PARAMETERS: path(30)    TYPE c DEFAULT 'C:SAPWorkdir'.
SELECTION-SCREEN END OF BLOCK b03.
SELECTION-SCREEN BEGIN OF BLOCK b04 WITH FRAME TITLE text-b04.
PARAMETERS: p_exp RADIOBUTTON GROUP radi,
            p_imp RADIOBUTTON GROUP radi,
            p_clear     AS CHECKBOX.
SELECTION-SCREEN END OF BLOCK b04.
SELECTION-SCREEN END OF BLOCK b00.
* data
DATA: q_return     LIKE syst-subrc,
      err_flag(1)  TYPE c,
      answer(1)    TYPE c,
      w_text1(62)  TYPE c,
      w_text2(40)  TYPE c,
      winfile(128) TYPE c,
      w_system(40) TYPE c,
      winsys(7)    TYPE c,
      zname(8)     TYPE c,
      w_line(80)   TYPE c.
* internal tables
DATA : BEGIN OF textpool_tab OCCURS 0.
        INCLUDE STRUCTURE textpool.
DATA : END OF textpool_tab.
* table for subroutine pool
DATA : itab(80) OCCURS 0.
* events
INITIALIZATION.
  PERFORM check_system.
AT SELECTION-SCREEN ON tabname.
  PERFORM check_table_exists.
START-OF-SELECTION.
  PERFORM init_report_texts.
  PERFORM request_confirmation.
END-OF-SELECTION.
  IF answer = 'J'.
    PERFORM execute_program_function.
  ENDIF.
TOP-OF-PAGE.
  PERFORM process_top_of_page.
* forms
*       FORM CHECK_TABLE_EXISTS                                      *
FORM check_table_exists.
  SELECT SINGLE * FROM dd02l
  INTO CORRESPONDING FIELDS OF dd02l
  WHERE tabname = tabname.
  CHECK syst-subrc NE 0.
  MESSAGE e402(mo) WITH tabname.
ENDFORM.
*       FORM INIT_REPORT_TEXTS                                        *
FORM init_report_texts.
  READ TEXTPOOL syst-repid
  INTO textpool_tab LANGUAGE syst-langu.
  LOOP AT textpool_tab
  WHERE id EQ 'R' OR id EQ 'T'.
    REPLACE '&1............................'
    WITH tabname INTO textpool_tab-entry.
    MODIFY textpool_tab.
  ENDLOOP.
ENDFORM.
*       FORM REQUEST_CONFIRMATION                                     *
FORM request_confirmation.
* import selected, confirm action
  IF p_imp = 'X'.
*   build message text for popup
    CONCATENATE 'Data for table'
                 tabname
                 'will be imported' INTO w_text1 SEPARATED BY space.
*   check if delete existing selected, and change message text
    IF p_clear = ' '.
      w_text2 = 'and appended to the end of existing data'.
    ELSE.
      w_text2 = 'Existing Data will be deleted'.
    ENDIF.
    CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
         EXPORTING
              defaultoption  = 'N'
              textline1      = w_text1
              textline2      = w_text2
              titel          = 'Confirm Import of Data'
              cancel_display = ' '
         IMPORTING
              answer         = answer
         EXCEPTIONS
              OTHERS         = 1.
  ELSE.
*   export selected, set answer to yes so export can continue
    answer = 'J'.
  ENDIF.
ENDFORM.
*       FORM EXECUTE_PROGRAM_FUNCTION                                 *
FORM execute_program_function.
  PERFORM build_file_name.
  CLEAR: q_return,err_flag.
  IF p_imp = 'X'.
    PERFORM check_file_exists.
    CHECK err_flag = ' '.
    PERFORM func_import.
  ELSE.
    PERFORM func_export.
  ENDIF.
ENDFORM.
*       FORM BUILD_FILE_NAME                                          *
FORM build_file_name.
  MOVE path TO winfile.
  WRITE '' TO winfile+30.
  WRITE tabname TO winfile+31.
  WRITE '.TAB' TO winfile+61(4).
  CONDENSE winfile NO-GAPS.
ENDFORM.
*       FORM CHECK_FILE_EXISTS                                        *
FORM check_file_exists.
  CALL FUNCTION 'WS_QUERY'
       EXPORTING
            filename = winfile
            query    = 'FE'
       IMPORTING
            return   = q_return
       EXCEPTIONS
            OTHERS   = 1.
  IF syst-subrc NE 0 OR q_return NE 1.
    err_flag = 'X'.
  ENDIF.
ENDFORM.
*     FORM func_export                                              *
FORM func_export.
  CLEAR itab. REFRESH itab.
  APPEND 'PROGRAM SUBPOOL.' TO itab.
  APPEND 'FORM DOWNLOAD.' TO itab.
  APPEND 'DATA: BEGIN OF IT_TAB OCCURS 0.' TO itab.
  CONCATENATE 'INCLUDE STRUCTURE'
              tabname
              '.' INTO w_line SEPARATED BY space.
  APPEND w_line TO itab.
  APPEND 'DATA: END OF IT_TAB.' TO itab.
  CONCATENATE 'SELECT * FROM'
              tabname
              'INTO TABLE IT_TAB.' INTO w_line  SEPARATED BY space.
  APPEND w_line TO itab.
  APPEND 'CALL FUNCTION ''WS_DOWNLOAD''' TO itab.
  APPEND 'EXPORTING' TO itab.
  CONCATENATE 'filename = ' ''''
              winfile '''' INTO w_line SEPARATED BY space.
  APPEND w_line TO itab.
  APPEND 'filetype = ''DAT''' TO itab.
  APPEND 'TABLES' TO itab.
  APPEND 'DATA_TAB = IT_TAB.' TO itab.
  APPEND 'DESCRIBE TABLE IT_TAB LINES sy-index.' TO itab.
  APPEND 'FORMAT COLOR COL_NORMAL INTENSIFIED OFF.' TO itab.
  APPEND 'WRITE: /1 syst-vline,' TO itab.
  APPEND '''EXPORT'',' TO itab.
  APPEND '15 ''data line(s) have been exported'',' TO itab.
  APPEND '68 syst-index,' TO itab.
  APPEND '80 syst-vline.' TO itab.
  APPEND 'ULINE.' TO itab.
  APPEND 'ENDFORM.' TO itab.
  GENERATE SUBROUTINE POOL itab NAME zname.
  PERFORM download IN PROGRAM (zname).
ENDFORM.
*       FORM func_import                                              *
FORM func_import.
  CLEAR itab. REFRESH itab.
  APPEND 'PROGRAM SUBPOOL.' TO itab.
  APPEND 'FORM UPLOAD.' TO itab.
  APPEND 'DATA: BEGIN OF IT_TAB OCCURS 0.' TO itab.
  CONCATENATE 'INCLUDE STRUCTURE'
              tabname
              '.' INTO w_line SEPARATED BY space.
  APPEND w_line TO itab.
  APPEND 'DATA: END OF IT_TAB.' TO itab.
  APPEND 'DATA: BEGIN OF IT_TAB2 OCCURS 0.' TO itab.
  CONCATENATE 'INCLUDE STRUCTURE'
              tabname
              '.' INTO w_line SEPARATED BY space.
  APPEND w_line TO itab.
  APPEND 'DATA: END OF IT_TAB2.' TO itab.
  APPEND 'CALL FUNCTION ''WS_UPLOAD''' TO itab.
  APPEND 'EXPORTING' TO itab.
  CONCATENATE 'filename = ' ''''
              winfile '''' INTO w_line SEPARATED BY space.
  APPEND w_line TO itab.
  APPEND 'filetype = ''DAT''' TO itab.
  APPEND 'TABLES' TO itab.
  APPEND 'DATA_TAB = IT_TAB.' TO itab.
  IF p_clear = 'X'.
    CONCATENATE 'SELECT * FROM'
                tabname
                'INTO TABLE IT_TAB2.' INTO w_line SEPARATED BY space.
    APPEND w_line TO itab.
    APPEND 'LOOP AT IT_TAB2.' TO itab.
    CONCATENATE 'DELETE'
                tabname
                'FROM IT_TAB2.' INTO w_line SEPARATED BY space.
    APPEND w_line TO itab.
    APPEND 'ENDLOOP.' TO itab.
    APPEND 'COMMIT WORK.' TO itab.
  ENDIF.
  APPEND 'LOOP AT IT_TAB.' TO itab.
  CONCATENATE 'MODIFY'
              tabname
              'FROM IT_TAB.' INTO w_line SEPARATED BY space.
  APPEND w_line TO itab.
  APPEND 'ENDLOOP.' TO itab.
  APPEND 'DESCRIBE TABLE IT_TAB LINES sy-index.' TO itab.
  APPEND 'FORMAT COLOR COL_NORMAL INTENSIFIED OFF.' TO itab.
  APPEND 'WRITE: /1 syst-vline,' TO itab.
  APPEND '''IMPORT'',' TO itab.
  APPEND '15 ''data line(s) have been imported'',' TO itab.
  APPEND '68 syst-index,' TO itab.
  APPEND '80 syst-vline.' TO itab.
  APPEND 'ULINE.' TO itab.
  APPEND 'ENDFORM.' TO itab.
  GENERATE SUBROUTINE POOL itab NAME zname.
  PERFORM upload IN PROGRAM (zname).
ENDFORM.
*       Form  CHECK_SYSTEM
*            Check users workstation is running
*            WINDOWS 95, or WINDOWS NT.
*            OS/2 uses 8.3 file names which are no good for
*            this application as filenames created are 30 char
*            same as table name.
*            You could change the logic to only use the first 8 chars
*            of the table name for the filename, but you could possibly
*            get problems if users had exported already with a table
*            with the same first 8 chars.
*            As an alternate method you could request the user to input
*            the full path including filename and remove the logic to
*            build the path using the table name.
FORM check_system.
  CALL FUNCTION 'WS_QUERY'
       EXPORTING
            query  = 'WS'
       IMPORTING
            return = winsys.
  IF winsys NE 'WN32_95'.
    WRITE: 'Windows NT or Windows 95/98 is required'.
    EXIT.
  ENDIF.
ENDFORM.                               " CHECK_SYSTEM
*       FORM PROCESS_TOP_OF_PAGE                                      *
FORM process_top_of_page.
  FORMAT COLOR COL_HEADING INTENSIFIED ON.
  ULINE.
  CONCATENATE syst-sysid
              syst-saprl
              syst-host INTO w_system SEPARATED BY space.
  WRITE : AT /1(syst-linsz) w_system CENTERED.
  WRITE : AT 1 syst-vline, syst-uname.
  syst-linsz = syst-linsz - 11.
  WRITE : AT syst-linsz syst-repid(008).
  syst-linsz = syst-linsz + 11.
  WRITE : AT syst-linsz syst-vline.
  LOOP AT textpool_tab WHERE id EQ 'R'.
    WRITE : AT /1(syst-linsz) textpool_tab-entry CENTERED.
  ENDLOOP.
  WRITE : AT 1 syst-vline, syst-datum.
  syst-linsz = syst-linsz - 11.
  WRITE : AT syst-linsz syst-tcode(004).
  syst-linsz = syst-linsz + 11.
  WRITE : AT syst-linsz syst-vline.
  LOOP AT textpool_tab WHERE id EQ 'T'.
    WRITE : AT /1(syst-linsz) textpool_tab-entry CENTERED.
  ENDLOOP.
  WRITE : AT 1 syst-vline, syst-uzeit.
  syst-linsz = syst-linsz - 11.
  WRITE : AT syst-linsz 'Page', syst-pagno.
  syst-linsz = syst-linsz + 11.
  WRITE : AT syst-linsz syst-vline.
  ULINE.
  FORMAT COLOR COL_HEADING INTENSIFIED OFF.
  LOOP AT textpool_tab WHERE id EQ 'H'.
    WRITE : AT /1(syst-linsz) textpool_tab-entry.
  ENDLOOP.
  ULINE.
ENDFORM.
if it helps you reward with points.
regards,
venu
regards,
venu.

October 11, 2015

How to upload excel file in application server??

Hi, How to upload an excel file into internal table in background mode from application server? ThanksHi vipin, check this it may help you... hope below links helps you Export the report list to Excel Sheet http://www.sapdevelopment.co.uk/file/file_u

How to save CSV file in application server while making infospoke

How to save CSV file in application server to be used as destination while making infospoke. Please give the steps.........Hi If you want to load your flatfile from Application server,then you need to trasfer your file from your desktop(Computer) to

Create Excel file in application server but the field value is incorrect

Hi Experts, i am facing a problem when create excel file in application server using OPEN DATASET command. the internal table have 4 field and one of those field contains 19 digit number --> ICCID. the code running well, successfully create EXCELfile

How to rename a file in Application server

Hi All, Here I have a issue with  the present file which is being generated in application server. Before the completion of the file the EDI tool is extracting the file from the app server.So here I would like to generate the file with a temp name an

Upload 1gb file from application server to PSA

Hi, The following is the requirement my client has, 1) there will be a 1gb file on application server 2) pick up the file, and validate if the number of records are equal to number provided in the footer, if they dont match, reject the file 3) then v

How to download a file from application server to presentation server

Hi experts, I want to download a file from application server to presentaion server, file contaims three fields customer name, customer email id and status.. help me out i m new into sap.Dear Aditya, Please check below thread http://scn.sap.com/threa

Opening the Excel file from Application server

Hi All, I had uploaded an excel file on the application server for using it in my program . But when i am opening the uploaded file on the Application server it shows some special characters and those are also displayed on my report output while read

How to upload multiple files into a server location at a single time

Hi All, In my application i need to send multiple files from a particular page into the server location. In this page there will be an option to upload a file and after selecting the file , we will have an option asking if we were interested to send

Uploading file to Application Server using Tcode: CG3Z

Hi Friends, I am facing a weird problem when uploading a file(PIPE delimited format) to application server using the transaction CG3Z. The data is getting truncated at the end of each row and the file size doesn't match with the one i had uploaded. C

Upload excel file to internal table in web dynpro program

Hi friend's In web dynpro program how to upload excel file into  internal table and finally data will be save Y table.hi, See the properties of File Upload UI element.. Link: [http://help.sap.com/saphelp_nw70ehp1/helpdata/en/48/732f0510d83ff6e1000000

Error while uploading the file from Allpcation server in LSMW-7th step

Hi Experts, what should be the specific CODE PAGE should be maintained while uploading the file from application server in LSMW-7th Step Thanks in advance, KSRHi I mean that there is any seperate CODE PAGE which comes at the bottom of screen while up

How best store files on application server: Tables vs File system

Hi Experts, We want to let users to upload files to application server. The number of files can potencially grow over time (1000 files every month) though I whould like to limit size of each file not more than 1-2 MB. Also files should be classified

Help Required:How Upload Excel file Into Oracle Table Using PLSQL Procedure

Please Help , Urgent Help Needed. Requirement is to Upload Excel file Into Oracle Table Using PLSQL Procedure/Package. Case's are : 1. Excel File is On Users/ Client PC. 2. Application is on Remote Server(Oracle Forms D2k). 3. User Is Using Applicati

How to send File on application server for Attachment

Hi, Friends in my application file is to be sent with Email as an attachment. all this to be done via servlet for that i have to send the file to application server from there servlet will send mail via Email server. How can send this file to server.

Program for uploading file on application server...

Hi, I have created a program to upload a file from presentation server (local desktop) to application server. But in this program I have to specify the file length. What should I do in given program so that I can upload file of any length on applicat

How to search file in application server using pattern

Hi all, I want to search file in application server. Suppose there is file named abc20090808.dat. Is there is any function module to search the file? it should return back the file names starting with abc, if the import parameter is abc* Regards, Nik

How to delete files from application server posted in last 30 days

I have some files in application server posted through ABAP program with the below format \.\.\.abcd_20110209_111209.csv   (with  date and time). I need to delete those files which was posted in last 30 days through another program. Could you plaese

Uploading Excel File and Reading Data from that File

<b>Hi Can anyone Please tell me how to upload an Excel File in to the Web Dynpro Application and After that i want to read the data from that uploaded excel file in the Web Dynpro Application to the Web Dynpro table. Plz help me to solve this.......

How to upload large file with http via post

Hi guys, Does anybody know how to upload large file (>100 MB) use applet to servlet with http via post method? Thanks in advance. Regards, Mark.Hi SuckRatE Thanks for your reply. Could you give me some client side code to upload a large file. I use U

I want to put header while stroing file in application server

Hi Guru,    Can anybody tell how to put header while stroing file in application server. in the below pgm data is coming i want to put heading .if we see in al11 transaction the header should come .plese give on eg in the code itself.its urgent eg: m