2007 Jan 12 6:33 AM
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
2007 Jan 12 6:35 AM
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
2007 Jan 12 6:35 AM
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
2007 Jan 12 6:36 AM
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
2007 Jan 12 6:37 AM
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
2007 Jan 12 6:37 AM
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
2007 Jan 12 6:39 AM
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
2007 Jan 12 6:46 AM
thanks a lot shivkumar.
cheers sanath
2007 Jan 12 6:49 AM
Wish you had a better sense in judging the answers...
Eswar
2007 Jan 12 6:40 AM
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
2007 Jan 12 6:43 AM
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
2007 Jan 12 6:52 AM
Thanks a million guys...
cheers
sanath
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |