‎2008 May 21 8:22 PM
Hi Guys
I have a question regarding the use of std function modules rather than customized selection.
E.g. instead of doing a
select single * from marc
where matnr = marc-matnris better if we use the Func Module marc_read ?
Isnt this FM also going to eventually read the database by using a star or something?
Please enlighten me on the concept
Best Regards
Sameer
‎2008 May 22 7:17 AM
SAP recommend to use FM instead of writing code for the same, so what ever is the code inside the FM it will be performance wise more effecient then your own code (as SAP say) so you should use FM
Regards
Bikas
‎2008 May 21 8:33 PM
What you are saying is kind of true, however, sometimes these FM have a little bit overhead with all kinds of checks for example. On the other hand, normally these FM read all the fields of a db table, while most of the times you will only need a few of them. So performance wise it would be better to use your own selection in my opinion.
‎2008 May 21 9:15 PM
Hello Sameer
My general approach to this problem is to use always the highest possible abstraction and only use the SELECT statement as a last resort.
1.) Check if a class provides appropriate methods
2.) Check for a BAPI
3.) Check for function module
4.) ELSE: use SELECT statement
In case of multiple available function modules I check the package assignment and prefer those ones which are "closest" to the SAP "core" modules.
Regards
Uwe
‎2008 May 22 7:17 AM
SAP recommend to use FM instead of writing code for the same, so what ever is the code inside the FM it will be performance wise more effecient then your own code (as SAP say) so you should use FM
Regards
Bikas
‎2008 May 23 10:42 AM
>
> SAP recommend to use FM instead of writing code for the same, so what ever is the code inside the FM it will be performance wise more effecient then your own code (as SAP say) so you should use FM
>
> Regards
> Bikas
Well, SAP would say that wouldn't they. But SAP function modules are just bits of code whose efficiency depends on the skill of whoever has written them. And I've seen examples of SAP standard code that I don't consider have been very well written.
One really good reason for using a SAP function module to get eg address data is that if SAP reorganise the way the data is stored - as I've read they did once to addresses - the function module should also have been rewritten so that it still works while your own selects would need to be rewritten.
‎2008 May 23 12:27 PM
If you're programming a user exit of any kind, then you can get a performance improvement by using the function modules. This is because they buffer the data for you, and the data you want may have been read somewhere already in the standard SAP code.
matt
‎2008 May 22 11:54 AM
I would like to add an example from recent experience:
Standard function READ_TEXT is designed for selecting long texts from STXH/STXL. But it reads one at a time. This does not matter much if you're dealing with hundreds or maybe a few thousands of objects. A very time critical interface I designed had to read about 300K of such long texts (on G/L document item level), so I had to come up with my own sort of mass processing. As a result, the text reading part of the interface ran about three to four times faster than before.
So Uwe's approach is perfect, as long as there is an existing method/function etc. that does the job and no performance issues arise (what Micky said, basically).
Cheers
Thomas
‎2008 May 23 2:54 PM
Hi,
Its better to use FM instead of using own Select statements. In most of the FMs, they use buffering technique which reduces the database access and in return helps in system performance.
Thnx
Pradipta K Mishra
‎2008 May 23 11:29 PM
Wow, This seems to ve started a debate
Thanx a lot guys for your inputs.
Regards
Sameer
‎2008 May 30 8:12 AM
Hi Sameer!
Using already existing code i.e FM is always bettr if u have to fetch all the records.
It seems u r enjoying the debate
I guess it would be good if u mark the question as "answered."
hope the above answers helped u!
dnt forget to rewrd.
‎2008 May 28 10:44 AM
To get the better of both you need to check the code written in fn module also .
It depends on the type and amount of the data which is to be fetched will give u.
Also select single directly reads from the DB .So u shld now know which to use for better performance .
‎2008 May 30 2:41 PM