‎2008 Oct 07 6:09 PM
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
‎2008 Oct 07 6:11 PM
‎2008 Oct 07 6:11 PM
‎2008 Oct 07 6:14 PM
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
‎2008 Oct 07 6:22 PM
You might want to try just reading the table once with index 2.
Rob
‎2008 Oct 07 6:24 PM
Ajay,
Read internal table with index 2..You don't have to delete the first record..
Thanks,
Vivek
‎2008 Oct 07 6:27 PM
Hi,
I have many duplicates records in the internal table.
regards,
Ajay
‎2008 Oct 07 6:37 PM
Try sorting internal table with key and then use delete adjacent duplicates from internal table..then read the second record..
‎2008 Oct 07 6:41 PM
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
‎2008 Oct 07 6:46 PM
‎2008 Oct 07 6:12 PM