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 statement issue

Former Member
0 Likes
1,217

Dear Experts,

I have parameters and select-options like below..

data: d_date type vbrp-erdat.

parameters: p_bukrs type t001k-bukrs,

                  p_matnr type mara-matnr,

                  s_date  for  d_date.  

I want to pass matnr and erdat to table vbrp and fetch data like vbeln,fkimg,erdat,werks,matnr,arktx  from table vbrp  for that inputed matnr.

So I created the types for vbrp table for these declared fields and also created the itab and wa.

when I wrote the select statement to fetch data from vbrp table and put the where condition as where matnr = p_matnr and erdat in s_date,no data has populated to itan it_vbrp. So in that case how I ll fetch data from vbrp table. Also if i remove the where conditions it fetched the wrong data from the table.

Please guide me how to write the select statement to fetch data based on above conditions..

Kind Regards,

Ajit

1 ACCEPTED SOLUTION
Read only

former_member210857
Participant
0 Likes
1,186

Hi Ajit,

I think you are trying to create a select options for s_date and you have declared it in parameters.u

if you want to use IN in select query  .you should use select options.

data:            d_date type erdat

.

parameters: p_bukrs type bukrs,

                   p_matnr type matnr.


SELECT-OPTIONS : s_date  for  d_date.

Kindly check.

Regards,

Subeesh Kannottil

11 REPLIES 11
Read only

former_member187748
Active Contributor
0 Likes
1,186

Hi Ajit,

parameters are defined as shown below

PARAMETERS : P_VKBUR TYPE VBAK-VKBUR  OBLIGATORY.

Then you can use it as shown below.

vkbur EQ p_vkbur

Read only

Former Member
0 Likes
1,186

Hi,

parameters: p_bukrs type t001k-bukrs,

                  p_matnr type mara-matnr,

                  s_date  for  d_date.  

is wrong. for using select....from...where erdat in s_date you should define s_date as select option.

tables : vbrp.

parameters: p_bukrs type t001k-bukrs,

                  p_matnr type mara-matnr.

select-options :  s_date  for  vbrp-erdat..  

thanks

akshay

Read only

0 Likes
1,186

Hi Ajit,

Akshay is right. IN operator used in select-options defined parameter.

select <fieldname> into table <internaltable> where matnr = p_matnr and erdat in s_date.

Thanks,

Ranjit K.

Read only

former_member210857
Participant
0 Likes
1,187

Hi Ajit,

I think you are trying to create a select options for s_date and you have declared it in parameters.u

if you want to use IN in select query  .you should use select options.

data:            d_date type erdat

.

parameters: p_bukrs type bukrs,

                   p_matnr type matnr.


SELECT-OPTIONS : s_date  for  d_date.

Kindly check.

Regards,

Subeesh Kannottil

Read only

Former Member
0 Likes
1,186

Dear Akshay,

I declared select-option.

If I declared select-option : s_date for vbrp-erdat,its showing vbrp table is unknown.

@sanjiv....

if i pass as per your suggstion,its not fetching any data to itab it_vbrp.

Regards,

Ajit

Read only

0 Likes
1,186

Hello Ajit,

please see i have edited my post, sorry i didn't not seen that you have used

parameters and declared as SELECT-OPTIONS.

Please see my edited post.

Read only

former_member187748
Active Contributor
0 Likes
1,186

Hi Ajit,

please change your code logic as shown below

parameters: p_bukrs TYPE t001k-bukrs,

                  p_matnr TYPE mara-matnr,

                  s_date  TYPE  vbrp-erdat

Now you can write your code logic and put EQ for your parameters.

Read only

sivaprasad_paruchuri
Active Participant
0 Likes
1,186

hi ,

u can declare as follows there wont be any issue

tables : vbrp

parameters: p_bukrs type t001k-bukrs,

                  p_matnr type mara-matnr.

slect-options s_date  for  vbrp-erdat.

select .... from vbrp into table itab where matnr = p_matnr and erdat in s_erdat.

regards

Siva 

Read only

Former Member
0 Likes
1,186

tHANK YOU VERY MUCH ALL FOR YOUR VALUABLE ANSWERS..

I DECLARED THE INPUT FIELDS AAS SELECT-OPTIONS AND SOLVE MY PROBLEM AS NEERAJ SAID.

tHANK YOU ALL..

Read only

Former Member
0 Likes
1,186

Dear Ajit.

Please Check Bellow Source code.

DATA: D_DATE TYPE VBRP-ERDAT.

DATA : BEGIN OF IT_VBRP OCCURS 0,
           VBELN TYPE VBRP-VBELN,
           FKIMG TYPE VBRP-FKIMG,
           ERDAT TYPE VBRP-ERDAT,
           WERKS TYPE VBRP-WERKS,
           MATNR TYPE VBRP-MATNR,
           ARKTX TYPE VBRP-ARKTX,
        END OF IT_VBRP.



PARAMETERS: P_BUKRS TYPE T001K-BUKRS,

                   P_MATNR TYPE MARA-MATNR.

SELECT-OPTIONSS_DATE FOR D_DATE.



SELECT VBELN FKIMG ERDAT WERKS MATNR ARKTX
   FROM VBRP
   INTO TABLE IT_VBRP
   WHERE MATNR = P_MATNR
   AND ERDAT IN S_DATE.


your requirement is may fulfill and Replay me Your Friend and  kind of problem please tell me.  

Read only

Former Member
0 Likes
1,186

THANK YOU @RAJ