• No results found

Chapter 3. Customization

3.5 Using the LC LSX to access the BAPI

3.5.2 Finding the right table to use

After having successfully accessed BAPI_VENDOR_GETDETAIL, we find that we can now fetch a vendor’s data using its vendor number. But for our intended use, we will not have the vendor number right away; we will only have the vendor name. We need an intermediate step that helps us find the vendor number using the vendor name. As developers, we now

immediately think of the terms

mapping

and

table

.

We need a table that holds both the vendor name and its number. To find out where this might be stored, we use the SAP GUI client again. SAP uses tables, so there must be a reference somewhere in the BAPI_VENDOR_GETDETAIL module. We just have to find it.

When we look at the module again in SE37, we notice a tab called Tables, but this only holds a reference to the BANKDETAILS table, which is a part of the result set.

Next, we check the function module documentation by clicking the respective button on the top right of the window. Again, this is not what we want.

It is time to drill down into the system a little more. One possible approach is to take a look at the source code. Another one is to explore the structures involved. We take a peek at both methods now.

Method A: Trying to interpret the source code

Let’s switch to the Source Code tab and see what is written there (Figure 3-11 on page 51). Even if you are not an ABAP programmer, there might still be some hints there to help you find your way. Most of the time you do not have to look at the code itself—examining the comments is often sufficient. (Sometimes it also helps if you speak a little German. Many comments are written in that language, as well as some variables and table names. After all, SAP is a German company.)

Figure 3-11 Source code of BAPI_VENDOR_GETDETAIL1

The first block of the source code is a comment that documents the local interface (“Lokale Schnittstelle” in German) of the code. Although it does not say anything about tables, at least it lists the names of some structures.

Structures are complex SAP data types that can hold virtually anything: tables, data fields, and even other structures. So although we might not have found the correct table itself, we might have found its container. The structures BAPIVENDOR_04 and BAPIVENDOR_05 look particularly interesting because they seem to hold values described as GENERALDETAIL (which contained the address data we found earlier) and COMPANYDETAIL. To explore these structures, we open the Export tab. From now on, follow the steps under method B in the following section.

Method B: Explore the structures

We can also skip the scrutinizing of the module’s source code by taking a click-by-click approach. There is a good chance that the missing information is to be found somewhere on the Export tab, because that is where our results come from. Therefore, we open the Export tab and see what is in there (Figure 3-12).

Figure 3-12 Export tab of BAPI_VENDOR_GETDETAILS1

The first line tells us something along the lines of GENERALDETAIL is LIKE the structure BAPIVENDOR_04, so we double-click that structure’s name.

This takes us to the SAP Data Dictionary (shortcut SE11), where all data structures are centrally defined and stored for any given SAP system. The selected structure opens on the Components tab (Figure 3-13).

We seem to be on the right path. The components listed here look familiar; these are the table headings we saw before in the SAP GUI client. Therefore, we need to check the other tabs for table names. The Attributes and Currency tabs show no tables. But the Entry help/check tab has a column called Check table (Figure 3-14).

Figure 3-14 Entry help/check tab of structure BAPIVENDOR_041

In the first line of that column, we find an entry called LFA1, which is highlighted in blue. Double-click this table name to go to the corresponding Data Dictionary entry (Figure 3-15). A check of the Fields tab tells us that this table contains the data we need, complete with the respective data types.

Figure 3-15 Data Dictionary entry for table LFA12

Now that we know how the vendor data is organized and where it is stored, we have to check if the table contains our example entry #200030. (So far, we only know the structure of the table, but not its contents.)

1 © SAP AG 2006. All rights reserved. 2 © SAP AG 2006. All rights reserved.

For this task, use the Data Browser (shortcut SE16) in the SAP GUI client (Figure 3-16). This tool (among others) enables you to peruse tables.

Figure 3-16 Data Browser Selection Screen1

We enter our vendor number into the LIFNR field (LIFNR is an abbreviation for

Lieferantennummer, which is German for vendor number), click the clock symbol, and get the following result window (Figure 3-17).

Figure 3-17 Data Browser result2

We found vendor number 200030 in table LFA1. Scrolling to the right tells us that the other address information pertaining to this particular vendor is also there. To get all the details and field names, check the box to the left of the table entry and click the display icon (glasses). Now you can see all data about this vendor (Figure 3-18).

We found the right place to populate our list of vendors to present in the UI. The next step in the process for us is to read a few columns from table LFA1 in LotusScript and build a list of choices from them. This list is then presented to the users in a later step.

Related documents