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

loop problem

Former Member
0 Likes
1,581

hi masters,

i have requirment where i need to fetch all the classification data.

i used a function moudle to get it and i got it into a table OBJECT_DATA.

so for a single characterisctic there are 3 values assinged to it.

ex : characteristic : CC-NOTES

-


TABIX | SMBEZ | ZAEHL | AUSP1 | ATNAM |POSNR

-


|--


|
|

|

|
--


1 | CommodityNotes | 002 | 303 | CC-NOTES | 001

1 | CommodityNotes | 003 | 333 | CC-NOTES | 001

1 | CommodityNotes | 001 | TAR083| CC-NOTES | 001

For CC-NOTES I have 3 values as we see. so i have to display 3 of them on my screen

so when i issue statement like this

ex : loop at object_data into wa.

READ TABLE object_data INTO wa WITH KEY atnam = 'CC-NOTES'.

it always looks only the first record so HOW CAN I MAKE MY STATEMENT TO READ THE SECOND RECORD?

CAN ANYONE HELP ME PLS?

THANK YOU,

PASALA.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,543

Hello,

READ statement will read only the first record it satisfies. But i dont see a reason why you are using a READ statement on the same internal table you are looping at . Either try the following


loop at object_data into wa.
if object_data-atnam = 'CC-NOTES'.
---
endif.
endloop.

else


loop at object_data into wa where atnam = 'CC-NOTES' .
---
-----
endloop.

Vikranth

14 REPLIES 14
Read only

Former Member
0 Likes
1,543

Hi,

In the read statement you give all the primary keys.

Regards,

pravin

Read only

Former Member
0 Likes
1,544

Hello,

READ statement will read only the first record it satisfies. But i dont see a reason why you are using a READ statement on the same internal table you are looping at . Either try the following


loop at object_data into wa.
if object_data-atnam = 'CC-NOTES'.
---
endif.
endloop.

else


loop at object_data into wa where atnam = 'CC-NOTES' .
---
-----
endloop.

Vikranth

Read only

0 Likes
1,543

use loop and endloop statement

Read only

Former Member
0 Likes
1,543

hi

Try this

loop at object_data into wa.

loop at object_data into wa where where atnam = 'CC-NOTES' .

endloop.

endloop.

Read only

Former Member
0 Likes
1,543

You only have to use

Loop at OBJECT_DATA  into wa where atnam = 'CC-NOTES' .
...
....
Endloop.

Read only

Former Member
0 Likes
1,543

Hi,

Why ru looping the same internal table.

If u want to print the 3 records just

loop the interanal table where characteristic value is CC-NOTES

write the what ever fields u require.

endloop.

Regards

Jai

Read only

Former Member
0 Likes
1,543

Hi,

In this case you need to loop on ur table.

Use parallel cursor concept, to enhance the performance.

Read only

Former Member
0 Likes
1,543

Please specify uour requirement.

You are looping table 'OBJECT_DATA' and reading the same table.

if you use the loop like below then you will get all the 3 records sequentially in the work area.

Loop at OBJECT_DATA into wa where atnam = 'CC-NOTES'.

-


---

endloop.

Hope this helps.

Read only

Former Member
0 Likes
1,543

hey if u want to read only second record then u can add 1 more condition ...

READ TABLE object_data INTO wa WITH KEY atnam = 'CC-NOTES'

zaehl = '003' .

else do loop for all 3 record ...

Regards,

Prakash Patel

Read only

Former Member
0 Likes
1,543

Hello,

Use loop endloop instead of read.

Read only

Former Member
0 Likes
1,543

Hi,

The only solution for this is

loop at object_data into wa where atnam = 'CC-NOTES'

-


endloop.

Read only

Former Member
0 Likes
1,543

answered by self

Read only

0 Likes
1,543

Could you please tell us how you did ?

Read only

0 Likes
1,543

Hello

This will remain great secret for us