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

Number of rows in Excel sheet

In ABAP reports, is there any logic to find number of rows in Excel sheet.

Regards,

Naseer.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Posted on Dec 03, 2007 at 09:10 AM

    Hi,

    Use FM ALSM_EXCEL_TO_INTERNAL_TABLE to read data from excel sheet to internal table and then use describe statement to count the records from internal table.

    Regards,

    Prashant

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 03, 2007 at 09:15 AM

    Hi Naseer,

    Use sy-index or sy-dbcnt in loop processing after read from excel sheet.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 03, 2007 at 09:28 AM

    Hi,

    Try this code...

    REPORT zreport.
    
    PARAMETER p_infile LIKE rlgrap-filename DEFAULT 'C:TEMPZMPR.xls'.
    DATA : lin TYPE i.
    DATA: itab LIKE alsmex_tabline OCCURS 0 WITH HEADER LINE.
    
    START-OF-SELECTION.
      CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
        EXPORTING
          filename                = p_infile
          i_begin_col             = '1'
          i_begin_row             = '1'
          i_end_col               = '1'
          i_end_row               = '28000'
        TABLES
          intern                  = itab
        EXCEPTIONS
          inconsistent_parameters = 1
          upload_ole              = 2
          OTHERS                  = 3.
      IF sy-subrc <> 0.
        MESSAGE text-009 TYPE 'S'. "Problem uploading Excel Spreadsheet
        EXIT.
      ENDIF.
    
      DESCRIBE TABLE itab LINES lin.
    
      WRITE :/ 'Number of lines: ', lin.
    

    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.