12B - A Reporting Framework for Plex and 2E

18
3rd Annual Plex/2E Worldwide Users Conference 12B - A Reporting Framework for Plex and 2E Mark Murphy STAR Base Consulting, Inc.

description

12B - A Reporting Framework for Plex and 2E. Mark Murphy STAR Base Consulting, Inc. Bio. Mark Murphy STAR BASE Consulting, Inc. Cincinnati, OH Started with AS/400 and 2E in 1989 Using Plex since 1997 - PowerPoint PPT Presentation

Transcript of 12B - A Reporting Framework for Plex and 2E

Page 1: 12B - A Reporting Framework for Plex and 2E

3rd Annual Plex/2E Worldwide Users

Conference

12B - A Reporting Framework for Plex and 2E

Mark Murphy

STAR Base Consulting, Inc.

Page 2: 12B - A Reporting Framework for Plex and 2E

2

Bio

> Mark Murphy

> STAR BASE Consulting, Inc.

> Cincinnati, OH

> Started with AS/400 and 2E in 1989

> Using Plex since 1997

> Experience in Warehousing, Distribution, Retail, Manufacturing and Business Services markets

Page 3: 12B - A Reporting Framework for Plex and 2E

3

Overview

Scenario: Your company has several locations across the US, and all your sales history is stored in a single file. Corporate wants to be able to generate sales reports with the ability to select the effective dates, sort order, and summary level.

The Good News: You can do this easily in Plex or 2E, and the performance can even be good.

The Approach: By extracting the data to be reported on into a temporary file, and then printing the report from there you can simplify your code, and improve your performance.

Page 4: 12B - A Reporting Framework for Plex and 2E

4

Overview (continued)

Start

Running in Batch

Display Prompt

Prompt Successful

End

Build Temporary

Files

Extract Data

Print Report

Submit Report to

Batch

No

Yes

No

Yes

Page 5: 12B - A Reporting Framework for Plex and 2E

5

The Components

> A Work File

> A Data Queue

> Four Programs A Control Program

A Prompt Program

An Extract Program

A Report Program

Page 6: 12B - A Reporting Framework for Plex and 2E

6

The Work File

> Known By 5-10 text fields named Key 1, Key 2, … , Key n

> Refers to the file being reported on (e.g. Sales History)

> Needs only standard views to allow sorting report in any order requested

Page 7: 12B - A Reporting Framework for Plex and 2E

7

The Data Queue

> Used to communicate from the interactive job to the batch job

> Keyed data queue used to allow multiple jobs to use it simultaneously

> Helps me deal with long parameter strings

CRTDTAQ DTAQ(PARMDQ) MAXLEN(128) FORCE(*YES) SEQ(*KEYED) KEYLEN(12) AUTORCL(*YES) TEXT('Job parameter data queue')

Page 8: 12B - A Reporting Framework for Plex and 2E

8

The Programs

> CL to control the Job – required

> RPG to prompt for parameters – optional

> RPG to extract records – optional

> RPG to print report – required

> The report will run in batch, and the CL is self submitting

Page 9: 12B - A Reporting Framework for Plex and 2E

9

A Quick Refresher

> When you submit a job, a request message is placed on the job queue that is processed by a program selected from the routing table.

> A request message is a plain text string.

> If the command being submitted is a CALL, rather than a custom command, parameters are literals.

> Numbers passed as packed(15 5)

> Everything else treated as a character string that is at least 25 characters long (only 25 characters guaranteed to be cleared)

Page 10: 12B - A Reporting Framework for Plex and 2E

10

The Job Control Program

RTVJOBA TYPE(&INTER) NBR(&JOBN)

RTVSYSVAL SYSVAL(QTIME) RTNVAR(&TIME)

/* Interactive portion of program */

IF COND(&INTER *EQ '1') THEN(DO)

/* *** Insert call to Prompt program */

IF COND(&RTNCDE *EQ ' ') THEN(DO)

/* Load long parameter in data queue */

CHGVAR VAR(&KEY) VALUE(&JOBN || &TIME)

