SAP Development :: ABAP programming :: Parameters Issue ~ Runboard
SAP Development
 ABAP programming
  Parameters Issue
Support
Search
RSS

runboard.com       Sign up (learn about it) | Sign in (lost password?)


 
Aisha Ishrat
Registered user
Global user

Registered: 02-2007
Posts: 5
Karma: 0 (+0/-0)
Reply | Quote
Parameters Issue


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.

Regards,

Aisha Ishrat.
2/2/2007, 7:09 am Send Email to Aisha Ishrat   Send PM to Aisha Ishrat
 
sapdev
Head Administrator
Global user

Registered: 07-2004
Posts: 56
Karma: 0 (+0/-0)
Reply | Quote
Re: Parameters Issue


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!

Hope this helps
regards
Mart

P.s. Just for your information, for performamce reasons you should not generally use the select..endselect command. It is much better practice to select all the data into an internal table and then loop around that internal table.

Last edited by sapdev, 2/2/2007, 11:36 am
2/2/2007, 11:32 am Send Email to sapdev   Send PM to sapdev Blog
 
Aisha Ishrat
Registered user
Global user

Registered: 02-2007
Posts: 5
Karma: 0 (+0/-0)
Reply | Quote
Re: Parameters Issue


Its working.Thanks a lot.your advice is welcomed , I have just started my career in SAP/ABAP so thats y need a lot of improvement.

Regards.
2/2/2007, 11:58 am Send Email to Aisha Ishrat   Send PM to Aisha Ishrat
 
sapdev
Head Administrator
Global user

Registered: 07-2004
Posts: 56
Karma: 0 (+0/-0)
Reply | Quote
Re: Parameters Issue


Your welcome, how you enjoyiong it in the world of SAP so far? If you have any further queries where you cant find the answer on http://www.sapdevelopment.co.uk please dont hesitate post it on here, and hopefully myself or somebody else will be able to provide the answer!

Regards
Mart
2/4/2007, 6:30 pm Send Email to sapdev   Send PM to sapdev Blog
 


Add a reply






Link to us   -  Blogs   -  Hall of Honour   -  Chat
You are not logged in (login)      Board's time is: 11/28/2009, 12:21 pm