Function | Returns the HTML context info object | ||||||
Example |
mycontextinfo = s10contextinfo( ). |
||||||
Format |
data: mycontextinfo type ref to /s10/contextinfo. mycontextinfo = s10contextinfo( ). |
||||||
Parameters |
|
||||||
Description |
When executing an ABAP method that the user has triggered by an action in the
HTML page, it may be necessary to know more precisely what the action refers
to, e.g. which line in a table display. For this purpose, a call to s10contextinfo() returns an object containing the following information about the origin of the action in the HTML page:
s10contextinfo( )->fieldname
s10contextinfo( )->fieldvalue
s10contextinfo( )->tablename
s10contextinfo( )->rownumber
s10contextinfo( )->elementid
s10contextinfo( )->getvalue() <span class="output linkkey" name="kunnr" /> </span> The current value of the attribute "kunnr" is then noted in the HTML page and can be retrieved later by s10contextinfo->getvalue( 'kunnr' ). All elements with class "linkkey" that are on the same level in the HTML hierarchy as the element that triggered the action are taken into account. It is best to insert the "linkkey" elements right after the corresponding action element. The getvalue() method returns the values in the external representation, for example a customer number without leading zeros is returned. With the s10userinput() function you can get the value in internal format. Or you can use s10fromcontextinfo(), which already combines s10contextinfo->getvalue() and s10userinput(). If a child object is named as name= in the linkkey element, e.g. name="abc.kunnr", the value is taken from the attribute "kunnr" of the object "abc", but provided under "kunnr", not under "abc.kunnr". The reason for this is that the called method can also be in the object "abc" and the name attribute name "abc" is not known there. As an example for the use of s10contextinfo() here is a customer list, where we can display the customer address per line by a click. Below the address we have displayed a pushbutton with which the user can branch to a change dialog for the address:
HTML ABAP
In order that the changed address is also displayed immediately in the list, something more is to be done, which is explained in detail elsewhere. But here, for the sake of completeness, is the whole method including the update of the list display:
method change_address. This will then display the changed address immediately:
Instead of the class "linkkey" we can also use the number of the row on
which
the user clicked. If all the needed information can be found in the table row,
in our case only the customer number, this is even a bit easier: Reading the address twice is necessary in both variants of the method, once for "mykna1" and once for the object <c> corresponding to the list line, because address information is displayed both in the directly displayed table line and in the detailed information (after clicking on the list line). For example, if we use the line <c>->s10databaseread( ). a change of the country would not be displayed in the list but only in the
detail info of the list line. |
||||||
Components | S10 Framework |