Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

powerbuilder initialize values

Posted on 2009-04-08
5
Medium Priority
?
441 Views
Last Modified: 2013-12-26
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
Comment
Question by:basilhs_s
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 18

Accepted Solution

by:
diasroshan earned 2000 total points
ID: 24104985
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
 
LVL 14

Expert Comment

by:sandeep_patel
ID: 24107466
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
 

Author Comment

by:basilhs_s
ID: 24110521
thanks Rosh. i will let you know if it is working
0
 

Author Comment

by:basilhs_s
ID: 24111741
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
 

Author Closing Comment

by:basilhs_s
ID: 31568173
i just tried it. it works perfectly.thanks
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question