Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Conditional execution of fexes using -INCLUDE

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Conditional execution of fexes using -INCLUDE
 Login/Join
 
Platinum Member
posted
Hello everyone,

I am trying to call 2 fexes from a single fex - the 2 fexes are called based on a Language code Eng or French.

-IF &LANG_CDE EQ 'FR' THEN GOTO FR_RPT ELSE GOTO ENG_RPT;

-FR_RPT
-INCLUDE app/frrpt.fex
-GOTO EXIT

-ENG_RPT
-INCLUDE app/engrpt.fex
-GOTO EXIT

-EXIT


I read the Language code from a ON TABLE HOLD command and I also verified the value in the variable using -TYPE command. Irrespective of the value in the variable, the ENG_RPT fex is the one that executes always. Even if the language code is FR for French, the English version executes. The control does not go to the FR_RPT label at all, no matter what the value of the &LANG_CDE variable is!

I am not sure what I am doing wrong here - am I using labels or -INCLUDE incorrectly?

Thanks in advance for all your help!

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


WF 7.7.03, Win 7
 
Posts: 127 | Registered: January 12, 2017Report This Post
Virtuoso
posted Hide Post
Change the code to say -EXIT instead of -GOTO EXIT.


WebFOCUS 8206, Unix, Windows
 
Posts: 1853 | Location: New York City | Registered: December 30, 2015Report This Post
Virtuoso
posted Hide Post
And why not just perform as this:
-INCLUDE app/&LANG_CDE.EVALrpt.fex

No need to test the language and perform GOTO.

And if you still want to use the GOTO either use Babak suggestion or have a real tag
-IF &LANG_CDE EQ 'FR' THEN GOTO FR_RPT ELSE GOTO ENG_RPT;

-FR_RPT
-INCLUDE app/frrpt.fex
-GOTO XEXIT

-ENG_RPT
-INCLUDE app/engrpt.fex
-GOTO XEXIT

-XEXIT
-EXIT


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
 
Posts: 2409 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Report This Post
Virtuoso
posted Hide Post
MartinY's suggestion is more elegant.

The point is -EXIT is a reserved syntax that basically means quit processing. You shouldn't use it as a label.


WebFOCUS 8206, Unix, Windows
 
Posts: 1853 | Location: New York City | Registered: December 30, 2015Report This Post
Platinum Member
posted Hide Post
Tried changing the name of the label for EXIT, but that doesn't help.. I don't think this has anything to do with the label name...

Basically, when the language code is FR it still does not go to the label meant for executing the French version of the report.. It just goes to the Eng report label...

I am not sure why the control won't go to the French report label like it is supposed to!!?

Thanks!


WF 7.7.03, Win 7
 
Posts: 127 | Registered: January 12, 2017Report This Post
Virtuoso
posted Hide Post
Please add

-SET &ECHO=ALL;

to the beginning of the code and run it. What does the echo show?


WebFOCUS 8206, Unix, Windows
 
Posts: 1853 | Location: New York City | Registered: December 30, 2015Report This Post
Platinum Member
posted Hide Post
TABLE FILE T_CAN_CDE_CNDCT_BOX_1
 PRINT
 LANG_CDE
 WHERE MER_NUM EQ 8029283432
 ON TABLE HOLD
 END
 -RUN
 0 NUMBER OF RECORDS IN TABLE=       24  LINES=     24
 -READ HOLD &LANGCDE.A4.
 -TYPE ##AFTER_READ = FR
 ##AFTER_READ = FR
 -IF FR EQ FR THEN GOTO FR_PDF ELSE GOTO ENG_PDF;
 -ENG_PDF
 -TYPE ##INSIDE_ENG_LABEL = FR
 ##INSIDE_ENG_LABEL = FR
 -*-INCLUDE app/disclosurepacket.fex
 -GOTO XEXIT
 -XEXIT
 -EXIT


This is part of the result of SET &ECHO=ALL

Here, in the READ statement - I am reading the language code. It is FR in this case.
Then I just used TYPE to check my value after READ.
The IF statement also replaces &LANGCDE with FR (as expected) and the test is true for FR EQ FR so it should go to the FR_PDF label, but instead it goes to the ENG_PDF label Frowner

And I have a TYPE inside the ENG_PDF label to see what the value is for &LANGCDE, which it says is FR.. I just don't know why it won't go to the FR_PDF label Frowner


WF 7.7.03, Win 7
 
Posts: 127 | Registered: January 12, 2017Report This Post
Virtuoso
posted Hide Post
Could it be caused by the A4 size of the &LANG_CDE? I mean maybe your if test is 'FR ' EQ 'FR' which will not be true. Try LTRIM(&LANG_CDE) to get rid of any spaces.


WebFOCUS 8206, Unix, Windows
 
Posts: 1853 | Location: New York City | Registered: December 30, 2015Report This Post
Platinum Member
posted Hide Post
Isn't LTRIM only used by SQL queries? How do I use it here?

