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 application server ?
*& Report  Z_FILE_DOWNLOAD_TO_APP_SERVER                               *
* This Program can be used to move flat files to application server from presentation server.
REPORT  Z_FILE_DOWNLOAD_TO_APP_SERVER.
PARAMETERS: P_FILE       LIKE IBIPPARMS-PATH,
           P_FILE1(20000) default 'E:CONVERSIONFLAT' lower case.
DATA: WS_FILE TYPE STRING.
DATA: BEGIN OF T_DATA OCCURS 0,
       RECORD(20000),
     END OF T_DATA.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
  PROGRAM_NAME        = SYST-CPROG
  DYNPRO_NUMBER       = SYST-DYNNR
  FIELD_NAME          = ' '
IMPORTING
  FILE_NAME           = P_FILE
START-OF-SELECTION.
WS_FILE = P_FILE.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
   FILENAME                      = WS_FILE
  FILETYPE                      = 'ASC'
TABLES
   DATA_TAB                      = T_DATA
EXCEPTIONS
  FILE_OPEN_ERROR               = 1
  FILE_READ_ERROR               = 2
  NO_BATCH                      = 3
  GUI_REFUSE_FILETRANSFER       = 4
  INVALID_TYPE                  = 5
  NO_AUTHORITY                  = 6
  UNKNOWN_ERROR                 = 7
  BAD_DATA_FORMAT               = 8
  HEADER_NOT_ALLOWED            = 9
  SEPARATOR_NOT_ALLOWED         = 10
  HEADER_TOO_LONG               = 11
  UNKNOWN_DP_ERROR              = 12
  ACCESS_DENIED                 = 13
  DP_OUT_OF_MEMORY              = 14
  DISK_FULL                     = 15
  DP_TIMEOUT                    = 16
  OTHERS                        = 17
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
        WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* Creating the file at Appl server............................
OPEN DATASET P_FILE1 FOR OUTPUT IN TEXT MODE encoding utf-8.
if sy-subrc ne 0.
message e000(--) with 'Error in opening file'.
endif.
* Trasfer the records to file.............
loop at t_data.
transfer t_data to p_file1.
endloop.
close dataset p_file1.
if sy-subrc eq 0.
write: / 'Written the files at ', p_file1.
write:/ 'Goto AL11 Transaction and then click on SAP Directory DIR_SAPUSERS to look for the file'.
endif.
Please advice.
Regards,
Rajesh

Try declaring it as TYPE STRING. Not sure though.
There are two predefined types in ABAP with variable length:
STRING for character strings
XSTRING for byte strings
Thanks,
SKJ

