Abap

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

Report VBAK table

parameter: p_vbeln type vbeln_va.

Types: Begin of lty_data,


vbeln type vbeln_va,
erdat type erdat.

Types: Begin of lty_data1,


vbeln type vbeln_va,
posnr type posnr_va,
END OF lty_data1.

Types: Begin og lty_final,


vbeln type vbeln_va,
erdat type erdat,
posnr type posnr_va,
End of lty_final.

Data: lt_data type table of lty_data


Data: lt_data1 type table of lty_data1

select vbeln erdat OR select vbeln erdat


into lt_data into corresponding fields of table lt_data
from vbak from vbak
where vbeln = p_vbeln. where vbeln = p_vbeln.

select vbeln posnr


into table lt_data1
from vbap
for all enteries in lt_data **(to join the tables)
where vbeln = lt_data-vbeln. ** ( common key is vbeln)

OR
(Combining these two queries - by declaring a type begin of lty_final)

Select vbeln erdat posnr


into table lt_final
from vbak as L1
Join VBAP as L2
on L1- Vbeln = L2-vbeln
Where VBELN = P_VBELN

OR

Select A-vbeln A-erdat B-posnr


into table lt_final
from vbak as L1
Join VBAP as L2
on L1- Vbeln = L2-vbeln
Where VBELN = P_VBELN

LOOP AT
(** always avoid using the corresponding word)

(** in the first table vbeln is the primary key also the primary key table and in
the second table vbap is the foreign key table whoch has vbeln and posnr is the
primary key)
se colums from
(** ALWAYS USE for all enteries in as performance wise it is better)

(** try not using star word(*) from the table it will put load on the code.)- only
fetch those colums from the database tables.

(** use same sequence to that of data dictonary query)

You might also like