SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Net Chart



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Dialog Programming -> Graphics
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Fri Apr 11, 2008 10:18 pm    Post subject: Net Chart Reply with quote

Code:
*&---------------------------------------------------------------------*
*& Report  Z_GUI_NETCHART                                              *
*&                                                                     *
*&---------------------------------------------------------------------*

REPORT  z_gui_netchart                          .
CLASS CL_GUI_CFW DEFINITION LOAD.
CLASS lcl_event_receiver DEFINITION DEFERRED.
DATA:
**gt_CLUSTERS      Type   table of CNG_CLUSTR_TAB,
**gt_CVALS      Type   table of CVALS_TAB,
**gt_DELETIONS      Type   table of NET_DELETE_TAB,
**gt_INODES      Type   table of CNG_INODES_TAB,
**gt_LINES      Type   table of CNG_LINES_TAB,
**gt_LVALS      Type   table of LVALS_TAB,
**gt_NVALS      Type   table of NVALS_TAB,
**gt_POSITIONS      Type   table of NET_POS_TAB,
gt_nodes           TYPE  chg_nodes_tab,
gt_nvals           TYPE  STANDARD TABLE OF net_nvals ,
g_profile          LIKE  net_profil.

DATA:
g_container        TYPE REF TO cl_gui_custom_container,
gp_net             TYPE REF TO cl_gui_netchart,
g_firstcall        TYPE c,
g_ok               LIKE sy-ucomm,
g_caption          TYPE string,
g_event_receiver   TYPE REF TO lcl_event_receiver.



*----------------------------------------------------------------------*
*       CLASS lcl_event_receiver DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_event_receiver DEFINITION.
  PUBLIC SECTION.
    METHODS:
    left_click_run     FOR EVENT left_click_run   OF  cl_gui_netchart,
    left_click_design  FOR EVENT  left_click_design OF cl_gui_netchart.

  PRIVATE SECTION.
ENDCLASS.                    "lcl_event_receiver DEFINITION

*----------------------------------------------------------------------*
*       CLASS lcl_event_receiver IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_event_receiver IMPLEMENTATION.
  METHOD left_click_run.
    MESSAGE i002(sy) WITH 'left_click_run'.
  ENDMETHOD.                    "LEFT_CLICK_RUN
  METHOD left_click_design.
    MESSAGE i002(sy) WITH 'LEFT_CLICK_DESIGN'.
  ENDMETHOD.                    "LEFT_CLICK_DESIGN
ENDCLASS.                    "lcl_event_receiver IMPLEMENTATION



SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-010.
PARAMETER: prf_grup  LIKE tcngt-prf_gruppe  DEFAULT 'SAP',
           prf_name  LIKE tcngt-prf_name    DEFAULT 'DEFAULT',
           prf_indx  LIKE tcngt-prf_index   DEFAULT '0'.
SELECTION-SCREEN END OF BLOCK b1.

START-OF-SELECTION.
  CLEAR g_firstcall.
  CALL SCREEN '100'.
*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.

  SET PF-STATUS 'GRAFIK'.

*  SET TITLEBAR 'xxx'.

ENDMODULE.                 " STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  PBO  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE pbo OUTPUT.

  IF g_firstcall IS INITIAL.
*    профиль
    g_profile-gruppe = prf_grup.
    g_profile-name   = prf_name.
    g_profile-index  = prf_indx.

    CREATE OBJECT g_container
     EXPORTING
       container_name = 'CONTAINER'.

    CREATE OBJECT gp_net
      EXPORTING parent = g_container.

    PERFORM get_data.

IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.






    IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

CALL METHOD gp_net->reg_event_left_click_run_mode
  EXPORTING
    REGISTER                 = 1
  EXCEPTIONS
    ERROR_REGIST_EVENT       = 1
    ERROR_UNREGIST_EVENT     = 2
    CNTL_ERROR               = 3
    EVENT_ALREADY_REGISTERED = 4
    EVENT_NOT_REGISTERED     = 5
    others                   = 6
        .

CALL METHOD gp_net->reg_event_left_click_run_mode
  EXPORTING
    REGISTER                 = 1
  EXCEPTIONS
    ERROR_REGIST_EVENT       = 1
    ERROR_UNREGIST_EVENT     = 2
    CNTL_ERROR               = 3
    EVENT_ALREADY_REGISTERED = 4
    EVENT_NOT_REGISTERED     = 5
    others                   = 6
        .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

    CREATE OBJECT g_event_receiver.
    SET HANDLER   g_event_receiver->left_click_run    FOR gp_net.
    SET HANDLER   g_event_receiver->left_click_design FOR gp_net.

data: it_events type CNTL_SIMPLE_EVENTS.

CALL METHOD gp_net->get_registered_events
  IMPORTING
    EVENTS     = it_EVENTS
  EXCEPTIONS
    CNTL_ERROR = 1
    others     = 2
        .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

CALL METHOD gp_net->set_registered_events
  EXPORTING
    events                    = it_EVENTS
*  EXCEPTIONS
*    CNTL_ERROR                = 1
*    CNTL_SYSTEM_ERROR         = 2
*    ILLEGAL_EVENT_COMBINATION = 3
*    others                    = 4
        .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

