Skip to Content
author's profile photo Former Member
Former Member

SELECT from table vs. CALL FUNCTION

Hello,

I have always wondered what the "best practice" is in this case, so I am looking for input. When writing custom reports etc. in SAP, is it generally regarded as better practice to write a SELECT statement to get a line from say a Txxx configuration table, or is it best to use an associated BAPI or call to function module? I know in some cases perfomance must obvioulsy be considered, but in terms of SAP's recommendations or upgrade considerations, which is typically better?

Assume for example something as simple as getting company code data... Is it best to do <b>SELECT * FROM T001...</b> or to call a BAPI like <b>BAPI_COMPANYCODE_GETDETAIL</b>?

Any feedback would be greatly appreciated.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Feb 10, 2005 at 10:17 AM

    I use table,

    - When I want to fetch a table array, not only one entry.

    - When I'm sure that the data is coming from that table/tables

    -When I'm sure about that this is the best from performance point of view.

    I use FM,

    - when it's released for customers (eg BAPI)

    - when I need only one entry

    - when I need RFC

    - when the data is fetched in a complicated way, and I can see that this FM used in standard transaction.

    FM is a higher level approach, if it's released for customers, then probable you can use in the next release also. It's very unlike (however sometimes happens eg Ibase tables), that SAP change the way of data storing in db. FM should work after it also.

    Peter

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Feb 09, 2005 at 05:23 PM

    I would say that 95% of the time, if I need to hit a "T" table, I just write a select statement, I don't bother to look for a FM/BAPI which essential will do the same thing.

    Regards,

    Rich Heilman

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Christian Finkbeiner

      > True but in some cases those function modules come

      > with a internal buffering technique which avoid

      > multiple reads - when called several time - this can

      > become quite handy if you are in a user-exit and use

      > the same function module to "reread" the data which

      > has been read in the program before.

      > Christian

      You're right Christian, but if you're working with Customizing tables, most of the times they're buffered in the application server, so I understand that the time you earn use FM with buffering techniques is not too much.

      But I agree with you when you have to deal with transactional data. Then it pays the price to search an FM with built-in buffer.

      cheers,

      David

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.