50 Things You May Not Know You Can Do With The 4GL



Similar documents
Form And List. SuperUsers. Configuring Moderation & Feedback Management Setti. Troubleshooting: Feedback Doesn't Send

Best Practices. EMEA Pug Challenge Nectar Daloglou, White Star Software

Elixir Schedule Designer User Manual

MAS 500 Intelligence Tips and Tricks Booklet Vol. 1

Participant Guide RP301: Ad Hoc Business Intelligence Reporting

Simply Accounting Intelligence Tips and Tricks Booklet Vol. 1

How To Use Optimum Control EDI Import. EDI Invoice Import. EDI Supplier Setup General Set up

Grandstream Networks, Inc. UCM6100 Series IP PBX Appliance CDR and REC API Guide

ODBC Client Driver Help Kepware, Inc.

PHP Debugging. Draft: March 19, Christopher Vickery

Create a New Database in Access 2010

STATGRAPHICS Online. Statistical Analysis and Data Visualization System. Revised 6/21/2012. Copyright 2012 by StatPoint Technologies, Inc.

Product: DQ Order Manager Release Notes

Tips and Tricks SAGE ACCPAC INTELLIGENCE

django-cron Documentation

McAfee Network Threat Response (NTR) 4.0

SRFax Fax API Web Services Documentation

EXT: SEO dynamic tag

StreamServe Persuasion SP5 Oracle Database

SnapLogic Salesforce Snap Reference

Information Server Documentation SIMATIC. Information Server V8.0 Update 1 Information Server Documentation. Introduction 1. Web application basics 2

Table of Contents. Introduction: 2. Settings: 6. Archive 9. Search Browse Schedule Archiving: 18

Websense SQL Queries. David Buyer June 2009

T-CONNECT EDI VIEWER. Installation and User Guide 12/16/2014 WE BUILD SOFTWARE THAT HELPS OUR CLIENTS GROW DOCUMENT CREATED BY:

The release notes provide details of enhancements and features in Cloudera ODBC Driver for Impala , as well as the version history.

REP200 Using Query Manager to Create Ad Hoc Queries

Oracle Database: Introduction to SQL

A table is a collection of related data entries and it consists of columns and rows.

Data Warehouse Troubleshooting Tips

1. To start Installation: To install the reporting tool, copy the entire contents of the zip file to a directory of your choice. Run the exe.

Send TLM. Table of contents

SQL Server Database Coding Standards and Guidelines

Sage Accpac ERP 5.6A. CRM Analytics for SageCRM I User Guide

Amicus Link Guide: Outlook/Exchange

DiskPulse DISK CHANGE MONITOR

Oracle Database: Introduction to SQL

Contents. Introduction. Chapter 1 Some Hot Tips to Get You Started. Chapter 2 Tips on Working with Strings and Arrays..

Time Clock Import Setup & Use

Using a Data Warehouse to Audit a Transactional System

Rational Rational ClearQuest

Lab 9 Access PreLab Copy the prelab folder, Lab09 PreLab9_Access_intro

v1.1.0 SimpleSQL SQLite manager for Unity3D echo17.com

Architecting the Future of Big Data

SnapLogic Tutorials Document Release: October 2013 SnapLogic, Inc. 2 West 5th Ave, Fourth Floor San Mateo, California U.S.A.

Oracle Database 12c: Introduction to SQL Ed 1.1

PIC 10A. Lecture 7: Graphics II and intro to the if statement

CREATING AND DEPLOYING ABL WEB SERVICES

SLIDE SHOW 18: Report Management System RMS IGSS. Interactive Graphical SCADA System. Slide Show 2: Report Management System RMS 1

Database Migration : An In Depth look!!

Forensic Analysis of Internet Explorer Activity Files

Contents CHAPTER 1 IMail Utilities

WiredContact Enterprise x3. Admin Guide

Oracle Database: Introduction to SQL

New Perspectives on Creating Web Pages with HTML. Considerations for Text and Graphical Tables. A Graphical Table. Using Fixed-Width Fonts

