0050 - Data Sources

Moderators: Snowy, thx4allthefish, Rich, ilya

Post Reply
Posts: 7116
Joined: Thu Oct 31, 2002 4:47 pm
Location: Liverpool

0050 - Data Sources

Post by Rich » Sat Mar 28, 2009 8:53 am

Data Sources.

So, now you've learnt about the structures and you know that SAP uses them to store data in memory, but where the data is coming from?

Unfortunately, SAP data model is mostly undocumented; at least, SAP doesn't provide good public documentation. Learning the data model is hard work that will pay back after several months of sweating with ABAP code, something everyone has to go through.

Something may be given to you as a part of SAP functional training. Something you can get from your colleagues. Sapfans can help a lot. But the rest will be your own experience. The advice below will not always help you to find what you need, there is no magic trick. Learn and never give up.

A typical situation for you will be writing a report that will show some data, explained verbally or written in business terms (sometimes, if you are lucky enough, the specification will mention database tables you can use). If you don't know where to find or how to process the data you are asked to find:
  1. Go to your user/analyst/functional person. Ask them to show this data in a standard SAP transaction (or some custom report they use). Write down how they do that, and do the following later (or do it as they do that):
    • On the field of interest (say, sales order), position the cursor (single click on it) and hit F1, find the Technical Info button, click it. You get the name of the structure and field in the program your are running. The structure can be either the table you need or just a memory field. The latter is trickier. I normally double click on the structure name to get into its definition in SE11. Then I double click on the data element used for the field of interest (data element is at the right of the field name). You get the SE11 screen for the data element. Now you can run Where Used List (look for a toolbar button) to get the list of real database tables that use the same data element. It's very likely that you will find the needed table there.
    • From the previous point, you can find a global field name of the SAP program/transaction that is used to update or read the data. If you will be running this under debugger, you can set a watchpoint on this field. The first part of this article explains how to work with that. SAP will stop when this field is changed, so it will be easier for you to find the place where the data is read. Of course, the field may be filled from another field and so on - you will have to examine a lot of stuff. C'est la vie...
    • While looking at the data in the business transaction, run SQL trace. Right before going into your data, go to ST05, enable trace. When you reached the screen with data, disable the trace (don't forget! it's a heavy load for the system and also, if left for a long time, generates to much information to review), and analyse it. It lists all the tables being accessed - you will find the table you need there. There is a button to jump to particular select statement, so you can analyze the WHERE conditions or see how the data is processed further.
    • While looking at the data, click menu System-Status. You get the program name. Go to SE80 with this program name, Display. There will be a tree with a node Dictionary Structures. Expand it to see the database tables being accessed. You can analyse the source code as well. Note: not all the tables that are used are listed there.
    • If users can give you an example of custom report that is using the data - look at the source code to find the tables you need and see how they are used (keys, relations etc). Especially useful are reports created for your implementation (starting with Y or Z, for example). They can explain you company specifics and often, in contrast to standard SAP programs, use only the data they need, not more.
  2. When you already know the table you need, but not sure how the data is organized, go to SE11, enter the table name and use Where Used List (button on the toolbar) to get the programs using the table. See the source code then. Again, the custom programs should be checked first.
  3. You can build a list of all the database tables present in the system (alas! it should be about 40000!). Go to SE16, enter table DD02T, press Enter. On the selection screen enter the code for your preferred language. Clear the field that limits the maximum number of hits to get the whole list. Run it ( F8 ). Be patient, it takes time! Download the list to your PC using menu System-List-Save. Now you can open it in a text editor and use some keyword search.
  4. If you want to use some function to update the data, you can get the list of all the functions similarly to point 3 above, using the table TFTIT. To get an example on how to use this function, use Where-Used List from SE37. As always, try to look at custom programs first.
  5. Both tricks 3 and 4 can be used on demand. Just go to SE16 every time and enter some search pattern like *sales order* .
  6. BAPIs. A nice way to work with your data without learning the SAP data model. BAPIs are functions that are "published" by SAP for customer use. They are very well documented and bring less surprises than internal functions. Go to transaction BAPI to get the tree of the functions by functional areas. In addition to simply using them for data extracts or updates you can look into their source code to understand how the data is organized (but this is not an easy task). BAPIs are the first thing to check if you need to update the data (the next thing would probably be BDC - described in Knowledge Corner as well). Using BAPIs for updates can speed up your program significantly (like 100 times!). You can use them to select the data, but of course if you know how to access the database directly, simple select will work faster. Sometimes BAPIs are the only way to get the data, as it is the case with accessing some objects in APO (that are stored only in "Livecache" memory).
Thanks to Ilya for this article.


Abap KC:http://www.richard-harper.me.uk/Kb

Post Reply