Similar Messages

  • Program for storing files on application server

    Hi,
    I want to store my csv file on application sever can any one provide me the program for this

    Maya,
    there is no program per se for this ....
    you would need to maintain the directory structure in AL11 and then if required , you can have an FTP program to push the file into that directory. Also please specify your landscape  - are you on Windows / UNIX / AIX / SOLARIS... depending on that you would have to configure your FTP client...
    Arun
    Hope it helps...

  • T-code for delete file from application server

    Hi all!
    Please, has any t-code for delete file from application server? For upload exist CG3Z, for download has CG3Y. And for delete? Has anyone?
    I need to delete file from application server in QA system and i don't want to create a program for this because i will need to transport a request from DEV to QA.

    I don't have contact with basis team.
    The FM EPS_DELETE_FILE support directory name with max 60 char. My dir. has more than that. I need a transaction for this.
    Anybody know if this transaction exist?

  • How to upload file from Application Server?

    Dear Friends,
    How to upload file from Application Server?
    Plz. with example...
    Regards,
    Dharmesh

    hi,
    check the code for upload from application server.
    tables: kna1.
    types: begin of s_file,
             customer type kna1-kunnr,
             country  type kna1-land1,
             name     type kna1-name1,
             region   type kna1-regio,
           end of s_file.
    *--Internal tables
    data: it_file type s_file occurs 0 with header line.
    *-- Selection screen
    selection-screen: begin of block b1 with frame title text-001.
    parameter: p_file type rlgrap-filename default 'C:/customer.txt'
    obligatory.
    selection-screen: end of block b1.
    *-- At selection screen
    at selection-screen on value-request for p_file.
    perform file_help using p_file.
    *-- Process File
    start-of-selection.
      perform upload_file using p_file.
    *-- write File data to o/p
    end-of-selection.
      perform write_data.
    *&      Form  file_help
    form file_help  using    p_p_file.
      data: l_filepath type ibipparms-path.
      call function 'F4_FILENAME'
    EXPORTING
      PROGRAM_NAME        = SYST-CPROG
      DYNPRO_NUMBER       = SYST-DYNNR
      FIELD_NAME          = ' '
       importing
         file_name           = l_filepath
      p_p_file = l_filepath.
    endform.                    " file_help
    *&      Form  upload_file
    form upload_file  using    p_p_file.
      call function 'WS_UPLOAD'
       exporting
         filename                      = p_p_file
         filetype                      = 'DAT'
    IMPORTING
      FILELENGTH                    =
        tables
          data_tab                      = it_file
       exceptions
         conversion_error              = 1
         file_open_error               = 2
         file_read_error               = 3
         invalid_type                  = 4
         no_batch                      = 5
         unknown_error                 = 6
         invalid_table_width           = 7
         gui_refuse_filetransfer       = 8
         customer_error                = 9
         no_authority                  = 10
         others                        = 11
      if sy-subrc <> 0.
        message i001.
      endif.
    endform.                    " upload_file
    *&      Form  write_data
    form write_data .
      loop at it_file.
        write:/ it_file-customer, it_file-country, it_file-name,
                it_file-region.
      endloop.
      endform.
    regards,
    keerthi.

  • 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.
    Can anyone resolve this issue.
    Thanks in advance.
    Murthy

    Hi Friends
    I wrote the custom program to upload the file on application server.
    Thanks for your time.
    Murthy

  • Problem in uploading file from Application Server

    Hi everyone,
    i got a problem in uplaoding a file from application server.i am having two folder (one folder name is current and another one is processed)in application server. In current folder i am having N no of files.I want to upload all the files names into one internal table and i want to process one by one file.After processing each file the file should be moved to processed folder and the files should not exist in current folder.All these process must be done everyday.Please rectify my problem asap.

    Ramesh,
    Take authorization from basis guy.
    Use the below code to get the list of files from require directory
    *& Report  ZDIRFILES                                                   *
    REPORT  ZDIRFILES    .
    PARAMETER: p_fdir            type pfeflnamel DEFAULT '/usr/sap/tmp'.
    data: begin of it_filedir occurs 10.
            include structure salfldir.
    data: end of it_filedir.
    *START-OF-SELECTION
    START-OF-SELECTION.
    Get Current Directory Listing for OUT Dir
      call function 'RZL_READ_DIR_LOCAL'
           exporting
                name     = p_fdir
           tables
                file_tbl = it_filedir.
    Now in internal table "it_filedir"  will have all your files.
    For moving and deleting
    report zrich_0001.
    Parameters: d1 type localfile default '/usr/sap/TST/SYS/fld1/Data1.txt',
                d2 type localfile default '/usr/sap/TST/SYS/fld2/Data1.txt'.
    data: begin of itab occurs 0,
          rec(20) type c,
          end of itab.
    data: wa(20) type c.
    start-of-selection.
      open dataset d1 for input in text mode.
      if sy-subrc = 0.
        do.
          read dataset d1 into wa.
          if sy-subrc <> 0.
            exit.
          endif.
          itab-rec = wa.
          append itab.
        enddo.
      endif.
      close dataset d1.
      open dataset d2 for output in text mode.
      loop at itab.
        transfer itab to d2.
      endloop.
      close dataset d2.
      delete dataset d1.
    Check below FM if required
    To move the file to archive directoryuse FMs 'PFL_COPY_OS_FILE'
    To Delete 'EPS_DELETE_FILE'.
    Don't forgot to reward if useful

  • Problem while uploading file from application server to internal tab in BG

    Hi all,
    When i see the file  in application server.data is like this
    #################00\);_(#####}#-#}###############################00\);_(#####}#-#}###############################00\);_(*#####}#-#}#########
    ###################}###}#############A#############???#00\);_(*#################;_(@_)  ########???#        ########???#        ########???###
    #######???#########}###}#############)##############}##00\);_(*#################;_(@_)  ############        ############        ##############
    ###################}#A#}#############:##############}##00\);_(#################;_(@_)  }###}##############################00\);_(*##########
    #######???#########}#-#}#############F#################00\);_(#####}###}#############@#################00\);_(#################;_(@_)  #####
    ###################}#-#}#############3#################00\);_(#####}#U#}#############E#################00\);_(#################;_(@_)  #####
    Because the csv which is uploaded has dropdowns and some formattings.
    when download from tcode cg3y i am getting correct file
    When try to use open(binary mode) and read dataset i getting data as it is (junk).
    i need to process in background.
    Any help.
    Rhea.

    upload file to string format
    begin of ty_tab,
    string type char200,
    end of ty_tab.
    loop at ty_tab into string
    use statement replace string into tab deliminated fromat(particular occurance in string)
    now call class to break string at tab into fields
    endloop.
    DATA : BEGIN OF i_data OCCURS 0,
            data(200)    TYPE c,       "To hold Upload file data
           END OF i_data.
    OPEN DATASET v_str FOR INPUT
                              IN TEXT MODE
                              ENCODING DEFAULT IGNORING CONVERSION ERRORS.
        IF sy-subrc EQ 0.
          DO.
    *Read a line from input file
            READ DATASET v_str INTO i_data-data.
            IF sy-subrc NE 0.
              EXIT.
            ENDIF.
    *Append record to an internal table
            APPEND i_data.
            CLEAR: i_data.
          ENDDO.
    *Close the file
          CLOSE DATASET v_str.
    *---Start of inserti
    LOOP AT i_data.
            REPLACE ALL OCCURRENCES OF '"' IN i_data WITH '#'.
            SPLIT i_data AT cl_abap_char_utilities=>horizontal_tab
                                INTO i_doc-pvaudt
                                     i_doc-pvpate
                                     i_doc-vecatc
                                     i_doc-vhvend
                                     i_doc-vhidt8
                                     i_doc-vhinvn
                                     i_doc-vhhexp
                                     i_doc-vhiref.

  • Issue in Uploading file to application server

    Hi folks,
    I need to transfer data to excel file on application server but i am facing issues while doing so.
    I am working on ECC6.0 system.
    I am trying with this code and it giving dump error on transfer command.
    w_file = '/usr/data/020//varun.xls'.
    OPEN DATASET w_file for input in text mode encoding non-unicode.
    LOOP AT T_MARD.
    TRANSFER string to w_file.
    endloop.
    CLOSE DATASET w_file.
    Please help.
    Is there any other way to do so please let me know

    Hi Got the solution :-
    If the data to be transferred is having all characters then we can use this:-
    OPEN DATASET w_file for output in text mode encoding non-unicode.
    if sy-subrc eq 0.
       LOOP AT T_MARD into wa_mard.
            TRANSFER wa_mard to w_file.
       endloop.
    endif.
    CLOSE DATASET w_file.
    If all the data is not in char then - declare a char strinf of the table length.
    Data: loc_string(300) type c.
    OPEN DATASET w_file for output in text mode encoding non-unicode.
    if sy-subrc eq 0.
       LOOP AT T_MARD into wa_mard.
          CALL FUNCTION 'HR_99S_COPY_STRUC1_STRUC2'
            EXPORTING
              p_struct1 = wa_mard
            IMPORTING
              p_struct2 = loc_string.
            TRANSFER loc_string to w_file.
       endloop.
    endif.
    CLOSE DATASET w_file.
    Thanks for the help

  • Urgent.... Help Needed for Storing file in Application Server

    Hi All,
    I have a requirement where in I have to save a file in Application Server.
    File is of 141 Character Length, so there can be spaces left at the end.
    When I am downloading the file into Application Sever and then downloading the same file from Application Server to Presentation into a notepad then the spaces at the end are truncating.
    I want that the file that is generated should be of 141 character though if there may be spaces at the end.
    It will be great if you can help me out in this.
    Thanks in Advance.
    Jayant Sahu.

    when downloading to App server, you need to specify the LENGTH option on your TRANSFER ststement to keep fixed length.  You must also use a STRING type variable in your transfer.
    From Documentation on Transfer command:
    <b>If the file was opened as a text file or a legacy text file, the trailing blank characters are deleted for all data objects, except for those of data type string. The line end marker defined when the file was opened is then added to the remaining content of the data object or to the result of the conversion, and the final result is written byte-by-byte to the file.</b>
    There also used to be a problem with WS_DOWNLOAD - you had to do the following:
    Maintaining Trailing spaces when downloading to PC
    Before calling DOWNLOAD or WS_DOWNLOAD, do a perform SET_TRAIL_BLANKS(saplgrap) using 'X'
    To set the length of each record including your blanks add this code: perform SET_FIXLEN(saplgrap) using '0' '100'
    Don't think this is needed any more.
    Andrew

  • How to upload file on Application Server with Forms 6i?

    Please, I need to upload .csv file from local to Application Server, I think to use .jsp application, but I don't know where I had to put it...Apache can't read .jsp file without Tomcat? If I launch my .jsp file from Apache/htdocs directory can't view .jsp code (Method Not Allowed)...method is POST...any idea? Thanks in advance!

    Hi,
    You could write a java bean to get the file from the client and to upload to App Server. And, you simply use it in Forms 6i.
    Also, you could use d2kwutil (not tried though. you could search this forum and get an idea of that).
    Of course, For your information, You could use WebUtil (in Forms 10g / 10.1.2) which has the functionality.
    HTH.
    Regards,
    Arun

  • To Delete the uploaded file in Application Server

    Hi Friends,
    I developed an BSP Application displaying the results from ITAB though Iterator, for which , each row there is feature to upload a particular file in the Application Server, where I stored the file  path into a database table field.  .When I delete the the row, I am successfully get rid of the entire row including the file path.
    My Question.
    1. How to delete the uploaded file of the Application Server ?
    Please mail me in this regard.
    Regards
    CSM Reddy

    Hi,
    you have the keyword and you have the documentation. What is your problem?
    Search in the forums with keyword "delete dataset", there are lots of threads about this.
    Example
    Deletion of dataset in applicaiton server
    deleting file from AL11 Tcode
    Best regards
    Renald

  • Remove link for uploaded files in application

    Hi all,
    I've been following the tutorial on how to upload and download files in application at http://download-uk.oracle.com/docs/cd/B32472_01/doc/appdev.300/b32469/up_dn_files.htm. I have now created my own table which stores the uploaded files and can download them successfully. I would now like to add the ability to delete these files within the application and was wondering what the best way of doing this was?
    I would like to add another column to the displayed report with a 'Remove file' link for each listed file, which when clicked would delete the file from the table. I've already tried using a similar method to the one used to upload the files (instead of uploading the file, the called procedure deletes it from the table using the specified ID), but this causes the application to display a blank page when the link is clicked, which I dont want (but does delete the file).
    I would appreciate any suggestions.
    Regards,
    Dave

    Dave,
    See the login page:
    http://htmldb.oracle.com/pls/otn/f?p=31517:101
    There are details on how to access the application builder, where you can see how the
    setup of that download, delete, upload application has been done.
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://htmldb.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

  • How to search for a file at application server?

    Hi,
    I need to choose one file for further processing from the directory, located into 'WORK' directory at application server. As far as I see, class CL_GUI_FRONTEND_SERVICES and FILE_OPEN_DIALOG woudn't help me - it's a 'FRONTEND_SERVICES'.... and work with directories at presentation server.
    The requirement is that the user has no file sharing from his local PC to the mentioned directory at application server - this directory is visible only in the scope of the application server. I need something as flexible as CL_GUI_FRONTEND_SERVICES=>FILE_OPEN_DIALOG, if exist.
    How can I achieve this?
    Any help would be highly appreciated.
    Many thanks in advance.
    Regards,
    Ivaylo Mutafchiev

    Thanks to all contributors!
    After short testing I found the following:
    1. F4_DXFILENAME_TOPRECURSION is not what I was looking for - it doesn;t behave as expected.
    2. FM EPS_GET_DIRECTORY_LISTING would help if I need the result into an internal table (thsi would be a case too), but it doesn;t prompt for selection. Helpful, anyway.
    3. /SAPDMC/LSM_F4_SERVER_FILE is the closest match to the requirements.
    Thanks to all.
    Regards,
    Ivaylo
    P.S. Abhijit Dani - sorry, you were the second with the same reply, I rewarded the 1st answer as very helpful.

  • Uploading file in application server to a transaction

    Hi All,
    I have a requirment where in i want to upload the transaction FF_5 using the file in the application server. Is there any way to do this. I dont want to download the file to presentation server and then upload the file in FF_5  transaction. According to the requirement i have to directly upload the application server file in the tcode FF_5. Pls let me know how to do this.
    Thanks,
    Raju

    Hi,
    You cannot upload the data from the applcation server. You have to upload from the presentation server.
    If you have data on the application server then you need to save it to presentation server and upload to FF_5.

  • How to create open file dialog for choosing file in application server?

    I would like to have the same functionality as
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      CALL FUNCTION 'NAVIGATION_FILENAME_HELP'
        EXPORTING
          DEFAULT_PATH            = '.'
          MODE                    = 'O'
        IMPORTING
          RETURNCODE              = return_code
          SELECTED_FILENAME       = p_file.
    But the above code, only allow me to choose files from local computer. How to do the same thing with the file location becomes the application server?
    Thanks!

    Try this it will give the full directory structure.
    REPORT  ZTEST3460  line-count 30(2)   .
    PARAMETERS: FILE LIKE RLGRAP-FILENAME.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR FILE.
                         CALL FUNCTION '/SAPDMC/LSM_F4_SERVER_FILE'
                         EXPORTING
                           DIRECTORY              = ' '
                           FILEMASK               = ' '
                          IMPORTING
                            SERVERFILE             = FILE
                         EXCEPTIONS
                           CANCELED_BY_USER       = 1
                           OTHERS                 = 2
    Cheers

Maybe you are looking for