04-24-2019 10:37 AM
Hi,
Is it good practice to create Local classes in Function Modules, please provide details with valid reasons.
Thanks,
Watchpoint.
04-24-2019 1:25 PM
1) Yes it is good practice
2) Modularisation and encapsulation is generally seen in programming as a good thing. FORMs are obsolete, so that leaves you with local classes to modularise and encapsulate your code.
04-24-2019 1:25 PM
1) Yes it is good practice
2) Modularisation and encapsulation is generally seen in programming as a good thing. FORMs are obsolete, so that leaves you with local classes to modularise and encapsulate your code.
03-04-2022 1:38 PM
I was hoping to also find an answer to "where (which include) in a function group should I add local classes to ?", and now, on a 2nd look I saw you give the answers right here: https://answers.sap.com/comments/13220293/view.html . Thanks!
03-07-2022 2:16 PM
Shame it had an error should read:
04-24-2019 2:36 PM
Like subroutines, function modules may also be considered (*) obsolete, except when required for using RFC, update tasks, screens.
(*) it's not officially said in the ABAP doc
04-24-2019 5:52 PM
Really? I thought it was just FORMS? But it makes sense... but what about where you need a reusable dynpro? That can only be done via FM, which don't have to be RFCs.
04-24-2019 6:00 PM
Matthew Billingham I should have mentioned that it's not officially said in the ABAP doc. Function modules are required for RFC, update tasks, screens. You can't do that with class pools. For the rest, use class and interface pools.
04-24-2019 3:14 PM
"...to create Local classes in Function Modules"
But it is NOT good practice to create local classes within a Function module. Use one or the other, but not both in combination.
04-24-2019 5:55 PM
loyd.enochs3
Nah. See Sandra's answer below.
If you need an RFC, then modularise using local classes. There's even a naming convention for the includes (can't quite remember what it is at the moment).
Also, function modules with screens might well benefit from a bit of modularisation using local classes.
04-24-2019 6:15 PM
Why it is good to practice to create Local classes in Function Modules? I think it is better when to create global class and use it in FM rather than local class. Of course we can create local class in FM like in Program rather than Form (Subroutine).
04-25-2019 3:43 PM
If the class is very specific to the FM, then a local FM makes sense.
Furthermore, if you have code in the FM and want to test it, you should write local test classes.
04-24-2019 6:57 PM
Personal Opinion:
not a fan of the hybrid approach. I would rather stick to either procedural or object oriented. I've been hearing the FORMS are obsolete argument for a while now. SAP still hasn't re-written all the subroutines in standard objects.
I hope to keep using the subroutines till the day I get syntax errors or loss of program performance due to subroutines.