<?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 related with loop in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-related-with-loop/m-p/7368273#M1542635</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;   Good work ... Congrats &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; This will  boost you to  and make you happy   .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Deepak&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 09 Oct 2010 11:32:40 GMT</pubDate>
    <dc:creator>deepak_dhamat</dc:creator>
    <dc:date>2010-10-09T11:32:40Z</dc:date>
    <item>
      <title>Need help related with loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-related-with-loop/m-p/7368270#M1542632</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Experts,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have written following code. The code is working fine. This code is creating records in table zhop_priority_pt. In the table the records are getting stored and priority of records is getting stored properly (zhop_priority_pt-z_prio). Every record of the table has distinct zhop_priority_pt-z_prio.  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In the  table zhop_priority_pt, I have stored location. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I have to calculate the priority (zhop_priority_pt-z_prio) seperately for each location.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For a given set of records in zhop_priority_pt, there may be say n distinct locations. So I have to create the priority list seperately for each location.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How I can do so? In my view, first of all I have to find out all distinct locations zhop_priority_pt-location.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After that for each location, I have to run the loop. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What changes should I make in the code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;IF NOT itab_prio[] IS INITIAL.
      CLEAR v_index.
      v_index = 1.
      SORT itab_prio BY z_prio_pts DESCENDING z_seniority descending z_hij_dob ascending. "


      LOOP AT itab_prio.

        MODIFY itab_prio TRANSPORTING z_prio_pts z_prio.
        if itab_prio-z_prio_pts &amp;gt; 0.
          itab_prio-z_prio = v_index.
          v_index = v_index + 1 .
          MODIFY itab_prio TRANSPORTING z_prio.
        endif.


      ENDLOOP.

      MODIFY zhop_priority_pt FROM TABLE itab_prio.
      COMMIT WORK.

    ENDIF.
  ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Gary&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Oct 2010 06:09:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-related-with-loop/m-p/7368270#M1542632</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-10-09T06:09:24Z</dc:date>
    </item>
    <item>
      <title>Re: Need help related with loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-related-with-loop/m-p/7368271#M1542633</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi gary ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SORT itab_prio BY z_prio_pts DESCENDING z_seniority descending z_hij_dob ascending.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; you are having  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;say itab having column   location ,proirity &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;       mundwa  , 9&lt;/P&gt;&lt;P&gt;       mundwa     10&lt;/P&gt;&lt;P&gt;       mundwa     7 &lt;/P&gt;&lt;P&gt;      spec            6&lt;/P&gt;&lt;P&gt;      spec           4&lt;/P&gt;&lt;P&gt;      spec           1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   sort  itab by  location descending proirity  .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   then you can also create another internal table   say itab1  having only column location and prority  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   move distinct location to itab1  .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   then  sort both table according to requirment   say    &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;sort  itab by  location descending proirity  .
  sort itab1 by location  .&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;loop at  itab .

   at new location  .

    read table itab1 with key location  = itab-location  .

   if sy-subrc = 0 .


   move  priority to itab1 .

append   itab1 .
 endif.

endat .

endloop.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;     &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can try this  .&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;Deepak.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Oct 2010 06:29:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-related-with-loop/m-p/7368271#M1542633</guid>
      <dc:creator>deepak_dhamat</dc:creator>
      <dc:date>2010-10-09T06:29:38Z</dc:date>
    </item>
    <item>
      <title>Re: Need help related with loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-related-with-loop/m-p/7368272#M1542634</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Deepak,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks. It is working fine after some minor modification. &lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Gary&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Modified Code&lt;/P&gt;&lt;P&gt;    &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;IF NOT itab_prio[] IS INITIAL.
      CLEAR v_index.
      v_index = 1.
      SORT itab_prio BY z_location z_prio_pts DESCENDING z_seniority descending z_hij_dob ascending.

      LOOP AT itab_prio.
        at new z_location.
          read table itab_prio with key
          z_location = itab_prio-z_location.

          if sy-subrc = 0.

            move itab_prio-z_location  to it_loc_pr.
            append it_loc_pr.
          endif.
        endat.
      endloop.

      SORT it_loc_pr BY location.
      DELETE ADJACENT DUPLICATES FROM it_loc_pr COMPARING location.
      loop at it_loc_pr.

        CLEAR v_index.
        v_index = 1.

        LOOP AT itab_prio where z_location = it_loc_pr-location.

        ENDLOOP.
      endloop.
      MODIFY zmyprogram_priority_pt FROM TABLE itab_prio.
      COMMIT WORK.
    ENDIF.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Oct 2010 08:07:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-related-with-loop/m-p/7368272#M1542634</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-10-09T08:07:15Z</dc:date>
    </item>
    <item>
      <title>Re: Need help related with loop</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-related-with-loop/m-p/7368273#M1542635</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;   Good work ... Congrats &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; This will  boost you to  and make you happy   .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Deepak&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 09 Oct 2010 11:32:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/need-help-related-with-loop/m-p/7368273#M1542635</guid>
      <dc:creator>deepak_dhamat</dc:creator>
      <dc:date>2010-10-09T11:32:40Z</dc:date>
    </item>
  </channel>
</rss>

