SAS/AF® andInternet Explorer™
Richard A. DeVenezia
SAS/AF
• Full featured– Object orientated
• Very capable– lack latest developments
• Frames are input forms– Can host ActiveX components
Web pages
• Browsers use latest standards
• Cascading Style Sheets (CSS)
• Scripting
• Contain input forms– <FORM> ... </FORM>
Why use a web page
• Designer pool
• Use of latest standards
• Development using production forms
• Interception– Flying under the radar
Internet Explorer
• Ever present in Windows systems
• ActiveX feature– Microsoft Web Browser component
• Voila! SAS/AF should be able to use Microsoft Web Browser
HTML Forms
• Inputs (parameters) transmitted to server– Name=Value pairs
• Tranmission types– GET
• pairs part of URL
– POST• pairs sent ‘behind the scenes’
ActiveX components
• Have methods
• Have properties
• Fire events– User of component can install event handler
that gets invoked when an event is fired.
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)
SAS/AF Frame
• Version 6 Objects– OLE - Insert Object
• Create Control
• Microsoft Web Browser– Insertable? (see SN-015762)
• Configure so BeforeNavigate2 runs MSBRWSEH.SCL
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;
ERROR
• OLE: One of the parameters is not a valid type.
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
Now what?
• Microsoft Web Browser– Not directly useable
• Need an adapter– Mediate special type issues of ActiveX in SAS– Simple design for specific use
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]
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
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)
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;
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;
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 ;
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;
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();
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;
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
CaptureInput.scl
init:
declare List input = {};
call display
( 'AFBROWSER.FRAME'
, symget('CaptureUrl')
, input
);
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');
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;
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;
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
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/
Top Related