1 / 27

What you can do with RPG? uno.ekberg@volvo

What you can do with RPG? uno.ekberg@volvo.com. 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.

tracy
Download Presentation

What you can do with RPG? uno.ekberg@volvo

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. What you can do with RPG?uno.ekberg@volvo.com Dep 4365, Uno Ekberg

  2. 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 Dep 4365, Uno Ekberg

  3. AB Volvo Business Areas MackTrucks RenaultTrucks Volvo Trucks Nissan Diesel Buses Construction Equipment Volvo Penta Volvo Aero FinancialServices Business Units Volvo 3P Volvo Powertrain Volvo Parts Volvo Logistics Volvo Information Technology The Volvo Group Dep 4365, Uno Ekberg

  4. Our company history Dep 4365, Uno Ekberg

  5. Offshore centres Sweden United Kingdom Russia Canada Poland Belgium France Korea Turkey Japan China USA Mexico Thailand India Malaysia Singapore Brazil South Africa Australia Volvo IT – Global Presence Dep 4365, Uno Ekberg

  6. Volvo IT customers The Volvo Group Volvo Cars Dep 4365, Uno Ekberg

  7. 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 Dep 4365, Uno Ekberg

  8. If you need a simple file with mostly just text, like a temporary error log Create file Open Write msg MyPgmCodeIf %error; tell someone someway about thist error Dep 4365, Uno Ekberg

  9. 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. Dep 4365, Uno Ekberg

  10. Huge amount of Audit Jrn events ?? 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 We have n number of Receivers, all want just there own part Dep 4365, Uno Ekberg

  11. File IO without an F record • We use this to filter out records from the System Audit JournalWe 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 Dep 4365, Uno Ekberg

  12. 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 Dep 4365, Uno Ekberg

  13. 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; Dep 4365, Uno Ekberg

  14. File IO without an F recordWrite record // First search for the correct file in a table of User Profileslookupappl = %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; Dep 4365, Uno Ekberg

  15. File IO without an F recordClose the files In the end close all the filesFor i = 1 by 1 to SizApplarr; pRfile = WFilptr(i); Rclose(pRfile); Endfor; Dep 4365, Uno Ekberg

  16. 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. Dep 4365, Uno Ekberg

  17. 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; Dep 4365, Uno Ekberg

  18. 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! Dep 4365, Uno Ekberg

  19. 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! Dep 4365, Uno Ekberg

  20. 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! Dep 4365, Uno Ekberg

  21. 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: Dep 4365, Uno Ekberg

  22. 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; Dep 4365, Uno Ekberg

  23. 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; Dep 4365, Uno Ekberg

  24. 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); Dep 4365, Uno Ekberg

  25. 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! Dep 4365, Uno Ekberg

  26. 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.... Dep 4365, Uno Ekberg

  27. Be /FREE! Dep 4365, Uno Ekberg

More Related