Code for excel sheets

Hi,
This is Employee Survey Application.
Environment:Java,Servlets,HTML,Windows2000,Oracle.
Our problem is ,we could able generate Reports from database to EXCEL sheet format.
We have prepared database to HTML reports.
Our client requirement is to generate Excel format reports.
I want java code for genrating Excel reports from database(oracle) and How to run this xsl reports.

Hi,
you can use the HSSF component of the jakarta POI API (http://jakarta.apache.org/poi/index.html)
Hi,
This is Employee Survey Application.
Environment:Java,Servlets,HTML,Windows2000,Oracle.
Our problem is ,we could able generate Reports from
database to EXCEL sheet format.
We have prepared database to HTML reports.
Our client requirement is to generate Excel format
reports.
I want java code for genrating Excel reports from
database(oracle) and How to run this xsl reports.

Similar Messages

  • KM Docs iView for Excel sheet

    Hi All,
    I have created a KM Document iView for excel sheet and gave the path of excel sheet from KM.
    When I launch the iView, it is opening in a new excel sheet. Is it possible to open the Excel sheet in a browser (html/iView) itself.
    Thanks
    Chinna.

    Chinna,
    Check [this|http://www.mrexcel.com/archive/Hyperlinks/16530.html] out and see if it serves your purpose.
    Cheers!
    Sandeep Tudumu

  • FM for excel sheet download

    Is there any function module which can help me download data from an internal table into mutiple sheets on an excel workbook ?
    My internal table contains more than 65536 records.

    Check it out !!
    *& Report  Y_EXCEL_MULTIPLE                                            *
    REPORT  Y_EXCEL_MULTIPLE.
    parameters: p_fname like RLGRAP-FILENAME
                 default 'C:\temp\testNN.xls'.
    data: fname like p_fname,
          kn like sy-repid.
    data: cnt type i value 0.
    data: sheetname(10) value 'TEST ',c_row type i,
          scnt type i,
          val(20), wb(2).
    parameters: p_exvis as checkbox default 'X',
                p_workbk(2) type p default '01',
                p_wsheet(2) type p default '01'.
    CONSTANTS: OK TYPE I VALUE 0.
    INCLUDE OLE2INCL.
    DATA: EXCEL     TYPE OLE2_OBJECT,
          WORKBOOK  TYPE OLE2_OBJECT,
          SHEET     TYPE OLE2_OBJECT,
          CELL      TYPE OLE2_OBJECT,
          CELL1     TYPE OLE2_OBJECT,
          COLUMN    TYPE OLE2_OBJECT,
          RANGE     TYPE OLE2_OBJECT,
          BORDERS   TYPE OLE2_OBJECT,
          button    TYPE OLE2_OBJECT,
          int      TYPE OLE2_OBJECT,
          FONT      TYPE OLE2_OBJECT,
          ROW       TYPE OLE2_OBJECT.
    data: application type ole2_object,
          book        type ole2_object,
          books       type ole2_object.
    data: ole_book    TYPE ole2_object.
    do p_workbk times.
      move p_fname to fname.
      unpack sy-index to wb.
      replace 'NN' with wb into fname.
      perform create_EXCEL.
    create sheets and save
      perform sheet.
      perform save_book.
    enddo.
    write: ' Done'.
          FORM create_excel                                             *
    form create_excel.
      CREATE OBJECT EXCEL 'EXCEL.APPLICATION'.
      if sy-subrc ne 0.
         write: / 'No EXCEL creation possible'.
         stop.
      endif.
      set property of EXCEL 'DisplayAlerts' = 0.
      CALL METHOD  OF EXCEL 'WORKBOOKS' = WORKBOOK .
    Put Excel in background
      if p_exvis eq 'X'.
        SET PROPERTY OF EXCEL 'VISIBLE' = 1.
      else.
        SET PROPERTY OF EXCEL 'VISIBLE' = 0.
      endif.
    Create worksheet
      set property of excel 'SheetsInNewWorkbook' = 1.
      call method of workbook   'ADD'.
    endform.
          FORM save_book                                                *
    form save_book.
      get property of excel 'ActiveSheet' = sheet.
      free object sheet.
      free object workbook.
      GET PROPERTY OF EXCEL 'ActiveWorkbook' = WORKBOOK.
      call method of workbook 'SAVEAS' exporting #1 = p_fname #2 = 1.
      call method of workbook 'CLOSE'.
      call method of excel 'QUIT'.
      free object sheet.
      free object workbook.
      free object excel.
    endform.
          FORM sheet                                                    *
    form sheet.
      do p_wsheet times.
        unpack sy-index to sheetname+5(2).
        if sy-index gt 1.
          CALL METHOD  OF EXCEL 'WORKSHEETS' = sheet.
          call method of sheet  'ADD'.
          free object sheet.
        endif.
        scnt = sy-index.
        call method  of excel     'WORKSHEETS' = SHEET EXPORTING #1 = scnt.
        call method  of sheet     'ACTIVATE'.
        SET PROPERTY OF SHEET     'NAME'       = sheetname.
        free object sheet.   "OK
        perform fill_sheet.
        CALL METHOD OF EXCEL 'Columns' = COLUMN.
        CALL METHOD OF COLUMN 'Autofit'.
        free object COLUMN.
       call method of sheet 'BUTTON' = button.
       call method of button 'ADD'.
       set property of button 'fmButtonStyle' = 0.
         exporting #1 = '96.75' #2 = '372' #3 = '123.75' #4 = '12'.
       set property of button 'Characters' = 'ButtonTest'.
        free object button.
        free object font.
        free object int.
        free object cell.
        free object: cell1.
        free object range.
        free object borders.
        free object: column, row.
      enddo.
      free object font.
      free object int.
      free object cell.
      free object cell1.
      free object range.
      free object borders.
      free object column.
      free object row.
      free object sheet.
    endform.
          FORM border                                                   *
    -->  we                                                            *
    form border using we.
    *left
      call method of CELL 'BORDERS' = BORDERS exporting #1 = '1'.
      set property of borders 'LineStyle' = '1'.
      set property of borders 'WEIGHT' = we.                    "4=max
      free object borders.
    right
      call method of CELL 'BORDERS' = BORDERS exporting #1 = '2'.
      set property of borders 'LineStyle' = '2'.
      set property of borders 'WEIGHT' = we.
      free object borders.
    top
      call method of CELL 'BORDERS' = BORDERS exporting #1 = '3'.
      set property of borders 'LineStyle' = '3'.
      set property of borders 'WEIGHT' = we.
      free object borders.
    bottom
      call method of CELL 'BORDERS' = BORDERS exporting #1 = '4'.
      set property of borders 'LineStyle' = '4'.
      set property of borders 'WEIGHT' = we.
       set property of borders 'ColorIndex' = 'xlAutomatic'.
      free object borders.
    endform.
          FORM border2                                                  *
    -->  we                                                            *
    form border2 using we.
    *left
      call method of CELL 'BORDERS' = BORDERS exporting #1 = '1'.
      set property of borders 'LineStyle' = '5'.
      set property of borders 'WEIGHT' = we.                    "4=max
      free object borders.
    right
      call method of CELL 'BORDERS' = BORDERS exporting #1 = '2'.
      set property of borders 'LineStyle' = '6'.
      set property of borders 'WEIGHT' = we.
      free object borders.
    top
      call method of CELL 'BORDERS' = BORDERS exporting #1 = '3'.
      set property of borders 'LineStyle' = '7'.
      set property of borders 'WEIGHT' = we.
      free object borders.
    bottom
      call method of CELL 'BORDERS' = BORDERS exporting #1 = '4'.
      set property of borders 'LineStyle' = '8'.
      set property of borders 'WEIGHT' = we.
       set property of borders 'ColorIndex' = 'xlAutomatic'.
      free object borders.
    endform.
          FORM border3                                                  *
    -->  we                                                            *
    form border3 using we.
    *left
      call method of CELL 'BORDERS' = BORDERS exporting #1 = '1'.
      set property of borders 'LineStyle' = '9'.
      set property of borders 'WEIGHT' = we.                    "4=max
      free object borders.
    right
      call method of CELL 'BORDERS' = BORDERS exporting #1 = '2'.
      set property of borders 'LineStyle' = '10'.
      set property of borders 'WEIGHT' = we.
      free object borders.
    top
      call method of CELL 'BORDERS' = BORDERS exporting #1 = '3'.
      set property of borders 'LineStyle' = '11'.
      set property of borders 'WEIGHT' = we.
      free object borders.
    bottom
      call method of CELL 'BORDERS' = BORDERS exporting #1 = '4'.
      set property of borders 'LineStyle' = '12'.
      set property of borders 'WEIGHT' = we.
       set property of borders 'ColorIndex' = 'xlAutomatic'.
      free object borders.
    endform.
          FORM fill_cell                                                *
    -->  color                                                         *
    -->  pattern                                                       *
    form fill_cell using color pattern.
      call method of cell 'INTERIOR' = int.
      set property of int 'ColorIndex' = color.
      set property of int 'Pattern' = pattern.
      free object int.
    endform.
          FORM font                                                     *
    -->  bold                                                          *
    -->  size                                                          *
    form font using bold size.
      call method  of CELL 'FONT' = font.
      set property of font 'BOLD' = bold.
      set property of font 'SIZE' = size.
      free object font.
    endform.
          FORM fill_sheet                                               *
    form fill_sheet.
      CALL METHOD  OF EXCEL   'RANGE' = CELL EXPORTING #1 = 'A1'.
      perform font          using 1 '14'.
      SET PROPERTY OF CELL    'VALUE' = 'Counter'.
      perform fill_cell     using '15' '1'.
      perform border        using '2'.
      free object cell.
      val = 'Workbook-Count'.
      move wb to val+16.
      CALL METHOD  OF EXCEL   'RANGE' = CELL EXPORTING #1 = 'B1'.
      SET PROPERTY OF CELL    'VALUE' = val.
      perform fill_cell using '14' '1'.
      perform border using '4'.
      free object cell.
      val = 'Sheet-Count'.
      unpack sy-index to val+12.
      CALL METHOD  OF EXCEL   'RANGE' = CELL EXPORTING #1 = 'C1'.
      SET PROPERTY OF CELL    'VALUE' = val.
      perform fill_cell using '12' '1'.
      perform border using '4'.
      free object cell.
      CALL METHOD  OF EXCEL   'RANGE' = CELL EXPORTING #1 = 'E3'.
      perform border        using '1'.
      free object cell.
      CALL METHOD  OF EXCEL   'RANGE' = CELL EXPORTING #1 = 'E5'.
      perform border        using '2'.
      free object cell.
      CALL METHOD  OF EXCEL   'RANGE' = CELL EXPORTING #1 = 'E7'.
      perform border        using '3'.
      free object cell.
      CALL METHOD  OF EXCEL   'RANGE' = CELL EXPORTING #1 = 'E9'.
      perform border        using '4'.
      free object cell.
      CALL METHOD  OF EXCEL   'RANGE' = CELL EXPORTING #1 = 'F3'.
      perform border2       using '1'.
      free object cell.
      CALL METHOD  OF EXCEL   'RANGE' = CELL EXPORTING #1 = 'F5'.
      perform border2       using '2'.
      free object cell.
      CALL METHOD  OF EXCEL   'RANGE' = CELL EXPORTING #1 = 'F7'.
      perform border2       using '3'.
      free object cell.
      CALL METHOD  OF EXCEL   'RANGE' = CELL EXPORTING #1 = 'F9'.
      perform border2       using '4'.
      free object cell.
      CALL METHOD  OF EXCEL   'RANGE' = CELL EXPORTING #1 = 'G3'.
      perform border3       using '1'.
      free object cell.
      CALL METHOD  OF EXCEL   'RANGE' = CELL EXPORTING #1 = 'G5'.
      perform border3       using '2'.
      free object cell.
      CALL METHOD  OF EXCEL   'RANGE' = CELL EXPORTING #1 = 'G7'.
      perform border3       using '3'.
      free object cell.
      CALL METHOD  OF EXCEL   'RANGE' = CELL EXPORTING #1 = 'G9'.
      perform border3       using '4'.
      free object cell.
      val = 'ROW-Count'.
      do 19 times.
        c_row = sy-index + 1.
        unpack c_row to val+12(4).
        CALL METHOD  OF excel 'CELLS' = CELL1 EXPORTING #1 = c_row #2 = 2.
        SET PROPERTY OF CELL1    'VALUE' = val.
        free object cell1.
        CALL METHOD  OF excel 'CELLS' = CELL1 EXPORTING #1 = c_row #2 = 4.
        SET PROPERTY OF CELL1    'VALUE' = val.
        free object cell1.
      enddo.
    endform.
    You find SAP OLE programs under development Class 'SOLE'             *
    MSTAPPL  Table Maintenance APPL                                     *
    RSOLEDOC Document list                                              *
    RSOLEIN0 OLE Load Type Information                                  *
    RSOLEINT Type Info Loaded                                           *
    RSOLETI0 OLE Object Browser                                         *
    RSOLETI1 OLE Object Browser                                         *
    RSOLETI2 OLE Object Browser                                         *
    RSOLETI3 F4 Help For OLE Objects                                    *
    RSOLETT1 OLE 2.0 Automation Demo Program                            *
    Transactions:                                                        *
    SOLE                                                                 *
    SOLO  - List of OLE applcations with loaded type info                *
    You will find the decription of possible objects and methods in the  *
    windows help file for excel.                                         *
    Hope this’ll give you idea!!
    <b>P.S award the points.!!! !!!</b>
    Good luck
    Thanks
    Saquib Khan
    "Some are wise and some are otherwise"

  • Heading for excel sheet

    Hi everyone,
                     I am downloading an internal table into an excel sheet using function module using GUI_DOWNLOAD . Now i need to have a heading line in the excel sheet. How should i do this? I kindly request you to help me in this issue. Thanks in advance.

    hiii
    yes you right..that is the only problem you are having..without using FIELDNAMES you can get header like following program..just check follwoing program it will solve your problem...as that parameter is not used in FM gui_download
    TABLES:
      mara.
    *                        T Y P E S                                     *
    TYPES:
      BEGIN OF type_a090,
        kschl TYPE a090-kschl,             " Condition type
        vbeln TYPE a090-vbeln,             " Sales document number
        posnr TYPE a090-posnr,             " Item number
        matnr TYPE a090-matnr,             " Material number
        datbi TYPE a090-datbi,             " Valid from
        datab TYPE a090-datab,             " Valid to
      END OF type_a090.
    TYPES:
      BEGIN OF type_mara,
        matkl TYPE mara-matkl,             " Material group
        matnr TYPE mara-matnr,             " Material number
      END OF type_mara.
    TYPES:
      BEGIN OF type_makt,
        maktx TYPE makt-maktx,             " Material description
        matnr TYPE makt-matnr,             " Material number
      END OF type_makt.
    TYPES:
      BEGIN OF type_output,
        kschl TYPE a090-kschl,             " Condition type
        vbeln TYPE a090-vbeln,             " Sales document number
        posnr TYPE a090-posnr,             " Item number
        matnr TYPE a090-matnr,             " Material number
        datbi(10) TYPE c,                  " Valid from
        datab(10) TYPE c,                  " Valid to
        matkl TYPE mara-matkl,             " Material group
        maktx TYPE makt-maktx,             " Material description
      END OF type_output.
    TYPES:
      BEGIN OF type_final,
        string TYPE string,
      END OF type_final.
    *                            D A T A                                   *
    DATA:wa_a090 TYPE type_a090,
         i_a090  TYPE STANDARD TABLE OF type_a090,
         wa_mara TYPE type_mara,
         i_mara  TYPE STANDARD TABLE OF type_mara,
         wa_makt TYPE type_makt,
         i_makt  TYPE STANDARD TABLE OF type_makt,
         wa_output TYPE type_output,
         i_output  TYPE TABLE OF type_output,
         wa_final TYPE type_final,
         i_final  TYPE STANDARD TABLE OF type_final.            "#EC NEEDED
    *                 S E L E C T I O N     S C R E E N                    *
    SELECTION-SCREEN BEGIN OF BLOCK sel1 WITH FRAME TITLE text-se1.
    SELECT-OPTIONS:
      s_matnr          FOR mara-matnr,     " Material Number
      s_mtart          FOR mara-mtart.     " Material Type
    PARAMETERS p_kschl TYPE konp-kschl  DEFAULT text-000.
    " Condition Type
    SELECTION-SCREEN END   OF BLOCK sel1.
    SELECTION-SCREEN BEGIN OF BLOCK sel2 WITH FRAME TITLE text-se2.
    SELECTION-SCREEN BEGIN OF BLOCK sel3 WITH FRAME TITLE text-se3.
    PARAMETERS:
      p_app_a          RADIOBUTTON GROUP file,
      p_filea          type rlgrap-filename,
                                           " Local file for upload/download
      p_app_p          RADIOBUTTON GROUP file,
      p_filep          type rlgrap-filename.
    " Local file for upload/download
    SELECTION-SCREEN END   OF BLOCK sel3.
    SELECTION-SCREEN BEGIN OF BLOCK sel4 WITH FRAME TITLE text-se4.
    PARAMETERS:
      p_price          type rlgrap-filename OBLIGATORY
        DEFAULT text-001.
    SELECTION-SCREEN END   OF BLOCK sel4.
    SELECTION-SCREEN END   OF BLOCK sel2.
    * Selection screen processing
    AT SELECTION-SCREEN ON p_filea.
      IF NOT p_app_a IS INITIAL.
        IF p_filea IS INITIAL.
          MESSAGE e398
            WITH text-002 '' '' ''.
        ENDIF.                             " IF p_filea IS INITIAL
      ENDIF.                               " IF NOT p_app_a IS INITIAL
    AT SELECTION-SCREEN ON p_filep.
      IF NOT p_app_p IS INITIAL.
        IF p_filep IS INITIAL.
          MESSAGE e398
            WITH text-003 '' '' ''.
        ENDIF.                             " IF p_filep IS INITIAL
      ENDIF.                               " IF NOT p_app_p
    START-OF-SELECTION.
      PERFORM get_data.
      PERFORM output_data.
      PERFORM header.
    *&      Form  get_data                                                 *
    * Fetching data from the tables.
    *  There are no interface parameters to be passed.                     *
    FORM get_data .
      SELECT   kschl                       " Condition type
               vbeln                       " Sales document number
               posnr                       " Item number
               matnr                       " Material number
               datbi                       " Valid from
               datab                       " Valid to
               FROM a090
               INTO TABLE i_a090
               WHERE matnr IN  s_matnr AND
               kschl EQ p_kschl
               AND datab LE syst-datum
               AND datbi GE syst-datum.
      IF sy-subrc EQ 0.
        SELECT matkl                         " Material group
               matnr                         " Material number
               FROM mara
               INTO TABLE i_mara
               FOR ALL ENTRIES IN i_a090
               WHERE matnr = i_a090-matnr.
      ENDIF.
      IF sy-subrc EQ 0.
        SELECT maktx                         " Material description
               matnr                         " Material number
               FROM makt
               INTO TABLE i_makt
               FOR ALL ENTRIES IN i_mara
               WHERE matnr = i_mara-matnr
               AND spras = 'EN'.
      ENDIF.
    ENDFORM.                               " get_data
    *&      Form  output_data                                              *
    *  Populating the final output table.
    * There are no interface parameters to be passed.                      *
    FORM output_data .
      DATA:
        w_date2(10) TYPE c,                " For date formate
        w_date1(10) TYPE c.                " For date formate
      LOOP AT i_a090 INTO wa_a090.
        CONCATENATE wa_a090-datbi+6(2) wa_a090-datbi+4(2) wa_a090-datbi+0(4)
        INTO w_date1 SEPARATED BY '/'.
        CONCATENATE wa_a090-datab+6(2) wa_a090-datab+4(2) wa_a090-datab+0(4)
        INTO w_date2 SEPARATED BY '/'.
        wa_output-kschl = wa_a090-kschl.
        wa_output-vbeln = wa_a090-vbeln.
        wa_output-posnr = wa_a090-posnr.
        wa_output-matnr = wa_a090-matnr.
        wa_output-datbi = w_date1.
        wa_output-datab = w_date2.
        READ TABLE i_mara INTO wa_mara WITH KEY matnr = wa_a090-matnr.
        IF sy-subrc EQ 0.
          wa_output-matkl = wa_mara-matkl.
        ENDIF.
        READ TABLE i_makt INTO wa_makt WITH KEY matnr = wa_a090-matnr.
        IF sy-subrc EQ 0.
          wa_output-maktx = wa_makt-maktx.
        ENDIF.
        APPEND wa_output TO i_output.
        CLEAR wa_output.
      ENDLOOP.                             " LOOP AT i_a090
      DELETE ADJACENT DUPLICATES FROM i_output COMPARING ALL FIELDS.
      LOOP AT i_output INTO wa_output.
        CONCATENATE wa_output-kschl
                    wa_output-vbeln
                    wa_output-posnr
                    wa_output-matnr
                    wa_output-datbi
                    wa_output-datab
                    wa_output-matkl
                    wa_output-maktx
               INTO wa_final-string
               SEPARATED BY ','.
        APPEND wa_final TO i_final.
      ENDLOOP.                             " LOOP AT i_output...
    ENDFORM.                               " output_data
    *&      Form  header                                                   *
    *  Formating the header.                                               *
    *  There are no interface parameters to be passed.                     *
    FORM header .
      CONCATENATE text-004
                  text-005
                  text-006
                  text-007
                  text-008
                  text-009
                  text-010
                  text-011
             INTO wa_final-string
             SEPARATED BY ','.
      INSERT wa_final
      INTO i_final INDEX 1.
      PERFORM f901_output.
    ENDFORM.                               " header
    *&      Form  f901_output                                              *
    *  Downloading the final output table to the presentation server or    *
    *  application server.                                                 *
    *      -->P_I_OUTPUT  text                                             *
    *      -->P_P_PRICE  text                                              *
    FORM f901_output .
      IF p_app_p = 'X'.
        PERFORM f903_file_to_presentation
          USING p_price.
      ELSE.
        PERFORM f904_file_to_application
          USING p_price.
      ENDIF.                               " IF p_app_p
    ENDFORM.                               " f901_output
    *&      Form  f903_file_to_presentation                                *
    *  Dowload the file to the presentation server.                        *
    *      -->P_P_PRICE  text                                              *
    FORM f903_file_to_presentation  USING    p_p_price.
      DATA:
        lwa_file            TYPE string.  "#EC NEEDED     "rlgrap-filename.
      CONCATENATE p_filep p_p_price INTO lwa_file.
    *      Download the file
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
    *   BIN_FILESIZE                    = BIN_FILESIZE
          filename                        = lwa_file
          filetype                        = 'ASC'
    *   APPEND                          = ' '
    *   WRITE_FIELD_SEPARATOR           = ' '
    *   HEADER                          = '00'
    *   TRUNC_TRAILING_BLANKS           = ' '
    *   WRITE_LF                        = 'X'
    *   COL_SELECT                      = ' '
    *   COL_SELECT_MASK                 = ' '
    *   DAT_MODE                        = ' '
    *   CONFIRM_OVERWRITE               = ' '
    *   NO_AUTH_CHECK                   = ' '
    *   CODEPAGE                        = ' '
    *   IGNORE_CERR                     = ABAP_TRUE
    *   REPLACEMENT                     = '#'
    *   WRITE_BOM                       = ' '
    *   TRUNC_TRAILING_BLANKS_EOL       = 'X'
    *   WK1_N_FORMAT                    = ' '
    *   WK1_N_SIZE                      = ' '
    *   WK1_T_FORMAT                    = ' '
    *   WK1_T_SIZE                      = ' '
    * IMPORTING
    *   FILELENGTH                      = FILELENGTH
        TABLES
          data_tab                        = i_final
    *   FIELDNAMES                      = FIELDNAMES
        EXCEPTIONS
          file_write_error                = 1
          no_batch                        = 2
          gui_refuse_filetransfer         = 3
          invalid_type                    = 4
          no_authority                    = 5
          unknown_error                   = 6
          header_not_allowed              = 7
          separator_not_allowed           = 8
          filesize_not_allowed            = 9
          header_too_long                 = 10
          dp_error_create                 = 11
          dp_error_send                   = 12
          dp_error_write                  = 13
          unknown_dp_error                = 14
          access_denied                   = 15
          dp_out_of_memory                = 16
          disk_full                       = 17
          dp_timeout                      = 18
          file_not_found                  = 19
          dataprovider_exception          = 20
          control_flush_error             = 21
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                               " f903_file_to_presentation
    regards
    twinkal

  • Data Writing Speed for Excel Sheet while taking data from PCI DAQ card

    Dear All,
              I am taking the data form the card EX-92026 pci card and writing those datas into the Excel sheet, now i want the data at the speed of max of 10 miliseconds but while writing the data into excel sheet, it shows the diff of 15 ms betn 2 readings, and the card specs says it takes the time of 500 microsecs to give the data, so is there any effect of timing, while writing data into excel sheet? is labview take more time, i am using the Open file, write file and close file method and write to spreadsheet file method, but none of them is giving me the effective timing that i wamt, so can u tell me how can i reduce it??????
    Thanks,
    Nishant

    Hi Nishant:
    I think I don't understand you very well. If you are using OpenFile, CloseFile and WriteToSpreadsheet VIs, you are not dealing with excel files, but text files.
    Writing to file is costly in time. You can:
    Open the file just once and
    during de process use just file writing VIs as 'write to spreadsheet'... or a more simple one 'write file'
    Close the file once at the end.
    If you need the process to be faster, you can save all the data at 10ms rate in an array and write to file at the end.
    Or write to file every second what you got the last second.
    Hope it helps
    Aitortxo.
    Aitortxo.

  • VBA Code for Excel Add-in Menu Items

    Howdy.
    Every month my team needs to execute the same process on a couple hundred documents. It's time consuming and inefficient to say the least, so I'm looking for a means by which to call a couple of the menu items on the Excel BPC Add-Ins menu via VBA. Specifically, Park'n'Go; Expand All; and Send and Refresh Schedules.
    Basically what happens is this:
    Open File
    Set Park'n'Go to Live
    Expand All
    Refresh and Send Schedules
    Set Park'n'Go to Offline
    Save
    Exit
    Loop
    I know how to loop through the files and directories, I just don't know the commands for the functions from the menu via code. The macro recorder can't help me, and I've even tried to mimic a user's actions by using mouse coordinates and clicks, but that doesn't work b/c it doesn't allow for the necessary load time from BPC.
    Any help would be extremely appreciated.

    Hey Jeff,
    here are some vba commands that may help you.
    Open a certain file: (you can assign "Path" to a button or range)
    Dim Path As String
    Path = Application.GetOpenFilename("All Files (.),.")
    Opening the Park 'n Go dialog box:
    Application.Run ("MNU_ETOOLS_PARKNGO")
    Expand All:
    Application.Run ("MNU_ETOOLS_EXPAND")
    Sending data and refreshing the workbook:
    Application.Run ("MNU_eSUBMIT_REFSCHEDULE_BOOK_REFRESH")
    Saving a file OFFLINE:
    Dim FName As String
    FName = InputBox(prompt:="Please enter filename")
    If FName = "" Then
    Application.DisplayAlerts = False
    ActiveWorkbook.Close
    Else
    ActiveWorkbook.SaveAs Filename:="c:\" & FName
    ActiveWorkbook.Close
    End If
    Application.DisplayAlerts = True
    Hope, that will help you
    Karsten

  • Integer codes for Excel FitToPagesWide ActiveX Needed

    Hello,
    I am currently using LV6.0.2 and have been doing some Excel controlling in my program. I don't have the tookit so I am been doing most the Excel stuff using direct ActiveX commands.
    I have gotten everything working but I am having trouble getting the FitToPagesWide to work before printing. I am not sure if there is an interger code, but if I use a I32 witha value of 1 it does not work.
    This is also with Excel 97.
    Jeff D.
    OS: Win 7 Ultimate
    LabVIEW Version: 2011,2010,2009 installed
    Certified LabVIEW Architect

    I have Excel 2003, but 1 is the correct setting. Try to also set the Zoom to False. Here is a snippet from the help:
    If the Zoom property is True, the FitToPagesWide property is ignored.
    Example
    This example causes Microsoft Excel to print Sheet1 exactly one page wide and tall.
    With Worksheets("Sheet1").PageSetup
    .Zoom = False
    .FitToPagesTall = 1
    .FitToPagesWide = 1
    End With
    Michael Munroe
    www.abcdef.biz
    Michael Munroe, ABCDEF
    Certified LabVIEW Developer, MCP
    Find and fix bad VI Properties with Property Inspector

  • Data in excel sheet to be used for programing

    Hi,
    I have to make a z report for which the data i have to use is in a excel sheet.
    How can I use this data for making different reports.
    Reg,
    Archana

    Hi,
    Try the following code for multiple sheets.
    data : $i_intern type  kcde_cells occurs 0 with header line.
    data : $v_index type i.
    data : $v_start_col type i value '1',
           $v_start_row type i value '1',
           $v_end_col   type i value '256',
           $v_end_row   type i value '7500'.
      data: excel_tab type kcde_sender.
      data: separator type c.
      field-symbols: <field>.
      data: application type ole2_object,
            workbook    type ole2_object,
            range       type ole2_object,
            worksheet   type ole2_object,
            worksheets  type ole2_object,
            sheets      type ole2_object.
      data: h_cell  type ole2_object.
      data: h_cell1 type ole2_object.
      data: l_sheet           type c length 40.
      data: l_active_sheet    type i.
      define m_message.
        case sy-subrc.
          when 0.
          when 1.
            message id sy-msgid type sy-msgty number sy-msgno
                    with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
          when others. raise upload_ole.
        endcase.
      end-of-definition.
    Create Excel OLE2 object and open XLS file
      if application-header = space or application-handle = -1.
        create object application 'Excel.Application'.
        m_message.
      endif.
      call method of application 'Workbooks' = workbook.
      m_message.
      call method of workbook 'Open' exporting #1 = pa_file.
      m_message.
    Show/don't show XLS
    set property of application 'Visible' = 1.
    m_message.
    Determine number of sheets
      call method of application 'Sheets' = sheets.
      m_message.
      call method of sheets 'Count' = sheetno.
      m_message.
      l_active_sheet = 0.
      do sheetno times.
        clear: $i_intern[], excel_tab[].
        clear: it_vals[], it_chars[].
        l_active_sheet = l_active_sheet + 1.
      Activate sheet number L_ACTIVE_SHEET
        call method of application 'Worksheets' = worksheets exporting #1 = l_active_sheet.
        m_message.
        call method of worksheets 'Activate'.
        m_message.
      Get active sheet
        get property of  application 'ACTIVESHEET' = worksheet.
        m_message.
      Find start
        call method of worksheet 'Cells' = h_cell
          exporting #1 = $v_start_row #2 = $v_start_col.
        m_message.
      Find end
        call method of worksheet 'Cells' = h_cell1
          exporting #1 = $v_end_row #2 = $v_end_col.
        m_message.
      Create range
        call method of worksheet 'RANGE' = range
          exporting #1 = h_cell #2 = h_cell1.
        m_message.
      Select range
        call method of range 'SELECT'.
        m_message.
      copy to Clipboard
        call method of range 'COPY'.
        m_message.
        call function 'CONTROL_FLUSH'
          exceptions
            others = 3.
      Import clipboard
        call function 'CLPB_IMPORT'
          tables
            data_tab   = excel_tab
          exceptions
            clpb_error = 1
            others     = 2.
        if sy-subrc <> 0. message x001(kx). endif.
        separator = cl_abap_char_utilities=>horizontal_tab.
        perform separated_to_intern_convert(saplkcde) tables excel_tab $i_intern
                                            using  separator.
        set property of application 'CutCopyMode' = 0.
        m_message.
      enddo.
      call method of application 'QUIT'.
      m_message.
      free object : application,
                    workbook,
                    worksheet,
                    sheets,
                    range.
      m_message.
    Hope it works.
    Please reward accordingly.
    Thanks,
    Priyanka

  • Need to protect Excel sheet

    Hi All,
    I am using Labview 7.0 and have successfully transported my data in to excel file. Further my requirement is to protect the excel sheet cell. I found many examples and codes for protecting sheet but my question is Can i make the excel sheet's cell write protected?? If yes than how ??
     Also i came to know through those examples that using invoke node for Activex controls and selecting class as Excel._ worksheet, where i can set the method as Protect. To this invoke node i need to connect reference but don't know how to create reference for the new excel report??
    If any one has idea abt that, then please.... guid me through vi's or snapshots.
    Thanks & Regards,
    Ratna

    Hi vt92,
    Thanks for ur reply, i woluld suggest u to have a look at excel report.png image as this may clear my requirement. In that vi i have transffered my data into excel sheet (area marked with red colour box) after that i m bringing that worksheet to front n then saving the report. Now my requirement is to make that worksheet password protected before saving it.
    Actually, I have gone through my discussion forums n found that to make worksheet password protected, need to use invoke node with class as Activex Excel._Worksheet n in that select method as protect but my confusion is wat input shuld i gave to that invoke node??? 
    Regards,
    Ratna
    Attachments:
    excel report.PNG ‏70 KB

  • Urgent:download data in differnt tabs of excel sheet

    Hi,
    I want to save data from internal table to different worksheet of an excel sheet file without using ole. I am having thousands of record in my internal table. Currently I am doing this by using OLE but its response time is very high. Plz suggest any other method with which we can do it fast.
    rely will be suitably rewarded
    Edited by: amit manglik on Jan 28, 2008 10:23 AM
    Edited by: amit manglik on Jan 29, 2008 10:18 AM

    hi,
    Refer sample code:
    Multiple excel sheets generation in a workbook
    CREATE OBJECT EXCEL 'EXCEL.SHEET'.
    GET PROPERTY OF EXCEL 'Application' = APPLICATION.
    SET PROPERTY OF APPLICATION 'Visible' = 1.
    CALL METHOD OF APPLICATION 'Workbooks' = BOOKS.
    CALL METHOD OF BOOKS 'Add' = BOOK.
    CALL METHOD OF BOOK 'WORKSHEETS' = SHEET.
    CALL METHOD OF SHEET 'ADD'.
    Fill all the sheets with relavant data
    PERFORM SHEET1 TABLES ITAB1.
    PERFORM SHEET2 TABLES ITAB2.
    PERFORM SHEET3 TABLES ITAB3.
    PERFORM SHEET4 TABLES ITAB4.
    Quit the excel after use
    CALL METHOD OF EXCEL 'QUIT'.
    FREE OBJECT: COLUMN,SHEET,BOOK,BOOKS,APPLICATION,EXCEL. "NO FLUSH.
    CLEAR V_SHEET.
    FORM FILL_CELL USING ROW COL VAL.
    CALL METHOD OF SHEET 'cells' = CELL NO FLUSH
    EXPORTING #1 = ROW #2 = COL.
    SET PROPERTY OF CELL 'value' = VAL.
    FREE OBJECT CELL NO FLUSH.
    ENDFORM. " FILL_CELL
    FORM SHEET1 TABLES ITAB1 STRUCTURE ITAB1.
    V_SHEET = Sheet Name.
    V_NO = V_NO + 1.
    CALL METHOD OF BOOK 'worksheets' = SHEET NO FLUSH EXPORTING #1 = V_NO.
    SET PROPERTY OF SHEET 'Name' = V_SHEET NO FLUSH.
    PERFORM FILL_SHEET1 TABLES ITAB1 USING V_NO V_SHEET.
    CALL METHOD OF SHEET 'Columns' = COLUMN.
    FREE OBJECT SHEET.
    CALL METHOD OF COLUMN 'Autofit'.
    FREE OBJECT COLUMN.
    ENDFORM.
    Repeat above procedure for all sheets you want to add
    FORM FILL_SHEET1
    TABLES ITAB1 STRUCTURE ITAB1
    USING V_NO V_SHEET.
    ROW = 1.
    PERFORM FILL_CELL USING ROW 1 'Column1 Name'.
    PERFORM FILL_CELL USING ROW 2 'Column2 Name'.
    PERFORM FILL_CELL USING ROW 3 'Column3 Name'.
    ROW = ROW + 1.
    LOOP AT ITAB1.
    PERFORM FILL_CELL USING ROW 1 ITAB1-Column1.
    PERFORM FILL_CELL USING ROW 2 ITAB1-Column2.
    PERFORM FILL_CELL USING ROW 3 ITAB1-Column3.
    ROW = ROW + 1.
    ENDLOOP.
    ENDFORM.
    Repeat above procedure for all sheets you want to add
    Also follow this link, for a simillar kind of download program.
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/c05db2ca-569e-2910-0784-fc06cc3be31d
    Hope this helps, Do reward.

  • SSRS/Powerview to compare SQL table and excel sheet

    I have a SQL table and an excel sheet with some data...
    I want to be able to compare the two and find out which Excel rows are missing in the SQL table...
    Would it be easier to do this report in SSRS or would it be better to do it in Excel PowerView?
    If so how do I go about it?
    Thanks in advance for your help...
    Dhananjay Rele

    Hi Dhananjay,
    According to your description, you want to compare the data of a SQL table and an excel sheet. To achieve this goal, we can create two tables in Reporting Services report, one for SQL table with SQL Server connection type, another for excel sheet with ODBC
    connection type.
    For more details about how to create the report, please see the following steps:
    Create a report server project with SQL Server Data Tools (SSDT) Business Intelligence Templates list.
    Create a new report definition file in Solution Explorer.
    Create a Data Source named DataSource1 with Microsoft SQL Server Type, then select the SQL table database from the corresponding server.
    Create a Data Source named DataSource2 with ODBC Type, then select the excel file.
    Create two datasets which returns the SQL data and Excel sheet data based on the two data source, one for DataSource1, another for DataSource2.
    Create two table next to each other based on the datasets on the design surface.
    References:
    Create a Basic Table Report (SSRS Tutorial)
    Create SSRS report using Excel Data Source Step by Step
    If there are any other questions, please feel free to ask.
    Regards,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • A temporary solution for issue of excel sheet for SO_NEW_DOCUMENT_ATT_SEND_

    Hi,
    we all sometime or the other have faced the problem with SO_NEW_DOCUMENT_ATT_SEND_API1, it passes all the data into a single excel sheet. the following is the code i have written using the same standard FM to resolve the issue.
    Problem's Facing     : To send the output of a report as mail attachment (Excel sheet) from SAP, to the User's outlook or TCP/IP
    What is happening     : All the data which is being passed to the excel is being put in a single cell of the excel sheet.
    Cause               : the difficulty lies in getting the internal table from SAP report, passing it to email Function Module If the structure of the internal Table is unknown .
    Solution:
    if the user while sending data to the Function module ( created using the following code) puts a '#' between field values, all the fields gets separated into individual cells and the data gets printed as required.
    <b>advantages</b> of the following code are:
    1) User just need to type userid or multiple userid's separated by comma.
    2) Performs multiple tasks with one function module.
    3) It can be used to send file with subject only
    4) It can be used to send file with subject and body
    5) It can be used to send file with subject, body, and attachment
    6) Attachment can be of 'TXT' format or 'XLS' format depending upon the choice of the user.
    7) User specific parameters for EMAILID, subject, body and attachment type avoiding the dump error of  "Type conflict"
    8) If the user requires to send output of a report as an excel file, then a single internal table will store the total output separating the field values by ' # ' and the data gets printed evenly. the ' # '  symbol is used as Tab delimiter.
    FUNCTION zemail_attachment.
    ""Local Interface:
    *"  IMPORTING
    *"     REFERENCE(EMAILID)
    *"     REFERENCE(SUBJECT)
    *"     REFERENCE(ATYPE)
    *"  TABLES
    *"      ATTACH_FILE STRUCTURE  SOLISTI1
    *"      BODY OPTIONAL
    *"  EXCEPTIONS
    *"      INCORRECT_PARAMETERS
    This table requires information about how the data in the
    tables OBJECT_HEADER, CONTENTS_BIN and CONTENTS_TXT are
    to be distributed to the documents and its attachments.
      DATA it_objpack LIKE sopcklsti1 OCCURS  2 WITH HEADER LINE.
    This table must contain the summarized data dependent on each object type.
    SAPscript objects store information here about forms and styles,
    for example. Excel list viewer objects store the number of rows and columns
    amongst other things and PC objects store their original file name.
      DATA it_objhead LIKE solisti1   OCCURS  1 WITH HEADER LINE.
    This table must contain the summarized content of the objects identified as binary objects.
      DATA   it_objbin TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
                     WITH HEADER LINE.
    This table must contain the summarized content of the objects identified as ASCII objects.
      DATA it_objtxt  LIKE solisti1   OCCURS 10 WITH HEADER LINE.
    This table must contain the document recipients.
      DATA  it_reclist LIKE somlreci1 OCCURS 5 WITH HEADER LINE .
    This structure must contain the attributes of the document to be sent.
      DATA: doc_ching LIKE sodocchgi1.
      DATA: tab_lines LIKE sy-tabix.
    Create the internal table for body , subject
      DATA: it_body LIKE solisti1 OCCURS 10 WITH HEADER LINE.
    *creation of internal table for Email-id.
      DATA: BEGIN OF it_mailid OCCURS 0,
            email LIKE kna1-name1 ,
            END OF it_mailid.
    *VARIABLES
      DATA : v_hash(1) TYPE c VALUE '#'.
      DATA: v_string1 LIKE kna1-name1,
            v_string2 LIKE kna1-name1,
            v_string3(12) TYPE c VALUE '@GMAIL.COM'.
    *CONSATNTS
      CONSTANTS: c_con_cret TYPE c VALUE cl_abap_char_utilities=>horizontal_tab,
                 c_con_tab  TYPE c VALUE cl_abap_char_utilities=>cr_lf,
                 c_raw(3)   TYPE c VALUE 'RAW',
                 c_comma(1) TYPE c VALUE ',',
                 c_rec_type(1) TYPE c VALUE 'U',
                 c_space(1)    TYPE c VALUE ''.
    Move Body to Internal Table (body into it_body)
      LOOP AT body .
        MOVE body TO it_body .
        APPEND it_body .
      ENDLOOP.
      doc_ching-obj_descr = subject.   "Subject of the Email
    Move the Subject and Body to OBJTXT
      it_objtxt[] = it_body[].
      DESCRIBE TABLE it_objtxt LINES tab_lines.
      READ TABLE it_objtxt INDEX tab_lines.
      doc_ching-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( it_objtxt ).
      CLEAR it_objpack-transf_bin.
    it_objpack-head_start = 1.
    it_objpack-head_num   = 0.
    it_objpack-body_start = 1.
    it_objpack-body_num   = tab_lines.
    it_objpack-doc_type   = c_raw.
      APPEND it_objpack.
    Convert to Excel format
    IF NOT attach_file[] IS INITIAL.
      IF atype IS INITIAL.
    RAISE INCORRECT_PARAMETERS.
      ELSEIF atype = 'XLS' .
        LOOP AT attach_file .
          CONCATENATE attach_file v_hash INTO attach_file.
          REPLACE ALL OCCURRENCES OF v_hash IN attach_file WITH c_con_cret.
          IF sy-tabix = 1.
            MOVE attach_file TO it_objbin.
          ELSE.
            CONCATENATE c_con_tab attach_file INTO it_objbin.
          ENDIF.
          APPEND  it_objbin.
        ENDLOOP.
      ELSEIF atype = 'TXT' .
    Convert to Text format
        LOOP AT attach_file .
          REPLACE ALL OCCURRENCES OF v_hash IN attach_file WITH c_con_cret.
          CONCATENATE attach_file c_con_tab  INTO it_objbin .
          APPEND it_objbin .
        ENDLOOP.
      ENDIF.
      DESCRIBE TABLE it_objbin LINES tab_lines.
      it_objhead = subject. APPEND it_objhead.
    Creating the entry for the compressed attachment
      it_objpack-transf_bin = 'X'.
      it_objpack-head_start = 1.
      it_objpack-head_num   = 1.
      it_objpack-body_start = 1.
      it_objpack-body_num   = tab_lines.
    *check for XLS ,TXT files
      IF atype = 'XLS'.
        it_objpack-doc_type   = atype.
      ELSEIF atype = 'TXT'.
        it_objpack-doc_type   = c_raw.
      ENDIF.
      it_objpack-obj_name   = 'ATTACHMENT'.
      it_objpack-obj_descr = 'ATTACHMENT'. "Attachment File Name
      it_objpack-doc_size   = tab_lines * 255.
      APPEND it_objpack..
    ENDIF.
    Entering names in the distribution list
    Concatenating the email with '@GMAIL.COM if the user doesnot specify any mail extension
    recipent type as U - for internet usage
      SPLIT emailid AT c_comma INTO TABLE it_mailid.
      APPEND it_mailid.
      LOOP AT it_mailid.
        SHIFT it_mailid-email LEFT DELETING LEADING c_space.
        SPLIT it_mailid-email AT '@' INTO: v_string1 v_string2.
        IF v_string2 IS INITIAL AND NOT it_mailid-email IS INITIAL.
          CONCATENATE v_string1 v_string3 INTO it_reclist-receiver.
          it_reclist-rec_type = c_rec_type.
          APPEND it_reclist.
          CLEAR: v_string1,v_string2.
        ELSE.
          it_reclist-receiver = it_mailid-email.
          it_reclist-rec_type = c_rec_type.
          APPEND it_reclist.
        ENDIF.
      ENDLOOP.
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
        EXPORTING
          document_data              = doc_ching
          put_in_outbox              = 'X'
          commit_work                = 'X'
        TABLES
          packing_list               = it_objpack
          object_header              = it_objhead
          contents_bin               = it_objbin
          contents_txt               = it_objtxt
          receivers                  = it_reclist
        EXCEPTIONS
          too_many_receivers         = 1
          document_not_sent          = 2
          operation_no_authorization = 4
          OTHERS                     = 99.
    ENDFUNCTION.
    If anyone, has a better solution, please share
    Cheers
    Ajay

    issue resolved

  • BAPI for automatic Pr creation witth multiple files from excel sheet

    I have written a programm  for automatic PR creation  with the help of bapi , where its picks data from excel sheet and makes PR .It is picking excel files from one folder(Files) for PR creation and moving to another folder(Files sucess).
    now the problem is if Folder (Files) contains one excel sheet ,PR is created fine , but if the Folder(Files) have multiple excel sheet ,its is creating 1st PR right, but next PR's contains all the line item of 1st PR , 2nd PR and so on .can anyone suggest me where is the problem in codes.
    types : begin of x_file ,
            key1(10),
            pur_grp(4),
            maktx(40),
            plant(4) ,
            req(10),
            s_qty(13),
            wbs(24),
            gl(10),
            trackno(10),
            supl(4),
            deladd(255).
    types : end of x_file .
      data : str5 type char10.
      data : mm type char2.
      data : yyyy type char4.
      data : dd type char2.
      data : str9 type char10.
      data : str6 type char10.
      data : month type char2.
      data : year type char4.
      year = sy-datum+0(4).
      month = sy-datum+4(2).
      dd = sy-datum+6(2).
      yyyy = sy-datum+0(4).
      mm = sy-datum+4(2).
      dd = sy-datum+6(2).
      clear str6 .
      clear str5.
      concatenate  dd'.' month '.' year into str5 .
      concatenate  yyyy mm dd into str6 .
    DATA : file type rlgrap-filename .
    data : it_file type table of x_file .
    data : wa_file type x_file .
    data : it_header type table of x_file .
    data : wa_header type x_file .
    *&  Internal Table For Define Row and Coloum Postion
    data: col_start type i value 1 ,
          row_start type i value 2,
          col_end type i value 256 ,
          row_end type i value 65000 .
    *&  Internal Table For Retrieve  Data From Excel
    *data: excel_bdcdata like kcde_cells occurs 0 with header line.
    *data: excel_bdcdata1 like kcde_cells occurs 0 with header line.
    data: excel_bdcdata like ALSMEX_TABLINE occurs 0 with header line.
    data: excel_bdcdata1 like ALSMEX_TABLINE occurs 0 with header line.
    data: it_index type i.
    DATA : IT_INDEX1 TYPE I.
    *&  Define Field Symbol
    field-symbols: <fs> .
    data :   bdcdata like bdcdata    occurs 0 with header line.
    data :   messtab like bdcmsgcoll occurs 0 with header line.
    data : req_items type table of bapiebanc .
    data : wa_req_items type bapiebanc .
    data : req_acc_asg type table of bapiebkn.
    data : wa_req_acc_asg type bapiebkn.
    DATA : RETURN LIKE BAPIRETURN OCCURS 0 WITH HEADER LINE .
    *data : return type table of     bapireturn.
    *data : wa_return type bapireturn .
    data : number type ebeln .
    *****************************MOVE FILES******************************
    data : xsource type string .
    data : xdestin type string .
    data : destin1 type string .
    data : destin2 type string .
    DATA : DEST1 TYPE STRING.
    DATA : DEST11 TYPE STRING.
    DATA : DEST2 TYPE STRING.
    DATA : DEST22 TYPE STRING.
    data : sou_dir_name like SALFILE-LONGNAME.
    data : tar_dir_name like SALFILE-LONGNAME.
    data : tar_dir_name1 like SALFILE-LONGNAME.
    data : sou_filename like EDI_PATH-PTHNAM .
    data : tar_filename like EDI_PATH-PTHNAM .
    data : filename1  type string .
    data : tar_filename1 like EDI_PATH-PTHNAM .
    data : file_itab like SALFLDIR occurs 0 with header line.
    data : wa_file_itab like SALFLDIR.
    data : file_count type i .
    data : dir_count type i.
    data : dir_table like sdokpath occurs 0 with header line.
    data : file_table like SDOKPATH occurs 0 with header line.
    data : wa_file_table like sdokpath.
    data : strr type string ,
           str1 type string ,
           str2 type string ,
           str3 type string .
    DATA : PA_VAL TYPE CHAR1.
    sou_dir_name = 'D:\barcodes\files\'.
    tar_dir_name = 'D:\barcodes\files-success\'.
        "success folder.
    CALL FUNCTION 'TMP_GUI_DIRECTORY_LIST_FILES'
      EXPORTING
        DIRECTORY  = sou_dir_name
        FILTER     = '.'
      IMPORTING
        FILE_COUNT = file_count
        DIR_COUNT  = dir_count
      TABLES
        FILE_TABLE = file_table
        DIR_TABLE  = dir_table
      EXCEPTIONS
        CNTL_ERROR = 1
        OTHERS     = 2.
    IF SY-SUBRC <> 0.
    ENDIF.
    loop at file_table into wa_file_table.
    clear  :  strr , str1 , str2 , str3 .
      strr = wa_file_table-PATHNAME .
      concatenate sou_dir_name strr into str1 .
      concatenate tar_dir_name strr into str2 . " success
      concatenate tar_dir_name1 strr into str3 .         " failed
    FILE = STR1 .
    *start-of-selection.
    *&  Function For Retrieve Data From Excel
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      EXPORTING
        filename                      = FILE
        i_begin_col                   = col_start
        i_begin_row                   = row_start
        i_end_col                     = col_end
        i_end_row                     = row_end
      tables
        intern                        = excel_bdcdata
    EXCEPTIONS
       INCONSISTENT_PARAMETERS       = 1
       UPLOAD_OLE                    = 2
       OTHERS                        = 3.
      IF sy-subrc NE 0.
    WRITE : / 'File Error'.
    EXIT.
    ENDIF.
      loop at excel_bdcdata.
        translate excel_bdcdata to upper case .
        move excel_bdcdata-col to it_index.
        assign component it_index of  structure  wa_file to <fs> .
        move excel_bdcdata-value to <fs>.
        at end of row.
          append wa_file to it_file .
            clear wa_file.
        endat.
      endloop.
    sort it_file by key1. "pur_grp maktx plant  .
    it_header[] = it_file[].
    delete adjacent duplicates from it_header comparing key1 pur_grp maktx
    plant .
    data : h_item(5) type n .
    data : h_pack(10) type n .
    data : line_no(5) type n .
    data : ln_no(5) type n .
    loop at it_header into wa_header .
    ln_no = 1.
    h_item = h_item + 10.
    h_pack = h_pack + 1.
    wa_req_items-preq_item = h_item .
    wa_req_items-doc_type = 'BOM'.
    wa_req_items-pur_group = wa_header-pur_grp .
    wa_req_items-MATERIAL = wa_header-maktx .
    wa_req_items-plant = wa_header-plant .
    wa_req_items-pckg_no =  h_pack .
    wa_req_items-deliv_date = str6 .
    wa_req_items-item_cat = '0'.
    wa_req_items-acctasscat = 'P'.
    *wa_req_items-distrib = '2' .
    **wa_req_items-gr_ind = 'X'.
    wa_req_items-ir_ind = '2'.
    wa_req_items-purch_org = 'TISL' .
    wa_req_items-QUANTITY =  wa_header-s_qty.
    wa_req_items-PREQ_NAME =  wa_header-req.
    wa_req_items-SUPPL_PLNT = wa_header-supl.
    wa_req_items-trackingno = wa_header-trackno.
    append wa_req_items to req_items .
    clear wa_req_items.
    wa_req_acc_asg-preq_item = h_item .
    wa_req_acc_asg-g_l_acct = wa_file-gl .
    WA_req_acc_asg-wbs_elem  = wa_header-wbs .
    append wa_req_acc_asg to req_acc_asg .
    clear wa_req_acc_asg.
    h_pack = h_pack + 1  .
    endloop.
    clear ln_no .
    ***BREAK-POINT.
    *& BAPI FUNCTION
    call function 'BAPI_REQUISITION_CREATE'
    importing
       number                               = number
      tables
        requisition_items                   = req_items
       requisition_account_assignment       = req_acc_asg
       return                               = return .

    Can someone please give me sol........

  • Data transfer from sap r/3 into excel sheet for mi01

    hi gurus,
       as i  am a xi consultant i got requirement to write a program for data transfer from sap r/3 into excel sheet for MI01.can any body help me by giving sample code or example for this requirement.please help me.

    Hi Rohit,
    This is an upload program and it has used both function modules to upload from an excel to R3 and to download from R3 onto excel.
    GUI_UPLOAD
    GUI_DOWNLOAD
    are the function modules used.
    Hope this helps,
    *Output:        Downloads error records onto presentation server,
    *               Displays report with number of success and error records
    REPORT ZMCG047CONTR NO STANDARD PAGE HEADING
                                   LINE-SIZE 255
                                   MESSAGE-ID ZM.
    *&       Table declarations
    TABLES : T001W,     "Plants/Branches
             T024E,     "Purchasing Organizations
             T001.      "Company Codes
    *              TYPE-POOLS  DECLARATION
    TYPE-POOLS : SLIS.
    *                       Types  Declaration                            *
    TYPES: BEGIN OF T_RECORD,    "record storing contract info
            LIFNR(010),      "Vendor Number
            EVART(004),      "Agreement Type
            EKORG(004),      "Purchasing Organization
            EKGRP(003),      "Purchasing Group
            WERKS(004),      "Plant
            LGORT(004),      "Storage Location
            KDATB(010),      "Valid start Date
            KDATE(010),      "Valid End Date
            ZTERM(004),      "Payment Terms
            KTWRT(020),      "Target Value
            EPSTP(001),      "Item Category
            EMATN(018),      "Material Number
            KTMNG(017),      "Target Quantity
            NETPR(014),      "Net Price
            PEINH(006),      "Net Price Unit
            BPRME(003),      "Net Price Order Price Unit
            IDNLF(035),      "Vendor Material number
            WEBRE(001),      "GR Based-IV
            MEPRF(001),      "Pricing Date Category
            LTEX1(040),      "Info Text
            DATAB(010),      "Valid From
            DATBI(010),      "Valid To
            KSCHL(004),      "Condition Type
            KBETR(016),      "Condition Rate if scale is not given
            KONWA(005),      "Currency
            KPEIN(005),      "Condition Pricing Unit
            KMEIN(003),      "Condition Unit of Measure
            KSTBM(019),      "Scale
            KBETR_01(016),   "Scale Rate
            DEL_FLAG,        "Delete Flag Indicator
            ERR_MSG(100),    "Error Message
          END OF T_RECORD,
          BEGIN OF T_ERR_RECORD,   "to have error records stored
             LIFNR(010),      "Vendor Number
             EVART(004),      "Agreement Type
             EKORG(004),      "Purchasing Organization
             EKGRP(003),      "Purchasing Group
             WERKS(004),      "Plant
             LGORT(004),      "Storage Location
             KDATB(010),      "Valid start Date
             KDATE(010),      "Valid End Date
             ZTERM(004),      "Payment Terms
             KTWRT(020),      "Target Value
             EPSTP(001),      "Item Category
             EMATN(018),      "Material Number
             KTMNG(017),      "Target Quantity
             NETPR(014),      "Net Price
             PEINH(006),      "Net Price Unit
             BPRME(003),      "Net Price Order Price Unit
             IDNLF(035),      "Vendor Material number
             WEBRE(001),      "GR Based-IV
             MEPRF(001),      "Pricing Date Category
             LTEX1(040),      "Info Text
             DATAB(010),      "Valid From
             DATBI(010),      "Valid To
             KSCHL(004),      "Condition Type
             KBETR(016),      "Condition Rate if scale is not given
             KONWA(005),      "Currency
             KPEIN(005),      "Condition Pricing Unit
             KMEIN(003),      "Condition Unit of Measure
             KSTBM(019),      "Scale
             KBETR_01(016),   "Scale Rate
             DEL_FLAG,        "Delete Flag Indicator
             ERR_MSG(100),    "Error Message
          END OF T_ERR_RECORD,
          BEGIN OF T_LOEKZ,    "To have deletion indicators for materials
              LOEKZ(001),    "Deletion indicator in purchasing document
              EMATN(018),    "Material Number
              WERKS(004),    "Plant
              LGORT(004),    "Storage Location
              BSTYP(001),    "Purchasing document category
          END OF T_LOEKZ,
          BEGIN OF T_MATNR,  " Type definition to store details of materials
               MATNR(018),    "Material Number
          END OF T_MATNR,
          BEGIN OF T_T001,   " Type definition for company codes
              BUKRS(004),    " Company Code
          END OF T_T001,
          BEGIN OF T_ZMVXREF,   "Cross-Reference table type
              D_ALTKN(10),      "Legacy Vendor Number
              D_BUKRS(4),       "Legacy Company Code
              M_ALTKN(10),      "SAP Company Code
          END OF T_ZMVXREF,
          BEGIN OF T_LFA1,    "Master data of vendors
              LIFNR(10),      "Vendor Number
          END OF T_LFA1,
    *  Type Declaration for T024E (Company Codes)
           BEGIN OF T_T024E,
             EKORG   LIKE   T024E-EKORG,     "Purchasing organization
             BUKRS   LIKE   T024E-BUKRS,     "Company Code
           END OF T_T024E,
    *  Type Declaration for t001w (Plant)
           BEGIN OF T_T001W,
             WERKS  LIKE  T001W-WERKS,            "Plant
           END OF T_T001W,
    *  Type Declatation for String Line
           BEGIN OF T_STR1,                                     "#EC NEEDED
             SLINE(6000) TYPE C,
           END OF T_STR1.
    TYPES:  BEGIN OF T_BDCDATA.  "BDC Data
            INCLUDE STRUCTURE BDCDATA.
    TYPES:  END OF T_BDCDATA.
    *       Internal Tables  Declaration                                  *
    DATA:
    *      Internal table to store input file data
           I_RECORD TYPE STANDARD TABLE OF T_RECORD INITIAL SIZE 0,
    *      Internal table to capture errors
           I_ERR_REC TYPE STANDARD TABLE OF T_ERR_RECORD INITIAL SIZE 0,
    *      Internal table to check for deletion indicators
           I_LOEKZ TYPE STANDARD TABLE OF T_LOEKZ INITIAL SIZE 0,
    *      Internal table to check for material numbers
           I_MATNR TYPE STANDARD TABLE OF T_MATNR INITIAL SIZE 0,
    *      Internal table used for storing Cross-Reference data of Vendor
           I_ZMVXREF TYPE STANDARD TABLE OF T_ZMVXREF INITIAL SIZE 0,
    *      Internal table for holding Vendor Numbers from Master table
           I_LFA1 TYPE STANDARD TABLE OF T_LFA1 INITIAL SIZE 0,
    *      Internal table for holding Purchase Org and Company Codes
           I_T024E TYPE STANDARD TABLE OF T_T024E INITIAL SIZE 0,
    *      Internal table for holding Plants
           I_T001W TYPE STANDARD TABLE OF T_T001W INITIAL SIZE 0,
    *      Internal table for storing a list of Company Codes
           I_T001 TYPE STANDARD TABLE OF T_T001 INITIAL SIZE 0,
    *      Internal table used for ALV Reporting
           I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
    *      Internal table used for holding List Header
           I_LISTHEADER TYPE SLIS_T_LISTHEADER,    "EC NEEDED
    *      Internal table to hold ALV Event
           I_ALV_EVENT TYPE SLIS_T_EVENT,
    *      Internal table to hold Sort Info for ALV Report
           I_SORT TYPE SLIS_T_SORTINFO_ALV,
    *      Internal table for BDC Data
           I_BDCDATA TYPE STANDARD TABLE OF T_BDCDATA INITIAL SIZE 0,
    *      Internal table for messages
           I_MESSTAB TYPE TABLE OF BDCMSGCOLL,
    *      Internal table for String line
           I_STR1 TYPE STANDARD TABLE OF T_STR1 INITIAL SIZE 0.
    *       Work Area Declaration                                         *
    DATA:
    *  Work Area to hold data for the Open Contract
          WA_RECORD TYPE T_RECORD,
    *  Work Area to hold previous record data
          WA_RECORDPREV TYPE T_RECORD,
    *  Work Area to hold errors
          WA_ERR_REC TYPE T_ERR_RECORD,
    *  Work Area to hold the Deletion Indicator of materials
          WA_LOEKZ TYPE T_LOEKZ,
    *  Work Area to hold Material numbers of required materials
          WA_MATNR TYPE T_MATNR,      "EC NEEDED
    *  Work Area to hold errors occured while performing BDC
          WA_MESSTAB TYPE BDCMSGCOLL,
    *  Work Area to hold field catalog for ALV Reports
          WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
    *  Work Area to hold list header data for ALV reports
          WA_LISTHEADER TYPE SLIS_LISTHEADER,
    *  Work Area to hold ALV Event
          WA_ALV_EVENT LIKE LINE OF I_ALV_EVENT,  "EC NEEDED
    *  Work Area to hold Layout of ALV Report
          WA_LAYOUT TYPE SLIS_LAYOUT_ALV,
    *  Work Area to hold Cross-Reference data of Vendor
          WA_ZMVXREF TYPE T_ZMVXREF,
    *  Work Area to hold Vendor Numbers from Master table
          WA_LFA1 TYPE T_LFA1,    "EC NEEDED
    *  Work Area to hold Purchase Org and Company Codes
          WA_T024E TYPE T_T024E,
    *  Work Area to hold Company Codes
          WA_T001 TYPE T_T001,
    *  Work Area to hold Plants
          WA_T001W TYPE T_T001W,
    *  Work Area to hold Sort Info for ALV Report
          WA_SORT TYPE SLIS_SORTINFO_ALV,
    *  Work Area to hold BDC Data
          WA_BDCDATA TYPE T_BDCDATA,
    *  Work Area for String line
          WA_STR1 TYPE T_STR1.
    *       Variables  Declaration                                        *
    DATA: V_ERRMSG(500),           "To temporarily store the error message
          V_CONV_DATE(10) TYPE C,  "To capture the converted date format
          V_DATE LIKE SY-DATUM,
          V_REPID LIKE SY-REPID,   "holds report id
          V_CROSS_REFERENCE_ERROR TYPE I,  " cross-reference error
          V_INPUTERROR_FLAG VALUE '',      " input error status
          V_FILENAME TYPE STRING,          " File Name
          VEN_FLAG(1),                       " at new status
          MAT_FLAG(1),                      " at new status
          V_IND(2) TYPE N,                 " index of table control
          V_IND2(2) TYPE N,                " index of table control
          V_IND3(2) TYPE N,                " index of table control
          V_EVRTP1(20),
          V_EPSTP1(20),
          V_EMATN1(20),
          V_KTMNG1(20),
          V_NETPR1(20),
          V_PEINH1(20),
          V_BPRME1(20),
          V_TCSELFLAG1(20),
          V_KSCHL2(20),
          V_KBETR2(20),
          V_KONWA2(20),
          V_KPEIN2(20),
          V_KMEIN2(20),
          V_SELKZ2(20),
          V_KBETR3(20),
          V_KSTBM3(20),
          V_LINE TYPE I,
          V_STR TYPE X VALUE '09',
          V_EXIST TYPE C,
          V_EXIST1 TYPE C,
          V_ISDIR TYPE C,
          V_ISDIR1 TYPE C.
    *       Constants  Declaration                                        *
    CONSTANTS: C_TCODE(5) VALUE 'ME31K', "Trx code - Open Contract Creation
               C_TRUE     VALUE 'X',       " Del_Flag indicator
               C_LOEKZ_MARKED VALUE 'X',   "Deletion indicator for material
               C_INPUTERROR_FLAG_YES VALUE 'X',  "Input File Indicator
               C_VEN_ERR1 VALUE 1,    "Error Indicator
               C_16(2)    VALUE '16',
               C_VEN_ERR2 VALUE 2,    "Error Indicator
               C_VEN_ERR3 VALUE 3,    "Error Indicator
               C_VEN_SUCS VALUE 0,    "Success Indicator
               C_SUCCESS  LIKE SY-SUBRC VALUE '0',
               C_STRUE    VALUE 'S',  "Del_flag for SAP Errors
               C_YTRUE    VALUE 'Y',  "Del_flag for Success Records
               C_MSGTYP_E VALUE 'E',  "holds error message type
               C_MSGTYP_S VALUE 'S',  "holds success message type
               C_BSTYP    VALUE 'K',  "Purchasing Document type is Contract
               C_BACKGROUND VALUE 'N', "Background mode
               C_FOREGROUND VALUE 'A', "All Screen mode
               C_ERRORS   VALUE 'E',   "Error screen mode
               C_WK(2)    VALUE 'WK'. "Value Contract
    *        Selection Screen                                             *
    SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-033.
    SELECTION-SCREEN SKIP.
    SELECT-OPTIONS:
    *              Plant
                   S_WERKS FOR T001W-WERKS OBLIGATORY,
    *              Purchase Organization
                   S_EKORG FOR T024E-EKORG OBLIGATORY.
    *              Company Code
    PARAMETER      P_BUKRS LIKE T001-BUKRS OBLIGATORY.
    SELECTION-SCREEN SKIP.
    SELECTION-SCREEN ULINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN POSITION 3.
    PARAMETER RB_SERVE RADIOBUTTON GROUP RBX DEFAULT 'X' USER-COMMAND U1.
    SELECTION-SCREEN COMMENT 6(19)  TEXT-036.
    SELECTION-SCREEN POSITION 37.
    PARAMETER RB_LOCAL RADIOBUTTON GROUP RBX.
    SELECTION-SCREEN COMMENT 40(13) TEXT-035.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN SKIP.
    PARAMETERS:
    *    Parameter holding Input File name
              P_FILE LIKE RLGRAP-FILENAME
                     OBLIGATORY
                     LOWER CASE
                     DEFAULT 'C:\'
                     MODIF ID G1,
              P_FILE1 LIKE RLGRAP-FILENAME
                      OBLIGATORY
                      LOWER CASE
                      DEFAULT '/celestica/interface/corp/in/work/'
                      MODIF ID G2,
    *    Parameter specifying Mode of calling the Transaction.
              P_MODE DEFAULT 'N' OBLIGATORY,
    *    Check box used to test the input file.
              P_TEST AS CHECKBOX DEFAULT 'X',
    *    Parameter holding Filename for holding Input File Errors
              P_IPERR LIKE RLGRAP-FILENAME
                      OBLIGATORY
                      LOWER CASE
                      DEFAULT 'C:\'
                      MODIF ID G1,
              P_IPERR1 LIKE RLGRAP-FILENAME
                     OBLIGATORY
                     LOWER CASE
                     DEFAULT '/celestica/interface/corp/in/work/047_Err.txt'
                     MODIF ID G2.
    SELECTION-SCREEN END OF BLOCK B2.
    *        AT Selection Screen  Events                                  *
    *  Loop the screen to activate relative paths
    AT SELECTION-SCREEN OUTPUT.
      LOOP AT SCREEN.
        IF RB_SERVE = C_TRUE AND SCREEN-GROUP1 = 'G1'.
          SCREEN-OUTPUT = 0.
          SCREEN-ACTIVE = 0.
          SCREEN-INPUT = 0.
        ELSEIF RB_LOCAL = C_TRUE AND SCREEN-GROUP1 = 'G2'.
          SCREEN-OUTPUT = 0.
          SCREEN-ACTIVE = 0.
          SCREEN-INPUT = 0.
        ENDIF.
        MODIFY SCREEN.
      ENDLOOP.
    AT SELECTION-SCREEN ON BLOCK B2.
    *  Checking Access Authorization for the user
      CALL FUNCTION 'ZU_DATA_ACCESS_AUTH_CHECK'
           EXPORTING
                ACTVT        = C_16
                P_BUKRS      = P_BUKRS
           TABLES
                S_WERKS      = S_WERKS
                S_EKORG      = S_EKORG
           EXCEPTIONS
                BUKRS_FAILED = 1
                VKORG_FAILED = 2
                VTWEG_FAILED = 3
                EKORG_FAILED = 4
                WERKS_FAILED = 5
                LGNUM_FAILED = 6
                OTHERS       = 7.
      IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    AT SELECTION-SCREEN ON P_BUKRS.
      IF NOT P_BUKRS IS INITIAL.
        SELECT SINGLE BUKRS INTO T001
                            FROM T001
                            WHERE BUKRS EQ P_BUKRS.
        IF SY-SUBRC NE 0.
          MESSAGE I000 WITH TEXT-089.
          STOP.
        ENDIF.
      ENDIF.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
    * Search Help to select Input File path.
      PERFORM GET_FILE_NAME USING P_FILE.
    * Check for the existence of the file.
      IF RB_LOCAL EQ C_TRUE.
        CALL FUNCTION 'TMP_GUI_GET_FILE_EXIST'
             EXPORTING
                  FNAME          = P_FILE
             IMPORTING
                  EXIST          = V_EXIST
                  ISDIR          = V_ISDIR
             EXCEPTIONS
                  FILEINFO_ERROR = 1
                  OTHERS         = 2.
        IF SY-SUBRC <> 0.
          MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                  WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
        IF V_ISDIR IS INITIAL.
          IF V_EXIST IS INITIAL.
            MESSAGE I000 WITH TEXT-018.
            STOP.
          ENDIF.
        ELSEIF V_ISDIR EQ C_TRUE.
          MESSAGE I000 WITH TEXT-068.
          STOP.
        ENDIF.
      ENDIF.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_IPERR.
    * Search Help to select Input Error File path.
      PERFORM GET_FILE_NAME USING P_IPERR.
    AT SELECTION-SCREEN.
    * Validate Transaction Mode
      IF  P_MODE <> C_BACKGROUND AND
          P_MODE <> C_FOREGROUND AND
          P_MODE <> C_ERRORS.
        MESSAGE I000 WITH TEXT-034.
        STOP.
      ENDIF.
    START-OF-SELECTION.
    * Get the Input File Data
      V_FILENAME = P_FILE.
      PERFORM UPLOAD_FLATFILE_DATA TABLES I_RECORD
                                   USING V_FILENAME.
    * Sorting the data by all fields
      SORT I_RECORD.
    * Ensuring the padding of the empty spaces before the vendor No
      CLEAR WA_RECORD.
      LOOP AT I_RECORD INTO WA_RECORD.
        CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
             EXPORTING
                  INPUT  = WA_RECORD-LIFNR
             IMPORTING
                  OUTPUT = WA_RECORD-LIFNR.
        MODIFY I_RECORD FROM WA_RECORD
                        INDEX SY-TABIX
                        TRANSPORTING LIFNR.
        CLEAR WA_RECORD.
      ENDLOOP.
    * Input file validation
      PERFORM VALIDATE_FLATFILE_DATA.
      IF P_TEST = C_TRUE.
        IF I_ERR_REC[] IS INITIAL.
          MESSAGE I000 WITH TEXT-032.
          STOP.
        ELSE.
    *  Display all the error records at the input level.
          PERFORM DISPLAY_INPERR_RECORDS.
    *  Download Error File
          PERFORM DOWNLOAD_ERROR_FILE.
        ENDIF.
      ELSE.
    * Build BDC Data
        PERFORM BUILD_BDC_DATA.
    * Download Error File
        PERFORM DOWNLOAD_ERROR_FILE.
    * Display the status report.
        PERFORM DISPLAY_PROCESSED_RECORDS.
      ENDIF.
    END-OF-SELECTION.
      REFRESH:  I_RECORD,
                I_ERR_REC,
                I_LOEKZ,
                I_MATNR,
                I_ZMVXREF,
                I_LFA1,
                I_T024E,
                I_FIELDCAT,
                I_LISTHEADER,
                I_ALV_EVENT,
                I_SORT,
                I_BDCDATA,
                I_MESSTAB,
                I_STR1.
      FREE: I_RECORD,
            I_ERR_REC,
            I_LOEKZ,
            I_MATNR,
            I_ZMVXREF,
            I_LFA1,
            I_T024E,
            I_FIELDCAT,
            I_LISTHEADER,
            I_ALV_EVENT,
            I_SORT,
            I_BDCDATA,
            I_MESSTAB,
            I_STR1.
    *&      Form  GET_file_name
    *       Fetches the file and path from the presentation system
    *  -->  p1        Path along with the file name
    FORM GET_FILE_NAME USING L_FILE LIKE RLGRAP-FILENAME.
      CALL FUNCTION 'WS_FILENAME_GET'
           EXPORTING
                MASK             = ',*.TXT,*.txt.'
                MODE             = 'O'
                TITLE            = TEXT-011
           IMPORTING
                FILENAME         = L_FILE
           EXCEPTIONS
                INV_WINSYS       = 1
                NO_BATCH         = 2
                SELECTION_CANCEL = 3
                SELECTION_ERROR  = 4
                OTHERS           = 5.
      CASE SY-SUBRC.
        WHEN 1.
          MESSAGE I000 WITH TEXT-084.
          STOP.
        WHEN 2.
          MESSAGE I000 WITH TEXT-085.
          STOP.
        WHEN 3.
          MESSAGE I000 WITH TEXT-086.
          STOP.
        WHEN 4.
          MESSAGE I000 WITH TEXT-087.
          STOP.
      ENDCASE.
    ENDFORM.                    " GET_file_name
    *&      Form  upload_flatfile_data
    *       Uploading data from Flat File
    FORM UPLOAD_FLATFILE_DATA
                          TABLES I_L_RECORD STRUCTURE WA_RECORD
                          USING L_FILENAME TYPE STRING.
      DATA WA_L_RECORD TYPE T_RECORD.
    * Upload the Flat file data
      IF RB_LOCAL EQ C_TRUE. "File is on the Local System
        CALL FUNCTION 'GUI_UPLOAD'
             EXPORTING
                  FILENAME                = L_FILENAME
                  FILETYPE                = 'ASC'
                  HAS_FIELD_SEPARATOR     = 'X'
             TABLES
                  DATA_TAB                = I_L_RECORD
             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.
        CASE SY-SUBRC.
          WHEN 0.
            DESCRIBE TABLE I_L_RECORD LINES V_LINE.
            IF V_LINE EQ 0.
              MESSAGE I000 WITH TEXT-065.
              STOP.
            ENDIF.
          WHEN 1.
            MESSAGE I000 WITH TEXT-068.
            STOP.
          WHEN 2.
            MESSAGE I000 WITH TEXT-069.
            STOP.
          WHEN 3.
            MESSAGE I000 WITH TEXT-070.
            STOP.
          WHEN 4.
            MESSAGE I000 WITH TEXT-071.
            STOP.
          WHEN 5.
            MESSAGE I000 WITH TEXT-072.
            STOP.
          WHEN 6.
            MESSAGE I000 WITH TEXT-073.
            STOP.
          WHEN 7.
            MESSAGE I000 WITH TEXT-074.
            STOP.
          WHEN 8.
            MESSAGE I000 WITH TEXT-075.
            STOP.
          WHEN 9.
            MESSAGE I000 WITH TEXT-076.
            STOP.
          WHEN 10.
            MESSAGE I000 WITH TEXT-077.
            STOP.
          WHEN 11.
            MESSAGE I000 WITH TEXT-078.
            STOP.
          WHEN 12.
            MESSAGE I000 WITH TEXT-079.
            STOP.
          WHEN 13.
            MESSAGE I000 WITH TEXT-080.
            STOP.
          WHEN 14.
            MESSAGE I000 WITH TEXT-081.
            STOP.
          WHEN 15.
            MESSAGE I000 WITH TEXT-082.
            STOP.
          WHEN 16.
            MESSAGE I000 WITH TEXT-083.
            STOP.
        ENDCASE.
        CLEAR V_LINE.
      ELSEIF RB_SERVE EQ C_TRUE. "File is on the Application Server
        P_MODE = C_BACKGROUND.
        OPEN DATASET P_FILE1 FOR INPUT IN TEXT MODE.
        CHECK SY-SUBRC EQ C_SUCCESS.
        CLEAR WA_STR1.
        DO.
          READ DATASET P_FILE1 INTO WA_STR1.
          IF SY-SUBRC <> 0.      " NE SUCCESS.
            EXIT.
          ELSEIF SY-SUBRC EQ C_SUCCESS.
            APPEND WA_STR1 TO I_STR1.
            CLEAR WA_STR1.
          ENDIF.                  " ENDIF on SY-SUBRC 0 Check.
        ENDDO.                    " ENDDO
        DELETE I_STR1 WHERE SLINE EQ ' '.
        DESCRIBE TABLE I_STR1 LINES V_LINE.
        IF V_LINE EQ 0.
          MESSAGE S000 WITH TEXT-065.
          STOP.
        ENDIF.
        LOOP AT I_STR1 INTO WA_STR1.
          CLEAR: WA_L_RECORD.
          SPLIT WA_STR1-SLINE AT V_STR
          INTO WA_L_RECORD-LIFNR
               WA_L_RECORD-EVART
               WA_L_RECORD-EKORG
               WA_L_RECORD-EKGRP
               WA_L_RECORD-WERKS
               WA_L_RECORD-LGORT
               WA_L_RECORD-KDATB
               WA_L_RECORD-KDATE
               WA_L_RECORD-ZTERM
               WA_L_RECORD-KTWRT
               WA_L_RECORD-EPSTP
               WA_L_RECORD-EMATN
               WA_L_RECORD-KTMNG
               WA_L_RECORD-NETPR
               WA_L_RECORD-PEINH
               WA_L_RECORD-BPRME
               WA_L_RECORD-IDNLF
               WA_L_RECORD-WEBRE
               WA_L_RECORD-MEPRF
               WA_L_RECORD-LTEX1
               WA_L_RECORD-DATAB
               WA_L_RECORD-DATBI
               WA_L_RECORD-KSCHL
               WA_L_RECORD-KBETR
               WA_L_RECORD-KONWA
               WA_L_RECORD-KPEIN
               WA_L_RECORD-KMEIN
               WA_L_RECORD-KSTBM
               WA_L_RECORD-KBETR_01
               WA_L_RECORD-DEL_FLAG
               WA_L_RECORD-ERR_MSG.
          APPEND WA_L_RECORD TO I_L_RECORD.
          CLEAR: WA_L_RECORD,
                  WA_STR1.
        ENDLOOP.
        REFRESH I_STR1.
        CLOSE DATASET P_FILE1.
      ENDIF.
    ENDFORM.
    *&      Form  BDC_DYNPRO
    *       Data populated into i_bdcdata table for program
    FORM BDC_DYNPRO USING PROGRAM DYNPRO.
      CLEAR WA_BDCDATA.
      WA_BDCDATA-PROGRAM  = PROGRAM.
      WA_BDCDATA-DYNPRO   = DYNPRO.
      WA_BDCDATA-DYNBEGIN = C_TRUE.
      APPEND WA_BDCDATA TO I_BDCDATA.
    ENDFORM.
    *&      Form  BDC_FIELD
    *       Data populated into i_bdcdata table for fields
    FORM BDC_FIELD USING FNAM FVAL.
      CLEAR WA_BDCDATA.
      WA_BDCDATA-FNAM = FNAM.
      WA_BDCDATA-FVAL = FVAL.
      APPEND WA_BDCDATA TO I_BDCDATA.
    ENDFORM.
    *&      Form  convert_date
    *       Converting the data from the file format to mm/dd/yyyy format
    *      <--P_wa_record_kdatb  Source Date
    *      <--p_l_conv_date      Target Date
    FORM CONVERT_DATE USING L_DATE
                            L_TAR_DATE.
      CONCATENATE L_DATE+0(2)
                  L_DATE+3(2)
                  L_DATE+6(4)
                  INTO L_TAR_DATE.
    ENDFORM.                    " convert_date
    *&      Form  validate_flatfile_data
    *       Validating the input file
    FORM VALIDATE_FLATFILE_DATA.
      DATA: L_TODAY LIKE SY-DATUM,
            L_STARTDATE_C LIKE SY-DATUM,
            L_ENDDATE_C LIKE SY-DATUM,
            L_ENDDATE_C1 LIKE SY-DATUM,
            L_STARTDATE_C1 LIKE SY-DATUM,
            L_STARTDATE(8),
            L_ENDDATE(8).
    * Fetch indicator for all records on the material, plant & storage
    * location combination.
      IF NOT I_RECORD[] IS INITIAL.
        REFRESH I_LOEKZ.
        SELECT EMATN            " Material Number
               WERKS            " Plant
               LGORT            " Storage Location
               BSTYP            " Purchasing Document Category
               LOEKZ            " Deletion indicator
          INTO TABLE I_LOEKZ
          FROM EKPO
          FOR ALL ENTRIES IN I_RECORD
          WHERE EMATN = I_RECORD-EMATN
            AND WERKS = I_RECORD-WERKS
            AND LGORT = I_RECORD-LGORT
            AND BSTYP = C_BSTYP
            AND LOEKZ = C_LOEKZ_MARKED.
        IF SY-SUBRC EQ 0.
          SORT I_LOEKZ BY EMATN WERKS LGORT BSTYP LOEKZ.
        ENDIF.
    * Fetching Plants for all entries in the selection screen
        REFRESH I_T001W.
        SELECT WERKS  "Plant
            INTO TABLE I_T001W
            FROM T001W
            WHERE WERKS IN S_WERKS.
        IF SY-SUBRC EQ 0.
          SORT I_T001W BY WERKS.
        ENDIF.
    * Fetching materials for the plants listed in flat file
        REFRESH I_MATNR.
        SELECT MATNR          " Material Number
          INTO TABLE I_MATNR
          FROM MARC
          FOR ALL ENTRIES IN I_RECORD
          WHERE WERKS = I_RECORD-WERKS.
        IF SY-SUBRC EQ 0.
          SORT I_MATNR BY MATNR.
        ENDIF.
    * Fetching Company Codes for repective Purchase Organizations
        REFRESH I_T024E.
        SELECT EKORG       "  Purchase Organization
               BUKRS       "  Company Code
            INTO TABLE I_T024E
            FROM T024E
            WHERE EKORG IN S_EKORG.
        IF SY-SUBRC EQ 0.
          SORT I_T024E BY EKORG.
        ENDIF.
    * Fetching SAP Data using Legacy Data.
        REFRESH I_ZMVXREF.
        SELECT D_ALTKN
               D_BUKRS
               M_ALTKN
            INTO TABLE I_ZMVXREF
            FROM ZMVXREF
            FOR ALL ENTRIES IN I_RECORD
            WHERE D_ALTKN = I_RECORD-LIFNR.
        IF SY-SUBRC EQ 0.
          SORT I_ZMVXREF BY D_ALTKN D_BUKRS.
        ENDIF.
    * Fetching Vendors from LFA1
        IF NOT I_ZMVXREF[] IS INITIAL.
          REFRESH I_LFA1.
          SELECT LIFNR
             INTO TABLE I_LFA1
             FROM LFA1
             FOR ALL ENTRIES IN I_ZMVXREF
             WHERE LIFNR = I_ZMVXREF-M_ALTKN.
          IF SY-SUBRC EQ 0.
            SORT I_LFA1 BY LIFNR.
          ENDIF.
        ENDIF.
    * Start Validating the flat file
        CLEAR: WA_RECORD,
               WA_T024E,
               WA_ZMVXREF,
               WA_LFA1,
               WA_LOEKZ,
               WA_MATNR.
        LOOP AT I_RECORD INTO WA_RECORD.
          L_TODAY = SY-DATUM.
          L_STARTDATE = WA_RECORD-KDATB.
          L_ENDDATE = WA_RECORD-KDATE.
          IF WA_RECORD-DEL_FLAG IS INITIAL.
            READ TABLE I_T001W INTO WA_T001W
                               WITH KEY WERKS = WA_RECORD-WERKS
                               BINARY SEARCH.
            IF SY-SUBRC EQ 0.
    *   Cross-Reference check performed for the given Vendors
              READ TABLE I_T024E INTO WA_T024E
                                 WITH KEY EKORG = WA_RECORD-EKORG
                                 BINARY SEARCH.
              IF SY-SUBRC NE 0.
                V_CROSS_REFERENCE_ERROR = C_VEN_ERR3.
              ELSE.
                READ TABLE I_ZMVXREF INTO WA_ZMVXREF
                            WITH KEY D_ALTKN = WA_RECORD-LIFNR
                                     D_BUKRS = P_BUKRS
                            BINARY SEARCH.
                IF SY-SUBRC EQ 0.
                  READ TABLE I_LFA1 INTO WA_LFA1
                             WITH KEY LIFNR = WA_ZMVXREF-M_ALTKN
                             BINARY SEARCH.
                  IF SY-SUBRC EQ 0.
                    V_CROSS_REFERENCE_ERROR = C_VEN_SUCS.
                  ELSE.
                    V_CROSS_REFERENCE_ERROR = C_VEN_ERR2.
                  ENDIF.
                ELSE.
                  V_CROSS_REFERENCE_ERROR = C_VEN_ERR1.
                ENDIF.
              ENDIF.
    * Legacy Vendor could not be mapped
              IF V_CROSS_REFERENCE_ERROR EQ C_VEN_ERR1.
            V_INPUTERROR_FLAG = C_INPUTERROR_FLAG_YES. "Inp.file err. occurd
                WA_RECORD-DEL_FLAG = C_TRUE.
                WA_RECORD-ERR_MSG = TEXT-007.
                MODIFY I_RECORD FROM WA_RECORD
                                TRANSPORTING DEL_FLAG
                                             ERR_MSG
                                WHERE LIFNR = WA_RECORD-LIFNR.
    * Legacy Vendor is mapped but the obtained SAP vendor doesn't exist.
              ELSEIF V_CROSS_REFERENCE_ERROR EQ C_VEN_ERR2.
    *           Inp.file err. occurd
                V_INPUTERROR_FLAG = C_INPUTERROR_FLAG_YES.
                WA_RECORD-DEL_FLAG = C_TRUE.
                WA_RECORD-ERR_MSG = TEXT-008.
                MODIFY I_RECORD FROM WA_RECORD
                                TRANSPORTING DEL_FLAG
                                             ERR_MSG
                                WHERE LIFNR = WA_RECORD-LIFNR.
    * Purchase Organization doesn't exist in T024E.
              ELSEIF V_CROSS_REFERENCE_ERROR EQ C_VEN_ERR3.
    *             Inp.file err. occurd
                V_INPUTERROR_FLAG = C_INPUTERROR_FLAG_YES.
                WA_RECORD-DEL_FLAG = C_TRUE.
                WA_RECORD-ERR_MSG = TEXT-014.
                MODIFY I_RECORD FROM WA_RECORD
                                TRANSPORTING DEL_FLAG
                                             ERR_MSG
                                WHERE EKORG = WA_RECORD-EKORG.
    * Vendor is mapped and validated successfully
              ELSEIF V_CROSS_REFERENCE_ERROR EQ C_VEN_SUCS.
    * Checking for the deletion indicator for that record
                CONCATENATE WA_RECORD-KDATB+6(4)
                            WA_RECORD-KDATB+3(2)
                            WA_RECORD-KDATB+0(2)
                            INTO
                            L_STARTDATE.
                MOVE L_STARTDATE TO L_STARTDATE_C.
                CONCATENATE WA_RECORD-KDATB+6(4)
                            WA_RECORD-KDATB+0(2)
                            WA_RECORD-KDATB+3(2)
                            INTO
                            L_STARTDATE_C1.
                CONCATENATE WA_RECORD-KDATE+6(4)
                            WA_RECORD-KDATE+3(2)
                            WA_RECORD-KDATE+0(2)
                            INTO
                            L_ENDDATE.
                MOVE L_ENDDATE TO L_ENDDATE_C.
                CONCATENATE WA_RECORD-KDATE+6(4)
                            WA_RECORD-KDATE+0(2)
                            WA_RECORD-KDATE+3(2)
                            INTO
                            L_ENDDATE_C1.
                READ TABLE I_LOEKZ INTO WA_LOEKZ WITH KEY
                                                 EMATN = WA_RECORD-EMATN
                                                 WERKS = WA_RECORD-WERKS
                                                 LGORT = WA_RECORD-LGORT
                                                 BINARY SEARCH.
                IF SY-SUBRC EQ 0.
    *             Inpfle err.occured
                  V_INPUTERROR_FLAG = C_INPUTERROR_FLAG_YES.
                  WA_RECORD-ERR_MSG = TEXT-003.
                  WA_RECORD-DEL_FLAG = C_TRUE.    "marking the record
                  MODIFY I_RECORD FROM WA_RECORD
                                  TRANSPORTING DEL_FLAG
                                                ERR_MSG
                                  WHERE LIFNR = WA_RECORD-LIFNR
                                    AND EVART = WA_RECORD-EVART
                                    AND EKORG = WA_RECORD-EKORG
                                    AND EKGRP = WA_RECORD-EKGRP
                                    AND WERKS = WA_RECORD-WERKS
                                    AND LGORT = WA_RECORD-LGORT
                                    AND KDATB = WA_RECORD-KDATB
                                    AND KDATE = WA_RECORD-KDATE
                                    AND ZTERM = WA_RECORD-ZTERM
                                    AND KTWRT = WA_RECORD-KTWRT
                                    AND EPSTP = WA_RECORD-EPSTP
                                    AND EMATN = WA_RECORD-EMATN.
    * Validating the Purchasing Organization for Blank/Null
                ELSEIF WA_RECORD-EKORG IS INITIAL.
    *             Inpfle err.occured
                  V_INPUTERROR_FLAG = C_INPUTERROR_FLAG_YES.
                  WA_RECORD-ERR_MSG = TEXT-010.
                  WA_RECORD-DEL_FLAG = C_TRUE.
                  MODIFY I_RECORD FROM WA_RECORD
                                  TRANSPORTING DEL_FLAG
                                               ERR_MSG
                                  WHERE LIFNR = WA_RECORD-LIFNR
                                    AND EVART = WA_RECORD-EVART
                                    AND EKORG = WA_RECORD-EKORG
                                    AND EKGRP = WA_RECORD-EKGRP
                                    AND WERKS = WA_RECORD-WERKS
                                    AND LGORT = WA_RECORD-LGORT
                                    AND KDATB = WA_RECORD-KDATB
                                    AND KDATE = WA_RECORD-KDATE
                                    AND ZTERM = WA_RECORD-ZTERM
                                    AND KTWRT = WA_RECORD-KTWRT
                                    AND EPSTP = WA_RECORD-EPSTP
                                    AND EMATN = WA_RECORD-EMATN.
    * Validating the Plant for Blank/Null
                ELSEIF WA_RECORD-WERKS IS INITIAL.
    *             Inpfle err.occured
                  V_INPUTERROR_FLAG = C_INPUTERROR_FLAG_YES.
                  WA_RECORD-ERR_MSG = TEXT-039.
                  WA_RECORD-DEL_FLAG = C_TRUE.
                  MODIFY I_RECORD FROM WA_RECORD
                                  TRANSPORTING DEL_FLAG
                                               ERR_MSG
                                  WHERE LIFNR = WA_RECORD-LIFNR
                                    AND EVART = WA_RECORD-EVART
                                    AND EKORG = WA_RECORD-EKORG
                                    AND EKGRP = WA_RECORD-EKGRP
                                    AND WERKS = WA_RECORD-WERKS
                                    AND LGORT = WA_RECORD-LGORT
                                    AND KDATB = WA_RECORD-KDATB
                                    AND KDATE = WA_RECORD-KDATE
                                    AND ZTERM = WA_RECORD-ZTERM
                                    AND KTWRT = WA_RECORD-KTWRT
                                    AND EPSTP = WA_RECORD-EPSTP
                                    AND EMATN = WA_RECORD-EMATN.
    * Validating the Contract Validity Start Date
                ELSEIF L_STARTDATE_C1 GT L_TODAY.             "#EC PORTABLE
    *             Inpfle err.occured
                  V_INPUTERROR_FLAG = C_INPUTERROR_FLAG_YES.
                  WA_RECORD-ERR_MSG = TEXT-004.
                  WA_RECORD-DEL_FLAG = C_TRUE.      "marking the record
                  MODIFY I_RECORD FROM WA_RECORD
                                  TRANSPORTING DEL_FLAG
                                               ERR_MSG
                                  WHERE LIFNR = WA_RECORD-LIFNR
                                    AND EVART = WA_RECORD-EVART
                                    AND EKORG = WA_RECORD-EKORG
                                    AND EKGRP = WA_RECORD-EKGRP
                                    AND WERKS = WA_RECORD-WERKS
                                    AND LGORT = WA_RECORD-LGORT
                                    AND KDATB = WA_RECORD-KDATB.
    * Validating the Contract Validity End Date
                ELSEIF L_ENDDATE_C1 LE L_TODAY.               "#EC PORTABLE
    *             Inpfle err.ocrd
                  V_INPUTERROR_FLAG = C_INPUTERROR_FLAG_YES.
                  WA_RECORD-ERR_MSG = TEXT-005.
                  WA_RECORD-DEL_FLAG = C_TRUE.    "marking the record
                  MODIFY I_RECORD FROM WA_RECORD
                                  TRANSPORTING DEL_FLAG
                                               ERR_MSG
                                  WHERE LIFNR = WA_RECORD-LIFNR
                                    AND EVART = WA_RECORD-EVART
                                    AND EKORG = WA_RECORD-EKORG
                                    AND EKGRP = WA_RECORD-EKGRP
                                    AND WERKS = WA_RECORD-WERKS
                                    AND LGORT = WA_RECORD-LGORT
                                    AND KDATB = WA_RECORD-KDATB
                                    AND KDATE = WA_RECORD-KDATE.
    * Checking for Material under the Plant for Agreement Type 'WK'
                ELSEIF WA_RECORD-EVART = C_WK.
                  READ TABLE I_MATNR INTO WA_MATNR
                                     WITH KEY MATNR = WA_RECORD-EMATN
                                     BINARY SEARCH.
                  IF SY-SUBRC NE 0.
                 V_INPUTERROR_FLAG = C_INPUTERROR_FLAG_YES. "Inpfle err.ocrd
                    WA_RECORD-ERR_MSG = TEXT-006.
                    WA_RECORD-DEL_FLAG = C_TRUE.   "marking the record
                    MODIFY I_RECORD FROM WA_RECORD
                                    TRANSPORTING DEL_FLAG
                                                 ERR_MSG
                                    WHERE LIFNR = WA_RECORD-LIFNR
                                      AND EVART = WA_RECORD-EVART
                                      AND EKORG = WA_RECORD-EKORG
                                      AND EKGRP = WA_RECORD-EKGRP
                                      AND WERKS = WA_RECORD-WERKS
                                      AND LGORT = WA_RECORD-LGORT
                                      AND KDATB = WA_RECORD-KDATB
                                      AND KDATE = WA_RECORD-KDATE
                                      AND ZTERM = WA_RECORD-ZTERM
                                      AND KTWRT = WA_RECORD-KTWRT
                                      AND EPSTP = WA_RECORD-EPSTP
                                      AND EMATN = WA_RECORD-EMATN.
                  ENDIF.
                ENDIF.  " checking of deletion indicator
              ENDIF.   " checking for success of vendor cross reference
            ELSE.
              V_INPUTERROR_FLAG = C_INPUTERROR_FLAG_YES. "Inpfle err.ocrd
              WA_RECORD-ERR_MSG = TEXT-041.
              WA_RECORD-DEL_FLAG = C_TRUE.   "marking the record
              MODIFY I_RECORD FROM WA_RECORD
                              TRANSPORTING DEL_FLAG
                                           ERR_MSG
                              WHERE WERKS = WA_RECORD-WERKS.
            ENDIF. " Plant checked to selection screen
          ENDIF.  " the records for which del_flag is initial
          CLEAR: WA_RECORD,
                 WA_T024E,
                 WA_ZMVXREF,
                 WA_LFA1,
                 WA_LOEKZ,
                 WA_MATNR,
                 L_TODAY,
                 L_STARTDATE_C,
                 L_ENDDATE_C,
                 L_STARTDATE,
                 L_ENDDATE.
        ENDLOOP.
        LOOP AT I_RECORD INTO WA_RECORD.
          IF WA_RECORD-DEL_FLAG = C_TRUE.
            APPEND WA_RECORD TO I_ERR_REC.
            CLEAR WA_RECORD.
          ENDIF.
        ENDLOOP.
      ELSE.
        MESSAGE E000 WITH TEXT-013.  " no records in the flat file
        STOP.
      ENDIF.
    ENDFORM.                    " validate_flatfile_data
    *&      Form  DOWNLOAD_ERROR_FILE
    *       Downloads all records along with the records encountering the
    *       input file validation error
    FORM DOWNLOAD_ERROR_FILE.
      DATA L_ISDIR TYPE C.
      IF V_INPUTERROR_FLAG = C_INPUTERROR_FLAG_YES.
        V_FILENAME = P_IPERR.
    * Check for the existence of the file.
        IF RB_LOCAL EQ C_TRUE.
          CALL FUNCTION 'TMP_GUI_GET_FILE_EXIST'
               EXPORTING
                    FNAME          = P_IPERR
               IMPORTING
                    ISDIR          = L_ISDIR
               EXCEPTIONS
                    FILEINFO_ERROR = 1
                    OTHERS         = 2.
          IF SY-SUBRC <> 0.
            MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
          IF L_ISDIR EQ C_TRUE.
            MESSAGE I000 WITH TEXT-088.
            STOP.
          ENDIF.
        ENDIF.
        IF RB_LOCAL EQ C_TRUE.
    * Download the Input Error File.
          CALL FUNCTION 'GUI_DOWNLOAD'
               EXPORTING
                    FILENAME                = V_FILENAME
                    FILETYPE                = 'ASC'
                    WRITE_FIELD_SEPARATOR   = '#'
               TABLES
                    DATA_TAB                = I_ERR_REC
               EXCEPTIONS
                    FILE_WRITE_ERROR        = 1
                    NO_BATCH                = 2
                    GUI_REFUSE_FILETRANSFER = 3
                    INVALID_TYPE            = 4
                    NO_AUTHORITY            = 5
                    UNKNOWN_ERROR           = 6
                    HEADER_NOT_ALLOWED      = 7
                    SEPARATOR_NOT_ALLOWED   = 8
                    FILESIZE_NOT_ALLOWED    = 9
                    HEADER_TOO_LONG         = 10
                    DP_ERROR_CREATE         = 11
                    DP_ERROR_SEND           = 12
                    DP_ERROR_WRITE          = 13
                    UNKNOWN_DP_ERROR        = 14
                    ACCESS_DENIED           = 15
                    DP_OUT_OF_MEMORY        = 16
                    DISK_FULL               = 17
                    DP_TIMEOUT              = 18
                    FILE_NOT_FOUND          = 19
                    DATAPROVIDER_EXCEPTION  = 20
                    CONTROL_FLUSH_ERROR     = 21
                    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.
        ELSEIF RB_SERVE EQ C_TRUE.
          OPEN DATASET P_IPERR1 FOR OUTPUT IN TEXT MODE.
          CHECK SY-SUBRC EQ 0.
          CLEAR WA_ERR_REC.
          LOOP AT I_ERR_REC INTO WA_ERR_REC.
            IF WA_ERR_REC-DEL_FLAG = C_TRUE.
              TRANSFER WA_ERR_REC TO P_IPERR1.
            ENDIF.
            CLEAR WA_ERR_REC.
          ENDLOOP.
          CLOSE DATASET P_IPERR1.
        ENDIF.
      ENDIF.
    ENDFORM.                    " DOWNLOAD_ERROR_FILE
    *&      Form  BUILD_BDC_DATA
    * Populates BDC for all the fields neccessary for Open Contract Creation
    FORM BUILD_BDC_DATA.
      DATA: L_MAT_INDEX TYPE I,
            L_CON_INDEX TYPE I,
            L_SCA_INDEX TYPE I.
      CLEAR   WA_BDCDATA.
      REFRESH: I_BDCDATA,
               I_MESSTAB.
    * Processing the bdc
      CLEAR: WA_RECORD,
             WA_RECORDPREV,
             VEN_FLAG,
             MAT_FLAG.
      LOOP AT I_RECORD INTO WA_RECORD.
    *    Checks for the del_flag of the record.
        IF     WA_RECORD-DEL_FLAG EQ C_TRUE
            OR WA_RECORD-DEL_FLAG EQ C_STRUE.
          CLEAR WA_RECORD.
          CONTINUE.
        ELSE.
          IF  WA_RECORDPREV-LIFNR NE WA_RECORD-LIFNR
           OR WA_RECORDPREV-EVART NE WA_RECORD-EVART
           OR WA_RECORDPREV-EKORG NE WA_RECORD-EKORG
           OR WA_RECORDPREV-EKGRP NE WA_RECORD-EKGRP
           OR WA_RECORDPREV-WERKS NE WA_RECORD-WERKS
           OR WA_RECORDPREV-LGORT NE WA_RECORD-LGORT
           OR WA_RECORDPREV-KDATB NE WA_RECORD-KDATB
           OR WA_RECORDPREV-KDATE NE WA_RECORD-KDATE
           OR WA_RECORDPREV-ZTERM NE WA_RECORD-ZTERM
           OR WA_RECORDPREV-KTWRT NE WA_RECORD-KTWRT.
            PERFORM BDC_DYNPRO      USING 'SAPMM06E' '0200'.
            PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                          'RM06E-LGORT'.
            PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                          '/00'.
    *   Cross-Reference check performed for the given Vendors
            CLEAR WA_T024E.
            READ TABLE I_T024E INTO WA_T024E
                               WITH KEY EKORG = WA_RECORD-EKORG
                               BINARY SEARCH.
            IF SY-SUBRC EQ 0.
              CLEAR WA_ZMVXREF.
              READ TABLE I_ZMVXREF INTO WA_ZMVXREF
                          WITH KEY D_ALTKN = WA_RECORD-LIFNR
                                   D_BUKRS = P_BUKRS
                          BINARY SEARCH.
              IF SY-SUBRC EQ 0.
                PERFORM BDC_FIELD   USING 'EKKO-LIFNR'
                                           WA_ZMVXREF-M_ALTKN.
              ENDIF.
              CLEAR WA_ZMVXREF.
            ENDIF.
            CLEAR WA_T024E.
            PERFORM BDC_FIELD       USING 'RM06E-EVART'
                                          WA_RECORD-EVART.
            PERFORM BDC_FIELD       USING 'EKKO-EKORG'
                                          WA_RECORD-EKORG.
            PERFORM BDC_FIELD       USING 'EKKO-EKGRP'
                                          WA_RECORD-EKGRP.
            PERFORM BDC_FIELD       USING 'RM06E-WERKS'
                                          WA_RECORD-WERKS.
            PERFORM BDC_FIELD       USING 'RM06E-LGORT'
                                          WA_RECORD-LGORT.
            PERFORM BDC_DYNPRO      USING 'SAPMM06E' '0201'.
            PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                          'EKKO-KTWRT'.
            PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                          '=AB'.
            PERFORM CONVERT_DATE USING WA_RECORD-KDATB V_CONV_DATE.
            PERFORM BDC_FIELD       USING 'EKKO-KDATB'
                                          V_CONV_DATE.
            PERFORM CONVERT_DATE USING WA_RECORD-KDATE V_CONV_DATE.
            PERFORM BDC_FIELD       USING 'EKKO-KDATE'
                                          V_CONV_DATE.
            PERFORM BDC_FIELD       USING 'EKKO-ZTERM'
                                          WA_RECORD-ZTERM.
            PERFORM BDC_FIELD       USING 'EKKO-KTWRT'
                                            WA_RECORD-KTWRT.
            VEN_FLAG = 1.
            L_MAT_INDEX = 1. "index for table-control of material
          ENDIF.
    *          "first check for itemline
          IF  WA_RECORDPREV-EPSTP NE WA_RECORD-EPSTP
           OR WA_RECORDPREV-EMATN NE WA_RECORD-EMATN
           OR WA_RECORDPREV-KTMNG NE WA_RECORD-KTMNG
           OR WA_RECORDPREV-NETPR NE WA_RECORD-NETPR
           OR WA_RECORDPREV-PEINH NE WA_RECORD-PEINH
           OR WA_RECORDPREV-BPRME NE WA_RECORD-BPRME
           OR WA_RECORDPREV-IDNLF NE WA_RECORD-IDNLF
           OR WA_RECORDPREV-WEBRE NE WA_RECORD-WEBRE
           OR WA_RECORDPREV-MEPRF NE WA_RECORD-MEPRF
           OR WA_RECORDPREV-LTEX1 NE WA_RECORD-LTEX1
           OR VEN_FLAG EQ 1.
            V_IND = L_MAT_INDEX.
            IF V_IND GT 1.
              V_IND = 2.
            ENDIF.
            CONCATENATE 'RM06E-EVRTP(' V_IND ')' INTO V_EVRTP1.
            CONCATENATE 'RM06E-EPSTP(' V_IND ')' INTO V_EPSTP1.
            CONCATENATE 'EKPO-EMATN(' V_IND ')' INTO V_EMATN1.
            CONCATENATE 'EKPO-KTMNG(' V_IND ')' INTO V_KTMNG1.
            CONCATENATE 'EKPO-NETPR(' V_IND ')' INTO V_NETPR1.
            CONCATENATE 'EKPO-PEINH(' V_IND ')' INTO V_PEINH1.
            CONCATENATE 'EKPO-BPRME(' V_IND ')' INTO V_BPRME1.
            CONCATENATE 'RM06E-TCSELFLAG(' V_IND ')' INTO V_TCSELFLAG1.
            PERFORM BDC_DYNPRO      USING 'SAPMM06E' '0220'.
            PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                          '=NP'.
            PERFORM BDC_DYNPRO      USING 'SAPMM06E' '0220'.
            PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                          V_EVRTP1.
            PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                          '=DETA'.
            PERFORM BDC_FIELD       USING V_EPSTP1
                                          WA_RECORD-EPSTP.
            PERFORM BDC_FIELD       USING V_EMATN1
                                          WA_RECORD-EMATN.
            PERFORM BDC_FIELD       USING V_KTMNG1
                                          WA_RECORD-KTMNG.
            PERFORM BDC_FIELD       USING V_NETPR1
                                          WA_RECORD-NETPR.
            PERFORM BDC_FIELD       USING V_PEINH1
                                          WA_RECORD-PEINH.
            PERFORM BDC_FIELD       USING V_BPRME1
                                          WA_RECORD-BPRME.
            PERFORM BDC_DYNPRO      USING 'SAPMM06E' '0211'.
            PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                          'EKPO-WEBRE'.
            PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                          '=DETZ'.
            PERFORM BDC_FIELD       USING 'EKPO-IDNLF'
                                          WA_RECORD-IDNLF.
            TRANSLATE WA_RECORD-EVART TO UPPER CASE.
            IF WA_RECORD-EVART EQ C_WK.
              PERFORM BDC_FIELD       USING 'EKPO-WEBRE' 'X'.
            ENDIF.
            PERFORM BDC_DYNPRO      USING 'SAPMM06E' '0212'.
            PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                          'EKPO-MEPRF'.
            PERFORM BDC_FIELD       USING 'BDC_OKCODE'
                                          '=TXP'.
            PERFORM BDC_FIELD       USING 'EKPO-MEPRF'
                                          WA_RECORD-MEPRF.
            IF NOT WA_RECORD-LTEX1 IS INITIAL. "NE space.
              PERFORM BDC_DYNPRO      USING 'SAPMM06E' '0106'.
              PERFORM BDC_FIELD       USING 'BDC_CURSOR'
                                            'RM06E-SELKZ(02)'.
              PERFORM BDC_FIELD 

  • Problem while executing app for retrieving data from EXCEL Sheet

    hi
    i have this exception while running my application of retrieving data from a Excel sheet through java application , i had also set theclasspath for jxl. jar file but where its going wrong i dont know heres my code
    import java.util.Date;
    import java.io.*;
    import jxl.*;
    import javax.swing.*;
    import java.awt.*;
    import jxl.read.biff.BiffException;
    public class testExcel2
    public static void main(String args[]) throws jxl.read.biff.BiffException
    try
    File f=new File("move.xls");
    jxl.Workbook workbook=null;
    jxl.Sheet sheet=null;
    workbook=jxl.Workbook.getWorkbook(f);
    sheet=workbook.getSheet(0);
    Cell a1 = sheet.getCell(0,0);
    String stringa1 = a1.getContents();
    System.out.println("stringshaddddddddjk "+stringa1);
    workbook.close();
    }catch(IOException ex){
    System.out.println("Error" + ex);
    catch (BiffException ex2){
    System.out.println("Error" + ex2);
    catch(IndexOutOfBoundsException ex1){
    System.out.println("Error" + ex1);
    compilation is sucees but while running its giving an EXCeption
    MicrosoftXP[Version 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.
    G:\mysfw\pgms>java testexcel2
    Exception in thread "main" java.lang.NoClassDefFoundError: testexcel2 (wrong nam
    e: testExcel2)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)

    Java is case sensitive. testexcel2 is different from testExcel2.
    G:\mysfw\pgms>java testexcel2
    Exception in thread "main" java.lang.NoClassDefFoundError: testexcel2 (wrong name: testExcel2)

Maybe you are looking for

  • How to enter symbol and on the apple tv, please

    How to seize symbol <and> on the apple tv? Thanks you

  • Ipod mini questions urgent pls answer

    wen ur ipod mini is low in battery does that affect your click wheel? cuz wen my battery was nearly flat i could bearly move the click wheel... and also wen its nearly flat and you play a song and a game can that cause it to freeze? pls reply

  • HT1222 Fails - 2014-001 - due to incompatible disk???

    Trying to udate a mac mini server running 10.7.5 using the security update 2014-001 and the install fails stating that none of the internal disks are compatible with this update. http://support.apple.com/kb/DL1727 Not quite sure how that's possible a

  • Acrobat fixup to make spots black

    In my workflow I like to set single color press jobs in black, that way if the spot color changes I don't have to mess with changing my file over and over, and also, I'm an old horse and this is the way I've always done it. (not a good reason, but a

  • Built-in iSight & External Webcam - Adjusting for both?

    I have a Microsoft LifeCam Cinema that I use when I'm at my desktop (external monitor). I find that the camera works great, but the video is squeezed into the frame. Is there any way to adjust the fit of the video in the frame?