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

Internal Table

Former Member
0 Likes
742

Hi,

I have an internal table with 12 fields.

I have loaded the data in the internal table from a database table but only in 10 fileds.

Now, I have to update the remaining 2 fields for all records with only one value .

How can I do it ?

Is there any direct modify statement to update all the records of the internal table ?

or only loop is the only method ?

Bye,

Satya.

1 ACCEPTED SOLUTION
Read only

former_member491305
Active Contributor
0 Likes
723

Hi,

WA_mara-field6 = 'X'.

WA_mara-field7 = 'X'.

Modify it_mara from wa_mara

Transporting field6 field7 where field6 ne 'X' or field7 ne 'X'.

Using this you can modify all the lines of the internal table with one line statement.

Message was edited by:

Vigneswaran S

8 REPLIES 8
Read only

Former Member
0 Likes
723

Hi

Use...

FIELD-SYMBOLS : <fs_tab> like line of itab.

LOOP AT itab ASSIGNING <fs_tab>.

<fs_tab>-field11 = value.

<fs_tab>-field12 = value.

ENDLOOP.

Regards

Raj

Read only

former_member491305
Active Contributor
0 Likes
724

Hi,

WA_mara-field6 = 'X'.

WA_mara-field7 = 'X'.

Modify it_mara from wa_mara

Transporting field6 field7 where field6 ne 'X' or field7 ne 'X'.

Using this you can modify all the lines of the internal table with one line statement.

Message was edited by:

Vigneswaran S

Read only

Former Member
0 Likes
723

Hi

LOOP AT ITAB.

l_tabix = sy-tabix.

select single f1 f2 into (v1, v2) from DBTABLE where f1 = itab-f1.

if sy-subrc = 0.

itab-f11 = v1.

itab-f12 = v2.

modify itab index l_tabix.

endif.

endloop.

This will update the the 2 left out fields

<b>

Reward points for useful Answers</b>Regards

Anji

Read only

Former Member
0 Likes
723

Hi,

you can update the data within the LOOP.. ENDLOOP using MODIFY statement.

Use MODIFY <INTERNAL TABLE>.. TRANSPORTING FIELD1 FIELD2.

If its not within the LOOP, use INDEX with MODIFY.

Regards

Lata

Read only

Former Member
0 Likes
723

Hi,

i know only this way:

loop at itab. itab-11 = '#'. itab-12 = '#'. mdify itab. endloop.

regards, dieter

Read only

Former Member
0 Likes
723

Hi,

Check the below code.

PARAMETERS: p_carrid TYPE sflight-carrid,

p_connid TYPE sflight-connid,

p_plane1 TYPE sflight-planetype,

p_plane2 TYPE sflight-planetype.

DATA sflight_tab TYPE SORTED TABLE OF sflight

WITH UNIQUE KEY carrid connid fldate.

DATA sflight_wa TYPE sflight.

SELECT *

FROM sflight

INTO TABLE sflight_tab

WHERE carrid = p_carrid AND

connid = p_connid.

sflight_wa-planetype = p_plane2.

MODIFY sflight_tab FROM sflight_wa

TRANSPORTING planetype WHERE planetype = p_plane1.

Read only

Former Member
0 Likes
723

as per my knowledge u can only modify all the lines of the internal table by using loop.

Regs,

Saurabh

Read only

Former Member
0 Likes
723

You cannot directly modify a coloumn in one go, u have to write modify code in LOOP...ENDLOOP.