2009 Aug 31 12:10 PM
Hello experts,
I'm calling a method (see example) and after receiving the returning table
I just want select one entry of this tabel. How can I do this with fast perfomrance ?
AT the moment I am doning this with a loop, but I need something faster !
DATA: EV_PARTNER TYPE BU_PARTNER.
DATA: ET_ATTRIBUTES TYPE /MRSS/T_FIELDNAME_VALUE_TAB.
DATA: RT_PARTNER TYPE /MRSS/T_PARTNER_TAB.
DATA: WA_PARTNER TYPE TABLE OF /MRSS/T_PARTNER_TAB.
DATA: WAA_PARTNER TYPE LINE OF /MRSS/T_PARTNER_TAB.
DATA: PARTNER_ROLE(2) TYPE C.
PARTNER_ROLE = 'WE'.
IF LV_PARTNER = ''.
CALL METHOD <FS_ITEM>-OBJECT->PARTNER_GET
RECEIVING
RT_PARTNER = RT_PARTNER.
LOOP AT RT_PARTNER INTO WAA_PARTNER.
IF WAA_PARTNER-PARTNER_ROLE = 'WE'.
LV_PARTNER = WAA_PARTNER-PARTNER_ID.
EXIT.
ENDIF.
ENDLOOP.
ENDIF.
Thanks,
Gerd
2009 Aug 31 12:16 PM
Hi Gerd,
the performance of the search depends on the type of table and the complexity of your search criteria.
If its just searching for an exact macth e.g. ROLE = 'WE' , then try this one:
Field-symbols: <partner> type line of /MRSS/T_PARTNER_TAB.
Read Table rt_partner assigning <partner>
with key partner_role = 'WE'. "#EC NOTEXT
if sy-subrc eq 0.
..... = <partner>-partner_id
endif.
if you interested of all hits :
loop at rt_partner assigning <partner>
where partner_role = 'WE'. "#EC NOTEXT
.....
endloop.
Hope that helps.
2009 Aug 31 12:16 PM
Hi Gerd,
the performance of the search depends on the type of table and the complexity of your search criteria.
If its just searching for an exact macth e.g. ROLE = 'WE' , then try this one:
Field-symbols: <partner> type line of /MRSS/T_PARTNER_TAB.
Read Table rt_partner assigning <partner>
with key partner_role = 'WE'. "#EC NOTEXT
if sy-subrc eq 0.
..... = <partner>-partner_id
endif.
if you interested of all hits :
loop at rt_partner assigning <partner>
where partner_role = 'WE'. "#EC NOTEXT
.....
endloop.
Hope that helps.
2009 Aug 31 1:27 PM
Hi,
Instead of looping in to a work area and then chekcing the condition , you can directly specify the condition in the loop by which the loop will only execute on those which satisfy the condition thereby making it much faster
DATA: EV_PARTNER TYPE BU_PARTNER.
DATA: ET_ATTRIBUTES TYPE /MRSS/T_FIELDNAME_VALUE_TAB.
DATA: RT_PARTNER TYPE /MRSS/T_PARTNER_TAB.
DATA: WA_PARTNER TYPE TABLE OF /MRSS/T_PARTNER_TAB.
DATA: WAA_PARTNER TYPE LINE OF /MRSS/T_PARTNER_TAB.
DATA: PARTNER_ROLE(2) TYPE C.
PARTNER_ROLE = 'WE'.
IF LV_PARTNER = ''.
CALL METHOD <FS_ITEM>-OBJECT->PARTNER_GET
RECEIVING
RT_PARTNER = RT_PARTNER.
LOOP AT RT_PARTNER where partner_role = 'WE'.
LV_PARTNER = RT_PARTNER-PARTNER_ID.
EXIT.
ENDLOOP.
Regards,
Vikranth
2009 Aug 31 1:52 PM
How many records are in the table RT_PARTNER ?
How often is it executed?
if both answers are small numbers, then you can have any problem.
If both a large, then you have a problem and there is no solution propsed.
You can apply all recoommendations, they do NOT REALLY change the behavior.
Siegfried