sql_perintah="select th"+ string(ii_tahun) +"from gaji_pokok where kd_golongan= ?"
DECLARE my_cursor DYNAMIC CURSOR FOR SQLSA;
PREPARE SQLSA FROM :sql_perintah;
OPEN DINAMIC my_cursor using :kd_golongan;
FETCH my_cursor INTO :id_tahun;
If sqlca.sqlcode = 100 then
messagebox('Informasi','data tidak ada')
End if
CLOSE my_cursor;
Tuesday, December 30, 2008
Wednesday, December 10, 2008
get datawindows
many type of data windows can use for reporting or form, Usualy for reporting you can use tabular type
get the data windows
dw_1.reset()
dw_1.retrieve() // get the datawindow ( dw_1)
dw_1.retrieve(unit,tgl_proses) //get the datawindow ( dw_1) with parameter
get the data windows
dw_1.reset()
dw_1.retrieve() // get the datawindow ( dw_1)
dw_1.retrieve(unit,tgl_proses) //get the datawindow ( dw_1) with parameter
Monday, December 1, 2008
Send Variabel to Datawindow
send variabel tertentu to data windows :
d_1.setitem( baris , 'field_datawindows ' , variabel )
contoh:
dw_1.setitem(dw_1.getrow(),'alamat',ls_alamat)
for baris = 1 to dw_1.rowcount()
dw_1.setitem(baris,'alamat',ls_alamat)
next
d_1.setitem( baris , 'field_datawindows ' , variabel )
contoh:
dw_1.setitem(dw_1.getrow(),'alamat',ls_alamat)
for baris = 1 to dw_1.rowcount()
dw_1.setitem(baris,'alamat',ls_alamat)
next
Friday, November 28, 2008
Get Field dalam datawindows Report ( Tabular )
Untuk mengambil file dari datawindows pada row model report ( tabular ) digunakan perintah
//==untuk row / abris yang sedang aktif
string ls_var1
dec lc_var2, lc_hitung
date ld_var3
datetime ldt_var4
int baris
dw_1.retrieve() //==mengambil data
for baris = 1 to dw_1.rowcount()
ls_var1 = dw_1.getitemstring(baris,'field1')
lc_var2 = dw_1.getitemnumber(baris,'field2')
ld_var3 = dw_1.getitemdate(baris,'field3')
ldt_var4 = dw_1.getitemdatetime(baris,'field4')
//===hitung
lc_hitung = lc_var2 * 100
next
//==untuk row / abris yang sedang aktif
string ls_var1
dec lc_var2, lc_hitung
date ld_var3
datetime ldt_var4
int baris
dw_1.retrieve() //==mengambil data
for baris = 1 to dw_1.rowcount()
ls_var1 = dw_1.getitemstring(baris,'field1')
lc_var2 = dw_1.getitemnumber(baris,'field2')
ld_var3 = dw_1.getitemdate(baris,'field3')
ldt_var4 = dw_1.getitemdatetime(baris,'field4')
//===hitung
lc_hitung = lc_var2 * 100
next
Get Data Windows Variable ( get field )
get the row of datawindows we can use this sintaks:
string ls_var1
dec lc_var2
date ld_var3
datetime ldt_var4
ls_var1 = dw_1.getitemstring(dw_1.getrow(),'field1')
lc_var2 = dw_1.getitemnumber(dw_1.getrow(),'field2')
ld_var3 = dw_1.getitemdate(dw_1.getrow(),'field3')
ldt_var4 = dw_1.getitemdatetime(dw_1.getrow(),'field4')
string ls_var1
dec lc_var2
date ld_var3
datetime ldt_var4
ls_var1 = dw_1.getitemstring(dw_1.getrow(),'field1')
lc_var2 = dw_1.getitemnumber(dw_1.getrow(),'field2')
ld_var3 = dw_1.getitemdate(dw_1.getrow(),'field3')
ldt_var4 = dw_1.getitemdatetime(dw_1.getrow(),'field4')
Thursday, November 27, 2008
Declaring Variable
To declare a variable, you first type in the data type followed by the name of variable. You can also assign the variable a default value by makin the name equal to appropriate value
Integer il_var_sex
Long ll_salary = 1000000
Date ld_daytogo
Date startdate = 1995-03-01
Integer il_var_sex
Long ll_salary = 1000000
Date ld_daytogo
Date startdate = 1995-03-01
Data Types
PowerBuilder can handle many diffrent types of data. A few of the standart data type are given below:
Boolean -> True or False
Integer / Int -> 16 bit signed integer from -32768 to 32768. Whole number is not decimal points
Long -> 32 bit signed interger from -2.147.483.648 to 2.147.483.648 it is the same as an integer
String->This data type hold between 0 - 60.000 ASCII character
Blop -> A Binary Large Object can be use for extreme large data item
Datetime -> The date and time store as a single data
Dec -> These are signed decimal number with up to 18 digits
Dauble/Real -> The data types used to store very larger or very small number
Date -> Define variable as date
Boolean -> True or False
Integer / Int -> 16 bit signed integer from -32768 to 32768. Whole number is not decimal points
Long -> 32 bit signed interger from -2.147.483.648 to 2.147.483.648 it is the same as an integer
String->This data type hold between 0 - 60.000 ASCII character
Blop -> A Binary Large Object can be use for extreme large data item
Datetime -> The date and time store as a single data
Dec -> These are signed decimal number with up to 18 digits
Dauble/Real -> The data types used to store very larger or very small number
Date -> Define variable as date
Wednesday, November 26, 2008
Gretting Aplication
Gretting for every day
ll_jam = hour(now()) * 3600 + minute(now()) * 60 + second(now())
CHOOSE CASE ll_jam
CASE IS <>
ls_slm = 'Selamat Pagi' // good morning
CASE 39601 to 54000
ls_slm = 'Selamat Siang' // good afternoon
CASE 54001 to 64800
ls_slm = 'Selamat Sore' // good evening
CASE ELSE
ls_slm = 'Selamat Malam' // good night
END CHOOSE
ll_jam = hour(now()) * 3600 + minute(now()) * 60 + second(now())
CHOOSE CASE ll_jam
CASE IS <>
ls_slm = 'Selamat Pagi' // good morning
CASE 39601 to 54000
ls_slm = 'Selamat Siang' // good afternoon
CASE 54001 to 64800
ls_slm = 'Selamat Sore' // good evening
CASE ELSE
ls_slm = 'Selamat Malam' // good night
END CHOOSE
Tuesday, November 25, 2008
Open Window with parameter
when you call (open) the windows search in main windows and want to return variable you can use this script
string ls_parm
if keydown(KeyF1!) then
OpenWithParm( w_search, ls_parm, parent)
ls_parm = Message.StringParm
this.SetText(ls_parm)
end if
string ls_parm
if keydown(KeyF1!) then
OpenWithParm( w_search, ls_parm, parent)
ls_parm = Message.StringParm
this.SetText(ls_parm)
end if
Using Enter Key
Default moving between field or column is “tab key” if you want to change the movement with “enter key” you can use this script. First you can make custom data window even ( even id : pbm_dwnprocessenter even name : rowenter return variable : long an then you can use this script for data windows and using “enter key” to move pointer between field.
Send(Handle(This), 256, 9, Long(0, 0))
Message.Processed = TRUE
Message.ReturnValue = 1
Tuesday, October 28, 2008
Windows Search
If you want to make windows seacrh with user object control you can use windows object and put the user object control in centre of the windows and then you can use single line edit for search the word and so the button for execute. if you use this windows design you can use this script and put into this script in user event.
// Entry_Chosen Script for UO_1
string ls_selected_value,ls_ret
ls_selected_value = left(return_selected (),6)
if Len (ls_selected_value) = 0 then
RETURN
END IF
// ls_selected_value = "Nothing"
ls_ret = trim(ls_selected_value)
CloseWithReturn(parent,ls_ret)
Monday, October 6, 2008
Using User Event ( ue_add) to define or adding rows
I usually use this script in windows ancestor by define custom event ( user event), this script prepare the windows for adding rows
If dw_1.AcceptText() = -1 then
MessageBox('Message','Header not complete...')
return
end if
dw_1.enabled=true
dw_1.Object.DataWindow.ReadOnly = false
If (dw_1.modifiedcount() > 0 Or dw_1.deletedCount() > 0) and &
imn_mymenu.m_file.m_save.enabled then
if messagebox("Informasi","Data harus disimpan terlebih "+&
"dahulu...Simpan?", Question!,YesNo!,2) = 1 then
triggerevent("ue_save")
end if
end if
dw_1.reset()
dw_1.scrolltorow(dw_1.insertrow(0))
if hdr_autoinc = true then
header_id ++
dw_1.SetItem(dw_1.GetRow(),hdr_pk1,header_id)
dw_1.SetTabOrder(hdr_pk1,0)
dw_1.SetColumn(hdr_set)
Else
dw_1.SetTabOrder(hdr_pk1,10)
If hdr_pk2 <> '' then
dw_1.SetTabOrder(hdr_pk2,20)
End if
If hdr_pk3 <> '' then
dw_1.SetTabOrder(hdr_pk3,30)
End if
dw_1.SetColumn(hdr_pk1)
dw_1.SetFocus()
End if
ibl_add = true
If dw_1.AcceptText() = -1 then
MessageBox('Message','Header not complete...')
return
end if
dw_1.enabled=true
dw_1.Object.DataWindow.ReadOnly = false
If (dw_1.modifiedcount() > 0 Or dw_1.deletedCount() > 0) and &
imn_mymenu.m_file.m_save.enabled then
if messagebox("Informasi","Data harus disimpan terlebih "+&
"dahulu...Simpan?", Question!,YesNo!,2) = 1 then
triggerevent("ue_save")
end if
end if
dw_1.reset()
dw_1.scrolltorow(dw_1.insertrow(0))
if hdr_autoinc = true then
header_id ++
dw_1.SetItem(dw_1.GetRow(),hdr_pk1,header_id)
dw_1.SetTabOrder(hdr_pk1,0)
dw_1.SetColumn(hdr_set)
Else
dw_1.SetTabOrder(hdr_pk1,10)
If hdr_pk2 <> '' then
dw_1.SetTabOrder(hdr_pk2,20)
End if
If hdr_pk3 <> '' then
dw_1.SetTabOrder(hdr_pk3,30)
End if
dw_1.SetColumn(hdr_pk1)
dw_1.SetFocus()
End if
ibl_add = true
Change Data Window and Drop Down Data Window with Radio Button
If you want to change data window and drop down data window using sintax in any radio button or else with even click by that , you can using this script for that before you retriving data, this script usually using in the many reporting.
dw_2.dataobject = 'dw_drop_down'
dw_1.dataobject = 'dw_report'
dw_2.settransobject(sqlca)
dw_1.settransobject(sqlca)
DataWindowChild ldw_child1
dw_2.GetChild('uk', ldw_child1)
ldw_child1.SetTransObject(SQLCA)
ldw_child1.Retrieve()
dw_2.dataobject = 'dw_drop_down'
dw_1.dataobject = 'dw_report'
dw_2.settransobject(sqlca)
dw_1.settransobject(sqlca)
DataWindowChild ldw_child1
dw_2.GetChild('uk', ldw_child1)
ldw_child1.SetTransObject(SQLCA)
ldw_child1.Retrieve()
Friday, September 26, 2008
Happy Ied Day 1429 H
Minal Aidzin Wal Faidzin, Please Forgive all of my mistakes with all your heart, and we will be meet again after ied holliday with many script in SCRIPTROOM blog
Wednesday, September 24, 2008
Power Builder - Script for using Horizontal ProgressBar Control
If you want to use Horizontal ProgressBar Control for many process, you can following this sintax
hpb_1.SetRange(0, li_row)
hpb_1.SetStep = 1
ll_start = cpu()
for i = 1 to li_row
hpb_1.offsetpos(1)
st_100.Text = string(round( i / li_row * 100, 0) ) + '%'
............ ( sintax )
............ ( sintax )
ll_used = cpu() - ll_start
st_time.Text = string( RelativeTime(Time(0,0,0), ll_used / 1000), 'hh:mm:ss')
next
hpb_1.SetRange(0, li_row)
hpb_1.SetStep = 1
ll_start = cpu()
for i = 1 to li_row
hpb_1.offsetpos(1)
st_100.Text = string(round( i / li_row * 100, 0) ) + '%'
............ ( sintax )
............ ( sintax )
ll_used = cpu() - ll_start
st_time.Text = string( RelativeTime(Time(0,0,0), ll_used / 1000), 'hh:mm:ss')
next
Power Builder - Get Current Directory
We can get current active directory of application , the output of variable is string.
string ls_temp
ulong lul_value
boolean lb_rc
lul_value = 255
ls_temp = space(255)
lb_rc = GetCurrentDirectoryA( lul_value,ls_temp)
If lb_rc Then sle_path.text=ls_temp
string ls_temp
ulong lul_value
boolean lb_rc
lul_value = 255
ls_temp = space(255)
lb_rc = GetCurrentDirectoryA( lul_value,ls_temp)
If lb_rc Then sle_path.text=ls_temp
Tuesday, September 23, 2008
Power Bulider 7 - Manage Database Console
you can use profile ( native / odbc) to connect database and then manage table to create / modify evey each property of tables
Power Builder - Adding Table for ASA Database
//===adding table for ASA database=======
select count(*) into :li_table from systable where table_name = upper('saldo_rekmtr');
if li_table = 0 then
ls_add = 'CREATE TABLE "dba"."saldo_rekmtr" ' +&
'("kd_unit" char(5) NOT NULL DEFAULT NULL,' +&
'"rek" varchar(9) NOT NULL DEFAULT NULL, ' +&
'PRIMARY KEY ("kd_unit"")) ;'
execute immediate :ls_add;
ls_idx = 'CREATE UNIQUE INDEX "idx_saldorekmtr" ON "dba"."saldo_rekmtr" ' +&
'("kd_unit") ;'
execute immediate :ls_idx;
end if
select count(*) into :li_table from systable where table_name = upper('saldo_rekmtr');
if li_table = 0 then
ls_add = 'CREATE TABLE "dba"."saldo_rekmtr" ' +&
'("kd_unit" char(5) NOT NULL DEFAULT NULL,' +&
'"rek" varchar(9) NOT NULL DEFAULT NULL, ' +&
'PRIMARY KEY ("kd_unit"")) ;'
execute immediate :ls_add;
ls_idx = 'CREATE UNIQUE INDEX "idx_saldorekmtr" ON "dba"."saldo_rekmtr" ' +&
'("kd_unit") ;'
execute immediate :ls_idx;
end if
Power Builder - Adding Table Sintax
//===if using oracle you can use this sintax for adding table===
Select count(*) Into :ll_adabaris from user_tables
Where lower(table_name) = 'debitur' ;
IF sqlca.sqlcode = 100 or ll_adabaris = 0 Then
ls_sql = "create table sample_b.debitur (kar_nik char(6) not null, kd_kredit char(5) not null, no_setuju varchar2(25) not null, tgl_setuju date, keterangan1 varchar2(25)," +&
"primary key ( kar_nik, kd_kredit, no_setuju ))"
Execute immediate :ls_sql ;
IF sqlca.sqlcode <> 0 Then
Beep(1)
MessageBox('Information', "must add table...")
Return
End IF
End IF
Select count(*) Into :ll_adabaris from user_tables
Where lower(table_name) = 'debitur' ;
IF sqlca.sqlcode = 100 or ll_adabaris = 0 Then
ls_sql = "create table sample_b.debitur (kar_nik char(6) not null, kd_kredit char(5) not null, no_setuju varchar2(25) not null, tgl_setuju date, keterangan1 varchar2(25)," +&
"primary key ( kar_nik, kd_kredit, no_setuju ))"
Execute immediate :ls_sql ;
IF sqlca.sqlcode <> 0 Then
Beep(1)
MessageBox('Information', "must add table...")
Return
End IF
End IF
Monday, September 22, 2008
Today For All
Today I will begin write about all of my experiences of carrying out the production of the application by using the programming language that was involved in by me from the start of me began to at this time. this blog will contain about production discussions of the application of the based programming power builder or other, i hope this writing could use for the world and was useful to world goodness to help all humankind so that this life is better and useful. Special thanks for my whole friend who was support for All this became the reality..
Power Builder - MySQL connectiom Database Sintax
// Profile connection with MYSQL Database sintax
SQLCA.DBMS = "ODBC"
SQLCA.AutoCommit = false
SQLCA.DBParm = "ConnectString='DSN=sdmlocal;UID=root;PWD=mount8860;OPTION=135168',DisableBind=1,StaticBind=0,PBUseProcOwner=NO"
SQLCA.DBMS = "ODBC"
SQLCA.AutoCommit = false
SQLCA.DBParm = "ConnectString='DSN=sdmlocal;UID=root;PWD=mount8860;OPTION=135168',DisableBind=1,StaticBind=0,PBUseProcOwner=NO"
Power Builder - Oracle Database Connection Sintax
The oracle ('big size') database can connect with native, we can using two ways to connection as i know off course
// Profile
SQLCA.DBMS = "O84 ORACLE 8.0.4"
SQLCA.LogPass = 'password'
SQLCA.ServerName = "server"
SQLCA.LogId = "hrd1"
SQLCA.AutoCommit = False
SQLCA.DBParm = "PBCatalogOwner='hrd1'
//Profile using INI file setting
SetPointer(HourGlass!)
SQLCA.DBMS =ProfileString("XXX.INI","Database","DBMS", " ")
SQLCA.Database =ProfileString("XXX.INI","Database","DataBase", " ")
SQLCA.LogID =ProfileString("XXX.INI","Database","LogID", " ")
SQLCA.LogPass =ProfileString("XXX.INI","Database","LogPassword", " ")
SQLCA.ServerName =ProfileString("XXX.INI","Database","ServerName", " ")
SQLCA.UserID =ProfileString("XXX.INI","Database","UserID", " ")
SQLCA.DBPass =ProfileString("XXX.INI","Database","DatabasePassword", " ")
SQLCA.Lock =ProfileString("XXX.INI","Database","Lock", " ")
SQLCA.DbParm =ProfileString("XXX.INI","Database","DbParm", " ")
connect;
if sqlca.sqlcode <> 0 then
messagebox("Error Connection",sqlca.sqlerrtext)
exit
else
open(w_login)
end if
XXX.ini ( INI file)
[siop]
DBMS=O84 ORACLE 8.0.4
Database=
UserId=
ServerName=server
LogId=hrd1
Lock=
DbParm=PBCatalogOwner='hrd1'
// Profile
SQLCA.DBMS = "O84 ORACLE 8.0.4"
SQLCA.LogPass = 'password'
SQLCA.ServerName = "server"
SQLCA.LogId = "hrd1"
SQLCA.AutoCommit = False
SQLCA.DBParm = "PBCatalogOwner='hrd1'
//Profile using INI file setting
SetPointer(HourGlass!)
SQLCA.DBMS =ProfileString("XXX.INI","Database","DBMS", " ")
SQLCA.Database =ProfileString("XXX.INI","Database","DataBase", " ")
SQLCA.LogID =ProfileString("XXX.INI","Database","LogID", " ")
SQLCA.LogPass =ProfileString("XXX.INI","Database","LogPassword", " ")
SQLCA.ServerName =ProfileString("XXX.INI","Database","ServerName", " ")
SQLCA.UserID =ProfileString("XXX.INI","Database","UserID", " ")
SQLCA.DBPass =ProfileString("XXX.INI","Database","DatabasePassword", " ")
SQLCA.Lock =ProfileString("XXX.INI","Database","Lock", " ")
SQLCA.DbParm =ProfileString("XXX.INI","Database","DbParm", " ")
connect;
if sqlca.sqlcode <> 0 then
messagebox("Error Connection",sqlca.sqlerrtext)
exit
else
open(w_login)
end if
XXX.ini ( INI file)
[siop]
DBMS=O84 ORACLE 8.0.4
Database=
UserId=
ServerName=server
LogId=hrd1
Lock=
DbParm=PBCatalogOwner='hrd1'
Subscribe to:
Posts (Atom)