12-15-2010 3:31 AM
I have a TMG where I am populating the user name(created by) and date(creation date) based on the even 05 for creation.This user name and date field are non-editable and gets populated through the subroutine I had written for event 05.This if fine.
But I have a problem in populating the username(changed by) and date(changed on ) for the event 01.The event is getting triggered but I am not getting how to populate the values in these fields.I had checked the SAP Help saying interntal tables TOTAL and EXTRACT needs to be used and finally sy-subrc should be set to zero.But,this TOTAL and EXTRACT are type LINE and not fieldwise.
form change.
DATA: F_INDEX LIKE SY-TABIX, "Index to note the lines found
ls_wa type zani_table.
ls_wa = <vim_total_struc>.
LOOP AT TOTAL.
IF <ACTION> = 'U'.
ls_wa-aenam = 'VIMAL'. "for testing
ls_wa-laeda = sy-datum.
READ TABLE EXTRACT WITH KEY <vim_xtotal_key>.
IF SY-SUBRC EQ 0.
F_INDEX = SY-TABIX.
ELSE.
CLEAR F_INDEX.
ENDIF.
MODIFY TOTAL.
CHECK F_INDEX GT 0.
EXTRACT = TOTAL.
MODIFY EXTRACT INDEX F_INDEX.
ENDIF.
ENDLOOP.
SY-SUBRC = 0.
endform.
And how to make the these fields hidden in TMG Level.When I check the dsiplay attributes of the maintenance screen the checkbox for the feilds are greyed out.Kindly do let me know your inputs.
Thanks,
Kiran.
01-19-2011 9:52 AM
Atlast I got it
DATA: F_INDEX LIKE SY-TABIX. "Index to note the lines found
field-symbols : <fs> type any.
LOOP AT TOTAL.
IF <ACTION> = 'U'.
READ TABLE EXTRACT WITH KEY <vim_xtotal_key>.
IF SY-SUBRC EQ 0.
F_INDEX = SY-TABIX.
ELSE.
CLEAR F_INDEX.
ENDIF.
check f_index <> 0.
* Update By
Assign component 'AENAM' of structure
<vim_total_struc> to <fs>.
<fs> = sy-uname.
* Update on
Assign component 'LAEDA' of structure
<vim_total_struc> to <fs>.
<fs> = sy-datum.
MODIFY TOTAL.
EXTRACT = TOTAL.
MODIFY EXTRACT INDEX f_index.
clear f_index.
ENDIF.
endloop.
Kiran.
02-17-2023 12:10 PM
02-23-2023 6:24 AM
Here
last_changed_by,last_changedon,last_changedat are table fields.
TYPE-POOLS: esp1.
FIELD-SYMBOLS : <fs_field> TYPE any .
LOOP AT total.
IF <action> EQ 'U'.
CHECK <action> EQ aendern.
ASSIGN COMPONENT 'last_changed_by' OF STRUCTURE <vim_total_struc> TO <fs_field> .
IF sy-subrc = 0 .
<fs_field> = sy-uname .
ENDIF.
ASSIGN COMPONENT 'last_changedon' OF STRUCTURE <vim_total_struc> TO <fs_field> .
IF sy-subrc = 0 .
<fs_field> = sy-datum .
ENDIF.
ASSIGN COMPONENT 'last_changedat' OF STRUCTURE <vim_total_struc> TO <fs_field> .
IF sy-subrc = 0 .
<fs_field> = sy-uzeit .
ENDIF.
READ TABLE extract WITH KEY <vim_xtotal_key>.
IF sy-subrc = 0.
extract = total .
MODIFY extract INDEX sy-tabix.
ENDIF.
MODIFY total.
ENDIF.
ENDLOOP.