How to skip first records while reading a csv file

Hi,
How to skip the first 5 records while reading csv file.
I have a file which contains first 5 records as dummy records, I want to skip those records and load the rest into RDBMS.
How to achieve this?
Thanks,
Naveen Suram

Hi Guru,
Actually I have converted an excel to CSV format, which is generating first 4 rows as some dummy records. 5th row is my header record. But in hearder record, two column names are same. Thats why while reversing it is giving an error.
With zero in number of columns in header, I am getting the column names as C1, C2...
If not in reversing, can we reject the first records while loading into RDMBS table using an interface?
Thanks,
Naveen Suram

Similar Messages

  • 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 Design this Class while Reding a Csv File.

    i[b] want to make this more Design orinted. This code is for reading A csv file and scnning it for Duplicate data in that Csv file.public Vector upLoadCsv(String csvFile) throws Exception
              boolean flag =false;
               Connection conn    = null;
             PreparedStatement  stmt    = null;
               Vector upload_data=new Vector();
               patternMapDescs = new Vector();
               patternFroms     = new Vector();
               patternTos     = new Vector();
               oprNetIds     = new Vector();
               circleIds     = new Vector();
               ldcaIds          = new Vector();
               sdcaIds          = new Vector();
         try{
              fileOut = new FileOutputStream(patrnBulkFailureFilePath, true);
              patternMapList=readFile(csvFile);
              System.out.println("PatternMapList is "+patternMapList); 
              Vector Patter_From=(Vector)patternMapList.get(0);
              Vector Pattern_To=(Vector)patternMapList.get(1);
              Vector Opr_Net_Id=(Vector)patternMapList.get(2);
              Vector Circle_Id=(Vector)patternMapList.get(3);
              Vector Ldca_Id=(Vector)patternMapList.get(4);
              Vector Sdca_Id=(Vector)patternMapList.get(5);
              Vector Msc_Id=(Vector)patternMapList.get(6);
              Vector Cell_Id=(Vector)patternMapList.get(7);
              Vector Pattern_Desc=(Vector)patternMapList.get(8);
              try
                        conn = DBHelper.getConnection();
                        System.out.println("Size is "+Patter_From.size());
                        for(int i=0;i<Patter_From.size();i++)
                             try
                             int result = 0;
                             System.out.println("Count value is "+i);
                             stmt = conn.prepareStatement("update lcorating.PATTERN_MAP set PATTERN_FROM=?,PATTERN_TO=?,OPR_NET_ID=?,CIRCLE_ID=?,LDCA_ID=?,SDCA_ID=?,MSC_ID=?,CELL_ID=?,PATTERN_DESC=? where pattern_from=? and pattern_to=?");                         
                             stmt.setString(1,(String)Patter_From.get(i));
                             stmt.setString(2,(String)Pattern_To.get(i));
                             stmt.setString(3,(String)Opr_Net_Id.get(i));
                             stmt.setString(4,(String)Circle_Id.get(i));
                             stmt.setString(5,(String)Ldca_Id.get(i));
                             stmt.setString(6,(String)Sdca_Id.get(i));
                             stmt.setString(7,(String)Msc_Id.get(i));
                             stmt.setString(8,(String)Cell_Id.get(i));
                             stmt.setString(9,(String)Pattern_Desc.get(i));
                             stmt.setString(10,(String)Patter_From.get(i));
                             stmt.setString(11,(String)Pattern_To.get(i));
                             result = stmt.executeUpdate();
                             System.out.println("result is "+result + "for "+(String)Patter_From.get(i));
              if(result==1)
                             upload_data.add((String)Patter_From.get(i));
                             upload_data.add((String)Pattern_To.get(i));
                             upload_data.add((String)Opr_Net_Id.get(i));
                             upload_data.add((String)Circle_Id.get(i));
                             upload_data.add((String)Ldca_Id.get(i));
                             upload_data.add((String)Sdca_Id.get(i));
                             upload_data.add((String)Msc_Id.get(i));
                             upload_data.add((String)Cell_Id.get(i));
                             upload_data.add((String)Pattern_Desc.get(i));
                             patternFroms.add((String)Patter_From.get(i));
                             patternTos.add((String)Pattern_To.get(i));
                             oprNetIds.add((String)Opr_Net_Id.get(i));
                             circleIds.add((String)Circle_Id.get(i));
                             ldcaIds.add((String)Ldca_Id.get(i));
                             sdcaIds.add((String)Sdca_Id.get(i));
                             patternMapDescs.add((String)Pattern_Desc.get(i));
                        if(result==0)
                             stmt = conn.prepareStatement("insert into lcorating.PATTERN_MAP values(?,?,?,?,?,?,?,?,?)");
                             stmt.setString(1,(String)Patter_From.get(i));
                             stmt.setString(2,(String)Pattern_To.get(i));
                             stmt.setString(3,(String)Opr_Net_Id.get(i));
                             stmt.setString(4,(String)Circle_Id.get(i));
                             stmt.setString(5,(String)Ldca_Id.get(i));
                             stmt.setString(6,(String)Sdca_Id.get(i));
                             stmt.setString(7,(String)Msc_Id.get(i));
                             stmt.setString(8,(String)Cell_Id.get(i));
                             stmt.setString(9,(String)Pattern_Desc.get(i));
                             stmt.executeUpdate();
    upload_data.add((String)Patter_From.get(i));
    upload_data.add((String)Pattern_To.get(i));
    upload_data.add((String)Opr_Net_Id.get(i));
    upload_data.add((String)Circle_Id.get(i));
    upload_data.add((String)Ldca_Id.get(i));
    upload_data.add((String)Sdca_Id.get(i));
    upload_data.add((String)Msc_Id.get(i));
    upload_data.add((String)Cell_Id.get(i));
    upload_data.add((String)Pattern_Desc.get(i));
                             catch(Exception e)
                                  System.out.println("Exception entry "+i);
                                  String strFailure = (String)Patter_From.get(i) + ","+
                                                           (String)Pattern_To.get(i) + ","+
                                                           (String)Opr_Net_Id.get(i) + ","+
                                                           (String)Circle_Id.get(i) + ","+
                                                           (String)Ldca_Id.get(i) + ","+
                                                           (String)Sdca_Id.get(i) + ","+
                                                           (String)Msc_Id.get(i) + ","+
                                                           (String)Cell_Id.get(i) + ","+
                                                           (String)Pattern_Desc.get(i)+ "," + new java.util.Date()+ "\n";
                                  System.out.println("writing "+ (String)Patter_From.get(i));
                                  fileOut.write(strFailure.getBytes());
                                  continue;
                        }catch(Exception e)
                             System.out.println("Excepion is "+e);                         
                   flag=true;
                   catch(Exception e)
                   flag=false;
                   System.out.println("Exception in Reading File===>"+e);
    System.out.println("Uploaded data is ");
    System.out.println(upload_data);
              return      upload_data;
    // This method "readFile"  Reads the CSV file in the form of StringToken
    private List readFile(String fileName)
              BufferedReader     br;
              String               record;
              StringTokenizer     st;
              Vector     vPatternFrom= new Vector();
              Vector vectorPatternFrom= new Vector();
              Vector vectorPatternTo= new Vector();
              Vector vectorOpertorNetworkId= new Vector();
              Vector vectorCircleId= new Vector();
              Vector vectorLdcaId= new Vector();
              Vector vectorSdcaId= new Vector();
              Vector vectorMscId= new Vector();
              Vector vectorCellId= new Vector();
              Vector vectorPatternDesc= new Vector();
              ArrayList totalList=new ArrayList();
              boolean isExist=false;
               boolean duplicateOrgNUmFlag=false;
              try
                   br = new BufferedReader(new InputStreamReader(new FileInputStream(fileName)));
                   while ((record = br.readLine()) != null)
                        st = new StringTokenizer(record,",");
                        try
                             while (st.hasMoreTokens())
                                  vPatternFrom.add(st.nextToken());
                                  vPatternFrom.add(st.nextToken());
                                  vPatternFrom.add(st.nextToken());
                                  vPatternFrom.add(st.nextToken());
                                  vPatternFrom.add(st.nextToken());
                                  vPatternFrom.add(st.nextToken());
                                  vPatternFrom.add(st.nextToken());
                                  vPatternFrom.add(st.nextToken());
                                  vPatternFrom.add(st.nextToken());     
                        catch(NoSuchElementException nseex)
                             System.out.println("Record without valid data :: " + record);
              catch(FileNotFoundException fnfex)
                   System.out.println("exception is"+fnfex.toString());
              catch (IOException ioex)
                   System.out.println("exception is"+ioex.toString());
              catch(Exception e){
                   System.out.println("praveen is stupid");
              System.out.println("vPatternFrom"+vPatternFrom);
              int noOfRecords = vPatternFrom.size();
              //System.out.println("Size of record is "+noOfRecords);
              for(int i=0;i<vPatternFrom.size();i=i+9)
                        String sPatternFrom=(String)vPatternFrom.get(i);
                        vectorPatternFrom.add(sPatternFrom);
                        String sPatternTo     =(String)vPatternFrom.get(i+1);
                        vectorPatternTo.add(sPatternTo);
                        String sOpertorNetworkId=(String)vPatternFrom.get(i+2);
                        vectorOpertorNetworkId.add(sOpertorNetworkId);
                        String sCircleId=(String)vPatternFrom.get(i+3);
                        vectorCircleId.add(sCircleId);
                        String sLdcaId=(String)vPatternFrom.get(i+4);     
                        vectorLdcaId.add(sLdcaId);
                        String sSdcaId=(String)vPatternFrom.get(i+5);
                        vectorSdcaId.add(sSdcaId);     
                        String sMscId=(String)vPatternFrom.get(i+6);
                        vectorMscId.add(sMscId);
                        String sCellId=(String)vPatternFrom.get(i+7);
                        vectorCellId.add(sCellId);
                        String sPatternDesc =(String)vPatternFrom.get(i+8);
                        vectorPatternDesc.add(sPatternDesc);
         totalList.add(vectorPatternFrom);
         totalList.add(vectorPatternTo);
         totalList.add(vectorOpertorNetworkId);
         totalList.add(vectorCircleId);
         totalList.add(vectorLdcaId);
         totalList.add(vectorSdcaId);
         totalList.add(vectorMscId);
         totalList.add(vectorCellId);
         totalList.add(vectorPatternDesc);
    ArrayList rrList=new ArrayList();
    try{
              rrList=verifyTotalPatternData(totalList);
    }catch(Exception e){
         System.out.println("excpetion is bothering");
              return rrList;
    public ArrayList verifyTotalPatternData(ArrayList totalList)
              Vector pattern_from=(Vector)totalList.get(0);
              Vector pattern_to=(Vector)totalList.get(1);
              Vector opr_net_id=(Vector)totalList.get(2);
              Vector circle_id=(Vector)totalList.get(3);
              Vector ldca_id=(Vector)totalList.get(4);
              Vector sdca_id=(Vector)totalList.get(5);
              Vector msc_id=(Vector)totalList.get(6);
              Vector cell_id=(Vector)totalList.get(7);
              Vector pattern_desc=(Vector)totalList.get(8);
              String strFailure = "";
              for(int i=0;i<pattern_from.size();i++){
                   for(int j=i+1;j<pattern_from.size();j++){
                        if((pattern_from.get(j)).equals(pattern_from.get(i))){
                             if((pattern_to.get(j)).equals(pattern_to.get(i))){
                                  try{
                                  strFailure=(String)pattern_from.get(i) + ","+
                                                 (String)pattern_to.get(i) + ","+
                                                 (String)opr_net_id.get(i) + ","+
                                                 (String)circle_id.get(i) + ","+
                                                 (String)ldca_id.get(i) + ","+
                                                 (String)sdca_id.get(i) + ","+
                                                 (String)msc_id.get(i) + ","+
                                                 (String)cell_id.get(i) + ","+
                                                 (String)pattern_desc.get(i) + "," + new java.util.Date()+"\n";
                                  //System.out.println("writing "+ (String)pattern_from.get(i));
                                  fileOut.write(strFailure.getBytes());
                                  catch(Exception e)
                                       System.out.println("Exception while adding entry in bulkFailureData.csv "+e);
                                  pattern_from.removeElementAt(j);
                                  pattern_to.removeElementAt(j);
                                  opr_net_id.removeElementAt(j);
                                  circle_id.removeElementAt(j);
                                  ldca_id.removeElementAt(j);
                                  sdca_id.removeElementAt(j);
                                  msc_id.removeElementAt(j);
                                  cell_id.removeElementAt(j);
                                  pattern_desc.removeElementAt(j);
                                  j--;
              ArrayList ret_list = new ArrayList();
              ret_list.add(pattern_from);
              ret_list.add(pattern_to);
              ret_list.add(opr_net_id);
              ret_list.add(circle_id);
              ret_list.add(ldca_id);
              ret_list.add(sdca_id);
              ret_list.add(msc_id);
              ret_list.add(cell_id);
              ret_list.add(pattern_desc);
              //System.out.println("The filtered list is "+ret_list);
              return ret_list;
         }

    I was bored, so I took a stab at cleaning your code up a bit. You need
    to take advantage of the Collections API, and you desparately
    need to learn how to use data structures. Some would argue
    that my get???Statement methods are really bad, fyi. They might
    very well be right -- it's hard to tell from the few methods provided.
    You should also take a serious look at Log4j, or at least the
    java standard logger.
    import java.io.BufferedReader;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.FileReader;
    import java.io.IOException;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.SQLException;
    import java.util.Collection;
    import java.util.HashSet;
    import java.util.Iterator;
    import java.util.Set;
    import java.util.Vector;
    public class Foo {
        private final FileOutputStream fileOut;       
        public Foo() throws FileNotFoundException {
            this.fileOut = new FileOutputStream(patrnBulkFailureFilePath, true);
        public Set uploadCsv(final String csvFile) {
            final Set uploadedData = new HashSet();
            Connection conn = null;
            Vector upload_data = new Vector();
            final Collection patternDataSet = this.readFile(csvFile);
            try {
                conn = DBHelper.getConnection();
                for (final Iterator i = patternDataSet.iterator(); i.hasNext(); ) {
                    final PatternData patternData = (PatternData) i.next();
                    final PreparedStatement updateStatement =
                        patternData.getUpdateStatement(conn);
                    try {
                        final int result = updateStatement.executeUpdate();
                        if (result == 1) {
                            uploadedData.add(patternData);
                        if (result == 0) {
                            final PreparedStatement insertStatement =
                                patternData.getInsertStatement(conn);
                            insertStatement.executeUpdate();
                            uploadedData.add(patternData);
                    } catch (final SQLException se) {
                        final String errorMsg =
                            patternData.toString() + "," +
                            System.currentTimeMillis();
                        this.fileOut.write(errorMsg.getBytes());
            } catch (final SQLException se) {
                System.err.println("Unexpected SQL Exception");
                se.printStackTrace(System.err);
            return uploadedData;
        private Collection readFile(final String fileName) {
            final FileReader fileReader;
            final BufferedReader bufferedReader;
            final Set patternData = new HashSet();
            try {
                fileReader = new FileReader(fileName);
                bufferedReader = new BufferedReader(fileReader);
                while (bufferedReader.ready()) {
                    final String dataLine = bufferedReader.readLine();
                    final String[] values = dataLine.split(",");
                    final PatternData data = new PatternData(values);
                    if (patternData.contains(data)) {
                        final String errorMsg =
                            data.toString() + "," + System.currentTimeMillis();
                        this.fileOut.write(errorMsg.getBytes());                   
                    } else {
                        patternData.add(new PatternData(values));
            } catch (final FileNotFoundException fnfe) {
                System.err.println("Unable to locate file: " + fileName);
            } catch (final IOException ioe) {
                System.err.println("Unexpected IO Exception");
                ioe.printStackTrace(System.err);
            return patternData;
        private static class PatternData {
            private final String patternFrom;
            private final String patternTo;
            private final String oprNetID;
            private final String circleID;
            private final String ldcaID;
            private final String sdcaID;
            private final String mscID;
            private final String cellID;
            private final String patternDesc;
            public PatternData(final String patternFrom, final String patternTo,
                    final String oprNetID, final String circleID, final String
                    ldcaID, final String sdcaID, final String mscID,
                    final String cellID, final String patternDesc) {
                this.patternFrom = patternFrom;
                this.patternTo = patternTo;
                this.oprNetID = oprNetID;
                this.circleID = circleID;
                this.ldcaID = ldcaID;
                this.sdcaID = sdcaID;
                this.mscID = mscID;
                this.cellID = cellID;
                this.patternDesc = patternDesc;
            public PatternData(final String[] dataValues)
            throws IllegalArgumentException {
                if (dataValues == null) {
                    throw new IllegalArgumentException("The dataValues " +
                            "parameter may not be null.");
                if (dataValues.length != 9) {
                    throw new IllegalArgumentException("The dataValues parameter " +
                            "must have a length of 9, not " + dataValues.length);
                this.patternFrom = dataValues[0];
                this.patternTo = dataValues[1];
                this.oprNetID = dataValues[2];
                this.circleID = dataValues[3];
                this.ldcaID = dataValues[4];
                this.sdcaID = dataValues[5];
                this.mscID = dataValues[6];
                this.cellID = dataValues[7];
                this.patternDesc = dataValues[8];
            public boolean equals(final Object obj) {
                if (this == obj) {
                    return true;
                if (!(obj instanceof PatternData)) {
                    return false;
                final PatternData otherData = (PatternData) obj;
                if (this.patternFrom.equals(otherData.patternFrom) &&
                        this.patternTo.equals(otherData.patternTo)) {
                    return true;
                return false;
            public int hashCode() {
                int hash = 17;
                hash = 37 * hash + this.patternFrom.hashCode();
                hash = 37 * hash + this.patternTo.hashCode();
                return hash;
            public String toString() {
                return this.patternFrom + "," + this.patternTo + "," +
                     this.oprNetID + "," + this.circleID + "," +
                     this.ldcaID + "," + this.sdcaID + "," + this.mscID + "," +
                     this.cellID + "," + this.patternDesc;
            public PreparedStatement getUpdateStatement(final Connection conn)
            throws SQLException {
                final PreparedStatement statement =
                    conn.prepareStatement("update lcorating.PATTERN_MAP set " +
                            "PATTERN_FROM=?,PATTERN_TO=?,OPR_NET_ID=?," +
                            "CIRCLE_ID=?,LDCA_ID=?,SDCA_ID=?,MSC_ID=?,CELL_ID=?" +
                            ",PATTERN_DESC=? where pattern_from=? and " +
                            "pattern_to=?");                                  
                statement.setString(1, this.patternFrom);
                statement.setString(2, this.patternTo);
                statement.setString(3, this.oprNetID);
                statement.setString(4, this.circleID);
                statement.setString(5, this.ldcaID);
                statement.setString(6, this.sdcaID);
                statement.setString(7, this.mscID);
                statement.setString(8, this.cellID);
                statement.setString(9, this.patternDesc);
                statement.setString(10, this.patternFrom);
                statement.setString(11, this.patternTo);
                return statement;
            public PreparedStatement getInsertStatement(final Connection conn)
            throws SQLException {
                final PreparedStatement statement =
                    conn.prepareStatement("insert into lcorating.PATTERN_MAP " +
                            "values(?,?,?,?,?,?,?,?,?)");
                statement.setString(1, this.patternFrom);
                statement.setString(2, this.patternTo);
                statement.setString(3, this.oprNetID);
                statement.setString(4, this.circleID);
                statement.setString(5, this.ldcaID);
                statement.setString(6, this.sdcaID);
                statement.setString(7, this.mscID);
                statement.setString(8, this.cellID);
                statement.setString(9, this.patternDesc);
                return statement;
    }

  • How to skip first screen while calling transaction

    Hi all,
    I am using interactive alv.
    if i select one line and press details
    that must go to another screen.
    In that i must skip first screen and directly go to the details of that first screen.
    suppose i am using the code as follows
    call transaction mm01 and skip first screen
    this is giving me error.
    how to solve the problem.
    thanks and regards,
    giri.

    hi giri,
    For ur requirement, u can use SKIP FIRST SCREEN addition for CALL TRANSACTION Command.
    Before this, u have to use SET PARAMETER ID Command to pass the required values for transaction.
    Example, In transaction VA01, we have to set parameter AUN to pass the sale order number to the transaction.
    <b>
    AT LINE-SELECTION .
    SET PARAMETER ID 'AUN' FIELD w_vbeln.
    CALL TRANSACTION 'VA01' AND SKIP FIRST SCREEN .</b>
    where w_vbeln contains the sale ordre number. Now VA01 runs for this sale order number..... And AUN is the PARAMETER to be set before calling VA01 TCODE.
    similarly, check the PARAMETER associated with MM01 Tcode and initialize that parameter and call the code in the similar way.
    To check parameter Id of MM01,
    1) Enter MM01 Transaction
    2) Press F1 on Material Field
    3) Select Technical Info
    4) u can find Parameter ID associated with this field.
    check these links for full details.
    call transaction...
    http://help.sap.com/saphelp_47x200/helpdata/en/78/21761c51ce11d189570000e829fbbd/frameset.htm
    at line selection,
    http://help.sap.com/saphelp_47x200/helpdata/en/9f/dba2c435c111d1829f0000e829fbfe/frameset.htm
    get/set parameter:
    http://help.sap.com/saphelp_nw04/helpdata/en/5b/7bc3775d1111d295ad0000e82de14a/frameset.htm
    Reward me if useful........
    Harimanjesh AN

  • How to skip footer record in SQL*Loader input file

    I have am using SQL*Loader in a batch import process.
    The input files to SQL*Loader have a header record and footer record - always the 1st and last records in the file.
    I need SQL*Loader to ignore these two records in every file when performing the import. I can easily ignore the header by using the SKIP function.
    Does anybody know how to ignore the last record (footer) in an input file??
    I do not want to physically pre-strip the footer since the business want all data files to have the header and footer records.

    Thanks - how do I use the when clause to specify the last line of the input file?
    I am presuming it requires me to have a unique identifier at a given position on that last line. If I don't have such an identifier can I still use your solution?
    Cheers Why not putting an idetifier at the end of your input file: echo "This_is_the_End" >> input_file ?

  • How to skip first 5 lines from a txt file when using sql*loader

    Hi,
    I have a txt file that contains header info tat i dont need. how can i skip those line when importing the file to my database?
    Cheers

    Danny Fasen wrote:
    I think most of us would process this report using pl/sql:
    - read the file until you've read the column headers
    - read the account info and insert the data in the table until you have read the last account info line
    - read the file until you've read a new set of column headers (page 2)
    - read the account info and insert the data in the table until you have read the last account info line (page 2)
    - etc. until you reach the total block idenfitied by Count On-line ...
    - read the totals and compare them with the data inserted in the tableOr maybe like this...
    First create an external table to read the report as whole lines...
    SQL> ed
    Wrote file afiedt.buf
      1  CREATE TABLE ext_report (
      2    line VARCHAR2(200)
      3          )
      4  ORGANIZATION EXTERNAL (
      5    TYPE oracle_loader
      6    DEFAULT DIRECTORY TEST_DIR
      7    ACCESS PARAMETERS (
      8      RECORDS DELIMITED BY NEWLINE
      9      BADFILE 'bad_report.bad'
    10      DISCARDFILE 'dis_report.dis'
    11      LOGFILE 'log_report.log'
    12      FIELDS TERMINATED BY X'0D' RTRIM
    13      MISSING FIELD VALUES ARE NULL
    14      REJECT ROWS WITH ALL NULL FIELDS
    15        (
    16         line
    17        )
    18      )
    19      LOCATION ('report.txt')
    20    )
    21  PARALLEL
    22* REJECT LIMIT UNLIMITED
    SQL> /
    Table created.
    SQL> select * from ext_report;
    LINE
    x report page1
    CDC:00220 / Sat Aug-08-2009 xxxxp for 02/08/09 - 08/08/09 Effective Date 11/08/09 Wed Sep-30-2009 08:25:43
    Bill to
    Retailer Retailer Name                  Name on Bank Account           Bank ABA   Bank Acct            On-line Amount  Instant Amount  Total Amount
    ======== ============================== ============================== ========== ==================== =============== =============== ===============
    0100103  BANK Terminal                  raji                           123456789  123456789            -29,999.98    9 0.00         99 -29,999.98
    0100105  Independent 1                  Savings                        123456789  100000002            -1,905.00     9 0.00         99 -1,905.00
    0100106  Independent 2                  system                         123456789  100000003            -800.00       9 -15.00       99 -815.00
    LARGE SPACE
    weekly_eft_repo 1.0 Page: 2
    CDC:00220 / Sat Aug-08-2009 Weekly EFT Sweep for 02/08/09 - 08/08/09 Effective Date 11/08/09 Wed Sep-30-2009 08:25:43
    Bill to
    Retailer Retailer Name Name on Bank Account Bank ABA Bank Acct On-line Amount Instant Amount Total Amount
    ======== ============================== ============================== ========== ==================== =============== =============== ===============
    Count On-line Amount Instant Amount Total Amount
    ============== ====================== ====================== ======================
    Debits 0 0.00 0.00 0.00
    Credits 3 -32,704.98 -15.00 -32,719.98
    Totals 3 -32,704.98 -15.00 -32,719.98
    Total Tape Records / Blocks / Hash : 3 1 37037034
    End of Report
    23 rows selected.Then we can check we can just pull out the lines of data we're interested in from that...
    SQL> ed
    Wrote file afiedt.buf
      1  create view vw_report as
      2* select line from ext_report where regexp_like(line, '^[0-9]')
    SQL> /
    View created.
    SQL> select * from vw_report;
    LINE
    0100103  BANK Terminal                  raji                           123456789  123456789            -29,999.98    9 0.00         99 -29,999.98
    0100105  Independent 1                  Savings                        123456789  100000002            -1,905.00     9 0.00         99 -1,905.00
    0100106  Independent 2                  system                         123456789  100000003            -800.00       9 -15.00       99 -815.00And then we adapt that view to extract the data from those lines as actual columns...
    SQL> col retailer format a10
    SQL> col retailer_name format a20
    SQL> col name_on_bank_account format a20
    SQL> col online_amount format 999,990.00
    SQL> col instant_amount format 999,990.00
    SQL> col total_amount format 999,990.00
    SQL> ed
    Wrote file afiedt.buf
      1  create or replace view vw_report as
      2  select regexp_substr(line, '[^ ]+', 1, 1) as retailer
      3        ,trim(regexp_replace(regexp_substr(line, '[[:alpha:]][[:alnum:] ]*[[:alpha:]]', 1, 1), '(.*) +[^ ]+$', '\1')) as retailer_name
      4        ,trim(regexp_replace(regexp_substr(line, '[[:alpha:]][[:alnum:] ]*[[:alpha:]]', 1, 1), '.* ([^ ]+)$', '\1')) as name_on_bank_account
      5        ,to_number(regexp_substr(regexp_replace(line,'.*[[:alpha:]]([^[:alpha:]]+)','\1'), '[^ ]+', 1, 1)) as bank_aba
      6        ,to_number(regexp_substr(regexp_replace(line,'.*[[:alpha:]]([^[:alpha:]]+)','\1'), '[^ ]+', 1, 2)) as bank_account
      7        ,to_number(regexp_substr(regexp_replace(line,'.*[[:alpha:]]([^[:alpha:]]+)','\1'), '[^ ]+', 1, 3),'999,999.00') as online_amount
      8        ,to_number(regexp_substr(regexp_replace(line,'.*[[:alpha:]]([^[:alpha:]]+)','\1'), '[^ ]+', 1, 5),'999,999.00') as instant_amount
      9        ,to_number(regexp_substr(regexp_replace(line,'.*[[:alpha:]]([^[:alpha:]]+)','\1'), '[^ ]+', 1, 7),'999,999.00') as total_amount
    10* from (select line from ext_report where regexp_like(line, '^[0-9]'))
    SQL> /
    View created.
    SQL> select * from vw_report;
    RETAILER   RETAILER_NAME        NAME_ON_BANK_ACCOUNT   BANK_ABA BANK_ACCOUNT ONLINE_AMOUNT INSTANT_AMOUNT TOTAL_AMOUNT
    0100103    BANK Terminal        raji                  123456789    123456789    -29,999.98           0.00   -29,999.98
    0100105    Independent 1        Savings               123456789    100000002     -1,905.00           0.00    -1,905.00
    0100106    Independent 2        system                123456789    100000003       -800.00         -15.00      -815.00
    SQL>I couldn't quite figure out the "9" and the "99" data that was on those lines so I assume it should just be ignored. I also formatted the report data to fixed columns width in my external text file as I'd assume that's how the data would be generated, not that that would make much difference when extracting the values with regular expressions as I've done.
    So... something like that anyway. ;)

  • How to do the paging while reading from the file !!!

    I've able to display the contents of the file in my jsp as a tabular form. I want to apply the paging concept in my jsp page. As i did in my database project there i's sending the next value as a parameter and it works.
    But when i retrieving the value from the file then i'm not able to get particular values anyhow i'm using the concepts of getLineNumber() but unable to get the previous one worked. I want to diplay only the first 20 contents of the file then, by clicking the next button he should be able to view the next 20 contents of the file. Please help me out for this problem. If possible send me the codes too it'll very helpful for me.
    in advance thanks....

    I hope the following code will help u.
    If your bean is:
    public class yourBean
    private int startIndex ;
    private int pageSize ;
    private int endIndex ;
    public void useBean()
    startIndex = 0;
    pageSize = 10;
    endIndex = pageSize;
    public setters and getters for each of the above.
    In servlet :
    doGet/doPost:
    yourBean uBean =
    (yourBean)sess.getAttribute("urBean");
    int sIndex = uBean.getStartIndex();
    int eIndex = uBean.getEndIndex();
    int pSize = uBean.getPageSize();
    if (sIndex = 0)
    //means first time
    dont do anything
    if ((sIndex >0)&&(sIndex <
    uBean.getRecords().size())))
    eIndex = sIndex + pSize - 1;
    sIndex = eIndex;
    //update Indexes to the bean
    uBean.setStartIndex(sIndex);
    uBean.setEndIndex(eIndex);
    sess.setAttribute("urBean",uBean);
    res.sendRedirect("yourJSP.jsp",req,res);
    In yourJSP.jsp:
    <jsp:useBean id="urBean" type="...." scope="session"
    />
    <%
    int sIndex = urBean.getStartIndex();
    int eIndex = urBean.getEndIndex();
    for (int
    i=sIndex;(i<=eIndex)&&(i<urBean.getRecords().size()))
    out.println(....);
    if (eIndex >= urBean.getRecords().size())
    out.println("NExt");
    else
    out.println("<a href=yourServlet>Next</a>");
    if (sIndex <= 0)
    out.println("Previous");
    else
    out.println("<a href=yourServlet>Previous</a>");
    %>

  • Read a csv file and read the fiscal yr in the 4th pos?

    Hello ABAP Experts,
    how to write a code for read a csv file and read the fiscal year in the 4th position.
    any suggestions or code highly appreciated.
    Thanks,
    BWer

    Hi Bwer,
    Declare table itab with the required fields...
    Use GUI UPLOAD to get the contents of the file (say abc.csv) in case if the file is on the presentation server...
    CALL FUNCTION 'GUI_DOWNLOAD'
      EXPORTING
        filename                        = 'c:\abc.csv'
       FILETYPE                        = 'ASC'
        WRITE_FIELD_SEPARATOR           = 'X'
      tables
        data_tab                        = itab
    EXCEPTIONS
       FILE_WRITE_ERROR                = 1
       NO_BATCH                        = 2
       OTHERS                          = 22
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    Use OPEN DATASET in case if the file is on the application server..
    After that USE SPLIT command at comma to get the contents of the 4th field...
    Regards,
    Tanveer.
    <b>Please mark helpful answers</b>

  • How to skip a record in flat file to idoc scenario?

    Hi,
    Anybody have good suggestions on how to skip a record(xi not process the record) based on certain conditions?  I don't want to use bpm, anybody has experience with file to idoc can advise how to deal with this situation?
    Thanks,
    Meg

    Meg,
    Its very clear. It can be easily done. I hope u might be knowing about Michal's changing the IDOC occurence blog. Based on that blog change the IDOC occurence to 0...Unbounded.
    Now map all the necessary fields to the target IDOC. On the IDOC root node set condition from source if the source field is not Delete then create IDOC else don't create.
    Source --- If without else[Check condition if  the source is delete] -
    IDOC(root node).
    /people/michal.krawczyk2/blog/2005/12/04/xi-idoc-bundling--the-trick-with-the-occurance-change
    Hope its clear, if not kindly revert back.
    Best regards,
    raj.

  • How to read a .csv file(excel format) using Java.

    Hi Everybody,
    I need to read a .csv file(excel) and store all the columns and rows in 2d arrays. Then I can do the rest of the coding myself. I would like it if somebody could post their code to read .csv files over here. The .csv file can have different number of columns and different number of rows every time it is ran. The .csv file is in excel format, so I don't know if that affects the code or not. I would also appreciate it if the classes imported are posted too. I would also like to know if there is a way I can recognize how many rows and columns the .csv file has. I need this urgently so I would be very grateful to anybody who has the solution. Thanks.
    Sincerely Taufiq.

    I used this
    BufferedReader in = new BufferedReader (new FileReader ("test.csv"));
    // and                
    StringTokenizer parser = new StringTokenizer (str, ", ");
                    while (parser.hasMoreTokens () == true)
                    { //crap }works like a charm!

  • How to read a .CSV file using UTL_FILE

    HI,
    How do i read a .csv file line by line using UTL_FILE?
    Thanks in advance
    Regards,
    Gayatri

    ----do open the file logic
    begin
    ----Let's say this file is delimited by ','
    ---declare variables
    v_startPos number; -- starting position of field
    v_Pos number; -- position of string
    v_lenString number; -- length
    v_first_field varchar2(30);
    v_second_field varchar2(30);
    v_third_field varchar2(30);
    v_fourth_field varchar2(30);
    input_String varchar2(1000); -- buffer for each line of file
    ----Say you have a 4 column file delimited by ','
    delimitChar varchar2(1) := ','
    Joe;Joan;People;Animal
    Teddy;Bear;Beans;Toys
    begin
    loop
    utl_file.get_line(input_file, input_String); -- get each line
    ---- this will get the first field as specified by the last number
    v_Pos := instr(input_String,delChar,1,1);
    v_lenString := v_Pos - 1;
    v_first_field := substr(input_String,1,v_lenString);
    v_startPos := v_Pos + 1;
    -- this will get the second field
    v_Pos := instr(inString,delChar,1,2);
    v_lenString := v_Pos - v_startPos;
    v_second_field := substr(input_String,v_startPos,v_lenString);
    v_startPos := v_Pos + 1;
    -- 3rd field
    v_Pos := instr(inString,delChar,1,3);
    v_lenString := v_Pos - v_startPos;
    v_third_field := substr(input_String,v_startPos,v_lenString);
    v_startPos := v_Pos + 1;
    -- last field -- there is no delimiter for last field
    v_Pos := length(input_String) + 1;
    v_lenString := v_Pos - v_startPos;
    v_fourth_field := substr(input_String,v_StartPos,v_lenString);
    end;
    EXCEPTION
    WHEN no_data_found then
              fnd_file.put_line(FND_FILE.LOG, 'Last line so exit');
              exit;
    end loop;

  • Exception thrown while reading an XML file using Properties

    Exception thrown while reading an XML file using Properties.
    Exception in thread "main" java.util.InvalidPropertiesFormatException: org.xml.sax.SAXParseException:
    The processing instruction target matching "[xX][mM][lL]" is not allowed.
    at java.util.XMLUtils.load(Unknown Source)
    <?xml version="1.0"?>
    <Config>
         <Database>
              <Product>FX.O</Product>
              <URL>jdbc:oracle:thin:@0.0.0.0:ABC</URL>
         </Database>
    </Config>Am I missing anything?

    Thanks a lot for all yr help.I have got the basics of
    the DTD
    However,when I say thus
    <!DOCTYPE Config SYSTEM "c:/PartyConfig">
    ?xml version="1.0"?>
    <Config>
         <Database>
              <Product>FX</Product>
              <URL>jdbc:oracle:thin:@0.0.0.0:ABC</URL>
         </Database>
    </Config>I get the error
    Invalid system identifier: file:///c:/ParyConfig.dtd
    Please advise?for goodness sake, how many times do I have to tell you that you can't just expect the Properties class to accept arbitrary XML in any format? it reads XML in the format I linked to, and nothing else. Properties is not a general purpose XML binding. you can't do what you're trying to do with it. read this and in particular pay attention to the following
    The XML document must have the following DOCTYPE declaration:
    <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
    Furthermore, the document must satisfy the properties DTD described above.
    you are not reading my answers properly, are you? kindly do so

  • Exception occured while reading the license file.

    Java Exception: java.lang.RuntimeException
    Exception occurred while reading the license file.
    java.lang.RuntimeException: Exception occurred while reading the license file.
    at weblogic.security.utils.SSLSetup.getLicenseLevel(SSLSetup.java:143)
    at weblogic.security.utils.SSLSetup.getSSLDelegateInstance(SSLSetup.java:196)
    at weblogic.security.utils.SSLContextWrapper.<init>(SSLContextWrapper.java:27)
    at weblogic.security.utils.SSLContextWrapper.getInstance(SSLContextWrapper.java:22)
    at weblogic.security.utils.SSLSetup.getSSLContext(SSLSetup.java:380)
    at weblogic.security.SSL.SSLClientInfo.getSSLSocketFactory(SSLClientInfo.java:56)
    at weblogic.socket.ChannelSSLSocketFactory.getSocketFactory(ChannelSSLSocketFactory.java:125)
    at weblogic.socket.ChannelSSLSocketFactory.createSocket(ChannelSSLSocketFactory.java:75)
    at weblogic.socket.AbstractMuxableSocket.createSocket(AbstractMuxableSocket.java:212)
    at weblogic.rjvm.t3.MuxableSocketT3.newSocketWithRetry(MuxableSocketT3.java:252)
    at weblogic.rjvm.t3.MuxableSocketT3.connect(MuxableSocketT3.java:421)
    at weblogic.rjvm.t3.MuxableSocketT3S.createConnection(MuxableSocketT3S.java:79)
    at weblogic.rjvm.ConnectionManager.createConnection(ConnectionManager.java:1729)
    at weblogic.rjvm.ConnectionManager.findOrCreateConnection(ConnectionManager.java:1392)
    at weblogic.rjvm.ConnectionManager.bootstrap(ConnectionManager.java:445)
    at weblogic.rjvm.ConnectionManager.bootstrap(ConnectionManager.java:323)
    at weblogic.rjvm.RJVMManager.findOrCreateRemoteInternal(RJVMManager.java:263)
    at weblogic.rjvm.RJVMManager.findOrCreate(RJVMManager.java:206)
    at weblogic.rjvm.RJVMFinder.findOrCreateRemoteServer(RJVMFinder.java:226)
    at weblogic.rjvm.RJVMFinder.findOrCreate(RJVMFinder.java:189)
    at weblogic.rjvm.ServerURL.findOrCreateRJVM(ServerURL.java:154)
    at weblogic.jndi.WLInitialContextFactoryDelegate$1.run(WLInitialContextFactoryDelegate.java:342)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:363)
    at weblogic.security.service.SecurityManager.runAs(Unknown Source)
    at weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialContextFactoryDelegate.java:337)
    at weblogic.jndi.Environment.getContext(Environment.java:307)
    at weblogic.jndi.Environment.getContext(Environment.java:277)
    at weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialContextFactory.java:117)
    at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
    at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
    at javax.naming.InitialContext.init(Unknown Source)
    at javax.naming.InitialContext.<init>(Unknown Source)
    I read in the community, that i need to set -Dbea.home="Directory", the Directory should refer to the path where license.bea file is kept on the client side. After setting this i need to pass the
    -Dbea.home="path" to the client jvm.
    Am using tomcat 6.0 server, and weblogic server 10.0.1.  I kept license.bea file in bin folder of the tomcat server.  But i dint understand how to set -Dbea.home="path" and how to pass it to the client jvm. Am stucked up hear. Can pls anyone help me,  to overcome this issue.

    Hi,
    Thank you for contacting us, the best community to place your question is at the OTN JAVA: https://home.java.net/?intcmp=JNET-javanet-sm
    Please let us know if you have any question about OPN CLOUD! Have a great day!

  • How to perform a query to read an xml file in SCCM 2007

    Good,
    I need read knows how to read an csv file for a specific column after collecting the results, then put the PC's in a collection in particular.
    A greeting and thanks

    Good,
    What I want to do is create a query that examine a csv that is on a server. And after consideration and select the column that I am interested
    in(Name pc) be able to engage these data to a collection, clear is if it can be done in SCCM 2007
    A greeting and thanks

  • I have iphoto '08 version with an imac osx 10.5.8. It will not read my RAW files  from my Nikon D800 - a very new model.How can I get it to read my RAW files?

    my somewhat old imac osx 10.5.8 with iphoto '08 will not read my RAW files from my new Nikon D800 camera - a new model on the market( 5 months or so). How can I get iphoto to read my RAW  files?

    iPhoto 08 would not read RAW files from that new a camera. You need to upgrade so you can get more up-to-date version of OS X and iPhoto. Another possiblity is see if iPhoto 11 will run on 10.5.8, if so you should update. You can also attempt to run Software Update and see if it finds a newer release of iPhoto 08 that supports newer RAW formats.

Maybe you are looking for

  • JTextAreaCellRenderer to wrap text in multiple columns... any better way?

    I would like to use a basic JTextArea cell renderer to wrap the text in a JTable cell, like in this thread http://forum.java.sun.com/thread.jspa?threadID=664671&messageID=3893724 Although the technique works, a disadvantage is that it cannot be used

  • Recreate indexes,triggers and primary keys.

    Hi All, We have done an import of few table from MS SQL Server to oracle. But we couldnt see the indexes, triggers, primary key, foreign key of those tables. Could you please let us know how to recreate the primary key, foreign key, indexes, triggers

  • Premiere CC freeze on export and sometimes during rendering

    I have a small project which has four mpeg2 clips in .mov containers, the Fast Color Corrector, Red Giant Looks and Dynamics effects applied to each clip and some title elements. The sequence in Premiere CC seemed to be working fine until the 2.5 upg

  • Is it possible to embed fonts in Keynote theme?

    I've created custom theme for Keynote'08 and everything works fine. My theme uses corporate fonts. At the moment the theme is distributed with additional font pack and the user have to install both, but I'd like to simplify the theme installation pro

  • How to obtain an access key for modifying standard objects?

    Hello, I am a so-called "dummy" in ABAP development, and I need some very basic help. I'm trying to modify standard communication structure MCVBAK for LIS enhancement, as I learned in the LO630 SAP training, but I need an "access key". I went into my