2007 Dec 23 10:55 AM
I have 3 parameters in my ABAP Program:
Parameters: p_date like ZSTATS_CUML2-zdate ,
p_user like ZSTATS_CUML2-account,
p_tcode like ZSTATS_CUML2-tcode.
and I put entries in table tab_1 from ZSTATS_CUML2 table as follows:
select * from ZSTATS_CUML2 where Not tcode = ''and tcode = p_tcode and
zdate = p_date and account = p_user.
tab_1-tcode = ZSTATS_CUML2-tcode.
tab_1-logindate = ZSTATS_CUML2-zdate.
tab_1-username = ZSTATS_CUML2-account.
tab_1-responsetime = ZSTATS_CUML2-respti.
append tab_1 to tab_1.
endselect.
I want that if user gives no input in parameters, then all entries come in tab_1 or if user gives input in 2 parameters then the selection criteria should apply only in 2 parameters.what happens now ,if i give no value in any paramater , the output table contains nothing , it's empty.
Kindly help.
Suneela.
2007 Dec 24 1:53 PM
Hi There,
the easiest way to do this would be to replace the parameters with select options and modify the select statement appropriatley. See the following code:
TABLES: ZSTATS_CUML2.
select-options: so_date for ZSTATS_CUML2-zdate NO INTERVALS no-extension ,
so_user for ZSTATS_CUML2-account NO INTERVALS no-extension ,
so_tcode for ZSTATS_CUML2-tcode NO INTERVALS no-extension .
and I put entries in table tab_1 from ZSTATS_CUML2 table as follows:
select *
from ZSTATS_CUML2
where Not tcode = ' ' and
tcode in so_tcode and
zdate in so_date and
account in so_user.
tab_1-tcode = ZSTATS_CUML2-tcode.
tab_1-logindate = ZSTATS_CUML2-zdate.
tab_1-username = ZSTATS_CUML2-account.
tab_1-responsetime = ZSTATS_CUML2-respti.
append tab_1 to tab_1.
endselect.
Therefore if the select option is left blank the 'tcode in so_tcode' statement will return everything!
Reward points if found helpful....
Cheers,
Chandra Sekhar.
Hi There,
the easiest way to do this would be to replace the parameters with select options and modify the select statement appropriatley. See the following code:
TABLES: ZSTATS_CUML2.
select-options: so_date for ZSTATS_CUML2-zdate NO INTERVALS no-extension ,
so_user for ZSTATS_CUML2-account NO INTERVALS no-extension ,
so_tcode for ZSTATS_CUML2-tcode NO INTERVALS no-extension .
and I put entries in table tab_1 from ZSTATS_CUML2 table as follows:
select *
from ZSTATS_CUML2
where Not tcode = ' ' and
tcode in so_tcode and
zdate in so_date and
account in so_user.
tab_1-tcode = ZSTATS_CUML2-tcode.
tab_1-logindate = ZSTATS_CUML2-zdate.
tab_1-username = ZSTATS_CUML2-account.
tab_1-responsetime = ZSTATS_CUML2-respti.
append tab_1 to tab_1.
endselect.
Therefore if the select option is left blank the 'tcode in so_tcode' statement will return everything!
Reward points if found helpful....
Cheers,
Chandra Sekhar.
2007 Dec 23 3:54 PM
Hi,
you can use the IN-operator together with the select-options:
Here ist your coding, changed by using select-options and the in operetors:
Whitout the NO-EXTENSION and NO INTERVALS keywords, the select-options have more options then the PARAMETERS.
...
TABLES zstats_cuml2.
SELECT-OPTIONS:
s_date FOR zstats_cuml2-zdate NO-EXTENSION NO INTERVALS,
s_user FOR zstats_cuml2-account NO-EXTENSION NO INTERVALS,
s_tcode FOR zstats_cuml2-tcode NO-EXTENSION NO INTERVALS.
SELECT * FROM zstats_cuml2 WHERE NOT tcode = ''
AND tcode IN s_tcode
AND zdate IN s_date
AND account IN s_user.
tab_1-tcode = zstats_cuml2-tcode.
tab_1-logindate = zstats_cuml2-zdate.
tab_1-username = zstats_cuml2-account.
tab_1-responsetime = zstats_cuml2-respti.
APPEND tab_1 TO tab_1.
ENDSELECT.
...
Many greetings,
Stefan
2007 Dec 24 1:53 PM
Hi There,
the easiest way to do this would be to replace the parameters with select options and modify the select statement appropriatley. See the following code:
TABLES: ZSTATS_CUML2.
select-options: so_date for ZSTATS_CUML2-zdate NO INTERVALS no-extension ,
so_user for ZSTATS_CUML2-account NO INTERVALS no-extension ,
so_tcode for ZSTATS_CUML2-tcode NO INTERVALS no-extension .
and I put entries in table tab_1 from ZSTATS_CUML2 table as follows:
select *
from ZSTATS_CUML2
where Not tcode = ' ' and
tcode in so_tcode and
zdate in so_date and
account in so_user.
tab_1-tcode = ZSTATS_CUML2-tcode.
tab_1-logindate = ZSTATS_CUML2-zdate.
tab_1-username = ZSTATS_CUML2-account.
tab_1-responsetime = ZSTATS_CUML2-respti.
append tab_1 to tab_1.
endselect.
Therefore if the select option is left blank the 'tcode in so_tcode' statement will return everything!
Reward points if found helpful....
Cheers,
Chandra Sekhar.
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |