cancel
Showing results for 
Search instead for 
Did you mean: 

how to Update single field of internal table based on another internal table.

Former Member
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

former_member202771
Contributor
0 Kudos

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

Answers (2)

Answers (2)

Former Member
0 Kudos

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

former_member205763
Active Contributor
0 Kudos

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