[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 449
  • Last Modified:

powerbuilder initialize values

i want to create a function(lets call it initialize)  that will receive a data window as input (dw_imp)  and act as follows

all numeric fields of dw_imp  should be equal to 0
all string fields should be equal to '' (empty)
0
basilhs_s
Asked:
basilhs_s
  • 3
1 Solution
 
diasroshanCommented:
Hi,

Import the attached function.
Save the below contents in notepad and save as f_update_dw.srf
Import it into ur pbl.

From ur code call the function as
f_update_dw(dw_imp)

Cheers,
Rosh
$PBExportHeader$f_update_dw.srf
global type f_update_dw from function_object
end type
 
forward prototypes
global subroutine f_update_dw (datawindow arg_dw)
end prototypes
 
global subroutine f_update_dw (datawindow arg_dw);Long ll_ColCount,ll_ColNo, i
String ls_ColType, ls_ColName
 
For i = 1 to arg_Dw.RowCount()
	ll_ColCount = Long(arg_dw.Describe("Datawindow.Column.Count"))
	For ll_ColNo = 1 To ll_ColCount
		ls_ColType = arg_dw.Describe("#"+String(ll_ColNo)+".ColType")
		ls_ColName = arg_dw.Describe("#"+String(ll_ColNo)+".Name")
		Choose Case Upper(Mid(ls_Coltype,1,4))
			Case "CHAR"
				arg_dw.SetItem ( i, ls_ColName, '' )
			Case "DECI"	
				arg_dw.SetItem ( i, ls_ColName, 0 )
		End Choose	
	Next
Next
end subroutine

Open in new window

0
 
sandeep_patelCommented:
If you are not creating your datawindow dynamically then it would be better if you give Initial Value while designing the datawindow. Hence for any new row in datawindow will have the default value.

open datawindow > from menu.. view > column specifications > set 'Initial Value'

Regards,
Sandeep
0
 
basilhs_sAuthor Commented:
thanks Rosh. i will let you know if it is working
0
 
basilhs_sAuthor Commented:
Sandeep thanks for your reply. i know it but in many cases we used datawindows with a lage number of fields and we forget sometimes to give initial values to some of them
0
 
basilhs_sAuthor Commented:
i just tried it. it works perfectly.thanks
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now