<?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: uploading excel sheet and using control break statement. in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/uploading-excel-sheet-and-using-control-break-statement/m-p/12517621#M2004463</link>
    <description>&lt;P&gt;But again the 2nd(item No.) column should also get sorted and and summed up.&lt;/P&gt;&lt;P&gt;for every item number there should be one entry.&lt;/P&gt;</description>
    <pubDate>Tue, 08 Mar 2022 13:44:18 GMT</pubDate>
    <dc:creator>pritam_baboo49</dc:creator>
    <dc:date>2022-03-08T13:44:18Z</dc:date>
    <item>
      <title>uploading excel sheet and using control break statement.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/uploading-excel-sheet-and-using-control-break-statement/m-p/12517618#M2004460</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2028814-capture.png" /&gt;&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;I need to upload this excel file into sap and get the output in the below format using control break statement. but while using sum with 'at end of' event the negative values are getting summed up. For each doc item only one record and it should get added or substracted according to debit or credit.&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/2028816-capture1.png" /&gt; &lt;/CODE&gt;&lt;/PRE&gt;
  &lt;PRE&gt;&lt;CODE&gt;TYPE-POOLS: truxs.&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;BR /&gt;TYPES: BEGIN OF str_exceldata,
  &lt;BR /&gt;col_1 TYPE vbeln_va,
  &lt;BR /&gt;col_2 TYPE i,
  &lt;BR /&gt;col_3 TYPE c,
  &lt;BR /&gt;col_4 TYPE i,
  &lt;BR /&gt;END OF str_exceldata.
  &lt;BR /&gt;
  &lt;BR /&gt;DATA: it_excel TYPE TABLE OF str_exceldata,
  &lt;BR /&gt;wa_excel TYPE str_exceldata,
  &lt;BR /&gt;wa_temp TYPE str_exceldata,
  &lt;BR /&gt;wa_temp2 TYPE str_exceldata,
  &lt;BR /&gt;it_data TYPE truxs_t_text_data.
  &lt;BR /&gt;
  &lt;BR /&gt;
  &lt;BR /&gt;PARAMETERS: p_file TYPE rlgrap-filename.
  &lt;BR /&gt;
  &lt;BR /&gt;AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
  &lt;BR /&gt;CALL FUNCTION 'F4_FILENAME'
  &lt;BR /&gt;EXPORTING
  &lt;BR /&gt;* PROGRAM_NAME = SYST-CPROG
  &lt;BR /&gt;* DYNPRO_NUMBER = SYST-DYNNR
  &lt;BR /&gt;field_name = 'P_FILE'
  &lt;BR /&gt;IMPORTING
  &lt;BR /&gt;file_name = p_file.
  &lt;BR /&gt;IF sy-subrc &amp;lt;&amp;gt; 0.
  &lt;BR /&gt;* Implement suitable error handling here
  &lt;BR /&gt;ENDIF.
  &lt;BR /&gt;START-OF-SELECTION.
  &lt;BR /&gt;CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
  &lt;BR /&gt;EXPORTING
  &lt;BR /&gt;* I_FIELD_SEPERATOR =
  &lt;BR /&gt;i_line_header = 'X'
  &lt;BR /&gt;i_tab_raw_data = it_data
  &lt;BR /&gt;i_filename = 'C:\Users\admin\Desktop\ControlBreak.xlsx.'
  &lt;BR /&gt;TABLES
  &lt;BR /&gt;i_tab_converted_data = it_excel
  &lt;BR /&gt;EXCEPTIONS
  &lt;BR /&gt;conversion_failed = 1
  &lt;BR /&gt;OTHERS = 2.
  &lt;BR /&gt;IF sy-subrc &amp;lt;&amp;gt; 0.
  &lt;BR /&gt;* Implement suitable error handling here
  &lt;BR /&gt;ENDIF.
  &lt;BR /&gt;SORT it_excel BY col_1 col_2.
  &lt;BR /&gt;
  &lt;BR /&gt;LOOP AT it_excel INTO wa_excel.
  &lt;BR /&gt;IF wa_excel-col_3 = 'D'.
  &lt;BR /&gt;wa_excel-col_4 = wa_excel-col_4 * -1.
  &lt;BR /&gt;ENDIF.
  &lt;BR /&gt;wa_temp = wa_excel.
  &lt;BR /&gt;AT FIRST.
  &lt;BR /&gt;WRITE: /'Balance Sheet'.
  &lt;BR /&gt;ENDAT.
  &lt;BR /&gt;AT NEW col_1.
  &lt;BR /&gt;WRITE: / 'Document Number Doc No. Balance'.
  &lt;BR /&gt;ENDAT.
  &lt;BR /&gt;LOOP at it_excel INTO wa_temp2.
  &lt;BR /&gt;at END OF col_2.
  &lt;BR /&gt;SUM.
  &lt;BR /&gt;wa_temp = wa_temp2.
  &lt;BR /&gt;ENDAT.
  &lt;BR /&gt;endloop.
  &lt;BR /&gt;WRITE: / wa_temp-col_1, wa_temp-col_2, wa_temp-col_4.
  &lt;BR /&gt;
  &lt;BR /&gt;AT END OF col_1.
  &lt;BR /&gt;SUM.
  &lt;BR /&gt;WRITE: / 'Subtotal', wa_excel-col_4.
  &lt;BR /&gt;ENDAT.
  &lt;BR /&gt;
  &lt;BR /&gt;AT LAST.
  &lt;BR /&gt;SUM.
  &lt;BR /&gt;WRITE:/ 'Grand Total', wa_excel-col_4.
  &lt;BR /&gt;ENDAT.
  &lt;BR /&gt;
  &lt;BR /&gt;ENDLOOP.</description>
      <pubDate>Mon, 07 Mar 2022 11:52:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/uploading-excel-sheet-and-using-control-break-statement/m-p/12517618#M2004460</guid>
      <dc:creator>pritam_baboo49</dc:creator>
      <dc:date>2022-03-07T11:52:11Z</dc:date>
    </item>
    <item>
      <title>Re: uploading excel sheet and using control break statement.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/uploading-excel-sheet-and-using-control-break-statement/m-p/12517619#M2004461</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;TYPE-POOLS: truxs.&lt;/CODE&gt;&lt;/PRE&gt;&lt;BR /&gt;TYPES: BEGIN OF str_exceldata,&lt;BR /&gt;                col_1 TYPE vbeln_va,&lt;BR /&gt;                col_2 TYPE i,&lt;BR /&gt;                col_3 TYPE c,&lt;BR /&gt;                col_4 TYPE i,&lt;BR /&gt;       END OF str_exceldata.&lt;BR /&gt;&lt;BR /&gt;DATA: it_excel TYPE TABLE OF str_exceldata,&lt;BR /&gt;      wa_excel TYPE str_exceldata,&lt;BR /&gt;      wa_temp TYPE str_exceldata,&lt;BR /&gt;      wa_temp2 TYPE str_exceldata,&lt;BR /&gt;      it_data TYPE truxs_t_text_data.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;PARAMETERS: p_file TYPE rlgrap-filename.&lt;BR /&gt;&lt;BR /&gt;AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.&lt;BR /&gt;  CALL FUNCTION 'F4_FILENAME'&lt;BR /&gt;    EXPORTING&lt;BR /&gt;*     PROGRAM_NAME  = SYST-CPROG&lt;BR /&gt;*     DYNPRO_NUMBER = SYST-DYNNR&lt;BR /&gt;      field_name    = 'P_FILE'&lt;BR /&gt;    IMPORTING&lt;BR /&gt;      file_name     = p_file.&lt;BR /&gt;  IF sy-subrc &amp;lt;&amp;gt; 0.&lt;BR /&gt;* Implement suitable error handling here&lt;BR /&gt;  ENDIF.&lt;BR /&gt;START-OF-SELECTION.&lt;BR /&gt;CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'&lt;BR /&gt;    EXPORTING&lt;BR /&gt;*     I_FIELD_SEPERATOR    =&lt;BR /&gt;      i_line_header        = 'X'&lt;BR /&gt;      i_tab_raw_data       = it_data&lt;BR /&gt;      i_filename           = 'C:\Users\admin\Desktop\ControlBreak.xlsx.'&lt;BR /&gt;    TABLES&lt;BR /&gt;      i_tab_converted_data = it_excel&lt;BR /&gt;    EXCEPTIONS&lt;BR /&gt;      conversion_failed    = 1&lt;BR /&gt;      OTHERS               = 2.&lt;BR /&gt;  IF sy-subrc &amp;lt;&amp;gt; 0.&lt;BR /&gt;* Implement suitable error handling here&lt;BR /&gt;  ENDIF.&lt;BR /&gt;  SORT it_excel BY col_1 col_2.&lt;BR /&gt;&lt;BR /&gt;  LOOP AT it_excel INTO wa_excel.&lt;BR /&gt;    IF wa_excel-col_3 = 'D'.&lt;BR /&gt;      wa_excel-col_4 = wa_excel-col_4 * -1.&lt;BR /&gt;    ENDIF.&lt;BR /&gt;  wa_temp = wa_excel.&lt;BR /&gt;    AT FIRST.&lt;BR /&gt;      WRITE: /'Balance Sheet'.&lt;BR /&gt;    ENDAT.&lt;BR /&gt;    AT NEW col_1.&lt;BR /&gt;      WRITE: / 'Document Number    Doc No.     Balance'.&lt;BR /&gt;    ENDAT.&lt;BR /&gt;LOOP at it_excel INTO wa_temp2.&lt;BR /&gt;at END OF col_2.&lt;BR /&gt;SUM.&lt;BR /&gt;wa_temp = wa_temp2.&lt;BR /&gt;  ENDAT.&lt;BR /&gt;  endloop.&lt;BR /&gt;    WRITE: / wa_temp-col_1, wa_temp-col_2, wa_temp-col_4.&lt;BR /&gt;&lt;BR /&gt;    AT END OF col_1.&lt;BR /&gt;      SUM.&lt;BR /&gt;      WRITE: / 'Subtotal', wa_excel-col_4.&lt;BR /&gt;    ENDAT.&lt;BR /&gt;&lt;BR /&gt;    AT LAST.&lt;BR /&gt;      SUM.&lt;BR /&gt;      WRITE:/ 'Grand Total', wa_excel-col_4.&lt;BR /&gt;    ENDAT.&lt;BR /&gt;&lt;BR /&gt;  ENDLOOP.</description>
      <pubDate>Mon, 07 Mar 2022 11:53:42 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/uploading-excel-sheet-and-using-control-break-statement/m-p/12517619#M2004461</guid>
      <dc:creator>pritam_baboo49</dc:creator>
      <dc:date>2022-03-07T11:53:42Z</dc:date>
    </item>
    <item>
      <title>Re: uploading excel sheet and using control break statement.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/uploading-excel-sheet-and-using-control-break-statement/m-p/12517620#M2004462</link>
      <description>&lt;P&gt;Please merge your code into your question, and please select your code and press the button [CODE], which makes the code appear colored/indented, it will be easier for people to look at it. Thank you!&lt;/P&gt;&lt;P&gt;NB: SUM is still not deprecated, but I would recommend not using it because it's more obvious to anyone what means "subtotal = subtotal + amount", and "total = total + subtotal", and less prone to errors and questions...&lt;/P&gt;</description>
      <pubDate>Mon, 07 Mar 2022 12:39:29 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/uploading-excel-sheet-and-using-control-break-statement/m-p/12517620#M2004462</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2022-03-07T12:39:29Z</dc:date>
    </item>
    <item>
      <title>Re: uploading excel sheet and using control break statement.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/uploading-excel-sheet-and-using-control-break-statement/m-p/12517621#M2004463</link>
      <description>&lt;P&gt;But again the 2nd(item No.) column should also get sorted and and summed up.&lt;/P&gt;&lt;P&gt;for every item number there should be one entry.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Mar 2022 13:44:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/uploading-excel-sheet-and-using-control-break-statement/m-p/12517621#M2004463</guid>
      <dc:creator>pritam_baboo49</dc:creator>
      <dc:date>2022-03-08T13:44:18Z</dc:date>
    </item>
    <item>
      <title>Re: uploading excel sheet and using control break statement.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/uploading-excel-sheet-and-using-control-break-statement/m-p/12517622#M2004464</link>
      <description>&lt;P&gt;Sorry I can't read your code (missing indentation and color). I suggest that you write easy and understandable code like:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;LOOP AT input_lines ASSIGNING FIELD-SYMBOL(&amp;lt;input_line&amp;gt;).
  ASSIGN aggregated_lines[ doc_number = &amp;lt;input_line&amp;gt;-doc_number
                           item_no    = &amp;lt;input_line&amp;gt;-item_no ]
        TO FIELD-SYMBOL(&amp;lt;aggregated_line&amp;gt;).
  IF sy-subrc &amp;lt;&amp;gt; 0. " not found
    INSERT VALUE #( doc_number = &amp;lt;input_line&amp;gt;-doc_number
                    item_no    = &amp;lt;input_line&amp;gt;-item_no )
          INTO TABLE aggregated_lines
          ASSIGNING &amp;lt;aggregated_line&amp;gt;.
  ENDIF.
  &amp;lt;aggregated_line&amp;gt;-amount = &amp;lt;aggregated_line&amp;gt;-amount + &amp;lt;input_line&amp;gt;-...
ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Then calculate the sub-totals and grand total.&lt;/P&gt;&lt;P&gt;Then generate the Excel file.&lt;/P&gt;&lt;P&gt;It will make your life easier to have simple code, organized in several sections, and using meaningful names.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Mar 2022 16:16:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/uploading-excel-sheet-and-using-control-break-statement/m-p/12517622#M2004464</guid>
      <dc:creator>Sandra_Rossi</dc:creator>
      <dc:date>2022-03-08T16:16:06Z</dc:date>
    </item>
  </channel>
</rss>