Accounts Receivable: Importing Remittance Data

Title. Syntax. stata.com. odbc Load, write, or view data from ODBC sources. List ODBC sources to which Stata can connect odbc list

Microsoft SQL connection to Sysmac NJ Quick Start Guide

Changing the Tufts University Moon Site. Needed:

Lab III: Unix File Recovery Data Unit Level

Hands-On UNIX Exercise:

Informatica Corporation Proactive Monitoring for PowerCenter Operations Version 3.0 Release Notes May 2014

Portals and Hosted Files

VDF Query User Manual

WASv6_Scheduler.ppt Page 1 of 18

What is Memento. Content

How To Set Up An Intellicus Cluster And Load Balancing On Ubuntu (Windows) With A Cluster And Report Server (Windows And Ubuntu) On A Server (Amd64) On An Ubuntu Server

IT2304: Database Systems 1 (DBS 1)

Lab 2: PostgreSQL Tutorial II: Command Line

(For OpenEdge 10.1C & 10.2A customers)

Microsoft Access 2010 Overview of Basics

WEB BASED Access Control/Time Attendance Software Manual V 1.0

Facebook Twitter YouTube Google Plus Website

Using LDAP Authentication in a PowerCenter Domain

CrontabFile Converter

Change Management for Rational DOORS User s Guide

X1 Professional Client

aspwebcalendar FREE / Quick Start Guide 1

ODBC Chapter,First Edition

FORMS. Introduction. Form Basics

Resources You can find more resources for Sync & Save at our support site:

LAB 1: Getting started with WebMatrix. Introduction. Creating a new database. M1G505190: Introduction to Database Development

SQL. Short introduction

To install Multifront you need to have familiarity with Internet Information Services (IIS), Microsoft.NET Framework and SQL Server 2008.

IT2305 Database Systems I (Compulsory)

LabVIEW Day 6: Saving Files and Making Sub vis

Developer Updates for. Microsoft Dynamics NAV

Differences in Use between Calc and Excel

LICENSE4J AUTO LICENSE GENERATION AND ACTIVATION SERVER USER GUIDE

Job Scheduler Daemon Configuration Guide

Managed File Transfer with Universal File Mover

Setting Up ALERE with Client/Server Data

Search help. More on Office.com: images templates

"SQL Database Professional " module PRINTED MANUAL

Transcription:

You May Not Know You Can Do With The 4GL Gus Björklund. Progress. PUG Challenge Americas Westford, MA June 5 to 8, 2011 1

Agenda A smörgåsbord of large and small topics Having nothing to do with each other In no particular order 2

Credit I didn't think all this up myself. Greg Higgins, Dmitri Levin, Dustin Grau, Tom Bascom, Dan Foreman, and others came up with some of these 3

Call a dynamic shared library function (Windows.DLL or UNIX/Linux.so) 4

define variable x as integer no-undo. procedure putenv external "/lib64/libc.so.6": define input parameter env as character. define return parameter x as long. end. run putenv( "XYZZY=pflugh", output x ). display os-getenv( "XYZZY" ). os-command value( 'echo "$XYZZY"' ). return. Shared library call example This code was gratuitously stolen from Tom Bascom. He has lots more. 5

Get Process Identifiers 6

Using input through define variable pid as character no-undo. input through "echo $PPID". import pid. input close. 7

Using UNIX/Linux C library call procedure getpid external "/usr/lib/glibc.so" cdecl: define return parameter pid as long no-undo. end procedure. /* then to use it: */ def var p as integer no-undo. p = getpid (). 8

Using Windows kernel library call procedure GetCurrentProcessId external "kernel32.dll": define return parameter pid as long. end procedure. def var p as integer no-undo. run GetCurrentProcessId (output p). 9

Using Database VST def var p as integer no-undo. find first _myconnection no-lock. p = _myconnection._myconn-pid. 10

Time Management 11

