Focal Point
[SOLVED]Need help in coding....

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

May 02, 2016, 10:54 AM
N/A
[SOLVED]Need help in coding....
Hello,
I need help in certain task and I am new in developement.
By Default my report shows ALL coverage type A, B, C, D ...(covergarage type)
my aim is to show only 'A' when selected A cover type and B when slected B cover type...so on.... Also when selected ALL it should show A, B, C, D covergae type.
My code is like this but not working fully.
-DEFAULT &p_Covertype = ' A '; ( I can give value like B, C, D...so on)
-DEFAULT &p_WHEREDIDICLICK= 'gg'; ( it shoul give all covergae when ALL is given as value)
DEFINE FILE
aa, aoao,bb,bobo,cc,coco,dd,dodo
END
TABLE.....
PRINT
-IF &p_Covertype EQ 'A' THEN GOTO LBL_A;
-LBL_A
aa
aoao
-GOTO LBL_DWCTC;
-IF &p_WHEREDIDICLICK.QUOTEDSTRING EQ 'ALL' THEN GOTO LBL_ALLCOV;
- LBL_ALLCOV
aa,aoao,bb,bobo,cc,coco,dd,dodo
-GOTO LBL_DWCTC;
-IF &p_Covertype EQ 'B' THEN GOTO LBL_B;
-LBL_B
bb,bobo
-GOTO LBL_DWCTC;
-IF &p_WHEREDIDICLICK.QUOTEDSTRING EQ 'ALL' THEN GOTO LBL_ALLCOV;
aa,aoao,bb,bobo,cc,coco,dd,dodo
-GOTO LBL_DWCTC;
.......
BY
WHERE
STYLE
ENDSTYLE
END

NN

This message has been edited. Last edited by: <Emily McAllister>,


WebFOCUS 8
Windows 7
HTML
May 02, 2016, 11:14 AM
MartinY
This looks like a spaghetti...

1- What are you CLEARY attempting to do?

2- It looks like you are trying to display only certain columns based on selection but also display them all according to another selection?

3- You have a loop in your GOTOs : "GOTO LBL_ALLCOV" exist twice in the same loop block.

4- You have -IF that go to the next line under the test which as no sense...

Suggestion : try to make a clear definition of your need and try to make sample with CAR file.
It may be clear in your head but it doesn't for me when looking at your example; getting more confused.


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
May 02, 2016, 11:31 AM
BabakNYC
To show or hide columns I usually set up a variable set to either blank or NOPRINT based on whatever logic you want and then put all the fields in one report with that variable. When the user says No, the variable will hide the field.

-SET &NP = IF &SHOW.(<Yes,Y>,<No,N>).Show Costs?. EQ 'N' THEN 'NOPRINT' ELSE '';
TABLE FILE CAR
SUM SALES 
RETAIL_COST &NP
DEALER_COST &NP
BY COUNTRY
BY CAR
END



WebFOCUS 8206, Unix, Windows
May 02, 2016, 12:22 PM
N/A
Hello,
The code I gave was working before partly but it is missing some string.
let me be more simpler:
1. What are you CLEARY attempting to do? I am trying to select basing on certain selection.

-DEFAULT &p_Covertype = ' FN '
-IF &p_Covertype EQ 'A' THEN GOTO LBL_A;
-LBL_A
aa
bb
cc
-IF &p_Covertype EQ 'A' THEN GOTO LBL_B;

-LBL_B
GG
JJ
KK
But if All is selected it should give all type coverage. Lets assume there are A,B,C,D coverage type. I am doing it in Text Editor.


WebFOCUS 8
Windows 7
HTML
May 02, 2016, 12:34 PM
Ricardo Augusto
N/A,

Read about FILTERING using WHERE and/or IF.


# SQL

SELECT * FROM YOUR_TABLE
WHERE coverage_type_field = 'A' --replace as need;

# FOCUS

TABLE FILE YOUR_TABLE
PRINT *
IF coverage_type_field EQ '&COVERAGE'
END

This will prompt to you type de desired value of &COVERAGE

This message has been edited. Last edited by: Ricardo Augusto,


WebFOCUS 8.1.05 / APP Studio
May 02, 2016, 12:43 PM
BabakNYC
-DEFAULT &p_Covertype = ' FN '
-IF &p_Covertype NE 'A' THEN GOTO SKIP_A;
aa
bb
cc
-GOTO DONE;
-SKIP_A;
-IF &p_Covertype NE 'B' THEN GOTO SKIP_B;
GG
JJ
KK
-GOTO DONE;
-SKIP_B;
aa
bb
cc
GG
JJ
KK

-DONE;



WebFOCUS 8206, Unix, Windows
May 02, 2016, 01:02 PM
N/A
SORRY. THERE WAS A TYPO
-DEFAULT &p_Covertype = ' FN '
-IF &p_Covertype EQ 'A' THEN GOTO LBL_A;
-LBL_A
aa
bb
cc
-IF &p_Covertype EQ 'B' THEN GOTO LBL_B;

-LBL_B
GG
JJ
KK
But if All is selected it should give all type coverage. Lets assume there are A,B,C,D coverage type. I am doing it in Text Editor.


WebFOCUS 8
Windows 7
HTML
May 02, 2016, 01:13 PM
BabakNYC
Please look at the code above. Your IF THEN ELSE has to account for what happens when the variable EQ and NE to 'A'. What you have coded will not work.


WebFOCUS 8206, Unix, Windows
May 02, 2016, 01:54 PM
N/A
Hello Babak,
Thanks a lot! Yes I am getting some insight from your code but my requirements are not solved totally. May be I am not able to explain properly so I am going step by step.
-DEFAULT &p_Covertype = ' AssistedLivingCare '


-IF &p_Covertype EQ 'AssistedLivingCare' THEN GOTO LBL_ALC;
-LBL_ALC
ACCA
ACTP
-GOTO DONE;
-IF &p_Covertype EQ 'BusinessProperty' THEN GOTO LBL_BP;
-LBL_BP
BPC
BPAC
BPTP
-DONE;


Here if I put Assisted Living Care I am getting value but if I put Business Property I don't get value. There is something missing here.Please suggest. I have to make like 30 LBL like this.
please suggest and then I will ask my next requirements.


WebFOCUS 8
Windows 7
HTML
May 02, 2016, 02:04 PM
MartinY
You haven't applied BabakNYC suggestion properly

-DEFAULT &p_Covertype = ' FN '
-IF &p_Covertype NE 'AssistedLivingCare' THEN GOTO SKIP_A;
ACCA
ACTP
-GOTO DONE;

-SKIP_A;
-IF &p_Covertype NE 'BusinessProperty' THEN GOTO SKIP_B;
BPC
BPAC
BPTP
-GOTO DONE;

-SKIP_B;
ACCA
ACTP
BPC
BPAC
BPTP

-DONE;


You should test with a NEGATIVE (IF test NE condition) logic to bypass what you don't want to be proceed.

Having a IF that go to the following lines just under the IF, makes no sense.

You have nothing displayed when you pass 'BusinessProperty' because your first "-IF &p_Covertype EQ 'AssistedLivingCare' " is not true so the GOTO is not performed but it still continue to the next lines and perform:
-LBL_ALC
ACCA
ACTP
-GOTO DONE;


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
May 02, 2016, 03:37 PM
N/A
Thanks a Ton ! it really worked and worked. Good One


WebFOCUS 8
Windows 7
HTML