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

problem in select query

Former Member
0 Likes
1,472

Hi Gurus ,

I am having a problem with this select query , when the select options is initial it is not returning any data into the internal table .

I could not find out where the problem is .

Please help.

select  matnr HERKL   into corresponding fields of table lt_marc from marc
                                                    where matnr in S_matnr
                                                    and  Beskz  = p_beskz
                                                    and  ekgrp  = P_ekgrp
                                                    and  lgpro  in s_lgpro
                                                    and  dispo  in S_dispo
                                                    and werks   = P_werks.

I am providing only input in S_matnr  .

S_  : select options

P_  : are parameters.

Please help,

Bharathi

5 REPLIES 5
Read only

Former Member
0 Likes
1,183

problem was with input parameters not select options . I was assuming that the problem was with select-options .

I used if clause to verify parameters are initial and added it to where clause and not everything is fine.

Read only

Former Member
0 Likes
1,183

Hi Bharathi,

Please check your values in parameter option if parameter is initial than ur select query will fail & wont fill your internal table. U can also cross check it by commenting parameter where conditions 'Beskz  = p_beskz,  ekgrp  = P_ekgrp & werks   = P_werks' . I hope it will solve your problem.

Reward points once solution work.

Regards,

Amol Patil

Read only

Former Member
0 Likes
1,183

Dear Bharathi,

It seems that the problem is with your mentioned Parameters as whenever you declare the Parameters you should make sure that you are passing the values from the selection screen else it will treat the value of that parameter as space .

As your telling you are just providing the S_MATNR value as input so in this case select query will look the data from table where 'Beskz  = space and  ekgrp  = space and werks   = space' and in almost all cases this combination will not give you the data .

Thanks

Mallikarjun

Read only

Former Member
0 Likes
1,183

Hi Bharathi,

SELECT    matnr   " key field

                werks   " key field

                herkl     " your required field

into corresponding fields of table lt_marc from marc

  where matnr in S_matnr[]

      and werks   = P_werks.

  IF sy-subrc <> 0.

*Show Message

      LEAVE LIST-PROCESSING.

  ELSE.

*Deleting extra value which is not matched .

    DELETE  lt_marc WHERE NOT (

           Beskz  = p_beskz

    and  ekgrp  = P_ekgrp

     and  lgpro  in s_lgpro[]

     and  dispo  in S_dispo).

    IF lt_marc[] IS NOT INITIAL.

      SORT lt_marc[] BY matnr werks.

    ELSE.

*Show Message

endif.

endif.

Try this,I think you will get the result.

Thanks,

Pravanjan

Read only

Former Member
0 Likes
1,183

Hi,

Don't use your parameters as initial, due that only the select query was not fetching the data. parameters are mandatory field mostly,

if you want to pass the empty parameter create a Range and pass your parameter value to the Range low value and give condition using IN key word.