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: Bar Chart in Display Mode



 
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:10 pm    Post subject: Demo: Bar Chart in Display Mode Reply with quote

Code:
REPORT BARCBO01.

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

DATA: CHART   LIKE BCCHART-ID,
      SECTION LIKE BCSECTION-ID,
      VAL     LIKE BCVALS-VAL.

PARAMETER: GRUPPE    LIKE TBCGT-PRF_GRUPPE  DEFAULT 'DEMO',
           NAME      LIKE TBCGT-PRF_NAME    DEFAULT '000000000001',
           INDEX     LIKE TBCGT-PRF_INDEX   DEFAULT '1'.

* Grafikprofil aufbauen
GRAPH_PROFILE-PRF_GRUPPE = GRUPPE.
GRAPH_PROFILE-PRF_NAME   = NAME.
GRAPH_PROFILE-PRF_INDEX  = INDEX.

* Start und Ende der Zeitachse festlegen
CALL FUNCTION 'BARC_SET_TIME_AXIS'
     EXPORTING
          START = '01.01.1994;'
          END   = '31.12.1994;'.

* Diagramm 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         = 1.
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.               "Boxen
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 erzuegen
CALL FUNCTION 'BARC_ADD_SECTION'
     EXPORTING
          SIZE  = 100
          START = '01.01.1994;'
          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

* Setzen der Boxen (Tabellenteil)
PERFORM SET_BOXES TABLES BOXES
                         BOX_VALS
                         POSITIONS
                  USING  CHART.

* Setzen der Nodes (Diagrammteil), Daten der Balken
PERFORM SET_NODES TABLES NODES
                         NODE_VALS
                         POSITIONS
                  USING  CHART.

STAT = SGRC_CONST-STAT_1.  "Open Window, Transfer Data, Wait for Input

DO.
* Daten fьr Balkenplangrafik aufbereiten
  CALL FUNCTION 'BARC_GRAPHIC_PBO'
       EXPORTING
            CONFIRM   = SPACE
            PROFILE   = GRAPH_PROFILE
            STAT      = STAT
       TABLES
            BOXES     = BOXES
            BOX_VALS  = BOX_VALS
            DELETIONS = DELETIONS
            LINKS     = LINKS
            LINK_VALS = LINK_VALS
            NODES     = NODES
            NODE_VALS = NODE_VALS
            POSITIONS = POSITIONS.

* Daten an Grafik ьbergeben
  CALL FUNCTION 'GRAPH_RECEIVE'
       IMPORTING
            MCODE             = M_TYP
       EXCEPTIONS
            INV_COMMUNICATION = 1
            NO_BATCH          = 2.

  IF NOT SY-SUBRC IS INITIAL.
    EXIT.
  ENDIF.

  CASE M_TYP.
    WHEN SGRC_CONST-M_TYP_D.
      EXIT.
    WHEN SGRC_CONST-M_TYP_I.
*     Auswertung der Daten von der Grafik (fьr Drucken)
      CALL FUNCTION 'BARC_GRAPHIC_PAI'
           IMPORTING
                GRAPH_CMD = GRAPH_CMD
           TABLES
                BOXES     = BOXES
                BOX_VALS  = BOX_VALS
                DELETIONS = DELETIONS
                NODES     = NODES
                NODE_VALS = NODE_VALS
                POSITIONS = POSITIONS
                LINKS     = LINKS
                LINK_VALS = LINK_VALS
           EXCEPTIONS
                INV_WINID = 1.

      ABAP_CMD = GRAPH_CMD.
      STAT = SGRC_CONST-STAT_4.    "Wait for input
  ENDCASE.
ENDDO.


*---------------------------------------------------------------------*
*       FORM MAKE_BOX                                                 *
*---------------------------------------------------------------------*
*       Erzeugen einer Box                                            *
*---------------------------------------------------------------------*
FORM MAKE_BOX TABLES BOXES STRUCTURE BCBOXES
                     BOX_VALS STRUCTURE BCVALS
                     POSITIONS STRUCTURE BCPOSITION
              USING  CHART LIKE BCCHART-ID
                     ID TYPE I
                     FORMAT
                     COLOR
                     TEXT
                     ROW TYPE I.

  BOXES-ID         = ID.
  BOXES-TYPE       = BC_CONST-ROW_BOX.
  BOXES-CHART_ID   = CHART.
  BOXES-FORM_TYPE  = FORMAT.
  BOXES-COLOR_TYPE = COLOR.
  APPEND BOXES.

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

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

ENDFORM.                               "MAKE_BOX


