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: Mutual Updating of Bar Chart and Screen



 
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:13 pm    Post subject: Demo: Mutual Updating of Bar Chart and Screen Reply with quote

Code:

REPORT BARCBO04.

DATA: BEGIN OF G_DATES OCCURS 0,
        START LIKE SY-DATUM,
        END   LIKE SY-DATUM,
        NODE_ID LIKE BCNODES-ID,
      END OF G_DATES.

CONTROLS: TCTRL_DATES TYPE TABLEVIEW USING SCREEN 900.

INCLUDE SGRCCNST.                      "Allgemeine Konstanten der Grafik
INCLUDE LBARCCON.                      "Konstanten zum Balkenplan
INCLUDE BARCDATA.                      "Allgemeine Datendeklarationen

DATA: ACT_BOX_ID       LIKE BCBOXES-ID,
      ACT_NODE_ID      LIKE BCNODES-ID,
      CHART            LIKE BCCHART-ID,
      SECTION          LIKE BCSECTION-ID,
      FOCUS_FLAG       LIKE NET_GRAPH-FLAG,  "Fokussteuerung Grafik
      WFI_FLAG         LIKE NET_GRAPH-FLAG,  "Wait-for-Input
      ENTRY_ACT        TYPE I,
      TAB_INDEX        LIKE SY-TABIX,
      FLG_PLANTAFEL    TYPE C,         "Plantafel aktiv
      FLG_UPDATE       TYPE C,         "Dynpro aktualisieren
      TA_START         LIKE BCSECTION-START  VALUE '01.01.1997;',
      TA_END           LIKE BCSECTION-START  VALUE '31.12.1997;',
      ROW              LIKE SY-TABIX,
      VAL              LIKE BCVALS-VAL,
      PROG             LIKE SY-REPID.

*&---------------------------------------------------------------------*
* Termine
G_DATES-START = '19970102'. G_DATES-END = '19970120'. APPEND G_DATES.
G_DATES-START = '19970202'. G_DATES-END = '19970220'. APPEND G_DATES.
G_DATES-START = '19970302'. G_DATES-END = '19970320'. APPEND G_DATES.
G_DATES-START = '19970402'. G_DATES-END = '19970420'. APPEND G_DATES.
G_DATES-START = '19970502'. G_DATES-END = '19970520'. APPEND G_DATES.

CALL SCREEN 900.


*&---------------------------------------------------------------------*
*&      Module  STATUS_0900  OUTPUT
*&---------------------------------------------------------------------*
MODULE STATUS_0900 OUTPUT.

  SET PF-STATUS 'DYNPRO'.
  SET TITLEBAR '100'.

ENDMODULE.                             " STATUS_0900  OUTPUT


*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0900  INPUT
*&---------------------------------------------------------------------*
MODULE USER_COMMAND_0900 INPUT.

  CASE SY-UCOMM.
    WHEN 'BACK'.                       "Zurьck
      IF NOT FLG_PLANTAFEL IS INITIAL.
        ABAP_CMD = BC_CONST-ASK_FOR_EXIT.
        PERFORM PLANTAFEL.
      ENDIF.
      SET SCREEN 0.
      LEAVE SCREEN.
    WHEN 'ENDE'.                       "Ende
      IF NOT FLG_PLANTAFEL IS INITIAL.
        ABAP_CMD = BC_CONST-ASK_FOR_EXIT.
        PERFORM PLANTAFEL.
      ENDIF.
      SET SCREEN 0.
      LEAVE SCREEN.
    WHEN 'ABBR'.                       "Abbrechen
      IF NOT FLG_PLANTAFEL IS INITIAL.
        ABAP_CMD = BC_CONST-ASK_FOR_EXIT.
        PERFORM PLANTAFEL.
      ENDIF.
      SET SCREEN 0.
      LEAVE SCREEN.
    WHEN 'GRAF'.                       "Balkenplan
      IF FLG_PLANTAFEL IS INITIAL.     "falls erster Aufruf
        PERFORM CREATE_PLANTAFEL_OBJECTS.  "Grafikobjekte erzeugen
      ENDIF.
      FOCUS_FLAG = 'x'.                "Fokus auf Grafik setzen
      WFI_FLAG   = 'x'.                "Grafik soll auf Eingabe warten
      PERFORM PLANTAFEL.
  ENDCASE.

ENDMODULE.                             " USER_COMMAND_0900  INPUT


*&---------------------------------------------------------------------*
*&      Module  MODIFY_TAB_900  INPUT
*&---------------------------------------------------------------------*
MODULE MODIFY_TAB_900 INPUT.

  MODIFY G_DATES INDEX ENTRY_ACT.

  CHECK NOT FLG_PLANTAFEL IS INITIAL.  "falls Grafik da

