Solved

Dropdowndatawindow validation.

Posted on 2006-07-20
5
570 Views
Last Modified: 2013-12-26
I have a column(Adj Reason) in Powerbuilder window, which contains a dropdown data window.
Display value is : adj_reason_desc
Data Value is : adj_reason_cd
Dropdown datawindow data source is a procedure. Data window have 3 columns like adj_reason_cd, adj_reason_desc and adj_class.
Procedure is simply getting data from bill_adj table without any input parameters.
In bill_adj table, the data is like

adj_reason_cd  adj_class  adj_reason_desc             last_update_ts            last_update_userid
500                  M             Demand Change             1/1/2006                     RS94878
501                  S             Emergency Svc                3/2/2006                    VV88777
...................
999                 M                                                    
(the last one adj_reason_desc is space)
My requirement is when ever user select space value (adj_reason_desc), I mean adj_reason_cd  is 999. I need to give access for entering some desc on that column and need to stores to the bill_adj table  as
999                 M             User entered desc            7/20/2006                   user userid

How can I insert adj_reason_desc column thru this dropdowndatawindow.

Thanks for your advance help.





0
Comment
Question by:venkat4sv
  • 3
  • 2
5 Comments
 
LVL 4

Expert Comment

by:Lordain
Comment Utility
I am going to have to make some presumptions and conclusions based on your post so may need to work through this some.

It seems like adj_reason_cd is not unique.  My question then is what makes the row unique as this will likely be required to write back to the database.

I am also going to presume you want to update the parent record and not the child.

First you will need to make the datawindow updatable and make sure the column you want to update is selected.
Next you will need to properly set the updatable properties correctly.
You need to select the columns which are updatable along with what will uniquely qualify the row.
Last you need to choose the table/view where the insert/update to take place.

Presuming this correctly...

The flaw with this is you potentially expose the other adj_reason_cd to be modified which you probably don't want to do.  I am presuming you only want a user to enter a description when the adj_reason_cd = 999.  You can accomplish this via the protect property of the control.

When you issue a dw.update( ) to the control it should accomplish what I believe you are trying to do.
0
 

Author Comment

by:venkat4sv
Comment Utility
Already the table is defined a row like adj_reason_cd is 999.
For 999, the adj_reason_desc is spaces.
From dddw, if we select space (ie, adj_reason_cd is 999) then how do we opens up a single line edit box for entering the adj_reason_desc.
If they selected space then we need to disable the dddw and forcible need to enter desc for that column (ie.,single line edit column should not be null, when selected 999), and the new column is only visible, if we select adj_reason_cd is 999.  Finally when ever we press update button, then I need to pass that adj_reason_desc (single line edit column data) for update procedure.

0
 
LVL 4

Expert Comment

by:Lordain
Comment Utility
I would do something like this if I understand you correctly.

Add the column you want to update to the dataobject.  Protect this column until the user either through the protect property or just toggle the visible property.  Looks like it is already in the same table so should be easy.

In the case of your DDDW.  I would code in the itemchanged event to make this column available and editable to the user.  If you need the syntax for this let me know.

User makes the data entry for the row and let PB handle the update for you.

This is a clean, simple, and easy to maintain method.  There would be no need to mess with single line edit columns, or passing to procedures.
0
 

Author Comment

by:venkat4sv
Comment Utility
I would appreciate if you send the syntax for  the above method.
0
 
LVL 4

Accepted Solution

by:
Lordain earned 250 total points
Comment Utility
In the dw control housing your dataobject you want to go to the itemchanged event

In this event you have access to the following information:

row      Long by value. The number of the row containing the item whose value is being changed
dwo      DWObject by value. A reference to the column containing the item whose value has been changed. Dwo is a reference to the column control, not the name of the column
data      String by value. The new data the user has specified for the item

Code:

//BEST PRACTICE WHICH ENSURE YOUR DATA IS CAPTURED

   THIS.ACCEPTTEXT( )

//DETERMINE WHICH COLUMN WAS CHANGED BY NAME

   CHOOSE CASE DWO.NAME

      Case "<dw_column_name>"  //For you it may be "Adj Reason"

//IF THE DATA MATCHES THE CONDITION DESIRED THEN

         If string(data) = '999' then

//UNPROTECT THE COLUMN YOU WANT USER TO BE ABLE TO EDIT
//NOTE: I WOULD CLICK THE COLUMN AND SET ITS PROTECT PROPERTY TO 1 TO PROTECT THEM BY DEFAULT

//SUBSTITUTE <COLUMN_NAME> WITH THE NAME OF THE COLUMN YOU WANT USER TO TYPE IN

            THIS.OBJECT.<column_name>.PROTECT = 0

         ELSE

//ENSURE THE COLUMN IS PROTECTED

            THIS.OBJECT.<column_name>.PROTECT = 1

   END CHOOSE

There ya go...
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now