Link to home
Start Free TrialLog in
Avatar of Mateen
Mateen

asked on

Generalisation of a drop down datawindow in pb7

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.

ASKER CERTIFIED SOLUTION
Avatar of namasi_navaretnam
namasi_navaretnam
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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-
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mateen
Mateen

ASKER

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 )

Avatar of Mateen

ASKER

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:
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
Avatar of Mateen

ASKER

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
https://www.experts-exchange.com/questions/20963086/Complimentary-points-for-Rosh.html
to be accepted at once.
> 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-
ignore my comment about watson error. That  is a different issue.