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

Re:regarding delete adjacent

Former Member
0 Likes
493

hi friends,

again with the same program.

everyone is telling me that the program is already sorted by col1.

but here key field is col2.

if u look at col2 up to sixth row all are sorted except seventh row .

but still it is taking it as correct one .

please clear my doubt.

DATA OFF TYPE I.

DATA: BEGIN OF LINE,

COL1 TYPE I,

COL2 TYPE C,

END OF LINE.

DATA ITAB LIKE STANDARD TABLE OF LINE

WITH NON-UNIQUE KEY COL2.

LINE-COL1 = 1. LINE-COL2 = 'A'. APPEND LINE TO ITAB.

LINE-COL1 = 1. LINE-COL2 = 'A'. APPEND LINE TO ITAB.

LINE-COL1 = 1. LINE-COL2 = 'B'. APPEND LINE TO ITAB.

LINE-COL1 = 2. LINE-COL2 = 'B'. APPEND LINE TO ITAB.

LINE-COL1 = 3. LINE-COL2 = 'B'. APPEND LINE TO ITAB.

LINE-COL1 = 4. LINE-COL2 = 'B'. APPEND LINE TO ITAB.

LINE-COL1 = 5. LINE-COL2 = 'A'. APPEND LINE TO ITAB.

OFF = 0. PERFORM LIST.

DELETE ADJACENT DUPLICATES FROM ITAB COMPARING ALL FIELDS.

OFF = 14. PERFORM LIST.

DELETE ADJACENT DUPLICATES FROM ITAB COMPARING COL1.

OFF = 28. PERFORM LIST.

DELETE ADJACENT DUPLICATES FROM ITAB.

OFF = 42. PERFORM LIST.

FORM LIST.

SKIP TO LINE 3.

LOOP AT ITAB INTO LINE.

WRITE: AT /OFF LINE-COL1, LINE-COL2.

ENDLOOP.

ENDFORM.

hi friends,

again with the same program.

everyone is telling me that the program is already sorted by col1.

but here key field is col2.

if u look at col2 up to sixth row all are sorted except seventh row .

but still it is taking it as correct one .

please clear my doubt.

DATA OFF TYPE I.

DATA: BEGIN OF LINE,

COL1 TYPE I,

COL2 TYPE C,

END OF LINE.

DATA ITAB LIKE STANDARD TABLE OF LINE

WITH NON-UNIQUE KEY COL2.

LINE-COL1 = 1. LINE-COL2 = 'A'. APPEND LINE TO ITAB.

LINE-COL1 = 1. LINE-COL2 = 'A'. APPEND LINE TO ITAB.

LINE-COL1 = 1. LINE-COL2 = 'B'. APPEND LINE TO ITAB.

LINE-COL1 = 2. LINE-COL2 = 'B'. APPEND LINE TO ITAB.

LINE-COL1 = 3. LINE-COL2 = 'B'. APPEND LINE TO ITAB.

LINE-COL1 = 4. LINE-COL2 = 'B'. APPEND LINE TO ITAB.

LINE-COL1 = 5. LINE-COL2 = 'A'. APPEND LINE TO ITAB.

OFF = 0. PERFORM LIST.

DELETE ADJACENT DUPLICATES FROM ITAB COMPARING ALL FIELDS.

OFF = 14. PERFORM LIST.

DELETE ADJACENT DUPLICATES FROM ITAB COMPARING COL1.

OFF = 28. PERFORM LIST.

DELETE ADJACENT DUPLICATES FROM ITAB.

OFF = 42. PERFORM LIST.

FORM LIST.

SKIP TO LINE 3.

LOOP AT ITAB INTO LINE.

WRITE: AT /OFF LINE-COL1, LINE-COL2.

ENDLOOP.

ENDFORM.

4 REPLIES 4
Read only

Former Member
0 Likes
476

You need to sort the table on COL2.

Read only

Former Member
0 Likes
476

Hi...,

I didnt go through ur earlier thread !!!!!!!

And this program is working perfectly !!

Wats ur doubt actually ???

Before using Delete Adjacent duplicates.. we have to sort the table.

regards,

sai ramesh

Read only

0 Likes
476

my doubt is

it is working properly eventhough without sorting.

but when we are using delete adjacent entries,

before using it we should first sort the table then after that we should go for it.

here without sorting it is giving correct output.

ONETHING HERE KEY IS <b>COL2</b> NOT COL1.

Read only

Former Member
0 Likes
476

the values you are appending is already in sorted order. So if u want to see the difference append the values as below.

LINE-COL1 = 1. LINE-COL2 = 'A'. APPEND LINE TO ITAB.

LINE-COL1 = 1. LINE-COL2 = 'A'. APPEND LINE TO ITAB.

LINE-COL1 = 5. LINE-COL2 = 'A'. APPEND LINE TO ITAB.

LINE-COL1 = 1. LINE-COL2 = 'B'. APPEND LINE TO ITAB.

LINE-COL1 = 3. LINE-COL2 = 'B'. APPEND LINE TO ITAB.

LINE-COL1 = 2. LINE-COL2 = 'B'. APPEND LINE TO ITAB.

LINE-COL1 = 4. LINE-COL2 = 'B'. APPEND LINE TO ITAB.