|
Overview In this example we create an application that displays the measurement points for equipment. The user can enter new measurements and confirm them with a signature, or display measurements that have already been saved. This application is suitable, for example, for service technicians who need easy access to equipment data while on the road and who want to quickly enter measurement values and save them directly in the SAP system. It is also conceivable, however, to make this app directly available to customers, who can then report their own measurement points. Example If a measurement document is selected, details of the measurement point, the recorded measurement and the signature made are displayed. This view can then be processed directly, e.g. by printing it out or forwarding it as a PDF document:
When entering measurements, values can be entered in each case,
whereby the S10 Framework automatically uses the correct format according to the unit of measure.
Only after a signature has been made, can the document be saved:
|
|
Implementation The application is implemented in the following steps: :
However, this is only to be considered as a suggestion, because the HTML views can in principle be designed freely, whereby only the connection to the ABAP objects must be ensured by certain naming conventions. |
|
1. Determine the appropriate SAP tables for the data to be displayed We want to map parts of an existing SAP transaction with this S10 application. In this case we start with the transaction IE03 (Display Equipment) and can display the technical information about fields there with the F1 key. As shown below, the table view ITOB is used in IE03, which we could also take as a basis for the application.
By double-clicking on the view, however, we see that the SAP
table EQUI (Equipment Master Data) is linked here and
therefore we use this as the starting point for generating
the application: |
|
2. Determining an interface for saving the input data
(measured values) In principle, function modules should be used for saving data if they are available and suitable for the application. As a further option, you can also record a transaction via batch input and make it available as a function call. Except for your own tables, you should generally not write directly to SAP tables. You can find suitable functions for saving data via transactions SE37 (Function Builder), SE38 (ABAP Editor), SE24 (Class Builder) or also BAPI (BAPI Explorer) or mostly on the Internet in various places. In this application we use the function module MEASUREM_DOCUM_RFC_SINGLE_001 (Saving of measured values) and the ABAP class CL_MIME_REPOSITORY_API (API for MIME Repository) to save the image file with the signature into the SAP MIME-Repository. |
|
3. Generating the basic application with the S10
Utilities As a general rule, it is recommended to start with an existing application and to adjust and extend it. This way, basic functions such as the login page are already available. In this example we use the S10 utilities to generate an already executable application from an SAP table. Details can be found in the documentation under the point "Generating application parts". To do this, we first call transaction /S10/UTIL and switch to the "Generate list display" tab. As stated in step 1, we want to start with the view of the equipment and therefore enter "EQUI" as table. Then we select some fields for displaying the table, search fields as well as for the detail view. After the execution, there is a finished S10 application in the specified output directory, which we will extend. ![]() ![]() In principle, an S10 application is built from individual views, i.e. separate HTML pages, each belonging to a specific ABAP class. This means that we can develop and test individual parts of the application separately, and then use them together in a more complex application. We therefore generate further applications, whereby the output directory may well remain the same, another view with associated ABAP class is then generated. However, the table with the measurements of the measuring points of a piece of equipment is then composed of different columns, so that we edit this part directly in the HTML file. Basically, a generated S10 application consists of a view on the selected fields of the specified table or table view as well as the possibility to expand individual rows of the table and thus display details of this object. This detail view can be extended as needed by further fields, but also more complex parts like images, further tables or interaction and navigation options. |
|
4. Extending the generated application In concrete terms, we now insert a table with the previous measurements in the generated detail view as well as a pushbutton that opens a new screen for entering measured values. This screen can in turn be developed as an independent view with an associated class (modular structure). This greatly simplifies the reuse of individual parts as well as testing. The HTML views First open the generated HTML file for the view, in our case the file "equi_manager.list.html" in the directory "classes\equi_manager\views.en". The detail view for a line starts with the following code part: HTML
You can find the generated fields in this section and we can add more elements there: A pushbutton to navigate to a screen where measured values can be entered: HTML
When the user presses this pushbutton, the ABAP method
'open_measurepoints' is called in the active class.For the table with the measurement values first the headers: HTML
Following this, the definition of the table row, where we
again specify the assignment to the ABAP object by name=:HTML
The ABAP methodsWe have defined calls to the ABAP class in two places in the HTML code:
ABAP
Hint After the dialog or the view "measurepoints" has been closed, e.g. in which the user has triggered a "back", the code execution is continued in the next line. In this case, the user might have entered and saved new measurements, so a refresh of the previous view should be triggered. The second method navigates to a view that displays the details of the respective measurement or measurement document as well as an image of the signature made: ABAP
Hints
|
|
5. Implementation of the saving of measurements In principle, we only need a small table that displays the name of each measuring point and the unit of entry, as well as offering an input field for new measured values. Here you can see the connection between the elements of the HTML interface and the respective variables in the ABAP class (for details see the tropic "Data binding" in the documentation): HTML
The fields in the associated ABAP class:ABAP
We now need a simple pushbutton with which the user can trigger the saving of the entered measured values: HTML
Hint It should be pointed out once again that no passing of the entered values to the ABAP method is necessary, instead the S10 Framework automatically ensures that the user data entered at the front end is directly available in a called ABAP method. The other way round, data changed in the ABAP method is automatically sent to the front end after execution, so that the current data is displayed there in each case. The corresponding ABAP method "measures_save" is not very complex: ABAP
Note on the data type of the measured values to be entered The measured value that the user enters does not first have to be converted into another data type in this example, since it is already defined in the type expected for the function call. The type is "rimr0-recdc which belongs to the domain FLTP_INOUT (input/output field for floating point fields, 22 digits) and is basically a CHAR, i.e. text. However, you can inform the S10 framework in the ABAP program which field defines the unit of measure. On the interface, the unit is then formatted accordingly, e.g. without decimal places for ST (pieces), 2 decimal places for currency units and so on: ABAP
Here we define a field for entering a measurement value, a
field for the unit of measure, and a link between the two fields
by prefixing the name of the field with "unit_". ![]() Note on translation capabilities In addition to the possibility of using so-called text IDs in ABAP coding for the translation of texts, the S10 framework also offers the possibility of maintaining small text files and using "s10localize" to determine the text in the user's logon language. For details, see the reference to s10localize() . |
|
6. Implementation of the saving of the signature The signature feature was included by using an open-source JavaScript library available at github.com/szimek/signature_pad. It offers the possibility to save the signature image directly as a string (Base64). Thus, it can be transferred to the ABAP method very easily in a hidden S10 field. Afterwards, this text is converted back into binary format with a function call and stored in the MIME Repository as an image file. We first include the JavaScript library in the HTML view: HTML
For the signature field, a so-called HTML5 <canvas> element
is used, which allows drawing graphics. JavaScript offers a
function in the standard with which the graphic can be saved and
processed as a text representation (Base64):
HTML
After the user has signed, the image is encoded as a Base64
string and inserted into the S10 field. This will automatically
transfer it from the S10 framework to the ABAP variable:
JavaScript
When saving the measured values, the "save_signature" method
is also called. This converts the Base64 text into binary files
and saves them in the MIME Repository as .PNG image file:
ABAP
|
|
Download You can download all project files here: s10_service_example.zip The .ZIP archive contains the HTML views and a text file with the ABAP program "/s10/service_demo". To import the HTML views you can use the report "BSP_UPDATE_MIMEREPOS" as described in the documentation on "Development environment". If necessary, adjust the number of the client in the "user.logon.html" file. For details, see the documentation on S10Logon() |
|
Component: S10 Framework |