Date/Time related stuff Data types DATE DATETIME DATETIME-TZ INT64 Session attributes SESSION:TIMEZONE SESSION:DISPLAY-TIMEZONE 12

Date/Time related stuff "constructor" functions d = date (2011, 6, 7) dt = datetime (2011, 6, 7, 11, 15, 0, 0) dtz = datetime-tz (2011, 6, 7, 11, 15, 0, -240) 13

ABL Calendar Based on Gregorian Calendar Epoch Date 1 January 4713 at 00:00:00 Units DATE datatype: days DATETIME: milliseconds DATETIME-TZ: milliseconds 14

UNIX time Different Calendars epoch is Jan 1, 1970 at 00:00:00 unit is seconds JMS time epoch is Jan 1, 1970 at 00:00:00 unit is milliseconds Windows time epoch is Jan 1, 1601 at 00:00:00 unit is centinanoseconds (100 nanoseconds) aka "ticks" 15

Useful Time Constants Number Description 116 444 736 000 000 000 ticks from 1/1/1601 to 1/1/1970 11 644 473 600 000 milliseconds from 1/1/1601 to 1/1/1970 2 305 814 days from 1/1/- 4713 to 1/1/1601 2 440 588 days from 1/1/- 4713 to 1/1/1970 134 774 days from 1/1/1601 to 1/1/1970 210 866 889 600 seconds from 1/1/- 4713 to 1/1/1970 3 600 seconds in 1 hour 86 400 seconds in 1 day 31 536 000 seconds in 365 days 16

Time arithmetic is easy with datetime and datetime-tz data types arithmetic units is milliseconds def var starttime as datetime. def var endtime as datetime. def var i as int64. i = endtime - starttime. endtime = starttime + i. 17

Arithmetic in other units def var starttime as datetime. def var endtime as datetime. def var nsecs as int64. def var ndays as int64. nsecs = (endtime starttime) / 1000. ndays = (endtime starttime) / 86400000. /* but this is too hard!!! */ 18

INTERVAL: A useful function i = INTERVAL (endtime, starttime, units). starttime, endtime are expressions of type DATE, DATETIME, or DATETIME-TZ units is a character expression evaluating to one of "years", "months", "weeks", "days", "hours", "minutes", "milliseconds" 19

Changing Times From Windows to DATETIME: 0. convert from ticks to milliseconds 1. adjust for epoch difference def var wintime as int64 no-undo. def var dt as datetime no-undo. wintime = wintime / 10000. dt = add-interval (datetime (1, 1, 1601, 0, 0, 0, 0), wintime, "milliseconds"). 20

Changing Times From DATETIME-TZ to UNIX: 0) adjust for epoch difference in seconds def var dt as datetime-tz no-undo. def var unixtime as int64 no-undo. unixtime = interval (dt, DATETIME-TZ (1, 1, 1970, 0, 0, 0, 0, 0), "seconds"). 21

Time Zones DATETIME-TZ data type milliseconds from epoch stored as GMT with originating session time zone offset (in minutes) def var tzoffset as int no-undo. tzoffset = timezone (dt-tz expression). gives you the timezone offset dtz = datetime-tz (dtz, tzoffset) to change a timezone offset 22

DATETIME-TZ: Time Zones database indexing ignores timezone arithmetic ignores timezone comparison operators (>, <, >=, <=, =, <>) ignore timezone 23

Time Zones SESSION:DISPLAY-TIMEZONE integer timezone offset used for formatting initialized to? when? then SESSION:TIMEZONE is used instead. 24

Time Zones SESSION:TIMEZONE integer session timezone offset initialized to? set with timezone function: SESSION:TIMEZONE = TIMEZONE. 25

Some other things 26

Import data thruough stdin, stdout On UNIX and Linux: cat cdata.txt pro -b -p import.p cat On Windows: type cdata.txt pro -b -p import.p more the program imp.p: def var c as char no-undo. import cv. put unformatted string (c). 27

