IBM U2 SB+ for UniData® and UniVerse® (SB+), is a cross-platform, complete, and powerful rapid application development and deployment environment that enables developers to focus on what they know best: their application, their business, and their users. SB+ lets you quickly design IBM U2 data server structures and develop applications using a comprehensive developer interface.
These examples are designed to be implemented by running SBClient Version 5.4 or later in an SBDEMO account in GUI on SB+ Release 5.4 or later using UniData 6.1 or later on a UNIX® or Windows® OS or UniVerse 10.1 (Pick compatibility) or later on a UNIX or Windows OS.
Both of these examples use ActiveX controls, that are provided to you for free, that you should already have on your PC. The first example uses MSCAL.Calendar, which is shipped with SBClient. The second example uses Shell.Explorer, which is part of the Windows OS.
The first example is based on an ActiveX control in a screen that has been in SBDEMO for a number of years. You will see how to apply this example within a new screen in SBDEMO to help you utilize this idea within your application.
The second example shows how you can present data within an HTML object. Since this is HTML, you can make use of all the HMTL formatting and presentation capabilities. It also demonstrates how to embed a hypertext link within the HTML that is generated. Many developers may already be familiar with the concept of creating a new window to display HTML using the HTML,<url> style process, but this example displays the HTML within a field in a screen rather than in a new window.
Example 1: How to include an ActiveX control within an input screen
Register your ActiveX control as SB.MSCAL. Invoke the user classes registration (UCR) process, then complete the screen, as shown in Figure 1. The attributes for this control are:
-
ShowTitle
0 will not show a title when you display the control
1 will show a title of the month and year when you display the control -
DayLength
0 will show the first letter of the days of the week
1 will show the first three letters of the days of the week
Figure 1. UCR for SB.MSCAL
You then create a new file, MYFILE, using the File Create (FC) process in which we will create a screen that will access this new control.
Figure 2. Create MYFILE
In this file, we create the following fields using the Field Definition (FD) process:
- MYKEY
- FIRST.NAME
- LAST.NAME
- ENTRY.DATE
Figure 3. Create MYKEY
Figure 4. Create FIRST.NAME
Figure 5. Create LAST.NAME
Figure 6. Create ENTRY.DATE
You then create a screen using the Screen Definition (SD) process that contains these fields, called MY.SCREEN. Note that the coordinates and dimensions for the field ENTRY.DATE are used as the coordinates and the dimensions for the ActiveX control that you use in this screen:
Figure 7. Create MY.SCREEN
You then create a paragraph using the Paragraph Definition process (PD.P) called XDATE that creates the ActiveX SB.MSCAL object based on the dimensions and the coordinates of the field ENTRY.DATE:
Listing 1. XDATE paragraph
LOCAL HANDLE, FBG
IF NOT(@GUI) THEN EXIT
*
BEGIN CASE
CASE @PARAM = 1
FBG = GETATTR(@FORM,G.BACKGROUND)
HANDLE = OBJCREATE("SB.MSCAL", @FORM, "ENTRY.DATE", G.BACKGROUND, FBG)
IF HANDLE = 0 THEN DISP 4,'OBJECT NOT CREATED'
CASE 1
DISP 4,'In Paragraph, Event = ':@PARAM
END CASE
|
The paragraph XDATE is then called from the Process Before Screen Display field within the GUI Parameters screen for the Input Process definition that you will create to call the input screen:
Figure 8. Insert XDATE into the Process Before Screen Display field
When you invoke the screen, you can see the ActiveX control displayed in the container that you specified for ENTRY.DATE.
Figure 9. Invoke the screen
The control is set to today's date when the input screen is empty, and is then set to the value that has been stored in ENTRY.DATE when the record is read and then displayed in this input screen. The user is able to select a date by selecting a month and a year from the drop-down boxes, and can then select a day within that month using the mouse.
Example 2: How to display an HTML object within an SB+ screen
The objective of this example is to demonstrate how to display HTML in a field within an SB+ screen. The first thing that you need to do is to register the ActiveX that you are going to use.
Figure 10. Register the BROWSER ActiveX control
Then, define the paragraph using the (PD.P) that will be used to handle events for this object, which in this example is called BROWSER.EVENT.HANDLER:
Listing 2. BROWSER.EVENT.HANDLER paragraph
LOCAL EVENTSTR,EVENT,OBJECT,PROCESS.NAME.POS,KEY.POS,L.DATA,L.PROCESS
EVENTSTR = @PARAM
EVENT = EVENTSTR<1>
OBJECT = EVENTSTR<2>
* Find the position of the string that marks the beginning of the Process Name in the
* passed parameter
PROCESS.NAME.POS = INDEX(EVENTSTR<3,2>,"#$",1)
* Find the position of the string that marks the beginning of the Data in the
* passed parameter
KEY.POS = INDEX(EVENTSTR<3,2>,"%20",1)
*Extract the name of the process
L.PROCESS = EVENTSTR<3,2>[PROCESS.NAME.POS+2,(KEY.POS-PROCESS.NAME.POS-2)]
*Extract the key to be passed to the process
L.DATA = EVENTSTR<3,2>[KEY.POS+3,(LEN(EVENTSTR<3,2>)-KEY.POS-3)]
DATA L.DATA
EXEC L.PROCESS
|
Then, define a paragraph using the (PD.P), to create and populate the HTML field, which in this example is called XBROWSER:
Listing 3. XBROWSER paragraph
LOCAL HANDLE, FBG, SET.VAL, L.REC
IF NOT(@GUI) THEN EXIT
*
BEGIN CASE
CASE @PARAM = 1
FBG = GETATTR(@FORM,G.BACKGROUND)
*
* Create browser object
*
HANDLE = OBJCREATE("BROWSER", @FORM, "PSFIELD", G.BACKGROUND, FBG)
IF HANDLE = 0 THEN DISP 4,'OBJECT NOT CREATED'
*
* Create HTML
*
L.REC = '<HTML>'
L.REC<2> = "<B>Title</B> ":@RECORD<4>:"<BR>"
L.REC<3> = "<B>First Name</B> :":@RECORD<2>:"<BR>"
L.REC<4> = "<B>Surname</B> ":@RECORD<1>:"<BR>"
L.REC<5> = "<B>Phone No</B> ":@RECORD<6>:"<BR>"
*
* The following line contains the name of an SB+ process to call from within a hypertext
* link and it also passes the current KEY to be data stacked into that process by the
* BROWSER.EVENT.HANDLER paragraph process that you created earlier
*
L.REC<6> = '<A HREF="#$O*CUST*S1 ':@KEY:'$">This is a link to the enq screen</A>'
L.REC<7> = "</HTML>"
*
* Transfer the HTML to the client as the ActiveX control will only display HTML from a
* Windows file
*
WRITE L.REC ON "CHWORK","HTMLREC":@PORT
EXEC "L:SB.TO.DOS CHWORK HTMLREC":@PORT:" TO C:\TEMP\MYOUTPUT.HTML (OZ"
*
* Put HTML into browser control Navigate2 is a method within Shell.Explorer
*
SET.VAL = GETATTR(HANDLE, '(Navigate2,C:\TEMP\MYOUTPUT.HTML)')
CASE 1
DISP 4,'In Paragraph, Event = ':@PARAM
END CASE
|
Then, define a field using the FD process called PSFIELD (this field name should not contain any special characters) that is used as a container for the HTML control:
Figure 11. Define a field called PSFIELD
Create a screen using the SD process, that contains PSFIELD. Note that the coordinates and dimensions for the field PSFIELD are used as the coordinates and the dimensions for the ActiveX control that you are going to use in this screen, and that the field must be an input field.
Figure 12. Create the screen using SD
Insert XBROWSER,1 in the Process After Read Record field in the Screen Parameters window of the screen in which you wish to display the HTML, as shown in Figure 13.
Figure 13. Insert the process name XBROWSER in the Process After Read Record fiend
When you invoke the screen and select a record, you see the following:
Figure 14. Invoke the screen
When you then click on the hyperlink that you have created, you invoke the enquiry screen that you specified in the HTML that you built in the paragraph XBROWSER:
Figure 15. Use the hyperlink
These examples have demonstrated how to display a calendar control within an SB+ input screen and how to display a browser control within an input screen. Using these examples, you should get the idea of how easy it is to incorporate ActiveX controls within your application, and take advantage of the work that other people have done to improve the look and feel and also the usability of your application without a significant investment from you in programming time. Note that these examples only work in the GUI.
Learn
-
U2 Library page: Find SB+ manuals.
-
MSDN Entry for ActiveX: Find further information about ActiveX controls.
-
MSDN Entry for WebBrowser Control: Locate additional information about WebBrowser control.
-
developerWorks U2 zone: Read articles and tutorials and connect to other resources to expand your U2 skills.
-
U2 product family: Learn more about the U2 product family.
-
developerWorks Information Management zone: Learn more about DB2. Find technical documentation, how-to articles, education, downloads, product information, and more.
-
Stay current with developerWorks
technical events and webcasts.
Get products and technologies
-
Build your next development project with
IBM
trial software, available for download directly from developerWorks.
Discuss
-
Participate in developerWorks blogs and get involved in the developerWorks community.
Comments (Undergoing maintenance)







