Application Development and Automation 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: 
Read only

Better approach

Former Member
0 Likes
1,310

Hi,

I have a select statement within which a perform is called. This is decreasing the efficiency. how could i avoid this. I have pasted the code below. please let me know.

***********************************************************

select devclass object obj_name

into corresponding fields of tadir from tadir

where ( devclass like 'Y%' or devclass like 'Z%' )

and object in r_objtypes

and devclass ne '$TMP'.

i_obj-devclass = tadir-devclass. (i_obj is an internal table)

i_obj-object = tadir-object.

i_obj-obj_name = tadir-obj_name.

perform get_desc using i_obj-object i_obj-obj_name

changing i_obj-obj_desc.

append i_obj.

clear i_obj.

end select.

************************

form get_desc using value(p_object)

value(p_obj_name)

changing p_obj_desc type c.

case p_object.

when 'PROG'.

select single text into p_obj_desc from trdirt

where name = p_obj_name and sprsl = sy-langu.

when 'TABL'.

select single ddtext into p_obj_desc from dd02t

where tabname = p_obj_name

and ddlanguage = sy-langu.

when 'FUGR'.

select single areat into p_obj_desc from tlibt

where area = p_obj_name and spras = sy-langu.

when 'DOMA'.

select single ddtext into p_obj_desc from dd01t

where domname = p_obj_name

and ddlanguage = sy-langu.

when 'DTEL'.

select single ddtext into p_obj_desc from dd04t

where rollname = p_obj_name

and ddlanguage = sy-langu.

when 'VIEW' or 'ENQU'.

select single ddtext into p_obj_desc from dd25t

where viewname = p_obj_name

and ddlanguage = sy-langu.

when 'SHLP'.

select single ddtext into p_obj_desc from dd30t

where shlpname = p_obj_name

and ddlanguage = sy-langu.

when 'MSAG'.

select single stext into p_obj_desc from t100a

where arbgb = p_obj_name

and masterlang = sy-langu.

when 'DEVC'.

select single ctext into p_obj_desc from tdevct

where devclass = p_obj_name and spras = sy-langu.

when 'FUNC'.

select single stext into p_obj_desc from tftit

where funcname = p_obj_name.

when 'SUSO'.

select single ttext into p_obj_desc from tobjt

where object = p_obj_name and langu = sy-langu.

when 'TRAN'.

select single ttext into p_obj_desc from tstct

where tcode = p_obj_name and sprsl = sy-langu.

endcase.

endform.

Thanks and Regards

sanath

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,276

Try this way:

[code]select devclass object obj_name

into corresponding fields of table i_obj "tadir from tadir

where ( devclass like 'Y%' or devclass like 'Z%' )

and object in r_objtypes

and devclass ne '$TMP'.

loop at i_obj.

perform get_desc using i_obj-object i_obj-obj_name

changing i_obj-obj_desc.

modify i_obj.

endloop.[/code]

If the first 3 fields of internal table i_obj are devclass, object & obj_name - modify the select statment as below:

[code]select devclass object obj_name

into table i_obj "tadir from tadir

where ( devclass like 'Y%' or devclass like 'Z%' )

and object in r_objtypes

and devclass ne '$TMP'.[/code]

Regards

Eswar

Hi,

I have a select statement within which a perform is called. This is decreasing the efficiency. how could i avoid this. I have pasted the code below. please let me know.

***********************************************************

select devclass object obj_name

into corresponding fields of tadir from tadir

where ( devclass like 'Y%' or devclass like 'Z%' )

and object in r_objtypes

and devclass ne '$TMP'.

i_obj-devclass = tadir-devclass. (i_obj is an internal table)

i_obj-object = tadir-object.

i_obj-obj_name = tadir-obj_name.

perform get_desc using i_obj-object i_obj-obj_name

changing i_obj-obj_desc.

append i_obj.

clear i_obj.

end select.

************************

form get_desc using value(p_object)

value(p_obj_name)

changing p_obj_desc type c.

case p_object.

when 'PROG'.

select single text into p_obj_desc from trdirt

where name = p_obj_name and sprsl = sy-langu.

when 'TABL'.

select single ddtext into p_obj_desc from dd02t

where tabname = p_obj_name

and ddlanguage = sy-langu.

when 'FUGR'.

select single areat into p_obj_desc from tlibt

where area = p_obj_name and spras = sy-langu.

when 'DOMA'.

select single ddtext into p_obj_desc from dd01t

where domname = p_obj_name

and ddlanguage = sy-langu.

when 'DTEL'.

select single ddtext into p_obj_desc from dd04t

where rollname = p_obj_name

and ddlanguage = sy-langu.

when 'VIEW' or 'ENQU'.

select single ddtext into p_obj_desc from dd25t

where viewname = p_obj_name

and ddlanguage = sy-langu.

when 'SHLP'.

select single ddtext into p_obj_desc from dd30t

where shlpname = p_obj_name

and ddlanguage = sy-langu.

when 'MSAG'.

select single stext into p_obj_desc from t100a

where arbgb = p_obj_name

and masterlang = sy-langu.

when 'DEVC'.

select single ctext into p_obj_desc from tdevct

where devclass = p_obj_name and spras = sy-langu.

when 'FUNC'.

select single stext into p_obj_desc from tftit

where funcname = p_obj_name.

when 'SUSO'.

select single ttext into p_obj_desc from tobjt

where object = p_obj_name and langu = sy-langu.

when 'TRAN'.

select single ttext into p_obj_desc from tstct

