<?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>Question Re: foreach - long runtime in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/foreach-long-runtime/qaa-p/12390599#M4636952</link>
    <description>&lt;P&gt;no, because I need to check for each position if this has moved from one cycle to the other, there are around 70k positions, and 4k cost centers.  in abap world it would be easy, but with advanced formula i am not yet familiar..... &lt;/P&gt;&lt;P&gt;thanks anyhow.&lt;/P&gt;</description>
    <pubDate>Fri, 07 May 2021 15:14:00 GMT</pubDate>
    <dc:creator>dieterzenger</dc:creator>
    <dc:date>2021-05-07T15:14:00Z</dc:date>
    <item>
      <title>foreach - long runtime</title>
      <link>https://community.sap.com/t5/technology-q-a/foreach-long-runtime/qaq-p/12390594</link>
      <description>&lt;P&gt;Hi Experts, &lt;/P&gt;
  &lt;P&gt;I have to create data model showing shifts of Positions from one cost center to another comparing two different plan cycles. I have in my primary model for each plan cycle the position id a unique record. &lt;/P&gt;
  &lt;P&gt;I created a new model having current &amp;amp; prior cost center information as separate dimension in the model.&lt;/P&gt;
  &lt;P&gt;With a Data Action i am able to create a combined records. Unfortunately i was only able doing this with a foreach statement. For my test it worked perfectly, but in the reality its not coming to an end because of high amount of positions and cost centers. Therefore i need some help how to replace the for each with a result lookup.&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;primary model&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1935477-mn1kv.png" /&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;target "shift" model&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt;after having run Cross model copy function the content looks like following. &lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1935476-jkwz5.png" /&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt;after executing data action with forereach …. the result is like below....&lt;/P&gt;
  &lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1935478-brde5.png" /&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt;Below data action&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;MEMBERSET [d/prior_cycle] = %PriorCycle%
MEMBERSET [d/current_cycle] = %CurrentCycle%
MEMBERSET [d/type] = "02"


INTEGER @lv_combi


// //-----------------------------------------------------------------------------------
// //Calculation and Data Writing
// //-----------------------------------------------------------------------------------

//=================================================================================================//
// Step 1 
//=================================================================================================//
   FOREACH.BOOKED [d/Position_], [d/current_costcenter]
 	@lv_combi = 0
  	IF RESULTLOOKUP([d/current_costcenter] = "#") != 0 THEN
  		@lv_combi = 1
  	ENDIF
  	IF @lv_combi = 1 THEN


		@lv_combi = 0
  		FOREACH [d/prior_costcenter]
  			IF RESULTLOOKUP([d/prior_costcenter] = "#") != 0 THEN
  				@lv_combi = 1
  			ENDIF
  			IF @lv_combi = 1 THEN
  		        DATA([d/type] = "14", [d/Account] = "FTE_prior") = RESULTLOOKUP([d/current_costcenter] = "#", [d/Account] = "FTE_prior")
  			ENDIF
  		ENDFOR
  	ENDIF
  ENDFOR  

//=================================================================================================//
// Step 2
//=================================================================================================//
FOREACH.BOOKED [d/Position_], [d/prior_costcenter]
	@lv_combi = 0
	IF RESULTLOOKUP([d/prior_costcenter] = "#") != 0 THEN
		@lv_combi = 1
	ENDIF
	IF @lv_combi = 1 THEN
		@lv_combi = 0
		FOREACH [d/current_costcenter]
			IF RESULTLOOKUP([d/current_costcenter] = "#") != 0 THEN
				@lv_combi = 1
			ENDIF


			IF @lv_combi = 1 THEN
				DATA([d/type] = "13", [d/Account] = "FTE_current") = RESULTLOOKUP([d/prior_costcenter] = "#", [d/Account] = "FTE_current")
			ENDIF
		ENDFOR
	ENDIF
ENDFOR
&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;Thank you &lt;/P&gt;
  &lt;P&gt;Dieter &lt;/P&gt;</description>
      <pubDate>Fri, 07 May 2021 09:17:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/foreach-long-runtime/qaq-p/12390594</guid>
      <dc:creator>dieterzenger</dc:creator>
      <dc:date>2021-05-07T09:17:17Z</dc:date>
    </item>
    <item>
      <title>Re: foreach - long runtime</title>
      <link>https://community.sap.com/t5/technology-q-a/foreach-long-runtime/qaa-p/12390595#M4636948</link>
      <description>&lt;P&gt;Dieter,&lt;/P&gt;&lt;P&gt;In my experience, when you bring in multiple dims to the FOREACH you are going to have a long run time on the DA.  When combining the dims in the FOREACH statement, you are cycling through every combination of the dims in the FOREACH.  Try removing the cost centers and leave the Position.  I think your IF statements will handle what you are trying to do in the FOREACH with the Cost Center.&lt;/P&gt;&lt;P&gt;Dan&lt;/P&gt;</description>
      <pubDate>Fri, 07 May 2021 11:23:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/foreach-long-runtime/qaa-p/12390595#M4636948</guid>
      <dc:creator>dskiendziel</dc:creator>
      <dc:date>2021-05-07T11:23:14Z</dc:date>
    </item>
    <item>
      <title>Re: foreach - long runtime</title>
      <link>https://community.sap.com/t5/technology-q-a/foreach-long-runtime/qaa-p/12390596#M4636949</link>
      <description>&lt;P&gt;Hi Dan, &lt;/P&gt;&lt;P&gt;i tried your proposal. Not sure if I understood correct, but its now creating a record for each available cost center from master data dimension.&lt;/P&gt;&lt;P&gt;the code is like :&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;MEMBERSET [d/type] = "02"
