Find String in a String

DaveBarber

Active Member
I need a function to validate whether a string exists within a supplied given string - exactly the same as FindStringInaString (B986701).
My problem is that this is client side only and I need to run this function in a UBE on the server.

Have had a look through the various functions with string manipulation but there seems to be nothing else that does the same thing as B986701.
Anyone know of a suitable server side function that does the same thing, to save me writing my own?

many thanks in advance
Dave

JDE OW XE SP22 on Oracle, AIX batch servers
 
Hi Dave,

I suppose, there isn't any special reason of that this BSFN is client only. My 0.02$

1. switch this BSFN to Both, Client and Server and deploy onto the server
2. create a copy of this BSFN and switch this to Both, Client and Server and deploy this to the server

...and try it.

Regards,

Zoltán
 
Zoltan's suggestion is a nice one..

But make sure that the APIs used in the BSFN are not of Client only.

if that is the case, then the BSFN wont work even if you make it client server function.
 
Hi Dave & Gov,

First of all, thanks to Gov for the warning.

I recently checked B96701 (by the way, not B986701) BSFN Source Modul and it contains 9 Business Function - seein their purpose please, omit my suggestions.
blush.gif


The "FindStringInString" function is a tiny part of this source, which main processing contains less then 10 lines:

/************************************************************************
* Main Processing
************************************************************************/
jdeStripTrailingBlanks(lpDS->szMainString);
jdeStripTrailingBlanks(lpDS->szSearchString);

p = strstr(lpDS->szMainString, lpDS->szSearchString);
if( p != NULL )
lpDS->cReturnFlag = '0';
else
lpDS->cReturnFlag = '1';

I did not find "jdeStripTrailingBlanks" in the gelp, so I do not know, is it Client Only, or not - but I do not see any readon, why to be client only.

You can:
1. Write your own C BSFN based on this in B96701.
2. Write your own C BSFN without jdeAPI call and/or C Library function call. You can code these funcitionalities in C easily, if you are familiar a bit in C coding.
3. Write it in a NER BSFN easily - it requires only basic NER coding skills. OK, it won't be so fast, but I suppose, it won't be a bottle-nack.

I hade wrote some similar once upon a time in NER for a Customer Bank interface, where I analized, does the remark part of the bank statement line contain any invoice number referenc(es) of the customer. If you are interested in it, then I will try find this BSFN somewhere and will send you the code of it.

Regards,

Zoltán
 
Depending on your C Skillset - you can look at: B9109864-Find Character in a String (this is tagged as client and server).

I'm not a C person, but I was able to tweak this function to find characters within a string.

(db)
 
Hi Dave,

[ QUOTE ]
If you are interested in it, then I will try find this BSFN somewhere and will send you the code of it.


[/ QUOTE ]

I checked this and it containes some special logic, so it won't be useful for you.

On the other hand, it is really not a big deal to write this in NER BSFN, with 2 or 3 embedded while loop, with some
integer variables for
- string lengthes
- string positions
- maybe for counter(s) (???)
string variable(s) for
- substring(s)
char variable(s) for
- flags to drive the while loop exits and store result

It should be not more than an our to develop it - except if your system is terribly slow
cool.gif


Regards,

Zoltán
 
Hi Dave,

Ooopps,I missed
blush.gif
one While Loop is enough.
Here is the sample ER code:

evt_szStringSearchFor_GPTX
evt_szStringSearchIn_GPTX
evt_szSubString_GPTX
evt_nLengthSearchFor_INT01
evt_nLengthSearchIn_INT01
evt_nPosition_INT01
evt_nLastPosition_INT01
evt_cStringFound_EV01
//
// *** RTRIMs are optional Here and inside While Loop, depending on your needs
//
VA evt_szStringSearchFor_GPTX = rtrim([VA evt_szStringSearchFor_GPTX],' ')
VA evt_szStringSearchIn_GPTX = rtrim([VA evt_szStringSearchIn_GPTX],' ')
//
VA evt_nLengthSearchFor_INT01 = length([VA evt_szStringSearchFor_GPTX])
VA evt_nLengthSearchIn_INT01 = length([VA evt_szStringSearchIn_GPTX])
//
VA evt_nLastPosition_INT01 = [VA evt_nLengthSearchIn_INT01]-[VA evt_nLengthSearchFor_INT01]
//
VA evt_cStringFound_EV01 = "0"
VA evt_nPosition_INT01 = "0"
//
While VA evt_nPosition_INT01 is less than or equal to VA evt_nLastPosition_INT01
And VA evt_cStringFound_EV01 is not equal to "1"
//
VA evt_szSubString_GPTX = substr([VA evt_szStringSearchIn_GPTX],[VA evt_nPosition_INT01],[VA evt_nLengthSearchFor_INT01])
VA evt_szSubString_GPTX = rtrim([VA evt_szSubString_GPTX],' ')
//
If VA evt_szSubString_GPTX is equal to VA evt_szStringSearchFor_GPTX
VA evt_cStringFound_EV01 = "1"
Else
VA evt_nPosition_INT01 = [VA evt_nPosition_INT01]+1
End If
//
End While
//

Based on this logic, you can create a BSFN for general purpose for the future or simply integrate this logic into your APPL or UBE code.
If this functionality will be called more times on your Form or in your UBE, then place this logic onto a Hidden Push Button or into a Hidden Conditional section - and of course, change the the scope of the IN/OUT paremeters accordinly.

Hope, this helps.

Regards,

Zoltán
 
Guys - thanks for the suggestions.
In think I will try taking the c code from the FindStringinString only and create this as its own standalone c function with a new name. I will see how this goes.
Failing this I may tweak CharInString function to do something similar.

Thanks for the NER code Zoltan. Will save it as it could be useful anyway.

Dave
 
Yes Try useing BSFN : B0500690 - Is String in String(this is Client/Server BSFN works same as Find String in String)
 
Back
Top