‎2008 Feb 26 8:08 PM
I've a itab with following values
kunnr zdelval zvarval zcurval
23456
34344
43646
43553
Now I need to get all remaining values from ZTABLE
query should be like this
SELECT atwb INTO itab-zdelval FROM ZTAB
WHERE kunnr = 23456
AND zval = '0003'.
SELECT atwb INTO itab-zvarval FROM ZTAB
WHERE kunnr = 23456
AND zval = '0004'.
SELECT atwb INTO itab-zcurval FROM ZTAB
WHERE kunnr = 23456
AND zval = '0005'.
How can I write in single SELECT statement
to get all corresponding values with in loop???
please guide me....
‎2008 Feb 26 8:11 PM
Hi,
you can do this in two ways.
1) FOR ALL ENTRIES : you can use the FOR ALL ENTRIES addition to get the desired output.
2) RANGES : you can loop through the original table and fill the RANGES. then the multiple selects can be reduced using IN addition and the Ranges variable.
Regards,
Nirmal
‎2008 Feb 26 8:13 PM
thank you for reply nirmal...
please let me know how can i use FOR ALL ENTRIES in more detail...
‎2008 Feb 26 8:20 PM
Hi,
If you don't want to use 3 selects you can do that in one select.
loop at itab.
SELECT * FROM ZTAB
WHERE kunnr = itab-kunnr.
case ztab-zval.
when '003'.
...
when '004'.
....
when '004'.
....
endcase.
endselect.
endloop.
‎2008 Feb 26 10:43 PM
I think if you want to do all of this in one SELECT statement, you'll have to JOIN the ZTAB to itself 3 times.
Rob
‎2008 Feb 27 9:23 AM
Any more suggetions please.!! if possible sample code as well....
Thanks