MEMBERSET [d/Position_] = "02"
INTEGER @lv_combi


// //-----------------------------------------------------------------------------------
// //Calculation and Data Writing
// //-----------------------------------------------------------------------------------


FOREACH.BOOKED [d/Position_]
	@lv_combi = 0
	IF RESULTLOOKUP([d/current_costcenter] = "#") != 0 THEN
		@lv_combi = 1
	ENDIF
	IF @lv_combi = 1 THEN
		@lv_combi = 0
		FOREACH [d/prior_costcenter]
			IF RESULTLOOKUP([d/prior_costcenter] = "#") != 0 THEN
				@lv_combi = 1
			ENDIF
			IF @lv_combi = 1 THEN
				DATA([d/type] = "24", [d/Account] = "FTE_prior") = RESULTLOOKUP([d/current_costcenter] = "#", [d/Account] = "FTE_prior")
			ENDIF
		ENDFOR
	ENDIF
ENDFOR


FOREACH.BOOKED [d/Position_]
	@lv_combi = 0
	IF RESULTLOOKUP([d/prior_costcenter] = "#") != 0 THEN
		@lv_combi = 1
	ENDIF
	IF @lv_combi = 1 THEN
		@lv_combi = 0
			IF RESULTLOOKUP([d/current_costcenter] = "#") != 0 THEN
				@lv_combi = 1
			ENDIF
			IF @lv_combi = 1 THEN
				DATA([d/type] = "23" , [d/Account] = "FTE_current") = RESULTLOOKUP([d/prior_costcenter] = "#", [d/Account] = "FTE_current")
			ENDIF
	ENDIF
ENDFOR&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;the result is like &lt;/P&gt;&lt;P&gt;&lt;IMG alt="" /&gt;&lt;/P&gt;&lt;P&gt;I have added new record type for better analysis . Record type 13 vs 23 and 14 vs 24. &lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;Dieter &lt;/P&gt;</description>
      <pubDate>Fri, 07 May 2021 14:58:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/foreach-long-runtime/qaa-p/12390596#M4636949</guid>
      <dc:creator>dieterzenger</dc:creator>
      <dc:date>2021-05-07T14:58:33Z</dc:date>
    </item>
    <item>
      <title>Re: foreach - long runtime</title>
      <link>https://community.sap.com/t5/technology-q-a/foreach-long-runtime/qaa-p/12390597#M4636950</link>
      <description>&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1935506-result.png" /&gt;&lt;/P&gt;&lt;P&gt;result immage was missing&lt;/P&gt;</description>
      <pubDate>Fri, 07 May 2021 15:01:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/foreach-long-runtime/qaa-p/12390597#M4636950</guid>
      <dc:creator>dieterzenger</dc:creator>
      <dc:date>2021-05-07T15:01:47Z</dc:date>
    </item>
    <item>
      <title>Re: foreach - long runtime</title>
      <link>https://community.sap.com/t5/technology-q-a/foreach-long-runtime/qaa-p/12390598#M4636951</link>
      <description>&lt;P&gt;I don't think I fully understand your requirement or dimensions.  But, can't you limit the cost centers you are impacting by scoping them in the MEMBERSET?  Are they grouped hierarchically or through a property?&lt;/P&gt;</description>
      <pubDate>Fri, 07 May 2021 15:09:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/foreach-long-runtime/qaa-p/12390598#M4636951</guid>
      <dc:creator>dskiendziel</dc:creator>
      <dc:date>2021-05-07T15:09:53Z</dc:date>
    </item>
    <item>
      <title>Re: foreach - long runtime</title>
      <link>https://community.sap.com/t5/technology-q-a/foreach-long-runtime/qaa-p/12390599#M4636952</link>
      <description>&lt;P&gt;no, because I need to check for each position if this has moved from one cycle to the other, there are around 70k positions, and 4k cost centers.  in abap world it would be easy, but with advanced formula i am not yet familiar..... &lt;/P&gt;&lt;P&gt;thanks anyhow.&lt;/P&gt;</description>
      <pubDate>Fri, 07 May 2021 15:14:00 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/foreach-long-runtime/qaa-p/12390599#M4636952</guid>
      <dc:creator>dieterzenger</dc:creator>
      <dc:date>2021-05-07T15:14:00Z</dc:date>
    </item>
    <item>
      <title>Re: foreach - long runtime</title>
      <link>https://community.sap.com/t5/technology-q-a/foreach-long-runtime/qaa-p/12390600#M4636953</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;You can use an allocation method to assign the value to the cost center after copying the data.&lt;/P&gt;&lt;P&gt;step to be followed&lt;/P&gt;&lt;P&gt;1. use a source dimension as cost-center and target as cost-center &lt;/P&gt;&lt;P&gt;filter account dimension with FTE_prior&lt;/P&gt;&lt;P&gt;step  &lt;/P&gt;&lt;P&gt;driver account should be FTE_Current.&lt;/P&gt;&lt;P&gt;Please let me know if you need more information.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Saurabh S.&lt;/P&gt;</description>
      <pubDate>Wed, 19 May 2021 13:20:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/foreach-long-runtime/qaa-p/12390600#M4636953</guid>
      <dc:creator>saurabh_sonawane</dc:creator>
      <dc:date>2021-05-19T13:20:21Z</dc:date>
    </item>
  </channel>
</rss>

