Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

itab problem

Former Member
0 Likes
581

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....



5 REPLIES 5
Read only

Former Member
0 Likes
562

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

Read only

0 Likes
562

thank you for reply nirmal...

please let me know how can i use FOR ALL ENTRIES in more detail...

Read only

Former Member
0 Likes
562

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.

Read only

Former Member
0 Likes
562

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

Read only

Former Member
0 Likes
562

Any more suggetions please.!! if possible sample code as well....

Thanks