Reading file from ftp server and importing data into table

Hi experts,
Well basically i have text files with different layout that have been uploaded on an ftp server. Now i have to write a procedure to fetch those files, read them and insert data in a table... can that be done?
your precious help would be greatly helpful.
Thanks

declare
file1 UTL_FILE.FILE_TYPE;
filename varchar2(1000) := 'GTECHFILES';
str long;
begin
file1 := UTL_FILE.FOPEN (filename,'agent_dump_csv.rep','r',32767);
loop
UTL_FILE.GET_LINE ( file1, str );
--dbms_output.put_line('Value is :'||to_char(str));
end loop;
UTL_FILE.FCLOSE( file1 );
exception
when no_data_found then
dbms_output.put_line('END OF FILE');
UTL_FILE.FCLOSE( file1 ) ;
when others then
UTL_FILE.FCLOSE( file1 ) ;
dbms_output.put_line('ERROR: '||sqlcode||':'||sqlerrm) ;
end;
i have managed to write this piece of code and all lines are being read and now i need to insert data into my table and the fields are seperated by a `|` i am strill trying to figure how to do that now. help ...
Edited by: Kevin CK on 17-Jan-2010 22:40

Similar Messages

  • Oracle read files from FTP Server

    Hi,
    Somebody knowns Oracle how to read files from FTP Server ? Which package I can use?

    Duplicate post
    Oracle read files from FTP Server

  • Need to copy .txt file from FTP server and downloaded on local server directory.

    I need to figure out a way to copy .txt file from ftp server in local server directory using sql jobs.

    Below links will help achieving it:
    https://www.virtualobjectives.com.au/sqlserver/ftp_scripts.htm
    http://www.mssqltips.com/sqlservertip/2884/sql-server-integration-services-ssis-ftp-task-for-data-exchange/

  • Read File From FTP Server

    Hi all,
    I have to read a file from FTP server, manipulate it and then create another file at the same location.
    Currently, I am able to write a file onto FTP server ..but how do I read the file?
    Any help will be greatly appreciated.
    Thanks,
    Haritha

    can i know how do u placing the file in FTP?
    ( default path specified in the FTP server, it might be Pre. server address)

  • Pick the  file from FTP Server and place it on the App. Server of R/3

    Hi Guys,
      I had a requirement where i need to pick the file from the FTP Server and place it on the Application Server in R/3. If anybody has an Idea on acheiving this or if anybody has the piece of Code Snippet to acheive the same, Help me out.
    Regards,
    Kittu Chowdary.

    hi kittu,
    chk the demo programs RSFTP00* if they can help u

  • Read file from ftp SERVER(NON SAP) into an internal table

    Hi all,
    I need to read the data from an excel file which was uploaded from ftp (i.e different server) into an SAP internal table by using FTP connections.
    Actually i am already getting text file data successfully.
    But only when reading in excel file that is presented in JDA server.
    Facing problem to read excel file data from JDA server.
    Pls help me.
    How can we go ahead ?
    Kindly suggest with the help of some code.

    Hi Lokesh,
    Currently I need to interface JDA and SAP.
    Can you kindly recommend how to handle this?

  • Read file from FTP server (passive mode)

    HI,
    I want to read a file from a ftp server. I can do it by OpenStream() and read the file contents as a stream. But the ftp account is set as "PASSIVE Mode", so how to set it to passive mode and access the file ? Any thoughts?
    Thanks,
    thb.

    Hi,
    Thanks for your speedy response. How to set the PASV parameter, with the InputStream reader. Currently I am reading a file that is active thru. flg. steps.
    InputStream is = new URL("url").openStream();
    BufferedReader in = new BufferedReader(new InputStreamReader(is));
    Then, I am writing the stream contents to a file. So how to set up the PASV parameter?
    Thanks.

  • HowTo read file from app. server and store it in binary format (SDOKCNTBIN)

    Hi
    I need to upload Documents to Document Repository by using to function module RSOD_DOC_MAST_CHANGE.
    My question is: How can I fill the "parameter" i_t_file_content_binary from a file which is stored on an application server.
    br, michael

    Hi
    I need to upload Documents to Document Repository by using to function module RSOD_DOC_MAST_CHANGE.
    My question is: How can I fill the "parameter" i_t_file_content_binary from a file which is stored on an application server.
    br, michael

  • Dequeue XML from Oracle AQ and insert data into table

    Using PL/SQL in a stored procedure, I need to dequeue a message from an Oracle AQ queue, parse the XML content and insert the data in an Oracle table. This is being done in Oracle 9.2.x.
    The payload for the message consists of 2 attributes, APPLICATION_DATA (VARCHAR2(32) and MESSAGE_BODY (CLOB). The MESSAGE_BODY is an XML document. A sample of the message is shown below:
    (M_NAME=MSG_LAW_WR_CRE_UPD, <?xml version = "1.0"?>
    <MSG_LAW_WR_CRE_UPD ID = "WMIS-4744" SRC_SYSTEM_CODE = "WMIS" SRC_SYSTEM_INSTANCE = "WMIS">
    <WR:CMP_LAW_WR_CRE_UPD xmlns:WR = "WR" >
    <WR:DATETIME>12/19/2005</WR:DATETIME>
    <WR:RUSCODE>100</WR:RUSCODE>
    <WR:WRNO>38213</WR:WRNO>
    </WR:CMP_LAW_WR_CRE_UPD>
    </MSG_LAW_WR_CRE_UPD>)
    This message needs to be dequeued from a queue named INBOUND, parsed and inserted into a table named INFO_TO_ACCT (CREATEDATE date, RUSCODE varchar2(10), WRNO number).
    Any help would be appreciated.

    SELECT EXTRACTVALUE(xmltype('<?xml version = "1.0"?>
    <MSG_LAW_WR_CRE_UPD ID = "WMIS-4744" SRC_SYSTEM_CODE = "WMIS" SRC_SYSTEM_INSTANCE = "WMIS">
    <CMP_LAW_WR_CRE_UPD>
    <DATETIME>12/19/2005</DATETIME>
    <RUSCODE>100</RUSCODE>
    <WRNO>38213</WRNO>
    </CMP_LAW_WR_CRE_UPD>
    </MSG_LAW_WR_CRE_UPD>'),'//DATETIME/text()') FROM DUAL;
    hope this helps.

  • How to read XL file from FTP server

    Hi all,
    I have a requirement like to read file from FTP server using path
    ftp:
    10.212......\DTR\DTR_ Accounted_Out
    and again save  other file in same location ,
    to doing this RFC connection is required?
    give a  procedure or program to do this requirement ..
    To create rfc for FTP which connection type can i use ?
    Give complete settings to create rfc destination

    Hi Rakhi,
    Use the below code to check if you have received the proper data.
    call function 'FTP_SERVER_TO_R3' "Get data as character instead of BLOB
        exporting
          handle         = hdl
          fname          = docid
          character_mode = 'X'
        tables
          text           = chardata.
    If the data is incorrect, it is possible that you are in the wrong directory.
    Use
    call function 'FTP_COMMAND'
        exporting
          handle        = hdl
          command       = 'cd mydir\mysubdir' "cd <space> your path
        tables
          data          = result
        exceptions
          tcpip_error   = 1
          command_error = 2
          data_error    = 3.
    Regards,
    Jovito.

  • How to read .xls file from FTP server t oInternal table

    Hi
    am using the FTP_SERVER_TO_R3 to read xls file from FTP server to internal table
    but the data i get in LT_TEXT is special characters.
    CALL FUNCTION 'FTP_SERVER_TO_R3'
    EXPORTING
    handle = hdl
    fname = f_name "ProdDataFromCRM.xls.
    * CHARACTER_MODE = 'X'
    * IMPORTING
    * BLOB_LENGTH =
    TABLES
    BLOB = lt_text
    * TEXT = lt_text
    EXCEPTIONS
    TCPIP_ERROR = 1
    COMMAND_ERROR = 2
    DATA_ERROR = 3
    OTHERS = 4
    can any one help me out to get the exact data..
    Really appreciate your quick response..
    Thank You

    Hi, if you really retrieve an excel file, you can not see the data in ABAP. You may see them in Excel. For this you may use
    CALL METHOD document->open_document_from_table
    of the interface i_oi_document_proxy for OLE objects. You can access the data with reference to the interface i_oi_spreadsheet.
    Please check [Desktop Office Integration (BC-CI)|http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCCIOFFI/BCCIOFFI.pdf] for details.
    But, who knows, perhaps you want "And Now For Something Completely Different".
    Regards
    Clemens

  • What are the commands available to read a file from application server and

    What are the commands available to read a file from application server and store the file into an internal table?

    Hi,
    To read a file from an Application Server to an Object there is a command in ABAP called <b>READ DATASET</b>. After that file is transported to that object you have to do a loop and put that data in an Internal Table.
    This statement exports data from the file specified in dset into the data object dobj. For dobj, variables with elementary data types and flat structures can be specified. In Unicode programs, dobj must be character-type if the file was opened as a text file.
    For dset, a character-type data object is expected - that is, an object that contains the platform-specific name of the file. The content is read from the file starting from the current file pointer. After the data transfer, the file pointer is positioned after the section that was read. Using the MAXIMUM LENGTH addition, the number of characters or bytes to be read from the file can be limited. Using ACTUAL LENGTH, the number of characters or bytes actually used can be determined.
    In a Unicode program, the file must be opened with an arbitrary access type; otherwise, an exception that cannot be handled will be triggered.
    If the file has not yet been opened in anon-Unicode program, it will be implicitly opened as a binary file for read access using the statement
    OPEN DATASET dset FOR INPUT IN BINARY MODE.
    . If a non-existing file is accessed, an exception that can be handled can be triggered.
    Influence of Access Type
    Files can be read independently of the access type. Whether data can be read or not depends solely on the position of the file pointer. If the latter is at the end of the file or after the file, no data can be read and sy-subrc will be set to 4.
    Influence of the Storage Type
    The import function will take place irrespective of the storage type in which the file was opened with the statement OPEN DATASET.
    If the file was opened as a text file or as a legacy text file, the data is normally read from the current position of the file pointer to the next end-of-line marking, and the file pointer is positioned after the end-of-line marking. If the data object dobj is too short for the number of read characters, the superfluous characters and bytes are cut off. If it is longer, it will be filled with blanks to the right.
    If the file was opened as a binary file or as a legacy-binary file, as much data is read that fits into the data object dobj. If the data object dobj is longer than the number of exported characters, it is filled with hexadecimal 0 on the right.
    If the specified storage type makes conversion necessary, this is executed before the assignment to the data object dobj. Afterwards, the read data is placed, byte by byte, into the data object.
    System Fields
    sy-subrc Meaning
    0 Data was read without reaching end of file.
    4 Data was read and the end of the file was reached or there was an attempt to read after the end of the file.
    Thanks,
    Samantak.
    <b>Rewards points for useful answers.</b>

  • Problem while reading the file from FTP server

    Hi Friends,
    I have a problem while fetching files from FTP server.
    I used FTP_Connect, FTP_COMMAND function modules. I can able to put the files into FTP server.
    but I cant able to pick the files from FTP server.
    anyone have faced similar issues kindly let me know.
    Thanks
    Gowrishankar

    Hi,
    try this way..
    for reading the file using FTP you need to use different unix command ..
    Prabhuda

  • Copy file from FTP server to sap application server

    Hi,
    I am able to copy a particular file from FTP server to sap application server using FTP_CONNECT, FTP_COMMAND and FTP_DISCONNECT. But here my problem is, it copies into default application server path(DIR_HIOME). I want to copy into specified folder in the application server. How can I specify the required destination path.
    Can you please suggest how to achieve this.
    Thanks,
    Shiva Kankanala

    try something like this:
    data: user(30) type c value 'ftpuser', "ftp username
                  pwd(30) type c value 'ftppass', "ftp password
                  host(64) type c value '255.255.255.255', "ftp server IP
                  cmd1(80) type c value 'lcd /dump', "location on app server where you want to copy the file
                  cmd2(80) type c value 'get', "specifies you are going to get the file from ftp server
                  dest like rfcdes-rfcdest value 'SAPFTPA',
                  file(15) type c value 'file.txt'. "specifies file that you want to get from ftp server
    data: hdl type i,
            key type i value 26101957,
            slen type i.
    slen = strlen( pwd ).
    call function 'HTTP_SCRAMBLE'
        EXPORTING
          source      = pwd
          sourcelen   = slen
          key         = key
        IMPORTING
          destination = pwd.
    call function 'FTP_CONNECT'
        EXPORTING
          user            = user
          password        = pwd
          host            = host
          rfc_destination = dest
        IMPORTING
          handle          = hdl.
    call function 'FTP_COMMAND'
        EXPORTING
          handle        = hdl
          command       = cmd1
        TABLES
          data          = result
        EXCEPTIONS
          command_error = 1
          tcpip_error   = 2.
      loop at result.
        write at / result-line.
      endloop.
    CONCATENATE cmd2 file INTO cmd2 SEPARATED BY SPACE.
    call function 'FTP_COMMAND'
          EXPORTING
            handle        = hdl
            command       = cmd2
          TABLES
            data          = result
          EXCEPTIONS
            command_error = 1
            tcpip_error   = 2.
        loop at result.
          write at / result-line.
        endloop.
        refresh result.

  • Downloading file from ftp server

    hii
    how do i download the file from ftp server. plz suggest wat are the function modules for tht.. and plz do give the values of the parameters used in the fn modules
    points guranteed:-)

    <i><b>*--> Scramble the password.</b></i>
      CALL FUNCTION 'SCRAMBLE_STRING'
           EXPORTING
                source = password
                key    = 26101957
           IMPORTING
                target = password.
    <i><b>*--> Connect to the FTP server.</b></i>
    <i>*  user is the logon user for the FTP server.
    password is the password you have just scrambled.
    host is the ip address of the FTP server.
    rfc_destination is 'SAPFTPA'.</i>
      CALL FUNCTION 'FTP_CONNECT'
           EXPORTING
                user                = user
                password        = password
                host                = host
                rfc_destination = rfc_destination
           IMPORTING
                handle          = wa_handle
           EXCEPTIONS
                not_connected   = 1
                OTHERS          = 2.
    <i><b>*--> Carry out the command on the FTP server</b></i>
    <i>*  wa_command is the command you wish to carry out on the FTP server (e.g.   
    wa_command = 'ascii' will specify ascii mode).  Result_itab will contain the
    result of your commands.</i>
      CALL FUNCTION 'FTP_COMMAND'
           EXPORTING
                handle           = wa_handle
                command       = wa_command
           TABLES
                data          = result_itab
           EXCEPTIONS
                tcpip_error   = 1
                command_error = 2
                data_error    = 3
                OTHERS        = 4.
    <b>*--> Disconnect from the target host.</b>
      CHECK NOT wa_handle IS INITIAL.
      CALL FUNCTION 'FTP_DISCONNECT'
           EXPORTING
                handle = wa_handle
           EXCEPTIONS
                OTHERS = 1.
    <u><i><b>Hope this helps :)</b></i></u>

Maybe you are looking for

  • RAW CR2 NOT LOADING IN REVIEW LION 10.7.3 MAC PRO

    After upgrading to Lion 10.7.3, Adobe, Canon RAW CR2 files are not previewable. I don't use iPhoto and if I did, apaerantly I'd have to buy that upgrade (NOT INCLUDED IN LION?) from ver. 7 to ver.11? I'm pretty much done with spending money pointless

  • How to assign approval task to a person who is not a member of the site

    Hi All, I need to assign approval task to a person who is not a member of site but member of team site. I know that if a person need to approve/reject task form should have atleast contribute permission. Is it possible to assign contribute permission

  • Setting up wireless printer with Time Capsule

    I've just replaced my original Time Capsule after it had a terminal power failure. The replacement Time Capsule is working okay as a backup and I have set up my wireless network again, but now I can't print using my Canon MX860 printer, which had bee

  • Report 3.0 + Outlook Express

    Trabajando bajo Windows/95/98 al intenter enviar un informe desde el visor de report3.0 a Microsoft Outlook obtengo los mensajes de error : REP-4201 REP-4220 null

  • How do I view dbf files?

    Can anyone help with some (preferably free) software which will allow me to view dbf files generated by Arcview. They're pretty ordinary, in table format. Excel just doesn't do it; text, Word, rtf all lose the structure.