Application Development 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: 

Event 01 in TMG

kiran_k8
Active Contributor
0 Kudos

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.

3 REPLIES 3

kiran_k8
Active Contributor

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.

0 Kudos

Thank a lot for this very clear code exmple !

rakeshdevani
Explorer
0 Kudos

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.