Focal Point
If...Else problem.

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/9101028762

January 24, 2008, 07:56 AM
Robab
If...Else problem.
I'm getting an error for a conditional statement I'm using, and I don't udderstand why webfocus is having problem with it. Here's my code:

COMPUTE DIVISIONCODE1/A4 = EDIT(L2NAME, '99$$') || EDIT(L2NAME, '$$$9');

COMPUTE DIVISIONCODE2/A4 = EDIT(L2NAME, '99$$') || EDIT(L2NAME, '$$9$');
PAYROLLORGANIZATIONCODE
L2NAME
POSITIONNAME
LUPOSITIONTYPEID
DISTRIBUTIONPERCENT
EXPANSIONOPTIONFULL
OCCUPANTNAME
GRANTNUMBER
CATEGORYCODENAME
WHERE L2NAME EQ '&DIVISIONNAME.().DIVISIONNAME.';
-IF &DIVISIONNAME EQ '5201'
WHERE PAYROLLORGANIZATIONCODE EQ DIVISIONCODE1;
-ELSE
WHERE PAYROLLORGANIZATIONCODE EQ DIVISIONCODE2;


Any help would be greatly appreciated .


WebFocus 7.1
Developer Studio
January 24, 2008, 08:39 AM
FrankDutch
Robab

I suppose you have left out some part of the program and this is a FEX that starts with TABLE FILE xxx

You are mixing DM commands (starting with - ) with TABLE commands.




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

January 24, 2008, 08:52 AM
Tony A
As Frank says, you are mixing DM with core FOCUS. Check out the various posts that have already dealt with the differences between these two "languages".

Then you might understand why you need to do this -

COMPUTE DIVISIONCODE1/A4 = EDIT(L2NAME, '99$$') || EDIT(L2NAME, '$$$9');

COMPUTE DIVISIONCODE2/A4 = EDIT(L2NAME, '99$$') || EDIT(L2NAME, '$$9$');
PAYROLLORGANIZATIONCODE
L2NAME
POSITIONNAME
LUPOSITIONTYPEID
DISTRIBUTIONPERCENT
EXPANSIONOPTIONFULL
OCCUPANTNAME
GRANTNUMBER
CATEGORYCODENAME
WHERE L2NAME EQ '&DIVISIONNAME.().DIVISIONNAME.'
-SET &Div_Column = IF &DIVISIONNAME EQ '5201' THEN 'DIVISIONCODE1' ELSE 'DIVISIONCODE2';
WHERE PAYROLLORGANIZATIONCODE EQ &Div_Column

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
January 24, 2008, 09:15 AM
Robab
Hi Frank,

Thank you for responding.
What I'm trying to accomplish here is to filter my data based on the value of L2Name column. I am using a launch page that uses a drop down box generated with the L2Name, and once I capture that I want to filter the data based on it. Now I'm thinking may be I can use a procedure just to generate a combo box with L2Name and another procedures that checks for the value of L2Name(and I don't know how to refer to a variable in another procedure) and execute a different focexec based on the value of L2Name. I have a deadline to meet by the end of today. The idea seems to be easy, I just don't know how to make it work in Webfocus!!
Any advice?


WebFocus 7.1
Developer Studio
January 24, 2008, 09:46 AM
Glenda
What if you change:

-IF &DIVISIONNAME EQ '5201'
WHERE PAYROLLORGANIZATIONCODE EQ DIVISIONCODE1;
-ELSE
WHERE PAYROLLORGANIZATIONCODE EQ DIVISIONCODE2;


to:

]-IF &DIVISIONNAME EQ '5201' GOTO TEST1;
-GOTO TEST2
-TEST1
WHERE PAYROLLORGANIZATIONCODE EQ DIVISIONCODE1;
-GOTO CONT1
-TEST2
WHERE PAYROLLORGANIZATIONCODE EQ DIVISIONCODE2;
-GOTO CONT1
-CONT1



Glenda

In FOCUS Since 1990
Production 8.2 Windows
January 24, 2008, 09:48 AM
Glenda
Oops! Music

The ] should be removed from the beginning of my code.

Sorry.


Glenda

In FOCUS Since 1990
Production 8.2 Windows
January 24, 2008, 09:55 AM
Robab
Tony, I took your suggestion. I modified my code to:

TABLE FILE spdisplaypositiondistributiontwo
PRINT
COMPUTE DIVISIONCODE1/A4 = EDIT(L2NAME, '99$$') || EDIT(L2NAME, '$$$9');NOPRINT

