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

Making fields non editable in tables using events

Former Member
0 Likes
12,954

Hi,

I have a custom table with some 10 fields.When users assigned to a particular role acess the maitenance view of the table to edit the contents, they should only be allowed to change the contents of 3 fields.

Can this restriction be done using the table events without changing the attributes in the screen painter and coding in the PBO to modify screen ? . The changes done in the PBO would be lost once a new field is added to the table and maitenence screen is regenerated and so looking if there is any alternate way to do it.

Any hint would be helpful.

Thanks

Kavitha

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
6,912

Kavitha,

I guess one option could be to modify table x_namtab in event19 (After initializing global variables, field symbols, etc.)

LOOP AT x_namtab.

* if Criteria Matches.

     x_namtab-readonly = 'R'. " Set field to Read only.

     MODIFY x_namtab.

*  endif.

ENDLOOP.

Hope this helps,

Thanks,

VM.



Hi,

I have a custom table with some 10 fields.When users assigned to a particular role acess the maitenance view of the table to edit the contents, they should only be allowed to change the contents of 3 fields.

Can this restriction be done using the table events without changing the attributes in the screen painter and coding in the PBO to modify screen ? . The changes done in the PBO would be lost once a new field is added to the table and maitenence screen is regenerated and so looking if there is any alternate way to do it.

Any hint would be helpful.

Thanks

Kavitha

6 REPLIES 6
Read only

Former Member
0 Likes
6,913

Kavitha,

I guess one option could be to modify table x_namtab in event19 (After initializing global variables, field symbols, etc.)

LOOP AT x_namtab.

* if Criteria Matches.

     x_namtab-readonly = 'R'. " Set field to Read only.

     MODIFY x_namtab.

*  endif.

ENDLOOP.

Hope this helps,

Thanks,

VM.



Read only

Former Member
0 Likes
6,912

Hi Kavitha,

You can do it by using the events in table maintenance generator.

Try and let me know if you need any help..

Read only

Former Member
0 Likes
6,912

Hi,

Table Maintenance Events

The value to be displayed on the maintenance screen for any field can also be altered as per the requirement like for every new entry in the table one of the field should have the constant value appearing automatically. For this purpose, the event needs to be chosen which performs the action. In this case event  "05 creating a new entry".

List of Events available in Table maintenance

01         Before saving the data in the database

02         After saving the data in the database

03         Before deleting the data displayed

04         After deleting the data displayed

05         Creating a new entry

06         After completely performing the function 'Get original'

07         Before correcting the contents of a selected field

08         After correcting the contents of a selected field

09         After getting the original of an entry

10         After creating the header entries for the change task (E071)

11         After changing a key entry for the change task (E071K)

12         After changing the key entries for the change task (E071K)

13         Exit editing (exit main function module)

14         After lock/unlock in the main function module

15         Before retrieving deleted entries

16         After retrieving deleted entries

17         Do not use. Before print: Event 26

18         After checking whether the data has changed

19         After initializing global variables, field symbols, etc.

20         after input in date sub screen (time-dep. tab. /views)

21         Fill hidden fields

22         Go to long text maintenance for other languages

23         Before calling address maintenance screen

24         After restricting an entry (time-dep. tab./views)

25         Individual authorization checks

26         Before creating a list

27         After creation or copying a GUID (not a key field)

28         After entering a date restriction for time-dep. views

AA        Instead of the standard data read routine

AB        Instead of the standard database change routine

AC        Instead of the standard 'Get original' routine

AD       Instead of the standard RO field read routine

AE        Instead of standard positioning coding

AF        Instead of reading texts in other languages

AG       Instead of 'Get original' for texts in other languages

AH        Instead of DB change for texts in other languages

ST        GUI menu main program name

AI         Internal use only

Read only

Former Member
0 Likes
6,912

Hi Kavitha,

Please follow the best simplest Approach,

When you open the table maintainence screen, the screen same as in any Module Pool Program,

then navigate to element list tab beside attributes Tab, then check the checkbox with header text, output only and your required approach will be fulfilled.

Please validate the same at your end as well, let me know in case any further inputs from my end are required.

BR/Thanks

Pranav Agrawal

Read only

Former Member
0 Likes
6,912

hi,

I was able to do it using the x_namtab in the event . thanks Venkat Muthyala

for the tip

Thanks Kavitha

Read only

0 Likes
6,911

Hi

Defining fields to be non-editable in TMG can be achieved using

  • Maintenance screen
  • Events

Utilizing maintenance screen for the manipulation of fields can be easy but as known for every regeneration of TMG would cause the settings of Maintenance screen to be erased and implementing all settings would be inefficient so embrace using Events.

Case scenario
Before making the fields
non-editable

Steps to be followed to make fields non-editable using events

  1. Create Event 19
  2. Provide fields to be non-editable and write the code as below
  3. Get to know that fields are chosen Read-only in table x_namtab ( Try to debug the x_namtab table to know more about it so that will understand all other columns that x_namtab contain )
    for reference i have a screenshot of it.

  4. Go to SM30 -> maintain-> new entries-> you get the required format ( if you are debugging execute the steps and then go to SM30

Case scenario
After making the fields non-editable

SPAN {
font-family: "Courier New";
font-size: 10pt;
color: #000000;
background: #FFFFFF;
}
.L0S31 {
font-style: italic;
color: #808080;
}
.L0S33 {
color: #4DA619;
}
.L0S52 {
color: #0000FF;
}
.L0S55 {
color: #800080;
}
.L0S70 {
color: #808080;
}

SPAN {
font-family: "Courier New";
font-size: 10pt;
color: #000000;
background: #FFFFFF;
}
.L0S52 {
color: #0000FF;
}
.L0S55 {
color: #800080;
}

SPAN {
font-family: "Courier New";
font-size: 10pt;
color: #000000;
background: #FFFFFF;
}
.L0S52 {
color: #0000FF;
}
.L0S55 {
color: #800080;
}

FORM znon_edit.
LOOP AT x_namtab.
CASE x_namtab-viewfield.

   WHEN 'RE_BDRE_ID'.

    x_namtab-readonly = 'R'. " Set field to Read only.

    MODIFY x_namtab.

   WHEN 'LAST_UPDATE_DATE'.

    x_namtab-readonly = 'R'. " Set field to Read only.

    MODIFY x_namtab.


SPAN {
font-family: "Courier New";
font-size: 10pt;
color: #000000;
background: #FFFFFF;
}
.L0S52 {
color: #0000FF;
}
.L0S55 {
color: #800080;
}

ENDCASE.
ENDLOOP.
ENDFORM.