Function Returns the HTML context info object
Example mycontextinfo =
s10contextinfo( ).
Format data:
  mycontextinfo type ref to /s10/contextinfo.

mycontextinfo =
  s10contextinfo( ).
Parameters
Name Type Description
contextinfo /s10/contextinfo
Current HTML context info object
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
The name= attribute of the HTML element where the action was triggered, in lowercase.

s10contextinfo( )->fieldvalue
The current value of the HTML element where the action was triggered, in the external representation, for example a customer number without leading zeros. You can use the s10userinput() function to get the value in internal format.

s10contextinfo( )->tablename
The name of the table in which the action was triggered, in lowercase.

s10contextinfo( )->rownumber
The number of the table row where the action was triggered.

s10contextinfo( )->elementid
The id= attribute of the HTML element in which the action was triggered, or of the next parent HTML element with an id. For table cells, the id is set dynamically when the table is built in HTML unique per cell.

s10contextinfo( )->getvalue()
The getvalue() method provides s10contextinfo() to retrieve additional values from the HTML page. You can use it to retrieve the values that were provided in the HTML page by elements of the class "linkkey", e.g.

<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:

 

The method "change_address" called by the pushbutton now needs the information as to which customer of the list the action refers. Therefore we include the customer number separately with class "linkkey" in HTML after the definition of the pushbutton. It is not displayed there, but the value is automatically transmitted to the called method and can be read there via s10contextinfo():

HTML
<button type="button" class="button"
    onclick
="S10Apply('change_address')">
      Change address
</button>

<span class="output linkkey" name="mykna1.kunnr"> </span>

ABAP
method change_address.

* current customer number from HTML contaxt
  s10fromcontextinfo(
        
exporting key 'kunnr'
        
changing result mykna1->kunnr ).

* let the user change the address
    
datamycustomer type ref to /s10/customer.
    
create object mycustomer.
    
mycustomer->address_changemykna1->kunnr ).

endmethod.

 

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.

* current customer number from HTML contaxt
    s10fromcontextinfo(
        
exporting key 'kunnr'
        
changing result mykna1->kunnr ).

* let the user change the address
    
datamycustomer type ref to /s10/customer.
    
create object mycustomer.
    
mycustomer->address_changemykna1->kunnr ).

* read changed address from database
    mykna1
->s10databaseread( ).

* update list display
    
read table tabkna1 
         with
 key table_line->kunnr mykna1->kunnr 
            
assigning field-symbol(<c>).
    <c>
->s10databaseread( ).
    <c>
->s10detailview 'X'.

endmethod.

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:

method
 change_address.

  
datarownumber type i.
  
rownumber s10contextinfo( )->rownumber.
  
read table tabkna1 index rownumber assigning field-symbol(<c>).

let the user change the address
    
datamycustomer type ref to /s10/customer.
    
create object mycustomer.
    
mycustomer->address_change<c>->kunnr ).

read address from database
    mykna1
->kunnr <c>->kunnr.
    mykna1
->s10databaseread( ).

* update list display
    <c>
->s10databaseread( ).
    <c>
->s10detailview 'X'.

  
endmethod.

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