<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Need help in processing an excel into SAP in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-in-processing-an-excel-into-sap/m-p/7445686#M1552250</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you can use the std fun modules given by SAP.&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'&lt;/P&gt;&lt;P&gt;'GUI_UPLOAD'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;what is the reason for you to go for Z func modl and also so much coding.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 20 Dec 2010 06:44:19 GMT</pubDate>
    <dc:creator>former_member242255</dc:creator>
    <dc:date>2010-12-20T06:44:19Z</dc:date>
    <item>
      <title>Need help in processing an excel into SAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-in-processing-an-excel-into-sap/m-p/7445685#M1552249</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Im uploading an excel file from presentation server to SAP...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now the problem is hw to know how many records are there in the excel file..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have coded like below...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;w_max = '65536'.

  w_counter_lo = '2'.    "Start on row 1 because of header row
  w_increment  = '9999'. "Increment by 9999 each loop

  w_counter_hi = w_counter_lo + w_increment.

WHILE w_counter_hi &amp;lt;= w_max AND w_counter_lo &amp;lt;= w_max.
    " Clear the work area and the internal table to prevent duplicate rows
    CLEAR it_import_table.
    CALL FUNCTION 'ZPM_EXCEL_TO_INTERNAL_TABLE'
      EXPORTING
        filename                = p_file
        i_begin_col             = '1'
        i_begin_row             = w_counter_lo "we have a header row
        i_end_col               = '5'
        i_end_row               = w_counter_hi
      TABLES
        intern                  = it_import_table
      EXCEPTIONS
        inconsistent_parameters = 1
        upload_ole              = 2
        OTHERS                  = 3.
    "Increment our range
    w_counter_lo = w_counter_hi + 1.
    w_counter_hi = w_counter_lo + w_increment.

    "We SHOULD NOT scan any more than our max, so set our top end of the range
    "to the total number of rows to scan if the w_Counter_hi exceeds the max.
    IF w_counter_hi &amp;gt; w_max.
      w_counter_hi = w_max.
    ENDIF.

  ENDWHILE.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Considering the excel file would contain not more than 65536 records have coded like above...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But the problem is sometimes the file may contain lesser records say 10000 records even then also the while ..endwhile executes to check the last record( until 65536 records)..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;pls help me to handle this..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Priya&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Dec 2010 06:40:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-in-processing-an-excel-into-sap/m-p/7445685#M1552249</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-12-20T06:40:24Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in processing an excel into SAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-in-processing-an-excel-into-sap/m-p/7445686#M1552250</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you can use the std fun modules given by SAP.&lt;/P&gt;&lt;P&gt;CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'&lt;/P&gt;&lt;P&gt;'GUI_UPLOAD'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;what is the reason for you to go for Z func modl and also so much coding.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Dec 2010 06:44:19 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-in-processing-an-excel-into-sap/m-p/7445686#M1552250</guid>
      <dc:creator>former_member242255</dc:creator>
      <dc:date>2010-12-20T06:44:19Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in processing an excel into SAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-in-processing-an-excel-into-sap/m-p/7445687#M1552251</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Use the FM --&amp;gt; TEXT_CONVERT_XLS_TO_SAP&lt;/P&gt;&lt;P&gt;This will give you the excel into an internal table , then delete the rows that are greater then ur requirement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Madhukar Shetty&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Dec 2010 06:54:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-in-processing-an-excel-into-sap/m-p/7445687#M1552251</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-12-20T06:54:48Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in processing an excel into SAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-in-processing-an-excel-into-sap/m-p/7445688#M1552252</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Suppose If I use the standard Fm ALSM_EXCEL_TO_INTERNAL_TABLE only...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tell me what value to pass to        &lt;STRONG&gt;" i_end_row "&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My question is how to trace the no: of records of the exceel file..sothat I can pass the value to I_END_ROW...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Priya&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Dec 2010 07:03:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-in-processing-an-excel-into-sap/m-p/7445688#M1552252</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-12-20T07:03:12Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in processing an excel into SAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-in-processing-an-excel-into-sap/m-p/7445689#M1552253</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Priya,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We did had the requirement quite similar as of your's. Hope this code snippet helps you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;  DATA: STR_LEN TYPE I.
  STR_LEN = STRLEN( P_FILENM ).
  STR_LEN = STR_LEN - 4.
  IF P_FILENM+STR_LEN(4) = '.XLS' or P_FILENM+STR_LEN(4) = '.xls'.
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      EXPORTING
        FILENAME                = P_FILENM
        I_BEGIN_COL             = 1
        I_BEGIN_ROW             = 1
        I_END_COL               = 2
        I_END_ROW               = 10000
      TABLES
        INTERN                  = IT_EXCEL
      EXCEPTIONS
        INCONSISTENT_PARAMETERS = 1
        UPLOAD_OLE              = 2
        OTHERS                  = 3.
    

*-- Sagregate Excel Data into the Internal Table
    LOOP AT it_excel.
      CHECK it_excel-row NE '0001'.
      IF it_excel-col = '0001'.
        MOVE it_excel-value TO IT_INPUT-POSID.
      ELSEIF it_excel-col = '0002'.
        MOVE it_excel-value TO IT_INPUT-PSPRI.
      ENDIF.

      AT END OF row.

        APPEND  IT_INPUT.
        CLEAR   IT_INPUT.
