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

Former Member
0 Likes
1,141

Hi all,

The following is a piece of code i have in a program.

But I cant see any data is getting fetched into itab "i_vbak" although there is data for this.

I ran it in debug mode to see.

Anybody please suggest me what went wrong with this.

<b>tables: vbak,

vbap.

parameters: p_matnr like vbap-matnr obligatory,

p_charg like vbap-charg obligatory,

p_kunnr like vbak-kunnr.

select-options: s_audat FOR vbak-audat.

data: begin of i_vbak occurs 0,

vbeln like vbak-vbeln,

bstnk like vbak-bstnk,

end of i_vbak.

select vbakvbeln vbakbstnk

into table i_vbak

from vbak inner join

vbap

on vbakvbeln = vbapvbeln

where vbap~matnr = p_matnr

and vbap~charg = p_charg

and vbak~kunnr = p_kunnr

and vbak~audat IN s_audat.</b>

Thanks a lot,

Message was edited by: sam jose

13 REPLIES 13
Read only

Former Member
0 Likes
1,108

Hi,

If the parameters are not mandatory..Then it will blank values in the table VBAP..

Use SELECT-OPTIONS p_matnr NO-EXTENSION NO INTERVALS..

This way it will allow only single value..

And modify the your query to

<b> vbap~matnr IN p_matnr</b> instead of "="

Thanks,

Naren

Read only

0 Likes
1,108

Narendran,

The "matnr" and "charg" are mandatory.

Thnx.

Read only

Former Member
0 Likes
1,108

There does not seem anything wrong with the query just check if there are records for the particular selection in your vbak/vbap table.

Secondly, the problem can be related to format of the fields(basically the data content like leading zeroes etc).

Regards

Anurag

Read only

0 Likes
1,108

Anurag,

I have even checked it with the correct format of the data for selection-screen.

Thnx.

Read only

0 Likes
1,108

Sam,

Hmm..interesting, as there is nothing wrong with the querry. I would suggest to check with one where condition at a time and see if it is fetching data..by that you would be able to find the cause !!

I mean just use matnr first and if it does fetch data try with matnr and charg ...etc. I presume that you are feeling all your parameters as if you leave it blank it will try and check for blank data.

Message was edited by: Anurag Bankley

Message was edited by: Anurag Bankley

Read only

suresh_datti
Active Contributor
0 Likes
1,108

change the select to


select a~vbeln a~bstnk
into table i_vbak
from vbak as a
inner join  vbap as b
on a~vbeln = b~vbeln
where b~matnr = p_matnr
and b~charg = p_charg
and a~kunnr = p_kunnr
and a~audat IN s_audat.

~Suresh

Read only

Former Member
0 Likes
1,108

Hi,

How about customer..

<b>p_kunnr like vbak-kunnr</b>

Is customer also mandatory..

Thanks,

Naren

Read only

0 Likes
1,108

Nope.

<b>P_kunnr</b> and <b>s_audat</b> are not mandatory.

Thnx.

Read only

Former Member
0 Likes
1,108

Hi Sam,

1) I doubt have you specified START-OF-SELECTION in your report.

If not have START-OF-SELECTION before your SELECT query.

2) Did you leave KUNNR field empty while running the report. If so, it wont fetch any data.Specify some value to KUNNR field.

Thanks,

Vinay

Read only

Former Member
0 Likes
1,108

Hi,

That is the reason why you are not getting any records..

Since the customer is blank..it will look for records with blank values..

Instead use select-options for the customer as I mentioned above..

Please reward the points if it is helpful..

Thanks,

Naren

Read only

0 Likes
1,108

I hve specified "Start-of-selection" also in code.

Narendran,

Thanks for the response.

The user wants to get the data based on "MATNR" and "CHARG". He also wants to see the data by "KUNNR" sometimes. That's the reason I have the "P_KUNNR" on the selection-screen.

In that case how should design the selection-screen.

Plz advise.

Thnx.

Read only

0 Likes
1,108

The best is to define it as a select-option with no intervals.

and in select query use vbak~kunnr in s_kunnr.

OR

Define a range for customer

Range : r_kunnr for vbak~kunnr.

if p_kunnr ne space.

r_kunnr-low = p_kunnr.

r_kunnr-sign = 'I'

r_kunnr-option = 'EQ'.

append r_kunnr.

endif.

SELECT ...

where..

vbak~kunnr in r_kunnr.

Regards

Anurag

Message was edited by: Anurag Bankley

Read only

Former Member
0 Likes
1,108

Hi,

Use SELECT-OPTIONS p_KUNNR for vbak-kunnr NO INTERVALS NO-EXTENSION ..

And change the query to IN P_KUNNR instead of = P_KUNNR..

Thanks,

Naren