10-07-2008 7:17 AM
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
10-07-2008 7:23 AM
select *
from vbak
into table it_vbak.
select vbeln
posnr
from vbap
for all entries in it_vbak
where vbeln = it_vbak-vbeln.
10-07-2008 6:03 PM
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
10-08-2008 4:22 AM
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
10-08-2008 4:59 AM
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...
10-07-2008 7:52 AM
use inner join or for all enteries
use F1 help by typing this in editor
hope u will get that