Instead of using the "perform find" script steps to define your find parameter, try this:
Enter Find Mode
Set Field By Name: [ "Z_LongList_" & GetAsText ( Get ( ScriptParameter ) ) & "::EAN_Scanned" ; $EAN ]
Perform Find (no options)
That's pretty much the same as doing a find manually without scripts (cmd+F, type in a value, hit enter)
For exemple: Script Parameter passed = "2015" (obviously the year).
Not totally obvious because "2015" is a string …
Go to Layout [ "Z_LongList_" & GetAsText ( Get ( ScriptParameter ) ) ] - to go to layout "Z_LongList_2015"
Are you sure you need different layouts for different years? The data from 2016 will differ from that of 2016, but their format and your presentation will be the same.
Then I would like to perform a find: [ "Z_LongList_2015::EAN" = $EAN ]
(hardcoding works just fine; but I would like to re-use the same script just changing the parameter to "2016" for next year's routines. Cannot find a way to reference the layoutname by using the parameter).
Even if you do have different layout for the same task, their underlying table occurrence will be the same – and that is part of the fully qualified name, not the layout name.
Consider the relationship cardinality between these objects in FM:
Table --< TableOccurrences --< Layouts
It is the table occurrence that determines the context.
Z_LongList_2015 is for table "LongList_2015"
Z_LongList_2016 will be for table "LongList_2016"
Both tables are part of the same FM solution and linked via "Unique SKU ID" to main table.
Is there a reason you can't add a field called "Year" to the table called LongList? If you create a new table for every new year, you're asking for lots of hassles down the road.
lots of hassles down the road.
Why, it's already arrived …
Why do I always neglect the most simple solution ?
Like the responses above I believe that there is something not quite right with your schema choice. Having said that, I have come across the same situation before trying to pass a layout name as a parameter. The main problem is that your code will break if you ever decide to rename your layout. What we need is something similar to the GetFieldName function, "GetLayoutName", not Get(LayoutName). Until we have that function we have to do something else.
What I did to solve the situation is a bit long winded but it works and will not break. Instead of passing the layout name as a parameter, just pass a number (1,2,3,4,5,etc). This number will indicate which layout name you want to use. Then in your script that is receiving the parameter use a bunch of if, else if statements to branch to the correct layout depending on the number passed. That way your code will not break even when you change layout names or layout order.
There are some custom functions to get around the layout id and layout order problem, but I find them cumbersome and prefer the simpler approach.