cancel
Showing results for 
Search instead for 
Did you mean: 

loop over table variable

Former Member
0 Kudos

  I am writing a calculation view, and unfortunately, I must loop over a table variable, because I need to update a row on the current row based on the value of the prior row (old COBOL control break logic).   How do I do this?   I tried to use a cursor and it did not work.  

Thanks,

Raphael

P.S.   I already know that this will not be the efficient, but it is the only way that I can think of to accomplish my task.   

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member184768
Active Contributor
0 Kudos

Hi Raphael,

Are you trying to write a procedure to update the table. The Calculation view is to display the data.

Can you please post your code. It will be helpful in understand why it is not working as per your expectations.

Regards,

Ravi

Former Member
0 Kudos

I am trying to do the following in a calculation view. I want to display var_out to the user.    My end logic will be much more complicated, but I can not get this basic example to work:

var_out = select salary from employee; 

v_number :=0;

for var_out as var_out do

v_number := row_var.salary+v_number;

row_var = v_number;  

end for;

I get the following error:  

Calculation View: SQL: identifier is not a cursor

Thanks,

Raphael

former_member184768
Active Contributor
0 Kudos

Hi Raphael,

Since you haven't posted the complete code, I am going ahead with some assumptions.

- The var_out in general Calculation view is the output structure. It is not a cursor defined, hence you are getting the error message.

- Secondly, what I believe is you need a procedure with SQL output (WITH RESULT VIEW). In the procedure you can update the table and then produce the output. You can refer to sample examples on Cursor in the document http://scn.sap.com/docs/DOC-27981.

Hope this helps.

Regards,

Ravi