Application Development 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: 

duplicate records

Former Member
0 Kudos

hi experts,

i need to transfer the records from three internal tables (header, item and adress data) into logical file.

here i need to send the email to the user whenever duplicate records exist in any one of the internal tables and suppose if there r duplicate records in all the internal tables then how should i approach.

regards,

siri.

2 REPLIES 2

Former Member
0 Kudos

Hai Sireesha,

For Deletion of Duplicate Records from Internal table

DELETE ADJACENT DUPLICATES FROM itab.

Additions

1. ... COMPARING f1 f2 ...

2. ... COMPARING ALL FIELDS

Effect

Deletes neighboring, duplicate entries from the internal table itab . If there are n duplicate entries, the first entry is retained and the other n - 1 entries are deleted.

Two lines are considered to be duplicated if their default keys match.

The return code value is set as follows:

SY-SUBRC = 0 At least one duplicate exists, at least one entry deleted.

SY_SUBRC = 4 No duplicates exist, no entry deleted.

Addition 1

... COMPARING f1 f2 ...

Effect

Two lines of the internal table itab are considered to be duplicates if the specified fields f1 , f2 , .... match.

Addition 2

... COMPARING ALL FIELDS

Effect

Two lines are considered to be duplicates if all fields of the table entries match.

Notes

The DELETE ADJACENT DUPLICATES statement is especially useful if the internal table itab is sorted by fields (whether in ascending or descending order) which were compared during duplicate determination. In this case, the deletion of neighbouring duplicates is the same as the deletion of all duplicates.

If a comparison criterion is only known at runtime, it can be specified dynamically as the content of a field name by using COMPARING ... (name) ... . If name is blank at runtime, the comparison criterion is ignored. If name contains an invalid component name, a runtime error occurs.

Comparison criteria - statistically or dynamically specified - can be further restriced by specifying the offset and/or length.

Note

Performance

Deleting a line from an internal table incurs index maintenance costs which depend on the index of the line to be deleted. The runtime depends on the line width of the table.

For example, deleting a line in the middle of an internal table with 200 entries requires about 10 msn (standardized microseconds).

Deleting a range of entries with " DELETE itab FROM idx1 TO idx2. " deleting a set of entries with " DELETE itab WHERE ... " only incur index maintenance costs once. Compared with a LOOP , which deletes line-by-line, this is much faster.

To delete neighboring, duplicate entries from an internal table, use the variant " DELETE ADJACENT DUPLICATES FROM itab. " instead of LOOP constructions.

For Email

DATA: OBJPACK LIKE SOPCKLSTI1 OCCURS 2 WITH HEADER LINE.

DATA: OBJHEAD LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE.

DATA: OBJBIN LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.

DATA: OBJTXT LIKE SOLISTI1 OCCURS 10 WITH HEADER LINE.

DATA: RECLIST LIKE SOMLRECI1 OCCURS 5 WITH HEADER LINE.

DATA: DOC_CHNG LIKE SODOCCHGI1.

DOC_CHNG-OBJ_NAME = 'TEST'.

DOC_CHNG-OBJ_DESCR = 'Test-Dokument fur API1 Test'(001).

OBJTXT = 'Mindestgebot : $250000'.

APPEND OBJTXT.

OBJTXT = 'Eine Abbildung des zur Versteigerung stehenden Bildes'.

APPEND OBJTXT.

OBJTXT = 'wurde als Anlage beigefugt.'.

APPEND OBJTXT.

DESCRIBE TABLE OBJTXT LINES TAB_LINES.

READ TABLE OBJTXT INDEX TAB_LINES.

DOC_CHNG-DOC_SIZE = ( TAB_LINES - 1 ) * 255 + STRLEN( OBJTXT ).

  • * ERSTELLEN DES EINTRAGS ZUM KOMPRIMIERTEN DOKUMENT

CLEAR OBJPACK-TRANSF_BIN.

OBJPACK-HEAD_START = 1.

OBJPACK-HEAD_NUM = 0.

OBJPACK-BODY_START = 1.

OBJPACK-BODY_NUM = TAB_LINES.

OBJPACK-DOC_TYPE = 'RAW'.

APPEND OBJPACK.

  • * ERSTELLEN DER ANLAGE FUR DAS DOKUMENT

OBJBIN = '\O/ '. APPEND OBJBIN.

OBJBIN = ' '. APPEND OBJBIN.

OBJBIN = ' / \ '. APPEND OBJBIN.

DESCRIBE TABLE OBJBIN LINES TAB_LINES.

OBJHEAD = 'picasso.txt'. APPEND OBJHEAD.

  • * Erstellen des Eintrags zur komprimierten Anlage

OBJPACK-TRANSF_BIN = 'X'.

OBJPACK-HEAD_START = 1.

OBJPACK-HEAD_NUM = 1.

OBJPACK-BODY_START = 1.

OBJPACK-BODY_NUM = TAB_LINES.

OBJPACK-DOC_TYPE = 'TXT'.

OBJPACK-OBJ_NAME = 'ANLAGE'.

OBJPACK-OBJ_DESCR = 'Abbildung Objekt 138'.

OBJPACK-DOC_SIZE = TAB_LINES * 255.

APPEND OBJPACK.

  • * Fullen der Empfangerliste

RECLIST-RECEIVER = SY-UNAME.

RECLIST-REC_TYPE = 'B'.

APPEND RECLIST.

CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'

EXPORTING

DOCUMENT_DATA = DOC_CHNG

PUT_IN_OUTBOX = 'X'

TABLES

PACKING_LIST = OBJPACK

OBJECT_HEADER = OBJHEAD

CONTENTS_BIN = OBJBIN

CONTENTS_TXT = OBJTXT

RECEIVERS = RECLIST

EXCEPTIONS

TOO_MANY_RECEIVERS = 1

DOCUMENT_NOT_SENT = 2

OPERATION_NO_AUTHORIZATION = 4

OTHERS = 99.

Regards

Sreeni

0 Kudos

Suppose you have an internal table t_header and work area s_header defined like your table.

clear l_dup_fnd.

sort t_header.

loop at t_header.

if t_header = s_header.

l_dup_fnd = 'X'.

endif.

move t_header to s_header.

endloop.