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: 

Table Maintenance Events

Former Member
0 Kudos

Hi Friends,

I have 3 z tables and each has one view created.

Tables                                        

1.ZTT_RGA_DISPCODE     -fields--Cost center,created on,createdby,changed on ,changedby 

2.ZTT_RGA_RSN_CODE

-fields--Cost center,created on,createdby,changed on ,changedby 

3.

ZTT_RGA_MTRL_CON

-fields--Cost center,created on,createdby,changed on ,changedby 

Using event Create New entry ,i have a routine.

Issue:

When i am entrying a new entry in sm30 ,cost center does not exist,but the entry is available in the CSKS table.the Created on ,createdby should automatically populate..

Do i need to change any thing in the code below.

Please let me know any if you are not clear about my question.

FORM create_new.

  ztt_rga_dispcode-created_on = sy-datum.

  ztt_rga_dispcode-created_by = sy-uname.

  ztt_rga_dispcode-changed_on = sy-datum.

  ztt_rga_dispcode-changed_by = sy-uname.

  MODIFY ztt_rga_dispcode.

ENDFORM.                    "CREATE_NEW

*&---------------------------------------------------------------------*

*&      Form  CONTENT_CHANGE

*&---------------------------------------------------------------------*

*

*----------------------------------------------------------------------*

FORM content_change.

BREAK-POINT.

  ztt_rga_dispcode-changed_on = sy-datum.

  ztt_rga_dispcode-changed_by = sy-uname.

MODIFY ztt_rga_dispcode.

ENDFORM.                    "CONTENT_CHANGE

*&---------------------------------------------------------------------*

*&      Form  CREATE_NEW1

*&---------------------------------------------------------------------*

*       Event for Material number conversion:ZTT_RGA_MTRL_CON

*----------------------------------------------------------------------*

FORM CREATE_NEW1.

  ZTT_RGA_MTRL_CON-created_on = sy-datum.

  ZTT_RGA_MTRL_CON-created_by = sy-uname.

  ZTT_RGA_MTRL_CON-changed_on = sy-datum.

  ZTT_RGA_MTRL_CON-changed_by = sy-uname.

ENDFORM.                    "CREATE_NEW1

*&---------------------------------------------------------------------*

*&      Form  CREATE_NEW2

*&---------------------------------------------------------------------*

*       Events for Reason code table:ZTT_RGA_RSN_CON

*----------------------------------------------------------------------*

FORM CREATE_NEW2.

  data: gs_data TYPE ZTT_RGA_RSN_CODE.

  ZTT_RGA_RSN_CODE-created_on = sy-datum.

  ZTT_RGA_RSN_CODE-created_by = sy-uname.

  ZTT_RGA_RSN_CODE-changed_on = sy-datum.

  ZTT_RGA_RSN_CODE-changed_by = sy-uname.

  data: lv_index TYPE sy-tabix VALUE '1'.

  read TABLE extract INDEX sy-tabix.

  IF sy-subrc is INITIAL.

    gs_data-changed_on = sy-datum.

  gs_data-changed_by = sy-uname.

  modify ZTT_RGA_RSN_CODE from gs_data .

  ENDIF.

5 REPLIES 5

jitendra_it
Active Contributor
0 Kudos

former_member182041
Active Contributor
0 Kudos

Hi,

If the requirement is to populate changed date, changed by etc. then the same should happen both while creation and updation. If you write the code in event 'Creating new entry' then this would not happen. I would rather suggest to use the event 'Before Save data' to enter the audit field i.e changed date etc.

There is no need to use Modify statement.

Do write the code and let me know if the issue is solved. Thanks.

Regards,

Kumud

0 Kudos

Hi Kumud,

Thanks for your reply,

I have used save entry and save changes events,the change on changed by created on created by are populating  automatically

now the new requ.is

when ever the material id entered the material description should be populated automatically.

i have used the save entry for this.

data: lv_matnr type matnr,

        lv_maktx TYPE maktx.

  select maktx from makt into lv_maktx WHERE matnr =  zvw_rga_rsn_code-matnr

                                         and spras = sy-langu.

     zvw_rga_rsn_code-maktx = lv_maktx.

     zvw_rga_rsn_code-RCODE_DESC = lv_maktx.

    ENDSELECT.

I have used this code,its nt wrking.Can you suggest.

0 Kudos

Hi, for this use event create_entry(05)

0 Kudos

Hi Vandana,

I assume material no. is a primary key! Now, when material no. is entered and you press enter, then has the description to be displayed or after you click on Save button? Before_save entry would not work here. As suggested by Jitendra, use Create_entry and check. Let me know if that works.

Regards,

Kumud