Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
Contributor II

Passing Fields to Sub Issue (Like qvc project)


I recently downloaded Rob Wunderlich's QVC package and it inspired me to create a sub routine for a project I was working on.

I created a routine that would accept a tablename, field names and a couple of other parameters so that I could automate the loading of external tables.

All works great until if I pass fields (stored in a variable) like "@1 as Feed2_Name, @2 as Feed2_Zipcode", but when I try to pass a variable that has the following

@1 as FEED2_NAME,

IF(Index(@2,'-')>0,mid(@6,1,index(@2,'-')-1), @2) as FEED2_ZIPCODE,

IF(Index(@2,'-')>0,mid(@6,index(@2,'-')+1,4)) as FEED2_ZIP4

I get problems because of the single quotes.  They come over as not double quotes, but two single quotes where there use to be one.


Again, this is coming from a variable "vFeed2_Fields".

Any ideas on how I need to structure the information in the variable so this doesn't happen?



Tags (3)
1 Reply
Contributor II

Re: Passing Fields to Sub Issue (Like qvc project)

Here is what I ended up doing to get this to work.  It feels clunky, but it works:

In the macro that is creating the field list, I use ! instead of single quotes, then AFTER I pass the fields over to routine that is building the table I do a replace:

Let _fieldsFinal = Replace('$(_fields)', '!', chr(39));

//Build table from passed values




          FROM $(_fileName)

          (txt, codepage is 1252, no labels, delimiter is '$(_delimiter)', header is $(headerLines) lines, msq);

If anyone has a better way, please let me know.



Community Browser