Focal Point
[SOLVED] long string - search more than 4096 characters?

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/4287074786

August 10, 2017, 03:31 PM
BM
[SOLVED] long string - search more than 4096 characters?
Hi,
I have an HTML page with several controls including an EDIT BOX.
EDIT box is used to search PART numbers.
User can enter multiple Part numbers using "^" delimiter.
The length of the Part number varies.
I am able to replace '^' to ' OR ' and use that in my where clause.
Here is the code I am using to convert '^' to ' OR ' .


-SET &VALS = ∂
-SET &VALS2 = &VALS.LENGTH + 1365;
-SET &VALS3 = 'A' | &VALS2;
-SET &VALSX = STRREP(&VALS.LENGTH,&VALS,1,'^',6,''' OR ''',&VALS2,'&VALS3');
-SET &VALSX = TRUNCATE(&VALSX);
-SET &PART = &VALSX;



The issue I am facing now is that the length of the Input string could be more the 4096 characters and STRREP doesn't like that.
Not sure how to get around it.

How do I work around it?

Thanks

This message has been edited. Last edited by: BM,


WebFOCUS 8202M
August 10, 2017, 03:49 PM
MartinY
One question : How and Why a user would enter 4096 characters in a search string ???

According to me, if your users may enter that much of data as for a selection (filter), you should think of another way to select those many part numbers...


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
August 10, 2017, 03:55 PM
BM
User may get list of parts from the customer.
The length of each Part numbers can go from 5 character to 25 characters.
If the user wants to search 400-450 parts which is quiet normal then the length of the variable string goes over 4096 character.


WebFOCUS 8202M
August 10, 2017, 05:36 PM
Waz
Hi BM,

You don't specify the OS in your signature, so am guessing, but

I was thinking, if WebFOCUS can't do it, then perhaps something else can.

Some of the options I can think of are:




Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

August 11, 2017, 10:30 AM
BM
Thanks.
OS is Windows.

Would you be able to elaborate on the options you have suggested?

Thanks again for all your help


WebFOCUS 8202M
August 11, 2017, 11:00 AM
MartinY
quote:
User may get list of parts from the customer.

How this list is provided and in which format ?


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
August 11, 2017, 11:03 AM
FP Mod Chuck
Hi BM

This is off the the top of my head but what about using substring to break the string down to 4096 chunks and creating more than one &variable to manipulate


Thank you for using Focal Point!

Chuck Wolff - Focal Point Moderator
WebFOCUS 7x and 8x, Windows, Linux All output Formats
August 11, 2017, 12:29 PM
BM
quote:
Originally posted by MartinY:
quote:
User may get list of parts from the customer.

How this list is provided and in which format ?


Its in a text format.
User enters them in a EDIT BOX (&PART) with "^" delimiter.
I am able to add replace '^' with ' OR ' and use that in my WHERE CLAUSE.
Issue is if the the length &PART goes over 4096 then it doesn't work.
Here is the code I amusing to replace "^" to " OR ".

-SET &VALS = ∂
-SET &VALS2 = &VALS.LENGTH + 1365;
-SET &VALS3 = 'A' | &VALS2;
-SET &VALSX = STRREP(&VALS.LENGTH,&VALS,1,'^',6,''' OR ''',&VALS2,'&VALS3');
-SET &VALSX = TRUNCATE(&VALSX);
-SET &PART = &VALSX;



WebFOCUS 8202M
August 11, 2017, 12:31 PM
BM
quote:
Originally posted by Chuck Wolff:
Hi BM

This is off the the top of my head but what about using substring to break the string down to 4096 chunks and creating more than one &variable to manipulate


Hi,
This is what I am struggling with...Since the lenght of each Partnumber in the string varies 4096 chunk could break the value of the PartNumber.


WebFOCUS 8202M
August 11, 2017, 01:27 PM
MartinY
BM,

My question was to understand How does your user do receive the part list from the customer.
The way that the user actually enter the part list in a edit box was clear. This is where is your issue.
I'm wondering how do this list is provided to your users BEFORE they enter it in the edit box.

Maybe something could be done using that input list and avoid manual entry of part numbers.

Having users to type in several numbers (from 5 to 25 digit) with a "^" as delimiter can create so many entry errors that this is from where you need to take action to eliminate that manual entry.

So I repeat my question : From where, how and in which format does the part number list is given to your users BEFORE they enter it in you edit box ?


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
August 11, 2017, 04:13 PM
BM
Oh now I know what you mean. sorry for the confusion.
The user may get the list from the customer in a PDF or in a spreadsheet.
Or they may create a list of "Focus" parts to track for their Business Unit.
Majority of the time the list is manageable.
Its just sometimes we do get those strange request and not sure how to tackle it.
I was thinking of maybe creating a table off of the list but not sure how.

