‎2014 Jun 12 9:30 AM
Hello Experts
I have a Z table and a table maintenance Generator associated with that. I have a field for username in the table which gets filled by sy-uname using the TMG's Event(05).
Now my requirement is that I want to allow to display/maintenance of only those records which are maintained by the current user(sy-uname).
For Example in the below table
| FIELD1 | USERNAME |
|---|---|
| A | 100 |
| B | 100 |
| C | 200 |
| D | 300 |
| E | 200 |
| F | 100 |
if I log on with user name 100. then system should show me only 3 records(A,B & F).
Thanks & Regards
Mohit
‎2014 Jun 12 10:08 AM
Hi Mohit,
Use event AA this event tigger before displaying data in TMG (i.e It tiggers when the user click on "MAINTAIN' / "DISPLAY" button on TMG.
I have done this dev for my project, attaching sample code may be useful
DATA: BEGIN OF l_wa_total,
line(100), " Total lengeth of the table fields
END OF l_wa_total,
l_i_dispend TYPE STANDARD TABLE OF /scl/tunplan_ex. (Write your table name)
DATA: l_v_written TYPE char255.
FIELD-SYMBOLS: <field> TYPE any,
<wa_dispend> TYPE /scl/tunplan_ex.
CONSTANTS: l_c_02 TYPE char2 VALUE '02',
l_c_03 TYPE char2 VALUE '03',
l_c_s TYPE char1 VALUE 'S',
l_c_u TYPE char1 VALUE 'U'.
* Total[] is standad SAP table used for all table manintance ganeraters
CLEAR total[].
SELECT * FROM /scl/tunplan_ex (Write your table name here)
INTO TABLE l_i_dispend.
IF sy-subrc = 0.
SORT l_i_dispend BY bukrs.
LOOP AT l_i_dispend ASSIGNING <wa_dispend>."INTO wa_dispend.
IF maint_mode = l_c_s.
* Check for authority for Comapny Code
AUTHORITY-CHECK OBJECT 'F_BKPF_BUK'
ID 'ACTVT' FIELD l_c_03
ID 'BUKRS' FIELD <wa_dispend>-bukrs.
IF sy-subrc EQ 0.
<vim_total_struc> = <wa_dispend>.
APPEND total.
ENDIF.
ELSEIF maint_mode = l_c_u.
* Check for authority for Company Code
AUTHORITY-CHECK OBJECT 'F_BKPF_BUK'
ID 'ACTVT' FIELD l_c_03
ID 'BUKRS' FIELD <wa_dispend>-bukrs.
IF sy-subrc EQ 0.
<vim_total_struc> = <wa_dispend>.
APPEND total.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF
.
‎2014 Jun 12 9:48 AM
Hi Mohit,
Please use 01 event in TMG and restrict all entry based on login user .
you can get all table entry in EXTRACT internal table. and you can set condition in this table.
Regards,
Prasenjit
‎2014 Jun 12 9:59 AM
Thanks Prasenjit,
EVENT 01 triggers when I Save the data entered, I want some event which can trigger before displaying the data and the table extract holds the whole data in one line, so I am unable to pick up the username from that table to delete the entries from extract.
Regards
Mohit
‎2014 Jun 12 10:13 AM
Yes Mohit, Please use AA event for restricting values based on user ID.
Regards,
Prasenjit
‎2014 Jun 12 10:01 AM
Hi Mohit,
You have to implement the event 'AA' (Instead of the standard data read routine). SAP documentation on [Extended Table Maintenance Events|
http://help.sap.com/saphelp_nw04/helpdata/en/91/ca9f0ea9d111d1a5690000e82deaaa/frameset.htm].
Sample subroutine you can use:
FORM read_data.
DATA: st_view TYPE zmv01335.
* Read the data from the view using standard routine
PERFORM get_data_zmv01335.
* UPD & AEND are for change entries event.
CHECK sy-ucomm = 'UPD' OR sy-ucomm = 'AEND'.
LOOP AT total INTO st_view.
IF st_view-uname NE sy-uname.
DELETE total.
ENDIF.
ENDLOOP.
ENDFORM.
Please validate the same at your end as well. Let us know in case you need any further inputs.
BR/Thanks
Pranav Agrawal
‎2014 Jun 12 10:19 AM
Hello Pranav,
Please explain
* Read the data from the view using standard routine
PERFORM get_data_zmv01335.
If i write select statement to fetch all the records of the table in this subroutine, it won't be possible since the type of total internal table is different.
Thanks & regards
Mohit
‎2014 Jun 12 10:08 AM
Hi Mohit,
Use event AA this event tigger before displaying data in TMG (i.e It tiggers when the user click on "MAINTAIN' / "DISPLAY" button on TMG.
I have done this dev for my project, attaching sample code may be useful
DATA: BEGIN OF l_wa_total,
line(100), " Total lengeth of the table fields
END OF l_wa_total,
l_i_dispend TYPE STANDARD TABLE OF /scl/tunplan_ex. (Write your table name)
DATA: l_v_written TYPE char255.
FIELD-SYMBOLS: <field> TYPE any,
<wa_dispend> TYPE /scl/tunplan_ex.
CONSTANTS: l_c_02 TYPE char2 VALUE '02',
l_c_03 TYPE char2 VALUE '03',
l_c_s TYPE char1 VALUE 'S',
l_c_u TYPE char1 VALUE 'U'.
* Total[] is standad SAP table used for all table manintance ganeraters
CLEAR total[].
SELECT * FROM /scl/tunplan_ex (Write your table name here)
INTO TABLE l_i_dispend.
IF sy-subrc = 0.
SORT l_i_dispend BY bukrs.
LOOP AT l_i_dispend ASSIGNING <wa_dispend>."INTO wa_dispend.
IF maint_mode = l_c_s.
* Check for authority for Comapny Code
AUTHORITY-CHECK OBJECT 'F_BKPF_BUK'
ID 'ACTVT' FIELD l_c_03
ID 'BUKRS' FIELD <wa_dispend>-bukrs.
IF sy-subrc EQ 0.
<vim_total_struc> = <wa_dispend>.
APPEND total.
ENDIF.
ELSEIF maint_mode = l_c_u.
* Check for authority for Company Code
AUTHORITY-CHECK OBJECT 'F_BKPF_BUK'
ID 'ACTVT' FIELD l_c_03
ID 'BUKRS' FIELD <wa_dispend>-bukrs.
IF sy-subrc EQ 0.
<vim_total_struc> = <wa_dispend>.
APPEND total.
ENDIF.
ENDIF.
ENDLOOP.
ENDIF
.
‎2014 Jun 12 10:39 AM