Skip to Content
0
Former Member
Nov 30, 2006 at 09:23 AM

Wrong fetching from WHERE statement

18 Views

Hii All,

I have this problem.

I am using a select statement with the WHERE clause as:

Select FLD1 FLD2 FLD3 FLD4 from DBTAB into ITAB WHERE

bukrs = SS_BUKRS and

gjahr = SS_GJAHR and

monat = SS_MONAT and

tcode = SS_TCODE and

usnam = SS_USNAM.

Here, SS stands for selection-screen components.

If I enter company code (BUKRS), Fiscal Year (GJAHR), Period (MONAT), Transaction (TCODE) and User name (USNAM) in selection screen, I am able to fetch data from database table DBTAB. If suppose I dont enter TCODE and USNAM, I am not able to fetch the data, as WHERE clause is taking values tcode equal to space and usnam equal to space, which is wrong.

I dont want to put any condition like if usnam and tcode is initial, then dont consider these in where clause and if they are not initial, then consider these in WHERE clause.

I have even checked if tcode and usnam has any check table values, but there is nothing like that.

Is there any way out of this?

pls help.

MA