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

Alternative for below code

Former Member
0 Likes
1,080

Hi all, Please find the code.

LOOP AT it_werks.

CLEAR: it_prev, it_prev[].

SELECT

ztmm_end4~filename

ztmm_end4~werks

ztmm_end4~aedat

ztmm_end4~aezet

INTO TABLE it_prev

FROM ztmm_end4

JOIN ztmm_end3

ON ztmm_end4filename = ztmm_end3filename

WHERE ztmm_end4~werks EQ it_werks-werks

AND ztmm_end3~official EQ 'X' "only get official extracts

ORDER BY ztmm_end4~aedat DESCENDING

ztmm_end4~aezet DESCENDING.

IF sy-subrc EQ 0.

READ TABLE it_prev INDEX 1.

DELETE it_prev WHERE filename EQ it_prev-filename

AND werks EQ it_prev-werks.

READ TABLE it_prev INDEX 1.

it_prev_file-filename = it_prev-filename.

it_prev_file-werks = it_prev-werks.

APPEND it_prev_file.

CLEAR it_prev_file.

ENDIF.

ENDLOOP.

regards,

Ajay

Edited by: Ajay on Oct 7, 2008 7:09 PM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,051

Found it!

But what's your question?

9 REPLIES 9
Read only

Former Member
0 Likes
1,052

Found it!

But what's your question?

Read only

0 Likes
1,051

Hi ,

I want to delete the first filename from the internal. I want second file name directly.

But Every time i have to write Reab table index 1, then deleting from the internal.

after that I am again reading the internal table with index ,then I am getting the second

filename, How Can i Optimize the code.

regards,

Ajay

Read only

0 Likes
1,051

You might want to try just reading the table once with index 2.

Rob

Read only

0 Likes
1,051

Ajay,

Read internal table with index 2..You don't have to delete the first record..

Thanks,

Vivek

Read only

0 Likes
1,051

Hi,

I have many duplicates records in the internal table.

regards,

Ajay

Read only

0 Likes
1,051

Try sorting internal table with key and then use delete adjacent duplicates from internal table..then read the second record..

Read only

0 Likes
1,051

Hi Ajay,

sort the table by filename and werks and then use command "DELETE ADJACENT DUPLICATES". Then you eliminate all duplicates and you can use read with increasing index...

or just use instead of SELECT command "SELECT DISTINCT" so the select will not give you duplicates and with addition "UP TO 2 ROWS" because you are interested in first two records only. Then you can use read index 1 and read index 2.

Regards,

Karol

Read only

0 Likes
1,051

Thanks to Vivek and Karol.

points awarded.

regards,

Ajay

Read only

Former Member
0 Likes
1,051

can you quick explain the code or better just comment it?