Skip to Content
author's profile photo Former Member
Former Member

lsmw doubt.

hi all ,

i have one excel file (.csv).

and in that i have three worksheet.

i can read the data from first worksheet using function module(alsm_excel_to_internal_table).

<b>how i read data from second worksheet into internal table.

how to fetch data from second worksheet from same excel file.</b>

help me.

thank you.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Sep 20, 2007 at 07:40 AM

    Hi,

    this might be helpful

    eport zrich_0001.

    include ole2incl.

    data: e_sheet type ole2_object.

    data: e_appl type ole2_object.

    data: e_work type ole2_object.

    data: e_col1 type ole2_object.

    data: e_col2 type ole2_object.

    data: e_cols type ole2_object.

    data: e_cell type ole2_object.

    data: e_wind type ole2_object.

    data: field_value(30) type c.

    parameters: p_file type localfile default 'C:\RichTest.xls'.

    start-of-selection.

    • Start the application

    create object e_appl 'EXCEL.APPLICATION'.

    set property of e_appl 'VISIBLE' = 1.

    • Open the file

    call method of e_appl 'WORKBOOKS' = e_work.

    call method of e_work 'OPEN'

    exporting

    #1 = p_file.

    • Write data to the excel file

    do 20 times.

    • Create the value

    field_value = sy-index.

    shift field_value left deleting leading space.

    concatenate 'Cell' field_value into field_value separated by space.

    • Position to specific cell in Column 1

    call method of e_appl 'Cells' = e_cell

    exporting

    #1 = sy-index

    #2 = 1.

    • Set the value

    set property of e_cell 'Value' = field_value .

    • Position to specific cell in Column 2

    call method of e_appl 'Cells' = e_cell

    exporting

    #1 = sy-index

    #2 = 2.

    • Set the value

    set property of e_cell 'Value' = field_value .

    • Position to specific cell in Column 3

    call method of e_appl 'Cells' = e_cell

    exporting

    #1 = sy-index

    #2 = 3.

    • Set the value

    set property of e_cell 'Value' = field_value .

    t_text-charg = itab-value.

    endcase.

    endloop.

    endif.

    append t_text.

    ENDFORM. " upload_data

    &----


    *& Form modify_table

    &----


    • Modify the table ZBATCH_CROSS_REF

    ----


    FORM modify_table.

    loop at t_text.

    t_final-werks = t_text-werks.

    t_final-cmatnr = t_text-cmatnr.

    t_final-srlno = t_text-srlno.

    t_final-matnr = t_text-matnr.

    t_final-charg = t_text-charg.

    t_final-erdat = sy-datum.

    t_final-erzet = sy-uzeit.

    t_final-ernam = sy-uname.

    t_final-rstat = 'U'.

    append t_final.

    clear t_final.

    endloop.

    delete t_final where werks = ''.

    describe table t_final lines g_line.

    sort t_final by werks cmatnr srlno.

    • Deleting the Duplicate Records

    perform select_data.

    describe table t_final lines g_line1.

    modify zbatch_cross_ref from table t_final.

    if sy-subrc ne 0.

    write:/ 'Updation failed'.

    else.

    Skip 1.

    Write:/12 'Updation has been Completed Sucessfully'.

    skip 1.

    Write:/12 'Records in file ',42 g_line .

    write:/12 'Updated records in Table',42 g_line1.

    endif.

    delete from zbatch_cross_ref where werks = ''.

    ENDFORM. " modify_table

    &----


    *& Form select_data

    &----


    • Deleting the duplicate records

    ----


    FORM select_data.

    select werks

    cmatnr

    srlno from zbatch_cross_ref

    into table t_zbatch for all entries in t_final

    where werks = t_final-werks

    and cmatnr = t_final-cmatnr

    and srlno = t_final-srlno.

    sort t_zbatch by werks cmatnr srlno.

    loop at t_zbatch.

    read table t_final with key werks = t_zbatch-werks

    cmatnr = t_zbatch-cmatnr

    srlno = t_zbatch-srlno.

    if sy-subrc eq 0.

    delete table t_final .

    endif.

    clear: t_zbatch,

    t_final.

    endloop.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.