Application Development 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: 

Help on Parameters selections

Former Member
0 Kudos
152

In the below sample program if I select all the parameters then I able to see data which mateches those parameters. But my requirement is that, suppose if I don't select DATE parameter then I should be able to see the data of all the DATES.

Do I need to write separate select statements if user select the parameter and if he not.

Is there any other way of doing it.

Code is as follows.

Data : Begin of I_vbak occurs 0,

Vbeln like vbak-vbeln,

End of I_vbak.

Data : Begin of I_vbap occurs 0,

Vbeln like vbap-vbeln,

Posnr like vbap-posnr,

Matnr like vbap-matnr,

Kwmeng like vbap-kwmeng,

End of I_vbap.

Data : Begin of I_makt occurs 0,

Matnr like makt-matnr,

Maktx like makt-maktx,

End of I_makt.

Data : d_lines like sy-subrc.

parameters : p_erdat like vbak-erdat,

p_vkorg like vbak-vkorg,

p_vtweg like vbak-vtweg,

p_spart like vbak-spart.

Start-of-selection.

Refresh : I_vbak , I_vbap , I_makt.

Select vbeln from VBAK into table I_vbak

Where erdat = p_erdat And

vkorg = p_vkorg And

vtweg = p_vtweg And

spart = p_spart.

Clear d_lines.

Describe table I_vbak lines d_lines.

Check d_lines <> 0.

Select vbeln posnr matnr kwmeng from VBAP into table I_vbap

For all entries in I_vbak

Where vbeln = I_vbak-vbeln.

Clear d_lines.

Describe table I_vbap lines d_lines.

Check d_lines <> 0.

End-of-selection.

Sort I_vbap by vbeln matnr.

Select matnr maktx from makt into table I_makt

For all entries in I_vbap

Where spras = sy-langu And

matnr = I_vbap-matnr.

Sort I_makt by matnr.

Loop at I_vbap.

Clear I_makt.

Read table I_makt with key matnr = I_vbap-matnr binary search.

Write 😕 I_vbap-vbeln,

I_vbap-posnr,

I_vbap-matnr,

I_Makt-matnr,

I_vbap-kwmeng.

Endloop.

8 REPLIES 8

Former Member
0 Kudos
85

Hi,

use select-option for date and pass in the select query.

wheneverv the select option is initial it is ingnored for the select query.

i.e

select-option : date for dats

pass in select query

select * from ....

where date in date

and .......

Mark Helpul answers

Regards

Message was edited by: Manoj Gupta

0 Kudos
85

Hi Vishal,

Use select-options with<b> no intervals and no-extension</b> statement.

<b>select-options : p_date for vbak-erdat no-extension no intervals.</b>

Regards,

Santosh

Former Member
0 Kudos
85

Instead of parameter, use select-option with 'NO INTERVALS NO-EXTENSION' extension. It will act as u desired..

Former Member
0 Kudos
85

Hi vishal,

1. Thats bcos the Date

field is a parameter.

2. Make it a select option like this :

<b>data : jd type sy-datum.

select-options : p_erdat for jd no-extension no intervals.</b>

3. Then just change your sql, a little,

(use IN instead of = )

Where erdat IN p_erdat

regards,

amit m.

Former Member
0 Kudos
85

Hii Vishal ,

check thsi code

Data : Begin of I_vbak occurs 0,

Vbeln like vbak-vbeln,

End of I_vbak.

Data : Begin of I_vbap occurs 0,

Vbeln like vbap-vbeln,

Posnr like vbap-posnr,

Matnr like vbap-matnr,

Kwmeng like vbap-kwmeng,

End of I_vbap.

Data : Begin of I_makt occurs 0,

Matnr like makt-matnr,

Maktx like makt-maktx,

End of I_makt.

Data : d_lines like sy-subrc.

<b>select-options : s_erdat for vbak-erdat NO-EXTENSION NO INTERVALS.</b>

parameters :

p_vkorg like vbak-vkorg,

p_vtweg like vbak-vtweg,

p_spart like vbak-spart.

Start-of-selection.

Refresh : I_vbak , I_vbap , I_makt.

Select vbeln from VBAK into table I_vbak

Where erdat in s_erdat And

vkorg = p_vkorg And

vtweg = p_vtweg And

spart = p_spart.

Clear d_lines.

Describe table I_vbak lines d_lines.

Check d_lines <> 0.

Select vbeln posnr matnr kwmeng from VBAP into table I_vbap

For all entries in I_vbak

Where vbeln = I_vbak-vbeln.

Clear d_lines.

Describe table I_vbap lines d_lines.

Check d_lines <> 0.

End-of-selection.

Sort I_vbap by vbeln matnr.

Select matnr maktx from makt into table I_makt

For all entries in I_vbap

Where spras = sy-langu And

matnr = I_vbap-matnr.

Sort I_makt by matnr.

Loop at I_vbap.

Clear I_makt.

Read table I_makt with key matnr = I_vbap-matnr binary search.

Write 😕 I_vbap-vbeln,

I_vbap-posnr,

I_vbap-matnr,

I_Makt-matnr,

I_vbap-kwmeng.

Endloop.

Check this..it works

Reward points if helpful..

Regards

Naresh

Former Member
0 Kudos
85

Hi,

If you want to display the data corresponding to all the dates, the dates should be a select options not a parameters in order to select multiple date options.

Regards,

Aswin

Former Member
0 Kudos
85

hi vishal,

use select-options instead of parameters.

<b>select-options : p_erdat for vbak-erdat</b>

hope this helps,

priya.

Former Member
0 Kudos
85

Vishal,

Another work around, in case you don't want to change the selection field to select-option. Insert the following lines before the select.

Ranges: r_erdat for vbak-erdat.

r_erdat-sign = 'I'.

r_erdat-option = 'EQ'.

r_erdat-low = p_erdat.

APPEND r_erdat.

And then in the select, instead of 'erdat = p_erdat' , use <b>'erdat in r_erdat'</b> .