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

Demo: GFW: A simple hierarchy graphic using SAP Tree



 
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: Mon Nov 05, 2007 3:13 pm    Post subject: Demo: GFW: A simple hierarchy graphic using SAP Tree Reply with quote

Code:
REPORT GFW_DEMO_HIER1 .
***********************************************************************
* This is a program to demonstrate the functionality of the
* Graphical Framework (GFW).
* This is not a programming example. If you want to learn how to
* use the GFW in your own programs please take a closer look at our
* programming examples (with prefix GFW_PROG_).
***********************************************************************

* texts for example programs of GFW
INCLUDE GFW_PROG_TEXT.

* data container (DC)
INCLUDE GFW_DC_HIER.
CLASS CL_GUI_CFW DEFINITION LOAD.
CLASS CL_GFW_MUX DEFINITION LOAD.

DATA: OK_CODE          TYPE SY-UCOMM,
      ID               TYPE DOKHL-ID,
      LANGU            TYPE DOKHL-LANGU,
      OBJECT           TYPE DOKHL-OBJECT,
      FIRSTCALL        TYPE I,
      CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
      DC_INST          TYPE REF TO LCL_DC_HIER,
      DC_MANAGE        TYPE REF TO IF_DC_MANAGEMENT,
      MY_ID_AT_DC      TYPE I,
      RETVAL           TYPE SYMSGNO,
      GP_INST          TYPE REF TO CL_GUI_GP_HIER,
      cuobj_leave      TYPE REF TO CL_CU_POINT,
      ITEM_LIST        TYPE GFW_ITEM_ATTRIB_LIST,
      item_name        type gfw_item_attrib
      .

* main class needed to catch gui events
CLASS LCL_MAIN DEFINITION.
  PUBLIC SECTION.
    METHODS: ON_CLOSED FOR EVENT IF_GRAPHIC_PROXY~GRAPHIC_CLOSED
                       OF CL_GUI_GP_HIER IMPORTING EVENT.
ENDCLASS.
CLASS LCL_MAIN IMPLEMENTATION.
METHOD ON_CLOSED.
  LEAVE PROGRAM.
ENDMETHOD.
ENDCLASS.
DATA: MAIN TYPE REF TO LCL_MAIN.

START-OF-SELECTION.

CREATE OBJECT MAIN.
SET HANDLER MAIN->ON_CLOSED FOR ALL INSTANCES.

* USAGE allowed in SAP internal test reports, only
include applg_auto_test_init.

CALL SCREEN 100.

* USAGE allowed in SAP internal test reports, only
include applg_auto_test_form.
*&---------------------------------------------------------------------*
*&      Module  PBO_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE PBO_0100 OUTPUT.
  SET PF-STATUS '100'.
  RETVAL = CL_GFW=>OK.
  IF FIRSTCALL IS INITIAL.
*   create, initialize and fill DC
    CREATE OBJECT DC_INST.
    DC_MANAGE = DC_INST.
    CALL METHOD DC_MANAGE->INIT IMPORTING ID = MY_ID_AT_DC
                                          RETVAL = RETVAL.
    IF RETVAL <CL_GFW>OK.
      CALL METHOD CL_GFW=>SHOW_MSG EXPORTING MSGNO = RETVAL.
      CLEAR DC_INST.
      CLEAR DC_MANAGE.
    ELSE.
      PERFORM FILL_DC CHANGING RETVAL.
      IF RETVAL <CL_GFW>OK.
        CALL METHOD CL_GFW=>SHOW_MSG EXPORTING MSGNO = RETVAL.
      ELSE.
*       create container in which to place graphic
*       (place it in the custom control named CONTAINER
*        defined using screenpainter in dynpro 100)
        CREATE OBJECT CUSTOM_CONTAINER
          EXPORTING
            CONTAINER_NAME = 'CONTAINER'. "use uppercase letters!
