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: 

How to get fast one entry of an returning table ?

gerd_hotz
Contributor
0 Kudos

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

1 ACCEPTED SOLUTION

Marcel_Wahl
Advisor
Advisor
0 Kudos

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.

3 REPLIES 3

Marcel_Wahl
Advisor
Advisor
0 Kudos

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.

Former Member
0 Kudos

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

former_member194613
Active Contributor
0 Kudos

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