Certainly! Let's enhance the user interface (UI) of your ABAP report to make it more user-friendly and visually appealing. We'll organize the selection screen, group related parameters, and provide clear titles and texts.
Overview of Improvements
- Organize Selection Screen Blocks: Group related parameters into blocks with meaningful titles.
- Improve Parameter Texts: Use descriptive texts for parameters and selection options.
- Use Text Symbols: Define text symbols for titles and messages to allow easy localization and maintenance.
- Align Parameters: Arrange parameters neatly for better readability.
Updated Code
Here is the revised code with the improved UI:
*&---------------------------------------------------------------------*
*& Report ZBC_UML_CLASSDIAGRAM
*&---------------------------------------------------------------------*
REPORT zbc_uml_classdiagram.
""""" Data Declarations """""
DATA: gs_tadir TYPE tadir.
""""" Selection Screen Text Symbols """""
TEXT-001 = 'Selection Criteria'.
TEXT-002 = 'Configuration Options'.
TEXT-003 = 'Include Entities'.
TEXT-004 = 'Include Relationships'.
TEXT-005 = 'Include Details'.
TEXT-006 = 'Please specify either an object name or a package name.'.
""""" Selection Screen Definitions """""
* Block: Selection Criteria
SELECTION-SCREEN BEGIN OF BLOCK blk_selection WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS:
s_obj FOR gs_tadir-obj_name MODIF ID sel,
s_pkg FOR gs_tadir-devclass MODIF ID sel.
SELECTION-SCREEN END OF BLOCK blk_selection.
* Block: Configuration Options
SELECTION-SCREEN BEGIN OF BLOCK blk_config WITH FRAME TITLE TEXT-002.
* Sub-Block: Include Entities
SELECTION-SCREEN BEGIN OF BLOCK blk_entities WITH FRAME TITLE TEXT-003.
PARAMETERS:
p_inc_cl AS CHECKBOX DEFAULT abap_true USER-COMMAND config MODIF ID ent, " Include Classes
p_inc_if AS CHECKBOX DEFAULT abap_false USER-COMMAND config MODIF ID ent. " Include Interfaces
SELECTION-SCREEN END OF BLOCK blk_entities.
* Sub-Block: Include Details
SELECTION-SCREEN BEGIN OF BLOCK blk_details WITH FRAME TITLE TEXT-005.
PARAMETERS:
p_inc_at AS CHECKBOX DEFAULT abap_true USER-COMMAND config MODIF ID det, " Include Attributes
p_inc_mt AS CHECKBOX DEFAULT abap_true USER-COMMAND config MODIF ID det, " Include Methods
p_inc_mp AS CHECKBOX DEFAULT abap_false USER-COMMAND config MODIF ID det, " Include Method Parameters
p_icn_dt AS CHECKBOX DEFAULT abap_false USER-COMMAND config MODIF ID det, " Include Data Types
p_inc_rt AS CHECKBOX DEFAULT abap_false USER-COMMAND config MODIF ID det, " Include Return Type
p_inc_nt AS CHECKBOX DEFAULT abap_false USER-COMMAND config MODIF ID det. " Include Notes
SELECTION-SCREEN END OF BLOCK blk_details.
* Sub-Block: Include Relationships
SELECTION-SCREEN BEGIN OF BLOCK blk_relationships WITH FRAME TITLE TEXT-004.
PARAMETERS:
p_inc_ri AS CHECKBOX DEFAULT abap_true USER-COMMAND config MODIF ID rel, " Inheritance
p_inc_rc AS CHECKBOX DEFAULT abap_true USER-COMMAND config MODIF ID rel, " Composition
p_inc_ra AS CHECKBOX DEFAULT abap_false USER-COMMAND config MODIF ID rel, " Aggregation
p_inc_rs AS CHECKBOX DEFAULT abap_false USER-COMMAND config MODIF ID rel. " Association
SELECTION-SCREEN END OF BLOCK blk_relationships.
SELECTION-SCREEN END OF BLOCK blk_config.
""""" Initialization """""
INITIALIZATION.
" Default Values
p_obj = 'ZCL_BC_UML_CLASS_DIAGRAM'.
p_pkg = 'ZBC_UML'.
p_inc_cl = abap_true.
p_inc_if = abap_false.
p_inc_at = abap_true.
p_inc_mt = abap_true.
p_inc_mp = abap_false.
p_icn_dt = abap_false.
p_inc_rt = abap_false.
p_inc_nt = abap_false.
p_inc_ri = abap_true.
p_inc_rc = abap_true.
p_inc_ra = abap_false.
p_inc_rs = abap_false.
" Selection Texts for Parameters and Select-Options
%_s_obj_%_app_%-text = 'Object Name'.
%_s_pkg_%_app_%-text = 'Package Name'.
%_p_inc_cl_%_app_%-text = 'Include Classes'.
%_p_inc_if_%_app_%-text = 'Include Interfaces'.
%_p_inc_at_%_app_%-text = 'Include Attributes'.
%_p_inc_mt_%_app_%-text = 'Include Methods'.
%_p_inc_mp_%_app_%-text = 'Include Method Parameters'.
%_p_icn_dt_%_app_%-text = 'Include Data Types'.
%_p_inc_rt_%_app_%-text = 'Include Return Type'.
%_p_inc_nt_%_app_%-text = 'Include Notes'.
%_p_inc_ri_%_app_%-text = 'Include Inheritance'.
%_p_inc_rc_%_app_%-text = 'Include Composition'.
%_p_inc_ra_%_app_%-text = 'Include Aggregation'.
%_p_inc_rs_%_app_%-text = 'Include Association'.
""""" Input Validation """""
AT SELECTION-SCREEN.
IF s_obj[] IS INITIAL AND s_pkg[] IS INITIAL.
MESSAGE TEXT-006 TYPE 'E'.
ENDIF.
""""" Main Program """""
START-OF-SELECTION.
DATA: ls_config TYPE zbc_uml_renderer=>ty_config.
" Populate Configuration Structure
ls_config-include_classes = p_inc_cl.
ls_config-include_interfaces = p_inc_if.
ls_config-include_attributes = p_inc_at.
ls_config-include_methods = p_inc_mt.
ls_config-include_method_parameters = p_inc_mp.
ls_config-include_data_types = p_icn_dt.
ls_config-include_return_type = p_inc_rt.
ls_config-include_notes = p_inc_nt.
ls_config-include_relation_inheritance = p_inc_ri.
ls_config-include_relation_composition = p_inc_rc.
ls_config-include_relation_aggregation = p_inc_ra.
ls_config-include_relation_association = p_inc_rs.
" Instantiate Diagram Object
DATA(lo_diagram) = NEW zbc_uml_class_diagram(
it_packages = CONV zbc_uml_class_diagram=>tt_packages( s_pkg[] )
it_classes = CONV zbc_uml_class_diagram=>tt_classes( s_obj[] )
io_renderer = NEW zbc_uml_renderer_plantuml( ls_config )
).
" Generate and Display Diagram
lo_diagram->generate( ).
lo_diagram->render( ).
lo_diagram->display_diagram( ).
Explanation of Changes
1. Organized Selection Screen Blocks
2. Improved Parameter Texts and Titles
- Used meaningful titles for blocks and sub-blocks via text symbols (
TEXT-001, TEXT-002, etc.).
- Updated parameter texts using the selection texts (
%_parameter_%_app_%-text) for clarity.
- Ensured consistency in the naming and description of parameters.
3. Defined Text Symbols
- Added text symbols for block titles and error messages.
- This makes it easier to maintain and localize the texts if needed.
- Example:
TEXT-001 = 'Selection Criteria'.
TEXT-006 = 'Please specify either an object name or a package name.'.
4. Aligned Parameters and Used Modifiers
- Used
MODIF ID to group parameters, which can be helpful for dynamic modifications in the future.
- Ensured that parameters are neatly aligned within their blocks for better readability.
5. Input Validation Improvement
- Corrected the condition in
AT SELECTION-SCREEN to check if both s_obj and s_pkg are initial.
- Used
s_obj[] IS INITIAL instead of p_obj IS INITIAL since s_obj is a range table.
6. Minor Code Clean-Up
- Renamed variables (e.g.,
a to lo_diagram) for clarity.
- Added appropriate types in the
CONV statements to avoid syntax errors.
Additional Suggestions
Dynamic Selection Screen Behavior
- Dynamic Enabling/Disabling: You can use the
AT SELECTION-SCREEN OUTPUT event along with MODIFY SCREEN to enable or disable parameters based on user input.
- Validation Messages: Provide informative messages if the user input is incorrect or incomplete.
User Experience Enhancements
- Default Values: Review default values to ensure they make sense for typical use cases.
- Tooltips: Add tooltips to parameters to provide additional guidance (using
SELECTION-SCREEN COMMENT and SELECTION-SCREEN HELP-REQUEST).
Localization and Maintenance
- Text Elements: Use text symbols and selection texts consistently to make future maintenance and localization easier.
Conclusion
By organizing the selection screen into well-defined blocks with clear titles and grouping related parameters, the UI becomes more intuitive and user-friendly. The use of descriptive texts and proper alignment improves the overall readability of the selection screen.
Feel free to further customize the texts and organization to suit your specific requirements. If you have any questions or need further assistance, don't hesitate to ask!