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.)

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

  • 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

  • Saving query results to a flat file

    Hello Experts!
    We have a very specific issue on our current project and I would like to know if any of you have ever done something similar. We are taking query results from BW (after complex calculations, some based on SY-DATE) and saving them to flat files to transfer to a SQL database structure on the Enterprise Portal. From here, the portal team renders the information into more "static" dashboards that include mouse over features and even limited drilldown (i.e. no matter where a user clicks the report always drills down on profit center)
    There are many reasons why the model is set up as such (mostly training of executive level end users), and even though it doesn't mesh with the idea that BW could do this work on its own, we have to work with what we have.
    We have come up with 3 possible ways to save this data to flat files and hopefully someone can tell us which might be the most effective.
    1.) Information Broadcasting. If we broadcast XML files to the portal, will the portals team be able to read that data into a SQL database? Is there another way to use broadcasting to create and send a flat file to specific location?
    2.) RSCRM_BAPI. This transaction seems to not support texts.
    3.) Open Hub. In order to get the open hub to work, we first have to save all of our query results to direct write data store objects using APD. (calculations based on current date, for example, would require daily full loads to the underlying data providers otherwise.)
    What is the best way to accomplish this? Is information broadcasting capable of doing this?
    Thanks!

    Hi Adam,
    Do you have to use flat files to load the information to a SQL database? (if so maybe someone else has a suggestion on which way would be the best).
    I try to stay away from flat file uploads as there is a lot of manual work involved. May I suggest setting up a connection to your SQL table in the DBCON table and then writing a small abap program to push data into the SQL database (which you can automate).
    1) Use APD to push data into a table within BW.
    2) Go to transaction SM30 > table DBCON and setup a new entry specifying the conncection parameters to your SQL database.
    3) In SE38 Write an ABAP program along the folloing lines (assuming the connection you set in DBCON is named conn1:
    data: con_name like dbcon-con_name
    con_name = 'conn1'.
    exec sql.
      set connection :con_name
    endexec.
    ****have a select statement which reads data from your table which the data is saved from the APD into an internal table**********
    ****loop on the internal table and have a SQL insert statement to insert the records into the SQL table as below******
    exec sql.
    insert into <SQL TABLE> (column names seperated by ,)
    values (column names of the internal table seperated by ,)  if the internal table is named itab the columns have to be specified as :itab-column1
    If you decide to take this approach you may find more info on DBCON and the process in sdn. Good Luck!
    endexec.

  • 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

  • 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

  • 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;
    ############################################################

  • How to use LSMW to upload database table directly from flat file extract

    Hi Guru's,
    I am new to LSMW tool. I have searched the fourm before posting this thread for my issue but i didn't find any good posts for the same.
    my requirement is : I will have a flat ( tab -delimited ) or Excel file with number of records downloaded using the databrowser for some of standard tables from one SAP systesm  . I wanted to upload the records using the LSMW  to the same tables  in some other SAP systesm . Please help me to How to upload the same using the LSMW.
    Thanks & Regards,
    Praveen.

    Hi Praveen,
    There is a risk trying to migrate data directly into standard tables because this can generate database inconsistences or wrong inserted data according to what is customized in the target system. I do not recommend migrate like this. 
    With LSMW you use objects like direct input programs, idocs, bapis and recorded batch input. Try to create a project and use an standard object for your data. Also, check in SXDA transaction (Goto-->DX programs) if there is a standard program for your data.
    Anyway, if you want to upload data directly to tables, read below thread:
    ["UPLOAD  CSV  FILE";
    [how to upload .csv file into a custom table;
    Regards,
    Roger

  • Number of records in a flat file

    Hi All,
    I have a very big file in CSV format to be loaded into BW. When I try to open it to see the number of records, it is giving me a message "File not loaded completely". When I click on OK, it is showing some records, which I presume to be the maximum limit of the excel sheet. Is there anyway I can find the total number of records in this file?
    Thanks,
    RPK.

    Hi RPK,
    You can open your file with Access, there you will see all the lines. Another way if you don't have Access is to use the Notepad, there you will be able to see the number of lines using the "status bar" in the display menu.
    Regards,
    Philippe

  • ESB not moving data from database to flat file

    Using ESB, created an database adapter/routing service (polling for changed records) & file adapter to write all records from a database table to a flat file as a series of XML entries in the file. I only get the last record from the database into the flat file. Using JDev 10.1.3.2 and SOA Suite 10.1.3. Have a 'status' column in the source database table that is set to 'PROCESSED' when the record has been processed. After I get the one XML element, representing the last record in the database, I look at the database table and ALL rows have their 'status' column set to PROCESSED - the field was null before the database table was processed.
    How do I get ALL of the records into the flat file?
    Thanks - Casey

    Hi.
    Check this:
    ESB File Adapter: Append to log file not supported???
    Denis

  • How to skip first record while inserting data from a flat file to BW system

    Hi Experts,
    In my project we have to upload flat file into a BW system. I have written a program and it is working fine.
    Now we have got another requirement. The flat file will have a header record (first row). While uploading the flat file we have to skip this record. How I can do so?
    The code is as below:
    FORM upload1.
      DATA : wf_title    TYPE string,
              lt_filetab  TYPE filetable,
              l_separator TYPE char01,
              l_action    TYPE i,
              l_count     TYPE i,
              ls_filetab  TYPE file_table,
              wf_delemt TYPE rollname,
              wa_fieldcat TYPE lvc_s_fcat,
              tb_fieldcat TYPE lvc_t_fcat,
              rows_read TYPE i,
              p_error   TYPE char01,
              l_file      TYPE string.
      DATA: wf_object(30)  TYPE c,
              wf_tablnm TYPE rsdchkview.
      wf_object = 'myprogram'.
      DATA i TYPE i.
      DATA:
           lr_mdmt                TYPE REF TO cl_rsdmd_mdmt,
           lr_mdmtr               TYPE REF TO cl_rsdmd_mdmtr,
           lt_idocstate           TYPE rsarr_t_idocstate,
           lv_subrc               TYPE sysubrc.
      TYPES : BEGIN OF test_struc,
               /bic/myprogram TYPE  /bic/oimyprogram,
               txtmd   TYPE rstxtmd,
               END OF test_struc.
      DATA :    tb_assum TYPE TABLE OF /bic/pmyprogram.
      DATA: wa_ztext TYPE  /bic/tmyprogram,
            myprogram_temp TYPE ziott_assum,
            wa_myprogram TYPE /bic/pmyprogram.
      DATA : test_upload TYPE STANDARD TABLE OF test_struc,
             wa2 TYPE  test_struc.
      DATA : wa_test_upload TYPE test_struc,
             ztable_data TYPE TABLE OF /bic/pmyprogram,
             ztable_text TYPE TABLE OF /bic/tmyprogram,
             wa_upld_text TYPE /bic/tmyprogram,
             wa_upld_data TYPE /bic/pmyprogram,
              t_assum TYPE ziott_assum.
      DATA : wa1 LIKE  test_upload.
      wf_title = text-026.
      CALL METHOD cl_gui_frontend_services=>file_open_dialog
        EXPORTING
          window_title            = wf_title
          default_extension       = 'txt'
          file_filter             = 'Tab delimited Text Files (*.txt)'
        CHANGING
          file_table              = lt_filetab
          rc                      = l_count
          user_action             = l_action
        EXCEPTIONS
          file_open_dialog_failed = 1
          cntl_error              = 2
          OTHERS                  = 3.                          "#EC NOTEXT
      IF sy-subrc <> 0.
        EXIT.
      ENDIF.
      LOOP AT lt_filetab INTO ls_filetab.
        l_file = ls_filetab.
      ENDLOOP.
      CHECK l_action = 0.
      IF l_file IS INITIAL.
        EXIT.
      ENDIF.
      l_separator = 'X'.
      wa_fieldcat-fieldname = 'test'.
      wa_fieldcat-dd_roll = wf_delemt.
      APPEND wa_fieldcat TO tb_fieldcat.
      CALL FUNCTION 'MESSAGES_INITIALIZE'.
      CLEAR wa_test_upload.
    Upload file from front-end (PC)
    File format is tab-delimited ASCII
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename                = l_file
          has_field_separator     = l_separator
        TABLES
         data_tab                = i_mara
        data_tab                   = test_upload
        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.
        EXIT.
      ELSE.
       CALL FUNCTION 'MESSAGES_INITIALIZE'.
        IF test_upload IS NOT INITIAL.
          DESCRIBE TABLE test_upload LINES rows_read.
          CLEAR : wa_test_upload,wa_upld_data.
          LOOP AT test_upload INTO wa_test_upload.
            CLEAR :  p_error.
            rows_read = sy-tabix.
            IF wa_test_upload-/bic/myprogram IS INITIAL.
              p_error = 'X'.
              MESSAGE s153 WITH wa_test_upload-/bic/myprogram sy-tabix.
              CONTINUE.
            ELSE.
              TRANSLATE wa_test_upload-/bic/myprogram TO UPPER CASE.
              wa_upld_text-txtmd  = wa_test_upload-txtmd.
              wa_upld_text-txtsh  = wa_test_upload-txtmd.
              wa_upld_text-langu =  sy-langu.
              wa_upld_data-chrt_accts = 'xyz1'.
              wa_upld_data-co_area = '12'.
              wa_upld_data-/bic/zxyzbcsg = 'Iy'.
              wa_upld_data-objvers = 'A'.
              wa_upld_data-changed = 'I'.
              wa_upld_data-/bic/zass_mdl = 'rrr'.
              wa_upld_data-/bic/zass_typ = 'I'.
              wa_upld_data-/bic/zdriver = 'yyy'.
              wa_upld_text-langu = sy-langu.
              MOVE-CORRESPONDING wa_test_upload TO wa_upld_data.
              MOVE-CORRESPONDING wa_test_upload TO wa_upld_text.
              APPEND wa_upld_data TO ztable_data.
              APPEND wa_upld_text TO ztable_text.
            ENDIF.
          ENDLOOP.
          DELETE ADJACENT DUPLICATES FROM ztable_data.
          DELETE ADJACENT DUPLICATES FROM ztable_text.
          IF ztable_data IS NOT INITIAL.
            CALL METHOD cl_rsdmd_mdmt=>factory
              EXPORTING
                i_chabasnm     = 'myprogram'
              IMPORTING
                e_r_mdmt       = lr_mdmt
              EXCEPTIONS
                invalid_iobjnm = 1
                OTHERS         = 2.
       CALL FUNCTION 'MESSAGES_INITIALIZE'.
       **Lock the Infoobject to update
            CALL FUNCTION 'RSDG_IOBJ_ENQUEUE'
              EXPORTING
                i_objnm      = wf_object
                i_scope      = '1'
                i_msgty      = rs_c_error
              EXCEPTIONS
                foreign_lock = 1
                sys_failure  = 2.
            IF sy-subrc = 1.
              MESSAGE i107(zddd_rr) WITH wf_object sy-msgv2.
              EXIT.
            ELSEIF sy-subrc = 2.
              MESSAGE i108(zddd_rr) WITH wf_object.
              EXIT.
            ENDIF.
    *****Update Master Table
            IF ztable_data IS NOT INITIAL.
              CALL FUNCTION 'RSDMD_WRITE_ATTRIBUTES_TEXTS'
                    EXPORTING
                      i_iobjnm                     = 'myprogram'
                      i_tabclass                   = 'M'
           I_T_ATTR                     = lt_attr
                    TABLES
                      i_t_table                    = ztable_data
                      EXCEPTIONS
                     attribute_name_error         = 1
                     iobj_not_found               = 2
                     generate_program_error       = 3
                     OTHERS                       = 4.
              IF sy-subrc <> 0.
                CALL FUNCTION 'MESSAGE_STORE'
                  EXPORTING
                    arbgb  = 'zddd_rr'
                    msgty  = 'E'
                    txtnr  = '054'
                    msgv1  = text-033
                  EXCEPTIONS
                    OTHERS = 3.
                MESSAGE e054(zddd_rr) WITH 'myprogram'.
              ELSE.
                CALL FUNCTION 'MESSAGE_STORE'
                  EXPORTING
                    arbgb  = 'zddd_rr'
                    msgty  = 'S'
                    txtnr  = '053'
                    msgv1  = text-033
                  EXCEPTIONS
                    OTHERS = 3.
              ENDIF.
    *endif.
    *****update Text Table
              IF ztable_text IS NOT INITIAL.
                CALL FUNCTION 'RSDMD_WRITE_ATTRIBUTES_TEXTS'
                  EXPORTING
                    i_iobjnm               = 'myprogram'
                    i_tabclass             = 'T'
                  TABLES
                    i_t_table              = ztable_text
                  EXCEPTIONS
                    attribute_name_error   = 1
                    iobj_not_found         = 2
                    generate_program_error = 3
                    OTHERS                 = 4.
                IF sy-subrc <> 0.
                  CALL FUNCTION 'MESSAGE_STORE'
                    EXPORTING
                      arbgb  = 'zddd_rr'
                      msgty  = 'E'
                      txtnr  = '055'
                      msgv1  = text-033
                    EXCEPTIONS
                      OTHERS = 3.
                ENDIF.
              ENDIF.
            ELSE.
              MESSAGE s178(zddd_rr).
            ENDIF.
          ENDIF.
          COMMIT WORK.
          CALL FUNCTION 'RSD_CHKTAB_GET_FOR_CHA_BAS'
            EXPORTING
              i_chabasnm = 'myprogram'
            IMPORTING
              e_chktab   = wf_tablnm
            EXCEPTIONS
              name_error = 1.
          IF sy-subrc <> 0.
            MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
          ENDIF.
    ****Release locks on Infoobject
          CALL FUNCTION 'RSDG_IOBJ_DEQUEUE'
            EXPORTING
              i_objnm = 'myprogram'
              i_scope = '1'.
        ENDIF.
      ENDIF.
      PERFORM data_selection .
      PERFORM update_alv_grid_display.
      CALL FUNCTION 'MESSAGES_SHOW'.
    ENDFORM.
    Please let me know how I can skip first record of the flat file?
    Regards,
    S

    go through this hope u can get some idea
    REPORT  ztest no standard page heading line-size 255.
                          Declaration                            *
    TYPES t_itab1 TYPE alsmex_tabline.
    types: begin of t_csks,
           kostl like csks-kostl,
          end of t_csks.
    types: begin of t_cska,
           kstar like cska-kstar,
          end of t_cska.
    data: begin of t_flatfile,
          docdate like COHEADER-BLDAT,
          postdate like COHEADER-BUDAT,
          doctext like COHEADER-BLTXT,
           costele like RK23F-KSTAR,
           amount like RK23F-WTGBTR,
           scostctr like RK23F-SKOSTL,
           rcostctr like RK23F-EKOSTL,
           rintorder like RK23F-EAUFNR,
         end of t_flatfile.
    data: begin of t_flatfile1,
          docdate like COHEADER-BLDAT,
          postdate like COHEADER-BUDAT,
          doctext like COHEADER-BLTXT,
           costele like RK23F-KSTAR,
           amount like RK23F-WTGBTR,
           scostctr like RK23F-SKOSTL,
           rcostctr like RK23F-EKOSTL,
           rintorder like RK23F-EAUFNR,
           NUM LIKE SY-INDEX,
         end of t_flatfile1.
    data: itab like table of t_flatfile with header line.
    data: itab2 like table of t_flatfile1 with header line.
    DATA: it_itab1 TYPE STANDARD TABLE OF t_itab1 WITH HEADER LINE,
          MESSTAB1 LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE,
          MESSTAB LIKE BDCMSGCOLL OCCURS 0 WITH HEADER LINE.
    data: begin of bdcdata occurs 0.
            include structure bdcdata.
    data: end of bdcdata.
    data:t_lin type i VALUE '0',
         u_rec type i VALUE '0',
         s_rec type i VALUE '0'.
    data: it_csks type standard table of t_csks,
          wa_csks type t_csks.
    data: it_cska type standard table of t_cska,
          wa_cska type t_cska.
    *Selection Screen
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME  TITLE text-010.
    parameters: p_docdat  LIKE  COHEADER-BLDAT obligatory,
                p_postda LIKE  COHEADER-BUDAT obligatory,
                p_doctxt  LIKE  COHEADER-BLTXT.
    SELECTION-SCREEN END OF BLOCK b1.
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME  TITLE text-011.
    parameters: p_file LIKE RLGRAP-FILENAME obligatory,
                DIS_MODE LIKE CTU_PARAMS-DISMODE DEFAULT 'N'.
    SELECTION-SCREEN END OF BLOCK b2.
                  A T  S E L E C T I O N   S C R E E N                  *
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
      PERFORM get_local_file_name USING p_file.
    *Start of Selection
    START-OF-SELECTION.
      Perform get_Excel_data.
      perform validate_data.
      Perform Process_Data.
                    end-of-selection
    end-of-selection.
      perform display_data.
    *&      Form  get_local_file_name
          text
         -->P_P_FILE  text
    FORM get_local_file_name  USING    P_P_FILE.
      CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
        CHANGING
          file_name = p_file.
    ENDFORM.                    " get_local_file_name
    *&      Form  get_Excel_data
          text
    -->  p1        text
    <--  p2        text
    FORM get_Excel_data .
      FIELD-SYMBOLS : <FS>.
      DATA : V_INDEX TYPE I.
      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
        EXPORTING
          filename                = p_file
          i_begin_col             = 1
        i_begin_row             = 2
          i_begin_row             = 1
          i_end_col               = 256
          i_end_row               = 9999                        "65536
        TABLES
          intern                  = it_itab1
        EXCEPTIONS
          inconsistent_parameters = 1
          upload_ole              = 2
          OTHERS                  = 3.
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        Message text-013 type 'E'.
      ENDIF.
      IF IT_ITAB1[] IS INITIAL.
        Message text-001 type 'E'.
      else.                                    "IF IT_ITAB1[] IS INITIAL.
        data: itab2 like itab occurs 0 with header line.
        SORT IT_ITAB1 BY ROW COL.
        LOOP AT IT_ITAB1.
          MOVE :IT_ITAB1-COL TO V_INDEX.
          ASSIGN COMPONENT V_INDEX OF STRUCTURE itab2 TO  <FS>.
          MOVE : IT_ITAB1-VALUE TO <FS>.
          AT END OF ROW.
            MOVE-CORRESPONDING itab2 TO itab.
            APPEND itab.
            CLEAR:itab,itab2.
          ENDAT.
        endloop.
        describe table itab lines t_lin.
      endif.               "IF IT_ITAB1[] IS INITIAL.
    ENDFORM.                    " get_Excel_data
    *&      Form  Process_Data
          text
    -->  p1        text
    <--  p2        text
    FORM Process_Data .
      data:l_tabix type sy-tabix.
      data:l_periv like t001-periv,
           l_monat like bkpf-monat,
           l_gjahr like bkpf-gjahr,
           l_amt(21) type c.
      data: l_ddate(10),
            l_pdate(10).
      WRITE p_docdat TO l_ddate.
      WRITE p_postda TO l_pdate.
      clear: l_periv,l_monat,l_gjahr.
      select single periv from t001 into l_periv where bukrs = '5000'. "P_bukrs
      if sy-subrc eq 0.
        l_gjahr = p_postda+0(4).
        call function 'FI_PERIOD_DETERMINE'
          EXPORTING
            i_budat = p_postda
            i_bukrs = '5000'     "p_bukrs
            i_periv = l_periv
            i_gjahr = l_gjahr
          IMPORTING
            e_monat = l_monat.
        clear:l_periv.
      endif.
      loop at itab2.
        refresh:bdcdata.
        clear:bdcdata.
        l_tabix = sy-tabix.
        perform bdc_dynpro      using 'SAPLK23F1' '1200'.
        perform bdc_field       using 'BDC_OKCODE'
                                      '/00'.
        perform bdc_field       using 'COHEADER-SEND_REC_REL'
                                      '10SAP'.
        perform bdc_field       using 'RK23F-STATUS'
                                      'S'.
        perform bdc_field       using 'COHEADER-BLDAT'
                                 itab-docdate.
                                      l_ddate.
        perform bdc_field       using 'COHEADER-BUDAT'
                                 itab-postdate.
                                      l_pdate.
        perform bdc_field       using 'COHEADER-PERIO'
                                       l_monat.                 "'9'.
        perform bdc_field       using 'COHEADER-BLTXT'
                                 itab-doctext.
                                      p_doctxt.
        perform bdc_field       using 'RK23F-KSTAR'
                                      itab2-costele.
        WRITE itab2-amount TO l_amt.
    l_amt = itab-amount.
        condense l_amt no-gaps.
        perform bdc_field       using 'RK23F-WTGBTR'
                                       l_amt.
                                 itab-amount.
        perform bdc_field       using 'RK23F-WAERS'
                                      'USD'.
    *perform bdc_field       using 'RK23F-SGTXT'
                                 itab-doctext.
        perform bdc_field       using 'RK23F-SKOSTL'
                                      itab2-scostctr.
        perform bdc_field       using 'BDC_CURSOR'
                                      'RK23F-EAUFNR'.
        perform bdc_field       using 'RK23F-EKOSTL'
                                      itab2-rcostctr.
        perform bdc_field       using 'RK23F-EAUFNR'
                                      itab2-rintorder.
        perform bdc_dynpro      using 'SAPLK23F1' '1200'.
        perform bdc_field       using 'BDC_OKCODE'
                                      '=POST'.
        perform bdc_field       using 'COHEADER-SEND_REC_REL'
                                      '10SAP'.
        perform bdc_field       using 'RK23F-STATUS'
                                      'S'.
        perform bdc_field       using 'COHEADER-BLDAT'
                                 itab-docdate.
                                      l_ddate.
        perform bdc_field       using 'COHEADER-BUDAT'
                                  itab-postdate.
                                      l_pdate.
        perform bdc_field       using 'COHEADER-PERIO'
                                 '9'.
                                        l_monat.
        perform bdc_field       using 'COHEADER-BLTXT'
                                  itab-doctext.
                                      p_doctxt.
        perform bdc_field       using 'BDC_CURSOR'
                                      'RK23F-KSTAR'.
        perform bdc_field       using 'RK23F-WAERS'
                                      'USD'.
        CALL TRANSACTION 'KB15N' USING BDCDATA MODE DIS_MODE MESSAGES INTO MESSTAB.
        If sy-subrc = 0.
          s_rec = s_rec + 1.
        ELSE.
          u_rec = u_rec + 1.
          move ITAB2-NUM to messtab1-msgv1.
          concatenate itab2-costele ' | ' itab2-scostctr  ' | '  itab2-rcostctr ' | ' itab2-rintorder  into  messtab1-msgv2.
          condense messtab1-msgv2.
          condense messtab1-msgv1.
          append messtab1.
        endif.
        clear:itab2.
      endloop.
    ENDFORM.                    " Process_Data
          BDC_DYNPRO                                                     *
    FORM BDC_DYNPRO USING PROGRAM DYNPRO.
      CLEAR BDCDATA.
      BDCDATA-PROGRAM  = PROGRAM.
      BDCDATA-DYNPRO   = DYNPRO.
      BDCDATA-DYNBEGIN = 'X'.
      APPEND BDCDATA.
    ENDFORM.                    "BDC_DYNPRO
           BDC_FIELD                                                     *
    FORM BDC_FIELD USING FNAM FVAL.
      IF FVAL <> ''. "NODATA.
        CLEAR BDCDATA.
        BDCDATA-FNAM = FNAM.
        BDCDATA-FVAL = FVAL.
        APPEND BDCDATA.
      ENDIF.
    ENDFORM.                    "BDC_FIELD
    *&      Form  display_data
          text
    -->  p1        text
    <--  p2        text
    FORM display_data .
      skip 2.
      write:/15 text-002.
      skip 2.
      write:/8 text-003.
      SKIP.
      write:/12 text-008,
             25 P_DOCDAT.
      SKIP.
      write:/12 text-009,
             25 P_POSTDA.
      SKIP.
      write:/12 text-012,
              25 P_DOCTXT.
      SKIP.
      write:/12 text-004,
             25 p_file.
      skip 2.
      write:/8 text-005,
            60 t_lin.
      skip.
      write:/8 text-006,
            60 s_rec.
      skip.
      write:/8 text-007,
            60 u_rec.
      skip.
      write:/10 'row no',
             20 'Information'.
      skip.
      loop at messtab1.
        write:/10 messtab1-msgv1,
               20 messtab1-msgv2.
        clear:messtab1.
      endloop.
    ENDFORM.                    " display_data
    *&      Form  validate_data
          text
    -->  p1        text
    <--  p2        text
    FORM validate_data .
      data: l_tabix1 type sy-tabix.
    data: l_tabix2 type sy-tabix.
      if not itab[] is initial.
        select kostl from CSKS into table it_csks.
        if sy-subrc eq 0.
          sort it_csks by kostl.
        endif.
        select kstar from CSKA into table it_cska.
        if sy-subrc eq 0.
          sort it_cska by kstar.
        endif.
        loop at itab.
          l_tabix1 = sy-tabix.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        INPUT         = itab-scostctr
    IMPORTING
       OUTPUT        = itab-scostctr .
          read table it_csks into wa_csks with key kostl = itab-scostctr.
          if sy-subrc ne 0.
            u_rec = u_rec + 1.
           L_TABIX2 = l_tabix1 + 1.
           move l_tabix2 to messtab1-msgv1.
            move l_tabix1 to messtab1-msgv1.
            move itab-rintorder to messtab1-msgv2.
            concatenate itab-costele  ' | ' itab-scostctr  ' | '  itab-rcostctr  ' | ' itab-rintorder  into  messtab1-msgv2.
            condense messtab1-msgv2.
            condense messtab1-msgv1.
            append messtab1.
            clear:wa_csks.
           CLEAR:L_TABIX2.
            continue.
          endif.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        INPUT         = itab-rcostctr
    IMPORTING
       OUTPUT        = itab-rcostctr .
          read table it_csks into wa_csks with key kostl = itab-rcostctr.
          if sy-subrc ne 0.
            u_rec = u_rec + 1.
           L_TABIX2 = l_tabix1 + 1.
           move l_tabix2 to messtab1-msgv1.
            move l_tabix1 to messtab1-msgv1.
              concatenate itab-costele ' | ' itab-scostctr  ' | '  itab-rcostctr ' | ' itab-rintorder  into  messtab1-msgv2.
            condense messtab1-msgv2.
            condense messtab1-msgv1.
            append messtab1.
            clear:wa_csks.
           CLEAR:L_TABIX2.
            continue.
          endif.
    CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
      EXPORTING
        INPUT         = itab-costele
    IMPORTING
       OUTPUT        = itab-costele .
          read table it_cska into wa_cska with key kstar = itab-costele.
          if sy-subrc ne 0.
            u_rec = u_rec + 1.
           L_TABIX2 = l_tabix1 + 1.
           move l_tabix2 to messtab1-msgv1.
            move l_tabix1 to messtab1-msgv1.
            concatenate itab-costele ' | ' itab-scostctr  ' | '  itab-rcostctr ' | ' itab-rintorder  into  messtab1-msgv2.
            condense messtab1-msgv2.
            condense messtab1-msgv1.
            append messtab1.
            clear:wa_csks.
           CLEAR:L_TABIX2.
            continue.
          endif.
    move-corresponding itab to itab2.
    MOVE l_tabix1  TO ITAB2-NUM.
    append itab2.
    clear: itab2.
          clear:itab.
        endloop.
      else.
        message 'No records in File'  type 'S'.
      endif.
    ENDFORM.                    " validate_data

  • How to load a flat file with lot of records

    Hi,
    I am trying to load a flat file with hundreds of records into an apps table. when i create the process and deploy it onto the console it asks for an input in an html form. why does it ask for an input when i have specified the input file directory in my process? is there any way around tis where in it just reads all the records from the flat file directly??is custom queues anyway related to what I am about to do?any documents on this process will be greatly appreciated.If any one can help me on this it will be great. thank you guys....

    After deploying it, do you see if it is active and the status is on from the BPEL console BPEL Process tab? It should not come up to ask for input unless you are clicking it from the Dashboard tab. Do not click it from the Dashboard. Instead you should put some files into the input driectory. Wait few seconds you should see the instances of the BPEL process is created and start to process the files asynchrously.

  • Errors in flat file records? how can i handle them?

    Hi All,
    I am new for BDC. I am uploading customer(XD01) records using BDC caltransaction method.my problem is when i am running the program, some times my program is not updating the records because of my flat file errors. after i correcting the error records and if i run the same program already updated records not processing. my program not running. what i need to do? how can i handle the flat file for reprocessing the error records?
    i have around 50,000 records in my flat file.

    your program accepts a flat file say the structure of it is structure_load and you create another structure similar to structure_load and name it structure_error.
    loop at itab_load.
    call transactions...
    if success..
    commit work and wait X sec.
    else.
    move-corresponding field to structure_error
    append structure_error.
    endif.
    endloop.
    write the file stru_error to PC or app server and make the changes  to the data and use the str_error as input to your code again..

  • Validate Technical Information from Flat File header record

    Hi Experts,
    I would like to know the best way to validate data from a flat file where the layout has a header containing the number of records sent and the total amount distributed along the file content.
    Please, notice we have a commom layout where the first 3 fields are only used by header record (record type = 00)
    For example:
    RECORD TYPE     NUMBER OF RECORDS     TOTAL AMOUNT     COST CENTER     AMOUNT
              00                              3                                  250,00                                                    
              01                                                                                1000000             100,00
              01                                                                                2000000             100,00
              01                                                                                1000000               50,00
    So, let´s suppose I received the file content above and I have recorded all 4 records in a first DSO. The next step I would like to load to a different DSO the records where RECORD TYPE = 01 (business) data. That´s OK.
    The header record where RECORD TYPE = 00 (technical data) has to be uploded to a log DSO validating the total amount (250,00) and number of records (3)  sent in the file. This line will be further exported as a validation information.
    Well, any suggestions how to validate the data as described above?
    Any information will be fully appreciated.
    Thanks.
    Fábio
    Edited by: Fabio Chaves on Jan 30, 2010 9:30 PM

    Hi Fabio,
    You seem to compare the first record of file or header record with the collated values of rest of the records in the flat file.
    Simple way would be to do validation separate and load the file...
    create a function module to read a file...
    compare the first record with the collated values in the rest of file.
    If the file seems to be okay,then loading is your choice...
    rakesh

Maybe you are looking for