Function | Returns the object linked to an attribute | |||||||||
Example |
myobj = s10link( "kunnr" ). |
|||||||||
Format |
data: myattrname type string, myobj type /s10/any. myobj = s10link( myattrname ). |
|||||||||
Parameters |
|
|||||||||
Description |
With s10link() foreign key relationships
of the database system can be used in a simple and performant way. The
s10link() method returns a different object for an attribute depending on its
content, which is assigned via a foreign key relationship stored in the class
(see below). The same object is always assigned to the same attribute value
within a class. If the attribute value is initial, no object is created and an
empty object reference is returned.
s10link() is called automatically by the S10 framework if a compound name with dot notation is specified in HTML for name="...", e.g. name="adrnr.title", and the first attribute (here "adrnr") is not of the type object or table. The first specified attribute is interpreted as a foreign key relationship into another table. In the example "adrnr.title" "adrnr" is an address number for which the values are stored in another SAP table "ADRC". The S10 framework then reads the column "title" there. Prerequisite for this mechanism is: (a) In the S10 class, a link, i.e. a foreign key relationship, is assigned to the attribute "adrnr". This can be done explicitly in the class or implicitly via the SAP Data Dictionary. Explicitly, the link class is assigned by defining a constant named "dblink_xxxxx" where xxxxx is the name of the corresponding attribute. The value of the constant is the name of the assigned class. Example:
constants: This assigns the link class "db_adrc" to the attribute "adrnr", which creates the link to the database table ADRC. The class "db_adrc" can look like the following, for example:
class db_adrc definition inheriting from /s10/any. You can have such classes generated automatically from database tables via
the S10 utilities. (b) The automatic database access is done by the S10 framework with a call
to s10databaseread(), where the first key field is set, in the example the
address number. If the language key is a key field, the language key of the
current session is used for this. In an application that changes data in the foreign key tables, e.g.
implements a change of the customer address, you should not use the link
mechanism for the changing data, otherwise the old values will still be
displayed.
<!-- Name 1 -->
You can use both a local class defined in your program and a global class (transaction SE24) as a link class. This is convenient if you want to make general functionality available to several S10 applications when displaying objects via the link mechanism. As an example, in a customer list we display a small country flag and the country currency in addition to the country name:
For this purpose, we provide the attribute "land1" with a link to a global class, which we call "zz_link_t005"; the name is freely selectable. This class provides information about the country key, in particular the country currency "waers" as well as an HTML representation of the country flag "countryflag_html". HTML
<div
class='outputcelldiv'
style="width:
90px;"
name="kunnr"></div> For the representation of the country flag, which is transferred as HTML
string, we have specified the class "outputcellhtmldiv", because with
"outputcelldiv" the HTML string would be output. ABAP
* attribute links
In this way, any S10 application can access the information provided by the
class "zz_link_t005" by assigning the link class and naming the desired
attributes in HTML, i.e. "land1.countryflag_html", "land1.landx50",
"land1.waers". The S10 framework ensures that in a list with repeating country
keys, the information is read or built only once each.
data countryflag_html type string.
" Country flag as HTML code (.gif image)
|
|||||||||
Components | S10 Framework |