where tcode = p_obj_name and sprsl = sy-langu.

endcase.

endform.

Thanks and Regards

sanath

10 REPLIES 10
Read only

Former Member
0 Likes
1,277

Try this way:

[code]select devclass object obj_name

into corresponding fields of table i_obj "tadir from tadir

where ( devclass like 'Y%' or devclass like 'Z%' )

and object in r_objtypes

and devclass ne '$TMP'.

loop at i_obj.

perform get_desc using i_obj-object i_obj-obj_name

changing i_obj-obj_desc.

modify i_obj.

endloop.[/code]

If the first 3 fields of internal table i_obj are devclass, object & obj_name - modify the select statment as below:

[code]select devclass object obj_name

into table i_obj "tadir from tadir

where ( devclass like 'Y%' or devclass like 'Z%' )

and object in r_objtypes

and devclass ne '$TMP'.[/code]

Regards

Eswar

Read only

Former Member
0 Likes
1,276

1) Select all data from database in one shot only instead of hitting db again n again by select endselect loop.it will degrade performane.

so write -

select field 1 field 2 from dbtab into corresponding fields of table itab where field2 like 'Y%'.

2) then do a loop at itab.

loop at itab.

*processing

perform get_desc using itab-object itab-obj_name

*processing

endloop.

null

Read only

Former Member
0 Likes
1,276

HI,

Avoid using Select...endselect..

Change the stmt like ....into corresponding fields of table i_tadir.

Then use a loop...endloop and call the perform and do other processing as you have done.

Hope this helps.

Regards

Subramanian

Read only

Former Member
0 Likes
1,276

Hi,

Remove select...endselect.

Check the changes marked in bold..

select devclass object obj_name

into corresponding fields <b>of table i_obj</b>

where ( devclass like 'Y%' or devclass like 'Z%' )

and object in r_objtypes

and devclass ne '$TMP'.

LOOP AT i_obj

perform get_desc using i_obj-object i_obj-obj_name

changing i_obj-obj_desc.

modify i_obj.

ENDLOOP.

Thanks,

Naren

Read only

Former Member
0 Likes
1,276

Hi

Create a ITAB and move the values to the itab and remove into corresponding and use into table and remove enndselect.

i have made some changees to the code please check the same.

select devclass object obj_name

into corresponding fields of table i_obj from tadir

where ( devclass like 'Y%' or devclass like 'Z%' )

and object in r_objtypes

and devclass ne '$TMP'.

sort i_obj.

loop at i_obj into wa.

perform get_desc using i_obj-object i_obj-obj_name

changing i_obj-obj_desc.

endloop.

************************

form get_desc using value(p_object)

value(p_obj_name)

changing p_obj_desc type c.

case p_object.

when 'PROG'.

select single text into p_obj_desc from trdirt

where name = p_obj_name and sprsl = sy-langu.

when 'TABL'.

select single ddtext into p_obj_desc from dd02t

where tabname = p_obj_name

and ddlanguage = sy-langu.

when 'FUGR'.

select single areat into p_obj_desc from tlibt

where area = p_obj_name and spras = sy-langu.

when 'DOMA'.

select single ddtext into p_obj_desc from dd01t

where domname = p_obj_name

and ddlanguage = sy-langu.

when 'DTEL'.

select single ddtext into p_obj_desc from dd04t

where rollname = p_obj_name

and ddlanguage = sy-langu.

when 'VIEW' or 'ENQU'.

select single ddtext into p_obj_desc from dd25t

where viewname = p_obj_name

and ddlanguage = sy-langu.

when 'SHLP'.

select single ddtext into p_obj_desc from dd30t

where shlpname = p_obj_name

and ddlanguage = sy-langu.

when 'MSAG'.

select single stext into p_obj_desc from t100a

where arbgb = p_obj_name

and masterlang = sy-langu.

when 'DEVC'.

select single ctext into p_obj_desc from tdevct

where devclass = p_obj_name and spras = sy-langu.

when 'FUNC'.

select single stext into p_obj_desc from tftit

where funcname = p_obj_name.

when 'SUSO'.

select single ttext into p_obj_desc from tobjt

where object = p_obj_name and langu = sy-langu.

when 'TRAN'.

select single ttext into p_obj_desc from tstct

where tcode = p_obj_name and sprsl = sy-langu.

endcase.

endform.

thanks

Shiva

Read only

0 Likes
1,276

thanks a lot shivkumar.

cheers sanath

Read only

0 Likes
1,276

Wish you had a better sense in judging the answers...

Eswar

Read only

Former Member
0 Likes
1,276

if you want to write the perform statement outside of select endselect then

loop at i_obj.

perform get_desc using i_obj-object i_obj-obj_name

changing i_obj-obj_desc.

modify i_obj.

endloop.

but one thing your select query also not clear to me if devclass you are checking for only y or z then what is ne '$TMP' for ?

regards

shiba dutta

Read only

former_member404244
Active Contributor
0 Likes
1,276

Hi,

First of all declare a structure with three fields devclass,object,obj_name.as below

types : begin of t_tadir,

devclass type ,

object type ,

obj_name type ,

end of t_tadir.

data : i_tadir type standard table of t_tadir.

Now

select devclass object obj_name

into table i_tadir from tadir

where ( devclass like 'Y%' or devclass like 'Z%' )

and object in r_objtypes

and devclass ne '$TMP'.

Regards,

Nagaraj

Read only

Former Member
0 Likes
1,276

Thanks a million guys...

cheers

sanath