"       there will be a RABAX here if any error occurred while creating
"       the container
*       create, initialize and activate graphic proxy
        CREATE OBJECT GP_INST EXPORTING AUTO_LINK = GFW_TRUE.
        CALL METHOD GP_INST->IF_GRAPHIC_PROXY~INIT
                 EXPORTING parent  = CUSTOM_CONTAINER
                           DC      = DC_INST
                           PROD_ID = CL_GUI_GP_HIER=>CO_PROD_SAPTREE
                 IMPORTING RETVAL  = RETVAL.
        IF RETVAL = CL_GFW=>OK.
*         set DC attributes
          refresh item_list. clear item_name.
          item_name-no = 1.
          item_name-name = 'NODE_TEXT0'.
          insert item_name into table item_list.
          CALL METHOD GP_INST->SET_DC_NAMES
                    EXPORTING
                       OBJ_ID    = 'OBJID'
                       PRED      = 'PRED'
                       OBJREF_ID = 'CU_REFOBJ'
                       ITEM_LIST = ITEM_LIST
                    IMPORTING RETVAL = RETVAL.
        ENDIF. "// set dc attributes
        IF RETVAL = CL_GFW=>OK.
*         mark leaves to be not expandable
          CREATE OBJECT CUOBJ_LEAVE
                        EXPORTING INSTANCE_ID = 'GFW_DEMO_HIER1'.
          CALL METHOD CUOBJ_LEAVE->IF_CUSTOMIZING~SET
                        EXPORTING ATTR_ID = cl_cu_point=>CO_EXPANDABLE
                                  VALUE   = gfw_false.
          CALL METHOD GP_INST->IF_GRAPHIC_PROXY~ADD_CU_BUNDLE
                      EXPORTING PORT   = IF_GRAPHIC_PROXY=>CO_PORT_CHART
                                KEY    = 'LEAVE'            "#EC NOTEXT
                                BUNDLE = CUOBJ_LEAVE
                      IMPORTING RETVAL = RETVAL.
        ENDIF.
        IF RETVAL = CL_GFW=>OK.
          CALL METHOD GP_INST->IF_GRAPHIC_PROXY~ACTIVATE
                               IMPORTING RETVAL = RETVAL.
        ENDIF.
        IF RETVAL <CL_GFW>OK.
*         don't cut&paste this call in end user applications!!!
*         (user would be confused by technical message)
*         raise application specific message instead, please
          CALL METHOD CL_GFW=>SHOW_MSG EXPORTING MSGNO = RETVAL.
        ENDIF.
      ENDIF. "//fill_dc ok
      FIRSTCALL = 1.
    ENDIF. "//create and init dc ok
  ENDIF.

* **** distribute changes (to all subscribed graphics proxies)
  IF NOT DC_MANAGE IS INITIAL.
    CALL METHOD DC_MANAGE->DISTRIBUTE_CHANGES
                         IMPORTING RETVAL = RETVAL.
    IF RETVAL <CL_GFW>OK.
*         don't cut&paste this call in end user applications!!!
*         (user would be confused by technical message)
*         raise application specific message instead, please
      CALL METHOD CL_GFW=>SHOW_MSG EXPORTING MSGNO = RETVAL.
    ENDIF.
  ENDIF.
* **** activate mux (handling of external graphics and interactions)
  CALL METHOD CL_GFW_MUX=>ACTIVATE IMPORTING RETVAL = RETVAL.
  IF RETVAL <CL_GFW>OK.
*         don't cut&paste this call in end user applications!!!
*         (user would be confused by technical message)
*         raise application specific message instead, please
    CALL METHOD CL_GFW=>SHOW_MSG EXPORTING MSGNO = RETVAL.
  ENDIF.

* USAGE allowed in SAP internal test reports, only
  perform auto_test_pbo USING 'EXIT'.

ENDMODULE.                 " PBO_0100  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  PAI_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE PAI_0100 INPUT.
  OK_CODE = SY-UCOMM.
* activate event analysis of object-oriented Control Framework
  CALL METHOD CL_GUI_CFW=>DISPATCH.
