Normal Topic @XLookUpStatement Not Working (Read 2411 times)
NHUser
Full Member
***
Offline



Posts: 320
Location: Amherst, NH
Joined: Aug 2nd, 2010
@XLookUpStatement Not Working
Mar 9th, 2012 at 8:17pm
Print Post Print Post  
I'm pulling my hair out trying to get an @XLookUpSourceList statement to work.  I've used them before but i don't understand why this one doesn't work!

See the programming below.

I'm trying to get a variable from the operator that I've assigned vPartNumber.  I can tell this is working with the writeln statements.  However, there is no data from the @XLookUpSourceList command.

I've attached a photo of the menu tree of my application for your info.

Any suggestions would be a big help.




Var vReturnVal1 as string
Var vPartNumber as string
Var i as Int
Var vOutputFile as String
Var vFileHandle as Int         
Var vData as String   
Var vNames as string      
var vPFStatement1 as string
var vPFStatement2 as string
var vPFStatement3 as string
var vPFStatement4 as string
var vPFStatement5 as string
var vPFStatement6 as string
var vPFStatement7 as string
var vPFStatement8 as string
var vPFStatement9 as string
var vPFStatement10 as string
var vPFStatement11 as string
var vPFStatement12 as string
var vPFStatement13 as string
var vPFStatement14 as string
var vPFStatement15 as string



Function CleanData(vData as String) as String

     vData = @Replace(vData, @Newline(), "  ")
     vData = @Replace(vData, @Chr(34), @Chr(39) + @Chr(39)  )
     vData = @Replace(vData, @Chr(255), "" )
     Return(vData)

END Function

// GET DC NUMBER FROM THE OPERATOR
     
vPartNumber=@PromptForUserInput("PLEASE ENTER A DC NUMBER.","")

writeln("XX";vPartNumber;"XX")

// GET INFO FROM WORK INSTRUCTION FILE


vReturnVal1 = @XLookupSourceList(@Fn,vPartNumber,"newprocs!NEWPROCS!DIACOM P\N", "ELASTOMER#;PFStatement2;PFStatement3;PFStatement4;PFStatement5")

writeln(vPartNumber,vReturnVal1)

vPFStatement1 = @AccessStringArray (vreturnVal1, 1)
vPFStatement2 = @AccessStringArray (vreturnVal1, 2)
vPFStatement3 = @AccessStringArray (vreturnVal1, 3)
vPFStatement4 = @AccessStringArray (vreturnVal1, 4)
vPFStatement5 = @AccessStringArray (vreturnVal1, 5)

//PFStatement15 = @AccessStringArray (vreturnVal1, 15)



WriteLN(">>>> ";vPFStatement1, vPFStatement2,vPFStatement3,vPFStatement4,vPFStatement5)


  

Sesame1_001.jpg ( 47 KB | 60 Downloads )
Sesame1_001.jpg
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: @XLookUpStatement Not Working
Reply #1 - Mar 9th, 2012 at 8:40pm
Print Post Print Post  
I don't think you need the database name as this is not a XResultSet call. Try this:

vReturnVal1 = @XLookupSourceList(@Fn,vPartNumber,"NEWPROCS!DIACOM P\N", "ELASTOMER#;PFStatement2;PFStatement3;PFStatement4;PFStatement5")
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
NHUser
Full Member
***
Offline



Posts: 320
Location: Amherst, NH
Joined: Aug 2nd, 2010
Re: @XLookUpStatement Not Working
Reply #2 - Mar 9th, 2012 at 8:54pm
Print Post Print Post  
Thanks, but I tried that already and it didn't work either.  Is my variable the problem?
  
Back to top
 
IP Logged
 
Hammer
YaBB Administrator
Lanticans
*****
Offline


Fire bad. Tree pretty.

Posts: 3436
Location: Ohio
Joined: Nov 22nd, 2002
Re: @XLookUpStatement Not Working
Reply #3 - Mar 9th, 2012 at 9:12pm
Print Post Print Post  
NHUser wrote on Mar 9th, 2012 at 8:54pm:
Thanks, but I tried that already and it didn't work either.  Is my variable the problem?

Depends on where it's failing. You need to put some debug in.

Is vPartNumber valid?
Is there a record matching vPartNumber in the external database?
Are all the element names in your return list spelled correctly?
Is @Error getting set?
  

- Hammer
The plural of anecdote is not data.
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: @XLookUpStatement Not Working
Reply #4 - Mar 10th, 2012 at 6:58am
Print Post Print Post  
Quote:
vReturnVal1 = @XLookupSourceList(@Fn,vPartNumber,"newprocs!NEWPROCS!DIACOM P\N", "ELASTOMER#;PFStatement2;PFStatement3;PFStatement4;PFStatement5")

writeln(vPartNumber,vReturnVal1)


I had struggled a beat in the past with @XLookupSourceList( ) command but it is such an efficient one that you are better off dealing with it instead of making endless @XLookup ( ) commands and opening up the lookup database that many times instead of just one time with @XLookupSourceList( ) command.

My experience tells me it is a problem with the string 99% of the time when simple @xlookup ( ) command is working with the same key value. The way I test the string is as follows: 

vReturnVal1 = @XLookupSourceList(@Fn,vPartNumber,"NEWPROCS!DIACOM P\N", "ELASTOMER#") //;PFStatement2;PFStatement3;PFStatement4;PFStatement5")
WriteLN (vReturnVal1)

If that works fine, add one more to string and see..

