Solved

Generalisation of a drop down datawindow in pb7

Posted on 2004-04-21
9
797 Views
Last Modified: 2013-12-26
Follwoing is an exportable version of a dropdown datawindow namely 'dddw_user_id' created in pb7

$PBExportHeader$dddw_user_id.srd
$PBExportComments$security
release 7;
datawindow(units=0 timer_interval=0 color=16777215 processing=1 HTMLDW=no print.documentname="" print.orientation = 0 print.margin.left = 110 print.margin.right = 110 print.margin.top = 96 print.margin.bottom = 96 print.paper.source = 0 print.paper.size = 0 print.prompt=no print.buttons=no print.preview.buttons=no grid.lines=0 )
header(height=92 color="536870912" )
summary(height=0 color="536870912" )
footer(height=0 color="536870912" )
detail(height=88 color="536870912" )
table(column=(type=char(6) update=yes updatewhereclause=yes key=yes name=user_id dbname="password.user_id" )
 column=(type=char(2) updatewhereclause=yes name=company_code dbname="password.company_code" )
 column=(type=char(10) updatewhereclause=yes name=apps_name dbname="password.apps_name" )
 retrieve="  SELECT password.user_id,  
         password.company_code,  
         password.apps_name  
    FROM password
where company_code = '02'
and apps_name = 'packing'  
" update="password" updatewhere=1 updatekeyinplace=no )
text(band=header alignment="2" text="User Id" border="0" color="0" x="9" y="8" height="76" width="416"  name=user_id_t  font.face="Arial" font.height="-8" font.weight="400"  font.family="2" font.pitch="2" font.charset="0" background.mode="2" background.color="26845365" )
column(band=detail id=1 alignment="0" tabsequence=10 border="0" color="0" x="9" y="8" height="72" width="416" format="[general]"  name=user_id edit.limit=6 edit.case=any edit.focusrectangle=no edit.autoselect=yes edit.autohscroll=yes  font.face="Arial" font.height="-8" font.weight="400"  font.family="2" font.pitch="2" font.charset="0" background.mode="1" background.color="536870912" )
column(band=detail id=2 alignment="0" tabsequence=0 border="0" color="0" x="439" y="0" height="56" width="594"  name=company_code  font.face="Arial" font.height="-8" font.weight="400"  font.family="2" font.pitch="2" font.charset="0" background.mode="1" background.color="536870912" )
text(band=header alignment="0" text="Company Code" border="0" color="0" x="434" y="4" height="76" width="599"  font.face="Arial" font.height="-12" font.weight="400"  font.family="2" font.pitch="2" font.charset="0" background.mode="2" background.color="16777215" )
column(band=detail id=3 alignment="0" tabsequence=0 border="0" color="0" x="1047" y="0" height="56" width="690"  name=apps_name  font.face="Arial" font.height="-8" font.weight="400"  font.family="2" font.pitch="2" font.charset="0" background.mode="1" background.color="536870912" )
text(band=header alignment="0" text="Apps Name" border="0" color="0" x="1042" y="4" height="76" width="695"  font.face="Arial" font.height="-12" font.weight="400"  font.family="2" font.pitch="2" font.charset="0" background.mode="2" background.color="16777215" )
htmltable(border="1" )
htmlgen(clientevents="1" clientvalidation="1" clientcomputedfields="1" clientformatting="0" clientscriptable="0" generatejavascript="1" )


The sql select of the above dd is

SELECT password.user_id,  
         password.company_code,  
         password.apps_name  
    FROM password
where company_code = '02'
and apps_name = 'packing'  

This dd is associated in a window 'w_user_group'

I have never created dd at runtime and want to create now in the open event(or any right event suggested by dear experts) of the window.

I want to do so because I have enough apps_names and enough company_codes. At runtime my system knows the values of
company_code in global variable gs_company_code and apps_name in gs_apps_name and at runtime creation of dd
I want to  change the line
where company_code = '02'
and apps_name = 'packing'
with
where company_code = value of global variable gs_company_code
and apps_name = value of global vairable of gs_apps_name.

SECOND ASPECT/METHOD MAY BE:
If I write the sql this way
SELECT password.user_id,  
         password.company_code,  
         password.apps_name  
    FROM password
where company_code = :ra_company_code
and apps_name = :ra_apps_name

and control it through datawindow child then again I know this technique for one retrieval argument and I don't know
how to do this for two retrieval arguments.

Points will be awarded 500 each for both method.

Mateen:

There may be third aspect also and that is filtration line.
Thd dd may be retieved and then set filter with the values of gs_company_code and gs_apps_name.

0
Comment
Question by:Mateen
  • 4
  • 3
  • 2
9 Comments
 
LVL 15

Accepted Solution

by:
namasi_navaretnam earned 350 total points
Comment Utility
There are few ways...

You can try this in the constructor event of datawindow control.

Method 1:
string ls_sql
datawindowchild ldw_child
ls_sql = " SELECT password.user_id,    " + &
         " password.company_code,    " + &
         " password.apps_name " + &
         "  FROM password  "  + &
         " where company_code = '" +gs_company_code + "'" +  &
         " and apps_name = '" + gs_apps_name + "'"  

dw_1.GetChild('yourcolumnname', ldw_child)
ldw_child.SetSQLSelect(ls_sql)
ldw_child.SetTransObject(SQLCA)
ldw_child.Retrieve()

Method 2:
datawindowchild ldw_child
dw_1.GetChild('yourcolumnname', ldw_child)
ldw_child.SetTransObject(SQLCA)
ldw_child.Retrieve(gs_company_code , gs_apps_name )


Method 3:
You can also use SyntaxFromSQL, Create functions to create dw dynamically.

Pls let us know if you need further help...

regards-










0
 
LVL 15

Expert Comment

by:namasi_navaretnam
Comment Utility
If you need to see if dddw is associated with a column, you can try

string ls_desc, ls_dddwname
long ll_cc, ll_rc, ll_i

ll_cc = long(dw_1.Describe("Datawindow.column.count"))

for ll_i = 1 to ll_cc
    ls_desc = "#" + string(ll_i) + ".DDDW.Name"
    ls_dddwname = dw_1.Describe(ls_desc)


    if ls_dddwname = '?' then
       // column does not have dddw associated
    else
       // column has dddw associated
    end if    
next      
regards-
0
 
LVL 18

Assisted Solution

by:diasroshan
diasroshan earned 150 total points
Comment Utility
hi mateen,

u can define ur dddw at runtime as follows....
..write this code in the open event...

datawindowchild dwc

dw_2.object.<column name>.dddw.name ='dddw_user_id'
dw_2.object.<column name>.dddw.displaycolumn = '<ur displaycolumn name>'
dw_2.object.field_value.dddw.datacolumn = '<ur datacolumn name>'

dw_2.getchild("<column name>",dwc)
dwc.SetTransObject(sqlca);
if dwc.Retrieve(gs_company_code,gs_apps_name) = 0 Then dwc.InsertRow(0)  // if retrieve finds no rows retrieved then it insert a row so that at runtime argument window is not prompted


... u can pass as many retieval arguments u like in the datawindowchild provided u have declared those many in ur dddw creation (dddw_user_id)...

...this should solve ur problem...

Cheers,
Rosh
0
 

Author Comment

by:Mateen
Comment Utility
Hi experts :
I was confusing in
dw_1.GetChild('yourcolumnname', ldw_child)
and was wrongly thinking how to replace 'yourcolumnname' with two columns/arguments.

The best and simplest is

Method 2:
datawindowchild ldw_child
dw_1.GetChild('yourcolumnname', ldw_child)
ldw_child.SetTransObject(SQLCA)
ldw_child.Retrieve(gs_company_code , gs_apps_name )

0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:Mateen
Comment Utility
Hi Namasi:

as suggested I wrote in the open event.

datawindowchild dwc
dw_detail.GetChild('user_name', dwc)
dwc.SetTransObject(SQLCA)
IF dwc.Retrieve(gs_company_code , gs_apps_name ) = 0 THEN
      dwc.insertrow(0)
end if

and it worked.

But after saving one record it didn't work because after dw_detail.update() my system do dw_detail.reset()
So I wrote the same line in Extend Ancestor Script of ue_new (in my system for inserting new record). and it
worked.

But when I queried and retrieved and went to a particular record then again failed.
So I wrote the same line in the itemchanged event which worked with one defect and that is my dw_detail contains only one column 'user_id' and a copy of user_id renamed with 'user_name' and this name is  associated with dd.  When I enter in user_id and then click the arrow of dd it shows values but when I directly click the arrow key of dd it doesn't show any values (may be itemchanged event doesn't fire on mouse click)

