2014 Jul 15 6:52 AM
All,
I have the following code While executing system is pointing to sy-tabix, but the data I am getting in the READ statement is from last record in the internal table
report z_9699_30.
tables : eket.
types : begin of ty_eket.
include structure eket.
types: end of ty_eket.
data: wa_eket type ty_eket.
data: it_eket like sorted table of wa_eket
with unique key primary_key
components ebeln ebelp etenr
with non-unique sorted key secondary_key
components ebeln ebelp.
parameters: p_ebeln like eket-ebeln.
parameters: p_ebelp like eket-ebelp.
select * from eket into table it_eket
where ebeln eq p_ebeln.
read table it_eket into wa_eket with table key secondary_key
components ebeln = p_ebeln
ebelp = p_ebelp.
Please copy and execute this by giving EBELN and EBELP from EKET
Please make sure while selecting from EKET please select data of multiple records available for same EBELP ie llike
Here below PO # 4500000003 and for Item # 00030 is have multiple records
Here in selection screen by giving PO # as 4500000003 (EBELN) Item # as 00030 (EBELP) , then in the above READ statement system giving SY-TABIX as 3 but if you see the WA_EKET-ETENR is showing 2 instead of 1. This is where is the issue is
EBELN | EBELP | ETENR | Header 4 |
---|---|---|---|
4500000003 | 00010 | 1 | |
4500000003 | 00020 | 1 | |
4500000003 | 00030 | 1 | |
4500000003 | 00030 | 2 |
2014 Jul 15 7:31 AM
Hi,
I have the same issue with an IDES.
Maybe the reason is the secondary index have only one entry, the last one, and the TABIX is the line readed by the secondary index.
Regards
Fred
2014 Jul 15 8:24 AM
Hi,
The SAP documentation clearly saying it will read the first records if it having more than 1 record
2014 Jul 15 8:46 AM
Hello Abaper,
Its unexpected behaviour as regular ,
i also test in ides have out put,, i expect as it is sorted table system might found record in sy-tabix 3 but it search record having same key so we gat 4th row data in work area.
2014 Jul 15 9:02 AM
Hi,
I like to have experts in this forum, like to give their opinion whether it is SAP bug or its my code Bug.?
Thanks
aRs.
2014 Jul 15 4:31 PM
2014 Jul 15 7:41 PM
You'll have to wait more than 90 minutes before you get a response. Maybe even a few days.
2014 Jul 16 3:18 PM
Now execute some
MOVE sy_tabix TO lv_index.
READ TABLE it_eket INTO wa_eket
INDEX lv_index USING KEY secondary_key.
BREAK-POINT.
READ TABLE it_eket INTO wa_eket
INDEX lv_index USING KEY primary_key.
BREAK-POINT.
and conclude yourself on the meaning of life index with two different keys defined...
Regards,
Raymond
PS: Reference in online help for sy-tabix now
Note that the sy-tabix system field is populated by the assigned secondary index, if sorted secondary keys are used. If this value is used for the subsequent index access to the internal table, the same table index must be explicitly used here. If used implicitly, the value would be interpreted as a primary index.
2014 Jul 16 4:27 PM
Hi,
I am not fully understood your comment
that means we should not use declaration like the following
data: wa_eket type ty_eket.
data: it_eket like sorted table of wa_eket
with unique key primary_key
components ebeln ebelp etenr
with non-unique sorted key secondary_key
components ebeln ebelp.
Please correct if i wrongly understood.
Thanks
aRs