How many BI clusters exist? find _AreaStatus where _AreaStatus-Areanum = 3. find _dbstatus display _AreaStatus-Hiwater * _dbstatus._dbstatus-biblksize / _dbstatus-biclsize / 1024. Can t tell how many are active though 28

To get formatted data into Excel Excel can load HTML Create an HTML table text file Use one HTML table record per table row One cell per field 29

Sample: <table border=0 cellpadding=0 cellspacing=0 width=1034> <col width=146> <col width=185> <col width=159> <col width=181> <tr height=13> <td>marv Stone</td> <td>systems Engineering</td> <td>progress Software</td> <td>marv@example.com</td> </tr> </table> 30

Sample: <table border=0 cellpadding=0 cellspacing=0 width=1034> <col width=146> <col width=185> <col width=159> <col width=181> <tr height=13> <td>marv Stone</td> <td>systems Engineering</td> <td>progress Software</td> <td>marv@example.com</td> </tr> </table> 31

for each _AreaStatus where ( not _AreaStatus- Areaname matches "*After Image Area*" ) no- lock: display _AreaStatus- Areanum format ">>>" column- label "Num" _AreaStatus- Areaname format "x(20)" column- label "Area Name" _AreaStatus- Totblocks column- label "Tot blocks" _AreaStatus- Hiwater column- label "High water mark" _AreaStatus- Hiwater / _AreaStatus- Totblocks * 100 column- label "% use" _AreaStatus- Extents format ">>>" column- label "Num Extents" _AreaStatus- Freenum column- label "Free num" _AreaStatus- Rmnum. end. How much space is used? column- label "RM num" 32

What tables are being used? find first _MyConnection no- lock. for each _UserTableStat where _UserTableStat- Conn = _MyConnection._MyConn- UserId no- lock: find _file where _file- num = _UserTableStat- Num no- lock no- error. if available _file then display _UserTableStat._UserTableStat- Num _file- name format "x(20)" _UserTableStat- read format ">>>>>>>>>>" _UserTableStat- create format ">>>>>>>>>>" _UserTableStat- update format ">>>>>>>>>>" _UserTableStat- delete format ">>>>>>>>>>". end. 33

Table # File- Name read create update delete ::::::: ::::::::::::: :::::: :::::: :::::: :::::: 1 Invoice 5 2 Customer 2 1 3 Item 4 Order 6 5 Order- Line 21 6 Salesrep 7 State 52 8 Local- Default 9 Ref- Call 34

What indexes are being used? Same technique as for tables, but read the data from the _UserIndexStat table 35

Which areas are tables in? for each _StorageObject no- lock where _StorageObject._Object- type = 1 and _StorageObject._Area- number > 6 find _Area where _Area._Area- number = _StorageObject._Area- number no- lock no- error. find _File where _File._File- number = _StorageObject._Object- number no- lock no- error. display _StorageObject._Area- number format ">>9 column- label "Area" _Area._Area- name format "x(30)" column- label "Name" _File._File- nam when available _File column- label "Table". end. 36

List tables by storage area for each _Area, each _Storageobject where (_Storageobject._Area-number = _Area._Area-number), each _File where (_File._File-Number = _Storageobject._Object-number) and (_File._File-Number > 0) break by _File._File-name: display _Area._Area-name _File._File-name. end. 37

Listing of tables by storage area Area-name Schema Area Schema Area Schema Area Schema Area Schema Area Schema Area Schema Area Schema Area File-Name agedar agedar customer customer item item monthly monthly 38

List tables by storage area for each _Area, each _Storageobject where (_Storageobject._Area-number = _Area._Area-number), each _File where (_File._File-Number = _Storageobject._Object-number) and (_File._File-Number > 0) break by _File._File-name: display _Area._Area-name _File._File-name. end. 39

List tables by storage area 2 for each _Area, each _Storageobject where (_Storageobject._Area-number = _Area._Area-number), each _File where (_File._File-Number = _Storageobject._Object-number) and (_File._File-Number > 0) and (_StorageObject._Object-type eq 1) break by _File._File-name: display _Area._Area-name _File._File-name. end. 40

