CONCATENATE syntax error "unable to interpret text-cb1" - checkbox

I've been trying to make a dynamic col for a select. it's just for learning.
I've made a selection screen with some select-options and checkbox parameters. whenever i have a checked checkbox i want to concatenate a string to my lineselection var.
lineselect = ' CARRID CONNID'.
SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME TITLE text-001.
[...]
SELECTION-SCREEN END OF BLOCK block1.
IF cbcofr EQ 'X'. "where cbcofr is checkbox
CONCATENATE text-cb1 INTO lineselect SEPARATED BY space. "where text-cb1 is 'CONTRYFR
ENDIF.
When i check for error the compiler just says "Unable to interpret "text-cb1". possible cause: incorrect spelling or comma error."
Is not about text-cb1 , i've tried with string 'COUNTRYFR' and says the same thing. I don't get where my error is.

The syntax for concatenate is as follows:
CONCATENATE c1 c2 [... cn] INTO targetc [SEPARATED by sep].
or
CONCATENATE lines of itab into targetc [SEPARATED by sep].
As you have already noted, you need at least two source variables to concatenate.
Full documentation can be found here
As of Netweaver release 7.02 you can also do this:
targetc = c1 && [c2 ... && cn].
In this case, you lose the "separator" functionality, though.

Related

SSIS Expression cannot be evaluated -- why not?