* Werte in Grafik aktualisieren
  NODE_VALS-ID       = G_DATES-NODE_ID.
  NODE_VALS-CHART_ID = CHART.
  NODE_VALS-FL       = '1'.
  CALL FUNCTION 'BARC_CONVERT_DATE'
       EXPORTING
            DATE   = G_DATES-START
       IMPORTING
            STRING = NODE_VALS-VAL.
  APPEND NODE_VALS.

  NODE_VALS-FL       = '2'.
  CALL FUNCTION 'BARC_CONVERT_DATE'
       EXPORTING
            DATE   = G_DATES-END
       IMPORTING
            STRING = NODE_VALS-VAL.
  APPEND NODE_VALS.

  CLEAR: FOCUS_FLAG,                   "Fokus nicht setzen
         WFI_FLAG.     "Grafik soll nicht auf Eingabe warten

  PERFORM PLANTAFEL.

ENDMODULE.                             " MODIFY_TAB_900  INPUT


*---------------------------------------------------------------------*
*       FORM CREATE_PLANTAFEL_OBJECTS                                 *
*---------------------------------------------------------------------*
*       Grafikobjekte erzeugen                                        *
*---------------------------------------------------------------------*
FORM CREATE_PLANTAFEL_OBJECTS.

  CLEAR: ACT_BOX_ID, ACT_NODE_ID.

  REFRESH: BOXES, BOX_VALS, DELETIONS,
           NODES, NODE_VALS, POSITIONS.

* Grafikprofil
  GRAPH_PROFILE-PRF_GRUPPE = 'DEMO'.
  GRAPH_PROFILE-PRF_NAME   = '000000000001'.
  GRAPH_PROFILE-PRF_INDEX  = '4'.

* Fenstertitel setzen
  SET TITLEBAR '100'.

* CUA-Status setzen
  PROG = SY-REPID.
  CALL FUNCTION 'GRAPH_SET_CUA_STATUS'
       EXPORTING
            PROGRAM      = PROG
            STATUS       = 'GRAFIK'
       EXCEPTIONS
            INV_CUA_INFO = 1.

* Start und Ende der Zeitachse festlegen
  CALL FUNCTION 'BARC_SET_TIME_AXIS'
       EXPORTING
            START = TA_START
            END   = TA_END.

* Chart erzeugen
  CALL FUNCTION 'BARC_ADD_CHART'
       IMPORTING
            ID = CHART.

* Breite der Spalte im Tabellenteil setzten
  CALL FUNCTION 'BARC_SET_COLUMN_WIDTH'
       EXPORTING
            CHART_ID = CHART
            WIDTH    = 4000.

* Ьberschrift des Tabellenteils setzen
  BOXES-ID         = 999.
  BOXES-TYPE       = BC_CONST-ROW_BOX.
  BOXES-CHART_ID   = CHART.
  BOXES-FORM_TYPE  = 'B1'.
  BOXES-COLOR_TYPE = 'B0'.
  APPEND BOXES.

  BOX_VALS-ID  = BOXES-ID.
  BOX_VALS-FL  = '0'.
  BOX_VALS-VAL = TEXT-001.             "Balken
  APPEND BOX_VALS.

  POSITIONS-OBJ_ID     = BOXES-ID.
  POSITIONS-OBJ_TYPE   = BC_CONST-BOX_OBJECT.
  POSITIONS-CHART_ID   = CHART.
  POSITIONS-ROW_NUMBER = 0.
  APPEND POSITIONS.

  WRITE BOXES-ID TO VAL.

  CALL FUNCTION 'BARC_SET_CHART_ATTRIB'
       EXPORTING
            FL  = BC_CONST-CHART_TITLE_BOX
            ID  = CHART
            VAL = VAL.

* Sektion erzeugen
  CALL FUNCTION 'BARC_ADD_SECTION'
       EXPORTING
            SIZE  = 70
            START = TA_START
            UNIT  = '5'
       IMPORTING
            ID    = SECTION.

* Ribbons in Sektion einfьgen
  CALL FUNCTION 'BARC_ADD_RIBBON'
       EXPORTING
            CHART_ID   = CHART
            COLOR_TYPE = 'R1'
            SECTION_ID = SECTION
            UNIT       = '5'.          "Tagesribbon

  CALL FUNCTION 'BARC_ADD_RIBBON'
       EXPORTING
            CHART_ID   = CHART
            COLOR_TYPE = 'R2'
            SECTION_ID = SECTION
            UNIT       = '3'.          "Monatsribbon

* Boxen und Knoten erzeugen
  LOOP AT G_DATES.
    ROW = SY-TABIX.

