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] - Evaluate Variable in a Loop

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] - Evaluate Variable in a Loop
 Login/Join
 
Silver Member
posted
I think I must be missing something obvious.
I have a number of records in the NATNONPART file. Some are alpha numeric but some are numeric. The numeric ones for example are partial part numbers where I need to find all the full part numbers which contains that partial part number. Some of the values in this file are already the full part number.
When running this code, it works fine for the part numbers which are alpha numeric, however it's not working for the partial number which happen to have no alpha character.
I've tried various ways to evaluate the variable and converting it but it doesn't seem to be working or I'm doing something wrong (and yes the latter is the most likely)

 
TABLE FILE NATNONPART
SUM
	PART_NUM/A25 AS 'NATPART'
BY PART_NUM NOPRINT
ON TABLE SET ASNAMES ON
ON TABLE HOLD AS NATNONPART0 FORMAT ALPHA
-*ON TABLE PCHOLD FORMAT XLSX
END

FILEDEF NATNONPARTS DISK NATNONPARTS 

-SET &NEWLINES01=&LINES;

-SET &NATPART = '                         ';
-REPEAT LOOPCODE &LINES TIMES;

-READ NATNONPART0 NOCLOSE &NATPART.A25.
-IF &IORETURN NE 0 GOTO OUTLOOP;

-SET &PART_NUM1 = &NATPART;
-RUN

FILEDEF NATNONPARTS DISK NATNONPARTS (APPEND
-RUN

TABLE FILE V9F4101
PRINT
A_2ND_ITEM_NUMBER AS '2NDITEMS'
BY A_2ND_ITEM_NUMBER NOPRINT
WHERE A_2ND_ITEM_NUMBER CONTAINS '&PART_NUM1';
ON TABLE SET ASNAMES ON
ON TABLE HOLD AS NATNONPARTS FORMAT ALPHA
-*ON TABLE PCHOLD FORMAT XLSX
END

-RUN
-SET &NATPART = '                         ';
-LOOPCODE

-OUTLOOP
 


Any help is appreciated.

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


WF 81.5, Windows7
AS/400 Database.
All Outputs

 
Posts: 46 | Registered: November 26, 2008Report This Post
Virtuoso
posted Hide Post
rogerwilkouk

Put a -SET &ECHO=ALL; at the beginning of the fex and look at the feedback to see the values being tested.


Thank you for using Focal Point!

Chuck Wolff - Focal Point Moderator
WebFOCUS 7x and 8x, Windows, Linux All output Formats
 
Posts: 2127 | Location: Customer Support | Registered: April 12, 2005Report This Post
Silver Member
posted Hide Post
The set Echo shows that the value is correct and when I use the exact same syntax but passing the value from the Echo directly (hard code it into the contains), it all works fine.


WF 81.5, Windows7
AS/400 Database.
All Outputs

 
Posts: 46 | Registered: November 26, 2008Report This Post
Expert
posted Hide Post
Try:

WHERE A_2ND_ITEM_NUMBER CONTAINS '&PART_NUM1. EVAL';


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
 
Posts: 1972 | Location: Centennial, CO | Registered: January 31, 2006Report This Post
Silver Member
posted Hide Post
Tom,

Unfortunately the .EVAL didn't work.

The Echo that works shows
&PART_NUM1 = 84238455CH

and the one that doesn't shows
&PART_NUM1 = 5310104050

Thanks


WF 81.5, Windows7
AS/400 Database.
All Outputs

 
Posts: 46 | Registered: November 26, 2008Report This Post
Expert
posted Hide Post
roger,
OK, one last try:

Change
-SET &PART_NUM1 = &NATPART;
To:
-SET &PART_NUM1 = '%' || &NATPART || '%';

Then:
WHERE A_2ND_ITEM_NUMBER LIKE '&PART_NUM1';


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
 
Posts: 1972 | Location: Centennial, CO | Registered: January 31, 2006Report This Post
Silver Member
posted Hide Post
Tom

Unfortunately that didn't work either.


WF 81.5, Windows7
AS/400 Database.
All Outputs

 
Posts: 46 | Registered: November 26, 2008Report This Post
Silver Member
posted Hide Post
Tom, I think I got it. I needed to add the .EVAL to the previous SET command.

-SET &PART_NUM1 = &NATPART.EVAL;

Thank you for all your help.


WF 81.5, Windows7
AS/400 Database.
All Outputs

 
Posts: 46 | Registered: November 26, 2008Report This Post
Virtuoso
posted Hide Post
Try the following
TABLE FILE NATNONPART
SUM PART_NUM/A25 AS 'NATPART'
BY PART_NUM NOPRINT
ON TABLE SET ASNAMES ON
ON TABLE HOLD AS NATNONPART0
END
-RUN

-SET &NEWLINES01=&LINES;

FILEDEF NATNONPARTS DISK NATNONPARTS 

-REPEAT LOOPCODE &NEWLINES01 TIMES;

-READFILE NATNONPART0
-RUN
-SET &PART_NUM1 = &NATPART;

FILEDEF NATNONPARTS DISK NATNONPARTS (APPEND
-RUN

TABLE FILE V9F4101
PRINT A_2ND_ITEM_NUMBER AS '2NDITEMS'
BY A_2ND_ITEM_NUMBER NOPRINT
WHERE A_2ND_ITEM_NUMBER CONTAINS &PART_NUM1.QUOTEDSTRING;
ON TABLE SET ASNAMES ON
ON TABLE HOLD AS NATNONPARTS FORMAT ALPHA
END
-RUN

-LOOPCODE

I know that it works by using below sample:
TABLE FILE CAR
BY MODEL/A7 AS 'NATPART'
WHERE READLIMIT   EQ 5;
WHERE RECORDLIMIT EQ 5;
ON TABLE HOLD AS NATNONPART0
END
-RUN

-SET &NEWLINES01=&LINES;
-DEFAULTH &NATPART = ''

FILEDEF NATNONPARTS DISK NATNONPARTS 

-REPEAT LOOPCODE &NEWLINES01 TIMES;

-READFILE NATNONPART0
-RUN
-SET &PART_NUM1 = &NATPART;

FILEDEF NATNONPARTS DISK NATNONPARTS (APPEND
-RUN

TABLE FILE CAR
PRINT MODEL AS '2NDITEMS'
BY CAR NOPRINT
WHERE MODEL CONTAINS &PART_NUM1.QUOTEDSTRING;
ON TABLE SET ASNAMES ON
ON TABLE HOLD AS NATNONPARTS FORMAT ALPHA
END
-RUN

-LOOPCODE

TABLE FILE NATNONPARTS
PRINT *
END


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] - Evaluate Variable in a Loop

Copyright © 1996-2020 Information Builders