Quantcast
Channel: ABAP Development
Viewing all articles
Browse latest Browse all 948

How to create a RoadMap in GUI environment

$
0
0

Moderator note: this blog uses classes in the /USE/ namespace. If this namespace does not exist on your implementation, you cannot follow the examples in this blog.

 

Hi guys,

 

This is my first blog and I found an interesting subject one week ago about RoadMap but in GUI environment, normally Roadmap is used with Web Dynpros.

 

This is the code of my program

 

*---------------------------------------------------------------------*
* Description                                                                    *
*--------------------------------------------------------------------*
* Program      : YTEST_ROADMAP                               *
* Author          : David Carballido Córdova                   *
* Date             : 22/08/2013                                              *
* Comentarios   : Build and show Roadmap             *
*--------------------------------------------------------------------*
REPORT ytest_roadmap.
PARAMETERS: p_steps TYPE i OBLIGATORY.
*----------------------------------------------------------------------*
*       CLASS DEFINITION DEFERRED
*----------------------------------------------------------------------*
CLASS: lcl_main  DEFINITION DEFERRED,        lcl_event DEFINITION DEFERRED.
*----------------------------------------------------------------------*
*       Global Variables
*----------------------------------------------------------------------*
DATA: go_main TYPE REF TO lcl_main,       g_state TYPE /use/ugu1_state,       g_text  TYPE char40.
*----------------------------------------------------------------------*
*       CLASS lcl_main DEFINITION
*----------------------------------------------------------------------*
CLASS lcl_main DEFINITION FINAL.   PUBLIC SECTION.     METHODS: start_road,              state_click IMPORTING i_state_id TYPE /use/ugu1_state,              next_step.   PRIVATE SECTION.     METHODS: init_roadmap.     DATA: go_roadmap TYPE REF TO /use/cl_ugu1_html_roadmap,           go_custom  TYPE REF TO cl_gui_custom_container,           go_event   TYPE REF TO lcl_event.
ENDCLASS.                    "lcl_main DEFINITION
*----------------------------------------------------------------------*
*       CLASS lcl_event DEFINITION
*----------------------------------------------------------------------*
CLASS lcl_event DEFINITION FINAL.   PUBLIC SECTION.     METHODS: state_click FOR EVENT evt_state_click                 OF /use/cl_ugu1_html_roadmap                     IMPORTING i_state_id.
ENDCLASS.                    "lcl_event DEFINITION
*----------------------------------------------------------------------*
*       CLASS lcl_main IMPLEMENTATION
*----------------------------------------------------------------------*
CLASS lcl_main IMPLEMENTATION.   METHOD start_road.     IF go_custom IS INITIAL.
* Instance Container       CREATE OBJECT go_custom         EXPORTING           container_name              = 'ROADMAP'         EXCEPTIONS           cntl_error                  = 1           cntl_system_error           = 2           create_error                = 3           lifetime_error              = 4           lifetime_dynpro_dynpro_link = 5.       IF sy-subrc = 0.
* Instance Roadmap         CREATE OBJECT go_roadmap           EXPORTING             i_parent            = go_custom             i_application_event = abap_true           EXCEPTIONS             cntl_error          = 1.         IF sy-subrc <> 0.           EXIT.         ENDIF.
* Instance Event Class         CREATE OBJECT go_event.         SET HANDLER go_event->state_click FOR go_roadmap.
*  Initializing Roadmap         me->init_roadmap( ).
* Set  Width of Roadmap         go_roadmap->set_state_width( i_width = '40' ).
* Generate HTML of Roadmap         go_roadmap->render( EXCEPTIONS render_error = 1 ).       ELSE.         EXIT.       ENDIF.     ENDIF.   ENDMETHOD.                    "start_road   METHOD init_roadmap.
* Local Variables     DATA: l_step TYPE numc2,           l_text TYPE char30.
* Initializing States     go_roadmap->remove_all_states( EXCEPTIONS remove_failure = 1 ).     DO p_steps TIMES.       l_step = sy-index.       CONCATENATE 'Step' l_step INTO l_text SEPARATED BY space.       go_roadmap->add_state(         EXPORTING           i_state_text   = l_text           i_state_type   = /use/cl_ugu1_html_roadmap=>c_state_normal           i_is_clickable = abap_true           i_is_optional  = abap_false         EXCEPTIONS           add_failure    = 1 ).     ENDDO.
* Activate first state     IF g_state IS INITIAL.       go_roadmap->set_state_type(         EXPORTING           i_state_id     = '1'           i_state_type   = /use/cl_ugu1_html_roadmap=>c_state_active         EXCEPTIONS           invalid_state  = 1           update_failure = 2 ).
* Send initial text       g_text = go_roadmap->get_state_text( '1' ).     ELSE.       go_roadmap->set_state_type(         EXPORTING           i_state_id     = g_state           i_state_type   = /use/cl_ugu1_html_roadmap=>c_state_active         EXCEPTIONS           invalid_state  = 1           update_failure = 2 ).     ENDIF.   ENDMETHOD.                    "init_roadmap   METHOD state_click.     g_state = i_state_id.
* Get text of state      g_text = go_roadmap->get_state_text( i_state_id ).
* Free Objects     go_roadmap->free( ).     go_custom->free( ).
* Clean Objects     CLEAR: go_roadmap, go_custom.
* Simulate ENTER to refresh screen     cl_gui_cfw=>set_new_ok_code( '/00' ).   ENDMETHOD.                    "state_click   METHOD next_step.
* Local Variables     DATA: lt_states TYPE /use/ugu1_t_roadmap_state,           l_state   TYPE /use/ugu1_state.     FIELD-SYMBOLS: <fs_states> TYPE /use/ugu1_s_roadmap_state.
* Get active state     go_roadmap->get_states_by_type(       EXPORTING         i_state_type = /use/cl_ugu1_html_roadmap=>c_state_active       IMPORTING         et_states = lt_states ).     READ TABLE lt_states ASSIGNING <fs_states> INDEX 1.     IF sy-subrc = 0.       l_state = <fs_states>-state_id + 1.
* Get residue on parameter selected       l_state = l_state MOD ( p_steps + 1 ).       IF l_state = 0.         l_state = 1.       ENDIF.
* Set state click       me->state_click( l_state ).     ELSE.       MESSAGE s888(sabapdocu) WITH 'No existe paso activo'.     ENDIF.   ENDMETHOD.                    "next_step
ENDCLASS.                    "lcl_main IMPLEMENTATION
*----------------------------------------------------------------------*
*       CLASS lcl_event IMPLEMENTATION
*----------------------------------------------------------------------*
CLASS lcl_event IMPLEMENTATION.   METHOD state_click.     go_main->state_click( i_state_id ).   ENDMETHOD.                    "state_click
ENDCLASS.                    "lcl_event IMPLEMENTATION
*----------------------------------------------------------------------*
*       S T A R T  -  O F  -  S E L E C T I O N
*----------------------------------------------------------------------*
START-OF-SELECTION.
* Instance Main Class   CREATE OBJECT go_main.
* Show Roadmap   CALL SCREEN 100.
*&---------------------------------------------------------------------*
*&      Module  STATUS  OUTPUT
*&---------------------------------------------------------------------*
MODULE status OUTPUT.   SET PF-STATUS 'ST_100'.   SET TITLEBAR 'TIT_100'.
* Show Roadmap   go_main->start_road( ).
ENDMODULE.                 " status  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  user_command  INPUT
*&---------------------------------------------------------------------*
MODULE user_command INPUT.   CASE sy-ucomm.     WHEN 'BACK'.       LEAVE TO SCREEN 0.     WHEN 'NEXT'.       go_main->next_step( ).   ENDCASE.
ENDMODULE.                 " user_command  INPUT

 

Here I attach screen 100 to upload and generate

Dynpro_1.jpg

Dynpro_2.jpg

Then when you execute the program you can select how many steps are going to build, for example I'll select 10

Dynpro_3.jpg

And this is the result

Dynpro_4.jpg

You can click on any step or press "Next Step" button to select the next step, I hope this help you in any development and I welcome your comments

 

PD: Sry for my bad english

 

Regards

David Carballido


Viewing all articles
Browse latest Browse all 948

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>