*---------------------------------------------------------------------*
*       FORM SET_BOXES                                                *
*---------------------------------------------------------------------*
*       Erzeugen der Boxen fьr den Tabellenteil der Grafik            *
*---------------------------------------------------------------------*
FORM SET_BOXES TABLES BOXES STRUCTURE BCBOXES
                      BOX_VALS STRUCTURE BCVALS
                      POSITIONS STRUCTURE BCPOSITION
               USING  CHART LIKE BCCHART-ID.

  PERFORM MAKE_BOX TABLES BOXES BOX_VALS POSITIONS
                   USING  CHART 2 'B1' 'B1' TEXT-002 1.

  PERFORM MAKE_BOX TABLES BOXES BOX_VALS POSITIONS
                   USING  CHART 3 'B1' 'B1' TEXT-003 2.

  PERFORM MAKE_BOX TABLES BOXES BOX_VALS POSITIONS
                   USING  CHART 4 'B1' 'B1' TEXT-004 3.

  PERFORM MAKE_BOX TABLES BOXES BOX_VALS POSITIONS
                   USING  CHART 5 'B1' 'B1' TEXT-005 4.

  PERFORM MAKE_BOX TABLES BOXES BOX_VALS POSITIONS
                   USING  CHART 6 'B1' 'B1' TEXT-006 5.

ENDFORM.                               "SET_BOXES


*---------------------------------------------------------------------*
*       FORM SET_NODES                                                *
*---------------------------------------------------------------------*
*       Erzeugen der Knoten, Setzen der Layer                         *
*---------------------------------------------------------------------*
FORM SET_NODES TABLES NODES STRUCTURE BCNODES
                      NODE_VALS STRUCTURE BCNVALS
                      POSITIONS STRUCTURE BCPOSITION
               USING  CHART LIKE BCCHART-ID.

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

  NODE_VALS-ID       = NODES-ID.
  NODE_VALS-CHART_ID = NODES-CHART_ID.
  NODE_VALS-FL       = '1'.
  NODE_VALS-VAL      = '12.01.1994;'.
  APPEND NODE_VALS.

  NODE_VALS-FL       = '2'.
  NODE_VALS-VAL      = '27.06.1994;'.
  APPEND NODE_VALS.

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

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

*----------------------------------------------------------------------*
  NODES-ID         = 2.
  NODES-CHART_ID   = CHART.
  APPEND NODES.

  NODE_VALS-ID       = NODES-ID.
  NODE_VALS-CHART_ID = NODES-CHART_ID.
  NODE_VALS-FL       = '1'.
  NODE_VALS-VAL      = '02.02.1994;'.
  APPEND NODE_VALS.

  NODE_VALS-FL       = '2'.
  NODE_VALS-VAL      = '25.07.1994;'.
  APPEND NODE_VALS.

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

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

*----------------------------------------------------------------------*
  NODES-ID         = 3.
  NODES-CHART_ID   = CHART.
  APPEND NODES.

  NODE_VALS-ID       = NODES-ID.
  NODE_VALS-CHART_ID = NODES-CHART_ID.
  NODE_VALS-FL       = '1'.
  NODE_VALS-VAL      = '01.04.1994;'.
  APPEND NODE_VALS.

  NODE_VALS-FL       = '2'.
  NODE_VALS-VAL      = '25.09.1994;'.
  APPEND NODE_VALS.

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

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

*----------------------------------------------------------------------*
  NODES-ID         = 4.
  NODES-CHART_ID   = CHART.
  APPEND NODES.

  NODE_VALS-ID       = NODES-ID.
  NODE_VALS-CHART_ID = NODES-CHART_ID.
  NODE_VALS-FL       = '1'.
  NODE_VALS-VAL      = '11.02.1994;'.
  APPEND NODE_VALS.

  NODE_VALS-FL       = '2'.
  NODE_VALS-VAL      = '11.07.1994;'.
  APPEND NODE_VALS.

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

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

*----------------------------------------------------------------------*
  NODES-ID         = 5.
  NODES-CHART_ID   = CHART.
  APPEND NODES.

  NODE_VALS-ID       = NODES-ID.
  NODE_VALS-CHART_ID = NODES-CHART_ID.
  NODE_VALS-FL       = '1'.
  NODE_VALS-VAL      = '01.05.1994;'.
  APPEND NODE_VALS.

  NODE_VALS-FL       = '2'.
  NODE_VALS-VAL      = '11.12.1994;'.
  APPEND NODE_VALS.

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

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

ENDFORM.                               "SET_NODES

*Text elements
*----------------------------------------------------------
* 001 Boxes
* 002 Box number 1
* 003 Box number 2
* 004 Box number 3
* 005 Box number 4
* 006 Box number 5


*Selection texts
*----------------------------------------------------------
* GRUPPE         Graphic profile group
* INDEX         Graphic profile index
* NAME         Graphic profile name
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.