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

Func mod Vs Select single *

Former Member
1,789

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-matnr

is 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

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,580

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

11 REPLIES 11
Read only

Sm1tje
Active Contributor
0 Likes
1,580

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.

Read only

uwe_schieferstein
Active Contributor
0 Likes
1,580

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

Read only

Former Member
0 Likes
1,581

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

Read only

0 Likes
1,580

>

> 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.

Read only

matt
Active Contributor
0 Likes
1,580

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

Read only

ThomasZloch
Active Contributor
0 Likes
1,580

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

Read only

pradiptakumar_mishra
Participant
0 Likes
1,580

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

Read only

Former Member
0 Likes
1,580

Wow, This seems to ve started a debate

Thanx a lot guys for your inputs.

Regards

Sameer

Read only

0 Likes
1,580

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.

Read only

Former Member
0 Likes
1,580

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 .

Read only

Former Member
0 Likes
1,580

Thanks people