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: 

SQL Syntax Question

Former Member
0 Kudos

Hello everyone: I am trying to write an SQL query in ABAP function. I know how to write it in Oracle but not sure how to write it in ABAP. For example

DATA: begin of wa_ITAB_SALESRECS,

ZVBELN type VBELN_VA,

ZPOSNR type POSNR_VA,

end of WA_ITAB_SALESRECS,

ITAB_SALESRECS LIKE HASHED TABLE OF WA_ITAB_SALESRECS WITH UNIQUE KEY ZVBELN ZPOSNR.

Select VBAK, '' from VBAK

UNION ALL

Select VBELN, POSNR from VBAP

I'm trying to enter the result into wa_itab_salesrecs.

Please note that '' in the first select statement is a blank. I don't know the syntax for blanks.

So what I want to know is:

1. What is the syntax to enter blank

2. What is the syntax for UNION.

Thanks

R

5 REPLIES 5

Former Member
0 Kudos

select *

from vbak

into table it_vbak.

select vbeln

posnr

from vbap

for all entries in it_vbak

where vbeln = it_vbak-vbeln.

0 Kudos

Mohammed, what part of my question is your response answering? Looks like you're very new to SAP so let me know if you really didn't understand the question at all and I can clarifiy it for you. Thanks

Janagar: I was looking for the exact syntax and I'm not sure how using the inner join can fix the problem but Ill follow your suggestion about using F1 for help.

Thank you gentlemen

R

0 Kudos

Hi Romina, what do you mean by blank in the SELECT statement. I believe what Mohammad given will solve your problem. or else try the below statement:

data: l_auart like vbak-auart.

clear l_auart.

Select aVbeln bposnr a~vbtyp into table it_vbakvbap

from VBAK as A

JOIN VBAP as B

ON amandt = bmandt and

avbeln = bvbeln

WHERE

auart = l_auart.

Hope this help.

Rgds,

Jey

0 Kudos

Romina,

Be 'nicer' to people who answer your queries. I am refering to your 'new to SAP' in response to Mohammed's reply. Appreciate that he has tried to answer your query..

Madan...

Former Member
0 Kudos

use inner join or for all enteries

use F1 help by typing this in editor

hope u will get that