I know it's a long shot to ask for help, but perhaps we have some SAP members in the forum?
Please note-I can describe the problem in further detail if needed.
My problem relates to querying data to create a report in SAP utilizing ABAP, however my prof has not even touched on the subject or attempted to explain how this would be achieved. Additionally we don't have a textbook of any kind.
Currently, I'm trying to create a report which lists several things (ex: order #, sales #, mat#,etc) from tables already present in SAP (VBAK,MARAV). The assignment requires I call certain fields within these tables (specifically material numbers for my materials). The problem with this is we have only learned how to select everything from a table..for example-
select * from VBAK.
WRITE / VBAK-VBELN.
ENDSELECT.
I've tried sql and similar languages, however I just don't know ABAP well enough to know what I'm doing.
I appreciate any thoughts or input..Hopefully.
Posts
i'd do it like
TYPES: BEGIN OF vbak_data,
d_vbakid LIKE vbak-part_id,
*all other data types you want from the table goes in here*
END OF vbak_data.
DATA: itab_vbak_data TYPE STANDARD TABLE OF vbak_data,
wa_vbak_data TYPE vbak_data.
SELECT vbak~part-id
INTO TABLE itab_vbak_data
FROM vbak
LOOP AT vbak_inventory_data INTO vbak_inventory_data.
WRITE : / wa_vbak_data-d_vbakid.
endloop.
and of course you'd need to make a seperate new table (mine was wa_vbak_data) for each seperate SAP table you'd want to grab them from, and write them all out.
This is the only way I know how to do it, but like I said it seems pretty complicated compared to what you've done so far so I might be over complicating things
edit: you can also do joins on your select statements when selecting from multiple tables with
SELECT vbak~part-id, vbak2~wookie
INTO TABLE itab_vbak_data
FROM vbak JOIN vbak2
but it can get a bit tricky, looking at your examples you could try
select vbak~order#, marav~sales#
from vbak join marav
on vbak~order# = marav~order#. (these will be like your sql primary/foreign key relationship)
write: / vbak-order#.
write:/marav-order#.
not pulling them into an internal table first is something you'd never do in a real app, but for an assignment, why not
And yes, that's what I am "suppose to be doing", welcome to the hell that is my professor.
I can depict some things from your statements, however I'm not really familiar with the syntax. We've only recently been introduced to data types of integer and packed, additionally setting variables "like" eachother and "DATA" as a means of performing simple calculations (+ - / mod). With some work in databases. (se11 and the like)
I'm not sure of the significance of the ~ in SAP, so I can't really begin to attempt utilization of it. Perhaps some insight could be given if I show you what I've got thus far.
TABLES MARAV.
Tables VBAK.
WRITE 'Ord # '. write 'Item # '.
Write 'Mat. # '. write 'Description'.
uline.
select * from VBAK.
WRITE / VBAK-VBELN.
ENDSELECT.
With this being the output. However, I only need Sales Order #11.
Regardless, thanks for your time thus far.
select * from VBAK
WHERE vbak-order#(i don't know what your order# column is actually named in vbak,so substitute it here)= '11'.
to get things from two tables you'd go
select *
from vbak join marav
on vbak~(whatever column is in both vbak and marav) join marav~(whatever column is in both vbak and marav)
WHERE vbak-order#(i don't know what your order# column is actually named in vbak,so substitute it here)= '11'.
WRITE / VBAK-VBELN.