COMPUTE DIVISIONCODE2/A4 = EDIT(L2NAME, '99$$') || EDIT(L2NAME, '$$9$');NOPRINT
PAYROLLORGANIZATIONCODE
L2NAME
POSITIONNAME
LUPOSITIONTYPEID
DISTRIBUTIONPERCENT
EXPANSIONOPTIONFULL
OCCUPANTNAME
GRANTNUMBER
CATEGORYCODENAME
WHERE L2NAME EQ '&DIVISIONNAME.DIVISIONNAME.'
-SET &Div_Column = IF &DIVISIONNAME EQ '5201' THEN 'DIVISIONCODE1' ELSE 'DIVISIONCODE2';
WHERE PAYROLLORGANIZATIONCODE EQ &Div_Column


Now I'm getting this error:

COMPUTED FIELDS CAN ONLY BE REFERENCED IN A WHERE TOTAL
(FOC009) INCOMPLETE REQUEST STATEMENT
BYPASSING TO END OF COMMAND


WebFocus 7.1
Developer Studio
January 24, 2008, 11:57 AM
Robab
This is what I ended up using and it worked( I had to use define instead of edit:

-DEFAULT &DIVISIONNAME = FOC_NONE;
-* File DisplayPositionDivisionAllReport.fex
DEFINE FILE spdisplaypositiondistributiontwo
-*DIVISIONCODE1/A4 = EDIT(L2NAME, '99$$') || EDIT(L2NAME, '$$$9');
-*DIVISIONCODE2/A4 = EDIT(L2NAME, '99$$') || EDIT(L2NAME, '$$9$');

PAY_ORG_CODE/A4 = IF L2NAME EQ '5201' THEN
EDIT(L2NAME, '99$$') || EDIT(L2NAME, '$$$9') ELSE
EDIT(L2NAME, '99$$') || EDIT(L2NAME, '$$9$');
END
TABLE FILE SPDISPLAYPOSITIONDISTRIBUTIONTWO
-*COMPUTE DIVISIONCODE1/A4 = EDIT(L2NAME, '99$$') || EDIT(L2NAME, '$$$9');
-*COMPUTE DIVISIONCODE2/A4 = EDIT(L2NAME, '99$$') || EDIT(L2NAME, '$$9$');
-*-SET &Div_Column = IF &DIVISIONNAME EQ '5201' THEN 'DIVISIONCODE1' ELSE 'DIVISIONCODE2';
-*WHERE PAYROLLORGANIZATIONCODE EQ '&Div_Column.EVAL';
-*WHERE PAYROLLORGANIZATIONCODE EQ DIV_COLUMN;
PRINT
PAY_ORG_CODE AS 'Payroll Organization Code'
L2NAME NOPRINT
POSITIONNAME
LUPOSITIONTYPEID NOPRINT
DISTRIBUTIONPERCENT AS 'Distribution Percent'
EXPANSIONOPTIONFULL AS 'Expansion Option'
OCCUPANTNAME AS 'Occupant Name'
GRANTNUMBER AS 'Grant Number'
CATEGORYCODENAME AS 'Category Code Name'
WHERE L2NAME EQ '&DIVISIONNAME';


WebFocus 7.1
Developer Studio
January 24, 2008, 12:10 PM
GinnyJakes
quote:
PAY_ORG_CODE/A4 = IF L2NAME EQ '5201' THEN
EDIT(L2NAME, '99$$') || EDIT(L2NAME, '$$$9') ELSE
EDIT(L2NAME, '99$$') || EDIT(L2NAME, '$$9$');


Unless I'm missing something, couldn't you simplify your EDIT to:

 PAY_ORG_CODE/A4 = IF L2NAME EQ '5201' THEN
EDIT(L2NAME, '99$9') ELSE EDIT(L2NAME, '999$');
 



Ginny
---------------------------------
Prod: WF 7.7.01 Dev: WF 7.6.9-11
Admin, MRE,self-service; adapters: Teradata, DB2, Oracle, SQL Server, Essbase, ESRI, FlexEnable, Google
January 24, 2008, 01:30 PM
Darin Lee
Robab,
There are multiple ways you could handle this, with and without using DM code. If this works for you, great job.

One thing I noticed is that you've gone from two WHERE statements in you first fex (L2NAME and PAYROLLORGANIZATIONCODE) to only one in your last post (for L2NAME). You would get different results, but maybe that was intended because you've also changed the values of the output column (PAY_ORG_CODE)?


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat
January 24, 2008, 02:27 PM
Robab
Hi Darin,

Thank you for responding, and yes I was going to eventually use one output column based on the selected value from L2Name.


WebFocus 7.1
Developer Studio