Latest News

the latest news from our team

Using Data Access – From PowerBuilder 5 with Arrays

The MDMDA session object is being called from a PowerSoft PowerBuilder 5 application. This sample includes references to an item array (12J1).

The dataset and items are defined as follows:

ITEMS:
ITEM-NO, Z6;
SALES-PERIODS, 12X6;
SALES-HISTORY, 12P12;
MISC, 12J1;
OTHER, J2;

SETS:
NAME: HISTORY, DETAIL (1/18);
ENTRY: ITEM-NO(!HISTORY-M),
SALES-PERIODS,
SALES-HISTORY,
MISC,
OTHER;
CAPACITY: 101;
END.

mdm_003


Declare Global Variables

OLEObject da
OLEObject db
OLEObject ds
string upass

Open for window

string t1
integer result

open (w_genapp_upass,w_genapp_frame)

da = CREATE OLEObject
result = da.ConnectToNewObject ( "MdmDA.Session" )
if result <> 0 then
MessageBox("OLE Error", "Object not created")
close ( w_genapp_frame )
return
end if

da.TraceLevel = 0
da.HostAddress = "support"
da.Port = "30002"
da.LoginUser = "mgr"
da.UserPassword = upass
da.LoginGroup = "util"
da.LoginAccount = "minisoft"
If Not da.Connect Then
MessageBox ("MDMDA Error", "Connect failed")
close ( w_genapp_frame )
return
End If
If da.LoginStatus = False Then
MessageBox ("MDMDA Error", "Login failed")
close ( w_genapp_frame )
return
End If
db = da.AddImageDBRef("MSCARD")
ds = db.AddDatasetRef("HISTORY")
If Not db.Open("MSCARD", "UTIL", "MINISOFT", 1, "DO-ALL") Then
MessageBox ("MDMDA Error", "Open failed")
close ( w_genapp_frame )
return
End If
ds.Delimiter = ""
If Not ds.ReadSerialNext("@;") Then
MessageBox ("MDMDA Error", "readserialnext failed")
return
End If

sle_1.Text = ds.Item("ITEM-NO")
t1 = ds.Item("MISC")
sle_2.Text = t1
sle_misc_1.Text = string(integer(Mid(t1, 1, 6)),"0")
sle_misc_2.Text = string(integer(Mid(t1, 7, 6)),"0")
sle_misc_3.Text = string(integer(Mid(t1, 13, 6)),"0")
sle_misc_4.Text = string(integer(Mid(t1, 19, 6)),"0")
sle_misc_5.Text = string(integer(Mid(t1, 25, 6)),"0")
sle_misc_6.Text = string(integer(Mid(t1, 31, 6)),"0")
sle_misc_7.Text = string(integer(Mid(t1, 37, 6)),"0")
sle_misc_8.Text = string(integer(Mid(t1, 43, 6)),"0")
sle_misc_9.Text = string(integer(Mid(t1, 49, 6)),"0")
sle_misc_10.Text = string(integer(Mid(t1, 55, 6)),"0")
sle_misc_11.Text = string(integer(Mid(t1, 61, 6)),"0")
sle_misc_12.Text = string(integer(Mid(t1, 67, 6)),"0")

clicked for cb_next

string t1

If Not ds.ReadSerialNext("@;") Then
MessageBox ("MDMDA Error", "readserialnext failed")
return
End If

sle_1.Text = ds.Item("ITEM-NO")
t1 = ds.Item("MISC")
sle_2.Text = t1
sle_misc_1.Text = string(integer(Mid(t1, 1, 6)),"0")
sle_misc_2.Text = string(integer(Mid(t1, 7, 6)),"0")
sle_misc_3.Text = string(integer(Mid(t1, 13, 6)),"0")
sle_misc_4.Text = string(integer(Mid(t1, 19, 6)),"0")
sle_misc_5.Text = string(integer(Mid(t1, 25, 6)),"0")
sle_misc_6.Text = string(integer(Mid(t1, 31, 6)),"0")
sle_misc_7.Text = string(integer(Mid(t1, 37, 6)),"0")
sle_misc_8.Text = string(integer(Mid(t1, 43, 6)),"0")
sle_misc_9.Text = string(integer(Mid(t1, 49, 6)),"0")
sle_misc_10.Text = string(integer(Mid(t1, 55, 6)),"0")
sle_misc_11.Text = string(integer(Mid(t1, 61, 6)),"0")
sle_misc_12.Text = string(integer(Mid(t1, 67, 6)),"0")

clicked for cb_previous

If Not ds.Rewind Then
MessageBox ("MDMDA Error", "rewind failed")
return
End If

clicked for cb_add

string t1

t1 = ""
t1 = t1 + string(integer(sle_misc_1.Text),"000000")
t1 = t1 + string(integer(sle_misc_2.Text),"000000")
t1 = t1 + string(integer(sle_misc_3.Text),"000000")
t1 = t1 + string(integer(sle_misc_4.Text),"000000")
t1 = t1 + string(integer(sle_misc_5.Text),"000000")
t1 = t1 + string(integer(sle_misc_6.Text),"000000")
t1 = t1 + string(integer(sle_misc_7.Text),"000000")
t1 = t1 + string(integer(sle_misc_8.Text),"000000")
t1 = t1 + string(integer(sle_misc_9.Text),"000000")
t1 = t1 + string(integer(sle_misc_10.Text),"000000")
t1 = t1 + string(integer(sle_misc_11.Text),"000000")
t1 = t1 + string(integer(sle_misc_12.Text),"000000")
ds.WriteItem("ITEM-NO",sle_1.Text)
ds.WriteItem("MISC",t1)
sle_2.Text = t1

If Not ds.Write("@;") Then
MessageBox ("MDMDA Error", "Write failed")
return
End If

Leave a Reply

Your email address will not be published. Required fields are marked *