02-09-2009 3:31 AM
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE R_UCOMM.
WHEN '&ENT'.
LOOP AT IT_MARD.
IF IT_MARD-RP_MONTH <> 0.
IT_MARD-COVER = ( IT_MARD-T_STOCK * 26 ) / IT_MARD-RP_MONTH.
ELSE.
IT_MARD-COVER = 0.
ENDIF.
MODIFY IT_MARD.
ENDLOOP.
WHEN '&SAVE'.
LOOP AT IT_MARD.
MOVE-CORRESPONDING IT_MARD TO ZROC.
MODIFY ZROC.
ENDLOOP.
MESSAGE 'Entries are saved in table' TYPE 'I'.
ENDCASE.
in the above zroc is the table created by me for storing datas.
initially i am saving 5000 as default to it_mard-rp_month which is updating in zroc-rp_month.
if i give save it is saving in particular table.if i again execute the same program i should get the
save values.for that how i have to write query for getting it from zroc table.
02-09-2009 3:52 AM
Hi...
with the statement MODIFY ZROC u r modifing internal table not DB table. so that u r getting same old entries when u execute again.
update DB table. so that u won't get this problem.
MODITY ZROC FROM TABLE ZROC
and end of the program clear and free momory associated to all internal tables and work areas used in program.
Regards,
KP.
02-09-2009 3:57 AM
Hi,
Before looping the table u just clear the table like
IT_MARD[]
Modified code:
CASE R_UCOMM.
WHEN '&ENT'.
clear IT_MARD[].
LOOP AT IT_MARD.
IF IT_MARD-RP_MONTH 0.
IT_MARD-COVER = ( IT_MARD-T_STOCK * 26 ) / IT_MARD-RP_MONTH.
ELSE.
IT_MARD-COVER = 0.
ENDIF.
MODIFY IT_MARD.
ENDLOOP.
WHEN '&SAVE'.
IT_MARD[].
LOOP AT IT_MARD.
MOVE-CORRESPONDING IT_MARD TO ZROC.
MODIFY ZROC.
ENDLOOP.
MESSAGE 'Entries are saved in table' TYPE 'I'.
ENDCASE.
Regards
Kiran
Edited by: Kiran Saka on Feb 9, 2009 5:06 AM
02-09-2009 4:20 AM
Hi
In order to get the saved entries from zroc table, you must use a select query and populate your internal table:
select * from zroc into table it_mard.
I am assuming that the fields in both itab and db table are same.
Use this stmt to populate your it_mard and then you would get the saved values.
Hope this helps
Regards,
Jayanthi.K
02-09-2009 4:34 AM
Hi,
try this .
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE R_UCOMM.
WHEN '&ENT'.
clear it_mard[].
LOOP AT IT_MARD.
IF IT_MARD-RP_MONTH IS NOT INITIAL.
IT_MARD-COVER = ( IT_MARD-T_STOCK * 26 ) / IT_MARD-RP_MONTH.
ELSE.
IT_MARD-COVER = 0.
ENDIF.
MODIFY IT_MARD from table zroc.
ENDLOOP.
WHEN '&SAVE'.
LOOP AT IT_MARD.
MOVE-CORRESPONDING IT_MARD TO ZROC.
MODIFY ZROC from table zroc.
ENDLOOP.
MESSAGE 'Entries are saved in table' TYPE 'I'.
ENDCASE.
02-09-2009 4:38 AM
Hi,
WHEN '&SAVE'.
LOOP AT IT_MARD.
MOVE-CORRESPONDING IT_MARD TO ZROC.
MODIFY ZROC.
Lock table ZROC. " using a lock object
MODIFY ZROC FROM ZROC
UNLOCK table ZROC. " using a lock object
ENDLOOP.
02-09-2009 4:47 AM
Hi Bathrinath,
create a display push button and at user command u can give the code to retreive data from zorc.
Select *
from zorc
into table i_tab2.
loop at i_tab2 into work_area.
write......
endloop.
Regards,
Mdi.Deeba
02-09-2009 5:01 AM
Hi,
To make myself clear, I would just like to confirm certain doubts...
Is it like the next time you run a program it creates extra entries.....
if so could you please paste the structure of both the tables, and if you are fetching records pleasae paste that code as well.
Regards,
Siddarth
03-06-2009 5:30 AM