Dear Namasi, I have written so lengthy just to make u understand what is my problem now and so far I have failed to find out any event of pb which may avoid these duplications.

Please suggest although the answer has been accepted.

Thanks in Advance:
Mateen:
0
 
LVL 18

Expert Comment

by:diasroshan
Comment Utility
hi mateen,

itemchanged only triggers when u make any change in the values...only clicking with the mouse on the arrow will not trigger itemchanged....

try writing the code in getfocus event or clicked event of the datawindow...

datawindowchild dwc
dw_detail.GetChild('user_name', dwc)
dwc.SetTransObject(SQLCA)
IF dwc.Retrieve(gs_company_code , gs_apps_name ) = 0 THEN
     dwc.insertrow(0)
end if

...if this doesn't work let me know...i'd help...

Cheers,
Rosh
0
 

Author Comment

by:Mateen
Comment Utility
Hi Rosh:

Thanks

I deleted the codes from every events and wrote in getfocus event of dw and it is working nicely.

Please given any cooment for
http://www.experts-exchange.com/Programming/Programming_Languages/PowerBuilder/Q_20963086.html
to be accepted at once.
0
 
LVL 15

Expert Comment

by:namasi_navaretnam
Comment Utility
> I deleted the codes from every events and wrote in getfocus event of dw and it is working nicely.
Do you have code to delete from dd in every other event? That is not a good thing. That may be reason why you get watson error you have posted.

To avoid dups try this:

datawindowchild ldw_child
dw_1.GetChild('yourcolumnname', ldw_child)
ldw_child.SetTransObject(SQLCA)
ldw_child.reset()
ldw_child.Retrieve(gs_company_code , gs_apps_name )

regards-
0
 
LVL 15

Expert Comment

by:namasi_navaretnam
Comment Utility
ignore my comment about watson error. That  is a different issue.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In our object-oriented world the class is a minimal unit, a brick for constructing our applications. It is an abstraction and we know well how to use it. In well-designed software we are not usually interested in knowing how objects look in memory. …
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org (http://seleniumhq.org) Go to that link and select download selenium in the right hand columnThat will then direct you to their downlo…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

772 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

15 Experts available now in Live!

Get 1:1 Help Now