02
Sat, Nov
2 New Articles

Creating Presentation Graphics with GDDM

Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

Bar graphs, pie charts and other business graphics are at your fingertips with standard OS/400 facilities.

Brief: The Graphical Data Display Manager (GDDM) is a standard part of OS/400. If you have the correct device (either a terminal or a printer that can support graphics), GDDM can produce a wide variety of charts and graphics. In this article, we get you started with GDDM basics and a command you can use to create simple bar graphs from data entered as parameters. Although many people may not realize it, the AS/400 has always had the capability of producing graphic images. This capability is provided at no extra cost. No matter which version of OS/400 you are running, you already have the Graphical Data Display Manager (GDDM) built right into the operating system.

You may have heard of a similar product called Business Graphics Utility (BGU). If so, you're probably wondering what the differences are between BGU and GDDM. Well, the main difference is that BGU is a menu-driven software package that lets you interactively design and create business graphics. GDDM, on the other hand, is a series of routines which you call from within an application program.

If you think BGU sounds easier to use, you're probably right. However, you should be aware that you have to purchase BGU separately, whereas GDDM is included free of charge when you purchase OS/400. My guess, however, is that few people take advantage of it. Hopefully, after reading this article and trying the accompanying Create Bar Chart (CRTBARCHT) utility, you will be inspired to take advantage of this powerful feature.

GDDM consists of a set of routines which you call from within an application program. These routines perform a wide variety of graphical tasks. Basic graphics routines are provided, such as those which draw lines and fill areas, as well as much more powerful routines which create presentation graphics. These presentation graphics routines provide you with an easy way to convert numerical data into bar charts, histograms, pie charts, line graphs, scatter plots, surface charts and Venn diagrams. It is these presentation graphics routines that this article focuses on.

Although all AS/400s have the capability of producing graphics, only certain display and printer devices can produce graphic image output. Valid displays are the IBM 5292 model 2 or a PC using the Workstation Function of PC Support configured as graphics capable. To print, you would need one of the following printers:

IBM 4214 Printer IBM 4234 Printer IBM 5224 Printer IBM 5225 Printer

