cancel
Showing results for 
Search instead for 
Did you mean: 

Looping in calculation view

former_member182337
Participant
0 Kudos

Hello Experts,

Good day!

Can you please suggest the best way to handle Loop/Append/Endloop in Calculation view.

Example - Say, i have 10 records in my ITAB and if ITAB-COLUMN1 is 'AB' then i need to append a new record with COLUMN1 as 'AC' and few of the other fields in the work area cleared. If ITAB-COLUMN1 is 'AD' then i need to read another table and append records accordingly.

I searched for loop in calculation view and saw few posts regarding usage of calculated column but am not sure how to handle multiple checks like mentioned above.

Please suggest.

Thank you in advance.

Regards,

Prem

View Entire Topic
lbreddemann
Active Contributor

"Can you please suggest the best way to handle Loop/Append/Endloop in Calculation view"

You really should try to avoid looping.

For the example, you described, you don't need a loop but could cover the different conditions by several SQL commands, e.g.

  • conditional joins (one outer join per condition)
  • case joins (join target depending on case evaluation)
  • union (arbitrary "appending" of records)
  • multiple table variables

and combinations of these.

It will require you to rethink how the business requirement is mapped to a technical implementation (i.e. the looping is one way to implement the solution but it's neither the only way nor is it identical with the requirement).

former_member182337
Participant
0 Kudos

Thanks Lars. Will try the options mentioned.