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: Hierarchy Graphics



 
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 1:04 pm    Post subject: Demo: Hierarchy Graphics Reply with quote

Code:
REPORT GRHIER_1.
*
* Demonstration von GRAPH_HIERARCHY_MENUE

DATA: BEGIN OF MENU OCCURS 1,
        TEXT(40),
      END OF MENU.
DATA: BEGIN OF MTEXT OCCURS 1,
        TEXT(60),
      END OF MTEXT.
DATA: RETWIN(10).
DATA: RETBUF(40).
DATA: BEGIN OF HIER OCCURS 1,
        ELKEY(11),
        UEKEY(11),
        ETEXT(20),
      END OF HIER.

DATA: BEGIN OF PHIER OCCURS 1,
        ELKEY(11),
        UEKEY(11),
        ETEXT(20),
      END OF PHIER.


DATA: BEGIN OF BUSGDATA OCCURS 1,
        ELKEY(11),
        VAL1 TYPE P,
        VAL2 TYPE P,
        VAL3 TYPE P,
        VAL4 TYPE P,
      END OF BUSGDATA.

DATA RBUFFER(64).
DATA TEXT(64).
DATA INDEX LIKE SY-INDEX.
DATA M_TYP(1).
DATA: HIER_STAT, PHIER_STAT, TWIN1_STAT, BUSG_STAT.
FIELD-SYMBOLS: <F>.

DATA: BEGIN OF TCOL OCCURS 1,
        TEXT(20),
      END OF TCOL,
      BEGIN OF GOPTS OCCURS 1,
        C(20),
      END OF GOPTS.


SET PF-STATUS 'GRAF'.

REFRESH MENU.
MENU = TEXT-M01. APPEND MENU.
MENU = TEXT-M02. APPEND MENU.
MENU = TEXT-M03. APPEND MENU.
MENU = TEXT-M04. APPEND MENU.
*ENU = 'Abmelden'. APPEND MENU.

HIER-UEKEY = SPACE.
HIER-ELKEY = '10000000001'.
HIER-ETEXT = 'El.1 - S1'.
APPEND HIER.
BUSGDATA-ELKEY = HIER-ELKEY.
BUSGDATA-VAL1 = 1234.
BUSGDATA-VAL2 = 2345.
BUSGDATA-VAL3 = 3456.
BUSGDATA-VAL4 = 4567.
APPEND BUSGDATA.

HIER-UEKEY = '10000000001'.
HIER-ELKEY = '11000000002'.
HIER-ETEXT = 'El.1 - S2'.
APPEND HIER.
BUSGDATA-ELKEY = HIER-ELKEY.
BUSGDATA-VAL1 = 3534.
BUSGDATA-VAL2 = 7845.
BUSGDATA-VAL3 = 1256.
BUSGDATA-VAL4 = 3467.
APPEND BUSGDATA.

HIER-UEKEY = '10000000001'.
HIER-ELKEY = '12000000002'.
HIER-ETEXT = 'El.2 - S2'.
APPEND HIER.
BUSGDATA-ELKEY = HIER-ELKEY.
BUSGDATA-VAL1 = 1734.
BUSGDATA-VAL2 = 2345.
BUSGDATA-VAL3 = 4256.
BUSGDATA-VAL4 = 3767.
APPEND BUSGDATA.

HIER-UEKEY = '10000000001'.
HIER-ELKEY = '13000000002'.
HIER-ETEXT = 'El.3 - S2'.
APPEND HIER.
BUSGDATA-ELKEY = HIER-ELKEY.
BUSGDATA-VAL1 = 8734.
BUSGDATA-VAL2 = 1345.
BUSGDATA-VAL3 = 5256.
BUSGDATA-VAL4 = 3767.
APPEND BUSGDATA.

HIER-UEKEY = '10000000001'.
HIER-ELKEY = '14000000002'.
HIER-ETEXT = 'El.4 - S2'.
APPEND HIER.
BUSGDATA-ELKEY = HIER-ELKEY.
BUSGDATA-VAL1 = 5890.
BUSGDATA-VAL2 = 3245.
BUSGDATA-VAL3 = 1786.
BUSGDATA-VAL4 = 3647.
APPEND BUSGDATA.

HIER-UEKEY = '11000000002'.
HIER-ELKEY = '11100000003'.
HIER-ETEXT = 'El.11 - S3'.
APPEND HIER.
BUSGDATA-ELKEY = HIER-ELKEY.
BUSGDATA-VAL1 = 2370.
BUSGDATA-VAL2 = 2845.
BUSGDATA-VAL3 = 1286.
BUSGDATA-VAL4 = 7311.
APPEND BUSGDATA.

HIER-UEKEY = '11000000002'.
HIER-ELKEY = '11200000003'.
HIER-ETEXT = 'El.12 - S3'.
APPEND HIER.
BUSGDATA-ELKEY = HIER-ELKEY.
BUSGDATA-VAL1 = 1210.
BUSGDATA-VAL2 = 2165.
BUSGDATA-VAL3 = 3290.
BUSGDATA-VAL4 = 1311.
APPEND BUSGDATA.

