on 10-24-2014 10:31 AM
Hi,
DATA: ITAB TYPE TABLE OF ZV_SDR1 WITH HEADER LINE.
* ITAB Holds the data collected from view table zv_sdr1
DATA: BEGIN OF P_ITAB OCCURS 0,
LA_VBELN TYPE VBRK-VBELN,
LA_PERNR TYPE VBPA-PERNR,
LA_WGBEZ TYPE V023-WGBEZ,
END OF P_ITAB.
select * from zv_sdr1 into corresponding fields of table ITAB.
if sy-subrc = 0 and itab is not initial.
SELECT WGBEZ
FROM T023T INTO P_ITAB-LA_WGBEZ FOR ALL ENTRIES IN ITAB
WHERE MATKL = ITAB-MATKL.
ENDSELECT.
SELECT PERNR FROM VBPA INTO P_ITAB-LA_PERNR FOR ALL ENTRIES IN ITAB
WHERE VBELN = ITAB-VBEL AND PARVW = 'PE'.
ENDSELECT.
end if.
I WANT TO INSERT WEBEZ AND PERNR INTO P_ITAB FOR ALL ENTRY BASED ON ITAB.
BUT I AM GETTING SAME VALUE FOR ALL ROWS IN P_ITAB
GUIDE ME THE BETTER WAY TO DO THIS.
Hi Murali,
SELECT WGBEZ
FROM T023T INTO table i_wgbez FOR ALL ENTRIES IN ITAB
WHERE MATKL = ITAB-MATKL.
SELECT PERNR FROM VBPA INTO table i_pernr FOR ALL ENTRIES IN ITAB
WHERE VBELN = ITAB-VBEL AND PARVW = 'PE'.
loop at itab.
read table i_wgbez into wa_wgbez with key MATKL = ITAB-MATKL.
read table i_pernr into wa_pernr with key MATKL = ITAB-MATKL.
p_itab-WGBEZ = wa_wgbez-wgbez.
p_itab-pernr = wa_wgbez-pernr .
append p_itab.
ENDLOOP.
thanks,
Anil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi murali,
The select statement which you have written is not correct.
First you create two internal table for fetching data from T023T and VBPA with required key fields.
Then change your second and 3rd select statement .
ie,
in second select statement instead of INTO P_ITAB-LA_WGBEZ use INTO table <tablename>.
change the remaining select statement like this.
Then try to merge the tables based on the particular key relationship by loop and read.
Regards,
Sajeesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
the way you have written ur selects wont work, fetch the data into 2 internal tables separately then loop at ptab.
LOOP at p_tab assigning <FS>.
"use read table to get the value and fill them in the field symbol which would automatically update the p_tab.
U need appropriate keys to match and read.
ENDLOOP
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
9 | |
4 | |
3 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.