
This procedure describes how to:
The start page is a simple page that displays the retrieved image. With the Complete button, the application notifies the Guided Procedures framework that the task should be completed.
This event handler is called when the page is requested. It restores the internal data structures from the request. This handler retrieves the input data from the HTTP request, converts it to the appropriate format, and loads the required data.
This event handler checks and processes user input and defines navigation. It stores the output data and navigates to the completion page.
Attributes that are accessed in the event handlers must be declared for the input to the page.
You are in the ABAP Workbench.
You have created a BSP application named EUP_BSP_CO.
Create the Page Layout
| Parameter | Value |
|---|---|
|
Name |
tutorial.htm |
|
Page type |
Page with Flow Logic |
|
<%@page language="abap" %> <html> <head> <link rel="stylesheet" href="../../sap/public/bc/bsp/styles/sapbsp.css"> <title> SAP Web Application Server </title> <head> <body class="bspBody1"> <center>
<p> <img src="../../../../PUBLIC/BC/Pictograms/<%= pictogram_name %>"> <br> <form method="POST"> <input type="submit" name="onInputProcessing(update)" value="Complete"> <form/> </body> </html> |
The most important tags are explained in the table below:
| Tag | Description |
|---|---|
<img src="../../../../PUBLIC/BC/Pictograms/<%= pictogram_name %>"> |
Defines the location where the pictogram is displayed. The name of the image is dynamically specified by variable pictogram_name . |
<form method="POST"> <input type="submit" name="onInputProcessing(update)" value="Complete"><form/> |
This form defines a button that invokes the OnInputProcessing event handler. |
Implementing OnRequest Event Handler
|
DATA: method type string. method = request->get_method( ). IF method = 'POST'. EXIT. ENDIF. |
|
DATA: lv_input_type TYPE STRING, lv_input_value TYPE STRING, lv_process_id TYPE GUID_32, lv_task_id TYPE GUID_32, lv_conf_props TYPE EUP_BSP_CONF_PROPS_TABLE, lv_value_label TYPE REF TO EUP_VALUE_LABEL. |
|
CALL METHOD PAGE->GET_ATTRIBUTE EXPORTING NAME = 'process_id' IMPORTING VALUE = lv_process_id.
CALL METHOD PAGE->GET_ATTRIBUTE EXPORTING NAME = 'task_id' IMPORTING VALUE = lv_task_id. |
To transform the XML representation of the input data to object-oriented representation, use the methods of function EUP_STRUCTURE_FACTORY. In the example, call method UNPACK_VALUE_LABEL_FROM_XML to instantiate class EUP_VALUE_LABEL.
|
CALL FUNCTION 'EUP_GET_BSP_INPUT_DATA' EXPORTING IV_PROCESS_ID = lv_process_id IV_TASK_ID = lv_task_id IMPORTING EV_INPUT_VALUE = lv_input_value EV_INPUT_TYPE = lv_input_type EV_OUTPUT_TYPE = lv_output_type TABLES ET_CONF_PROPS = lv_conf_props.
CALL METHOD EUP_STRUCTURE_FACTORY=>UNPACK_VALUE_LABEL_FROM_XML EXPORTING IV_XML = lv_input_value IMPORTING EV_VALUE_LABEL = lv_value_label. |
To visualize the retrieved image, assign the data to variable pictogram_name .
|
pictogram_name = lv_value_label->get_string_struct_element( label_name = 'pictogram_name' namespace = 'com.sap.caf.gp' ). |
Implementing OnInputProcessing Event Handler
|
DATA: lt_result_state TYPE EUP_BSP_ST_RESULT_STATE, lt_result_states TYPE EUP_BSP_RESULT_STATES, str type string. |
|
lt_result_state-result_state = 'COMPLETED'. APPEND lt_result_state TO lt_result_states. DATA: lv_value_label TYPE REF TO eup_value_label. CALL FUNCTION 'EUP_CREATE_BSP_OUTPUT_STRUCT' IMPORTING EV_VALUE_LABEL = lv_value_label.
lv_value_label->set_string_struct_element( element = 'test' label_name = 'test' ). |
To convert the output data to XML, call method PACK_VALUE_LABEL_TO_XML of class EUP_STRUCTURE_FACTORY.
|
DATA: lv_value_label TYPE REF TO eup_value_label. CALL FUNCTION 'EUP_CREATE_BSP_OUTPUT_STRUCT' IMPORTING EV_VALUE_LABEL = lv_value_label.
lv_value_label->set_float_struct_element( element = '1.12' label_name = 'double' ).
CALL METHOD EUP_STRUCTURE_FACTORY=>PACK_VALUE_LABEL_TO_XML EXPORTING IV_VALUE_LABEL = lv_value_label IMPORTING EV_XML = str. |
The output is retrieved when the Application Server (AS) Java has been notified that the task was completed or an exception occurred. It is then deleted.
|
CALL FUNCTION 'EUP_STORE_BSP_OUTPUT_DATA' EXPORTING IV_PROCESS_ID = process_id IV_TASK_ID = task_id IV_OUTPUT_VALUE = str TABLES IT_RESULT_STATES = lt_result_states. |
|
navigation->goto_page( url = 'complete.htm' ). |
Define Page Attributes
| Attribute | Auto | TypingMeth | Associated Type |
|---|---|---|---|
|
PICTOGRAM_NAME |
Checked |
TYPE |
STRING |
|
PROCESS_ID |
Checked |
TYPE |
GUID_32 |
|
TASK_ID |
Checked |
TYPE |
GUID_32 |
Proceed with Creating a Completion Page .