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: 

Why this simple SELECT is NOT working??

Former Member
0 Kudos

Hi Experts,

When I input the P_VKORG the following SELECT is working.

When I did not inut(leaving blank) the P_VKORG the same SELECT is NOT working??

Can u tell me, Why this simple SELECT is NOT working??

selection screen:

PARAMETERS: p_vkorg TYPE mvke-vkorg.

SELECT-OPTIONS: s_prodh FOR mvke-prodh,

s_mvgr2 FOR mvke-mvgr2,

s_matnr FOR mvke-matnr.

PARAMETERS: p_werks TYPE mard-werks.

SELECT-OPTIONS: s_lgort FOR mard-lgort.

select:

SELECT

vmatnr vvkorg vvtweg vvmsta

dlabst dinsme d~speme

INTO CORRESPONDING FIELDS OF TABLE it_itab

FROM mvke AS v

INNER JOIN mard AS d ON dmatnr = vmatnr

WHERE v~matnr IN s_matnr AND

v~vkorg EQ p_vkorg AND

v~vmsta = '33' AND

v~vmstd GE sy-datum AND

v~prodh IN s_prodh AND

v~mvgr2 IN s_mvgr2 AND

d~werks = p_werks AND

d~lgort IN s_lgort.

i tried also with,

SELECT

vmatnr vvkorg vvtweg vvmsta

dlabst dinsme d~speme

INTO CORRESPONDING FIELDS OF TABLE it_itab

FROM mvke AS v

INNER JOIN mard AS d ON dmatnr = vmatnr

WHERE v~matnr IN s_matnr AND

v~vkorg = p_vkorg AND

v~vmsta = '33' AND

v~vmstd GE sy-datum AND

v~prodh IN s_prodh AND

v~mvgr2 IN s_mvgr2 AND

d~werks = p_werks AND

d~lgort IN s_lgort.

thanq

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

COnvert p_vkorg to a range:

ranges: r_vkorg for mvke-vkorg.

if p_vkorg is not initial.

r_vkorg-sign = 'I'.

r_vkorg-option = 'EQ'.

r_vkorg-low = p_vkorg.

append r_vkorg.

IN the select query enter :

v~vkorg IN r_vkorg ............

Regards,

Subramanian

7 REPLIES 7

Former Member
0 Kudos

Hi,

COnvert p_vkorg to a range:

ranges: r_vkorg for mvke-vkorg.

if p_vkorg is not initial.

r_vkorg-sign = 'I'.

r_vkorg-option = 'EQ'.

r_vkorg-low = p_vkorg.

append r_vkorg.

IN the select query enter :

v~vkorg IN r_vkorg ............

Regards,

Subramanian

0 Kudos

thanq.

1 - So, this is the case with all PARAMETERS, I mean, when we use them in SELECTs, Do we need to convert to RANGES?

2 - or Is it specific some fileds, some data types? bcoz, in some of my or´ther prog., it was worked, like for BUKRS, doc type etc.

thanq

Former Member
0 Kudos

may be there is not a record in the table MVKE with VKORG empty.

try to use SELECT-OPTIONS.

SELECT-OPTIONS: s_vkorg FOR MVKE-VKORG.

SELECT
v~matnr v~vkorg v~vtweg v~vmsta
d~labst d~insme d~speme
INTO CORRESPONDING FIELDS OF TABLE it_itab
FROM mvke AS v
INNER JOIN mard AS d ON d~matnr = v~matnr
WHERE v~matnr IN s_matnr AND
v~vkorg IN s_vkorg AND  "change here
v~vmsta = '33' AND
v~vmstd GE sy-datum AND
v~prodh IN s_prodh AND
v~mvgr2 IN s_mvgr2 AND
d~werks = p_werks AND
d~lgort IN s_lgort.

0 Kudos

thanq.

my impression is that, If we leave as blank any thing in the selection criteria of the selection screen, i thought that, SAP wuld treate as ALL VKORGs ( all Sales Orgs), bcoz I did not INPUT any thing, so, it is just wide open!!

thanq

former_member193335
Active Participant
0 Kudos

Srinivas:

Your SELECT does not work because you left parameter P_VKORG blank. I suppose there are no records that meet your selection criteria ( MVKE-VKORG = blank).

I suggest you to change P_VKORG, from PARAMETER to SELECT OPTIONS, and use P_VKORG the following way:

SELECT-OPTIONS: s_prodh FOR mvke-prodh,

s_mvgr2 FOR mvke-mvgr2,

s_matnr FOR mvke-matnr,

S_VKORG FOR mvke-vkorg.

PARAMETERS: p_werks TYPE mard-werks.

SELECT-OPTIONS: s_lgort FOR mard-lgort.

SELECT

vmatnr vvkorg vvtweg vvmsta

dlabst dinsme d~speme

INTO CORRESPONDING FIELDS OF TABLE it_itab

FROM mvke AS v

INNER JOIN mard AS d ON dmatnr = vmatnr

WHERE v~matnr IN s_matnr AND

v~vkorg IN s_vkorg AND

v~vmsta = '33' AND

v~vmstd GE sy-datum AND

v~prodh IN s_prodh AND

v~mvgr2 IN s_mvgr2 AND

d~werks = p_werks AND

d~lgort IN s_lgort.

This way you do not need to worry if parameter is left blank or not.

Regards.

Rafael Rojas.

0 Kudos

my impression is that, If we leave as blank any thing in the selection criteria of the selection screen, i thought that, SAP wuld treate as ALL VKORGs ( all Sales Orgs), bcoz I did not INPUT any thing, so, it is just wide open!!

thanq

0 Kudos

your assumption is right only for select options not parameters , if parameter is left blank it consider it as a vlaue ' '.