Focal Point Banner
Community Center Education Summit Technical Support User Groups
Let's Get Social!

Facebook Twitter LinkedIn YouTube
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] - Evaluate Variable in a Loop
Go
New
Search
Notify
Tools
Reply
  
[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, 2008Reply With QuoteReport 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: 1506 | Location: Customer Support | Registered: April 12, 2005Reply With QuoteReport 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, 2008Reply With QuoteReport This Post
Virtuoso
posted Hide Post
Try:

WHERE A_2ND_ITEM_NUMBER CONTAINS '&PART_NUM1. EVAL';


Tom Flynn
WebFOCUS 7.7.05 - PROD/QA
DB2 - AS400 - Mainframe
 
Posts: 1942 | Location: Parker, CO | Registered: January 31, 2006Reply With QuoteReport 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, 2008Reply With QuoteReport This Post
Virtuoso
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 7.7.05 - PROD/QA
DB2 - AS400 - Mainframe
 
Posts: 1942 | Location: Parker, CO | Registered: January 31, 2006Reply With QuoteReport 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, 2008Reply With QuoteReport 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, 2008Reply With QuoteReport 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.0.1M gen 240, Dev 8.2.04 gen 48, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
 
Posts: 2105 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] - Evaluate Variable in a Loop

Copyright © 1996-2018 Information Builders, leaders in enterprise business intelligence.