Title
A method to share data between multiple webdynpro applications and a business workflow using the shared memory concept.
Introduction
The blog describes the process of sharing data between multiple webdynpro applications and a business workflow using the shared memory concept. To demonstrate this, we have selected a business case for an employee visa application approval process wherein an employee fills its personal details and submits the form for approval. The approval process consists of two webdynpro applications. The first WD application is the employee screen wherein the employee fills out its personal information and the second WD application is the approver screen, wherein the approver reviews the data filled by the employee and either approves or rejects the form. The first WD application creates an Employee Visa Application number after the employee submits the form. Then, it triggers a business workflow. Upon which, a workflow task calls the second WD application or the approver’s screen. Before calling the approver’s screen, the workflow passes the values of the application number and the workflow work item to the shared memory. Thereafter, when the second WD application is invoked, it retrieves the data passed to the shared memory earlier and updates a custom table.
Step by Step process of the Employee Visa Application approval process.
Step 1. Create a Shared memory area ‘ZCL_SHMA_WF_WD_AREA’ using Tcode SHMA.
Image Description: Tcode SHMA: Shared memory area: ‘ZCL_SHMA_WF_WD_AREA’.
Step 2. Create a root class ‘ZCL_SHMA_WF_WD_ROOT’ in SE24 and define two instance methods SET_ATTRIBUTES and GET_ATTRIBUTES with two parameters: application_no and workitem_id.
Image Description: Tcode SE24: Instance methods SET_ATTRIBUTES and GET_ATTRIBUTES of the root class.
Step 3. Create two instance attributes GV_APPLICATION_NO and GV_WORKITEM_ID in the root class.
Image Description: Tcode SE24: Instance Attributes of the root class.
Step 4. Add an interface ‘IF_SHM_BUILD_INSTANCE’ to the root class. Then, implement its method ’IF_SHM_BUILD_INSTANCE~BUILD’ with the following code.
Image Description: Tcode SE24: Interface ‘IF_SHM_BUILD_INSTANCE’ with its method implemented in the root class.
Below is the code for the interface method if_shm_build_instance~build.
METHOD if_shm_build_instance~build.
DATA:lo_area TYPE REF TO zcl_shma_wf_wd_area,
lo_root TYPE REF TO zcl_shma_wf_wd_root,
lo_excep TYPE REF TO cx_root.
DATA : lv_workitem_id TYPE sww_wiid.
DATA : lv_application_no TYPE guid_16.
TRY.
lo_area = zcl_shma_wf_wd_area=>attach_for_write( ).
CATCH cx_shm_error INTO lo_excep.
RAISE EXCEPTION TYPE cx_shm_build_failed
EXPORTING
previous = lo_excep.
ENDTRY.
TRY.
CREATE OBJECT lo_root AREA HANDLE lo_area.
CLEAR lv_workitem_id.
CLEAR lv_application_no.
CALL METHOD lo_root->set_attributes "Initialize all the tables here
EXPORTING
im_workitem_id = lv_workitem_id
im_application_no = lv_application_no.
lo_area->set_root( lo_root ).
lo_area->detach_commit( ).
CATCH cx_root.
ENDTRY.
ENDMETHOD.
Step 5. Create a WD application ZEMPL_VISA0 using Tcode SE 80.
Image Description: Tcode SE80: WD Employee Visa Application or the First Employee Visa Application Screen.
Step 6. The WD application is an Employee Visa Application Form as shown below:
Image Description: WD Employee Visa Application Form with Employee information filled in.
Step 7. After filling in the WD form, when the employee presses the SUBMIT button, the WD application creates a visa application number and updates a custom table ZTEMPLVISA, with status ‘S’ at the back end, as shown below:
Image Description: The WD Employee Visa Application Form with a Visa Application no. created and submitted for approval.
Custom Table : ZTEMPLVISA
Image Description: Tcode SE11: the custom table ZTEMPLVISA is updated with the employee information filled in on the Employee Visa Application Form earlier.
Step 9: After that, the event handler method of SUBMIT button triggers a workflow as shown below:
Image Description: Tcode SE80: The event handler of the SUBMIT button triggers a workflow from the WD application.
Step 10: The design of the triggered workflow is shown below:
Image Description: Tcode SWDD: The design of the triggered workflow.
Step 11. The workflow work items are shown below:
Image Description: Tcode SWIA: Workflow work items.
Step 12. Create a WD application ZEMPL_VISA1 for the approver’s screen. On this screen, the approver reviews and approves the employee visa application form submitted by the employee earlier. This screen is triggered by the workflow class-method CALL_VIEW1 of workflow class ZCL_WF_WEBDYNPRO as shown below and appears as a WD work item as shown above. Further, the CALL_VIEW1 method writes the values of the parameters (application_no and workitem_id) to the shared memory using a class-method WRITE_TO_MEMORY as shown below:
Image Description: Tcode SE24: The workflow class-method CALL_VIEW1, for calling the WD Approver Screen and writing the parameter values to the shared memory.
Below is the code of class-method WRITE_TO_MEMORY:
METHOD write_to_memory.
DATA : lo_root TYPE REF TO zcl_shma_wf_wd_root.
DATA : lo_area TYPE REF TO zcl_shma_wf_wd_area.
TRY.
zcl_shma_wf_wd_area=>build( ).
CATCH cx_shma_not_configured.
RETURN.
CATCH cx_shm_inconsistent.
RETURN.
CATCH cx_shm_build_failed.
RETURN.
ENDTRY.
TRY.
lo_area = zcl_shma_wf_wd_area=>attach_for_update( ).
CATCH cx_shm_pending_lock_removed.
RETURN.
CATCH cx_shm_change_lock_active.
RETURN.
CATCH cx_shm_version_limit_exceeded.
RETURN.
CATCH cx_shm_exclusive_lock_active.
RETURN.
CATCH cx_shm_inconsistent.
RETURN.
CATCH cx_shm_no_active_version.
RETURN.
ENDTRY.
TRY.
lo_root ?= lo_area->get_root( ).
IF lo_root IS INITIAL.
CREATE OBJECT lo_root AREA HANDLE lo_area.
ENDIF.
CALL METHOD lo_root->set_attributes "Set the attributes here
EXPORTING
im_workitem_id = im_workitem_id
im_application_no = im_application_no.
lo_area->set_root( lo_root ).
lo_area->detach_commit( ).
CATCH cx_root.
ENDTRY.
ENDMETHOD.
Step 13. The workflow class ZCL_WF_WEBDYNPRO is shown below:
Image Description: Tcode SE24: Workflow class: ZCL_WF_WEBDYNPRO.
Step 14. The second WD Approver screen, when called, reads the value of the parameters (application_no and workitem_id) from the shared memory in its WDDOINIT method using a class method READ_MEMORY of assistance class ZCL_ASSIST_WEBDYNPRO as shown below:
Image Description: Tcode SE24: Assistance class of the WD applications for triggering the workflow and reading parameter values from the shared memory.
Below is the code of class-method READ_MEMORY:
METHOD read_memory.
DATA : lo_root TYPE REF TO zcl_shma_wf_wd_root.
DATA : lo_area TYPE REF TO zcl_shma_wf_wd_area.
DATA : lv_application_no TYPE guid_16.
DATA : lv_workitem_id TYPE sww_wiid.
TRY.
lo_area = zcl_shma_wf_wd_area=>attach_for_read( ).
lo_root ?= lo_area->get_root( ).
IF lo_root IS INITIAL.
CREATE OBJECT lo_root AREA HANDLE lo_area.
ENDIF.
CLEAR lv_application_no.
CLEAR lv_workitem_id.
lo_area->root->get_attributes(
IMPORTING
ex_application_no = lv_application_no
ex_workitem_id = lv_workitem_id ).
ex_application_no = lv_application_no.
ex_workitem_id = lv_workitem_id.
lo_area->detach( ).
CATCH cx_root.
ENDTRY.
ENDMETHOD.
Step15: The Second WD application or the Approver screen is shown as below:
Image Description: The WD approver screen.
Step 16. After the Approver approves the Employee Visa Application form as shown below, it updates the custom table ZTEMPLVISA with status ‘A’.
Image Description: Approved status of the approver screen.
Custom Table : ZTEMPLVISA
Image Description: Tcode SE11: Custom Table ZTEMPLVISA.
Below is the list of Work items created.
Image Description: Tcode SWIA: Workflow work items of the Employee Visa Application Form.
Conclusion
The blog helps design workflows with integration to WD applications using the shared memory concept.
I hope this article was insightful.
Any comments or suggestions will be appreciated.
Please follow the following pages for SAP ABAP Development and post your answers & questions:
ABAP Development Environment Topic Page:
https://community.sap.com/topics/abap
Post and answer questions:
ABAP Development - SAP Community
Thank you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
14 | |
10 | |
10 | |
8 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 |