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 Statment condition

Former Member
0 Likes
1,327

Hi All,

I have a following select statement.

SELECT TSTC~PGMNA

TSTC~TCODE

TSTCT~TTEXT

TRDIR~SECU

INTO CORRESPONDING FIELDS OF TABLE IT_TEST

FROM ( TSTC inner join tstct on tstcttcode = tstctcode

INNER JOIN TRDIR ON TRDIRNAME = TSTCPGMNA )

WHERE PGMNA IN S_PGNAME

and SPRSL IN S_LKEY.

in the above code I need to enter a condition that it should look out for only those Tcodes in the table TSTC where TSTC~PGMNA = ' ' " (space) ... so can you please tell me how can I do that.

thanks,

Rajeev

1 ACCEPTED SOLUTION
Read only

ThomasZloch
Active Contributor
0 Likes
1,258

Is S_PGNAME on your selection screen? If yes, then the desired condition can be entered there.

The INNER JOIN TRDIR needs to be changed to an LEFT OUTER JOIN, since there will not be an entry in TRDIR for these cases.

Thomas

P.S. include SPRSL = SY-LANGU in your join of TSTCT, otherwise there could be duplicates due to multi-language descriptions.

12 REPLIES 12
Read only

ThomasZloch
Active Contributor
0 Likes
1,259

Is S_PGNAME on your selection screen? If yes, then the desired condition can be entered there.

The INNER JOIN TRDIR needs to be changed to an LEFT OUTER JOIN, since there will not be an entry in TRDIR for these cases.

Thomas

P.S. include SPRSL = SY-LANGU in your join of TSTCT, otherwise there could be duplicates due to multi-language descriptions.

Read only

0 Likes
1,258

Thanks for the reply thomas.... now I am not worried about the TRDIR table... as you are right TRDIR table will not hold good in this case:

but can you please explain a more how to take care of that TSTC~PGMNA = ' ' condition? as I don't user to add this conditon.. what I want when ever a user execute this report he should see only those T-cdoes whch don't have program names.

my updated code is :

SELECT TSTC~PGMNA

TSTC~TCODE

TSTCT~SPRSL

TSTCT~TTEXT

INTO CORRESPONDING FIELDS OF TABLE IT_TCODELISTING

FROM ( TSTC inner join tstct on tstcttcode = tstctcode)

WHERE PGMNA IN S_PGNAME

and SPRSL IN S_LKEY.

Thanks,

Rajeev

Read only

0 Likes
1,258

Hi Rajeev,

SELECT TSTC~PGMNA

TSTC~TCODE

TSTCT~SPRSL

TSTCT~TTEXT

INTO CORRESPONDING FIELDS OF TABLE IT_TCODELISTING

FROM ( TSTC inner join tstct on tstcttcode = tstctcode)

WHERE PGMNA IN S_PGNAME

and SPRSL IN S_LKEY.

In your code you are checking using S_PGNAME, if input is not specified in Selection screen it will fectch all records.

So you can do

1) check WHERE PGMNA = ' '

why you are checking using S_PGNAME?

If you want to use S_PGNAME then

S_PGNAME-LOW = ' '.

S_PGNAME-OPTION = 'EQ'.

S_PGNAME-SIGN = 'I'.

APPEND S_PGNAME.

Regards,

Sunil

Edited by: Sunil Reddy Sibbala on Feb 5, 2009 5:25 PM

Read only

0 Likes
1,258

Well, then either

> WHERE PGMNA = SPACE

or

> WHERE PGMNA IN S_PGNAME

and filling S_PGNAME before for selecting blank values: OPTION = "EQ", SIGN = "I", LOW = SPACE.

Thomas

Read only

0 Likes
1,258

Thanks for the reply Sunil... basically what I am looking for is the ability for the user to see all the Custom T_codes which doesn't have any program name assigned to it. So can you please tell me how can I get that.

THanks,

Rajeev

Read only

0 Likes
1,258

Hi,

This query could help you.

SELECT TSTC~PGMNA

TSTC~TCODE

TSTCT~SPRSL

TSTCT~TTEXT

INTO CORRESPONDING FIELDS OF TABLE IT_TCODELISTING

FROM TSTC

JOIN TSTCT

ON TSTCTTCODE = TSTCTCODE

WHERE TSTC~PGMNA = ' '

AND TSTC~TCODE = 'Z#'

AND TSTCT~SPRSL = S_LKEY.

Thanks,

Pranav

Read only

0 Likes
1,258

Hi Pranav,

It didn't work.... it didn't fetch any data in the internal table

Read only

0 Likes
1,258

Hi,

Sorry you have to put LIKE there. Try this.

SELECT TSTC~PGMNA

TSTC~TCODE

TSTCT~SPRSL

TSTCT~TTEXT

INTO CORRESPONDING FIELDS OF TABLE IT_TCODELISTING

FROM TSTC

JOIN TSTCT

ON TSTCTTCODE = TSTCTCODE

WHERE TSTC~PGMNA = ' '

AND TSTC~TCODE LIKE 'Z%' (or 'Y%')

AND TSTCT~SPRSL = S_LKEY.

Thanks,

Sudha

Read only

0 Likes
1,258

It's still behaving the same and not fetching anything in the internal table... somehow it's just skipping the whole select statement

tahnks,

Rajeev

Read only

0 Likes
1,258

It is working to me. Do you have any conditions before the select query?

Pranav

Read only

0 Likes
1,258

Rajeev - rather than just cutting and pasitng the code, do some desk checking to see if you can find the error before posting back to the forum.

Rob

Read only

0 Likes
1,258

Hi Pranav...

thanks for the reply... the conditon for tstc - pgmna = ' '... is not working!!!