IBI WebFOCUS - Restricting calendar date range on the launch page dynamically using WebFOCUS procedure

Dear Developers, 

Recently we received a requirement where on the launch page, we wanted to restrict the user to select the dates in a specified date range. The requirement basically came up because in calendar, user can select 10 years past and future dates from current year. There is no point in allowing user to select a date for which data is not available or it is not relevant for the report. We can simply do this if the range is static and not going to change in future however that is not the scenario. We would need to do this from WebFOCUS procedure so that if the range changes in future, it should automatically reflect in the launch page.

First for all, we would need to create a .fex file which will have similar content (here I am 4 years past and 3 years future dates) : 

-* File: IBFS:/localhost/EDA/EDASERVE/APPPATH/pravin/purge_date.fex Created by WebFOCUS AppStudio

DEFINE FILE CENTURYCUSTOMERS
StDt1/MDYY=&MDYY;
StDt2/MDYY=DATEADD(StDt1,'Y',-4);
StDt3/MDYY=DATEMOV(StDt2,'EOY');
StDt4/A8MDYY=StDt3;
StDt/YYMD=StDt4;

EnDt1/MDYY=&MDYY;
EnDt2/MDYY=DATEADD(EnDt1,'Y',3);
EnDt3/MDYY=DATEMOV(EnDt2,'EOY');
EnDt4/A8MDYY=EnDt3;
EnDt/YYMD=EnDt4;
END

TABLE FILE CENTURYCUSTOMERS
PRINT StDt
      CUSTOMERID NOPRINT
WHERE RECORDLIMIT EQ 1
ON TABLE HOLD AS START_DATE FORMAT FOCUS
END
-RUN

TABLE FILE CENTURYCUSTOMERS
PRINT EnDt
      CUSTOMERID NOPRINT
WHERE RECORDLIMIT EQ 1
ON TABLE HOLD AS END_DATE FORMAT FOCUS
END
-RUN

USE
START_DATE.FOC AS START_DATE
END_DATE.FOC AS START_DATE
END
-RUN
-*****************Table file DATES will hold both Start Date and End Date in same hold file*************
TABLE FILE START_DATE
PRINT StDt
ON TABLE PCHOLD FORMAT XML
END


I have used CENTURYCUSTOMERS since I am using App Studio where CAR file is not present. You can use any dummy table since we will not use any column from it. Now save that file in your application folder with name as purge_date.fex.
Now select Dynamic under Popup Calendar Settings as provided in the below screen:



Now your launch page is ready with the limitation of start date and end date coming from the .fex file. Please have a look at the screen shot once we run the report.
I thought it is worth sharing as it can save some time of yours during coding.

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

Comments

Popular posts from this blog

IBI WebFOCUS - Functions available and syntax to use

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

IBI WebFOCUS - Testing and Debugging in WebFOCUS codes