Overview
It is usually easiest to read the new values directly from the database. After all, the user can cancel the dialogue after entering new values instead of saving them, and in this case the values entered but not saved should not be transferred to the list. In the example above, the table consists of objects of the class "offerinfo", which contains the information about the offer needed in the table display, i.e. offer number, date, validity, net value, currency, status and customer reference. The class "offerinfo" does not contain the other information displayed in the detail area, especially not the offer items. These are only read after clicking on a line in a separate object of the class "offerdetails" and displayed in the expanded area. A total of three different classes are involved here: Class "offerinfo" It contains only the information about the offer displayed in the table. The database then only has to evaluate a few columns of the table VBAK for reading in, so that even very many offers can be read in quickly. Class "offerdetails" All information needed for the detailed display. It also contains a table of the positions of the respective offer (database table VBAP). Access to it is made for a single offer at a time. Class "offer The comprehensive dialogue object to which the HTML pages with the table display are assigned. Here the table "taboffers" is created, whose lines are "offerinfo" objects, as well as a single object "myofferdetails" of the class "offerdetails". It is also possibIe to work with only a single class, but this reduces performance and makes the coding more confusing. It is recommended to work from the beginning with two classes analogous to "offerinfo" and "offer" for table-like displays, and with a separate detail class "offerdetails" when implementing a detail view (expanding rows). Now let's implement the update of the displayed table row as well as the expanded detail area. We first get the current "offerinfo" object in the "onchange" method. The number of the row that the user has selected is provided by the S10 framework in the context object s10contextinfo(): data: This works if the button pressed is either in the table row itself or in the expanded detail area. From "offerinfo" we transfer the offer number into the manager object "offer" and call up the change dialogue. After the change dialog, we read the current data from the database into the "offerinfo" object again:
This means that the changed values appear in the table display after returning from the "change" dialogue. In the expanded detail area, however, the old values are still displayed. To make the new values appear here as well, we have to do something more: data: This attribute is added to the display table in HTML as a hidden column: <input type="hidden" class="inputcell" name="s10detailview" /> By setting the value "X" in "s10detailview" in the called method, the S10 Framework transfers the new values to the expanded detail area. In the ABAP method we need the following steps: (1) Read in the changed detail data of the quotation. (2) Set an indicator "s10detailview" in the table to 'X'. In the example, the details of the offer are contained in class "offerdetails", which also contains all offer items as a table. The corresponding object is "myorderdetails". We therefore add the following coding: In step (2), note that the indicator is in "myofferinfo" (table object, not detail object). Here now is the entire method, whereby for the sake of completeness the SAP-side blocking of the offer is also implemented: method.
data:
rownumber type i.
rownumber = s10contextinfo( )->rownumber.
* offerinfo object (table object)
data: myofferinfo type ref to offerinfo.
read table taboffers index rownumber into myofferinfo.
* enqueue offer
call function 'ENQUEUE_EVVBAKE'
exporting
vbeln = myofferinfo->vbeln
exceptions
others = 1.
* offer currently in work? then error message
if sy-subrc > 0.
data: msgline type string.
call function 'MESSAGE_TEXT_BUILD'
exporting
msgid = sy-msgid
msgnr = sy-msgno
msgv1 = sy-msgv1
msgv2 = sy-msgv2
msgv3 = sy-msgv2
msgv4 = sy-msgv2
importing
message_text_output = msgline.
s10errormessage( msgline ).
endif.
* after enqueue, read the offer from the database
myoffer->vbeln = myofferinfo->vbeln.
myoffer->read( ).
* start the "change" dialog
myoffer->s10dialog( 'change' ).
* dequeue offer after the change dialog
call function 'DEQUEUE_EVVBAKE'
exporting
vbeln = myoffer->vbeln.
* read updated values into current offerinfo object
myofferinfo->read( ).
* read offer details
myofferdetails->vbeln = myofferinfo->vbeln.
myofferdetails->read( ).
* indicate: table detail area needs an update
myofferinfo->s10detailview = 'X'.
endmethod.
|
Components: S10 Framework |