on 2016 May 09 6:48 AM
Hi experts,
I have created the following table in my AMDP as below. I want to loop at the table and fetch the contents to fill the variables:
tab1 = SELECT mandt AS client,
col1 as Column1,
col2 as Column2
FROM DB_Table WHERE col1 = :input_parameter;
Now I want to implement the following logic:
If Column2 IS ' ' "Column2 returned from the query is BLANK
Then query again.
However I am not sure how to get the work area from the internal table tab1. Please help. Also I want to know how to set up a WHILE loop for the above scenario.
Regards,
Shalini
Request clarification before answering.
Hi,
SQLScript is not ABAP. You should use a different approach and use CASE WHEN within your SQL statement. For some circumstances you can use the CURSOR.
Greetz
Silvio
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Haehner,
Yes, I used the cursor to loop over my table entries. However I want to append these into a new table.
How can I repeatedly insert into a same table?
say, result:
(tab is populated from cursor row)
result = select * from :result
union Select * from :tab;
Here I would get an error on the first line - I want to do this inside a for loop and keep adding entries to result table.
Regards,
Shalini
Hi,
Just to be clear: With inserting you mean populating in result and not inserting in a physical table?
Assuming the first:
The syntax of code seems correct, except I would use a union all. But if its resulting in an error in the first line... Hm
Can you use temporary tables in your project?
These you can use like any other tables. In your scenario:
insert into <temp_table> (select * from :tab);
Silvio
User | Count |
---|---|
33 | |
22 | |
17 | |
8 | |
7 | |
5 | |
4 | |
4 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.