Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Modify an internal table value another internal table loop

Former Member
0 Likes
3,321

How to Modify an internal table value another internal table loop?

LOOP AT t_final_n.

READ TABLE t_covp_ks WITH KEY kokrs = t_final_n-kokrs

objnr = t_final_n-c_objnr

gjahr = t_final_n-gjahr

perio = t_final_n-monat

objnr_n1 = t_final_n-p_objnr

chk = ' '.

IF sy-subrc EQ 0.

MOVE : t_covp_ks-belnr TO t_final_n-r_belnr,

t_covp_ks-bldat TO t_final_n-bldat,

t_covp_ks-refbn TO t_final_n-refbn,

t_covp_ks-wtgbtr TO t_final_n-wtgbtr,

'X' TO t_covp_ks-chk.

Modify : t_covp_ks.

READ TABLE t_covp_pr INTO wa_covp_pr WITH KEY kokrs = t_covp_ks-kokrs

belnr = t_covp_ks-belnr

objnr = t_covp_ks-objnr_n1

gjahr = t_covp_ks-gjahr

perio = t_covp_ks-perio

objnr_n1 = t_covp_ks-objnr.

IF sy-subrc EQ 0.

MOVE : wa_covp_pr-wtgbtr TO t_final_n-wlp00.

ENDIF.

ENDIF.

MODIFY : t_final_n.

CLEAR : t_final_n, wa_rpsco_c.

ENDLOOP.

Here in this loop of t_final_n, i would like to modify t_covp_ks after a matched record is fetched. How to solve this problem. Now this code is giving dump becoz of modify ?

7 REPLIES 7
Read only

Former Member
0 Likes
1,022

Hi,

Try this..The changes are marked in bold..

<b>DATA: V_TABIX TYPE SYTABIX.</b>

LOOP AT t_final_n.

READ TABLE t_covp_ks WITH KEY kokrs = t_final_n-kokrs

objnr = t_final_n-c_objnr

gjahr = t_final_n-gjahr

perio = t_final_n-monat

objnr_n1 = t_final_n-p_objnr

chk = ' '.

IF sy-subrc EQ 0.

<b>V_TABIX = SY-TABIX.</b>

MOVE : t_covp_ks-belnr TO t_final_n-r_belnr,

t_covp_ks-bldat TO t_final_n-bldat,

t_covp_ks-refbn TO t_final_n-refbn,

t_covp_ks-wtgbtr TO t_final_n-wtgbtr,

'X' TO t_covp_ks-chk.

<b>Modify t_covp_ks INDEX V_TABIX.</b>

READ TABLE t_covp_pr INTO wa_covp_pr WITH KEY kokrs = t_covp_ks-kokrs

belnr = t_covp_ks-belnr

objnr = t_covp_ks-objnr_n1

gjahr = t_covp_ks-gjahr

perio = t_covp_ks-perio

objnr_n1 = t_covp_ks-objnr.

IF sy-subrc EQ 0.

MOVE : wa_covp_pr-wtgbtr TO t_final_n-wlp00.

ENDIF.

ENDIF.

MODIFY : t_final_n.

CLEAR : t_final_n, wa_rpsco_c.

ENDLOOP.

THanks,

Naren

Read only

0 Likes
1,022

Hi narendra....Thank you...it worked ...

And i have Given points..

I have a doubt in internal tables..Hope you would clarify it.

If the same thing , i do it in a work area and want to update it an internal table without header line. How do i do that?

Read only

0 Likes
1,022

MODIFY ITAB FROM WA WHERE ...

OR

MODIFY ITAB FROM WA INDEX V_TABIX.

here WA is your WORK AREA.

Regards

srikanth

Read only

Former Member
0 Likes
1,022
LOOP AT t_final_n.

READ TABLE t_covp_ks WITH KEY kokrs = t_final_n-kokrs
objnr = t_final_n-c_objnr
gjahr = t_final_n-gjahr
perio = t_final_n-monat
objnr_n1 = t_final_n-p_objnr
chk = ' '.
IF sy-subrc EQ 0.
MOVE : t_covp_ks-belnr TO t_final_n-r_belnr,
t_covp_ks-bldat TO t_final_n-bldat,
t_covp_ks-refbn TO t_final_n-refbn,
t_covp_ks-wtgbtr TO t_final_n-wtgbtr,
'X' TO t_covp_ks-chk.
Modify : t_covp_ks <b>where kokrs = t_final_n-kokrs
objnr = t_final_n-c_objnr
gjahr = t_final_n-gjahr
perio = t_final_n-monat
objnr_n1 = t_final_n-p_objnr
chk = ' '.</b>.
READ TABLE t_covp_pr INTO wa_covp_pr WITH KEY kokrs = t_covp_ks-kokrs
belnr = t_covp_ks-belnr
objnr = t_covp_ks-objnr_n1
gjahr = t_covp_ks-gjahr
perio = t_covp_ks-perio
objnr_n1 = t_covp_ks-objnr.
IF sy-subrc EQ 0.
MOVE : wa_covp_pr-wtgbtr TO t_final_n-wlp00.
ENDIF.
ENDIF.
MODIFY : t_final_n.
CLEAR : t_final_n, wa_rpsco_c.

ENDLOOP.

you can give the WHERE clause along with MODIFY statement will work for your purpose. as you are reading the entry by giving some condition,you can give the SAME condition to MODIFY that ENTRY.

Regards

Srikanth

Message was edited by: Srikanth Kidambi

Read only

Former Member
0 Likes
1,022

hi,

check this..

LOOP AT t_final_n.

READ TABLE t_covp_ks WITH KEY kokrs = t_final_n-kokrs

objnr = t_final_n-c_objnr

gjahr = t_final_n-gjahr

perio = t_final_n-monat

objnr_n1 = t_final_n-p_objnr

chk = ' '.

IF sy-subrc EQ 0.

MOVE : t_covp_ks-belnr TO t_final_n-r_belnr,

t_covp_ks-bldat TO t_final_n-bldat,

t_covp_ks-refbn TO t_final_n-refbn,

t_covp_ks-wtgbtr TO t_final_n-wtgbtr,

'X' TO t_covp_ks-chk.

Modify t_covp_ks <b>Transporting chk</b>.

READ TABLE t_covp_pr INTO wa_covp_pr WITH KEY kokrs = t_covp_ks-kokrs

belnr = t_covp_ks-belnr

objnr = t_covp_ks-objnr_n1

gjahr = t_covp_ks-gjahr

perio = t_covp_ks-perio

objnr_n1 = t_covp_ks-objnr.

IF sy-subrc EQ 0.

MOVE : wa_covp_pr-wtgbtr TO t_final_n-wlp00.

ENDIF.

ENDIF.

MODIFY : t_final_n <b>transporting r_belnr n-bldat n-refbn wtgbtr n-wlp00.</b>

CLEAR : t_final_n, wa_rpsco_c.

ENDLOOP.

Read only

Former Member
0 Likes
1,022

Hi,

write like:

Modify t_covp_ks transporting bldat refbn refbn wtgbtr.

Regards

Sudheer

Read only

Former Member
0 Likes
1,022

Hi,

use the FROM addition for updating it from the work area..

MODIFY t_covp_ks FROM WA INDEX V_TABIX..

Thanks,

Naren