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: 

change event for table maintance generator

Former Member
0 Kudos

Hi,

I created the ztable which contains fileds like created by and changed by.

for Updating the created by field i used the 05 event.

Some one changed the existing record how can i update the changed by field using the event.

Please provide me solution.

Regards,

Suresh.

7 REPLIES 7

raymond_giuseppi
Active Contributor
0 Kudos

[Event 05 "When creating a new entry"|http://help.sap.com/saphelp_46c/helpdata/en/91/ca9f1aa9d111d1a5690000e82deaaa/frameset.htm] is only called for new record, when [Event 01 "Before saving the data in the database"|http://help.sap.com/saphelp_46c/helpdata/en/91/ca9f0ba9d111d1a5690000e82deaaa/frameset.htm] is called before every update/insert. (sample provided in the linked documentation) You could also use [Event 21 "Fill hidden fields"|http://help.sap.com/saphelp_46c/helpdata/en/91/ca9f4aa9d111d1a5690000e82deaaa/frameset.htm]

Regards,

Raymond

0 Kudos

Hi,

I read the documentation for events but still i am unable to update the changed by field using event 01.

if Possible please give simple example .

Thanks,

Suresh.

0 Kudos

Hi,

Refer below code to call your FM generated while creating change object.

CALL FUNCTION 'ZLAN_QM_PADDOCK_WRITE_DOCUMENT'
    EXPORTING
      OBJECTID                = OBJECTID
      TCODE                   = SY-TCODE
      UTIME                   = SY-UZEIT
      UDATE                   = SY-DATUM
      USERNAME                = SY-UNAME
      OBJECT_CHANGE_INDICATOR = 'U'
      N_ZLAN_QM_TBL_PDOK      = ZLAN_QM_TBL_PDOK
      O_ZLAN_QM_TBL_PDOK      = *ZLAN_QM_TBL_PDOK
      UPD_ZLAN_QM_TBL_PDOK    = 'U'
    TABLES
      ICDTXT_ZLAN_QM_PADDOCK  = ICDTXT_ZLAN_QM_PADDOCK.

[http://sapwithrab.com/tutorials/abap/changelogs.html]

[http://help.sap.com/saphelp_47x200/helpdata/en/2a/fa0b1a493111d182b70000e829fbfe/frameset.htm]

Refer these links for more help.

Thanks,

Archana

0 Kudos

Create a FORM for event 01 that coul look like

FORM event01.
  FIELD-SYMBOLS <l_fs> LIKE sy-uname.
  DATA: f_index LIKE sy-tabix. "Index to note the lines found
  LOOP AT total.
    IF <action> = neuer_eintrag
    OR <action> = aendern.
      READ TABLE extract WITH KEY <vim_xtotal_key>.
      IF sy-subrc EQ 0.
        f_index = sy-tabix.
      ELSE.
        CLEAR f_indx.
      ENDIF.
      IF <action> = neuer_eintrag.
        ASSIGN COMPONENT ernam OF STRUCTURE <total> TO <user>.
        ASSIGN COMPONENT ersda OF STRUCTURE <total> TO <date>.
      ELSEIF <action> = aendern.
        ASSIGN COMPONENT aenam OF STRUCTURE <total> TO <user>.
        ASSIGN COMPONENT laeda OF STRUCTURE <total> TO <date>.
      ENDIF.
      <user> = sy-uname.
      <date> = sy-datum.
      MODIFY total.
      CHECK f_indx GT 0.
      extract = total.
      MODIFY extract INDEX f_indx.
    ENDIF.
  ENDLOOP.
  sy-subrc = 0.
ENDFORM.

Regards,

Raymond

Former Member
0 Kudos

Hi,

Use the event 18 from table maintainence and read the table as Extract as

READ TABLE EXTRACT INTO wa_tab INDEX sy-tabix.

after this fill the value of change by field in this work area and again modify the table Extract.

Try this.........it may help you.

Former Member
0 Kudos

You can update those fields in the events before saving to database...

Regards,

Lalit Mohan Gupta

Former Member
0 Kudos

Hi,

Use event '02' to call your FM generated while creating change object.

In this event, EXTRACT table, which is standard table with header line will contain the updated record at the header line.

Hope this helps.

Thanks,

Archana