‎2014 Jun 10 11:15 AM
Hi,
I have created a transaction that allows a user to write into a custom database table using SM30. Basically, when user calls that transaction, SM30 is called and name of my transaction is written into the "Table/View" field of the first screen of SM30.
That database table contains field DATUM. What I want now is that when user is inserting a new record into that database table using my transaction, the DATUM field will automatically equal to current date (sy-datum). Is that possible? Can I make a field to be non-modifiable by user? Do I need to modify something in table settings or in my transaction?
Regards,
Jake Alexander
‎2014 Jun 10 11:43 AM
Hi,
Please use table maintenance generator event in your custom table 05 or 01 event and add your code then it will be updated the same when you want to add any entryusing z tcode.
Regards,
Prasenjit
‎2014 Jun 10 12:12 PM
‎2014 Jun 10 12:19 PM
Hi Jake,
In TMG screen in menu Environment->Modification->Maintenance Screen
for screen changes
and for other changes Environment->Modification->Events.
As mentioned above you can use 05 or 01 EVENT.
Regards,
Ganesh Lathi
‎2014 Jun 10 1:20 PM
Hi Jake,
There are two things to be done in your requirement.
1. Make date field non-editable.
Go to table Maintenance Generator . Select Menu Environment-> Modifications -> Maintenance Screens.
Select the screen.
In the element list tab or in the Layout, un-check input field check-box for date field.
Now the date field would be non-editable.
2. Default to date to current date
This as provided above, can be done by creating event.
If you want it to be defaulted when the element is saved to database, chose event 01.
Table Maintenance Generator .
Environment Menu-> Modifications -> Events.
Click on the editor and input your code within the subroutine name provided above.
You could provide something like this.
FORM zdate.
DATA: ls_wa TYPE zccuser_dat.
DATA: f_index LIKE sy-tabix. "Index to note the lines found
LOOP AT total.
CHECK <action> EQ 'N'. " This for new entry, for updating existing entry include 'U' also.
ls_wa = <vim_total_struc>.
ls_wa-datum = sy-datum.
<vim_total_struc> = ls_wa.
READ TABLE extract WITH KEY <vim_xtotal_key>.
IF sy-subrc EQ 0.
f_index = sy-tabix.
ELSE.
CLEAR f_index.
ENDIF.
MODIFY total.
CHECK f_index GT 0.
extract = total.
MODIFY extract INDEX f_index.
sy-subrc = 0.
ENDLOOP.
ENDFORM. "zdate
‎2014 Jun 10 1:41 PM
Thank you, Susmitha.
One thing not related to this question I was wondering if you could answer. I updated my database table and now it has several new fields. However, if I try to insert or view my database table using SM30, I can see only the old fields there. My database table is activated, and I adjusted it using SE14. What else should I do so that the most recent version of my table is displayed in SM30?
‎2014 Jun 10 1:44 PM
Hi Jake,
Whenever you make any field changes in Table you have to again regerate the TMG again.
Go to TMG screen and click on change button and follow instruction on screen.
Regards,
Ganesh Lathi.
‎2014 Jun 10 1:47 PM
You have to regenerate TMG.
in Se11, Go to TMG -> Click on edit and select the appropriate option.
‎2014 Jun 10 2:06 PM
1. Make date field non-editable.There is no need to make the field as "non-editable" manually. If someone regenerates the TMG everything is lost for good.
BR,
Suhas
‎2014 Jun 11 5:32 AM
I did regenerate the table n Table Maintenance Generator, but in SM30 I can still see only the first field of the table (PERNR). Is there something I need to do in SM30 as well?
‎2014 Jun 11 6:09 AM
Hope you selected the maintenance screen when you regenerated TMG.
And as Suhas mentioned, you will have to redo your maintenance screen modifications when you regenerate the screen.
‎2014 Jun 11 7:12 AM
Thank you, it worked out. I previously only selected "New field/sec. table in structure".