Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Alternative for below code

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

Tags:
replied

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

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question