2012 Jan 15 12:59 AM
Hello Experts,
I'm a beginner and my teacher said that I need create an report of the table VBAK and it need relating with the itens from table VBAP. I tried of my way but didn't work. Anyone can give me a idea?
I tried something like this:
DATA: BEGIN OF wa_vbak OCCURS 0,
vbeln TYPE vbak-vbeln,
erdat TYPE vbak-erdat,
END OF wa_vbak.
DATA: BEGIN OF wa_vbap OCCURS 0,
vbeln LIKE vbak-vbeln,
erdat LIKE vbak-erdat,
posnr TYPE vbap-posnr,
END OF wa_vbap.
SELECT vbeln erdat INTO TABLE wa_vbap FROM VBAK UP TO 10 ROWS.
IF sy-subrc = 0.
LOOP AT wa_vbak.
WRITE: /
wa_vbap-vbeln,
wa_vbap-erdat.
ENDLOOP.
ENDIF.
But I think this is wrong. hehe.
Thanks in advance and regards.
Edited by: vsugamele1 on Jan 15, 2012 2:41 AM
Moderator Message: Basic question. Thread locked.
Edited by: Suhas Saha on Jan 15, 2012 11:05 AM
2012 Jan 15 3:35 AM
types: begin of ty_vbak,
vbeln type vbeln_va,
erdat type erdat,
end of ty_vbak.
types : begin of ty_vbap,
vbeln type vbeln_va,
posnr type posnr_va,
arktx type arktx,
end of ty_vbap.
types : begin of ty_final,
vbeln type vbeln_va,
erdat type erdat,
posnr type posnr_va,
arktx type arktx,
end of ty_final.
* I T Declaration
data : it_vbak type standard table of ty_vbak.
it_vbap type standard table of ty_vbap,
it_final type standard table of ty_final,
* Work Area Declaration
wa_final type ty_final, " Avoid using headerlines, use explicit work areas instead.
wa_vbap type ty_vbap,
wa_vbak type ty_vbak.
refresh it_vbak[].
select vbeln erdat
from vbak
up to 10 rows
into table it_vbak.
refresh it_vbap[].
if it_vbak[] is not initial. " very imp. before using for all entries.
select vbeln erdat posnr arktx
for all entries in it_vbak
from vbap
into table it_vbap.
endif.
clear wa_vbak.
clear wa_vbap.
clear wa_final.
refresh it_final.
* Populating the final table with vbak & vbap details.
loop at it_vbak into wa_vbak.
wa_final-vbeln = wa_vbak-vbeln.
wa_final-erdat = wa_vbak-erdat.
loop at it_vbap into wa_vbap where vbeln = wa_vbak-vbeln. " to find matching header and item records
wa_final-posnr = wa_vbap-posnr.
wa_final-arktx = wa_vbap-arktx.
append wa_final to it_final.
endloop.
endloop.
clear wa_final.
loop at it_final into wa_final.
write : / wa_final-vbeln, wa_final-erdat, wa_final-posnr, wa_final-arkts.
endloop.
2012 Jan 15 4:24 AM
Hi,
Welcome to SCN.This is a basic question.Read the documentation of the key words and use it.If you ask basic question it may be locked.
Regards,
Madhu.