Posted: Mon Nov 05, 2007 1:05 pm Post subject: Demo: Hierarchy
Code:
REPORT GRHIER_2.
*---------------------------------------------------------------------*
* D *
*---------------------------------------------------------------------*
* Dieser Report ruft die SAP-Hierarchiegrafik auf. *
* Je nach Funktionstastenwahl ist ein anderer Dialog moeglich, *
* in dessen Verlauf eine oder mehrere andere SAP-Grafikprogramme *
* angestartet werden. *
* Die Beschreibung der Dialoge befindet sich bei den entsprechenden *
* Codebloecken. *
*---------------------------------------------------------------------*
*---------------------------------------------------------------------*
* E *
*---------------------------------------------------------------------*
* This Report start the SAP-HIERARCHY-SYSTEM. *
* It demonstrates several dialogues and starts some other *
* SAP-GRAPHIC-SYSTEMS. *
* The description of the dialogues will be found where the code is *
* located (PF10 - PF14). *
* *
*---------------------------------------------------------------------*
DATA: BEGIN OF HIER OCCURS 1,
ELKEY(11),
UEKEY(11),
ETEXT(20),
VAL1 TYPE P,
VAL2 TYPE P,
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: BEGIN OF MTEXT OCCURS 1,
TEXT(100),
END OF MTEXT.
*---------------------------------------------------------------------*
* D *
*---------------------------------------------------------------------*
* PF05 *
* *
* Anstarten einer Hierarchie. *
* Selektion eines Knotens bewirkt Anzeige eines Textfensters. *
* Beendigung des Dialogs, wenn die Hierarchiegrafik beendet wird *
* Vorzeitiges Schliessen des Textfensters wird erkannt und *
* das Textfenster wird bei der naechsten Anforderung neu gestartet. *
* *
*---------------------------------------------------------------------*
*---------------------------------------------------------------------*
* E *
*---------------------------------------------------------------------*
* PF05 *
* *
* Start SAP-HIERARCHY *
* Selection of a node causes appearance of a textwindow *
* Dialog will be ended, when hierarchy is closed by the user *
* Closing the textwindow will lead to a restart next time *
* *
*---------------------------------------------------------------------*
AT PF05.
CLEAR HIER1_STAT.
TEMA_STAT = '2'. "// Start and do not wait
DO.
CALL FUNCTION 'GRAPH_HIERARCHY'
EXPORTING
MAIL_ALLOW = 'x'
NLVAL = '2/1'
TTEXT = SY-TITLE
NDIMS = 4
SMODE = 2
VTXT1 = TEXT-K01 "// Kennzahl 1 mit
VAL11 = 20 "// 2 Schwellwerten
VAL12 = 50 "// und 3 Farben
COL11 = 'DARKBLUE'
COL12 = 'DARKYELLOW'
COL13 = 'RED'
VTXT2 = TEXT-K02 "// Kennzahl 2 mit
VAL21 = 30 "// 2 Schwellwerten
VAL22 = 60 "// und 3 Farben
COL21 = 'BLUE'
COL22 = 'YELLOW'
COL23 = 'BLACK'
NTEXT = 'WHITE'
STAT = HIER1_STAT
SUPER = 'X'
IMPORTING
NODES = HIER-ELKEY
M_TYP = M_TYP
TABLES
DATA = HIER.
HIER1_STAT = '4'. "// just wait next time
CASE M_TYP.
WHEN 'D'.
EXIT. "// exit-condition
WHEN ' '.
WHEN '0'.
"// from other Application
"// if must be from Textwindow
"// it must have benn 'Q'
TEMA_STAT = '2'. "// restart TEMA next time
WHEN 'Q'.
WHEN 'I'.
READ TABLE HIER WITH KEY HIER-ELKEY.
READ TABLE BUSGDATA WITH KEY HIER-ELKEY.
PERFORM DISPLAY_TEXT TABLES MTEXT USING HIER BUSGDATA.
CALL FUNCTION 'TEXT_MATRIX'
EXPORTING
TTEXT = TEXT-TIT
RSIZE = '6'
CSIZE = '40'
STAT = TEMA_STAT
TABLES
DATA = MTEXT.
TEMA_STAT = '5'. "// reload data next time
ENDCASE.
ENDDO.
*---------------------------------------------------------------------*
* D *
*---------------------------------------------------------------------*
* PF06 *
* *
* Anstarten einer Hierarchie. *
* Selektion eines Knotens bewirkt Anzeige einer Teilhierarchie *
* Beendigung des Dialogs, wenn die erste Hierarchie geschlossen *
* wird. *
* Vorzeitiges Schliessen der Teilhierarchie wird erkannt und *
* das Programm bei der naechsten Anforderung erneut gestartet *
* *
*---------------------------------------------------------------------*
AT PF06.
CLEAR HIER1_STAT. "// start and wait
HIER2_STAT = '2'. "// start and do not wait
DO.
CALL FUNCTION 'GRAPH_HIERARCHY'
EXPORTING
WINID = 'HIER1'
TTEXT = SY-TITLE
VTXT1 = TEXT-K01 "// Kennzahl 1 mit
VAL11 = 20 "// 2 Schwellwerten
VAL12 = 50 "// und 3 Farben
COL11 = 'DARKBLUE'
COL12 = 'DARKYELLOW'
COL13 = 'RED'
VTXT2 = TEXT-K02 "// Kennzahl 2 ohne
STAT = HIER1_STAT "// Schwellwerte
SMODE = 2
NTEXT = 'WHITE'
SUPER = 'X'
MAIL_ALLOW = 'x'
IMPORTING
NODES = HIER-ELKEY
M_TYP = M_TYP
RWNID = RWNID
TABLES
DATA = HIER.
HIER1_STAT = '4'.
CASE M_TYP.
WHEN 'D'.
EXIT.
WHEN '0'.
WHEN 'Q'. "// HIER2 was closed
"// Closing HIER1 would produce
"// a 'D' Message due to SUPER
HIER2_STAT = '2'. "// restart HIER2 next time
WHEN 'I'. "// Mess. from HIER1 OR HIER2
IF RWNID EQ 'HIER1'.
PERFORM DISPLAY_NODES USING HIER-ELKEY.
CALL FUNCTION 'GRAPH_HIERARCHY'
EXPORTING
TTEXT = TEXT-TI3
SMODE = '2'
STAT = HIER2_STAT
WINID = 'HIER2'
TABLES
DATA = PHIER.
HIER2_STAT = '5'. "// reload data next time
ELSE.
"// ignore selection in HIER2
ENDIF.
ENDCASE.
ENDDO.
*---------------------------------------------------------------------*
* D *
*---------------------------------------------------------------------*
* PF07 *
* *
* Anstarten einer Hierarchie. *
* Selektion eines Knotens bewirkt Anzeige einer Praesentationsgrafik *
* Beendigung des Dialogs, wenn die Hierarchie beendet wird. *
* Vorzeitiges Schliessen der Praesentationsgrafik wird erkannt *
* und das Programm ggf. neu gestartet (sonst : INVALID_CHILD_ID_ERROR)*
* *
*---------------------------------------------------------------------*
AT PF07.
REFRESH GOPTS.
TCOL = TEXT-S01. APPEND TCOL.
TCOL = TEXT-S02. APPEND TCOL.
TCOL = TEXT-S03. APPEND TCOL.
TCOL = TEXT-S04. APPEND TCOL.
CLEAR HIER1_STAT.
BUSG_STAT = '2'. "// start and do not wait
DO.
CALL FUNCTION 'GRAPH_HIERARCHY'
EXPORTING
TTEXT = SY-TITLE
NDIMS = 4
SMODE = 2
VTXT1 = TEXT-K01
VAL11 = 20
VAL12 = 50
COL11 = 'DARKBLUE'
COL12 = 'DARKYELLOW'
COL13 = 'RED'
VTXT2 = TEXT-K02
NTEXT = 'WHITE'
STAT = HIER1_STAT
SUPER = 'X'
IMPORTING
NODES = HIER-ELKEY
M_TYP = M_TYP
TABLES
DATA = HIER.
HIER1_STAT = '4'. "// wait next time
CASE M_TYP.
WHEN 'D'.
EXIT.
WHEN 'I'.
READ TABLE HIER WITH KEY HIER-ELKEY.
READ TABLE BUSGDATA WITH KEY HIER-ELKEY.
CALL FUNCTION 'GRAPH_MATRIX_2D'
EXPORTING
TITL = HIER-ETEXT
NROW = SY-TABIX
STAT = BUSG_STAT
TABLES
DATA = BUSGDATA
OPTS = GOPTS
TCOL = TCOL.
BUSG_STAT = '5'.
WHEN '0'. "// must be from BUSG
"// must be 'Q'
BUSG_STAT = '2'. "// restart BUSG next time
ENDCASE.
ENDDO.
*--------------------------------------------------------------------*
* D *
*---------------------------------------------------------------------*
* PF08 *
* *
* Anstarten einer Hierarchie *
* Selektion eines Knotens bewirkt Anzeige einer Statistik *
* Selektion eines Punktes in Statistik startet Textfenster *
* Beendigung der Interaktion, wenn Hierarchie beendert wird *
* Vorzeitige Beendigung der Statistik oder des Textfensters *
* wird erkannt und das entsprechenden Programm bei der *
* naechsten Anforderung neu gestartet *
* *
*--------------------------------------------------------------------*
AT PF08.
DATA: BEGIN OF STATDATA OCCURS 1,
X TYPE P,
Y TYPE P,
END OF STATDATA.
CLEAR HIER1_STAT.
STAT_STAT = '2'. "// start and do not wait
TEMA_STAT = '2'. "// start and do not wait
DO.
CALL FUNCTION 'GRAPH_HIERARCHY'
EXPORTING
TTEXT = SY-TITLE
NDIMS = 4
SMODE = 2
VTXT1 = TEXT-K01
VAL11 = 20
VAL12 = 50
COL11 = 'DARKBLUE'
COL12 = 'DARKYELLOW'
COL13 = 'RED'
VTXT2 = TEXT-K02
NTEXT = 'WHITE'
STAT = HIER1_STAT
SUPER = 'X'
IMPORTING
NODES = NODE
RBUFF = RBUFF
RWNID = RWNID
M_TYP = M_TYP
TABLES
DATA = HIER.
HIER1_STAT = '4'. "// wait next time
CASE M_TYP.
WHEN 'D'.
EXIT.
WHEN 'Q'.
WHEN ' '.
WHEN 'I'.
MOVE NODE TO HIER-ELKEY.
READ TABLE HIER WITH KEY HIER-ELKEY.
READ TABLE BUSGDATA WITH KEY HIER-ELKEY.
REFRESH GOPTS.
GOPTS = '$ 4'. APPEND GOPTS.
GOPTS = 'C_ART=1'. APPEND GOPTS.
GOPTS = 'CTYPE=3'. APPEND GOPTS.
GOPTS = 'COLOR=3'. APPEND GOPTS.
GOPTS = 'LTEXT='.
WRITE TEXT-MON TO GOPTS+6. APPEND GOPTS.
REFRESH STATDATA.
STATDATA-X = 1. STATDATA-Y = BUSGDATA-VAL1. APPEND STATDATA.
STATDATA-X = 2. STATDATA-Y = BUSGDATA-VAL2. APPEND STATDATA.
STATDATA-X = 3. STATDATA-Y = BUSGDATA-VAL3. APPEND STATDATA.
STATDATA-X = 4. STATDATA-Y = BUSGDATA-VAL4. APPEND STATDATA.
MOVE TEXT-TI4 TO NODE.
WRITE HIER-ETEXT TO NODE+16(20).
CALL FUNCTION 'STAT_GRAPH'
EXPORTING
INFORM = 'X'
STAT = STAT_STAT
TTEXT = NODE
TAXIS = TEXT-AXE
SCALE = 'MAN'
XRNGU = 5
XTCKS = '6'
YRNGU = 10000
YTCKS = '11'
TABLES
DATA = STATDATA
OPTS = GOPTS.
STAT_STAT = '5'.
WHEN '0'. "// other window
IF RWNID(4) = 'STAT'. "// from STATISTIK-Window
CALL FUNCTION 'STAT_GRAPH'
EXPORTING
STAT = 'R'
INBUF = RBUFF
IMPORTING
KURVE = KURVE
INDEX = PUNKT
M_TYP = STAT_TYP
TABLES
DATA = STATDATA "// not used here
OPTS = GOPTS. "// not used here
IF STAT_TYP = 'I'.
PERFORM DISPLAY_STAT TABLES MTEXT
USING KURVE PUNKT HIER-ETEXT BUSGDATA.
CALL FUNCTION 'TEXT_MATRIX'
EXPORTING
TTEXT = TEXT-TI2
RSIZE = '4'
CSIZE = '30'
STAT = TEMA_STAT
TABLES
DATA = MTEXT.
TEMA_STAT = '5'. "// reload data next time
ELSE.
STAT_STAT = '2'. "// restart STAT next time
ENDIF.
ENDIF.
IF RWNID(4) = 'TEMA'. "// from Textwindow
"// it must have been 'Q'
TEMA_STAT = '2'. "// restart TEMA next time
ENDIF.
ENDCASE.
ENDDO.
*---------------------------------------------------------------------*
* D *
*---------------------------------------------------------------------*
* PF09 *
* *
* Anstarten einer Hierarchie. *
* Selektion eines Knotens bewirkt Anzeige von *
* - Teilhierarchie, *
* - Statistik *
* - Praesentationsgrafik *
* - Textinformation. *
* Der Dialog wird beendet, wenn die erste Hierarchie geschlossen wird *
* Selektion eines Punktes im Statistikfenster startet eine *
* zusaetzliche Textanzeige. *
* Vorzeitiges Schlieesen eines Fensters wird erkannt und das *
* entsprechende Programm bei der naechsten Anforderung erneut *
* gestartet. *
* *
*---------------------------------------------------------------------*
CASE M_TYP.
WHEN 'D'.
EXIT.
WHEN 'Q'. "// must be from HIER2
"// because quitting HIER1 would
"// cause a 'D' because of SUPER
HIER2_STAT = '2'. "// restart next time
WHEN ' '.
WHEN 'I'.
IF RWNID(5) = 'HIER1'. "// message from HIER2
MOVE HIER-ELKEY TO NODE.
READ TABLE HIER WITH KEY HIER-ELKEY.
READ TABLE BUSGDATA WITH KEY HIER-ELKEY.
REFRESH GOPTS.
CALL FUNCTION 'GRAPH_MATRIX_2D'
EXPORTING
TITL = HIER-ETEXT
NROW = SY-TABIX
STAT = BUSG_STAT
TABLES
DATA = BUSGDATA
OPTS = GOPTS
TCOL = TCOL.
BUSG_STAT = '5'.
PERFORM DISPLAY_TEXT TABLES MTEXT USING HIER BUSGDATA.
CALL FUNCTION 'TEXT_MATRIX'
EXPORTING
TTEXT = TEXT-TIT
RSIZE = '6'
CSIZE = '30'
STAT = TEMA_STAT
TABLES
DATA = MTEXT.
TEMA_STAT = '5'. "// reload data next time
PERFORM DISPLAY_NODES USING HIER-ELKEY.
CALL FUNCTION 'GRAPH_HIERARCHY'
EXPORTING
TTEXT = TEXT-TI3
SMODE = '2'
STAT = HIER2_STAT
WINID = 'HIER2'
TABLES
DATA = PHIER.
HIER2_STAT = '5'. "// reload data next time
MOVE NODE TO HIER-ELKEY.
READ TABLE HIER WITH KEY HIER-ELKEY.
REFRESH GOPTS.
GOPTS = '$ 4'. APPEND GOPTS.
GOPTS = 'C_ART=1'. APPEND GOPTS.
GOPTS = 'CTYPE=3'. APPEND GOPTS.
GOPTS = 'COLOR=3'. APPEND GOPTS.
GOPTS = 'LTEXT='.
WRITE TEXT-MON TO GOPTS+6. APPEND GOPTS.
REFRESH STATDATA.
STATDATA-X = 1. STATDATA-Y = BUSGDATA-VAL1. APPEND STATDATA.
STATDATA-X = 2. STATDATA-Y = BUSGDATA-VAL2. APPEND STATDATA.
STATDATA-X = 3. STATDATA-Y = BUSGDATA-VAL3. APPEND STATDATA.
STATDATA-X = 4. STATDATA-Y = BUSGDATA-VAL4. APPEND STATDATA.
MOVE TEXT-TI4 TO NODE.
WRITE HIER-ETEXT TO NODE+16(20).
CALL FUNCTION 'STAT_GRAPH'
EXPORTING
INFORM = 'X'
STAT = STAT_STAT
TTEXT = NODE
TAXIS = TEXT-AXE
SCALE = 'MAN'
XRNGU = 5
XTCKS = '6'
YRNGU = 10000
YTCKS = '11'
TABLES
DATA = STATDATA
OPTS = GOPTS.
STAT_STAT = '5'.
ELSE. "// must be HIER2
"// ignore mess. from HIER2
ENDIF.
WHEN '0'. "// from an non-HIER window
IF RWNID(4) = 'STAT'. "// from STAT-Window
CALL FUNCTION 'STAT_GRAPH' "// reuse RBUFF to fill
EXPORTING "// STAT-returnparameters
STAT = 'R'
INBUF = RBUFF
IMPORTING
KURVE = KURVE
INDEX = PUNKT
M_TYP = STAT_TYP
TABLES
DATA = STATDATA "// not used here
OPTS = GOPTS. "// not used here
IF STAT_TYP = 'I'.
PERFORM DISPLAY_STAT TABLES MTEXT
USING KURVE PUNKT HIER-ETEXT BUSGDATA.
CALL FUNCTION 'TEXT_MATRIX'
EXPORTING
TTEXT = TEXT-TI1
RSIZE = '4'
CSIZE = '30'
STAT = TEMA1_STAT
WINID = 'TEMA1'
TABLES
DATA = MTEXT.
TEMA1_STAT = '5'. "// reload next time
ELSE. "// must have been a 'Q'
STAT_STAT = '2'. "// restart next time
ENDIF.
ENDIF.
IF RWNID(4) = 'BUSG'.
"// must be a 'Q'-message
BUSG_STAT = '2'. "// restart BUSG next time
ENDIF.
IF RWNID(4) = 'TEMA'.
"// must be TEMA or TEMA1
IF RWNID EQ 'TEMA1'. "// restart TEMA1 next time
TEMA1_STAT = '2'.
ELSE.
TEMA_STAT = '2'. "// restart TEMA next time
ENDIF.
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 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-M01 TO FELD.
MOVE: TEXT-ELKEY TO FELD+13.
MOVE FELD TO MTEXT.
APPEND MTEXT.
MOVE: TEXT-M02 TO FELD.
MOVE: TEXT-UEKEY TO FELD+13.
MOVE FELD TO MTEXT.
APPEND MTEXT.
MOVE: TEXT-M03 TO FELD.
MOVE: TEXT-ETEXT TO FELD+13.
MOVE FELD TO MTEXT.
APPEND MTEXT.
MOVE: TEXT-M04 TO FELD.
MOVE: TEXT-VAL1 TO FELD+9(10).
MOVE FELD TO MTEXT.
APPEND MTEXT.
MOVE: TEXT-S01 TO FELD.
MOVE: DATA-VAL1 TO FELD+9(10).
MOVE FELD TO MTEXT.
APPEND MTEXT.
MOVE: TEXT-S02 TO FELD.
MOVE: DATA-VAL2 TO FELD+9(10).
MOVE FELD TO MTEXT.
APPEND MTEXT.
MOVE: TEXT-S03 TO FELD.
MOVE: DATA-VAL3 TO FELD+9(10).
MOVE FELD TO MTEXT.
APPEND MTEXT.
MOVE: TEXT-S04 TO FELD.
MOVE: DATA-VAL4 TO FELD+9(10).
MOVE FELD TO MTEXT.
APPEND MTEXT.
ENDFORM.
*---------------------------------------------------------------------*
* FORM DISPLAY_STAT *
*---------------------------------------------------------------------*
* text *
*---------------------------------------------------------------------*
* ETEXT *
*---------------------------------------------------------------------*
FORM DISPLAY_STAT TABLES MTEXT USING KURVE PUNKT ETEXT EDATA.
DATA: BEGIN OF DATA,
ELKEY(11),
VAL1 TYPE P,
VAL2 TYPE P,
VAL3 TYPE P,
VAL4 TYPE P,
END OF DATA.
DATA FELD(40).
DATA PU_1.
MOVE EDATA TO DATA.
REFRESH MTEXT.
MOVE: TEXT-T01 TO FELD.
MOVE: ETEXT TO FELD+13.
MOVE FELD TO MTEXT.
APPEND MTEXT.
MOVE: TEXT-T02 TO FELD.
WRITE KURVE TO FELD+13.
MOVE FELD TO MTEXT.
APPEND MTEXT.
MOVE: TEXT-T03 TO FELD.
WRITE PUNKT TO FELD+13.
MOVE FELD TO MTEXT.
APPEND MTEXT.
MOVE: TEXT-T04 TO FELD.
PU_1 = PUNKT.
CASE PU_1.
WHEN '1'.
WRITE DATA-VAL1 TO FELD+13(8).
WHEN '2'.
WRITE DATA-VAL2 TO FELD+13(8).
WHEN '3'.
WRITE DATA-VAL3 TO FELD+13(8).
WHEN '4'.
WRITE DATA-VAL4 TO FELD+13(8).
ENDCASE.
MOVE FELD TO MTEXT.
APPEND MTEXT.
ENDFORM.
*Text elements
*----------------------------------------------------------
* K01 Ratio 1
* K02 Ratio 2
* M01 Element :
* M02 Higher-level:
* M03 Name:
* M04 Ratio % :
* MON Monthly salaries
* S01 Column 1
* S02 Column 2
* S03 Column 3
* S04 Column 4
* T01 Title......:
* T02 Curve no...:
* T03 Point no...:
* T04 Value......:
* TI1 Stat.info window
* TI2 Add.info window
* TI3 Display subhierarchy
* TI4 Test data
* TIT Info window
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.