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

select statement problem

Former Member
0 Likes
544

Hi

below select statement's sy-subrc is 4.But entry is in table.

i think something wrong in AND ( OBJCT = LC_REL_STRATEGY and OBJCT = LC_COM_CODE ).

how to rectify this.

SELECT PROFN
           AUTH
      INTO TABLE I_AUTH
      FROM UST10S
      FOR ALL ENTRIES IN I_PROFILES
     WHERE PROFN = I_PROFILES-PROFILE
       AND AKTPS = LC_A
      AND ( OBJCT = LC_REL_STRATEGY and OBJCT =  LC_COM_CODE ).

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
510

Hi,

if LC_REL_STRATEGY and LC_COM_CODE have different contents you will never get data. Maybe you want an OR for either LC_REL_STRATEGY or LC_COM_CODE for OBJCT here.

Regards,

Klaus

3 REPLIES 3
Read only

Former Member
0 Likes
511

Hi,

if LC_REL_STRATEGY and LC_COM_CODE have different contents you will never get data. Maybe you want an OR for either LC_REL_STRATEGY or LC_COM_CODE for OBJCT here.

Regards,

Klaus

Read only

santosh_kumarm
Participant
0 Likes
510

Hi Kumar,

Use the IN operator in the select statement.

SELECT PROFN

AUTH

INTO TABLE I_AUTH

FROM UST10S

FOR ALL ENTRIES IN I_PROFILES

WHERE PROFN = I_PROFILES-PROFILE

AND AKTPS = LC_A

AND OBJCT IN ( LC_REL_STRATEGY , LC_COM_CODE ).

IF Either of one value matches with the field value in the table. the record is fetched and sy-subrc will be 0.

Hope it shall be useful .

Regards

Santosh

Read only

Former Member
0 Likes
510

HI Kumar

I think your query is correct but want to ask some questions.

-does your table I_AUTH containes only two fields ( PROFN and AUTH)?

-what is LC_A? Is it a constant defined with initial value.

some points

-Before using FOR ALL ENTRIES always check whether your table which you are using for all entires is empty or not?

-sort it.

you need to add all the primary keys in your where condition. Like, if you have 5 prim keys and don't want them in your selection, then you need to define constants for those 5 prim keys with their initial values.

like

Constants: C_KEY1 type PRIM_KEY1 value is intial,

C_KEY2 type PRIM_KEY2 value is intial,

C_KEY3 type PRIM_KEY3 value is intial,

C_KEY4 type PRIM_KEY4 value is intial,

C_KEY5 type PRIM_KEY5 value is intial.

Now your query will be like:

SELECT PROFN

AUTH

INTO TABLE I_AUTH

FROM UST10S

FOR ALL ENTRIES IN I_PROFILES

WHERE PROFN = I_PROFILES-PROFILE AND

AKTPS = LC_A AND

OBJCT = LC_REL_STRATEGY and

OBJCT = LC_COM_CODE

prim_key1 GT c_key1

prim_key2 GT c_key2

prim_key3 GT c_key3

prim_key4 GT c_key4

prim_key5 GT c_key5.

Try this and I hope it will resolve your query.

Thanks

Lalit Gupta