what you can do with rpg? uno.ekberg@volvo
DESCRIPTION
What you can do with RPG? [email protected]. Who am I?. Started with IT 1969, at Volvo since 1980 Worked with Mainframes, spefically IMS until 1988 With AS400/iSeries/System i since 1989 Software Architect at Volvo IT Problem solver, consultant, the ”fixer” on System i. AB Volvo. - PowerPoint PPT PresentationTRANSCRIPT
![Page 2: What you can do with RPG? uno.ekberg@volvo](https://reader036.vdocuments.site/reader036/viewer/2022062309/5681599e550346895dc6e928/html5/thumbnails/2.jpg)
2
Volvo IT
2009Dep 4365, Uno Ekberg
Who am I?
Started with IT 1969, at Volvo since 1980
Worked with Mainframes, spefically IMS until 1988
With AS400/iSeries/System i since 1989
Software Architect at Volvo IT
Problem solver, consultant, the ”fixer” on System i
![Page 3: What you can do with RPG? uno.ekberg@volvo](https://reader036.vdocuments.site/reader036/viewer/2022062309/5681599e550346895dc6e928/html5/thumbnails/3.jpg)
3
Volvo IT
2009Dep 4365, Uno Ekberg
The Volvo Group
MackTrucks
RenaultTrucks
VolvoTrucks
Volvo Aero
FinancialServices
AB VolvoBusiness Areas
Business Units
Volvo Powertrain
Volvo Parts
Volvo Logistics
Volvo Information Technology
Volvo 3P
Nissan Diesel
VolvoPenta
ConstructionEquipment
Buses
![Page 4: What you can do with RPG? uno.ekberg@volvo](https://reader036.vdocuments.site/reader036/viewer/2022062309/5681599e550346895dc6e928/html5/thumbnails/4.jpg)
4
Volvo IT
2009Dep 4365, Uno Ekberg
Our company history
1967 Established as Volvo Data
1972 First large Data Centre building set up in Gothenburg
1991 Volvo Data gets responsibility for data centres in Greensboro and Ghent
1992-93 Offices established in the UK and Belgium
1993 Office established in the US
1996-97 Study on the future of IT at the Volvo Group – result is that IT resources stay at the Volvo Group
1998 Formation of Volvo Information Technology
1999 Volvo Car Corporation acquired by Ford Motor Co.
2001 Renault V.I./Mack Trucks integration
2004-08 Offices established in India, China, Korea, South Africa, Australia, Mexico, Turkey, Thailand, Russia, Japan, Canada and Singapore
2007-08 Volvo IT incorporated Fortos Management Consulting and WirelessCar
![Page 5: What you can do with RPG? uno.ekberg@volvo](https://reader036.vdocuments.site/reader036/viewer/2022062309/5681599e550346895dc6e928/html5/thumbnails/5.jpg)
5
Volvo IT
2009Dep 4365, Uno Ekberg
Volvo IT – Global Presence
France
Sweden
Poland Belgium
United Kingdom
USA
Malaysia
Australia
Brazil
India
ChinaKorea
South Africa
Offshore centres
Mexico
Turkey
Russia
Thailand
Canada
Japan
Singapore
![Page 6: What you can do with RPG? uno.ekberg@volvo](https://reader036.vdocuments.site/reader036/viewer/2022062309/5681599e550346895dc6e928/html5/thumbnails/6.jpg)
6
Volvo IT
2009Dep 4365, Uno Ekberg
Volvo IT customers
The Volvo Group
Volvo Cars
![Page 7: What you can do with RPG? uno.ekberg@volvo](https://reader036.vdocuments.site/reader036/viewer/2022062309/5681599e550346895dc6e928/html5/thumbnails/7.jpg)
7
Volvo IT
2009Dep 4365, Uno Ekberg
Agenda
Dynamic use of files
How can I work with unknown number of files in a program?
API instead of commands
Dynamicly invoke other programs
Acknowledgement
![Page 8: What you can do with RPG? uno.ekberg@volvo](https://reader036.vdocuments.site/reader036/viewer/2022062309/5681599e550346895dc6e928/html5/thumbnails/8.jpg)
8
Volvo IT
2009Dep 4365, Uno Ekberg
If you need a simple file with mostly just text, like a temporary error log
MyPgmCodeIf %error;
tell someone
someway
about thist error
Create file
Open
Write msg
![Page 9: What you can do with RPG? uno.ekberg@volvo](https://reader036.vdocuments.site/reader036/viewer/2022062309/5681599e550346895dc6e928/html5/thumbnails/9.jpg)
9
Volvo IT
2009Dep 4365, Uno Ekberg
Dynamic use of Work files
FWorkfile O A F 61 Disk USROPN
If Not %Open (Workfile) ;
Crtcmd = 'CRTPF FILE(QTEMP/WORKFILE) RCDLEN(61) ';
CallP(E) CmdPgm (Crtcmd : %Len(Crtcmd));
Open Workfile;
Endif;
Write Workfile Wrkrec_DS;
Close Workfile;
Good for logging, error notification etc.
![Page 10: What you can do with RPG? uno.ekberg@volvo](https://reader036.vdocuments.site/reader036/viewer/2022062309/5681599e550346895dc6e928/html5/thumbnails/10.jpg)
10
Volvo IT
2009Dep 4365, Uno Ekberg
Huge amount of Audit Jrn events
We have n number of Receivers, all want just there own part
The problem:How can we avoid to read thru the AuditJrn more than once?
And we have a variable number of intrested apps on each LPAR
![Page 11: What you can do with RPG? uno.ekberg@volvo](https://reader036.vdocuments.site/reader036/viewer/2022062309/5681599e550346895dc6e928/html5/thumbnails/11.jpg)
11
Volvo IT
2009Dep 4365, Uno Ekberg
File IO without an F record We use this to filter out records from the System Audit Journal
We have an unknown number of ”subscribers” for data, based on the user profile in the journal record. Each subscriber have there own result file.By using these techniques, we only need to run thru the System Audit Journal once for the time period.
We use C Library functions _Ropen, _RWrite and _Rclose.
H BndDir( 'QC2LE' )
D RIOFB Ds Based( pRIOFB )
D pKey *
D pSysParm *
D IoRcdRrn 10u 0
D IoNbrBytRw 10i 0
D IoBlkCnt 5i 0
D IoBlkFllBy 1a
D IoBitFld 1a
D IoRsv 20a
![Page 12: What you can do with RPG? uno.ekberg@volvo](https://reader036.vdocuments.site/reader036/viewer/2022062309/5681599e550346895dc6e928/html5/thumbnails/12.jpg)
12
Volvo IT
2009Dep 4365, Uno Ekberg
File IO without an F recordProcedure definitions
**-- Open file: ------------------------------------------------------
D Ropen Pr * ExtProc( '_Ropen' )
D pRFile * Value Options( *String )
D pMode * Value Options( *String )
**-- Close file: -----------------------------------------------------
D Rclose Pr 10i 0 ExtProc( '_Rclose' )
D pRFile * Value
**-- Write file ----------------------------------------------------
D Rwrite Pr * ExtProc( '_Rwrite' )
D pRFile * Value
D pBuffer * Value
D BufLength 10u 0 Value
![Page 13: What you can do with RPG? uno.ekberg@volvo](https://reader036.vdocuments.site/reader036/viewer/2022062309/5681599e550346895dc6e928/html5/thumbnails/13.jpg)
13
Volvo IT
2009Dep 4365, Uno Ekberg
File IO without an F recordOpen the files!
Read reqf01;
Dou %eof;
filnptr = %addr(filname1);
%str(filnptr:35) = Jrnfilnm;
pRFILE = *null;
pRFILE = Ropen(Filname1 : 'ar' ) ;
If pRfile = *null;
Errmsg = 'Error on Open' + Jrnfilnm;
Errorrtn(Errmsg);
else;
i = i + 1;
WFilptr(i) = pRfile;
// Get Users to include (not shown here)
Endif; Read reqf01;
Enddo;
![Page 14: What you can do with RPG? uno.ekberg@volvo](https://reader036.vdocuments.site/reader036/viewer/2022062309/5681599e550346895dc6e928/html5/thumbnails/14.jpg)
14
Volvo IT
2009Dep 4365, Uno Ekberg
File IO without an F recordWrite record
// First search for the correct file in a table of User Profiles
lookupappl = %lookup(UsrarrAppl(lookupres) :
Wappl : 1: SizApplarr);
If lookupappl > 0; Found!
PRFILE = Wfilptr(lookupappl); Get the file ptr
pRIOFB = Rwrite( PRFILE - Write record
: %Addr( JrnOutDs )
: %Size( JrnOutDs ));
If IoNbrBytRw = 0; Test result
Errorrtn(WrtError);
Endif;
Endif;
![Page 15: What you can do with RPG? uno.ekberg@volvo](https://reader036.vdocuments.site/reader036/viewer/2022062309/5681599e550346895dc6e928/html5/thumbnails/15.jpg)
15
Volvo IT
2009Dep 4365, Uno Ekberg
File IO without an F recordClose the files
In the end close all the files
For i = 1 by 1 to SizApplarr;
pRfile = WFilptr(i);
Rclose(pRfile);
Endfor;
![Page 16: What you can do with RPG? uno.ekberg@volvo](https://reader036.vdocuments.site/reader036/viewer/2022062309/5681599e550346895dc6e928/html5/thumbnails/16.jpg)
16
Volvo IT
2009Dep 4365, Uno Ekberg
API instead of commandsRetrieve Journal Entries
Retrieve Journal Entries (QjoRetrieveJournalEntries) APIPerformance can be enhanced if you give a higher value in the Key 6, number of variable length Records. Carsten Flensburg used 1000, but I found in our environment that at least 3000 gave a lot better performance.
If you want to get all records, make sure your selection are not fullfilled until all records are returned! If the continuation indicator is 0, it means you are done! So change search criteria before next call to the API!By using the API performance can be improved a lot.
![Page 17: What you can do with RPG? uno.ekberg@volvo](https://reader036.vdocuments.site/reader036/viewer/2022062309/5681599e550346895dc6e928/html5/thumbnails/17.jpg)
17
Volvo IT
2009Dep 4365, Uno Ekberg
QjoRetrieveJournalEntries
D RcvVar Ds Align Based(prcvvar)D RtvJrnE Pr ExtProc( 'QjoRetrieveJournalEntries’)
pRcvVar = %alloc(sizeAlloc); //Get enough bytes! DoU JhConInd = '0' Or ErrBytAvl > *Zero; RtvJrnE( JeRcvVar : %Size( RcvVar ) : JrnObject : 'RJNE0200' : JrnEntRtv + JrnVarR01 + JrnVarR02 + JrnVarR06 + JrnVarR07 + JrnVarR08 : ApiError ); // Process the records retrieved in a loop! If JhConInd = '1'; JvR01RcvStr = JhConRcvStr; JvR01LibStr = JhConLibStr; JvR02SeqNbr = JhConSeqNbr; Endif; Enddo;
![Page 18: What you can do with RPG? uno.ekberg@volvo](https://reader036.vdocuments.site/reader036/viewer/2022062309/5681599e550346895dc6e928/html5/thumbnails/18.jpg)
18
Volvo IT
2009Dep 4365, Uno Ekberg
API instead of CommandsQUSLOBJ and QWCCVTDT
Quslobj – List Object description Can be used to find all objects of a certain type, where the change date are between certain dates.
%SUBST(WOBJ:1:10) = Obj; %SUBST(WOBJ:11:10) = Lib; OBJLNM = 'OBJL0400'; Quslobj ( PUsrSpc : 'OBJL0400' : Wobj : Objtype : ApiError); If AeBytAvl = *Zero ; // OK do what you intended to do!
![Page 19: What you can do with RPG? uno.ekberg@volvo](https://reader036.vdocuments.site/reader036/viewer/2022062309/5681599e550346895dc6e928/html5/thumbnails/19.jpg)
19
Volvo IT
2009Dep 4365, Uno Ekberg
API instead of CommandsQUSLOBJ and QWCCVTDT
Qwccvtdt – Convert Date and TimeQuscdt03 is the change date from QUSLOBJ
QWCCVTDT ('*DTS ' : Quscdt03 : '*YMD' : Workdate : ApiError); Wdate = %subst(Workdate:1:7) ; If WFrdate <= Wdate and WTodate >= Wdate; We have an object that matches our date criteria!
![Page 20: What you can do with RPG? uno.ekberg@volvo](https://reader036.vdocuments.site/reader036/viewer/2022062309/5681599e550346895dc6e928/html5/thumbnails/20.jpg)
20
Volvo IT
2009Dep 4365, Uno Ekberg
The problem: We need to send data from our ordinary files to a receiver that can’t handle our packed decimal, or binaries or zoned fields. We need to convert to ASCII as well! We can’t just convert the whole string, since the binaries and the packed will give unpredictable (well always wrong!) result
8 char 3 packed 4 char 5 packed more chars....
8 char 5 char+1Z 4 char 9 char +1Z more chars....
When converting to Unicode, or from DBCS Ebcdic to DBCS Ascii it is even worse!
![Page 21: What you can do with RPG? uno.ekberg@volvo](https://reader036.vdocuments.site/reader036/viewer/2022062309/5681599e550346895dc6e928/html5/thumbnails/21.jpg)
21
Volvo IT
2009Dep 4365, Uno Ekberg
More use of API:sQUSLFLD
D LstFldSpc Pr ExtPgm( 'QUSLFLD' )
LstFldSpc( PUsrSpc : 'FLDL0100' : FilNam + PxLibNam : *FIRST' : '0’ : ApiError);
For Idx = 1 To UsNumLstEnt; // fill a table with Field information, each elemnt describe one field:
![Page 22: What you can do with RPG? uno.ekberg@volvo](https://reader036.vdocuments.site/reader036/viewer/2022062309/5681599e550346895dc6e928/html5/thumbnails/22.jpg)
22
Volvo IT
2009Dep 4365, Uno Ekberg
More use of API:sQUSLFLD
For Idx = 1 To NumLstEnt; If F1DtaTyp = 'P'; WrkPack = 0; %SUBST(WrkpackX: 33 - F1len) = %SUBST(INSTR : F1InpBufPos : F1len); If WrkPack < 0; WrkSign = '-'; WrkPack = %abs(WrkPack); Else; WrkSign = ' '; Endif;
![Page 23: What you can do with RPG? uno.ekberg@volvo](https://reader036.vdocuments.site/reader036/viewer/2022062309/5681599e550346895dc6e928/html5/thumbnails/23.jpg)
23
Volvo IT
2009Dep 4365, Uno Ekberg
More use of API:sQUSLFLD
Wrkstr = %Editc(Wrkpack:'X'); // we can now also do iCONV (not shown here!) // ResFldaddr is where we want to move the // result to. It is in the Output record, // on the next byte to be written to. ResFldAddr = %addr(Wrkstr) + (63 - F1Digits); Endif;Endfor;
![Page 24: What you can do with RPG? uno.ekberg@volvo](https://reader036.vdocuments.site/reader036/viewer/2022062309/5681599e550346895dc6e928/html5/thumbnails/24.jpg)
24
Volvo IT
2009Dep 4365, Uno Ekberg
Dynamically invoke other programs and still use prototypes
D libpgm s 21a * Prototype for External call D Pgmtocall PR EXTPGM(libpgm) D Jobname_ LIKE(JobName) D JobUser_ LIKE(JobUser )
libpgm = %trimr(pgmlib) + '/' + %trimr(pgmtocall);
CALLP(E) Pgmtocall ( Jobname : JobUser);
![Page 25: What you can do with RPG? uno.ekberg@volvo](https://reader036.vdocuments.site/reader036/viewer/2022062309/5681599e550346895dc6e928/html5/thumbnails/25.jpg)
25
Volvo IT
2009Dep 4365, Uno Ekberg
What’s next....
Search for your need on Internet!
There are lots of free programs, and most of them come with source!
So – when you have a need – search, download and modify!
![Page 26: What you can do with RPG? uno.ekberg@volvo](https://reader036.vdocuments.site/reader036/viewer/2022062309/5681599e550346895dc6e928/html5/thumbnails/26.jpg)
26
Volvo IT
2009Dep 4365, Uno Ekberg
Acknowledgement
I have learned a LOT from people like
Scott Klement – System iNetwork
Carsten Flensburg – System iNetwork
Bob Cozzi – RPG World
Susan Gantner and Jon Paris – Partner400
and more....
![Page 27: What you can do with RPG? uno.ekberg@volvo](https://reader036.vdocuments.site/reader036/viewer/2022062309/5681599e550346895dc6e928/html5/thumbnails/27.jpg)
27
Volvo IT
2009Dep 4365, Uno Ekberg
Be /FREE!