CALL METHOD gp_net->graphic_hierarchy_pbo
      EXPORTING
        abap_cmd       = space
        confirm        = 'x' "'space
*    INDXKEY        =
        profile        = g_profile
        sort           = 'X'
        so_contents    = space
        so_send        = space
        stat           = '1' "space
        status_text    = space
*        wait_for_input = 'X'
     CHANGING
*    CLUSTERS       =
*    CVALS          =
*    DELETIONS      =
*    INODES         =
         nodes          = gt_nodes
         nvals          = gt_nvals
*    PNODES         =
*    PVALS          =
      EXCEPTIONS
        err_in_profile = 1
        inv_profile    = 2
        OTHERS         = 3
            .
*CALL METHOD gp_net->set_visible
*  EXPORTING
*    visible           = '1'
*  EXCEPTIONS
*    CNTL_ERROR        = 1
*    CNTL_SYSTEM_ERROR = 2
*    others            = 3
        .
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.


    .



*    CALL METHOD cl_gui_cfw=>flush
*            EXCEPTIONS cntl_system_error = 1
*                       cntl_error        = 2.


    g_firstcall = 'X'.

  ENDIF.


ENDMODULE.                 " PBO  OUTPUT
*&---------------------------------------------------------------------*
*&      Form  get_data
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*

FORM get_data .
  DATA:
   ls_nodes TYPE LINE OF chg_nodes_tab,
   ls_nvals LIKE net_nvals,
   l_count  TYPE i.

*------------
*id узла
  ls_nodes-id       = '1'.
*id родителя
  ls_nodes-parent_id = space.
*id узла слева
  ls_nodes-left_id   = space.
  APPEND ls_nodes TO gt_nodes.

*-----------
* id узла
  ls_nvals-id        = '1'.
* подпись линии
*  ls_NVALS-FL        = ''.
* заголовок узла в прямоугольнике
  ls_nvals-val    = '1 узел'.
  APPEND ls_nvals TO gt_nvals.

*------------
  ls_nodes-id       =  '2'.
  ls_nodes-parent_id = '1'.
  ls_nodes-left_id   = space.
  APPEND ls_nodes TO gt_nodes.

  ls_nvals-id        = '2'.
  ls_nvals-val    = '2 узел'.
  APPEND ls_nvals TO gt_nvals.

  ls_nodes-id       =  '3'.
  ls_nodes-parent_id = '1'.
  ls_nodes-left_id   = '2'.
  APPEND ls_nodes TO gt_nodes.

  ls_nvals-id        = '3'.
  ls_nvals-val    = '3 узел'.
  APPEND ls_nvals TO gt_nvals.
  CLEAR: ls_nodes, ls_nvals-val.

  l_count = 2.
  DO 20 TIMES.
    l_count = l_count +  1.
    ls_nodes-id        = l_count + 1 .
    ls_nodes-parent_id = l_count .
    ls_nodes-left_id   = space.
    APPEND ls_nodes TO gt_nodes.

    ls_nvals-id        = l_count.
*    ls_NVALS-FL        = NET_CONST-TEXT_INDEX_0.
    ls_nvals-val       = l_count.                           "Knoten 2
    APPEND ls_nvals TO gt_nvals.
  ENDDO.

ENDFORM.                    " get_data
*&---------------------------------------------------------------------*
*&      Module  pai  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE pai INPUT.
data: l_return type i.


data:
      gr_mes           type net_graph-gr_mes,
      lg_mes           type net_graph-gr_mes,
      m_typ            type net_graph-m_typ,
      sel_field        type net_graph-sel_field,
      mode             type net_graph-gr_mode.
data: net_nodes_tab    type standard table of cng_nodes.

**data: rt type i.
**CALL METHOD cl_gui_cfw=>dispatch
**  IMPORTING
**    RETURN_CODE = rt.


CALL METHOD gp_net->graphic_pai
  EXPORTING
*    INDXKEY            =
    ACTIVATE_HELP      = 'X'
*    AT_CONTROL_DESTROY =
  IMPORTING
    GR_MES             = gr_mes
    GR_MODE            =  mode
    GR_SEL_FIELD       = sel_field
*    SETTINGS           =
  CHANGING
*    BOXES              =
*    BVALS              =
*    CLUSTERS           =
*    CVALS              =
*    DELETIONS          =
*    FRAMES             =
*    FVALS              =
*    LINES              =
*    LVALS              =
     NODES              = net_nodes_tab
*    NVALS              =
*    POSITIONS          =
    .

  IF g_ok  = 'QUIT' OR g_ok  = 'EXIT' OR g_ok  =  'BACK'.
    LEAVE TO SCREEN 0.
  else.
     CALL METHOD gp_net->set_function_code
       EXPORTING
         function_code = g_ok
       IMPORTING
         RETURN        = l_return
         .

  ENDIF.

  CALL METHOD cl_gui_cfw=>flush.

ENDMODULE.                 " pai  INPUT



screen_0100.txt
 Description:
Экран 100

Download
 Filename:  screen_0100.txt
 Filesize:  1.59 KB
 Downloaded:  1911 Time(s)

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> Dialog Programming -> Graphics All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.