Application Development and Automation 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: 
Read only

Trigger a FM upon table updation

0 Likes
947

Dear friends,

I have a custom Z-table created in my ERP system. To this table I have created a table maintenance generator to enable updation of values.

Whenever a new record is inserted/deleted in this table or any existing record in this table has been changed, then a FM needs to be triggered immediately with details of the record that has been inserted or updated.

This FM has to be triggered immediately and not by running a batch job in the background.

Pls help me with the details for achieving the same. Awaiting your valuable inputs.

Best Regards,

Gayathri.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
795

You can do this in events of table maintenance generator. Have a look at below link for details of how to use the events:

[Table Maintenance Events|https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/abap/how%20to%20implement%20events%20in%20table%20maintenance.doc]

Let me know if any doubts.

I hope it helps.

Best Regards,

Vibha

Please mark all the helpful answers

You can do this in events of table maintenance generator. Have a look at below link for details of how to use the events:

[Table Maintenance Events|https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/abap/how%20to%20implement%20events%20in%20table%20maintenance.doc]

Let me know if any doubts.

I hope it helps.

Best Regards,

Vibha

Please mark all the helpful answers

4 REPLIES 4
Read only

Former Member
0 Likes
795

When you created a table maintenance generator, then a function module get autometically generated that used to update the table in database when you use table maintenance for data updetion.

You will find the function group by the following path:

SE11-> open the table -> Utilities -> table maintenance generator.

Now this autometically created function group can be changed according to your requirements. There you will find the point where when you table is getting uodated ( you will also get the screen no there which is used to update your table, search the PAI of that screen), and if the updetion is successful then add code ( call FM in your case) according to your requirements.

For more hints to get that perticular point, search the following path in the screen of the function group:

MODULE LISTE_UPDATE_LISTE -> PERFORM update_tab

-> PERFORM update_entry -> MODIFY extract

Read only

Former Member
0 Likes
795

Hi,

Find out the function group.

And go for the PAI module of your screen

There you can write the function module . for what you want to perform the action.

it will work.

Regards,

Madan.

Read only

Former Member
0 Likes
796

You can do this in events of table maintenance generator. Have a look at below link for details of how to use the events:

[Table Maintenance Events|https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/abap/how%20to%20implement%20events%20in%20table%20maintenance.doc]

Let me know if any doubts.

I hope it helps.

Best Regards,

Vibha

Please mark all the helpful answers

Read only

Former Member
0 Likes
795

Hi,

Pls find below the link which will automatically update the user and the date whenever the table has a new entry or changed in table maintenance generator.

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/8129f164-0a01-0010-2a8e-87652872...

If you have any doubts please get back to me as I am also currently working on a similiar object.

Also other than as shown in the attached PDF you can also write the following code in EVENT '01'.

FORM update_user_date_time.

DATA: f_index LIKE sy-tabix.

DATA: BEGIN OF l_total.

INCLUDE STRUCTURE zztable.

INCLUDE STRUCTURE vimtbflags.

DATA END OF l_total.

DATA: s_record TYPE zztable.

LOOP AT total INTO l_total.

IF l_total-vim_action = aendern OR

l_total-vim_action = neuer_eintrag.

MOVE-CORRESPONDING l_total TO s_record.

s_record-zz_user = sy-uname.

s_record-zz_date = sy-datum.

s_record-zz_time = sy-uzeit.

READ TABLE extract WITH KEY l_total.

IF sy-subrc EQ 0.

f_index = sy-tabix.

ELSE.

CLEAR f_index.

ENDIF.

MOVE-CORRESPONDING s_record TO l_total.

MODIFY total FROM l_total.

CHECK f_index GT 0.

MODIFY extract INDEX f_index FROM l_total.

ENDIF.

ENDLOOP.

ENDFORM. " UPDATE_USER_DATE_TIME[/code]

Here ZZTABLE is the Z table and ZZ_USER, ZZ_DATE, and ZZ_TIME are the fields that are updated.

Reward if found helpful.