Thanks


WebFOCUS 8202M
August 11, 2017, 10:37 PM
dbeagan
In situations like this in the past I have used JavaScript to do the replacement. Here is some sample code that you can try to see how it would work:
 <html>
 <script>
 function replacetext() {
    var parts = document.getElementById("edit1");
    parts.value = parts.value.replace(/\^/g,"' OR '");
 }
 </script>
 <input id=edit1 onkeyup=replacetext() size=100></input>
 </html>

You could incorporate the two lines of code in the function into your HTML Composer/Canvas page to run when your run button is clicked.


WebFOCUS 8.2.06
August 13, 2017, 05:35 PM
Waz
quote:
Would you be able to elaborate on the options you have suggested?



I just has a thought.

Can you -WRITE the string to a file, then -READ it or create a master file for it and TABLE FILE it ?


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

August 13, 2017, 06:36 PM
Doug
How about taking that list of part numbers and writing them to a file, then use "WHERE PART_NUMBER IN FILE (FileName)" (I think that the syntax, maybe?)?




   In FOCUS Since 1983 ~ from FOCUS to WebFOCUS.
   Current: WebFOCUS Administrator at FIS Worldpay | 8204, 8206
August 14, 2017, 08:24 AM
MartinY
quote:

The user may get the list from the customer in a PDF or in a spreadsheet.
Or they may create a list of "Focus" parts to track for their Business Unit.

Since it doesn't seems to always be the same way that the data is "received", dbeagan look like your best and simplest option
 function replacetext() {
    var parts = document.getElementById("edit1");
    parts.value = parts.value.replace(/\^/g,"' OR '");
 }



WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
August 14, 2017, 02:18 PM
BM
thanks all.
Will give javascript replacement a try and get back.


WebFOCUS 8202M
August 14, 2017, 02:19 PM
BM
quote:
Originally posted by Waz:
quote:
Would you be able to elaborate on the options you have suggested?



I just has a thought.

Can you -WRITE the string to a file, then -READ it or create a master file for it and TABLE FILE it ?


Thanks .. not sure how to do that.
Do you have any example or post you can point to?


WebFOCUS 8202M
August 14, 2017, 03:23 PM
FP Mod Chuck
Hi BM

Since your limitation is the 4096 limit for STRREP I think the javascript is your best option.


Thank you for using Focal Point!

Chuck Wolff - Focal Point Moderator
WebFOCUS 7x and 8x, Windows, Linux All output Formats
August 14, 2017, 03:26 PM
MartinY
quote:
Since your limitation is the 4096 limit for STRREP I think the javascript is your best option.

I do agree, as I already mentioned and it's much more simplest then perform -WRITE, create a master file and -READ to then perform other action on the string.


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
August 14, 2017, 03:44 PM
BM
Thanks all. Javascript it is Smiler


WebFOCUS 8202M
August 14, 2017, 05:47 PM
Waz
quote:
Thanks all. Javascript it is


Let me know if you need the other option.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

August 15, 2017, 04:57 PM
BM
quote:
Originally posted by Waz:
quote:
Thanks all. Javascript it is


Let me know if you need the other option.


For now I have used the javascript and its working well but for sure I would like to learn the other option Smiler.


WebFOCUS 8202M
August 20, 2017, 05:43 PM
Waz
The Idea, I had was to -WRITE out the &Var, then -READ bit of it into new vars.

You could also use a TABLE FILE to do things as well, but this is the simple example.

-SET &BASE = '123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 ' ;
-SET &BASE1K = &BASE | &BASE | &BASE | &BASE | &BASE | &BASE | &BASE | &BASE | &BASE | &BASE ;

-SET &TEST = '' ;
-REPEAT LOAD FOR &CNTR FROM 1 TO 5 ;

-SET &BLK = DECODE &CNTR(1 'A' 2 'B' 3 'C' 4 'D' 5 'E' ELSE 'X') ;

-SET &TEST = &TEST || &BLK || &BASE1K ;

-LOAD

-*-TYPE &TEST

FILEDEF TESTFILE DISK test.ftm

-RUN

-WRITE TESTFILE &TEST

-READ TESTFILE &BLOCK1.A1000. &BLOCK2.A1000. &BLOCK3.A1000. &BLOCK4.A1000. &BLOCK5.A1000. 

-TYPE BLOCK1 = &BLOCK1
-TYPE BLOCK2 = &BLOCK2
-TYPE BLOCK3 = &BLOCK3
-TYPE BLOCK4 = &BLOCK4
-TYPE BLOCK5 = &BLOCK5


* Tested on a linux environment


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!