You can also use one of the following printers as long as it is defined as an intelligent printer data stream (IPDS) device (i.e., the device description's TYPE parameter is equal to *IPDS):

IBM 3812 Printer IBM 3816 Printer IBM 4028 Printer IBM 4224 Printer

Even if your printer isn't an IBM product, it may still work-as long as the device description for the printer is defined as one of the printers mentioned above. When you attempt to print the results, you may receive error message CPA3388, "Attributes of file not supported for device." This indicates that either the device description for your printer is defined incorrectly or your printer is not one of those supported by GDDM. If you attempt to display the results to a workstation that doesn't support graphics, you will receive message CPC8601, "Graphics messages signalled during processing."

The Command

The CRTBARCHT utility (1) serves two purposes. First of all, CRTBARCHT serves as an example of the kinds of things GDDM can accomplish. Secondly, it gives you a useful (although somewhat limited) utility that you can start using right away to produce bar charts on your AS/400. Let's take a look.

The CRTBARCHT utility (Figure 1) serves two purposes. First of all, CRTBARCHT serves as an example of the kinds of things GDDM can accomplish. Secondly, it gives you a useful (although somewhat limited) utility that you can start using right away to produce bar charts on your AS/400. Let's take a look.

CRTBARCHT prints a bar chart with up to 12 bars. You supply the labels and values for the bars, the device type of the printer and the heading for the chart. Let's say, for example, that you entered the command shown in 2.

CRTBARCHT prints a bar chart with up to 12 bars. You supply the labels and values for the bars, the device type of the printer and the heading for the chart. Let's say, for example, that you entered the command shown in Figure 2.

When the output of this command is sent to a 4234 printer, you obtain the graph depicted in 3.

When the output of this command is sent to a 4234 printer, you obtain the graph depicted in Figure 3.

Using this utility as an example, you may want to experiment with some of the many other GDDM routines which are available. This particular utility happens to use 11 different GDDM routines. However, there are more than 150 routines from which to choose. When you add to this the fact that many of these routines have multiple options, the number of ways you can combine these routines becomes practically limitless.

Let's take a close look at how this utility works. First of all, the CRTBARCHT command prompts for up to four parameters: BAR, HEADING, OUTDEV and DEVTYPE. The BAR parameter allows a maximum of 12 elements containing two parts-label and value. Each label can contain up to eight characters of text to identify the bar. The value, which can be a number up to 99,999,999, represents the height of the bar. The next parameter, HEADING, consists of up to 50 characters of text to appear at the top of the chart.

The output device parameter allows you to send the output to the display ('*') or to the requesting job's printer (*PRINT). If the output device is *PRINT, the DEVTYPE parameter must be one of the following values: 4214, 4234, 5224, 5225 or IPDS. To determine the correct value, use the Display Device Description (DSPDEVD) command on the printer you want to print the graph on and note the device type.

The CL program BAR001CL (4) calculates how many bars were requested and converts the embedded list into two fields-one for the labels and the other for the values.

The CL program BAR001CL (Figure 4) calculates how many bars were requested and converts the embedded list into two fields-one for the labels and the other for the values.

The RPG program BAR001RG (5) starts out by moving the two fields LABELS and VALUES into arrays. The program then begins calling the GDDM routines. The following is a list of the GDDM routines which are called and a brief explanation of what each one does. For more detailed information, refer to the GDDM Programming Reference (SC33-0537).

The RPG program BAR001RG (Figure 5) starts out by moving the two fields LABELS and VALUES into arrays. The program then begins calling the GDDM routines. The following is a list of the GDDM routines which are called and a brief explanation of what each one does. For more detailed information, refer to the GDDM Programming Reference (SC33-0537).

FSINIT-Initializes graphics processing. This routine must be called before any other GDDM routines.

DSOPEN-Opens the device to be used for graphics. The DEVTYPE parameter from the command is passed into this routine.

DSUSE-Activates the device that has been opened.

CHHEAD-Specifies the chart heading text. The HEADING parameter is passed into this routine.

CHXLAB-Allows the specification of labels. The labels are placed, in sequence, at major scale marks along the X-axis. The label array is passed into this routine.

CHSET-Overrides default chart attributes. For the CRTBARCHT utility, I call this routine three times to set three attributes:

CBAR specifies a composite (stacked) bar chart (colinear bars).

NOLEGEND specifies that a legend is not to be constructed.

VALUES controls the appearance of data values at the ends of bars on bar charts.

The attribute value is passed as the option parameter on each call.

CHPAT-Overrides the default shading pattern value to be used. In this case 15 is chosen for white bars.

CHBAR-Plots one or more bar chart data groups on the currently selected axes.

ASREAD-Performs an output to the display, then unlocks the workstation keyboard and waits for operator acknowledgement (Enter key, Function keys or Clear key).

FSFRCE-Performs all outstanding graphics output.

FSTERM-Terminates graphics processing for the application program and frees all the resources acquired. This routine should always be the last GDDM routine called.

At this point, you may be wondering which routines are required and which ones are optional. Well, let me put it this way. A bare bones GDDM application would need at least six routines, called in this order:

1. FSINIT - Initialize Graphics 2. DSOPEN - Open Device 3. DSUSE - Specify Device Usage (optional routines go here) 4. Choose one of the following:

CHBAR - Bar Charts CHHIST - Histograms CHPIE - Pie Charts CHPLOT - Line Graphs and Scatter Plots CHSURF - Surface Charts CHVENN - Venn Diagrams

5. FSFRCE - Display Outstanding Graphics 6. FSTERM - Terminate Graphics

There are far too many optional routines for me to cover in this article. Refer to the GDDM Programming Reference manual to discover the wealth of graphical functions available through GDDM.

An Important Observation

One final thing I would like to mention is that although this utility includes a command, a CL program and an RPG program, only one RPG program is really necessary to produce a graph. The command and the CL program are provided to make the utility more user friendly.

You can create your own applications, incorporating GDDM routines with a single RPG program. For example, you could read one of your sales history files in an RPG program and load the sales amounts in an array. You could then pass the array directly into one of the appropriate GDDM routines and create a graph all within the same program.

GDDM routines also give you the ability to create an interesting graph from an existing report program. Just add the code which calls the various GDDM routines to produce a graph to the program. When you run this program, you would receive the same report that you got originally; however, it would now be accompanied by a graphed version.

This article gives you one more tool which you can use to view the information you have stored in your database. Whether you use the Create Bar Chart utility or create your own applications using GDDM routines, you now have the ability to turn numbers into graphical images. By experimenting with this technique, you can come up with some exciting new ways to look at your data.

Robin Klima is a senior technical editor at Midrange Computing.


Creating Presentation Graphics with GDDM

Figure 1 CRTBARCHT Command

 /*===================================================================*/ /* To compile: */ /* CRTCMD CMD(XXX/CRTBARCHT) PGM(XXX/BAR001CL) + */ /* SRCFILE(XXX/QCMDSRC) ALLOW(*INTERACT + */ /* *IPGM *IREXX) */ /* */ /*===================================================================*/ CRTBARCHT: CMD PROMPT('Create Bar Chart') PARM KWD(BAR) TYPE(ELEM1) MIN(1) MAX(12) + PROMPT('Bar labels and values') PARM KWD(HEADING) TYPE(*CHAR) LEN(50) + PROMPT('Chart heading') PARM KWD(OUTDEV) TYPE(*CHAR) LEN(6) RSTD(*YES) + DFT(*) VALUES(* *PRINT) PROMPT('Output + device') PARM KWD(DEVTYPE) TYPE(*CHAR) LEN(4) RSTD(*YES) + DFT(4214) VALUES(4214 4234 IPDS) + SPCVAL((5224 522X) (5225 522X)) + PMTCTL(PMTCTL1) PROMPT('Device type') ELEM1: ELEM TYPE(*CHAR) LEN(8) PROMPT('Label') ELEM TYPE(*INT4) RANGE(0 99999999) PROMPT('Value') PMTCTL1: PMTCTL CTL(OUTDEV) COND((*EQ '*PRINT')) 
Creating Presentation Graphics with GDDM

Figure 2 Sample Submission of CRTBARCHT

 CRTBARCHT BAR(('Jan' 181898) ('Feb' 193082) ('Mar' 210365) + ('Apr' 261303) ('May' 269201) ('Jun' 277945) + ('Jul' 366935) ('Aug' 385192) ('Sep' 216270) + ('Oct' 268672) ('Nov' 178373) ('Dec' 147111)) + HEADING('Monthly Sales for 1992') + OUTDEV(*PRINT) DEVTYPE(4234) 
Creating Presentation Graphics with GDDM

Figure 3 Sample Bar Chart Output

 UNABLE TO REPRODUCE GRAPHICS 
Creating Presentation Graphics with GDDM

Figure 4 Command Processing Program BAR001CL

 /*===================================================================*/ /* To compile: */ /* CRTCLPGM PGM(XXX/BAR001CL) SRCFILE(XXX/QCLSRC) */ /* */ /*===================================================================*/ BAR001CL: + PGM PARM(&BAR &HEADING &OUTDEV &DEVTYPE) DCL VAR(&BAR) TYPE(*CHAR) LEN(218) DCL VAR(&DEVTYPE) TYPE(*CHAR) LEN(4) DCL VAR(&HEADING) TYPE(*CHAR) LEN(50) DCL VAR(&CNT) TYPE(*DEC) LEN(5 0) DCL VAR(&CNTR) TYPE(*DEC) LEN(5 0) DCL VAR(&OFFSET) TYPE(*DEC) LEN(5 0) VALUE(1) DCL VAR(&OUTDEV) TYPE(*CHAR) LEN(6) DCL VAR(&DISP) TYPE(*DEC) LEN(5 0) DCL VAR(&SUBSTR) TYPE(*DEC) LEN(5 0) VALUE(1) DCL VAR(&LABEL) TYPE(*CHAR) LEN(8) DCL VAR(&VALUE) TYPE(*DEC) LEN(8 0) DCL VAR(&LABELS) TYPE(*CHAR) LEN(96) DCL VAR(&VALUES) TYPE(*CHAR) LEN(96) + VALUE('000000000000000000000000000000000000000000000000000+ 00000000000000000000000000000000000000000000') /* Get number of entries */ CHGVAR VAR(&CNT) VALUE(%BIN(&BAR 1 2)) /* Process entries */ LOOP: + CHGVAR VAR(&CNTR) VALUE(&CNTR + 1) CHGVAR VAR(&OFFSET) VALUE(&OFFSET + 2) CHGVAR VAR(&DISP) VALUE(%BIN(&BAR &OFFSET 2)) CHGVAR VAR(&DISP) VALUE(&DISP + 3) CHGVAR VAR(&LABEL) VALUE(%SST(&BAR &DISP 8)) CHGVAR VAR(%SST(&LABELS &SUBSTR 8)) VALUE(&LABEL) CHGVAR VAR(&DISP) VALUE(&DISP + 8) CHGVAR VAR(&VALUE) VALUE(%BIN(&BAR &DISP 4)) CHGVAR VAR(%SST(&VALUES &SUBSTR 8)) VALUE(&VALUE) CHGVAR VAR(&SUBSTR) VALUE(&SUBSTR + 8) IF COND(&CNTR *LT &CNT) THEN(GOTO CMDLBL(LOOP)) /* Call program to produce bar chart */ CALL PGM(BAR001RG) PARM(&CNT &LABELS &VALUES + &HEADING &OUTDEV &DEVTYPE) ENDPGM 
Creating Presentation Graphics with GDDM

Figure 5 BAR001RG RPG Program

 *==============================================================* * * * To compile: * * * * CRTRPGPGM PGM(XXX/BAR001RG) SRCFILE(XXX/QRPGSRC) * * * *==============================================================* E LAB 12 8 E VAL 12 8 0 * I DS I B 1 40LINES I B 5 80POINTS I B 9 120COUNT I B 13 160LENGTH I B 17 200DEVID I B 21 240FAMILY I B 25 280PROCNT I B 29 320PROLST I B 33 360NAMCNT I B 37 400USAGE I B 41 440PATRN I B 45 480ATTYPE I B 49 520ATMOD I DS I 1 96 VAL I 1 96 VALS * C *ENTRY PLIST C PARM CNT 50 C PARM LABELS 96 C PARM VALUES 96 C PARM HEADNG 50 C PARM OUTDEV 6 C PARM DEVTYP 4 * C OUTDEV IFEQ '*' C MOVEL'5292M2' TOKEN 8 C ELSE C MOVELDEVTYP TOKEN C ENDIF * Load arrays with labels and values C MOVEALABELS LAB C MOVELVALUES VALS * Initialize graphics C CALL 'GDDM' C PARM 'FSINIT 'GDDM 8 * Open device C CALL 'GDDM' C PARM 'DSOPEN 'GDDM C PARM 1 DEVID C PARM 1 FAMILY C PARM TOKEN C PARM 0 PROCNT C PARM 0 PROLST C PARM 1 NAMCNT C PARM '* 'NAMLST 10 * Use device C CALL 'GDDM' C PARM 'DSUSE 'GDDM C PARM 1 USAGE C PARM 1 DEVID * * Specify heading text C CALL 'GDDM' C PARM 'CHHEAD 'GDDM C PARM 50 LENGTH C PARM HEADNG * * Specify label text C CALL 'GDDM' C PARM 'CHXLAB 'GDDM C PARM CNT COUNT C PARM 8 LENGTH C PARM LAB * * Specify bar chart type C CALL 'GDDM' C PARM 'CHSET 'GDDM C PARM 'CBAR 'OPTION 8 * * Specify no legend option C CALL 'GDDM' C PARM 'CHSET 'GDDM C PARM 'NOLEGEND'OPTION * * Specify values option C CALL 'GDDM' C PARM 'CHSET 'GDDM C PARM 'VALUES 'OPTION * * Specify shading pattern C CALL 'GDDM' C PARM 'CHPAT 'GDDM C PARM 1 COUNT C PARM 15 PATRN * * Plot the bar chart C CALL 'GDDM' C PARM 'CHBAR 'GDDM C PARM 1 LINES C PARM CNT POINTS C PARM VAL * * If output is display, perform output/input C OUTDEV IFEQ '*' C CALL 'GDDM' C PARM 'ASREAD 'GDDM C PARM ATTYPE C PARM ATMOD C PARM COUNT C ELSE * * If output is print, perform output C CALL 'GDDM' C PARM 'FSFRCE 'GDDM C ENDIF * * Terminate graphics processing C CALL 'GDDM' C PARM 'FSTERM 'GDDM * C SETON LR 
BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

Book Reviews

Resource Center

  • SB Profound WC 5536 Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application. You can find Part 1 here. In Part 2 of our free Node.js Webinar Series, Brian May teaches you the different tooling options available for writing code, debugging, and using Git for version control. Brian will briefly discuss the different tools available, and demonstrate his preferred setup for Node development on IBM i or any platform. Attend this webinar to learn:

  • SB Profound WP 5539More than ever, there is a demand for IT to deliver innovation. Your IBM i has been an essential part of your business operations for years. However, your organization may struggle to maintain the current system and implement new projects. The thousands of customers we've worked with and surveyed state that expectations regarding the digital footprint and vision of the company are not aligned with the current IT environment.

  • SB HelpSystems ROBOT Generic IBM announced the E1080 servers using the latest Power10 processor in September 2021. The most powerful processor from IBM to date, Power10 is designed to handle the demands of doing business in today’s high-tech atmosphere, including running cloud applications, supporting big data, and managing AI workloads. But what does Power10 mean for your data center? In this recorded webinar, IBMers Dan Sundt and Dylan Boday join IBM Power Champion Tom Huntington for a discussion on why Power10 technology is the right strategic investment if you run IBM i, AIX, or Linux. In this action-packed hour, Tom will share trends from the IBM i and AIX user communities while Dan and Dylan dive into the tech specs for key hardware, including:

  • Magic MarkTRY the one package that solves all your document design and printing challenges on all your platforms. Produce bar code labels, electronic forms, ad hoc reports, and RFID tags – without programming! MarkMagic is the only document design and print solution that combines report writing, WYSIWYG label and forms design, and conditional printing in one integrated product. Make sure your data survives when catastrophe hits. Request your trial now!  Request Now.

  • SB HelpSystems ROBOT GenericForms of ransomware has been around for over 30 years, and with more and more organizations suffering attacks each year, it continues to endure. What has made ransomware such a durable threat and what is the best way to combat it? In order to prevent ransomware, organizations must first understand how it works.

  • SB HelpSystems ROBOT GenericIT security is a top priority for businesses around the world, but most IBM i pros don’t know where to begin—and most cybersecurity experts don’t know IBM i. In this session, Robin Tatam explores the business impact of lax IBM i security, the top vulnerabilities putting IBM i at risk, and the steps you can take to protect your organization. If you’re looking to avoid unexpected downtime or corrupted data, you don’t want to miss this session.

  • SB HelpSystems ROBOT GenericCan you trust all of your users all of the time? A typical end user receives 16 malicious emails each month, but only 17 percent of these phishing campaigns are reported to IT. Once an attack is underway, most organizations won’t discover the breach until six months later. A staggering amount of damage can occur in that time. Despite these risks, 93 percent of organizations are leaving their IBM i systems vulnerable to cybercrime. In this on-demand webinar, IBM i security experts Robin Tatam and Sandi Moore will reveal:

  • FORTRA Disaster protection is vital to every business. Yet, it often consists of patched together procedures that are prone to error. From automatic backups to data encryption to media management, Robot automates the routine (yet often complex) tasks of iSeries backup and recovery, saving you time and money and making the process safer and more reliable. Automate your backups with the Robot Backup and Recovery Solution. Key features include:

  • FORTRAManaging messages on your IBM i can be more than a full-time job if you have to do it manually. Messages need a response and resources must be monitored—often over multiple systems and across platforms. How can you be sure you won’t miss important system events? Automate your message center with the Robot Message Management Solution. Key features include:

  • FORTRAThe thought of printing, distributing, and storing iSeries reports manually may reduce you to tears. Paper and labor costs associated with report generation can spiral out of control. Mountains of paper threaten to swamp your files. Robot automates report bursting, distribution, bundling, and archiving, and offers secure, selective online report viewing. Manage your reports with the Robot Report Management Solution. Key features include:

  • FORTRAFor over 30 years, Robot has been a leader in systems management for IBM i. With batch job creation and scheduling at its core, the Robot Job Scheduling Solution reduces the opportunity for human error and helps you maintain service levels, automating even the biggest, most complex runbooks. Manage your job schedule with the Robot Job Scheduling Solution. Key features include:

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • LANSAWhen it comes to creating your business applications, there are hundreds of coding platforms and programming languages to choose from. These options range from very complex traditional programming languages to Low-Code platforms where sometimes no traditional coding experience is needed. Download our whitepaper, The Power of Writing Code in a Low-Code Solution, and:

  • LANSASupply Chain is becoming increasingly complex and unpredictable. From raw materials for manufacturing to food supply chains, the journey from source to production to delivery to consumers is marred with inefficiencies, manual processes, shortages, recalls, counterfeits, and scandals. In this webinar, we discuss how:

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • Profound Logic Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application.

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: