sas/af® and internet explorer™ richard a. devenezia

29
SAS/AF® and Internet Explorer™ Richard A. DeVenezia

Upload: bruno-stephens

Post on 23-Dec-2015

224 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: SAS/AF® and Internet Explorer™ Richard A. DeVenezia

SAS/AF® andInternet Explorer™

Richard A. DeVenezia

Page 2: SAS/AF® and Internet Explorer™ Richard A. DeVenezia

SAS/AF

• Full featured– Object orientated

• Very capable– lack latest developments

• Frames are input forms– Can host ActiveX components

Page 3: SAS/AF® and Internet Explorer™ Richard A. DeVenezia

Web pages

• Browsers use latest standards

• Cascading Style Sheets (CSS)

• Scripting

• Contain input forms– <FORM> ... </FORM>

Page 4: SAS/AF® and Internet Explorer™ Richard A. DeVenezia

Why use a web page

• Designer pool

• Use of latest standards

• Development using production forms

• Interception– Flying under the radar

Page 5: SAS/AF® and Internet Explorer™ Richard A. DeVenezia

Internet Explorer

• Ever present in Windows systems

• ActiveX feature– Microsoft Web Browser component

• Voila! SAS/AF should be able to use Microsoft Web Browser

Page 6: SAS/AF® and Internet Explorer™ Richard A. DeVenezia

HTML Forms

• Inputs (parameters) transmitted to server– Name=Value pairs

• Tranmission types– GET

• pairs part of URL

– POST• pairs sent ‘behind the scenes’

Page 7: SAS/AF® and Internet Explorer™ Richard A. DeVenezia

ActiveX components

• Have methods

• Have properties

• Fire events– User of component can install event handler

that gets invoked when an event is fired.

Page 8: SAS/AF® and Internet Explorer™ Richard A. DeVenezia

Microsoft Web Browser

• Navigate method– render page at URL

• BeforeNavigate2 event– gives access to component prior to actual

transmission– Variables passed to handler

• URL (GET parameters)

• POST (buffer)

Page 9: SAS/AF® and Internet Explorer™ Richard A. DeVenezia

SAS/AF Frame

• Version 6 Objects– OLE - Insert Object

• Create Control

• Microsoft Web Browser– Insertable? (see SN-015762)

• Configure so BeforeNavigate2 runs MSBRWSEH.SCL

Page 10: SAS/AF® and Internet Explorer™ Richard A. DeVenezia

MSBRWSEH.SCL

BN2: public method

pDisp:numUrl:char(1024)Flags:char(1024)TargetFrameName:char(1024)PostData:numHeaders:numCancel:num

;put 'BeforNavigate2 event handler';put pDisp=; put Url=; put Flags=; put TargetFrameName=;put PostData=; put Headers=; put Cancel=;

endmethod;

Page 11: SAS/AF® and Internet Explorer™ Richard A. DeVenezia

ERROR

• OLE: One of the parameters is not a valid type.

Page 12: SAS/AF® and Internet Explorer™ Richard A. DeVenezia

BeforeNavigate2

ByVal pDisp As Object, _ByRef Url As Variant, _ByRef Flags As Variant, _ByRef TargetFrameName As Variant, _ByRef PostData As Variant, _ByRef Headers As Variant, _ByRef Cancel As Boolean

• Variant corresponding to PostData can not be mapped to a SAS type, thus the ERROR

Page 13: SAS/AF® and Internet Explorer™ Richard A. DeVenezia

Now what?

• Microsoft Web Browser– Not directly useable

• Need an adapter– Mediate special type issues of ActiveX in SAS– Simple design for specific use

Page 14: SAS/AF® and Internet Explorer™ Richard A. DeVenezia

Adapter Design

• Navigate to a page

• Signal when new page is to be navigated to

• Retrieve GET and POST

• URL property

• OnBeforeNavigate event• GetCount, GetName[index], GetValue[index]

• PostCount, PostName[index], PostValue[index]

Page 15: SAS/AF® and Internet Explorer™ Richard A. DeVenezia

OCX Development

• Borland Delphi 2006 Professional

• OleObjectForSasAf.ocx– Add form AfWebBrowser– Add properties and event– Delphi source at http://www.devenezia.com

• Install– regsvr32 OleObjectsForSasAf.ocx

Page 16: SAS/AF® and Internet Explorer™ Richard A. DeVenezia

Simple Frame

• AFBROWSER.FRAME– Contains only AfWebBrowser

• AFBRWSEH.SCL run by event map

• Caller passes in URL and SCL list to receive inputs

• Frame exits at first navigation attempt (i.e. submit button)

Page 17: SAS/AF® and Internet Explorer™ Richard A. DeVenezia

AFBROWSER.FRAME

entry

inUrl:input:char

outParameters:update:List;

init:

declare Object oBrowser;

_frame_._getWidget ('Browser', oBrowser);

rc = setNitemL (oBrowser, {}, 'GET');

rc = setNitemL (oBrowser, {}, 'POST');

oBrowser._setProperty('URL', inURL);

return;

Page 18: SAS/AF® and Internet Explorer™ Richard A. DeVenezia

AFBROWSER.FRAME

Browser:

browserCount + 1;

if browserCount = 1 then return;

if listlen (outParameters) >= 0 then do;

get = getNitemL (oBrowser, 'GET');

post = getNitemL (oBrowser, 'POST');

rc = setNitemL (outParameters, get, 'GET');

rc = setNitemL (outParameters, post, 'POST');

end;

* after capturing the data, shut down the browser frame;

* callee is responsible for deleting the SCL lists it receives upon return;

call execcmd ('CANCEL');

return;

Page 19: SAS/AF® and Internet Explorer™ Richard A. DeVenezia

AFBRWSEH.SCL

OBN:public method;/* _self_ is an * OLE - Insert Object that contains an AfWebBrowser * presume _self_ already has two attached lists named * GET and POST, for storing the inputs */

Get = GetNitemL (_self_, 'GET', 1,1,0);Post = GetNitemL (_self_, 'POST', 1,1,0);

rc = clearlist (Get);rc = clearlist (Post);

declare char(200) name value ;

Page 20: SAS/AF® and Internet Explorer™ Richard A. DeVenezia

AFBRWSEH.SCL

* Copy GET parameters to SCL list;

_self_._getProperty('GetCount', count);do i = 1 to count; * Fetch pair from OLE object; _self_._getProperty('GetName', i-1, name); _self_._getProperty('GetValue', i-1, value);

* Store pair in SCL list; rc = insertC (Get, value, -1, name); end;

Page 21: SAS/AF® and Internet Explorer™ Richard A. DeVenezia

AFBRWSEH.SCL

* Copy POST parameters to SCL list;

_self_._getProperty(’PostCount', count);do i = 1 to count; * Fetch pair from OLE object; _self_._getProperty('PostName', i-1, name); _self_._getProperty('PostValue', i-1, value);

* Store pair in SCL list; rc = insertC (Post, value, -1, name); end;

* force program flow through object label in frame SCL;

_self_._objectLabel();

Page 22: SAS/AF® and Internet Explorer™ Richard A. DeVenezia

GetWebInput.scl

• Test Unitinit:

declare List input = {};

call display

( 'AFBROWSER.FRAME’

, 'http://www.devenezia.com/papers/nesug-2006/Payments.html’

, input

);

call putlist (input,'',0);

return;

Page 23: SAS/AF® and Internet Explorer™ Richard A. DeVenezia

Web Inputs to SAS Table

• Callable from Base

• Uses macro variables to pass parameters to SCL code– Code raise a window with the web form

rendered via Microsoft Web Browser ensconced in Adapter.

• SCL code invoked using Proc DISPLAY

Page 24: SAS/AF® and Internet Explorer™ Richard A. DeVenezia

CaptureInput.scl

init:

declare List input = {};

call display

( 'AFBROWSER.FRAME'

, symget('CaptureUrl')

, input

);

Page 25: SAS/AF® and Internet Explorer™ Richard A. DeVenezia

CaptureInput.scl

ds = open (symget('CapturedData'), 'N');

rc = newvar (ds, 'Type', 'C', 4);

rc = newvar (ds, 'Name', 'C', 50);

rc = newvar (ds, 'Value','C', 300);

ds = close (ds);

ds = open (symget('CapturedData'), 'U');

call PutVarC (ds,1,'URL');

call PutVarC (ds,2,'');

call PutVarC (ds,3,symget('CaptureUrl'));

rc = append (ds,'NOINIT');

Page 26: SAS/AF® and Internet Explorer™ Richard A. DeVenezia

CaptureInput.scl

call PutVarC (ds,1,'GET');

list = GetNItemL (input,'GET',1,1,0);

if list then

do i = 1 to listlen(list);

call PutVarC (ds,2,NameItem(list,i));

call PutVarC (ds,3,GetItemC(list,i));

rc = append (ds,'NOINIT');

end;

Page 27: SAS/AF® and Internet Explorer™ Richard A. DeVenezia

CaptureInput.scl

call PutVarC (ds,1,'POST');

list = GetNItemL (input,'POST',1,1,0);

if list then

do i = 1 to listlen(list);

call PutVarC (ds,2,NameItem(list,i));

call PutVarC (ds,3,GetItemC(list,i));

rc = append (ds,'NOINIT');

end;

ds = close(ds);

return;

Page 28: SAS/AF® and Internet Explorer™ Richard A. DeVenezia

Conclusion

• SAS/AF is alive and kicking– Has issues with variants

• ActiveX adapters can smooth integration

• Frame hosted web browser– Great tool for getting input

Page 29: SAS/AF® and Internet Explorer™ Richard A. DeVenezia

About the Author

Richard A. DeVeneziaIndependent Consultant

9949 East Steuben RoadRemsen, NY 13438

(315) 831-8802

richard.contact@deveneziahttp://www.devenezia.com/contact.php

http://www.devenezia.com/papers/nesug-2006/