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

Update internal table rows based on values from a single row

Former Member
0 Likes
2,982

Hello Group,

Please could you help me on this below requirement:

I want to change CHANGED TIME (AEZET) for the record only once, as it is a key field in the Internal table.

ZPROFILE_ID ZPROF_MONTH ZPRO_EFF_DATE ZOPER_UNIT AEZET ZVALUE_PERC

P003 |201001 |20110503 |SESA |114642| 10.0000 |

P003 |201002 |20110503 |SESA |114644| 90.0000 |

Now I have to take the last value for AEZET that is 114644, I have to use this value and show up in the above record also. Can you let me know how do I do this?

Many Thanks,

Jagan.

Moderator message: subject corrected, please use a more meaningful one next time.

Edited by: Thomas Zloch on Mar 5, 2010 1:14 PM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,890

Hello Jagan,

Try something like this,



data: v_aezet type ztable-aezet.

sort itab by AEZET descending.

read table itab index 1. 
v_aezet = itab-aezet.

clear itab.

loop at itab.
itab-aezet = v_aezet.
modify itab.
endloop.

Vikranth

9 REPLIES 9
Read only

Former Member
0 Likes
1,890

Sorry your question is not clear. Elaborate your question properly.

Read only

0 Likes
1,890

Hello Vikranth,

Thanks for your reply. Here is the requirement

I have to use that last value for the changed time field (aezet), and modify my complete internal table with that value for every profile (ZPROFILE_ID), here in the example I have to modify every record of P003 with that last value of AEZET.

Please let me know if you got my question....

Many Thanks,

Jagan.

Read only

Former Member
0 Likes
1,891

Hello Jagan,

Try something like this,



data: v_aezet type ztable-aezet.

sort itab by AEZET descending.

read table itab index 1. 
v_aezet = itab-aezet.

clear itab.

loop at itab.
itab-aezet = v_aezet.
modify itab.
endloop.

Vikranth

Read only

0 Likes
1,890

Shorter

DATA wa_itab LIKE LINE OF itab.
SORT itab BY aezet DESCENDING.
READ TABLE itab INTO wa_itab INDEX 1.
MODIFY itab FROM wa_itab TRANSPORTING aezet
  WHERE aezet NE wa_itab-aezet.

But you wrote

as it is a key field

in this case (SORTED type table) you wont be able to update (nor SORT) the internal table, but need to delete and re-insert the records.

Regards,

Raymond

Read only

0 Likes
1,890

We are close to the solution I feel.

Here in my itab I have different profiles which will have one to many connection for zperc_value and aezet values.

profile aezet zvalue_perc

P001 17:43:07 20.0000

P001 17:42:22 90.0000

P001 17:43:10 80.0000

P002 18:08:18 10.0000

P002 18:08:19 20.0000

P002 18:08:21 30.0000

P002 18:08:22 40.0000

P002 18:08:28 0.0000

Now for every last aezet of the profile, I have to modify that complete profile values with that aezet value.

That is 17:43:10 for P001 should be updated for all the aezet values for the same P001 and like wise for all the new profiles respectively.

Many Thanks,

Jagan.

Read only

0 Likes
1,890

hi!

with in loop you can use at new .

sort itab.

loop at itab.

at new aezet.

read itab index sy-index.

endloop.

Edited by: dharma raj on Mar 5, 2010 5:59 PM

Read only

0 Likes
1,890

If I am using at new its only updating the first record for that profile.

Thanks and Regards,

P. Varun Kumar.

Read only

0 Likes
1,890

Try something like

DATA: wa_itab LIKE LINE OF itab,
      last_itab LIKE LINE OF itab.
SORT itab BY profile aezet.
LOOP AT itab INTO wa_itab.
  last_itab = wa_itab. " store last value
  AT END OF profile. " here cursor is already before next profile value
    MODIFY itab FROM last_itab TRANSPORTING aezet
      WHERE profile = last_itab-profile. " whole profile updated
  ENDAT.
ENDLOOP.

Regards,

Raymond

Read only

0 Likes
1,890

Many Thanks for your time, issue resolved....

Regards,

Jagan.