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

Question reg. Select statement

Former Member
0 Likes
1,265

I have a question reg. select statement:

data: str_knmt type knmt.

SELECT single vkorg vtweg kunnr

FROM knmt

INTO str_knmt

WHERE vkorg = p_vkorg

AND vtweg = p_vtweg

AND kunnr = p_kunnr.

Now on the selection screen, I entred only value for p_kunnr (i.e 0000019900) and pressed F8. Now in debugging mode, I see no entries in str_knmt even though there is an entry existing in knmt table with the kunnr value i entered. (the entry in the structure str_knmt is expected as

B280 for vkorg

10 for vtweg

0000019900 for kunnr).

Why that record is not coming into the structure? Please give your input.

Thanks.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,221

Hi,

You can also add NO-EXTENSION NO INTERVALS to allow enter only one value in the select-option..

REPORT ztest .

TABLES: knmt.

SELECT-OPTIONS: s_vkorg FOR knmt-vkorg <b>NO-EXTENSION NO INTERVALS</b>,

s_vtweg FOR knmt-vtweg <b>NO-EXTENSION NO INTERVALS</b>.

PARAMETERS: p_kunnr LIKE knmt-kunnr.

Thanks,

Naren

11 REPLIES 11
Read only

Former Member
0 Likes
1,221

There is no record in KNMT where vkorg is blank, vtweg is blank, and kunnr = 0000019900.

Read only

0 Likes
1,221

thank you.

Yes, i know. so, how to get that record even though i keep them blank or sometimes i may enter them..?

thanks again.

Read only

0 Likes
1,221

As Rob suggested, use Select-Options instead of Parameters and use IN in your select statement instead of =.

Read only

Former Member
0 Likes
1,221

If you didn't enter values in p_vkorg or p_vtweg, the select is looking for entries where these are blank as well. Remember, parameters are not select options and behave differently.

Rob

Read only

0 Likes
1,221

Like:


REPORT ztest .

TABLES: knmt.

SELECT-OPTIONS: s_vkorg FOR knmt-vkorg,
                s_vtweg FOR knmt-vtweg.
PARAMETERS: p_kunnr LIKE knmt-kunnr.

DATA: str_knmt TYPE knmt.

SELECT SINGLE vkorg vtweg kunnr
  FROM knmt
  INTO CORRESPONDING FIELDS OF str_knmt
  WHERE vkorg IN s_vkorg
    AND vtweg IN s_vtweg
    AND kunnr =  p_kunnr.

Rob

Added "INTO CORRESPONDING FIELDS OF..."

Message was edited by:

Rob Burbank

Read only

Former Member
0 Likes
1,221

This could be because the you havenet entered anything in the selection screen for p_vtweg. This is causing a blank value to be fed into the select statement and the statement is failing for this.

If your p_vtweg is a optional field then you declare it as a select option with no intervals and extension. This will appear as a parameter in the screen and will serve your perpose. Dont forget to alter the select statement to accomodate the select option instead of the parameter.

- Guru

Reward points for helpful answers

Read only

Former Member
0 Likes
1,221

Hi Krishen,

You are querying on database table KNMT with the combinatio of VKORG,VTWEG nd KUNNR where a you are querying only with the value of KUNNR at your datatable level through SE11.

In SE11, it will search for only those KUNNR value of 0000019900. You can interpret this as the below query.

SELECT single vkorg vtweg kunnr

FROM knmt

INTO str_knmt

WHERE kunnr = p_kunnr.

In your SELECT query it will search will blank values for VKORG and VTWEG. So you are unable to get an entry to this internal table.

Note: Plz mark all helpfuls answers.

Thanks,

Vinay

Read only

ferry_lianto
Active Contributor
0 Likes
1,221

Hi Krishen,

Please try this instead.


TABLES: KNMT.
                                                                        
SELECT-OPTIONS: S_VKORG FOR KNMT-VKORG,
                S_VTWEG FOR KNMT-VTWEG.
                                                                        
PARAMETERS: P_KUNNR LIKE KNMT-KUNNR.
                                                                        
DATA: BEGIN OF STR_KNMT,
        VKORG LIKE KNMT-VKORG,
        VTWEG LIKE KNMT-VTWEG,
        KUNNR LIKE KNMT-KUNNR.
DATA: END OF STR_KNMT.
                                                                        
SELECT SINGLE VKORG VTWEG KUNNR
FROM KNMT
INTO STR_KNMT
WHERE VKORG IN S_VKORG
  AND VTWEG IN S_VTWEG
  AND KUNNR EQ P_KUNNR.
                                                                        
WRITE: / STR_KNMT.

Regards,

Ferry Lianto

Read only

Former Member
0 Likes
1,221

If you are going to use select-option then make sure vkorg and vtweg is not initial otherwise it will search for all the rows in the table and may cause performance issue.

Thanks,

Santosh

Read only

Former Member
0 Likes
1,222

Hi,

You can also add NO-EXTENSION NO INTERVALS to allow enter only one value in the select-option..

REPORT ztest .

TABLES: knmt.

SELECT-OPTIONS: s_vkorg FOR knmt-vkorg <b>NO-EXTENSION NO INTERVALS</b>,

s_vtweg FOR knmt-vtweg <b>NO-EXTENSION NO INTERVALS</b>.

PARAMETERS: p_kunnr LIKE knmt-kunnr.

Thanks,

Naren

Read only

Former Member
0 Likes
1,221

For your Select query the problem might be for the value of KUNNR

Check the conversion exit for this field.

p_kunnr

like kunnr is having conversion exit ALPHA

call function 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = p_kunnr

IMPORTING

OUTPUT = p_kunnr.

These things you have to do before select statement and then write

SELECT single vkorg vtweg kunnr

FROM knmt

INTO str_knmt

WHERE vkorg = p_vkorg

AND vtweg = p_vtweg

AND kunnr = p_kunnr.

Regards,

Aman