‎2010 Mar 05 11:56 AM
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
‎2010 Mar 05 12:12 PM
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
‎2010 Mar 05 11:59 AM
Sorry your question is not clear. Elaborate your question properly.
‎2010 Mar 05 12:06 PM
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.
‎2010 Mar 05 12:12 PM
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
‎2010 Mar 05 12:21 PM
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
‎2010 Mar 05 12:24 PM
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.
‎2010 Mar 05 12:28 PM
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
‎2010 Mar 05 12:31 PM
If I am using at new its only updating the first record for that profile.
Thanks and Regards,
P. Varun Kumar.
‎2010 Mar 05 12:31 PM
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
‎2010 Mar 05 12:42 PM