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

How to write the Select Query on database view?

satish_kumar127
Participant
0 Likes
7,815

Hi guys,

trying to write select query on database view ( COAS)  to fetch the "objnr"  value which is  existing. But i'm failing to get it.

sharing my code below

SELECT SINGLE objnr FROM coas INTO lv_objnr WHERE aufnr = "lv_aufnr.    "   lv_aufnr is having value


I've tried like following also


SELECT * FROM coas INTO CORRESPONDING FIELDS OF TABLE it_coas WHERE aufnr = lv_aufnr.



can anybody please help me out in this.


Thanks in Advance.


Regards


satish

14 REPLIES 14
Read only

former_member585060
Active Contributor
0 Likes
3,863

Hi,

How you have declared lv_aufnr and what value you are pass into it. It might be some leading zeros missing.

Ex:- For 1000, try to provide '000000001000'.

Thanks & Regards

Bala Krishna

Read only

0 Likes
3,863

Hi bala krishna,

I've declared lv_aufnr as    data:   lv_aufnr TYPE aufnr.   (order no)

lv_aufnr is having the value like 500020. there are no leading zero's and all.

thanks & Regards

satish

Read only

0 Likes
3,863

Hi,

It seems you have hard coded the value, just pass this value and see '000000500020'. Just check what is value shown in AUFK table, as COAS is database view on AUFY table.

You have to add leading zeros into lv_aufnr using conversion exits.

Thanks & Regards

Bala Krishna

Read only

0 Likes
3,863

Hi bala krishna,

Thanks a lot . My problem has been solved. I've concatenated zeros to aufnr value. now it's working.

Regards,

satish

Read only

Former Member
0 Likes
3,863

Hi,

Try this function module.

'VIEW_GET_DATA'

Or try to use conversion exit for leading zeros in your select statement

Regards,

Karthik

Read only

kiran_k8
Active Contributor
0 Likes
3,863

Satish.

I don't think we can write a select query on a VIEW.

K.Kiran.

Read only

0 Likes
3,863

Hi Kiran,

It is a database view, so you can write select query on it.

Thanks & Regards

Bala Krishna

Read only

thangam_perumal
Contributor
0 Likes
3,863

Hi Sathish,

             its an conversion exit problem. we have to add leading zeros in front..

please use below function module it will resolve your problem.

let me know if facing same problem again.

Regards,

Thangam.P

Read only

0 Likes
3,863

hi thangam perumal,

in my case there are no leading zero's, i'm having the value straight away.  like lv_aufnr = 500020.

same matching aufnr value is there in  COAS .   but data is not picking up.

Thanks & Regards

satish

Read only

0 Likes
3,863

Hi thangam p,

Your right,

Thanks a lot  I've concatenated zeros to aufnr value. now it's working.

Thanks & Regards,

satish

Read only

thangam_perumal
Contributor
0 Likes
3,863

Hi Sathish,

               if you got solution for your query please mark it has correct answer or helpful answer because it will helps to someone who facing same problem. I hope you got what am saying .

Regards,

Thangam.P

Read only

Former Member
0 Likes
3,863

hi satish,

                   kindly provide the exact coding and value of the field store in data base table so

that we help you in better way.

regards,

vikas

Read only

satish_kumar127
Participant
0 Likes
3,863

Hi guys,

Thanks a lot for your help and ideas.  My issue has been resolved.

Regards

satish

Read only

Former Member
0 Likes
3,863

Hi,

You can write exaclty the same kind of SQLs on a view that you can for a table.

BR,

Nathan