HIER-UEKEY = '11000000002'.
HIER-ELKEY = '11300000003'.
HIER-ETEXT = 'El.13 - S3'.
APPEND HIER.
BUSGDATA-ELKEY = HIER-ELKEY.
BUSGDATA-VAL1 = 4578.
BUSGDATA-VAL2 = 2789.
BUSGDATA-VAL3 = 5412.
BUSGDATA-VAL4 = 4678.
APPEND BUSGDATA.

HIER-UEKEY = '12000000002'.
HIER-ELKEY = '12100000003'.
HIER-ETEXT = 'El.21 - S3'.
APPEND HIER.
BUSGDATA-ELKEY = HIER-ELKEY.
BUSGDATA-VAL1 = 4782.
BUSGDATA-VAL2 = 3571.
BUSGDATA-VAL3 = 1672.
BUSGDATA-VAL4 = 2690.
APPEND BUSGDATA.

HIER-UEKEY = '12000000002'.
HIER-ELKEY = '12200000003'.
HIER-ETEXT = 'El.22 - S3'.
APPEND HIER.
BUSGDATA-ELKEY = HIER-ELKEY.
BUSGDATA-VAL1 = 3710.
BUSGDATA-VAL2 = 3125.
BUSGDATA-VAL3 = 5178.
BUSGDATA-VAL4 = 3730.
APPEND BUSGDATA.

HIER-UEKEY = '12200000003'.
HIER-ELKEY = '12210000004'.
HIER-ETEXT = 'El.221-S4'.
APPEND HIER.
BUSGDATA-ELKEY = HIER-ELKEY.
BUSGDATA-VAL1 = 2710.
BUSGDATA-VAL2 = 4125.
BUSGDATA-VAL3 = 1278.
BUSGDATA-VAL4 = 1730.
APPEND BUSGDATA.

HIER-UEKEY = '12200000003'.
HIER-ELKEY = '12220000004'.
HIER-ETEXT = 'El.222-S4'.
APPEND HIER.
BUSGDATA-ELKEY = HIER-ELKEY.
BUSGDATA-VAL1 = 2710.
BUSGDATA-VAL2 = 1125.
BUSGDATA-VAL3 = 4178.
BUSGDATA-VAL4 = 3570.
APPEND BUSGDATA.


SORT HIER.
LOOP AT HIER.
  WRITE: / HIER-ELKEY,20 HIER-UEKEY,50 HIER-ETEXT.
ENDLOOP.

AT PF08.
  CLEAR HIER_STAT.
  TWIN1_STAT = '2'.
  BUSG_STAT = '2'.
  PHIER_STAT = '2'.
  REFRESH GOPTS.
  REFRESH TCOL.
  TCOL = TEXT-S01. APPEND TCOL.
  TCOL = TEXT-S02. APPEND TCOL.
  TCOL = TEXT-S03. APPEND TCOL.
  TCOL = TEXT-S04. APPEND TCOL.
  DATA FIRST.
  DATA MENUNR.
  DO.
    CALL FUNCTION 'GRAPH_HIERARCHY_MENUE'
         EXPORTING
              TTEXT = TEXT-HI1
              SUPER = 'X'
              STAT  = HIER_STAT
         IMPORTING
              MENNR = MENUNR
              NODES = HIER-ELKEY
              RWNID = RETWIN
              M_TYP = M_TYP
              RBUFF = RETBUF
         TABLES
              MENU  = MENU
              DATA  = HIER.
    CASE M_TYP.
      WHEN 'D'.
        EXIT.
      WHEN 'Q'.                        "// CLOSE OF HIER2
        PHIER_STAT = '2'.              "// restart next time
      WHEN ' '.                        "// ignore
      WHEN '0'.                        "// message from non-HIER-Window
        IF RETWIN(4) = 'BUSG'.
          BUSG_STAT = '2'.             "// restart next time
        ENDIF.
        IF RETWIN(4) = 'TEMA'.
          TWIN1_STAT = '2'.            "// restart next time
        ENDIF.
      WHEN 'I'.
        HIER_STAT = '4'.
        IF HIER-ELKEY NE SPACE.
          READ TABLE BUSGDATA WITH KEY HIER-ELKEY.
          INDEX = SY-TABIX.
          READ TABLE HIER WITH KEY HIER-ELKEY.
        ENDIF.
        IF MENUNR NE SPACE.
          CASE MENUNR.
            WHEN '1'.
              PERFORM DISPLAY_TEXT TABLES MTEXT  USING HIER BUSGDATA.
              CALL FUNCTION 'TEXT_MATRIX'
                   EXPORTING
                        RSIZE = '7'
                        TTEXT = TEXT-INF
                        CSIZE = '30'
                        STAT  = TWIN1_STAT
                   TABLES
                        DATA  = MTEXT.
              TWIN1_STAT = '5'.        " Daten nachlesen
            WHEN '2'.
              PERFORM DISPLAY_NODES USING HIER-ELKEY.
              CALL FUNCTION 'GRAPH_HIERARCHY'
                   EXPORTING
                        TTEXT = TEXT-HI2
                        SMODE = '2'
                        STAT  = PHIER_STAT
                        WINID = 'HIER2'
                   TABLES
                        DATA  = PHIER.
              PHIER_STAT = '5'.
            WHEN '3'.
              CALL FUNCTION 'GRAPH_MATRIX_2D'
                   EXPORTING
                        TITL = HIER-ETEXT
                        NROW = INDEX
                        STAT = BUSG_STAT
                   TABLES
                        DATA = BUSGDATA
                        TCOL = TCOL
                        OPTS = GOPTS.
              BUSG_STAT = '5'.
            WHEN '4'.
              CALL FUNCTION 'GRAPH_DIALOG'
                   EXPORTING
                        CLOSE = 'X'.
          ENDCASE.
        ENDIF.
    ENDCASE.
  ENDDO.
