Posted: Mon Nov 05, 2007 2:44 pm Post subject: Demo: Network Control
Code:
PROGRAM NETZOCX1 MESSAGE-ID CG.
INCLUDE LCNETDAT. "allg. Datendeklarationen
INCLUDE LCNETCON. "Konstanten
INCLUDE SGRCCNST. "allg. Konstanten Grafik
* Objekttabellen zum Halten der Grafikdaten im ABAP (Verprobung)
DATA: ALL_CLUSTERS_TAB LIKE CNG_CLUSTR OCCURS 0 WITH HEADER LINE,
ALL_CVALS_TAB LIKE NET_CVALS OCCURS 0 WITH HEADER LINE,
ALL_NODES_TAB LIKE CNG_INODES OCCURS 0 WITH HEADER LINE,
ALL_NVALS_TAB LIKE NET_NVALS OCCURS 0 WITH HEADER LINE,
ALL_LINES_TAB LIKE CNG_LINES OCCURS 0 WITH HEADER LINE,
ALL_LVALS_TAB LIKE NET_LVALS OCCURS 0 WITH HEADER LINE.
DATA: BEGIN OF FIELD_TAB OCCURS 0, "Modifizieren graf. Objekt
ID LIKE CNG_INODES-ID,
FL LIKE NET_NVALS-FL,
VAL LIKE NET_NVALS-VAL,
COLOR LIKE THLT-BG_COL,
END OF FIELD_TAB.
DATA: BEGIN OF NODE_LINE, "Modifizieren graf. Objekt
ID LIKE CNG_INODES-ID,
TYPE LIKE CNG_INODES-TYPE,
END OF NODE_LINE.
DATA: BEGIN OF SCROLL_TAB OCCURS 0, "BlЇttern in Sel. u. Pos.
FLAG(1) TYPE C,
END OF SCROLL_TAB.
DATA: ANZ TYPE I,
ANZ_C TYPE I,
ANZ_L TYPE I,
ANZ_N TYPE I,
ENTRY_ACT TYPE I,
ENTRY_TO TYPE I,
ENTRY_NEW TYPE I,
HEADERTEXT LIKE NET_NVALS-VAL,
DEF_HEADERTEXT LIKE NET_NVALS-VAL,
LINE_COUNT TYPE I VALUE 4,
LINE_COUNT_1 TYPE I VALUE 10,
OK-CODE TYPE SYUCOMM,
SAVE_OK-CODE LIKE OK-CODE,
TIME_EGG_TEXT LIKE NET_NVALS-VAL.
*----------------------------f_r Umstellung auf OCX -------------------*
INCLUDE <CTLDEF>. "allgemeine Control-Definitionen
DATA: NETZ_OCX TYPE CNTL_HANDLE, "Handle f_r Netzplan-Control
WS(4) TYPE C,
THIS_REPID LIKE SY-REPID,
THIS_DYNNR LIKE SY-DYNNR.
* USAGE allowed in SAP internal test reports, only
include applg_auto_test_init.
* Selection-screen
PARAMETER: OCX AS CHECKBOX DEFAULT 'X'. "f_r OCX-Umstellung
*----------------------------f_r Umstellung auf OCX -------------------*
SELECTION-SCREEN ULINE.
SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-010.
PARAMETER: PRF_GRUP LIKE TCNGT-PRF_GRUPPE DEFAULT 'DEMO',
PRF_NAME LIKE TCNGT-PRF_NAME DEFAULT '000000000001',
PRF_INDX LIKE TCNGT-PRF_INDEX DEFAULT '1'.
SELECTION-SCREEN END OF BLOCK B1.
*----------------------------f_r Umstellung auf OCX -------------------*
* Abfrage Betriebssystem des Frontends
CALL FUNCTION 'WS_QUERY'
EXPORTING
QUERY = 'WS'
IMPORTING
RETURN = WS
EXCEPTIONS
INV_QUERY = 1
NO_BATCH = 2
FRONTEND_ERROR = 3
OTHERS = 4.
IF OCX IS INITIAL OR NOT SY-SUBRC IS INITIAL.
CLEAR WS.
ENDIF.
* Daten f_r Grafik zusammenstellen
PERFORM COLLECT_DATA.
IF WS = 'WN32'. "Falls Windows, 32-Bit
*----------------------------f_r Umstellung auf OCX -------------------*
CALL SCREEN 300.
*----------------------------f_r Umstellung auf OCX -------------------*
ELSE. "wie bsiher
DO.
* Daten an Grafik _bergeben
PERFORM GRAPHIC_PBO.
CALL FUNCTION 'GRAPH_RECEIVE'
IMPORTING
ERRORCODE = ERR_NO
MCODE = M_TYP"Messagetyp
RWNID = RWNID
EXCEPTIONS
INV_COMMUNICATION = 1
NO_BATCH = 2.
IF NOT SY-SUBRC IS INITIAL.
EXIT.
ENDIF.
CASE M_TYP.
WHEN NET_CONST-M_TYP_D. "Graphic Window has been closed
* PAI-Verarbeitung Netzplangrafik, Globale Tabellen rЇumen
CALL FUNCTION 'CNET_GRAPHIC_PAI'.
EXIT.
WHEN NET_CONST-M_TYP_Q. "Anderes Fenster geschlossen
*---------------------------------------------------------------------*
* FORM FIELD_TO_TEXTINDEX_CVALS *
*---------------------------------------------------------------------*
* Feldname in Textindex umwandeln *
*---------------------------------------------------------------------*
FORM FIELD_TO_TEXTINDEX_CVALS TABLES CVALS STRUCTURE NET_CVALS
ALL_CLUSTERS STRUCTURE CNG_CLUSTR.
LOOP AT ALL_CLUSTERS WHERE ID = CVALS-ID.
EXIT.
ENDLOOP.
IF SY-SUBRC IS INITIAL.
CALL FUNCTION 'CNET_FIELD_TO_INDEX_CVALS'
EXPORTING
CLUSTER_TYPE = ALL_CLUSTERS-TYPE
TABLES
CVALS = CVALS.
ENDIF. "if SY-SUBRC is initial
LOOP AT ALL_LINES WHERE ID = LVALS-ID.
EXIT.
ENDLOOP.
IF SY-SUBRC IS INITIAL.
CALL FUNCTION 'CNET_FIELD_TO_INDEX_LVALS'
EXPORTING
LINE_TYPE = ALL_LINES-TYPE
TABLES
LVALS = LVALS.
ENDIF. "if SY-SUBRC is initial
ENDFORM. "form FIELD_TO_TEXTINDEX_LVALS
*---------------------------------------------------------------------*
* FORM FIELD_TO_TEXTINDEX_NVALS *
*---------------------------------------------------------------------*
* Feldname in Textindex umwandeln *
*---------------------------------------------------------------------*
FORM FIELD_TO_TEXTINDEX_NVALS TABLES NVALS STRUCTURE NET_NVALS
ALL_NODES STRUCTURE CNG_INODES.
LOOP AT ALL_NODES WHERE ID = NVALS-ID.
EXIT.
ENDLOOP.
IF SY-SUBRC IS INITIAL.
CALL FUNCTION 'CNET_FIELD_TO_INDEX_NVALS'
EXPORTING
NODE_TYPE = ALL_NODES-TYPE
TABLES
NVALS = NVALS.
ENDIF. "if SY-SUBRC is initial
ENDFORM. "form FIELD_TO_TEXTINDEX_NVALS
*---------------------------------------------------------------------*
* FORM MAKE_CLUSTERS *
*---------------------------------------------------------------------*
* Erzeugen der Cluster *
*---------------------------------------------------------------------*
FORM MAKE_CLUSTERS TABLES CLUSTERS STRUCTURE CNG_CLUSTR
CVALS STRUCTURE NET_CVALS.
*---------------------------------------------------------------------*
* FORM SET_CUA_STATUS. *
*---------------------------------------------------------------------*
* Pflegen der CUA-OberflЇche _ber den CUA-Painter *
*---------------------------------------------------------------------*
FORM SET_CUA_STATUS.
DATA: BEGIN OF EXCLUDING_TAB OCCURS 0.
INCLUDE STRUCTURE SGRCEXCLUD.
DATA: END OF EXCLUDING_TAB.
DATA: PROG LIKE SY-REPID.
PROG = SY-REPID.
* CUA-Status
CALL FUNCTION 'GRAPH_SET_CUA_STATUS'
EXPORTING
PROGRAM = PROG
STATUS = 'GRAFIK'
TABLES
EXCLUDING = EXCLUDING_TAB
EXCEPTIONS
INV_CUA_INFO = 1.
READ TABLE CVALS INDEX 1.
LOOP AT ALL_CLUSTERS WHERE ID = CVALS-ID.
NODE_LINE-ID = CVALS-ID.
NODE_LINE-TYPE = ALL_CLUSTERS-TYPE.
EXIT.
ENDLOOP.
LOOP AT CVALS.
MOVE-CORRESPONDING CVALS TO FIELD_TAB.
APPEND FIELD_TAB.
ENDLOOP.
SORT FIELD_TAB.
ENDFORM. "form INIT_0104
*---------------------------------------------------------------------*
* FORM SET_TITLE_BOX *
*---------------------------------------------------------------------*
* Setzen der Titelbox f_r's Drucken *
*---------------------------------------------------------------------*
FORM SET_TITLE_BOX TABLES BOXES STRUCTURE NET_BOXES
BVALS STRUCTURE NET_NVALS
USING CHANGE_FLAG LIKE NET_CONST-YES
HEADER_TEXT LIKE NET_NVALS-VAL.
BOXES-ID = 'B1'.
BVALS-ID = BOXES-ID.
IF CHANGE_FLAG = SPACE.
* Box neu erzeugen
BOXES-BOX_TYPE = NET_CONST-BORDERBOX.
BOXES-TYPE = NET_CONST-TYPE_2. "Rahmentyp 2
APPEND BOXES.
CALL FUNCTION 'CNET_MAKE_BOXES'
TABLES
BOXES = BOXES
BVALS = BVALS.
FREE: BOXES, BVALS.
ENDFORM. "SET_TITLE_BOX
*---------------------------------------------------------------------*
* FORM SET_TIME_EGG_TEXT *
*---------------------------------------------------------------------*
* Setzen Text im Zeitei *
*---------------------------------------------------------------------*
FORM SET_TIME_EGG_TEXT.
TIME_EGG_TEXT = TEXT-021.
CALL FUNCTION 'CNET_SET_TIMEEGG_TEXT'
EXPORTING
TEXT = TIME_EGG_TEXT.
ENDFORM. "SET_TIME_EGG_TEXT
*---------------------------------------------------------------------*
* FORM UPDATE_CLUSTERS *
*---------------------------------------------------------------------*
* Update der Clustertabellen *
*---------------------------------------------------------------------*
FORM UPDATE_CLUSTERS TABLES CLUSTERS STRUCTURE CNG_CLUSTR
CVALS STRUCTURE NET_CVALS
ALL_CLUSTERS STRUCTURE CNG_CLUSTR
ALL_CVALS STRUCTURE NET_CVALS
NODES STRUCTURE CNG_NODES
USING MES LIKE NET_GRAPH-GR_MES.
DATA: TEXT_FL_VALUES_1(10) TYPE C VALUE '1234567890',
TEXT_FL_VALUES_2(11) TYPE C VALUE '1234567890 '.
CASE MES.
WHEN SPACE. "Laden
LOOP AT CLUSTERS. "Cluster
CLEAR ALL_CLUSTERS.
MOVE-CORRESPONDING CLUSTERS TO ALL_CLUSTERS.
APPEND ALL_CLUSTERS.
ENDLOOP.
LOOP AT CVALS. "Attribute der Cluster
CLEAR ALL_CVALS.
MOVE-CORRESPONDING CVALS TO ALL_CVALS.
APPEND ALL_CVALS.
ENDLOOP.
WHEN OTHERS. "Update
LOOP AT CVALS.
* Text
IF TEXT_FL_VALUES_1 CA CVALS-FL(1)
AND TEXT_FL_VALUES_2 CA CVALS-FL+1(1).
LOOP AT ALL_CVALS WHERE ID = CVALS-ID
AND FL = CVALS-FL.
ALL_CVALS-VAL = CVALS-VAL.
MODIFY ALL_CVALS.
ENDLOOP.
IF NOT SY-SUBRC IS INITIAL.
MOVE-CORRESPONDING CVALS TO ALL_CVALS.
APPEND ALL_CVALS.
ENDIF.
* Typ
ELSEIF CVALS-FL = NET_CONST-TYPE.
LOOP AT ALL_CLUSTERS WHERE ID = CVALS-ID.
ALL_CLUSTERS-TYPE = CVALS-VAL.
MODIFY ALL_CLUSTERS.
ENDLOOP.
* AnhЇngen
ELSEIF CVALS-FL = NET_CONST-ADD_NODE "Knoten anhЇngen
OR CVALS-FL = NET_CONST-ADD_CLUSTER. "Cluster anhЇngen
IF MES = NET_CONST-ASK_FOR_INSERT
AND CVALS-FL = NET_CONST-ADD_NODE.
READ TABLE NODES INDEX 1.
CHECK SY-SUBRC IS INITIAL.
CVALS-VAL = NODES-ID.
MODIFY CVALS.
ENDIF.
LOOP AT ALL_CVALS WHERE ID = CVALS-ID
AND FL = CVALS-FL
AND VAL = CVALS-VAL.
EXIT.
ENDLOOP.
IF NOT SY-SUBRC IS INITIAL.
CLEAR ALL_CVALS.
MOVE-CORRESPONDING CVALS TO ALL_CVALS.
APPEND ALL_CVALS.
ENDIF.
* Knoten entfernen
ELSEIF CVALS-FL = NET_CONST-REMOVE_NODE.
LOOP AT ALL_CVALS WHERE ID = CVALS-ID
AND FL = NET_CONST-ADD_NODE
AND VAL = CVALS-VAL.
DELETE ALL_CVALS.
ENDLOOP.
* Cluster entfernen
ELSEIF CVALS-FL = NET_CONST-REMOVE_CLUSTER.
LOOP AT ALL_CVALS WHERE ID = CVALS-ID
AND FL = NET_CONST-ADD_CLUSTER
AND VAL = CVALS-VAL.
DELETE ALL_CVALS.
ENDLOOP.
* X-Position, Y-Position, Breite, H_he
ELSEIF CVALS-FL = NET_CONST-CLUSTER_XPOS
OR CVALS-FL = NET_CONST-CLUSTER_YPOS
OR CVALS-FL = NET_CONST-CLUSTER_WIDTH
OR CVALS-FL = NET_CONST-CLUSTER_HEIGHT.
LOOP AT ALL_CVALS WHERE ID = CVALS-ID
AND FL = CVALS-FL.
MODIFY ALL_CVALS.
ENDLOOP.
IF NOT SY-SUBRC IS INITIAL.
CLEAR ALL_CVALS.
MOVE-CORRESPONDING CVALS TO ALL_CVALS.
APPEND ALL_CVALS.
ENDIF.
*---------------------------------------------------------------------*
* MODULE MODIFY_TAB_0100 INPUT *
*---------------------------------------------------------------------*
* Modifikation der Knoten bzw. Kanten der Grafik *
*---------------------------------------------------------------------*
MODULE MODIFY_TAB_0100 INPUT.
*---------------------------------------------------------------------*
* MODULE OK_CODE_0100 INPUT *
*---------------------------------------------------------------------*
* Auswertung des OK-CODES bei der Modifikation der Knoten/Kanten*
*---------------------------------------------------------------------*
MODULE OK_CODE_0100 INPUT.
SAVE_OK-CODE = OK-CODE.
CLEAR OK-CODE.
CASE SAVE_OK-CODE.
WHEN 'UPDA'.
CASE OBJECT_TYPE.
WHEN NET_CONST-NODE_OBJECT. "Knoten
CLEAR NVALS_TAB.
REFRESH NVALS_TAB.
LOOP AT FIELD_TAB.
CLEAR NVALS_TAB.
MOVE-CORRESPONDING FIELD_TAB TO NVALS_TAB.
APPEND NVALS_TAB.
IF FIELD_TAB-COLOR <> SPACE.
CLEAR NVALS_TAB.
READ TABLE NVALS_TAB INDEX SY-TABIX.
WRITE NVALS_TAB-FL TO NVALS_TAB-VAL.
WRITE '/' TO NVALS_TAB-VAL+2(1).
WRITE FIELD_TAB-COLOR TO NVALS_TAB-VAL+3.
CONDENSE NVALS_TAB-VAL NO-GAPS.
NVALS_TAB-FL = NET_CONST-COLOR.
APPEND NVALS_TAB.
ENDIF.
ENDLOOP.
WHEN NET_CONST-LINE_OBJECT. "Kante
CLEAR LVALS_TAB.
REFRESH LVALS_TAB.
LOOP AT FIELD_TAB CURSOR ENTRY_ACT.
ENDLOOP.
*
PROCESS AFTER INPUT.
LOOP AT FIELD_TAB.
CHAIN.
FIELD FIELD_TAB-COLOR
SELECT * FROM TWCOL WHERE COLOR = FIELD_TAB-COLOR.
ENDCHAIN.
CHAIN.
FIELD: FIELD_TAB-FL.
FIELD: FIELD_TAB-VAL.
FIELD: FIELD_TAB-COLOR.
MODULE MODIFY_TAB_0100 ON CHAIN-REQUEST.
ENDCHAIN.
ENDLOOP.
MODULE OK_CODE_0100.
****************************************************************
* This file was generated by Direct Download Enterprise. *
* Please do not change it manually. *
****************************************************************
%_DYNPRO
NETZOCX1
0101
620
40
%_HEADER
NETZOCX1 0101M0101 9 48192 34 0 0 10 48101GXD 19970724165027
%_DESCRIPTION
Change Link
%_FIELDS
TEXT1 CHAR 48 00 00 00 30 00 1 2 0 0 0 4 R 0 0 102 Link
IDENTIFIKATION 3 CHAR 20 00 00 00 38 00 2 3 0 0 0 0 0 0 0 Identification
NODE_LINE-ID C CHAR 10 80 00 80 70 00 2 24 0 0 0 0 0 0 0 __________
TYPE 3 CHAR 10 00 00 00 38 00 3 3 0 0 0 0 0 0 0 Type
NODE_LINE-TYPE C CHAR 1 80 00 80 40 00 3 24 0 0 0 0 0 0 0 _
TEXT2 CHAR 48 00 00 00 30 00 5 2 0 0 0 5 R 0 0 103 Field Attributes
FIELD CHAR 4 00 00 00 38 00 6 3 0 0 0 0 0 0 0 Fld
TEXT CHAR 4 00 00 00 38 00 6 9 0 0 0 0 0 0 0 Text
FIELD_TAB-FL C CHAR 2 80 00 88 40 00 7 3 L 101 1 2 0 0 0 0 __
FIELD_TAB-VAL C CHAR 40 80 02 80 40 00 7 9 L 101 1 2 0 0 0 0 ________________________________________
OK-CODE CHAR 4 80 10 00 40 00 255 255 O 0 0 0 0 0 0 0 ____
%_FLOWLOGIC
PROCESS BEFORE OUTPUT.
MODULE SET_PF-STATUS_0101.
LOOP AT FIELD_TAB CURSOR ENTRY_ACT.
ENDLOOP.
*
PROCESS AFTER INPUT.
LOOP AT FIELD_TAB.
CHAIN.
FIELD: FIELD_TAB-FL.
FIELD: FIELD_TAB-VAL.
MODULE MODIFY_TAB_0100 ON CHAIN-REQUEST.
ENDCHAIN.
ENDLOOP.
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.