Upload XLS File, Loop through rows query a DB

What I would like to do is enable the user to upload an excel
spreadsheet with one column and many row of IP's. Then put the ips
in a list or array and loop through the list and query a table to
get the IPs that match the list.
Any help would be greatly appreciated.

We have some similar apps except that, instead of uploading a
file, the users copy and paste the column into a text area. Then we
do this:
<!--- First, replace carraige returns (chr(13)) and line
feeds (char(10)) with commas --->
<cfset
hscnumbers=Replace(form.hscnumbers,chr(13)&chr(10),",","ALL")>
<!--- remove last comma, if commas exist (there may be
only one hsc number) --->
<cfif find(",", hscnumbers) gt 0 and right(hscnumbers, 1)
is ",">
<cfset hscnumbers = left(hscnumbers, len(hscnumbers) -
1)>
</cfif>
And then we have a list to send to the db.

Similar Messages

  • Upload .xls file in internal table in web dynpro abap

    Hi everyone,
    i want to upload .xls(excel file) into an internal table.....after lots of attempts i came to a conclusion that web dynpro only supports .CSV(another format of excel file) to be uploaded into internal table....i tried many ways....is there a way i can upload .xls file...kindly help me in the same. following is the code i m using
      DATA LO_EL_CONTEXT TYPE REF TO IF_WD_CONTEXT_ELEMENT.
      DATA LS_CONTEXT TYPE WD_THIS->ELEMENT_CONTEXT.
      DATA ITEM_FILE TYPE WD_THIS->ELEMENT_CONTEXT-EXCEL_UPLOAD.
      get element via lead selection
      LO_EL_CONTEXT = WD_CONTEXT->GET_ELEMENT( ).
      @TODO handle not set lead selection
      IF LO_EL_CONTEXT IS INITIAL.
      ENDIF.
      get single attribute
      LO_EL_CONTEXT->GET_ATTRIBUTE(
        EXPORTING
          NAME =  `EXCEL_UPLOAD`
        IMPORTING
          VALUE = ITEM_FILE ). "xstring format
    DATA S_CONT TYPE STRING.
    DATA CONVT TYPE REF TO CL_ABAP_CONV_IN_CE.
    DATA: FIELDS1 TYPE STRING_TABLE.
    1st tried this code-> using "cl_abap_conv_in_ce"
    CALL METHOD cl_abap_conv_in_ce=>create
    EXPORTING
    *encoding = c_encoding "optional
    input = ITEM_FILE
    RECEIVING
    conv = CONVT.
    CALL METHOD CONVT->read
    IMPORTING
    data = S_CONT.
    when it didnt work out...then tried followin function module
      CALL FUNCTION 'HR_KR_XSTRING_TO_STRING'
        EXPORTING
          IN_XSTRING        = ITEM_FILE "xsrting
       IMPORTING
         OUT_STRING          = S_CONT
    TYPES: BEGIN OF TY_TAB,
           NAME_CHAR TYPE  STRING,
           DESCR_CHAR TYPE  STRING,
           NUMBER_DIGITS TYPE  STRING,
           END OF TY_TAB.
    DATA: FIELDS TYPE STRING_TABLE.
    DATA: LV_FIELD TYPE STRING.
    DATA: S_TABLE TYPE STRING_TABLE.
    DATA: ITAB TYPE TABLE OF TY_TAB.
    DATA: STR_ITAB TYPE TY_TAB.
    *splits string based on new line
    SPLIT S_CONT AT CL_ABAP_CHAR_UTILITIES=>CR_LF INTO TABLE S_TABLE.
    FIELD-SYMBOLS: <WA_TABLE> LIKE LINE OF S_TABLE.
    LOOP AT S_TABLE ASSIGNING <WA_TABLE>.
    splits string on basis of tabs
      SPLIT <WA_TABLE> AT ',' INTO
                      STR_ITAB-NAME_CHAR
                      STR_ITAB-DESCR_CHAR
                      STR_ITAB-NUMBER_DIGITS.
      APPEND STR_ITAB TO ITAB.
    ENDLOOP.
    I am able to do the uploading if the file is in .CSV format and not .XLS format....
    there are lots of forums on SDN for the same....but at the end there is no solution provided.....
    experts kindly solve it this time...thanks in advance

    Hi,
    It is not possible to upload an xls file because it will be having some binary characters. better to go with .csv file format.
    Refer this [link too|Re: Excel File Uplaod] it will explain you clearly.
    Regards
    Arun.P

  • Downloading .xls file with multiple rows and Columns

    Hi ALL,
    I need to genarate .xls file with multiple rows and and Columns and sent as an email.Since our customer having Problem with .CSV files need to genarate .XLS file.
    Please do the needful.
    Thanks
    Madhu

    Hi Madhu,
    You might also consider using Excel Spreadsheet XML as the target structure (namespace is urn:schemas-microsoft-com:office:spreadsheet).  When you double-click the resulting xml on a PC it automatically opens with Excel. So, users don't see a difference.  It will open up a lot of options with formatting including creating multiple worksheets if you wanted to.  Best of all you can stick with XML.
    See my response in this thread:
    Re: Convert XML data into XLS 
    Thanks,
    -Russ

  • Loop Through Rows in SQL Report.

    Hello Everyone,
    I've been creating a very different application, and I've run into quite the roadblock.
    Let me give you a breif about the problem.
    I have a form that needs to be dynamic and thus is created at runtime.
    I have used the APEX_ITEM and a SQL SELECT CASE to create a dynamic report.
    For example if the DATATYPE column in my table says DATE, I create an APEX_ITEM.DATE_POPUP, if it says CHAR i create a textbox, and if a column called
    LOV is populated APEX_ITEM.SELECT_LIST_FROM_QUERY using the number value of the LOV to query a List of Values from another table.
    Now this brings me to say in a single column of the there could be different data_types. meaning the multi-row update functionality with apex will not work.
    Getting the data to display is easy. However saving the updates is a different story.
    Which brings me to my question. Does anybody know of way in which you can loop through each row in a SQL Report on APEX and assess each row individually.
    I'd like to accomplish something like this
    LOOP
    MyUpdateProcedure(currentrow_id,currentrow_datatype, currentrow_value)
    Go to Next Row in Report
    END LOOP;
    Pretty simple in theory? Do we have an APEX expert out there who could give me a hand with this?

    Codes,
    It sounds to me like you could add a hidden field to tell you what you need to know in order to determine the column to update.
    Assuming it was created using the parameter p_idx = 50 and contained the names you provided (eg DATA_DATA) and your primary key is created using p_idx = 1 then you could add the logic for the update into an on submit process something like so
    FOR i IN 1 .. apex_application.g_f01.COUNT
    LOOP
    CASE apex_application.g_f50(i)
    WHEN 'DATA_DATA' THEN
    -- run the update against the data column
    WHEN 'CHAR_DATA' THEN
    -- run the update against the char column
    etc.
    If the multi-type column is created with the apex_item api using p_idx = 2 then you just refer to it in the loop as apex_application.g_f02(i) and the primary key is apex_application.g_f01(i).
    I hope this helps.
    Greg

  • Upload xls file issue

    HI Experts ,   i am uploading data from xls file , the problem is that if the xls file is in edit mode , the system goes  in indefinite loop or hang state ,  is there any way  or function module to determine whether the xls file is being edited or open .
    Thanks in advance.

    are you using Function Module for this? If yes, just uncomment the exceptions, problem will be solved, i suppose.
    Regards,
    Sam

  • Looping through row selector exonentially duplicating

    Using Apex 4.2
    Background
    Created a Tabular Form based on a view. Removed all the default multi-row updates and deletions, buttons and processes.
    I am using a tabular form because of the fact that I can gain access to a row selector.
    The row data itself is all read only so in effect this is a report with a row selector.
    This is because I can't find a way to select a row an interactive report, well I can and did but this was a work around.
    Problem
    I have created a button to process the selector to run the below code:
    begin
    kdm_adm_utils.log ('Page', 'XKDM: WF: Current Development', 'Selected Check Boxes:'||wwv_flow.g_f01(1)) ;
    kdm_adm_utils.log ('Page', 'XKDM: WF: Current Development', 'Selected Check Boxes:'||wwv_flow.g_f02(1)) ;
       for i in 1..wwv_flow.g_f01.count
       loop
       kdm_adm_utils.log ('Page', 'XKDM: WF: Current Development', 'i:'||i) ;
          kdm_adm_utils.log ('Page', 'XKDM: WF: Current Development', 'WF ID:'|| wwv_flow.g_f02 (wwv_flow.g_f01.count)) ;
       end loop;
    end;
    I just wanted to see what would be output. For one row this works fantastically and I can find the ID based on the row
    When I select more than one row the loop run's through for the number of rows but then also runs for the number of rows selected.
    So if I selected threee rows this above procedure would run three times, each times looping three times.
    I have set the execution scope to: For Created and Modified Rows in the button condition that appears.
    Required
    I only want to loop through the selected rows once per button click
    OR
    Know which row I am currently looping through.
    Really would appreciate some kind of input here.

    I think the built in selector is making your life harder because the information that contains is 1,2,3,4,5.  You then need to map 3 to the ID of your 3rd row.
    So, if you check row 1 and 3, on submit, the row selector will have two rows, one with value of 1 and with with value of 3.
    I would remove the selector, use and ID column that I can change to be Simple Checkbox (or whatever value you can use to uniquely identify it).  Or add your own apex_item.checkbox(n, ID) to your SQL.
    Then your loop on apex_application.g_f01.count (if that's the checkbox column) will only contain the elements checked and their values will be the ID that are checked.
    All that said, here's a useful example from Denes Kubicek
    http://apex.oracle.com/pls/otn/f?p=31517:95
    Hope this makes sense
    Thanks
    -Jorge
    http://rimblas.com/blog/
    Message was edited by: jrimblas
    Added link to Denes example page

  • How to loop through rows in datatable?

    Hi,
    I have a datatable component with a few columns bound to a database table but I have also added a new textfield column to the datatable. The purpose of this datatable is to present the user with a list of products from the database and then allow the user to enter a quantity value into the textfield for each product (ie datatable row).
    This all works fine until i need to capture the quantity values the user has entered. It seems the datatable component can only provide the current row details. However what I want to do is when the user finishes entering the quantities for all the products they click a button and then I loop through each row in the datatable from start to end and find out what quantities were entered for each product.
    I can find no documentation or threads on how to do this. It seems like a very basic concept but perhaps is not possible to achieve. Can anyone help?
    Also I entered a default value of "0" in the value expression (ie text) property of the new textfield in the datatable but this value never appears (ie the textfields are always empty). However the text property seems to work ok for normal textfield components not within a datatable. Any ideas?
    Thanks.

    thanks, I am able to iterate through the datatable rows now and get the values, however I still have one (actually two) big problem...
    1. I cannot get the textfields to be prepopulated with a value when the page first loads. I have the text property of the textfield set to a value but this makes no difference, the textfields are always blank.
    2. After a user enters values and clicks the button to calculate the page reloads and again all entered values are gone (ie the damn textfields are empty again). Is this normal behaviour for textfields within a datatable....surely not.
    So, I added some code to my prerender method to specifically populate the textfields and although it loops through each textfield only the last textfield gets populated. I cannot work this one out. Datatables should be easy to work with, but like most things Creator turns an easy job into an impossible one.
    Please help.

  • Cannot upload xls file in a Document in SAP DMS

    Hello Guru,
    I have tried to upload a excel file in an existing Document AA00-0123 in both SAP Easy DMS and GUI both i was now able to upload the file having same error message telling "An error occured while creating the original attribute for" how can i upload this excel file to my DMS document? please help.
    Thanks

    Hi,
    1) R U able to upload any other file type to the DIR AA00-0123 (word/ppt/pdf etc) ?
    2) Can u Create a new DIR and try uploading the same excel file? does that get created?
    once u do the above just let me know.
    Regards
    Abhishek
    Edited by: AAYNI_AK on Nov 11, 2011 11:33 AM

  • Upload xls file in application server

    Dear ALL
    I have a requirement in which I need to create Excel file on SAP
    Application Server using OPEN DATASET command. As I have to run the program and create the file in background mode, I can't use 'WS_DOWNLOAD' or 'DOWNLOAD' functions.  When I can create the file with .xls addition on the application server,
    all the fields in the file appear in the same column. How can place them in different  columns as one field in one Excel cell?

    Hi,
    Yes you can try doing like,
    DATA: c_tab TYPE c VALUE cl_abap_char_utilities=>horizontal_tab,
          c_ret TYPE c VALUE cl_abap_char_utilities=>cr_lf.
      itab1-f1 = 'AA'. itab1-f2 = '01'. APPEND itab1.
      itab1-f1 = 'BB'. itab1-f2 = '02'. APPEND itab1.
      itab1-f1 = 'CC'. itab1-f2 = '03'. APPEND itab1.
      itab2-f1 = 'ZZ'. itab2-f2 = '26'. APPEND itab2.
      itab2-f1 = 'YY'. itab2-f2 = '25'. APPEND itab2.
      LOOP AT itab1.
        CONCATENATE itab1-f1 itab1-f2 INTO objbin1 separated BY c_tab.
        CONCATENATE c_ret objbin1 INTO objbin1.
        APPEND objbin1.
      ENDLOOP.
      LOOP AT itab2.
        CONCATENATE itab2-f1 itab2-f2 INTO objbin2 separated BY c_tab.
        CONCATENATE c_ret objbin2 INTO objbin2.
        APPEND objbin2.
      ENDLOOP.
      LOOP AT objbin1.
        MOVE objbin1-line TO objbin_final-line.
        APPEND objbin_final.
      ENDLOOP.
    And then you can use open dataset and transfer statements to download internal table data in AS.
    Hope it helps
    Regards
    Mansi

  • How to loop through a query using LINQPAD?

    I have this query in LINQPAD:
    SELECT TIME_TEST+TIME_STEP AS Productive_Time
    FROM PFODS.PPL_TESTSYSTEMS_UTILISATION
    WHERE (SYSTEMTYPE = '0005-064') AND
    (TS_START >= to_date('13/01/2014', 'DD/MM/YYYY'))
    AND (TS_End <= to_date('18/01/2014 00:1:59', 'DD/MM/YYYY HH24:MI:SS')) AND MONO != '9999999999'
    Order by TS_START ASC
    However, I need to extract out the SELECT SUM(TIME_TEST+TIME_STEP) as ProductiveTime on a daily basis, and thus I need to execute those below codes each time to extract out each day values. How do I combine those into 1 single query such that each day data
    can be displayed? Do I need to write a loop inside the WHERE condition?
    SELECT SUM(TIME_TEST+TIME_STEP) as ProductiveTime
    FROM PFODS.PPL_TESTSYSTEMS_UTILISATION
    WHERE (SYSTEMTYPE = '0005-064') AND
    (TS_START >= to_date('13/01/2014', 'DD/MM/YYYY'))
    AND (TS_End <= to_date('14/01/2014 00:1:59', 'DD/MM/YYYY HH24:MI:SS')) AND MONO != '9999999999'
    Order by TS_START ASC
    SELECT SUM(TIME_TEST+TIME_STEP) as ProductiveTime
    FROM PFODS.PPL_TESTSYSTEMS_UTILISATION
    WHERE (SYSTEMTYPE = '0005-064') AND
    (TS_START >= to_date('14/01/2014', 'DD/MM/YYYY'))
    AND (TS_End <= to_date('15/01/2014 00:1:59', 'DD/MM/YYYY HH24:MI:SS')) AND MONO != '9999999999'
    Order by TS_START ASC
    SELECT SUM(TIME_TEST+TIME_STEP) as ProductiveTime
    FROM PFODS.PPL_TESTSYSTEMS_UTILISATION
    WHERE (SYSTEMTYPE = '0005-064') AND
    (TS_START >= to_date('15/01/2014', 'DD/MM/YYYY'))
    AND (TS_End <= to_date('16/01/2014 00:1:59', 'DD/MM/YYYY HH24:MI:SS')) AND MONO != '9999999999'
    Order by TS_START ASC
    SELECT SUM(TIME_TEST+TIME_STEP) as ProductiveTime
    FROM PFODS.PPL_TESTSYSTEMS_UTILISATION
    WHERE (SYSTEMTYPE = '0005-064') AND
    (TS_START >= to_date('16/01/2014', 'DD/MM/YYYY'))
    AND (TS_End <= to_date('17/01/2014 00:1:59', 'DD/MM/YYYY HH24:MI:SS')) AND MONO != '9999999999'
    Order by TS_START ASC
    SELECT SUM(TIME_TEST+TIME_STEP) as ProductiveTime
    FROM PFODS.PPL_TESTSYSTEMS_UTILISATION
    WHERE (SYSTEMTYPE = '0005-064') AND
    (TS_START >= to_date('17/01/2014', 'DD/MM/YYYY'))
    AND (TS_End <= to_date('18/01/2014 00:1:59', 'DD/MM/YYYY HH24:MI:SS')) AND MONO != '9999999999'
    Order by TS_START ASC
    In addition to display the SUM(TIME_TEST+TIME_STEP) for each day, I also need to display the date itself.
    I do no want (cannot) to write anything on Stored Procedure, and I can only write simple query.
    thanks. 

    Use a loop like the code below
    DateTime startDate = DateTime.Parse("1/1/14");
    DateTime endDate = DateTime.Parse("2/16/14");
    int numberOfDays = (endDate - startDate).Days + 1;
    for (int dateCount = 0; dateCount < numberOfDays; dateCount++)
    DateTime currentDate = startDate.AddDays(dateCount);
    Even better use a dictionary like in the code below
    static void Main(string[] args)
    DataTable table = new DataTable();
    Dictionary<DateTime, List<DataRow>> dict = table.AsEnumerable()
    .GroupBy(x => x.Field<DateTime>("TS_START").Date, x => x)
    .ToDictionary(x => x.Key, x => x.ToList());
    Console.WriteLine("Date ProductiveTime Comment");
    Console.WriteLine("========== ==========");
    foreach(DateTime date in dict.Keys)
    List<DataRow> dateRows = dict[date];
    int productiveTime = dateRows.AsEnumerable()
    .Select(x => x.Field<int>("PRODUCTIVE_TIME"))
    .ToList().Sum();
    int firstRow = table.Rows.IndexOf(dateRows[0]);
    int LastRow = table.Rows.IndexOf(dateRows[dateRows.Count - 1]);
    Console.WriteLine("{0} {1} Row{2} to Row{3}",
    date.ToShortDateString(), productiveTime.ToString(),
    firstRow.ToString(), LastRow.ToString());

  • Loop through result set and delete row

    so here is what I need -
    I have a query that pulls rows from the Database through a stored procedure.(these are properties in an area)
    Before I start looping through the query, I need to check the distance between my current location and the property. If it less than 5 miles, only then should I display that property. The distance in miles will be chosen while submitting the search form.
    So is there a way to delete rows from the result set based on the criteria? Or
    Is there a better way to accomplish this? I am using the the google api to get the latitudes and longitudes. The other issue to keep in mind is the load time.
    Thanks

    You can do this the easy way or the hard way.  Depends on whether your condition that needs to be checked can be expressed in the form of a SQL where clause.  If it can, then do what BKBK suggested, and use a query of query to create a new resultset that only has the rows from the original resultset that don't meet your condition.
    If the calculation of the condition is more complex, then do a CFLOOP over the query and examine each row to see if you want to keep it or toss it.  if you want to toss it, the delete that row - there is a function in CFLIB.ORG called querydeleterow that should help you.  Or, you could just clear out the row's contents and then do the query of query as described in BKBK's post to create a new resultset that doesn't include the blank rows.

  • Upload excel file (xls) into internal table in SRM 4.0

    Hi experts!
    I need upload a xls file into internal table (in ABAP report) in EBP machine for i work with data in the sheets. Can you help me?
    Best Regard!

    Hi Zeky,
    Try GUI_UPLOAD method of the class CL_GUI_FRONTEND_SERVICES
    or FM ALSM_EXCEL_TO_INTERNAL_TABLE
    Please look at this threads too:
    /people/thomas.jung3/blog/2004/09/02/creating-a-bsp-extension-for-downloading-a-table
    Upload XLS file from Application server into internal table.
    Regards,
    Marcin Gajewski
    please reward points for helpful answers

  • Loop through values in rows to find faulty data

    Hi all,
    We have a column which is supposed to have values in increasing order.(If it doesn't comply with this rule, we want to discard the row). How do I loop through rows for a particular column, in SQL or PL.SQL?
    Thanks.

    user12295995 wrote:
    If it doesn't comply with this rule, we want to discard the rowNot sure what you mean. It looks like you want to get rid of duplicates. If so, use:
    DELETE tbl WHERE ROWID NOT IN (SELECTMIN(ROWID) FROM tbl GROUP BY col)
    /If you want to identify gaps, use:
    with t as (
               select 1 id from dual union all
               select 2 id from dual union all
               select 3 id from dual union all
               select 4 id from dual union all
               select 5 id from dual union all
               select 11 id from dual union all
               select 12 id from dual union all
               select 13 id from dual union all
               select 21 id from dual union all
               select 22 id from dual union all
               select 23 id from dual
    select  '[' || (prev_id + 1) || ' - ' || (id - 1) || ']' gap
      from  (
             select  id,
                     lag(id) over(order by id) prev_id
               from  t
      where id > prev_id + 1
      order by id
    GAP
    [6 - 10]
    [14 - 20]
    SQL> SY.

  • Converting '.xls' file to '.txt' in BDC Session method

    Hi gurus,
    Happy DIWALIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII------',','
    Please help me in converting '.xls' file to '.txt' in BDC Session method. Is there is any method or function module for this conversion. Please help me with coding.
    Thanks and regards,

    Hi
    File->save as -> Save as type ( text tab delimted.txt) ->Click on yes .
    Now open .txt file -> here data will be tab delimted.
    genrally i use tab delimted file to upload the data.
    Even if you want to programtically then get the data from xls file to Internal table,now use concatenate with comma ,now download it.
    Check the below program :
    Upload xls file and you can see .txt file ( with comma delimted)
    Input ( XLS file )
    aaa 1245 2344 233 qwww
    233 2222 qwww www www
    Output ( .txt file with comma delimted)
    aaa,1245,2344,233,qwww
    233,2222,qwww,www,www
    REPORT ZFII_MISSING_FILE_UPLOAD no standard page heading.
    data : begin of i_text occurs 0,
    text(1024) type c,
    end of i_text.
    Internal table for File data
    data : begin of i_data occurs 0,
    field1(10) type c,
    field2(10) type c,
    field3(10) type c,
    field4(10) type c,
    field5(10) type c,
    end of i_data.
    data : begin of i_download occurs 0,
    text(1024) type c,
    end of i_download.
    data : v_lines type sy-index.
    data : g_repid like sy-repid.
    data v_file type string.
    data: itab like alsmex_tabline occurs 0 with header line.
    data : g_line like sy-index,
    g_line1 like sy-index,
    $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 '65536',
    gd_currentrow type i.
    selection-screen : begin of block blk with frame title text.
    parameters : p_file like rlgrap-filename obligatory.
    selection-screen : end of block blk.
    initialization.
    g_repid = sy-repid.
    at selection-screen on value-request for p_file.
    CALL FUNCTION 'F4_FILENAME'
    EXPORTING
    PROGRAM_NAME = g_repid
    IMPORTING
    FILE_NAME = p_file.
    start-of-selection.
    Uploading the data into Internal Table
    perform upload_data.
    download the file into comma delimted file.
    perform download_data.
    *& Form upload_data
    text
    --> p1 text
    <-- p2 text
    FORM upload_data.
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
    EXPORTING
    FILENAME = p_file
    I_BEGIN_COL = $v_start_col
    I_BEGIN_ROW = $v_start_row
    I_END_COL = $v_end_col
    I_END_ROW = $v_end_row
    TABLES
    INTERN = itab
    EXCEPTIONS
    INCONSISTENT_PARAMETERS = 1
    UPLOAD_OLE = 2
    OTHERS = 3.
    IF SY-SUBRC <> 0.
    write:/10 'File '.
    ENDIF.
    if sy-subrc eq 0.
    read table itab index 1.
    gd_currentrow = itab-row.
    loop at itab.
    if itab-row ne gd_currentrow.
    append i_data.
    clear i_data.
    gd_currentrow = itab-row.
    endif.
    case itab-col.
    when '0001'.
    first Field
    i_data-field1 = itab-value.
    second field
    when '0002'.
    i_data-field2 = itab-value.
    Third field
    when '0003'.
    i_data-field3 = itab-value.
    fourth field
    when '0004'.
    i_data-field4 = itab-value.
    fifth field
    when '0005'.
    i_data-field5 = itab-value.
    endcase.
    endloop.
    endif.
    append i_data.
    ENDFORM. " upload_data
    *& Form download_data
    text
    --> p1 text
    <-- p2 text
    FORM download_data.
    loop at i_data.
    concatenate i_data-field1 ',' i_data-field2 ',' i_data-field3 ','
    i_data-field4 ',' i_data-field5 into i_download-text.
    append i_download.
    clear : i_download,
    i_data.
    endloop.
    CALL FUNCTION 'GUI_DOWNLOAD'
    EXPORTING
    BIN_FILESIZE =
    FILENAME =
    'C:\Documents and Settings\smaramreddy\Desktop\fff.txt'
    FILETYPE = 'ASC'
    APPEND = ' '
    WRITE_FIELD_SEPARATOR = ' '
    HEADER = '00'
    TRUNC_TRAILING_BLANKS = ' '
    WRITE_LF = 'X'
    COL_SELECT = ' '
    COL_SELECT_MASK = ' '
    DAT_MODE = ' '
    IMPORTING
    FILELENGTH =
    TABLES
    DATA_TAB = i_download
    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.
    ENDFORM. " download_data
    Regards
    Pavan

  • Problem reading .xls file from App Server

    Hi Everyone......
    I hope this might be a common problem but i searched for similar problem......i did'nt find the solution my problem is
    I'm trying to download .xls(excel file data into an internal table using OPEN DATASET FOR INPUT IN TEXT MODE ENCODING DEFUALT and read dataset for reading it).But in the read dataset syntax all stange values like **$#@&&& are getting uploaded???? I dont now why......
    Is it happing because i'm trying to upload .XLS file ???
    My coding is as follows...........
      OPEN DATASET p_file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
        IF sy-subrc NE 0.
          IF sy-batch IS INITIAL.
            MESSAGE i001(zz) WITH 'Error opening file for upload'.
            EXIT.
          ELSE.
            MESSAGE s001(zz) WITH 'Error opening file for upload'.
            EXIT.
          ENDIF.
        ENDIF.
    *First Uploading the data into structure
        DO.
          READ DATASET p_file INTO l_wa_tab.   "My internal table work area
          IF sy-subrc = 0.
            APPEND l_wa_tab TO  l_tab.
          ELSE.
            EXIT.
          ENDIF.
          ADD 1 TO count.
        ENDDO.
        CLOSE DATASET p_file.
    Any solution for above problem.........

    Hi,
    Check whether path ur providing to the open data set stmt is correct or not in debugging mode.
    * File upload to internal table from UNIX Directory
        IF NOT p_i1file IS INITIAL AND NOT p_path IS INITIAL.
          CONCATENATE p_path p_i1file INTO v_file.
          CONDENSE v_file.
          OPEN DATASET v_file FOR INPUT IN TEXT MODE MESSAGE v_msg.
          IF sy-subrc EQ 0.
            WRITE:  / 'INPUT FILE CONTAINS NO RECORD :'(010), v_file.
            DO.
              CLEAR tbl_input.
              READ DATASET v_file INTO tbl_input.
              IF sy-subrc NE 0.
                EXIT.
              ELSE.
                APPEND tbl_input.
              ENDIF.
            ENDDO.
    * Close Input File
            CLOSE DATASET v_file.
          ELSE.
            WRITE:/'Error uploading file: '(008),v_file.
            STOP.
          ENDIF.
        ENDIF.
    It should work.check the sy-subrc value and file value in debug mode.
    Thanks
    Parvathi

Maybe you are looking for