Vous êtes sur la page 1sur 14

TMG EVENT TO Populate Auto values

(EVENT-01)
Refrence link -http://scn.sap.com/thread/1851232

In Above screen shot there are 3 fields which needs to be populate automatically when user enter data
in table through TMG(SM30).
E.g. When add new record in table ,system automatically should take current date(record added date)
also when user change the exisitng record thorugh sm30 system shoul capture current date and time.
On change of table record we need to handle the changed record of table with field-symbols for
TABLES and EXTRACT .
Note- TABLES and EXTRACT are the two internal tables get automatically created when we
create the TMG .
-Sumit Patil

TMG EVENT TO Populate Auto values


(EVENT-01)
So for this we have to write and read data in TABLES and EXTRACT internal table.
Below is the logic and snaps for same.

-Sumit Patil

TMG EVENT TO Populate Auto values


(EVENT-01)

-Sumit Patil

TMG EVENT TO Populate Auto values


(EVENT-01)

-Sumit Patil

TMG EVENT TO Populate Auto values


(EVENT-01)

Above screen shot created on ,changed on , Time coloumns make it non-editable mode. Thorugh se51.

-Sumit Patil

TMG EVENT TO Populate Auto values


(EVENT-01)

-Sumit Patil

TMG EVENT TO Populate Auto values


(EVENT-01)

01 Event trigger for create and change (add record /change/delete from tmg table)

-Sumit Patil

TMG EVENT TO Populate Auto values


(EVENT-01)

-Sumit Patil

TMG EVENT TO Populate Auto values


(EVENT-01)

-Sumit Patil

TMG EVENT TO Populate Auto values


(EVENT-01)

After creating event for TMG, Use FORM -ENDFORM. To write ABAP Code otherwise will get
"statement not accessible error" in TMG event editor.

FORM change_rec.
DATA: F_INDEX LIKE SY-TABIX. "Index to note the lines found
field-symbols : <fs> type any.
BREAK-POINT.
LOOP AT TOTAL.
-Sumit Patil

TMG EVENT TO Populate Auto values


(EVENT-01)
IF <ACTION> = 'U'. " Update
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 'CHANGEDON' of structure
<vim_total_struc> to <fs>.
<fs> = sy-datum. "Lase Update Date
* Time
Assign component 'ZTIME' of structure
<vim_total_struc> to <fs>.
<fs> = sy-uzeit. "Lase Update time
MODIFY TOTAL.
EXTRACT = TOTAL.
MODIFY EXTRACT INDEX f_index.
clear f_index.
elseif <ACTION> = 'N'. " Created By
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 'CREATEDON' of structure
<vim_total_struc> to <fs>.
<fs> = sy-datum. "Lase Update Date
-Sumit Patil

TMG EVENT TO Populate Auto values


(EVENT-01)
* Time
Assign component 'ZTIME' of structure
<vim_total_struc> to <fs>.
<fs> = sy-uzeit. "Lase Update time
MODIFY TOTAL.
EXTRACT = TOTAL.
MODIFY EXTRACT INDEX f_index.
clear f_index.
ENDIF.

endloop.
ENDFORM.

"change_rec

Or below code.

*----------------------------------------------------------------------*
***INCLUDE LZCFCOLLF01 .
*----------------------------------------------------------------------*
FORM change_rec.
DATA: F_INDEX LIKE SY-TABIX. "Index to note the lines found
field-symbols : <fs> type any.
BREAK-POINT.
LOOP AT TOTAL.
IF <ACTION> = 'U'. " Update
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 'CHANGEDON' of structure

-Sumit Patil

TMG EVENT TO Populate Auto values


(EVENT-01)
*

<fs> = sy-datum.

<vim_total_struc> to <fs>.
"Lase Update Date

Time
Assign component 'ZTIME' of structure
<vim_total_struc> to <fs>.
<fs> = sy-uzeit.
"Lase Update time
MODIFY TOTAL.
EXTRACT = TOTAL.
MODIFY EXTRACT INDEX f_index.
clear f_index.

*
*
*
*
*

elseif <ACTION> = 'N'. " Created By


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 'CREATEDON' of structure
<vim_total_struc> to <fs>.
<fs> = sy-datum.
"Lase Update Date
Time
Assign component 'ZTIME' of structure
<vim_total_struc> to <fs>.
<fs> = sy-uzeit.
"Lase Update time
MODIFY TOTAL.
EXTRACT = TOTAL.
MODIFY EXTRACT INDEX f_index.
clear f_index.
ENDIF.

endloop.
ENDFORM.

-Sumit Patil

"change_rec

TMG EVENT TO Populate Auto values


(EVENT-01)

Thanks.
Sumit.Patil.

-Sumit Patil

Vous aimerez peut-être aussi