*---------------------------------------------------------------------*
*       FORM DISPLAY_NODES                                            *
*---------------------------------------------------------------------*
*       text                                                          *
*---------------------------------------------------------------------*
*       ELKEY                                                         *
*---------------------------------------------------------------------*
FORM DISPLAY_NODES USING ELKEY.
  FIELD-SYMBOLS: <1>,<2>.
  DATA KEY(11).
  DATA S.
  MOVE ELKEY TO KEY.                   "Sichern Key !
  REFRESH PHIER.
  LOOP AT HIER.
    IF HIER-ELKEY GE KEY.
      ASSIGN KEY+10(1) TO <1>.
      ASSIGN HIER-ELKEY+10(1) TO <2>.
      IF <2> LE <1> AND S NE SPACE. EXIT. ENDIF.
      S = 'X'.
      MOVE HIER TO PHIER.
      MOVE HIER-ELKEY TO PHIER-ETEXT.
      APPEND PHIER.
    ENDIF.
  ENDLOOP.
ENDFORM.

*---------------------------------------------------------------------*
*       FORM DISPLAY_TEXT                                             *
*---------------------------------------------------------------------*
*       text                                                          *
*---------------------------------------------------------------------*
*       ELKEY                                                         *
*---------------------------------------------------------------------*
FORM DISPLAY_TEXT TABLES MTEXT STRUCTURE MTEXT USING ETEXT EDATA.
  DATA: BEGIN OF TEXT,
          ELKEY(11),
          UEKEY(11),
          ETEXT(20),
          VAL1 TYPE P,
          VAL2 TYPE P,
        END OF TEXT.
  DATA: BEGIN OF DATA,
          ELKEY(11),
          VAL1 TYPE P,
          VAL2 TYPE P,
          VAL3 TYPE P,
          VAL4 TYPE P,
        END OF DATA.
  DATA FELD(40).
  MOVE ETEXT TO TEXT.
  MOVE EDATA TO DATA.
  REFRESH MTEXT.
  MOVE: TEXT-MM1 TO MTEXT-TEXT.
  MOVE: TEXT-ELKEY  TO MTEXT-TEXT+13.
  APPEND MTEXT.
  MOVE: TEXT-MM2 TO MTEXT-TEXT.
  MOVE: TEXT-UEKEY  TO MTEXT-TEXT+13.
  APPEND MTEXT.
  MOVE: TEXT-MM3 TO MTEXT-TEXT.
  MOVE: TEXT-ETEXT  TO MTEXT-TEXT+13.
  APPEND MTEXT.
  MOVE: TEXT-S01 TO MTEXT-TEXT.
  MOVE: DATA-VAL1   TO MTEXT-TEXT+9(10).
  APPEND MTEXT.
  MOVE: TEXT-S02 TO MTEXT-TEXT.
  MOVE: DATA-VAL2   TO MTEXT-TEXT+9(10).
  APPEND MTEXT.
  MOVE: TEXT-S03 TO MTEXT-TEXT.
  MOVE: DATA-VAL3   TO MTEXT-TEXT+9(10).
  APPEND MTEXT.
  MOVE: TEXT-S04 TO MTEXT-TEXT.
  MOVE: DATA-VAL4   TO MTEXT-TEXT+9(10).
  APPEND MTEXT.
ENDFORM.

*Text elements
*----------------------------------------------------------
* S04 Column 4
* S03 Column 3
* S02 Column 2
* S01 Column 1
* MM3 Name:
* MM2 Higher-Level:
* MM1 Element    :
* M04 Presentation Graphics
* M03 Subordinate Elements
* M02 Detail Data
* M01 Menu
* INF Info Window
* HI2 Subhierarchy
* HI1 Display Hierarchy
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.