Dump data from server (unix) into flat file on client (PC) on regular schedule

Hi folks,
I wish to dump the contents of a table (Oracle on Unix) into a file residing in a local directory (PC client). I know how to use utl_file but, init.ora resides on unix, therefore it will create file on unix directory and not the client machine.
Any ideas?

Hi Bro
if u wan to write a file on Server use this code..
procedure write_file
filename varchar2,
mesg varchar2
is
hfile_handle utl_file.file_type;
begin
begin
file_handle := utl_file.fopen( '<FILE_PATH_HERE>', filename, 'A');
exception
when utl_file.invalid_path then
dbms_output.put_line('invalid path dummy');
when utl_file.invalid_operation then
file_handle := utl_file.fopen( '<FILE_PATH_HERE>', filename, 'W');
when others then
raise;
end;
utl_file.put( hfile_handle , mesg);
utl_file.fclose( hfile_handle );
exception
when utl_file.invalid_path then
dbms_output.put_line('invalid path dummy');
when utl_file.invalid_operation then
dbms_output.put_line('invalid opertaion dummy');
when others then
raise;
end write_file;
==================================================
and If you want it in the client you can use the one given below.
declare
file_handle text_io.file_type;
L_file_name := 'C:\Folder1\Filename.txt';
begin
file_handle := text_io.fopen(L_file_name,'w'); (mode should be 'a' instead of 'w' if u want to append)
text_io.put_line(file_handle,l_data) ;
text_io.fclose(file_handle) ;
end;
4 any help plz write me
Khurram.