*      v_excel = v_excel + 1.
      ENDAT.
    ENDLOOP&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: K.Manas on Dec 20, 2010 8:35 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Dec 2010 07:35:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-in-processing-an-excel-into-sap/m-p/7445689#M1552253</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-12-20T07:35:35Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in processing an excel into SAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-in-processing-an-excel-into-sap/m-p/7445690#M1552254</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Whenever there is SY-SUBRC fail the EXIT the While Loop.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;WHILE &amp;lt;condition&amp;gt;.
    CALL FUNCTION 'ZPM_EXCEL_TO_INTERNAL_TABLE'.
      IF SY-SUBRC NE 0.
        EXIT.  "to exit the WHILE loop
      ENDIF.
ENDWHILE.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Dec 2010 10:41:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-in-processing-an-excel-into-sap/m-p/7445690#M1552254</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-12-20T10:41:11Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in processing an excel into SAP</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-in-processing-an-excel-into-sap/m-p/7445691#M1552255</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;w_max = '65536'.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;  w_counter_lo = '2'.    "Start on row 1 because of header row&lt;/P&gt;&lt;P&gt;  w_increment  = '9999'. "Increment by 9999 each loop&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;  w_counter_hi = w_counter_lo + w_increment.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;before reading your file you want to know how many rows are there in excel file. put this code here.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;*******************************************&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; TYPES:&lt;/P&gt;&lt;P&gt;   truxs_t_text_data(4096) TYPE c OCCURS 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  DATA:&lt;/P&gt;&lt;P&gt;     lv_var TYPE  truxs_t_text_data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'&lt;/P&gt;&lt;P&gt;    EXPORTING&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    I_FIELD_SEPERATOR          =&lt;/P&gt;&lt;/LI&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;    I_LINE_HEADER                   =&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;      i_tab_raw_data                   = lv_var&lt;/P&gt;&lt;P&gt;      i_filename                            = p_file  * path of file&lt;/P&gt;&lt;P&gt;    TABLES&lt;/P&gt;&lt;P&gt;      i_tab_converted_data        = t_record&lt;/P&gt;&lt;P&gt;  EXCEPTIONS&lt;/P&gt;&lt;P&gt;    conversion_failed            = 1&lt;/P&gt;&lt;P&gt;    OTHERS                           = 2 .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;here you will get all records in t_record internal table.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;    MESSAGE 'Error in Uploading the specified file.' TYPE 'I'.&lt;/P&gt;&lt;P&gt; ELSE.&lt;/P&gt;&lt;P&gt;    DESCRIBE TABLE t_record LINES w_counter_hi&lt;/P&gt;&lt;P&gt; ENDIF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;refresh t_record.&lt;/P&gt;&lt;UL&gt;&lt;LI level="1" type="ul"&gt;&lt;P&gt;So, now you have no of lines in w_counter_hi variable.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;*******************************************&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;WHILE w_counter_hi &amp;lt;= w_max AND w_counter_lo &amp;lt;= w_max.&lt;/P&gt;&lt;P&gt;    " Clear the work area and the internal table to prevent duplicate rows&lt;/P&gt;&lt;P&gt;    CLEAR it_import_table.&lt;/P&gt;&lt;P&gt;    CALL FUNCTION 'ZPM_EXCEL_TO_INTERNAL_TABLE'&lt;/P&gt;&lt;P&gt;      EXPORTING&lt;/P&gt;&lt;P&gt;        filename                = p_file&lt;/P&gt;&lt;P&gt;        i_begin_col             = '1'&lt;/P&gt;&lt;P&gt;        i_begin_row             = w_counter_lo "we have a header row&lt;/P&gt;&lt;P&gt;        i_end_col               = '5'&lt;/P&gt;&lt;P&gt;        i_end_row               = w_counter_hi&lt;/P&gt;&lt;P&gt;      TABLES&lt;/P&gt;&lt;P&gt;        intern                  = it_import_table&lt;/P&gt;&lt;P&gt;      EXCEPTIONS&lt;/P&gt;&lt;P&gt;        inconsistent_parameters = 1&lt;/P&gt;&lt;P&gt;        upload_ole              = 2&lt;/P&gt;&lt;P&gt;        OTHERS                  = 3.&lt;/P&gt;&lt;P&gt;    "Increment our range&lt;/P&gt;&lt;P&gt;    w_counter_lo = w_counter_hi + 1.&lt;/P&gt;&lt;P&gt;    w_counter_hi = w_counter_lo + w_increment.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;    "We SHOULD NOT scan any more than our max, so set our top end of the range&lt;/P&gt;&lt;P&gt;    "to the total number of rows to scan if the w_Counter_hi exceeds the max.&lt;/P&gt;&lt;P&gt;    IF w_counter_hi &amp;gt; w_max.&lt;/P&gt;&lt;P&gt;      w_counter_hi = w_max.&lt;/P&gt;&lt;P&gt;    ENDIF.&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;  ENDWHILE.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;PD&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Dec 2010 12:23:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-in-processing-an-excel-into-sap/m-p/7445691#M1552255</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-12-20T12:23:29Z</dc:date>
    </item>
  </channel>
</rss>