* handle other events
  CASE OK_CODE.
    WHEN 'BACK'.
      LEAVE PROGRAM.
    WHEN 'EXIT'.
      LEAVE PROGRAM.
    WHEN 'DOCU'.
      ID = 'RE'. LANGU = SY-LANGU. OBJECT = 'GFW_DEMO_HIER1'.
*     display program documentation
      CALL FUNCTION 'DOCU_CALL'
        EXPORTING
          DISPL             = 'X' "//show mode
          DISPL_MODE        = '2' "//like F1 help
          ID                = ID
          LANGU             = LANGU
          OBJECT            = OBJECT.
  ENDCASE.

ENDMODULE.                 " PAI_0100  INPUT
*&---------------------------------------------------------------------*
*&      Form  FILL_DC
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <p2>E_GP_DCHANDLE.
    EXIT.
  ENDIF.
  RETVAL = CL_GFW=>OK.

* insert NODES
  CLEAR OBJ.
  OBJ-OBJTYPE    = 'n'.                                     "#EC NOTEXT

  OBJ-OBJID      = CO_GFW_PROG_TOP.
  OBJ-NODE_TEXT0 = OBJ-OBJID.
  CALL METHOD DC_INST->SET_OBJ_VALUES EXPORTING ID     = MY_ID_AT_DC
                                                  OBJ    = OBJ
                                      IMPORTING RETVAL = RETVAL.
  IF RETVAL <CL_GFW>OK. EXIT. ENDIF.
  OBJ-OBJID      = CO_GFW_PROG_LEFT.
  OBJ-PRED       = CO_GFW_PROG_TOP.
  OBJ-NODE_TEXT0 = OBJ-OBJID.
  OBJ-CU_REFOBJ  = 'LEAVE'.                                 "#EC NOTEXT
  CALL METHOD DC_INST->SET_OBJ_VALUES EXPORTING ID     = MY_ID_AT_DC
                                                  OBJ    = OBJ
                                      IMPORTING RETVAL = RETVAL.
  IF RETVAL <CL_GFW>OK. EXIT. ENDIF.
  OBJ-OBJID      = CO_GFW_PROG_CENTER.
  OBJ-PRED       = CO_GFW_PROG_TOP.
  OBJ-NODE_TEXT0 = OBJ-OBJID.
  OBJ-CU_REFOBJ  = 'LEAVE'.                                 "#EC NOTEXT
  CALL METHOD DC_INST->SET_OBJ_VALUES EXPORTING ID     = MY_ID_AT_DC
                                                  OBJ    = OBJ
                                      IMPORTING RETVAL = RETVAL.
  IF RETVAL <CL_GFW>OK. EXIT. ENDIF.
  OBJ-OBJID      = CO_GFW_PROG_RIGHT.
  OBJ-PRED       = CO_GFW_PROG_TOP.
  OBJ-NODE_TEXT0 = OBJ-OBJID.
  OBJ-CU_REFOBJ  = 'LEAVE'.                                 "#EC NOTEXT
  CALL METHOD DC_INST->SET_OBJ_VALUES EXPORTING ID     = MY_ID_AT_DC
                                                OBJ    = OBJ
                                      IMPORTING RETVAL = RETVAL.
  IF RETVAL <CL_GFW>OK. EXIT. ENDIF.
ENDFORM.                    " FILL_DC

****************************************************************
* This file was generated by Direct Download Enterprise. *
* Please do not change it manually. *
****************************************************************
%_DYNPRO
GFW_DEMO_HIER1
0100
620
40
%_HEADER
GFW_DEMO_HIER1 0100 0100 20 76192 35 0 0 21 83 0G E 20001113152507
%_DESCRIPTION
Main Screen
%_FIELDS
CONTAINER 75 00 00 00 30 00 1 2 0 0 0 19 U 1 1 102
CHAR 20 80 10 00 00 00 255 1 O 0 0 0 0 0 0 ____________________
%_FLOWLOGIC
PROCESS BEFORE OUTPUT.
MODULE PBO_0100.
*
PROCESS AFTER INPUT.
MODULE PAI_0100.
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.