Code: Alles auswählen.
TYPES: BEGIN OF _doc_group,
doc_id TYPE i,
count TYPE i,
END OF _doc_group,
_doc_groups TYPE SORTED TABLE OF _doc_group WITH UNIQUE KEY doc_id,
BEGIN OF _item,
doc_id TYPE i,
item_number TYPE i,
value TYPE string,
END OF _item,
_items TYPE SORTED TABLE OF _item WITH UNIQUE KEY doc_id item_number.
DATA(items) = VALUE _items(
( doc_id = 1 item_number = 1 value = 'a1' )
( doc_id = 1 item_number = 2 value = 'a2' )
( doc_id = 1 item_number = 3 value = 'a3' )
( doc_id = 2 item_number = 1 value = 'b1' )
( doc_id = 3 item_number = 1 value = 'c1' )
( doc_id = 3 item_number = 2 value = 'c2' )
( doc_id = 4 item_number = 1 value = 'd1' )
( doc_id = 5 item_number = 1 value = 'e1' )
).
DATA(result) = VALUE _doc_groups( FOR GROUPS docs OF wa IN items
GROUP BY ( doc_id = wa-doc_id
count = GROUP SIZE ) WITHOUT MEMBERS
( docs ) ).
"list all elements with COUNT
LOOP AT result INTO DATA(res).
WRITE: / res-doc_id, res-count.
ENDLOOP.
ULINE.
"Loop at elements with only 1 member
LOOP AT items INTO DATA(item)
GROUP BY ( doc_id = item-doc_id count = GROUP SIZE ) INTO DATA(doc) .
CHECK doc-count = 1.
WRITE: / doc-doc_id, doc-count.
LOOP AT GROUP doc INTO DATA(itm).
WRITE: /3 itm-item_number.
ENDLOOP.
ENDLOOP.
Code: Alles auswählen.
select DISTINCT(doc_id) from @items as items into table @data(result).
Code: Alles auswählen.
select doc_id from @items as items into table @data(result).
sort result by table_line.
delete adjacent duplicates from result comparing table_line.
Code: Alles auswählen.
SELECT doc_id FROM @items AS items
GROUP BY doc_id
HAVING COUNT( doc_id ) = 1
INTO TABLE @DATA(result) ##ITAB_DB_SELECT.