CHGVAR VAR(&PKEY) VALUE('P' || %SST(&KEY 2 11))

CALL PGM(QSNDDTAQ) PARM(PARMDQ *LIBL &PARMLEN &PARM &KEYLEN &PKEY)

Page 11: 12B - A Reporting Framework for Plex and 2E

11

Job Control Program

/* Submit the report */

SBMJOB CMD(CALL PGM(******) PARM(&KEY))

MSGLOOP:

RCVMSG MSGTYPE(*COMP) RMV(*NO) MSGDTA(&MSGDTA) MSGDTALEN(&MSGDTALEN) + MSGID(&MSGID) MSGF(&MSGF) MSGFLIB(&MSGFLIB)

IF COND(&MSGID *EQ ' ') THEN(GOTO CMDLBL(DONE))

IF COND(&MSGID *EQ CPC1221) THEN(DO)

SNDPGMMSG MSGID(&MSGID) MSGF(&MSGFLIB/&MSGF) MSGDTA(%SST(&MSGDTA 1 &MSGDTALEN))

ENDDO /* Message Received */

GOTO CMDLBL(MSGLOOP)

DONE:

ENDDO /* Prompt Return Code = *BLANK */

/* Send message if report cancelled by user */

ELSE CMD(DO) /* Report cancelled by user */

SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('Report cancelled by user')

ENDDO /* Report cancelled by user */

Page 12: 12B - A Reporting Framework for Plex and 2E

12

The Job Control Program

/* End of interactive section */

GOTO CMDLBL(OUT)

ENDDO

/* Batch portion of program */

/* Get long parameter from data queue */

CHGVAR VAR(&PKEY) VALUE('P' || %SST(&KEY 2 11))

CALL PGM(QRCVDTAQ) PARM(PARMDQ *LIBL &PARMLEN &PARM &WAIT EQ &KEYLEN &PKEY &SNDRLEN &SENDER)

/* Build Temporary files in QTEMP */

/* *** Insert call to Extract program */

/* *** Insert call to Print program */

OUT:

ENDPGM

Page 13: 12B - A Reporting Framework for Plex and 2E

13

Prompt Program

> This program is a UI function with no database IO function

> 2E: Prompt Record

> Plex OBASE: Process instance UI

> Plex Patterns: UIBASIC\Input

Page 14: 12B - A Reporting Framework for Plex and 2E

14

Extract Program

> A fairly simple program scoped against an appropriate view to make the extract easy

> 2E: Retrieve object wrapped in an Execute external function

> Plex OBASE: Process some instances

> Plex Patterns: ProcessGroup

> Writes records to be printed to the Work File

Page 15: 12B - A Reporting Framework for Plex and 2E

15

Print Program

> Built over Work File

> Approach Read record from the Work file Chain out to get any other data necessary (Work file only has

keys) Print record

> 2E: Print file

> Plex OBASE: Custom Template based on Print Key Break Report

> Plex Patterns: Same as OBASE (no report pattern in this library)

Page 16: 12B - A Reporting Framework for Plex and 2E

16

The Report Pattern - Plex

> Report patterns exist only in OBASE

> I prefer Business Entity.Standard functions.Print key break report

> BUT, headings do not print properly on page breaks

> Create an unscoped copy of the function

> Add an extra edit point in the Process overflow subroutine

> If you use the Patterns library instead of OBASE

Include OBASE in your model and then make the copy

Create a copy from scratch

Page 17: 12B - A Reporting Framework for Plex and 2E

17

Resources

E-mail: [email protected]

Phone: (513) 245-0400

The Edge: edgeusergroup.pugmarks.net

Plex Wiki: wiki.plexinfo.net

2E Wiki: wiki.2einfo.net

Page 18: 12B - A Reporting Framework for Plex and 2E

18

Synopsis

SQL support for iSeries development in Plex, and for that matter 2E is limited at best, and designing reports that perform acceptably can be a daunting task when the requirements are complex.  This framework provides a way to easily develop high performance reports for your iSeries without the need for creating a lot of extra access paths to support your reports.