*   Boxes
    ACT_BOX_ID = ACT_BOX_ID + 1.

    BOXES-ID         = ACT_BOX_ID.
    BOXES-TYPE       = BC_CONST-ROW_BOX.
    BOXES-CHART_ID   = CHART.
    BOXES-FORM_TYPE  = 'B1'.
    BOXES-COLOR_TYPE = 'B1'.
    APPEND BOXES.

    POSITIONS-OBJ_ID     = BOXES-ID.
    POSITIONS-OBJ_TYPE   = BC_CONST-BOX_OBJECT.
    POSITIONS-CHART_ID   = BOXES-CHART_ID.
    POSITIONS-ROW_NUMBER = ROW.
    APPEND POSITIONS.

    BOX_VALS-ID  = BOXES-ID.
    BOX_VALS-FL  = '0'.
    WRITE BOXES-ID TO BOX_VALS-VAL LEFT-JUSTIFIED.
    CONCATENATE TEXT-001 BOX_VALS-VAL INTO BOX_VALS-VAL
                                      SEPARATED BY SPACE.
    APPEND BOX_VALS.

*   Nodes
    ACT_NODE_ID = ACT_NODE_ID + 1.

    NODES-ID         = ACT_NODE_ID.
    NODES-CHART_ID   = CHART.
    APPEND NODES.

    POSITIONS-OBJ_ID     = NODES-ID.
    POSITIONS-OBJ_TYPE   = BC_CONST-NODE_OBJECT.
    POSITIONS-CHART_ID   = NODES-CHART_ID.
    POSITIONS-ROW_NUMBER = ROW.
    APPEND POSITIONS.

    NODE_VALS-ID       = NODES-ID.
    NODE_VALS-CHART_ID = CHART.
    NODE_VALS-FL       = '1'.
    CALL FUNCTION 'BARC_CONVERT_DATE'
         EXPORTING
              DATE   = G_DATES-START
         IMPORTING
              STRING = NODE_VALS-VAL.
    APPEND NODE_VALS.

    NODE_VALS-FL       = '2'.
    CALL FUNCTION 'BARC_CONVERT_DATE'
         EXPORTING
              DATE   = G_DATES-END
         IMPORTING
              STRING = NODE_VALS-VAL.
    APPEND NODE_VALS.

    NODE_VALS-FL  = BC_CONST-ADD_LAYER.
    NODE_VALS-VAL = '00'.
    APPEND NODE_VALS.

    G_DATES-NODE_ID = ACT_NODE_ID.
    MODIFY G_DATES.

  ENDLOOP.

ENDFORM.                               " CREATE_PLANTAFEL_OBJECTS


*---------------------------------------------------------------------*
*       FORM PLANTAFEL                                                *
*---------------------------------------------------------------------*
FORM PLANTAFEL.

  IF FLG_PLANTAFEL IS INITIAL.         "falls erster Aufruf
    FLG_PLANTAFEL = 'x'.
    CLEAR: ABAP_CMD, STAT.
  ELSE.
    STAT = SGRC_CONST-STAT_4.          "Wait for input
    IF ABAP_CMD <BC_CONST> Demoprog.: gegenseitiges Aktualisieren von Grafik und Dynpro
* 100 --> Демонстр. программа: обоюдная актуализация графики и экрана

*Text elements
*----------------------------------------------------------
* 001 Horizontal bars

****************************************************************
* This file was generated by Direct Download Enterprise. *
* Please do not change it manually. *
****************************************************************
%_DYNPRO
BARCBO04
0900
620
40
%_HEADER
BARCBO04 0900 0900 8 22192 0 0 0 21 83 0G D 19970305154532
%_DESCRIPTION
Deadlines
%_FIELDS
TCTRL_DATES 22 E0 C4 00 00 00 1 2 E 101 1 0 8 T 0 0 101
TERMINE CHAR 7 00 00 00 30 40 1 0 T 101 1 1 7 0 0 Dates
START CHAR 5 00 00 00 30 80 1 1 T 101 1 1 10 0 0 Start
END CHAR 5 00 00 00 30 80 1 2 T 101 1 1 10 0 0 End
G_DATES-START DATS 10 80 00 80 40 00 1 1 T 101 1 1 10 0 0 __________
G_DATES-END DATS 10 80 00 80 40 00 1 2 T 101 1 1 10 0 0 __________
CHAR 4 80 10 00 00 00 255 5 O 0 0 0 0 0 0 ____
%_FLOWLOGIC
PROCESS BEFORE OUTPUT.
MODULE STATUS_0900.
LOOP AT G_DATES WITH CONTROL TCTRL_DATES
CURSOR ENTRY_ACT.
ENDLOOP.
*
PROCESS AFTER INPUT.
LOOP AT G_DATES.
FIELD G_DATES-START MODULE MODIFY_TAB_900 ON CHAIN-REQUEST.
FIELD G_DATES-END MODULE MODIFY_TAB_900 ON CHAIN-REQUEST.
ENDLOOP.
MODULE USER_COMMAND_0900.
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.