‎2013 Jan 02 2:13 PM
Hi All,
I have a requirement to change the end date automatically if the category is same for two records.
The fields are,
1. Category,
2. Start date,
3. End date,
4. Category Number,
5. Category Description1,
6. Category Description2,
7. Category Description3,
8. Category Description4,
9. Category Description5,
10. Category Description6,
Here Category, Start date and End date are the Keys.
If i have a record for category as AA, Start date-02.01.2013, end date as 31.12.9999
if suppose a new record with category AA, Start date as 01.01.2014, end date as 31.12.9999, the 1st records end date should get changed to 31.12.2013,
i.e. before the start date of next record.
Kindly help me to achieve this.
Thanks.
‎2013 Jan 02 7:41 PM
You sort the records you have according to the start date and end date. You put a loop on the table of records. You read the next record using index access and compare the next record with current record in loop.
Where are you stuck?
‎2013 Jan 03 5:24 AM
Hi Chinmay,
I am not doing a report for this table. I will maintain the entries directly to the table through SM30, that time i want to change the end date of the previous record.
Thanks.
‎2013 Jan 03 6:25 AM
Go to SM30.
Put your table and click on maintian.
click on create new entries.
Once the screen is in editable mode, press F1 and navigate to the screen.
You can put your logic in Loop after PROCESS AFTER INPUT.
Or You can also create a new module to perform all checks after the loop. This is your custom FG, you can make all the changes you want.
‎2013 Jan 03 6:55 AM
Or You can also create a new module to perform all checks after the loop. This is your custom FG, you can make all the changes you want.
And what'll happen to your custom FG when you regenerate the Table Maintenance Generator(TMG) - did you think about it prior to replying?
This is a common mistake done by developers. Never change the system generated TMG FuGr All your changes will be lost when someone regenerates the TMG!
BR,
Suhas
‎2013 Jan 03 9:36 AM
Yes, I have thought about it and I do it often.
Whats wrong in that if you have mentioned the changes in TS?
This approach is far better than going for a module pool development for some small requirement, 95% of which is handled by SAP. Let me know if you have any other easier way to handle this requirement apart from creating a dedicated module pool.
‎2013 Jan 03 10:49 AM
Yes, I have thought about it and I do it often
Unfortunately you do it wrong then! Afair SAP even gives a pop-up not to change the standard code in the TMG
Whats wrong in that if you have mentioned the changes in TS?
In case you did not get the message I tried to convey in my previous response, let me reiterate it. Suppose you have to add a new field to the table & re-generate the TMG. All the changes that you've done in the FuGr. are lost for good!
Let me know if you have any other easier way to handle this requirement apart from creating a dedicated module pool.SAP has provided quite a few Extended Table Maintenance Events (SAP Library - BC - Generate Table Maintenance Dialog) for the very purpose of enhancing the standard TMG process. Although i must admit they don't cover all the requirements, but IMO any requirement beyond this should not be handled by TMG.
And if you're talking about the OP's requirement specifically, then SAP has provided a standard way of handling this - by defining Time-Dependent Table/View (SAP Library - BC - Generate Table Maintenance Dialog). You'll have to do the following to Generate Time-Dependence (SAP Library - BC - Generate Table Maintenance Dialog) in your table maintenance.
Now, I'm not sure if this is "easy" or "difficult" compared to your solution of implementing custom logic in the system-generated FuGr. But IMHO this is definitely the SAP recommended way of doing it.
BR,
Suhas
‎2013 Jan 03 3:47 PM