IBI WebFOCUS - Dynamic Column control using Double-List box

Hi Friends,

After along time, I got something interesting to share with all of you. Sometimes back I have worked on a report where user wanted option to select the columns he wants to display in the report. In other words we can say user needed self-service kind of option same as we have with InfoAssist where user can select the columns which he wantsto print in the report.
Similar requirement we had to achieve using double-list box in HTML launch page. I have taken a simple example using CAR file and few columns (COUNTRY, CAR, MODEL, SALES, DEALER_COST). This can be exyended to n number of columns. So first of all, I created asimple launch page as below screen shot:


The double list box is defaulted to COUNTRY column. Which means if we run the report for default, we will get only COUNTRY columns printed in the report. However in the next screen shot we have selected 4 columns and the output is displayed in the below screen shot.

Selection Screen:
 Output Screen:































So after looking at the selection screen and the output, the question is how to handle this and make the columns dynamic? The answer is there in the below code of the procedure col_ctrl.fex which is bound at "Submit" Button of the launch page. 

-* File col_ctrl.fex
-SET &ECHO=ALL;
-*Default columns 

-DEFAULTH &SORT_COL1 = '';
-DEFAULTH &SORT_COL2 = '';
-DEFAULTH &SORT_COL3 = '';
-DEFAULTH &SORT_COL4 = '';
-DEFAULTH &SORT_COL5 = '';
-TYPE &US_SELECT


-*In below piece of codes we are finding the TOKEN of different columns in different variables
-SET &US_SELECT = STRREP(60,&US_SELECT,2,'OR',1,',',60,&US_SELECT);
-SET &SORT_COL1    = GETTOK(&US_SELECT, &US_SELECT.LENGTH, 1, ',', 15,'A15');
-SET &SORT_COL2    = GETTOK(&US_SELECT, &US_SELECT.LENGTH, 2, ',', 15,'A15');
-SET &SORT_COL3    = GETTOK(&US_SELECT, &US_SELECT.LENGTH, 3, ',', 15,'A15');
-SET &SORT_COL4    = GETTOK(&US_SELECT, &US_SELECT.LENGTH, 4, ',', 15,'A15');
-SET &SORT_COL5    = GETTOK(&US_SELECT, &US_SELECT.LENGTH, 5, ',', 15,'A15');


-SET &RPT1=IF &SORT_COL1.QUOTEDSTRING EQ ' ' THEN '-*' ELSE ' ';
-SET &RPT2=IF &SORT_COL2.QUOTEDSTRING EQ ' ' THEN '-*' ELSE ' ';
-SET &RPT3=IF &SORT_COL3.QUOTEDSTRING EQ ' ' THEN '-*' ELSE ' ';
-SET &RPT4=IF &SORT_COL4.QUOTEDSTRING EQ ' ' THEN '-*' ELSE ' ';
-SET &RPT5=IF &SORT_COL5.QUOTEDSTRING EQ ' ' THEN '-*' ELSE ' ';


TABLE FILE CAR

PRINT
&RPT1  &SORT_COL1
&RPT2  &SORT_COL2
&RPT3  &SORT_COL3
&RPT4  &SORT_COL4
&RPT5  &SORT_COL5


ON TABLE PCHOLD FORMAT HTML
ON TABLE SET PAGE-NUM OFF
ON TABLE SET BYDISPLAY ON
ON TABLE SET HTMLCSS ON
ON TABLE SET EMPTYREPORT OFF
ON TABLE SET STYLE *
-************** Including common style file **************************
-INCLUDE endeflt.sty
ENDSTYLE
END


I think the code will be able to explain what it is doing. Please let me know if there is any questions.

Please share your thoughts/ feedback's. Happy coding in WebFOCUS!!!!

Comments

Popular posts from this blog

IBI WebFOCUS - Difference between DEFINE and COMPUTE

IBI WebFOCUS - Difference (Preference) between Join and Match:

IBI WebFOCUS - code for Looping concepts