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: 

singleselct statement instead of multiple select statements

Former Member
0 Kudos

Hi All,

INCLUDE <ICON>.

DATA : DEL_ICON    TYPE ICON-ID,
        BLNK_ICON   TYPE ICON-ID,
        ACTV_ICON_G TYPE ICON-ID,
        ACTV_ICON_R TYPE ICON-ID,
        SHLP_ICON   TYPE ICON-ID,
        CLEAR_ICON  TYPE ICON-ID .


   SELECT SINGLE ID INTO ICON-ID FROM ICON WHERE NAME = 'ICON_FENCING'.
   CONCATENATE ICON-ID 'Show Additional selection' INTO DY_SEL_ON SEPARATED BY SPACE.
   CONCATENATE ICON-ID 'Hide Additional selection' INTO DY_SEL_OF SEPARATED BY SPACE.

   SELECT SINGLE ID INTO DEL_ICON    FROM ICON WHERE NAME = 'ICON_DELETE'.
   SELECT SINGLE ID INTO BLNK_ICON   FROM ICON WHERE NAME = 'ICON_HOLD'.
   SELECT SINGLE ID INTO ACTV_ICON_G FROM ICON WHERE NAME = 'ICON_LED_GREEN'.
   SELECT SINGLE ID INTO ACTV_ICON_R FROM ICON WHERE NAME = 'ICON_LED_RED'.
   SELECT SINGLE ID INTO SHLP_ICON   FROM ICON WHERE NAME = 'ICON_ENTER_MORE'.
   SELECT SINGLE ID INTO CLEAR_ICON  FROM ICON WHERE NAME = 'ICON_REFRESH'.

I have to improve the performance of my report. How to write sigle select statement instead of multiple select statements?

Thanks,

Venkata.


3 REPLIES 3

former_member214709
Participant
0 Kudos

Dear Venkat,

Instead of using SINGLE SELECT for retrieving the data from the same table you should use

SELECT *

FROM ICON

INTO TABLE ITAB1.

Then based on your requirement you can use:

LOOP AT ITAB1.

IF             NAME = 'ICON_DELETE'.


DEL_ICON = ITAB1-NAME.

ELSEIF     NAME = 'ICON_HOLD'.

BLNK_ICON = ITAB1-NAME.

..............

ENDIF.

ENDLOOP.

Regards

Dinesh

Former Member
0 Kudos

Hi Venkat,

you don't need a SELECT to dbtab ICON to get the icon-id.

Within Include <ICON> for each icon an constant including the icon-id is defined.

So if you use the const-names within the CONCATENATE you will get the ICON-ID:

CONCATENATE ICON_FENCING 'Show Additional selection' INTO DY_SEL_ON SEPARATED BY SPACE.
CONCATENATE ICON_FENCING 'Hide Additional selection' INTO DY_SEL_OF SEPARATED BY SPACE.

Regards Hendrik

PS: If possible you should use   "TYPE-POOLS: icon." instead of "INCLUDE <icon>."

Former Member
0 Kudos

Hello,

Declare a structure and internal table as below :

types : begin of ty_icon,

               name type icon-name,

               id TYPE ICON-ID,

            end of ty_icon.

data : t_icon type table of ty_icon.

Extract all relevant entries from table ICON into internal table t_icon.

sort t_icon and then read internal table t_icon with binary search.

Ex :

read table t_icon with key name = 'ICON_DELETE' binary search.

if sy-subrc eq 0.

     move t_icon-id to DEL_ICON.

endif

You can also declare range table in program and fill it (like select option) and use this as select option where condition of extract query from ICON.

Let me know if above solution is helpful.

Regards,

Deepti