Can't use it in PRINT statement or IF statement either.


WF 7.7.03, Win 7
 
Posts: 127 | Registered: January 12, 2017Report This Post
Virtuoso
posted Hide Post
-IF LTRIM(&LANG_CDE) EQ 'FR' THEN GOTO FR_RPT ELSE GOTO ENG_RPT;


WebFOCUS 8206, Unix, Windows
 
Posts: 1853 | Location: New York City | Registered: December 30, 2015Report This Post
Platinum Member
posted Hide Post
quote:
IF LTRIM(&LANG_CDE) EQ 'FR' THEN GOTO FR_RPT ELSE GOTO ENG_RPT;


This doesn't work with -IF statement, throws an error - I tried earlier.

Anyway, the LTRIM idea is good.. I converted my TABLE FILE statement to a SQL query where I use LTRIM and now the logic works just fine...
It is strange how I couldn't trim the LANG_CDE field when I read it from my master file!!

Thanks a lot for all your help and assistance!


WF 7.7.03, Win 7
 
Posts: 127 | Registered: January 12, 2017Report This Post
Virtuoso
posted Hide Post
Your langcde format is set at the -READ.

-READ HOLD &LANGCDE.A4.

But the LTRIM syntax works when I tested it on my side and didn't get any errors. I'm happy you figured it out.


WebFOCUS 8206, Unix, Windows
 
Posts: 1853 | Location: New York City | Registered: December 30, 2015Report This Post
Expert
posted Hide Post
test the size of your &variable
-SET &LANGCDE = TRUNCATE(&LANGCDE);
-TYPE length: &LANGCDE.LENGTH
I use something like Martin's idea:
-SET &cmt_fr = IF &LANGCDE.QUOTEDSTRING EQ 'FR' THEN '' ELSE '-*';
-SET &cmt_en = IF &cmt_fr.QUOTEDSTRING EQ '-*' THEN '' ELSE '-*'
&cmt_fr.EVAL-INCLUDE app/frrpt.fex
&cmt_en.EVAL-INCLUDE app/engrpt.fex




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Report This Post
Virtuoso
posted Hide Post
Nova,

No matter how you perform and call your INCLUDE (using my version, Babak or Susannah) all your problem is related to you &LANGCDE variable.

One thing you can try to prove that is the following:
TABLE FILE T_CAN_CDE_CNDCT_BOX_1
 PRINT LANG_CDE
 WHERE MER_NUM EQ 8029283432
 ON TABLE HOLD
 END
-RUN
-DEFAULTH &LANG_CDE = ''
-READFILE HOLD
-TYPE ##AFTER_READ = -&LANG_CDE-

-IF &LANG_CDE NE 'FR' THEN GOTO ENG_PDF ELSE GOTO FR_PDF;
-FR_PDF
-TYPE ##INSIDE_FR_LABEL = -&LANG_CDE-
-GOTO XEXIT
-ENG_PDF
-TYPE ##INSIDE_ENG_LABEL = -&LANG_CDE-
-GOTO XEXIT
-XEXIT
-EXIT

First I use READFILE instead of READ. That way you don't bother for format.
Second I add dashes enclosing your variable. You will then see its real value (including spaces)
Third I reversed the test just to see what will happen.


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
 
Posts: 2409 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Report This Post
Platinum Member
posted Hide Post
Thanks Martin - your way works as expected. I think using READFILE made all the difference, don't need LTRIM anymore. The LANG_CDE variable spits out the value without any spaces.

I think since I was using READ and had to give it a format, that's where I was encountering issues with the extra spaces.

Thanks everyone once again for helping me out! Really appreciate it! Smiler


WF 7.7.03, Win 7
 
Posts: 127 | Registered: January 12, 2017Report This Post
Virtuoso
posted Hide Post
You could make the test insensitive to trailing blanks, by using CONTAINS instead of EQ:

-IF &LANG_CDE CONTAINS 'FR' THEN ...


- Jack Gross
WF through 8.1.05
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Virtuoso
posted Hide Post
Also have to pay attention to your NLS setting (Client and Server).
If you are sure that the language read will always come from your TABLE FILE... and only have FR and EN values, you are good to go.

But if you may use the IBIWF_language variable it may contains FC standing for French Canadian where FR is for French France.
So you may need to test both FR and FC or have something such as (in a common profile) :
-DEFAULTH &LANG = '';
-SET &LANG   = IF &LANG EQ 'FOC_NONE' OR '_FOC_NULL' OR '' THEN UPCASE(2, &IBIWF_language, 'A2') ELSE ⟨
-SET &LANG   = IF &LANG CONTAINS 'FC' OR 'FR' THEN 'FR' ELSE ⟨
-SET &LANG   = IF &LANG CONTAINS 'US'         THEN 'EN' ELSE ⟨

and then use &LANG to identify the selected language.


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
 
Posts: 2409 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Conditional execution of fexes using -INCLUDE

Copyright © 1996-2020 Information Builders