Similar Messages

  • Import data from Oracle table into flat file

    How to import the data in the oracle table into flat file using UTL File of PL/SQL....
    I am new in PL/SQL..
    can someone help me in writing query?

    Note : Not Tested.
    DECLARE
    V1 VARCHAR2(32767);
    F1 UTL_FILE.FILE_TYPE;
    cursor c1 is select ename,empno from emp;
    r_c1 c1%rowtype;
    BEGIN
    -- In this example MAX_LINESIZE is less than GET_LINE's length request
    -- so the number of bytes returned will be 256 or less if a line terminator is seen.
    open c1;
    F1 := UTL_FILE.FOPEN('MYDIR','MYFILE','W',256);
    loop
    fetch c1 into r_c1;
    v1:= r_c1.ename||''||To_char(r_c1.empno);
    UTL_FILE.PUT_LINE (F1, v1,TRUE);
    v1:= null;
    Exit when c1%not found;
    end loop;
    UTL_FILE.FCLOSE(F1);
    END;
    http://download.oracle.com/docs/cd/B19306_01/appdev.102
    ------------------------------------------------------------------

  • Extracting data from Essbase & loading into flat file through ODI

    Hi,
    I want to extract data from Essbase and load it into a flat file through ODI(for extraction from essbase I'm using a report script) and I’m using these KM’s:- LKM Hyperion Essbase data to SQL,IKM SQL to FILE Append & for reversing I’m using RKM Hyperion Essbase.All the mappings have been done and the interface has been made. But when I’m executing the interface it is throwing the error below:-
    ODI-1217: Session ESS_FILEI (114001) fails with return code 7000.
    ODI-1226: Step ESS_FILEI fails after 1 attempt(s).
    ODI-1240: Flow ESS_FILEI fails while performing a Loading operation. This flow loads target table ESS_FILE.
    ODI-1228: Task SrcSet0 (Loading) fails on the target FILE connection FILE_PS_ODI.
    Caused By: java.sql.SQLException: ODI-40417: An IOException was caught while creating the file saying The system cannot find the path specified
    at com.sunopsis.jdbc.driver.file.impl.commands.CommandCreateTable.execute(CommandCreateTable.java:62)
    at com.sunopsis.jdbc.driver.file.CommandExecutor.executeCommand(CommandExecutor.java:33)
    at com.sunopsis.jdbc.driver.file.FilePreparedStatement.execute(FilePreparedStatement.java:178)
    at oracle.odi.runtime.agent.execution.sql.SQLCommand.execute(SQLCommand.java:163)
    at oracle.odi.runtime.agent.execution.sql.SQLExecutor.execute(SQLExecutor.java:102)
    at oracle.odi.runtime.agent.execution.sql.SQLExecutor.execute(SQLExecutor.java:1)
    at oracle.odi.runtime.agent.execution.TaskExecutionHandler.handleTask(TaskExecutionHandler.java:50)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.processTask(SnpSessTaskSql.java:2906)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java:2609)
    at com.sunopsis.dwg.dbobj.SnpSessStep.treatAttachedTasks(SnpSessStep.java:537)
    at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java:453)
    at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java:1740)
    at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$2.doAction(StartSessRequestProcessor.java:338)
    at oracle.odi.core.persistence.dwgobject.DwgObjectTemplate.execute(DwgObjectTemplate.java:214)
    at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.doProcessStartSessTask(StartSessRequestProcessor.java:272)
    at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.access$0(StartSessRequestProcessor.java:263)
    at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$StartSessTask.doExecute(StartSessRequestProcessor.java:822)
    at oracle.odi.runtime.agent.processor.task.AgentTask.execute(AgentTask.java:123)
    at oracle.odi.runtime.agent.support.DefaultAgentTaskExecutor$2.run(DefaultAgentTaskExecutor.java:82)
    at java.lang.Thread.run(Thread.java:619)
    Please let me know what I'm missing and how I can resolve this error.
    Thanks

    It seems that you are trying to use the file as your staging areas. Hyperion LKM extracts essbase data into a DB staging area which can then be used by your file IKM to load it into file.
    You need to use a RDBMS for your staging area.

  • Download data from internal table to flat file.

    I need to download the data from Internal table to Flat file. can any one suggest how to do it? i suppose WS_Download OR GUI_DOWNLOAD.
    but if it is please guide me how to use this.
    is thre any other F.M. please provide the information.
    Thanks in advance

    Hi,
    Try this,
    * File download, uses older techniques but achieves a perfectly
    * acceptable solution which also allows the user to append data to
    * an existing file.
      PARAMETERS: p_file like rlgrap-filename.
    * Internal table to store export data  
      DATA: begin of it_excelfile occurs 0,
       row(500) type c,
       end of it_excelfile.
      DATA: rc TYPE sy-ucomm,
            ld_answer TYPE c.
      CALL FUNCTION 'WS_QUERY'
           EXPORTING
                query    = 'FE'  "File Exist?
                filename = p_file
           IMPORTING
                return   = rc.
      IF rc NE 0.                       "If File alread exists
        CALL FUNCTION 'POPUP_TO_CONFIRM'
          EXPORTING
    *          TITLEBAR              = ' '
    *          DIAGNOSE_OBJECT       = ' '
               text_question         = 'File Already exists!!'
               text_button_1         = 'Replace'
    *          ICON_BUTTON_1         = ' '
               text_button_2         = 'New name'
    *          ICON_BUTTON_2         = ' '
    *          DEFAULT_BUTTON        = '1'
    *          DISPLAY_CANCEL_BUTTON = 'X'
    *          USERDEFINED_F1_HELP   = ' '
    *          START_COLUMN          = 25
    *          START_ROW             = 6
    *          POPUP_TYPE            =
          IMPORTING
               answer                = ld_answer
    *     TABLES
    *         PARAMETER              =
          EXCEPTIONS
              text_not_found         = 1
              OTHERS                 = 2.
    * Option 1: Overwrite
        IF ld_answer EQ '1'.
          CALL FUNCTION 'GUI_DOWNLOAD'
            EXPORTING
    *            BIN_FILESIZE            =
                 filename                = p_file        "File Name
                 filetype                = 'ASC'
    *       IMPORTING
    *            FILELENGTH              =
            TABLES
                data_tab                = it_excelfile   "Data table
            EXCEPTIONS
                file_write_error        = 1
                no_batch                = 2
                gui_refuse_filetransfer = 3
                invalid_type            = 4
                OTHERS                  = 5.
          IF sy-subrc <> 0.
            MESSAGE i003(zp) WITH
                     'There was an error during Excel file creation'(200).
            exit. "Causes short dump if removed and excel document was open 
          ENDIF.
    * Option 2: New name.
        ELSEIF ld_answer EQ '2'.
          CALL FUNCTION 'DOWNLOAD'
            EXPORTING
                 filename            = p_file          "File name
                 filetype            = 'ASC'           "File type
    *             col_select          = 'X'            "COL_SELECT
    *             col_selectmask      = 'XXXXXXXXXXXXXXXXXXXXXXXXXX'
    *                                                   "COL_SELECTMASK
                 filetype_no_show    = 'X'     "Show file type selection?
    *       IMPORTING
    *             act_filename        = filename_dat
            TABLES
                 data_tab            = it_excelfile    "Data table
    *            fieldnames          =
            EXCEPTIONS
                 file_open_error     = 01
                 file_write_error    = 02
                 invalid_filesize    = 03
                 invalid_table_width = 04
                 invalid_type        = 05
                 no_batch            = 06
                 unknown_error       = 07.
        ENDIF.
      ELSE.                               "File does not alread exist.
        CALL FUNCTION 'GUI_DOWNLOAD'
          EXPORTING
    *          BIN_FILESIZE            =
               filename                = p_file         "File name
               filetype                = 'ASC'          "File type
    *     IMPORTING
    *          FILELENGTH              =
          TABLES
               data_tab                = it_excelfile   "Data table
          EXCEPTIONS
               file_write_error        = 1
               no_batch                = 2
               gui_refuse_filetransfer = 3
               invalid_type            = 4
               OTHERS                  = 5.
        IF sy-subrc <> 0.
          MESSAGE i003(zp) WITH
                   'There was an error during Excel file creation'(200).
          exit. "Causes short dump if removed and excel document was open 
        ENDIF.
      ENDIF.
    Regards,
    Raghav

  • Extracting data from Oracle to a flat file

    I'm looking for options to extract data a table or view at a time to a text file. Short of writing the SQL to do it, are there any other ideas? I'm dealing with large volumes of data, and would like a bulk copy routine.
    Thanks in advance for your help.

    Is there any script which i can use for pulling data from tables to a flat file and then import that data to other DB'sFlat file is adequate only from VARCHAR2, NUMBER, & DATA datatypes.
    Other datatypes present a challenge within text file.
    A more robust solution is to use export/import to move data between Oracle DBs.

  • Pulling data from table to a flat file

    hi all,
    Good day to all,
    Is there any script which i can use for pulling data from tables to a flat file and then import that data to other DB's. Usage of db link is restricted. The db version is 10.2.0.4.
    thanks,
    baskar.l

    Is there any script which i can use for pulling data from tables to a flat file and then import that data to other DB'sFlat file is adequate only from VARCHAR2, NUMBER, & DATA datatypes.
    Other datatypes present a challenge within text file.
    A more robust solution is to use export/import to move data between Oracle DBs.

  • How can i extract data from oracle table  to flat file or excel spread shee

    Hello,
    DB Version is 10.1.0.3.0
    How can i extract data from oracle table to flat file or excel spread sheet by using sub programs?
    Regards,
    D

    Here what I did
    SET NEWPAGE 0
    SET SPACE 0
    SET LINESIZE 80
    SET PAGESIZE 0
    SET ECHO OFF
    SET FEEDBACK OFF
    SET VERIFY OFF
    SET HEADING OFF
    SET MARKUP HTML OFF SPOOL OFF
    Sql> SPOOL bing
    select * from -------;
    SPOOL OFF;
    I do not see file.
    I also tried
    Sql> SPOOL /tmp/bing
    select * from -------;
    SPOOL OFF;
    But still not seeing the fie,

  • How to extract data From Hyperion Essbase to Flat Files

    Hi ,
    Can anyone tell me how to extract data from Hyperion essbase to Flat file(e.g. .csv , .txt ,...) or Oracle Table using ODI.
    Regards,
    Avneet

    Hi sutirtha,
    I have make one column as key column now i am getting this error,
    org.apache.bsf.BSFException: exception from Jython:
    Traceback (innermost last):
    File "<string>", line 1, in ?
    com.hyperion.odi.essbase.ODIEssbaseException: The number of columns returned by script [10] is less than the source data columns exposed [12]
    at com.hyperion.odi.essbase.ODIEssbaseDataReader.getAppData(Unknown Source)
    at com.hyperion.odi.essbase.AbstractEssbaseReader.extract(Unknown Source)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.python.core.PyReflectedFunction.__call__(PyReflectedFunction.java)
    at org.python.core.PyMethod.__call__(PyMethod.java)
    at org.python.core.PyObject.__call__(PyObject.java)
    at org.python.core.PyInstance.invoke(PyInstance.java)
    at org.python.pycode._pyx7.f$0(<string>:1)
    at org.python.pycode._pyx7.call_function(<string>)
    at org.python.core.PyTableCode.call(PyTableCode.java)
    at org.python.core.PyCode.call(PyCode.java)
    at org.python.core.Py.runCode(Py.java)
    at org.python.core.Py.exec(Py.java)
    at org.python.util.PythonInterpreter.exec(PythonInterpreter.java)
    at org.apache.bsf.engines.jython.JythonEngine.exec(JythonEngine.java:144)
    at com.sunopsis.dwg.codeinterpretor.k.a(k.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.scripting(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execScriptingOrders(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execScriptingOrders(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTaskTrt(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSqlC.treatTaskTrt(SnpSessTaskSqlC.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java)
    at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java)
    at com.sunopsis.dwg.cmd.DwgCommandSession.treatCommand(DwgCommandSession.java)
    at com.sunopsis.dwg.cmd.DwgCommandBase.execute(DwgCommandBase.java)
    at com.sunopsis.dwg.cmd.e.k(e.java)
    at com.sunopsis.dwg.cmd.g.A(g.java)
    at com.sunopsis.dwg.cmd.e.run(e.java)
    at java.lang.Thread.run(Unknown Source)
    Caused by: com.hyperion.odi.essbase.ODIEssbaseException: The number of columns returned by script [10] is less than the source data columns exposed [12]
    at com.hyperion.odi.essbase.wrapper.EssbaseReportDataIterator.validateColumns(Unknown Source)
    at com.hyperion.odi.essbase.wrapper.EssbaseReportDataIterator.init(Unknown Source)
    ... 33 more
    com.hyperion.odi.essbase.ODIEssbaseException: com.hyperion.odi.essbase.ODIEssbaseException: The number of columns returned by script [10] is less than the source data columns exposed [12]
    at org.apache.bsf.engines.jython.JythonEngine.exec(JythonEngine.java:146)
    at com.sunopsis.dwg.codeinterpretor.k.a(k.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.scripting(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execScriptingOrders(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execScriptingOrders(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTaskTrt(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSqlC.treatTaskTrt(SnpSessTaskSqlC.java)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java)
    at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java)
    at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java)
    at com.sunopsis.dwg.cmd.DwgCommandSession.treatCommand(DwgCommandSession.java)
    at com.sunopsis.dwg.cmd.DwgCommandBase.execute(DwgCommandBase.java)
    at com.sunopsis.dwg.cmd.e.k(e.java)
    at com.sunopsis.dwg.cmd.g.A(g.java)
    at com.sunopsis.dwg.cmd.e.run(e.java)
    at java.lang.Thread.run(Unknown Source)

  • Use transaction FILE to store data from a cube into a file with Open Hub

    Hi people:
    I'm using BI 7.0 .Mi requirement is to make a flat file using the information of a virtual cube. The file name must have the number of the month and the year. I know that this is possible through FILE transaction.
    Can anybody give me a clue how this transaction is used?Which are the steps in order to assemble the name of the file? Or is there any other option? I have defined the physical directory where the file must be leaved
    Any help will be great. Thanks in advanced

    Hi,
    pick up the code which you need from below.
    REPORT RSAN_WB_ROUTINE_TEMP_REPORT .
    TYPES: BEGIN OF y_source_fields ,
             /BIC/ZTO_ROUTE TYPE /BIC/OIZTO_ROUTE ,
             ZINT_HU__Z_WM_HU TYPE /BIC/OIZ_WM_HU ,
             CREATEDON TYPE /BI0/OICREATEDON ,
             ROUTE TYPE /BI0/OIROUTE ,
             PLANT TYPE /BI0/OIPLANT ,
             PLANT__0STREET TYPE /BI0/OISTREET ,
             PLANT__0CITY TYPE /BI0/OICITY ,
             PLANT__0REGION TYPE /BI0/OIREGION ,
             PLANT__0POSTAL_CD TYPE /BI0/OIPOSTAL_CD ,
             /BIC/ZRECVPLNT TYPE /BIC/OIZRECVPLNT ,
             ZRECVPLNT__0STREET TYPE /BI0/OISTREET ,
             ZRECVPLNT__0CITY TYPE /BI0/OICITY ,
             ZRECVPLNT__0REGION TYPE /BI0/OIREGION ,
             ZRECVPLNT__0POSTAL_CD TYPE /BI0/OIPOSTAL_CD ,
             KYF_0001 TYPE /BI0/OIDLV_QTY ,
             ROUTE__Z_CR_DOCK TYPE /BIC/OIZ_CR_DOCK ,
             REFER_DOC TYPE /BI0/OIREFER_DOC ,
           END OF y_source_fields .
    TYPES: yt_source_fields TYPE STANDARD TABLE OF y_source_fields .
    TYPES: BEGIN OF y_target_fields ,
             RECORDTYPE TYPE /BI0/OISTREET ,
             CONTAINER TYPE /BI0/OICITY ,
             /BIC/ZTO_ROUTE TYPE /BIC/OIZTO_ROUTE ,
             TRACKINGNUMBER TYPE /BIC/OIZ_WM_HU ,
             PO TYPE /BI0/OICITY ,
             STAGEDDATE TYPE /BI0/OICITY ,
             MOVEMENTTYPE TYPE /BI0/OICITY ,
             ROUTE TYPE /BI0/OIROUTE ,
             PLANT TYPE /BI0/OIPLANT ,
             PLANT__0STREET TYPE /BI0/OISTREET ,
             PLANT__0CITY TYPE /BI0/OICITY ,
             PLANT__0REGION TYPE /BI0/OIREGION ,
             PLANT__0POSTAL_CD TYPE /BI0/OIPOSTAL_CD ,
             ORIGINCONTACTNAME TYPE /BI0/OISTREET ,
             ORIGINCONTACTPHONE TYPE /BI0/OISTREET ,
             /BIC/ZRECVPLNT TYPE /BIC/OIZRECVPLNT ,
             ZRECVPLNT__0STREET TYPE /BI0/OISTREET ,
             ZRECVPLNT__0CITY TYPE /BI0/OISTREET ,
             ZRECVPLNT__0REGION TYPE /BI0/OISTREET ,
             ZRECVPLNT__0POSTAL_CD TYPE /BI0/OISTREET ,
             DESTINATIONCONTACTNAME TYPE /BI0/OISTREET ,
             DESTINATIONCONTACTPHONE TYPE /BI0/OISTREET ,
             RCCCODE TYPE /BI0/OISTREET ,
             GLCORCLLICODE TYPE /BI0/OISTREET ,
             JFCCODE TYPE /BI0/OISTREET ,
             DESCRIPTIONOFWORK1 TYPE /BI0/OISTREET ,
             DESCRIPTIONOFWORK2 TYPE /BI0/OISTREET ,
             INSTRUCTIONS TYPE /BI0/OISTREET ,
             REQUESTEDSHIPDATE TYPE /BI0/OICITY ,
             ROUTE__Z_CR_DOCK TYPE /BIC/OIZ_CR_DOCK ,
             REQUESTEDDELIVERYDATE TYPE /BI0/OICITY ,
             ATTSEORDER TYPE /BI0/OICITY ,
             CUBE TYPE /BI0/OISTREET ,
             WEIGHT TYPE /BI0/OISTREET ,
             PIECES TYPE /BI0/OIREFER_DOC ,
             REEL TYPE /BI0/OISTREET ,
             REELSIZE TYPE /BI0/OISTREET ,
             VENDORSKU TYPE /BI0/OISTREET ,
             ATTSESKU TYPE /BI0/OISTREET ,
             COMPANYNAME TYPE /BI0/OISTREET ,
             OEM TYPE /BI0/OISTREET ,
             REFER_DOC TYPE /BI0/OIREFER_DOC ,
             REFERENCENUMBER2 TYPE /BI0/OISTREET ,
             REFERENCENUMBER3 TYPE /BI0/OISTREET ,
             REFERENCENUMBER4 TYPE /BI0/OISTREET ,
           END OF y_target_fields .
    TYPES: yt_target_fields TYPE STANDARD TABLE OF y_target_fields .
    Begin of type definitions -
    *TYPES: ...
    End of type definitions -
    FORM compute_data_transformation
         USING     it_source TYPE yt_source_fields
                   ir_context TYPE REF TO if_rsan_rt_routine_context
         EXPORTING et_target TYPE yt_target_fields .
    Begin of transformation code -
      DATA: ls_source TYPE y_source_fields,
            ls_target TYPE y_target_fields,
            var1(10),
            var2(10),
            year(4),
            month(2),
            day(2),
            date(10),
            it_workdays type table of /bic/pzworkdays,
            wa_workdays type /bic/pzworkdays,
            sto_date(10),
            V_tabix TYPE sy-tabix,
            Y_tabix TYPE sy-tabix,
            sto_var1(10),
            sto_year(4),
            sto_month(2),
            sto_day(2),
            sto_final_date(10),
            W_HEADER LIKE LS_TARGET-RECORDTYPE,
            W_HEADER1(12) TYPE C VALUE 'HEDR00000000',
            W_FOOTER LIKE W_HEADER VALUE 'TRLR0000',
            CNT(5),
            CMD(125) TYPE C.
    **********CODE FOR GENRATING CSV FILE PATH*******************
    data: OUTFILE_NAME(100) TYPE C,
          OUTFILE_NAME1(10) TYPE C VALUE '/sapmnt/',
          OUTFILE_NAME3(18) TYPE C VALUE '/qoutsap/ATTUVS',
          DATE1 LIKE SY-DATUM,
          DD(2) TYPE C,
          MM(2) TYPE C,
          YYYY(4) TYPE C.
    MOVE SY-DATUM+6(2) TO DD.
    MOVE SY-DATUM+4(2) TO MM.
    MOVE SY-DATUM(4) TO YYYY.
    CONCATENATE YYYY MM DD INTO DATE1.
    CONCATENATE OUTFILE_NAME1 SY-SYSID OUTFILE_NAME3 '.CSV' INTO
    OUTFILE_NAME.
    **********END OF CODE FOR GENRATING CSV FILE PATH*************
      OPEN DATASET OUTFILE_NAME FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    Code for generating Header.
      CONCATENATE W_HEADER1  SY-DATUM SY-UZEIT INTO W_HEADER.
      APPEND W_HEADER TO ET_TARGET.
      TRANSFER W_HEADER TO OUTFILE_NAME.
      CLEAR W_HEADER.
    End of code for generating Header.
    code for excluding the rows who's Quantity(PIECES) equal to zero.
      LOOP AT it_source INTO ls_source where KYF_0001 NE '0'.
    end of code for excluding the rows who's Quantity(PIECES) equal to
    *zero
        MOVE-CORRESPONDING ls_source TO ls_target.
        ls_target-RECORDTYPE = 'PKUP'.
        ls_target-CONTAINER = ''.
        ls_target-TRACKINGNUMBER = ls_source-ZINT_HU__Z_WM_HU.
        ls_target-PO = ''.
    Date Conversion for Staged Date.
        var1 = ls_source-CREATEDON.
        year = var1+0(4).
        month = var1+4(2).
        day = var1+6(2).
        CONCATENATE month '/' day '/' year INTO date.
    End of Date Conversion for Staged Date.
        ls_target-STAGEDDATE = date.
        ls_target-MOVEMENTTYPE = 'P'.
        ls_target-ORIGINCONTACTNAME = ''.
        ls_target-ORIGINCONTACTPHONE = ''.
        ls_target-DESTINATIONCONTACTNAME = ''.
        ls_target-DESTINATIONCONTACTPHONE = ''.
        ls_target-RCCCODE = ''.
        ls_target-GLCORCLLICODE = ''.
        ls_target-JFCCODE = ''.
        ls_target-DESCRIPTIONOFWORK1 = ''.
        ls_target-DESCRIPTIONOFWORK2 = ''.
        ls_target-INSTRUCTIONS = ''.
        ls_target-REQUESTEDSHIPDATE = date.
    Calculating STO Creation Date + 3 working Days.
        select /BIC/ZWORKDAYS from /bic/pzworkdays into table it_workdays.
        loop at it_workdays into wa_workdays.
            if  wa_workdays-/bic/zworkdays = ls_source-CREATEDON.
                V_tabix = sy-tabix.
                Y_tabix = V_tabix + 3.
            endif.
            If sy-tabix = y_tabix.
                sto_date = wa_workdays-/bic/zworkdays.
            endif.
        Endloop.
        clear v_tabix.
        clear Y_tabix.
        sto_var1 = sto_date.
        sto_year = sto_var1+0(4).
        sto_month = sto_var1+4(2).
        sto_day = sto_var1+6(2).
        CONCATENATE sto_month '/' sto_day '/' sto_year INTO sto_final_date.
    End Of Calculating STO Creation Date + 3 working Days.
        ls_target-REQUESTEDDELIVERYDATE = sto_final_date.
        ls_target-ATTSEORDER = ''.
        ls_target-CUBE = ''.
        ls_target-PIECES = ls_source-KYF_0001.
        ls_target-REEL = ''.
        ls_target-REELSIZE = ''.
        ls_target-VENDORSKU = ''.
        ls_target-ATTSESKU = ''.
        ls_target-COMPANYNAME = 'AT&T'.
        ls_target-OEM = ''.
        ls_target-REFERENCENUMBER2 = '0'.
        ls_target-REFERENCENUMBER3 = '0'.
        ls_target-REFERENCENUMBER4 = '0'.
        APPEND ls_target TO et_target.
        TRANSFER ls_target TO OUTFILE_NAME.
        CNT = CNT + 1.
      ENDLOOP.
        CNT = CNT + 2.
    Code for generating Header -Footer.
      SHIFT CNT LEFT DELETING LEADING SPACE.
      CONCATENATE W_FOOTER CNT INTO W_HEADER.
      APPEND W_HEADER TO ET_TARGET.
    End of code for generating Header -Footer.
    Code for file permissions
      TRANSFER W_HEADER TO OUTFILE_NAME.
      CLOSE DATASET OUTFILE_NAME.
      CONCATENATE 'chmod 644' OUTFILE_NAME INTO CMD SEPARATED BY SPACE.
      CALL 'SYSTEM' ID 'COMMAND' FIELD CMD.
    End of code for file permissions
    End of transformation code -
    ENDFORM.
    Hope it helps
    bhaskar

  • Extract data from Query to a Flat File - scheduling in the background

    Hi All,
    We need to extract data from a query to a flat file periodically, but each time 10 separate executions based on 10 profit centers, to get the separate files.
    So, we have PC1, PC2, ... PC10 Profit centeres.
    We have Query1, with profit center variable.
    We have created 10 variants for Query1 so that we can execute for 10 profit centers.
    Now, we have used RSCRM_BAPI to execute the Query1 and write to a flat file. Now we are having a problem in getting this feature used to execute the query automatically for 10 different varaints.
    Thanks in advance,
    _ Shashi

    Shashi,
       You can try using Information Broadcasting or Reporting Agent. You can schedule this in Information Broadcasting.
    check this link for Information Broadcasting... <a href="http://help.sap.com/saphelp_nw04s/helpdata/en/a5/359840dfa5a160e10000000a1550b0/content.htm">http://help.sap.com/saphelp_nw04s/helpdata/en/a5/359840dfa5a160e10000000a1550b0/content.htm</a>
    Nagesh Ganisetti.

  • Dump data from a table into wwv_flow_files

    HI,
    Could you help me, to take data from a table, and insert it into blob_content in wwv_flow_files; and data should be stored in a .txt file
    regards,
    Rajesh

    Alex Nuijten wrote:
    But in case of APEX, that might be a really bad idea to insert metadata in the apex repository:
    http://joelkallman.blogspot.com/2010/01/perils-of-modifying-application-express.html
    This is not really an APEX metadata table, Alex. As far as I recall, it is a standard mod_plsql documents table that handles file uploads. One can also insert a document into the table dkirectly using an INSERT as it pretty straight forward.
    Not exactly sure why though as the doc download procedure needs a LOB or CLOB.. and it does not care from what table you create it from - or whether you do it on the fly.
    But still, you make an important point of using application/system objects for the purpose they have been designed for. And in this case, creating your own documents table may be a lot better.

  • Error while downloading data from internal table into XML file

    hi all,
    i developed a program to download data from into internal table to xml file like this.
    tables: mara.
    parameters: p_matnr like mara-matnr.
    data: begin of itab_mara occurs 0,
                matnr like mara-matnr,
                ernam like mara-ernam,
                aenam like mara-aenam,
                vpsta like mara-vpsta,
          end of itab_mara.
    data: lv_field_seperator type c,     " value 'X',
          lv_xml_doc_name(30) type c,    " string value ‘my xml file’,
          lv_result type i.
          lv_field_seperator = 'x'.
          lv_xml_doc_name = 'my xml file'.
    types: begin of truxs_xml_line,
              data(256) type x,
          end of truxs_xml_line.
    types:truxs_xml_table type table of truxs_xml_line.
    data:lv_tab_converted_data type truxs_xml_line,
         lt_tab_converted_data type truxs_xml_table.
    data: lv_xml_file type rlgrap-filename value 'c:\simp.xml'.
    select matnr ernam aenam vpsta from mara into table itab_mara up to 5
           rows where matnr = p_matnr.
    CALL FUNCTION 'SAP_CONVERT_TO_XML_FORMAT'
    EXPORTING
       I_FIELD_SEPERATOR          = lv_field_seperator
      I_LINE_HEADER              =
      I_FILENAME                 =
      I_APPL_KEEP                = ' '
       I_XML_DOC_NAME             = lv_xml_doc_name
    IMPORTING
       PE_BIN_FILESIZE            = lv_result
      TABLES
        I_TAB_SAP_DATA             = itab_mara
    CHANGING
       I_TAB_CONVERTED_DATA       = lt_tab_converted_data
    EXCEPTIONS
      CONVERSION_FAILED          = 1
      OTHERS                     = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    open dataset lv_xml_file for output in binary mode.
    loop at lt_tab_converted_data into lv_tab_converted_data.
    transfer lv_tab_converted_data to lv_xml_file.
    endloop.
    close dataset lv_xml_file.
    this program is syntactically correct and getting executed, but when i open the target xml file it is showing the following error.
    The XML page cannot be displayed
    Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.
    XML document must have a top level element. Error processing resource 'file:///C:/simp.xml'.
    will anyone show me the possible solution to rectify this error
    thanks and regards,
    anil.

    Hi,
    Here is a small sample program to convert data in an internal table into XML format and display it.
    DATA: itab  TYPE TABLE OF spfli,
          l_xml TYPE REF TO cl_xml_document.
    * Read data into a ITAB
    SELECT * FROM spfli INTO TABLE itab.
    * Create the XML Object
    CREATE OBJECT l_xml.
    * Convert data in ITAB to XML
    CALL METHOD l_xml->create_with_data( name = 'Test1'
                                         dataobject = t_goal[] ).
    * Display XML Document
    CALL METHOD l_xml->display.
    Here are some other sample SAP programs to handle XML in ABAP:
    BCCIIXMLT1, BCCIIXMLT2, and BCCIIXMLT3.
    Hope this helps,
    Sumant.

  • How to extract HRM master data from R/3 into LDIF file?

    Recently I have been asked to provide an extract from our R/3 system
    with some Human Resource master data. The extract has to be in the LDIF
    format (LDAP data interchange format). It is needed to import into a
    DirX metahub solution from Siemens.
    How can this be done most easily?
    (does SAP provide tools, can XI do this?) or do we have to write a
    customized abap to do this?
    Thanks in advance
    Kind regards
    Alex Veen

    Hi Satish,
    As per SAP Standard also the best way is to delete whole data from the cube and then load the data from set up tables as you have enhanced the data source.
    After data source enhancement it is supported to load normally because you don't get any historical data for that field.
    Best way is to take down time from the users, normally we do in weekends/non-business hours.
    Then fill the set-up tables; if the data is of huge volume you can adopt parallel mechanism like:
    1. Load set-up tables by yearly basis as a background job.
    2. Load set-up tables by yearly basis with posting periods from jan 1st to 31st dec of any year basis as a background job.
    This can make your self easier and faster for load of set-up tables. After filling up set-up tables. You can unlock all users as there is no worries of postings.
    Then after you can load all the data into BI first into PSA and then into Cube.
    Regards,
    Ravi Kanth.

  • Extract of Data from Oracle in a Flat File with Column and Record seperator

    I have a case where I have to extract whole data froma Oracle Table where the Columns should be seperated by |@|
    and Records by ^*^.
    The reason for this is My data has Space and New line in it. So My Program to recoganize each column and record I want them to be seperated by special chars.
    Itried this but of no much help.
    set echo off newpage 0 space 0 pagesize 0 feed off head off trimspool on;
    spool on;
    set colsep '|@|';
    set recsepchar '^*^';
    spool "T_COMPLAINT.dat";
    select * from T_COMPLAINT where ROWNUM < '100' order by cptoid;
    spool off;

    Having '@' and '*' characters in the data will not make any difference if you are using a combined column separator of '|@|' - provided any process you use subsequently can handle it.
    However, the recsepchar parameter appears to be restricted to a single character which is repeated right across the page, so I don't think you could have a single iteration of '|*|' using this method:
    SQL> set  newpage 0 space 0 pagesize 0 feed off head off trimspool on
    SQL> set recsep EACH
    SQL> set recsepchar '*'
    SQL> set colsep '|@|'
    SQL> select * from testa;
    A         |@|1@        |@|22-JUN-2010
    B         |@|2*        |@|22-JUN-2010
    B         |@|2*        |@|22-JUN-2010
    ********************************************************************************Edited by: LindaA on 23-Jun-2010 08:33

  • DOWNLOADING DATA FROM R/3 TO FLAT FILE

    hi,
      friends,
         In bdc while downloading DATA , i am getting error in filename
    error- field filename is unknown & it is neither in one of the specified tables nor defined by "data" statements.
    report yreport
    tables:kna1.
    DATA :BEGIN OF ITAB OCCURS 0,
               KUNNR LIKE KNA1-KUNNR,
               LAND1 LIKE KNA1-LAND1,
               NAME1 LIKE KNA1-NAME1,
               END OF ITAB.
    SELECT KUNNR LAND1 NAME1 FROM KNA1 INTO TABLE ITAB.
    CALL FUNCTION  'WS-DOWNLOAD'.
    FILENAME = 'C:\VEND.TXT'.
    FILETYPE ='DAT'.
    TABLES DATA_TAB = ITAB.
    NEAR  filename
    Error- field filename is unknown & it is neither in one of the specified tables nor defined by "data" statements.

    Hi,
    Please use the following code,
    DATA: ok_code TYPE sy-ucomm,
    save_ok TYPE sy-ucomm,
    lv_file(80),
    lv_fieldln TYPE i,
    lv_def_path TYPE rlgrap-filename,
    lv_mode TYPE c VALUE 'S',
    lv_tmp_filename TYPE rlgrap-filename,
    lv_tmp_mask(80).
    FIELD-SYMBOLS: <fs_tmp_sym>.
    save_ok = ok_code.
    CASE save_ok.
    WHEN 'EXCEL'.
    *--- On click of 'Download to Excel' button transfer the ALV data to
    *--- Excel sheet.
    lv_tmp_mask = ',.,..'.
    lv_fieldln = strlen( lv_def_path ) - 1.
    ASSIGN lv_def_path+lv_fieldln(1) TO <fs_tmp_sym>.
    IF <fs_tmp_sym> = '/' OR <fs_tmp_sym> = '\'.
    CLEAR <fs_tmp_sym>.
    ENDIF.
    *--- Get the file name & path to which file has to be downloaded.
    CALL FUNCTION 'WS_FILENAME_GET'
    EXPORTING
    def_path = lv_def_path
    mask = lv_tmp_mask
    mode = lv_mode
    IMPORTING
    filename = lv_tmp_filename
    EXCEPTIONS
    inv_winsys = 1
    no_batch = 2
    selection_cancel = 3
    selection_error = 4
    OTHERS = 5.
    IF sy-subrc = 0.
    *--- As we need to download the file in 'XLS' format add the
    *--- extension '.XLS' if it is not provided by the user.
    IF NOT lv_tmp_filename CS c_excel.
    CONCATENATE lv_tmp_filename c_excel INTO lv_file.
    ELSE.
    lv_file = lv_tmp_filename.
    ENDIF.
    ELSE.
    EXIT.
    ENDIF.
    *--- Down load the file to the path and filename provided above.
    CALL FUNCTION 'WS_DOWNLOAD'
    EXPORTING
    filename = lv_file
    filetype = 'DAT'
    TABLES
    data_tab = gt_excel1
    EXCEPTIONS
    file_open_error = 1
    file_write_error = 2
    invalid_filesize = 3
    invalid_type = 4
    no_batch = 5
    unknown_error = 6
    invalid_table_width = 7
    gui_refuse_filetransfer = 8
    customer_error = 9
    OTHERS = 10.
    IF sy-subrc = 0.
    MESSAGE i000(zf) WITH text-017.
    ELSE.
    MESSAGE e939(zf) WITH lv_file. "Errors while downloading.
    ENDIF.
    ENDCASE.
    gt_excel1 is the internal table you provide to the FM for downloading.
    lv_file is automatically taken care of from the input provided by the user.
    The above code is triggered when a button in Application tool bar is clicked. Please use it as needed. It will ask for the path to which file has to be downloaded and once provided it will download the table only to excel.
    It will work for sure.
    Regards,
    Paul.

Maybe you are looking for

  • Can't install HP Photosmart 2575 on BootCamp with windows 7

    Upgraded to OS X Lion and, so far didn't have any major problems. Then I opted to upgrade to Windows 7 on my BootCamp partition, since Windows XP is not supported any more. My HP Photosmart 2575 worked fine under Windows XP. But now, in Windows 7 I c

  • External HD with Mac OS Extended and FAT32

    Hi, I have partitioned my external harddisk using Apple's Partion scheme into 2 partitions. The first I formated as Max OS Extended (Journaled) and now I would like to format the second as FAT32, but somehow this is not possible: either I can choose

  • Polish characters in text input (linux problem only)

    I've got some problems with TextInput. When i want to type polish characters (RIGHT ALT + combination: A,C,E,L,N,O,S,Z and X) - I've got no results. This happend only in linux versin - windows is ok. Could be a problem with player... Any idea or quic

  • How do I recover my Qosmio G20-118 without loosing data?

    Hi there, I need to recover my system but have quite a lot of data in my D: HDD I would very much like to keep. In this forum, Gipsyman said that I should be able to use the dvd recovery disc selecting the advanced recovery mode, however there are a

  • Nokia 5800 Xpress Music-Horizontal Line Fault

    I've had a problem with the phone for a few weeks where every time I would lock and unlock the phone, or when the back light switched off, horizontal lines would appear across the screen. When I restarted the phone, or kept using it through calling o