Write records to a Flat file & Ftp to a remote server

I know this would be a basic question for most of the ppl in this forum, but I am stuck in here.
There is a "Orders" table, and when new orders are made , I need to build a file with relevant information(extracted from tables) and FTP to a remote server.There should be a SQL job that would run for every 30 mins to see if there are any new orders made , and if so, Write them to a file and FTP back to a remote server.
The orders that were written to a file previously shouldn't appear when new files are created.
How can this be done..?
Thanks in advance..

You'd need 3 basic components here
1) Something to identify new orders
2) Something to write whatever data you want to a flat file
3) Something to FTP that file
#2 is going to be the UTL_FILE package
#3 is going to require a third-party PL/SQL (or Java) FTP library. If you do a Google search on UTL_FTP, you'll find a few such PL/SQL packages or you can download an appropriate Java class and load that into the database.
#1 can be as simple as a Status column that gets set to NEW initially and PROCESSED when the file is generated. Or it could get a lot more complicated with something like Streams capturing changes to the table and sending those change records to a separate consumer process that would then generate the file and FTP it.
Justin

Similar Messages

  • Saving records to a flat file

    Dearest experts,
    I do need your kindest assistance.
    I have over 15 fieldnames from 11 tables.
    Some of these fieldnames are mandatory fieldnames and others are optional.
    The users are instructed to enter 'NA' to any to any fieldname that doesn't have a value.
    So far, that has not been the case. Sometimes, they enter 'NA' to some fieldnames.
    Some other times, they leave them blank. So, there is really noway to know which fieldnames would be left blank, we are forced now to come up with pl/sql script that will do 2 things:
    1, select all of those 15 records, and with the help of an if else statement, or even CASE or DECODE, come up with a catch_all code that is something like:
    if this fieldname is blank, assign 'NA' to it.
    2, Save the newly corrected records to a flat file.
    I will be forever indebted if you can give me a hand on this.
    Thanks very much.

    Great guy, thank you Warren!
    a couple of more follow-ups, please?
    Silly question 1, does NVL work with numeric values like 0 as well?
    Second, if I need to trim some stuff off and I need to use something like Substr, can I fit that into NVL?
    Thank you soooo very much

  • Saving database records in a flat file

    I am trying to save data from relational database into a flat file and then read back records based on the certain criteria.
    What will be a good approach for me? Should I use random access files or sequential files for storing and
    retrieving data or is there some other technique that is more efficient that I can use.
    Thanks

    I don't think that reading database records from a flat file based on certain criteria is a good approach, no matter how you produce the flat file. Using a second database table makes more sense to me, especially since you already have database software available and ready for use.
    (You asked about a "good approach" and then you wanted a technique that was "more efficient". Those two aren't the same thing at all.)

  • How to generate blank spaces at end of the record in a flat file with fixed

    Hi,
    I am generating a flat file with fixed length.
    In my ABAP program, i am able to see the spaces at the end of the recors in debug but when download to applicaiton server i am not able to see those spaces.
    How can i generate blank spaces at the end of the record in a flat file?
    Please update
    Thank you

    How are you downloading the file?  And, How are you looking at the file on the application server?
    Can you provide snippets of your code?
    Cheers
    John

  • Sql loader issue(How to specify a file that exists on remote server)

    In sqlldr infile parameter I'd like to give a data file that exists on remote server.How can I specify???Please help me in the syntax.
    Any help would be greatly appreciated.
    Edited by: 792353 on Sep 24, 2010 7:22 AM

    sqlldr can accept any path that is VALID and it can be any type of share as long as the OS supports the share.
    so INFILE can be anything you want as sqlldr will simply attempt to access it via the OS.
    if you are on a linux box going to another linux box with an NSF mount point on the box running sqlldr simply reference:
    INFILE '/mountpoint/fname'
    Now I have never tried a UNC path before but I would guess that if you are on a windows box, going to another winddows box and the box running sqlldr was logged in with the right permissions it would simply be:
    INFILE '\\server\directory\file'
    I doubt that it will accept a URL as in:
    INFILE '//servername.com/directory/file'
    I don't think that sqlldr does anonymous ftp or htp file transfer protocol, but I could be wrong.
    NOTE: I have found that it is best to ALWAYS surround your INFILE parameter with single quotes.

  • Flat file Ftp Adapter

    How can a I produce a flat file with ftp adapter for a receiving application?
    Source XML > Destination Flat File

    I do not think that you can use any of the standard adapters directly to produce af flat file.
    You might be able to use D3L, of which I do not know much. In any way I would prefer to arrange my data as XML if possible.
    To solve the flat file problem I would customize the standard ftp adapter by implementing the ReceiverCustomizer interface. How to do this you can see in the ftp adapters userguide on page 3-6. I hope you have the userguide yourself. I could not google it on the internet.
    By implementing this interface you are able to change the output of the ftp adapter before it is delivered.
    Regards,
    Peter

  • How can i duplicate records from a flat file to a cube

    Hi all,
    i got the next problem, i m loading a flat file, fur example:
    Material KF1 KF2
    A 10 12
    B 25 30
    01 02
    I Need duplicate the records for material A and B but with the values of Not assign, in other words the result in the cube would be like this:
    Material KF1 KF2
    A 10 12
    B 25 30
    01 02
    A 01 02
    B 01 02
    How can i do this, i know this must be a rutine, but where in the star? final? expert rutine? and how would be the code to do it, help guys and thanks!

    you can use end routine to accomplish that...
    hope the below code helps...
    DATA : IT_RESULT_PACKAGE LIKE TABLE OF RESULT_PACKAGE.
    DATA : WA_RESULT_PACKAGE LIKE RESULT_PACKAGE.
    SORT RESULT_PACKAGE BY MATERIAL.
    IT_RESULT_PACKAGE[] = RESULT_PACKAGE[].
    LOOP AT RESULT_PACKAGE ASSIGNING <RESULT_FIELDS>.
    READ TABLE RESULT_PACKAGE INTO WA_RESULT_PACKAGE WITH KEY MATERIAL IS INITIAL BINARY SEARCH.
    IF SY-SUBRC = 0.
    WA_RESULT_PACKAGE-MATERIAL = <RESULT_FIELDS>-MATERIAL.
    APPEND WA_RESULT_PACKAGE INTO IT_RESULT_PACKAGE.
    CLEAR WA_RESULT_PACKAGE.
    ENDIF.
    ENDLOOP.
    CLEAR RESULT_PACKAGE[].
    RESULT_PACKAGE[] = IT_RESULT_PACKAGE[].
    this code will be suitable only if the material as unique entry with initial value...
    else you would require to use a loop statement instead of the read statement which has been used...
    rgds, Ghuru

  • Processing selected range of record from a flat file.

    Hi,
    I am having a requirement like, I have a flat file as source with large number of records and oracle table as target. But i will be using 3 interfaces to process those records.
    Each interface will process 100 records. How to achieve this part? How to count records and add filter to the source so that I can achieve this part?
    Thanks.
    Regards.

    Yes. I assume that the header lines and the lines with the data are formatted differently. If so, you can process the file a line at a time and use a regualr expression to match the data lines. If the regular expression matches use that line. If it doesn't match then simply ignore that line of text.
    You can either read the file a line at a time or read the entire file and process the text a line at a time. If you may be processing large files I recommend reading the file a line at a time. Reading very large files in one read can be very slow. Reading the same file in chunks will be much faster.
    Mark Yedinak
    "Does anyone know where the love of God goes when the waves turn the minutes to hours?"
    Wreck of the Edmund Fitzgerald - Gordon Lightfoot

  • XI 7.0 Flat File FTP Transfer

    We have an ERP 2005-NetWeaver system installed and in process.  In the XI(now called PI) we have it set up properly checked x3 by 2 different people and the SM and SLD up and configured.  Our first Business Scenario was to pull an iDoc from ERP 2005 and deliver it to the PO for a Legacy non-SAP system.  It eventually worked, the problem turned out to be "rights".
       Scenario 2 is to pull a Flat File via adapter FTP:// from the FTP Server to the ERP 2005 system. It dosn't work, log below, it appears to just disappear somewhere between the FTP:// server and the XI box integration engine or before.  We have tested the FTP Transfer from each machine using the MS Srvr FTP service and it works there just fine (even used the exact same sub-directories and user/attributes. We have also changed OS rights on the:
      .../XIREPOSITORY/* and all sub-directories to: Group;Everyone, Role: Full Control.  We have done numerous other things I'm too embarrassed to even mention, yet we still get the same response:
    <u><b>HOCFTP2MAIL_Sender</b></u>
    Sender Adapter v2703 for Party 'Holly_DataStream', Service 'HOC_Read DataStreamFile.'
    Configured at 2006-06-13  10:53:03  CDT
    History:
    -2006-06-13 13:11:03:09 CDT: Processing started
    -2006-06-13 13:11:02:09 CDT: Error: Retrieving file 'LOADPAYABLE1.xml' failed unexpectedly:  FTPEx: Directory does not exists
    -2006-06-13 13:11:02:08 CDT: Processing started
    -2006-06-13 13:11:02:08 CDT: Error: Retrieving file 'LOADPAYABLE1.xml' failed unexpectedly:  FTPEx: Directory does not exists
    -2006-06-13 13:11:02:07 CDT: Processing started
    HOC READFile is set to 'inactive' as it never yeiled any information of use at this problem just one mamonth file.

    Pat
    It clearly says that it dont have the directory. Also eventhough it is there might be you would have given wrong credentials. So can you please once again give and check? After this go to sxmb_moni and check whether you find any error?
    In the last try to check the message display tool so that you can know till where your message has flown? You can log into the message display tool from http://<hostname>:<portno>/MessagingSystem/monitor/auditlog.jsp
    Regards,
    ---Satish

  • Diifferent java apllications write to the same flat file database

    I have a variety of java applications that need to be able to write diagnostics to the same flat file database (containes just one file). Could somebody give me the pointers what is the best way to write my applications so that different application not need to worry about the updates in file?
    They should be able to write whenever they want.

    JavaFunda wrote:
    I have a variety of java applications that need to be able to write diagnostics to the same flat file database (containes just one file). Could somebody give me the pointers what is the best way to write my applications so that different application not need to worry about the updates in file?I guess my question would be: is it a file or a database (as in an RDB)?
    I think EJP's post was aimed at syncing writes to files (and he'll definitely tell me if I'm wrong : )), but it may be redundant if, in fact, your output is going to a database.
    Also, Java has some quite sophisticated logging applications (I believe log4j is quite popular; but there are others), which may serve your needs.
    Winston

  • Export records into a flat file

    Hi...
    I have to export some tables into a flat file. The output must be like this:
    insert into table (col1, col2.....) value (one, two......)
    insert into table (col1, col2.....) value (one, two......)
    insert into table (col1, col2.....) value (one, two......)
    how can I do that.......with PLSQL code?
    Thanks
    Message was edited by:
    marckcos

    I got this package : and I got the follwing error:
    4:35:19 PM Execution failed: ORA-20011: GENERATE_STMT Error in populating file. Message: ORA-00904: "CHANGE_DATATYPE": invalid identifier
    What can I do?
    CREATE OR REPLACE PACKAGE BODY UTILITY
    IS
    -- VARIABLES USED by PROCEDURE generate_stmt
    -- File Related PACKAGE Variable
    cmn_file_handle UTL_FILE.file_type;
    PROCEDURE close_file
    IS
    BEGIN
    UTL_FILE.FCLOSE (cmn_file_handle);
    EXCEPTION
    WHEN UTL_FILE.INVALID_FILEHANDLE THEN
    RAISE_APPLICATION_ERROR(-20003, 'File handle was invalid');
    WHEN UTL_FILE.INVALID_PATH THEN
    RAISE_APPLICATION_ERROR(-20004, 'Invalid path for file');
    WHEN OTHERS THEN
    RAISE_APPLICATION_ERROR(-20005, 'CLOSE_FILE Error in creating file. Message: ' || SQLERRM);
    END close_file;
    PROCEDURE open_file (
    prm_output_folder IN VARCHAR2,
    prm_output_file IN VARCHAR2)
    IS
    BEGIN
    cmn_file_handle := UTL_FILE.FOPEN (prm_output_folder, prm_output_file, 'a', 32767);
    EXCEPTION
    WHEN UTL_FILE.INVALID_FILEHANDLE THEN
    close_file;
    RAISE_APPLICATION_ERROR(-20000, 'File handle was invalid');
    WHEN UTL_FILE.INVALID_PATH THEN
    close_file;
    RAISE_APPLICATION_ERROR(-20001, 'Invalid path for file');
    WHEN OTHERS THEN
    close_file;
    RAISE_APPLICATION_ERROR(-20002, 'OPEN_FILE Error in creating file. Message: ' || SQLERRM);
    END open_file;
    FUNCTION change_datatype (
    prm_value IN VARCHAR2,
    prm_data_type IN VARCHAR2)
    RETURN VARCHAR2
    IS
    BEGIN
    IF prm_value IS NULL THEN
    RETURN ('NULL');
    END IF;
    IF prm_data_type = 'C' THEN
    IF INSTR(prm_value, CHR(10)) > 0 THEN
    RETURN ('REPLACE(' || '''' || REPLACE (prm_value, CHR(10), CHR(977)) || '''' || ', CHR(977), CHR(10))');
    END IF;
    ELSIF prm_data_type = 'D' THEN
    RETURN ('TO_DATE(' || '''' || prm_value || '''' || ', ' || '''' || 'DD-MON-YYYY HH24:MI:SS' || '''' || ')');
    ELSIF prm_data_type = 'N' THEN
    RETURN (prm_value);
    END IF;
    RETURN ('''' || prm_value || '''');
    EXCEPTION
    WHEN OTHERS THEN
    RAISE_APPLICATION_ERROR(-20002, 'CHANGE_DATATYPE Error in Converting DataType. Message: ' || SQLERRM);
    END change_datatype;
    PROCEDURE generate_stmt (
    prm_table_name IN VARCHAR2,
    prm_where_clause IN VARCHAR2,
    prm_output_folder IN VARCHAR2,
    prm_output_file IN VARCHAR2)
    IS
    TYPE ref_cols IS REF CURSOR;
    mmy_ref_cols ref_cols;
    mmy_column_name VARCHAR2(100);
    mmy_column_data_type VARCHAR2(1);
    mmy_col_string VARCHAR2(32767);
    mmy_query_col_string VARCHAR2(32767);
    BEGIN
    IF prm_table_name IS NULL OR
    prm_output_folder IS NULL OR
    prm_output_file IS NULL THEN
    RAISE_APPLICATION_ERROR(-20012, 'Invalid Argument Passed');
    END IF;
    OPEN mmy_ref_cols
    FOR SELECT LOWER(column_name) column_name,
    DECODE (data_type, 'VARCHAR2', 'C', 'CHAR', 'C', 'LONG', 'C', 'NUMBER', 'N', 'DATE', 'D') data_type
    FROM user_tab_columns
    WHERE table_name = UPPER(prm_table_name)
    ORDER BY column_id;
    LOOP
    FETCH mmy_ref_cols INTO mmy_column_name, mmy_column_data_type;
    EXIT WHEN mmy_ref_cols%NOTFOUND;
    mmy_col_string := mmy_col_string || mmy_column_name || ', ';
    IF mmy_column_data_type = 'D' THEN
    mmy_query_col_string := mmy_query_col_string || 'change_datatype(' || 'TO_CHAR(' || mmy_column_name || ', ' || '''' || 'DD-MON-YYYY HH24:MI:SS' || '''' || ')' || ', ' || '''' || mmy_column_data_type || '''' || ') || ' || '''' || ', ' || '''' || ' || ';
    ELSIF mmy_column_data_type IN ('N', 'C') THEN
    mmy_query_col_string := mmy_query_col_string || 'change_datatype(' || mmy_column_name || ', ' || '''' || mmy_column_data_type || '''' || ') || ' || '''' || ', ' || '''' || ' || ';
    END IF;
    END LOOP;
    CLOSE mmy_ref_cols;
    IF mmy_col_string IS NOT NULL AND
    mmy_query_col_string IS NOT NULL THEN
    IF NOT UTL_FILE.IS_OPEN(cmn_file_handle) THEN
    open_file(prm_output_folder, prm_output_file);
    END IF;
    mmy_col_string := 'INSERT INTO ' || LOWER(prm_table_name) || ' (' || CHR(10) || CHR(9) || CHR(9) || mmy_col_string;
    mmy_col_string := RTRIM (mmy_col_string, ', ');
    mmy_col_string := mmy_col_string || ')' || CHR(10) || 'VALUES ( ' || CHR(9);
    mmy_query_col_string := RTRIM (mmy_query_col_string, ' || ' ||'''' || ',' || '''' || ' || ') || ' one_pare';
    OPEN mmy_ref_cols
    FOR ' SELECT ' || mmy_query_col_string ||
    ' FROM ' || prm_table_name ||
    ' ' || prm_where_clause;
    LOOP
    FETCH mmy_ref_cols INTO mmy_query_col_string;
    EXIT WHEN mmy_ref_cols%NOTFOUND;
    mmy_query_col_string := mmy_query_col_string || ');';
    UTL_FILE.put (cmn_file_handle, mmy_col_string);
    UTL_FILE.put_line (cmn_file_handle, mmy_query_col_string);
    END LOOP;
    CLOSE mmy_ref_cols;
    If UTL_FILE.IS_OPEN(cmn_file_handle) THEN
    close_file;
    END IF;
    END IF;
    EXCEPTION
    WHEN UTL_FILE.INVALID_FILEHANDLE THEN
    IF mmy_ref_cols%ISOPEN THEN
    CLOSE mmy_ref_cols;
    END IF;
    close_file;
    RAISE_APPLICATION_ERROR(-20009, 'File handle was invalid');
    WHEN UTL_FILE.INVALID_PATH THEN
    IF mmy_ref_cols%ISOPEN THEN
    CLOSE mmy_ref_cols;
    END IF;
    close_file;
    RAISE_APPLICATION_ERROR(-20010, 'Invalid path for file');
    WHEN OTHERS THEN
    IF mmy_ref_cols%ISOPEN THEN
    CLOSE mmy_ref_cols;
    END IF;
    close_file;
    RAISE_APPLICATION_ERROR(-20011, 'GENERATE_STMT Error in populating file. Message: ' || SQLERRM);
    END generate_stmt;
    END utility;
    ############################################################

  • Flat file data load through appln server # gets generated at each line

    Hi all,
    I am loading the data from flat file which is placed on the application server.
    At the end of each record i can see a # getting generated.
    While loading the data in bw 3.5 i am getting an error message. Can anyone pls let me know how to handle this issue through application server!!
    Thanks
    Pooja

    Hi Pooja,
    I had faced similar kind of issue in my earlier project.
    The issue is the way of uploading file to application server. Again, i m not say the format of file, but the way the file is uploaded. Normally there are 2 type of uploading, Binary and ASCII. If the file format is CSV and the Appl Server is Windows than, ASCII format is recommended. If it is uploaded in any other format, then the newline is not identified and converted to # - which result to error while loading the data.
    I had to put lot of time to find out the correct combination. And then later on train the user to upload it right way. My user used to upload the data by using some FTPPro software.
    Even after training, i had to have a manual check the file through AL11 everytime before load but after sometime user got trained and the problem was solved.
    Hope this helps.
    Regards
    Raj

  • FM to tansfer data in flat file from presentation to application server

    Hi Experts,
    Please tell the FM to tansfer data in flat file from presentation server to application server or vice versa in ECC 6.0.
    Thanks.

    Hi,
    This is how you can achieve it:
    1. You read the flat file from presentation layer and store the file content in internal table gt_inrec
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename                = gw_filename
          filetype                = 'ASC'
        IMPORTING
          filelength              = gw_length
          header                  = gw_header
        TABLES
          data_tab                = gt_inrec
        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.
    2. Create a new file at the application server:
      OPEN DATASET p_ofile FOR OUTPUT IN
      TEXT MODE ENCODING DEFAULT.
    3. Transfer the content from the internal table into the file at the application server:
        LOOP AT gt_inrec.
          TRANSFER gt_inrec-record TO p_ofile.
        ENDLOOP.
    Hope it helps,
    Lim....

  • Process for Flat file delta load from Application server to transactional??

    I want to do a flat file extraction in delta loads from application server and that should be loaded into a transactional cubes scheduling a process chain.
    Can any one help with ABAP code and step by step process for this?
    Thank you
    Devi

    Hi Devi,
    As per your explaination, you want to load a list of files from application server using process chain.
    You can do this with below steps.
    1) Create a Event and call event to run Process chain multiple times.
    2) Put all filenames in a file say, source-File
    3) Write a rooting to read filename from Source-File and trigger InfoPackage
    4) At the end of the process chain create new customized program which will delete first line from Source-File so that it will take next file in next run as well as delete currently loaded file. Once this is done trigger event again to start process chain again.
    Regards,
    Ganesh

  • Is it possible to load flat file data residing on a local machine via BODS 4.2 or flat file should reside on BODS server?

    Hi All,
    I have a requirement to load data from flatfiles stored on particular location, on a machine on which BODS client istallation is there.
    I am able to create a flat file format by browsing the file location and giving file name.I can view the file data also.
    But when I execute the job, job failswith the error "Cannot open file <D:/BODS_flatfiles/result.txt>. Check its path and permissions".
    Please let me know whether it is possible to load data from flat file on a local machine, which has BODS4.2 client installated on it or the flat file should reside in a path in BODS job server ?
    Thanks,
    Deepa

    Hi Deepa,
    If you get solution then please mark answer as correct and close the tread!
    Thanks,
    Swapnil

Maybe you are looking for