List indexes by storage area and table for each _Area, each _Storageobject where (_Storageobject._Area-number = _Area._Area-number and (_StorageObject._Object-type eq 2), each _Index where (_Index._Idx-num = _Storageobject._Object-number): find _File of _Index. if (_File._File-number > 0) then display _Area._Area-name _File._File-name _Index._Index-name. end. 41

List Tables and Their Fields output to tables.txt. for each _file where (0 < _file-num): put _file-name skip. for each _field of _file: put _field-name skip. end. put skip. end. output close. 42

Table and fields Invoice Adjustment Amount Cust-Num Invoice-Date Invoice-Num Order-Num Ship-Charge Total-Paid 43 Customer Address Address2 Balance City

You can do range checks in CASE statements DEF VAR MyVar AS INT. MyVar = RANDOM(- 10,11). CASE TRUE: WHEN MyVar LE 10 AND MyVar GT 1 THEN MESSAGE "case1" MyVar VIEW- AS ALERT- BOX. WHEN MyVar LE 1 AND MyVar GT 0 THEN MESSAGE "case2" MyVar VIEW- AS ALERT- BOX. WHEN MyVar LE 0 THEN MESSAGE "case3" MyVar VIEW- AS ALERT- BOX. OTHERWISE MESSAGE "case4" MyVar VIEW- AS ALERT- BOX. END CASE. 44

For dynamic query result fields, instead of this: REPEAT: hquery:get- NEXT(). IF hquery:query- OFF- END THEN LEAVE. hbufferfield1 = hbuffer:buffer- FIELD('Name'). hbufferfield2 = hbuffer:buffer- FIELD('CustomerCode'). DISPLAY hbufferfield1:buffer- VALUE hbufferfield2:buffer- VALUE. END. 45

You can do it this way REPEAT: hquery:get- NEXT(). IF hquery:query- OFF- END THEN LEAVE. DISPLAY hbuffer::name hbuffer::customercode. END. 46

Use PUBLISH for debugging Instead of adding and deleting MESSAGE statements in your code for debugging purposes, add PUBLISH statements and leave them in there forever: At runtime, you can SUBSCRIBE to this information when you need it, even in production, and decide what you do with it. You can DISPLAY the information in a Window. Write it to a log file (on AppServer or WebSpeed). The overhead is minimal if you don t subscribe. PUBLISH message (PROGRAM- NAME(1), <level>, <message>). 47

PUBLISH from classes: You can PUBLISH debug messages from classes using the following syntax: PUBLISH message FROM (SESSION:FIRST- PROCEDURE) (PROGRAM- NAME(1), <level>, <message>). You can process these messages in exactly the same way as from a procedure PROGRAM-NAME(1) returns the name of the class. Make sure there is a SESSION:FIRST-PROCEDURE 48

To send email from WebSpeed Use smtp server that is built in to Microsoft IIS. It is very simple to use. Does not need usercode/password setup and is very fast. def var chmessage as com- handle no- undo. create "CDO.Message" chmessage. chmessage:subject = "Test Subject". chmessage:from = "TestFrom@test.com". chmessage:to = "TestTo@test.com". chmessage:textbody = "Test Body". chmessage:send(). release object chmessage. 49

Call.Net assemblies from 4GL Regenerate the.net assembly with "register for COM Interop" = true in Build settings. That will generate.tlb (Type library). Now you can use that from Progress in the same manner as a.dll. If you don't own the source code to regenerate, you can code a.net wrapper around dll and expose the wrapper as type library. This is a good way to get functionality in Progress that is readily available in.net. 50

Are we up to 50 yet? 51

With your OpenEdge install, there are variety of functions and programs in the $DLC/src/samples folder. Examples includes source code for finding weekday, weeknum, get current folder path, get unique numbers, sample code for activex,.net, sockets etc. Go read it, you are likely to find something useful. Some of them are good. 52

Questions email: gus@progress.com 53