10-21-2008 1:48 PM
Hi Experts
I have a i_tab which is defined as follows:
i_tab TYPE STANDARD TABLE OF TAB_STRUCTURE
WITH HEADER LINE
WITH NON-UNIQUE DEFAULT KEY INITIAL SIZE 0
TAB_STRUCTURE is defined as follows:
TYPES:
BEGIN OF TAB_STRUCTURE.
INCLUDE STRUCTURE /BIC/CS8ZPURVEN5.
TYPES:
cnfqty like /bic/azpurcscg00-cnfqty,
END OF TAB_STRUCTURE.
Then the i_tab is filled and loop at. In the loop is a read on the new_data itab performed. If the read is successfull is a "Move-corresponding new_data to i_tab" performed. Will this cause double data in the i_tab (will the same line be present twice in i_tab after the "Move-corresponding new_data to i_tab"?)?
clear i_tab.
refresh i_tab.
* Find key from active table.
SELECT * FROM
/bic/azpurcscg00
WHERE oi_ebeln EQ DATA_PACKAGE-doc_num AND
oi_ebelp EQ DATA_PACKAGE-doc_item AND
sched_line EQ DATA_PACKAGE-sched_line.
MOVE-CORRESPONDING /bic/azpurcscg00 to i_tab.
MOVE /bic/azpurcscg00-oi_ebeln to i_tab-doc_num.
MOVE /bic/azpurcscg00-oi_ebelp to i_tab-doc_item.
APPEND i_tab.
ENDSELECT.
SORT i_tab BY doc_num doc_item sched_line conf_line.
* Find key from new table.
LOOP at i_tab.
READ TABLE NEW_DATA WITH KEY
oi_ebeln = DATA_PACKAGE-doc_num
oi_ebelp = DATA_PACKAGE-doc_item
sched_line = DATA_PACKAGE-sched_line
conf_line = i_tab-conf_line
BINARY SEARCH.
IF sy-subrc = 0.
Move-corresponding new_data to i_tab. <--------------------------------------------
modify i_tab.
ENDIF.
ENDLOOP.
Thanks a lot in advance and kind regards,
Torben
10-21-2008 1:57 PM
The UNIQUE or NON-UNIQUE determine whether the key is to be unique or non-unique, that is, whether the table can accept duplicate entries.
If we are not specifying the key then table type is generic
a®
10-21-2008 1:57 PM
The UNIQUE or NON-UNIQUE determine whether the key is to be unique or non-unique, that is, whether the table can accept duplicate entries.
If we are not specifying the key then table type is generic
a®
10-21-2008 2:02 PM
Hi
Thanks for your reply.
Yes I'm aware of that, but what I do not know is if the line "Move-corresponding new_data to i_tab" in the code I posted can cause duplicate records.
Kind regards,
Torben
EDIT: Arh, I guess it cannot add duplicated records since the "Move-corresponding new_data to i_tab" is followed by a modify i_tab statement and not a append i_tab statement - correct?
Edited by: Torben Pedersen on Oct 21, 2008 3:09 PM
10-21-2008 2:09 PM
Yes, Your sy-subrc = 0 (after read) and table i_tab have NON_UNIQUE will create duplicate entries
a®
10-21-2008 2:16 PM
It just occured to me, that it cannot add duplicated records since the "Move-corresponding new_data to i_tab" is followed by a modify i_tab statement and not a append i_tab statement - is that correct?
10-21-2008 2:29 PM
Try to change this way
LOOP at i_tab.
v_tabix = sy-tabix
READ TABLE NEW_DATA WITH KEY
oi_ebeln = DATA_PACKAGE-doc_num
oi_ebelp = DATA_PACKAGE-doc_item
sched_line = DATA_PACKAGE-sched_line
conf_line = i_tab-conf_line
BINARY SEARCH.
IF sy-subrc = 0.
Move-corresponding new_data to i_tab.
" Here after the read your sy-tabix value get changed so use v_tabix instead of sy-tabix
modify i_tab index v_tabix " .
ENDIF.
ENDLOOP.
a®