I have variable in an SSIS package name User::FileFullPathLDR.
From this variable at run time of the SSIS package I want to extract the file name from FileFullPathLDR and put it in another variable called User::FileName.
I have tried all types of combinations to try and get this code to resolve in Expression Builder to resolve except standing on my head with incense burning saying OM 4 million times, and nothing seems to work.
I put the following expression in Expression Builder for the variable User::FileName:
REVERSE(SUBSTRING(REVERSE(#[User::FileFullPathLDR]),1,FINDSTRING(REVERSE(#[User::FileFullPathLDR] ),"\\",1)-1))
From the full path I expect to get the filename similar to: LDRFile01242019.txt.
But I keep getting the following error when expression builder parses this statement:
The length -1 is not valid for function "Substring". The length parameter cannot be negative. Change the length parameter to zero or a positive value.
I tested this expression:
REVERSE(SUBSTRING(REVERSE(#[User::FileFullPathLDR]),1,FINDSTRING(REVERSE(#[User::FileFullPathLDR]),"\\",1)-1))
against this test string:
C:\Folder1\Folder2\FileName.TXT
and it returned
FileName.TXT
There was no error
I tested it by creating a variable and defining an expression for it, then evaluating that expression.
You can try the following expression:
RIGHT(#[User::FileFullPathLDR],FINDSTRING(REVERSE(#[User::FileFullPathLDR]),"\\",1)-1)
Also try to add a conditional operator to avoid bad values errors:
FINDSTRING(REVERSE(#[User::FileFullPathLDR]),"\\",1) == 0 ? "" : RIGHT(#[User::FileFullPathLDR],FINDSTRING(REVERSE(#[User::FileFullPathLDR]),"\\",1)-1)
References
SSIS Expression to get filename from FilePath
SSIS Expression to Get File Name From Full Path
The part FINDSTRING(#[User::FileFullPathLDR],"\\",1) returns 0 if FileFullPathLDR does not contain a \. Since you are subtracting -1, you might end up with a negative value if your string doesn't match the pattern, or if the variable is set at runtime (you might have an empty string during validation).
If you need it to work with an empty string as well, you could add a \\ in front of it if there is no \\ present yet, using something like FINDSTRING(#[User::FileFullPathLDR],"\\",1) == 0 ? "\\"+ #[User::FileFullPathLDR] : #[User::FileFullPathLDR]
So the whole thing will be:
REVERSE(
SUBSTRING(
REVERSE(
#[User::FileFullPathLDR]),1,FINDSTRING(REVERSE(FINDSTRING(#[User::FileFullPathLDR],"\\",1) == 0 ? "\\"+ #[User::FileFullPathLDR] : #[User::FileFullPathLDR])
,"\\",1
)-1
)
)
So, if there is no \ present, it will just return the string itself.

Hide row based on parameter value

How can I simply hide row based on selected parameter in SSRS 2012.
I have LineGuid parameter that has two values: Earthquake and Wind
I want to hide the row if 'Wind' parameter is chosen, because it shows sum value for Earthquake.
So I am entering an Expression in Row Visibility but it gives me an error saying: "Overload resolution failed because no Public '=' can be called..."
I also tried to pass Value(GUID), not Label but gives me the same error.
What am I missing here?
You have the Line GUID parameter set to accept multiple values. The values are passed in as an array which is why you see the String() syntax in the error message. One option is to change that to not accept multiple values. Another option is to use the First selected value like so:
=Parameters!lineGuid.Value(0)
Note the reference to the array index on the end of the expression.
If you want to combine all the values you can also join them like this:
=Join(Parameters!lineGuid.Value, ", ")
This will concatenate the values in the array into a comma separated string.
Join all of your parameters together, then check to see if Wind is part of the string.
= IIF(InStr(Join(Parameters!lineGuid.Label,","),"Wind") > 0,True,False)
In my case I needed to display row when "Earthquake" parameter is chosen, and also when both parameter chosen: Earthquake and Wind.
This expression made it work:
=IIF(InStr(JOIN(Parameters!lineGuid.Label,","),"E")
OR
InStr(JOIN(Parameters!lineGuid.Label,","),"W")
AND
InStr(JOIN(Parameters!lineGuid.Label,","),"E")>0,False,True)
Try use the actually parameter .value not .label name

Matching Regular Expressions In SQL Server

I am trying to extract id of Android app from its url but getting extra characters.
Using replace function in sql server, below are two sample urls:
https://play.google.com/store/apps/details?id=com.flipkart.android&hl=en com.flipkart.android
https://play.google.com/store/apps/details?hl=en_US&id=com.surveysampling.mobile.quickthoughts&referrer=mat_click_id%3Df1901cef59f79b1542d05a1fdfa67202-20150429-5128 en_US&id=com.surveysampling.mobile.quickthoughts&r
I am doing this right now:
SELECT
SUBSTRING(REPLACE(PREVIEW, '&hl=en',''), CHARINDEX('?', PREVIEW) + 4 , 50)
FROM OFFERS_TABLE;
But for 1st I am getting com.flipkart.android which is correct, but for 2nd I am getting en_US&id=com.surveysampling.mobile.quickthoughts&r.
I want to remove en_US&id from starting of it and &r from its end.
Can someone help me with any post or url from where I can refer?
What you are actually trying to do is extract the string preceded by id= until the & is found which is separator for variables in URL. Taking this condition I came up with following regex.
Regex: (?<=id=)[^&]*
Explanation: It uses the lookbehind assertion that is the string is preceded by id= until the first & is found.
Regex101 Demo
It seems like you've made some assumptions of lengths. The the &r is appearing because that is 50 characters. You are also getting the en_US because you assumed 4 characters at the beginning but your second string has more. Perhaps you can split on & and then look for the variable that begins with id=.
it seems like a function like this would help.
http://www.sqlservercentral.com/blogs/querying-microsoft-sql-server/2013/09/19/how-to-split-a-string-by-delimited-char-in-sql-server/

select first two characters of values in a concatenated string

I am trying to create a formula field that checks a string that is a series of concatenated values separated by a comma. I want to check the first two characters of each comma separated value in the string. For example, the string pattern could be: abcd,efgh,ijkl,mnop,qrst,uvwx
In my formula I'd like to check if the first two characters are 'ab','ef'
If so, I would return true, else false.
Thanks.
To do this properly, you need to use a regular expression. Unfortunately the REGEX function is not available in formula fields. It is, however, available in formulas in Validation Rules and in Workflow Rules. You can, therefore, specify the below formula in either of a Validation or Workflow Rule:
OR(
AND(
NOT(
BEGINS( KXENDev__Languages__c, "ab" )
),
NOT(
BEGINS( KXENDev__Languages__c, "ef" )
)
),
REGEX( KXENDev__Languages__c , ".*,(?!ab|ef).*")
)
If it's a Validation Rule, you're done -- this formula will create an error if any of the entries do not start with "ab" or "ef". If it's a Workflow Rule, then you can add a Field Update to it to update some field with False when this formula is true (if this formula is true then there is at least one item that doesn't start with ab or ef, so that would make your field False).
Some may ask "What's with the BEGINS statements? Couldn't you have done this all with one REGEX?" Yes, I probably could, but that makes for an increasingly complex REGEX statement, and these are quite difficult to debug in Salesforce.com, so I prefer to keep my REGEXes in Salesforce.com as simple as possible.
I suggest you to search for ',ab' and ',ef' using CONTAINS method. But first of all you need to re implement method which composes this string so it puts ',' before first substring. At the end returned string should look like ',abcd,efgh,ijkl,mnop,qrst,uvwx'.
If you are not able to re implement method which compose this string use LEFT([our string goes here],2) method to check first two chars.

VBScript: Error 10023 in : Array index out of range (trouble when reusing an array variable)

Using Sax ActiveX Scripting (long story), I have 3 nested if statements which reuse the same return variable. Script looks roughly like:
Dim rtnArray As Variant
If variable1 <> "" Then
' Perform SQL query against DB2 database
rtnArray = DB2SQLSearch(Query)
If UBound(rtnArray) = 0 Then
' ditto
rtnArray = DB2SQLSearch(Query2)
MsgBox "Gets this far"
If UBound(rtnArray) = 0 Then ' Error!
' Never make it here
What's odd is that this same code structure is working in a script I wrote last week; I simply changed a couple of the queries and the name of the function (find > replace).
After the 2nd query, I've tried a MsgBox CStr(rtnArray(0)(0)) but it yields Error 10025 in : Array has a different number of indexes.
Error codes correspond to the following manual:
http://www.ftgsoftware.com/manuals/basic32.pdf
You can either store it in another variable, or ReDim the rtnArray variable to havve the proper size. In order to Redim, you need to know the size.
Figured it out.
In this particular case, the user that I was connecting as had authorization to the first table, but not the second.
This did not throw an error, but there is a message I can check to see whether there was a success or not, so I can look for that and throw my own error, instead of passing back a null array. (it's not a proper Null, frankly I'm still not 100% sure what it is, aside from a Variant. But it sure doesn't like UBound()!

Resources