<?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: Doubt in abap report program. in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/doubt-in-abap-report-program/m-p/12123472#M1974463</link>
    <description>&lt;PRE&gt;&lt;CODE&gt;1st Method:&lt;BR /&gt;LOOP AT lt_input INTO ls_input.
 AT NEW FIELD1.
  if ls_output-field2 IS NOT INITIAL.
   APPEND ls_output to lt_output.
  endif.
   LS_OUTPUT-FIELD1 = LS_INPUT-FIELD1.
   CLEAR: LS_OUTPUT-FIELD2.
 ENDAT.
 IF LS_OUTPUT-FIELD2 IS NOT INITIAL.
   LV_TEMP = LS_OUTPUT-FIELD2.
   CLEAR: LS_OUTPUT-FIELD2.
   CONCATENATE LV_TEMP ',' LS_INPUT-FIELD2 INTO LS_OUTPUT-FIELD2.
 ELSE.
   LS_OUTPUT-FIELD2 = LS_INPUT-FIELD2.
 ENDIF.
ENDLOOP.

2nd Method&lt;BR /&gt;
LOOP AT lt_input INTO ls_input.

  lv_Current_key = ls_input-field1.

  READ TABLE LT_OUTPUT ASSIGNING &amp;lt;FS_OUTPUT&amp;gt; WITH KEY field1 = lv_current_key.

  IF sy-subrc = 0.

    "Already exists

    CONCATENATE &amp;lt;FS_OUTPUT&amp;gt;-field2 ',' ls_input-field2 INTO lv_temp.

    &amp;lt;FS_OUTPUT&amp;gt;-field2 = lv_temp.

  ELSE.

    ls_output-field1 = lv_current_key.

    ls_output-field2 = ls_input-field2.

    APPEND ls_output to lt_output.

  ENDIF.

ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 24 Oct 2019 17:23:31 GMT</pubDate>
    <dc:creator>Sourav1</dc:creator>
    <dc:date>2019-10-24T17:23:31Z</dc:date>
    <item>
      <title>Doubt in abap report program.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/doubt-in-abap-report-program/m-p/12123471#M1974462</link>
      <description>&lt;P&gt;Please can i get the logic without "GroupBY" or "Control break Statement" for the below picture.&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1741495-sap.png" /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Oct 2019 15:55:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/doubt-in-abap-report-program/m-p/12123471#M1974462</guid>
      <dc:creator>former_member657791</dc:creator>
      <dc:date>2019-10-24T15:55:06Z</dc:date>
    </item>
    <item>
      <title>Re: Doubt in abap report program.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/doubt-in-abap-report-program/m-p/12123472#M1974463</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;1st Method:&lt;BR /&gt;LOOP AT lt_input INTO ls_input.
 AT NEW FIELD1.
  if ls_output-field2 IS NOT INITIAL.
   APPEND ls_output to lt_output.
  endif.
   LS_OUTPUT-FIELD1 = LS_INPUT-FIELD1.
   CLEAR: LS_OUTPUT-FIELD2.
 ENDAT.
 IF LS_OUTPUT-FIELD2 IS NOT INITIAL.
   LV_TEMP = LS_OUTPUT-FIELD2.
   CLEAR: LS_OUTPUT-FIELD2.
   CONCATENATE LV_TEMP ',' LS_INPUT-FIELD2 INTO LS_OUTPUT-FIELD2.
 ELSE.
   LS_OUTPUT-FIELD2 = LS_INPUT-FIELD2.
 ENDIF.
ENDLOOP.

2nd Method&lt;BR /&gt;
LOOP AT lt_input INTO ls_input.

  lv_Current_key = ls_input-field1.

  READ TABLE LT_OUTPUT ASSIGNING &amp;lt;FS_OUTPUT&amp;gt; WITH KEY field1 = lv_current_key.

  IF sy-subrc = 0.

    "Already exists

    CONCATENATE &amp;lt;FS_OUTPUT&amp;gt;-field2 ',' ls_input-field2 INTO lv_temp.

    &amp;lt;FS_OUTPUT&amp;gt;-field2 = lv_temp.

  ELSE.

    ls_output-field1 = lv_current_key.

    ls_output-field2 = ls_input-field2.

    APPEND ls_output to lt_output.

  ENDIF.

ENDLOOP.&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 24 Oct 2019 17:23:31 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/doubt-in-abap-report-program/m-p/12123472#M1974463</guid>
      <dc:creator>Sourav1</dc:creator>
      <dc:date>2019-10-24T17:23:31Z</dc:date>
    </item>
    <item>
      <title>Re: Doubt in abap report program.</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/doubt-in-abap-report-program/m-p/12123473#M1974464</link>
      <description>&lt;P&gt;Why would you want it hard way? GROUP BY or control break statement is the first thing should used in this case. anw, without it you can do as follow:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;TYPES: BEGIN OF ty,
         f1 TYPE c,
         f2 TYPE c LENGTH 10,
       END OF ty.
DATA: tab1 TYPE TABLE OF ty,
      tab2 TYPE TABLE OF ty.
tab1 = VALUE #( ( f1 = 'a' f2 = 'x'  )
                ( f1 = 'b' f2 = 'y'  )
                ( f1 = 'b' f2 = 'z'  )
                ( f1 = 'b' f2 = 'w'  )
                ( f1 = 'c' f2 = 'v'  )
                ( f1 = 'c' f2 = 'u'  )
                ( f1 = 'd' f2 = 't'  )
                ( f1 = 'd' f2 = 's'  )
                ( f1 = 'e' f2 = 'q'  )
                ).
"Without group by
LOOP AT tab1 INTO DATA(wa1).
  READ TABLE tab2 ASSIGNING FIELD-SYMBOL(&amp;lt;wa2&amp;gt;) WITH KEY f1 = wa1-f1.
  "New
  IF sy-subrc &amp;lt;&amp;gt; 0.
    APPEND wa1 TO tab2.
    CONTINUE.
  ENDIF.
  "Update
  &amp;lt;wa2&amp;gt;-f2 = |{ &amp;lt;wa2&amp;gt;-f2 },{ wa1-f2 }|.
ENDLOOP.
"Write
LOOP AT tab1 INTO DATA(wa2) GROUP BY wa2-f1.
  DATA(str) = REDUCE string( INIT txt TYPE string
                             FOR grp IN GROUP wa2 NEXT txt = COND #( WHEN txt = space THEN |{ wa2-f1 }: { grp-f2 }|
                                                                     ELSE |{ txt },{ grp-f2 }| ) ).
  WRITE / str.
ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 25 Oct 2019 00:24:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/doubt-in-abap-report-program/m-p/12123473#M1974464</guid>
      <dc:creator>DoanManhQuynh</dc:creator>
      <dc:date>2019-10-25T00:24:58Z</dc:date>
    </item>
  </channel>
</rss>