vReturnVal1 = @XLookupSourceList(@Fn,vPartNumber,"NEWPROCS!DIACOM P\N", "ELASTOMER#;PFStatement2" )//;PFStatement3;PFStatement4;PFStatement5")

WriteLN (vReturnVal1)

If that works fine then...

vReturnVal1 = @XLookupSourceList(@Fn,vPartNumber,"NEWPROCS!DIACOM P\N", "ELASTOMER#;PFStatement2;PFStatement3") //;PFStatement4;PFStatement5")

WriteLN (vReturnVal1)

This way you will find the culprit in the string, the last added one is the culprit, check the spelling, semicolon, closing quotes, etc.
  
Back to top
 
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: @XLookUpStatement Not Working
Reply #5 - Mar 10th, 2012 at 7:17am
Print Post Print Post  
Also it could be a problem with the WriteLN ( ) you are using...
You used:
writeln(vPartNumber,vReturnVal1)

I believe, it is looking for variable vPartNumber,vReturnVal1  ,  that is not there. Instead try using the following

WriteLn ("PartNumber = " + vPartnumber + @NL ( ) + "String = " + vvReturnVal1 )

I could be wrong on this but I am sure esteemed Lanticans will kindly correct me if I am wrong.

« Last Edit: Mar 10th, 2012 at 2:49pm by Bharat_Naik »  
Back to top
 
IP Logged
 
tcgeo
Full Member
***
Offline



Posts: 278
Location: Traverse City, Michigan
Joined: May 13th, 2008
Re: @XLookUpStatement Not Working
Reply #6 - Mar 10th, 2012 at 12:49pm
Print Post Print Post  
Erika asked if all element names are spelled correctly, you may want to check for any spaces after your element names. This is how it happens to me, I sometimes adjust the label with spaces to move the text further away from the field, I should be doing this in the Property Editors Label field. For whatever reason, I’m not paying attention and do it in the Property Editors Name field instead, adding unwanted spaces for the name. Not giving it another thought, I don’t go back and remove the spaces, that’s when @XLookupSourceList( ) stops working.

  
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: @XLookUpStatement Not Working
Reply #7 - Mar 10th, 2012 at 3:22pm
Print Post Print Post  
tcgeo made an excellent point. Also there should not be semicolon at the end of the string. With earlier version semicolon at the end was tolerated but the later version is strict about this.

Also, Label is very conspicuous but element name and fieldName that are respectively used in @Xlookup ( ) and @XResultset ( ) commands are hidden or at least not that obvious. To look at all of them at once, use the following code using command button to display the Form and Database structure and the printout of which will be extremely helpful while debugging the code.

Code
Select All
var vList as String
var vLine as String
var n as Int
var vDelimit as String = ";"
var vTotal as Int
var vElement as String
var i as Int
var vName as String
var vCount as Int


WriteLn ( "Application Name is " + @application)
WriteLn ( "Database Name is " + @Database)
WriteLn ( "Layout (Form) Name is " + @layout)
vTotal = @NumberofElements( )
WriteLn ("There are " + vTotal + " Number of Elements in " + @layout + " layout")

Vlist = @stringArrayElementList( )
WriteLn (VList)

WriteLn ("ElementName              " + "Element BoundTo       "   + "Label               " + "BoundToType" )
WriteLn (@text (80, "="))


VLine = ""

/*

//WriteLn (vList)
        For i = 1 to vTotal


                vElement = Split (vList, vDelimit)
                vLine = vElement + @text (24 - @len (vElement), " ") +
                @ElementBoundTo (@(vElement)) + @text (20 - @len (@ElementBoundTo (@(vElement))), " ") +
                @Label (@(vElement)) +  @text ( 20 - @Len (@Label (@(vElement))), " ") +
                @ElementBoundToType(@(vElement))
                WriteLn (vLine)
                    //WriteLn (vElement)


        Next
*/

vList = @stringArrayElementList( )
vCount = @CountStringArray (vList)
n =1
While n <= vCount
	{
		vName = @AccessStringArray (vList, n)
		vLine = ""
		//vElement = Split (vList, vDelimit)
		vLine = vName
		SetThisElement ( vName)
		vLine = vLine + @text (24 - @len (vName), " ") +
                @ElementBoundTo (ThisElement) + @text (20 - @len (@ElementBoundTo (ThisElement)), " ") +
                @Label (ThisElement) +  @text ( 20 - @Len (@Label (ThisElement)), " ") +
                @ElementBoundToType(ThisElement)
                WriteLn (vLine)
		n = n + 1


	}
UnsetThisElement ( )


 

  
Back to top
 
IP Logged
 
tcgeo
Full Member
***
Offline



Posts: 278
Location: Traverse City, Michigan
Joined: May 13th, 2008
Re: @XLookUpStatement Not Working
Reply #8 - Mar 10th, 2012 at 3:43pm
Print Post Print Post  
Outstanding code Bharat, I just ran it on mass update for one record, it does show the extra space, if any, in the field name!

Great tool!

Thanks for this, and have a great day!

Brandon
  
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: @XLookUpStatement Not Working
Reply #9 - Mar 14th, 2012 at 3:46pm
Print Post Print Post  
A word of caution! If any data contains ";", since it is default delimiter, it will yield unexpected wrong results because of data-shift. The following topic discussion avoid placing ";" in the data fields and with a little modification with mass update routine can detect them and eliminate them. The code is generic so, it can be applied to any form.

http://lantica.com/Forum4/cgi-bin/yabb2/YaBB.pl?num=1331618448
  
Back to top
 
IP Logged