As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.
Join the TIBCO Community TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.
From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
Request access to the private WebFOCUS User Group (login required) to network with fellow members.
Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.
Hi, i need a loop to read multiple csv files. The structure of the files are always the same, the only different is the name. Can i also use only one master file and replace the name with &variables???
Regards
christianThis message has been edited. Last edited by: ChristianP,
WF Production Version: 7.7.02M WF Test Version: 7.7.02M Developer Studio: 7.7.02 HTML, EXL2K, FLEX, PDF,PPT
Originally posted by ChristianP: Hi, i need a loop to read multiple csv files. The structure of the files are always the same, the only different is the name. Can i also use only one master file and replace the name with &variables???
Regards
christian
I did something very similar last year. Code was written before I knew WebFOCUS had a looping syntax. I still like mine better, though. ;-)
-SET &FROMDATE = '20110401';
-SET &TODATE = '20110403';
-SET &BEDS_IN_UNIT = '14';
-SET &DEPARTMENT = '101926400';
-SET &MYDATE = &FROMDATE;
-SET &DAYSTOLOOP = (&TODATE - &FROMDATE) + 1;
-SET &ILOOPNO = 0;
-CONTINUE
-* SET THE 'LOOP' VARS ONLY TO CALC THE LOOP DAYS
-SET &FROMDATELOOP = DATECVT(&FROMDATE, 'I8YYMD', 'YYMD');
-SET &TODATELOOP = DATECVT(&TODATE, 'I8YYMD', 'YYMD');
-SET &DAYSTOLOOP = DATEDIF(&FROMDATELOOP,&TODATELOOP,'D');
-SET &DAYSTOLOOP = &DAYSTOLOOP + 1;
-*-TYPE &|FROMDATE = &FROMDATE
-*-TYPE &|TODATE = &TODATE
-*-TYPE &|MYDATE = &MYDATE
-*-TYPE &|DAYSTOLOOP = &DAYSTOLOOP
-*-EXIT
-DOLOOP3
-SET &IHMFD = 'BTLOOP' || &ILOOPNO;
DEFINE FILE DMBEDOCCDW
THE_DATE/YYMD = HDATE(DATE_OCC, 'YYMD');
MY_START_DATE/YYMD = &MYDATE;
START_00/HYYMDs = HADD(DT(&MYDATE 00:00:00), 'HOUR', 0, 8, 'HYYMDs');
END_00/HYYMDS = HADD(DT(&MYDATE 00:59:59), 'HOUR', 0, 8, 'HYYMDs');
OCC_00/I4 = IF (PARENT_FROM_CALC_DATETIME FROM START_00 TO END_00
OR PARENT_TO_CALC_DATETIME FROM START_00 TO END_00
OR START_00 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME
OR END_00 FROM PARENT_FROM_CALC_DATETIME TO PARENT_TO_CALC_DATETIME) THEN 1 ELSE 0;
PARENT_DATETIME_00/HYYMDs = PARENT_EFFECTIVE_TIME;
CHILD_DATETIME_00/HYYMDs = CHILD_EFFECTIVE_TIME;
MY_START_DATE_00/YYMD = &MYDATE;
MY_START_DATETIME_00/HYYMDS = DT(&MYDATE 00:00:00);
MY_END_DATE_00/YYMD = &MYDATE;
MY_END_DATETIME_00/HYYMDS = DT(&MYDATE 00:59:59);
FROM_00/HYYMDs MISSING ON = IF PARENT_DATETIME_00 LT START_00 THEN MY_START_DATETIME_00 ELSE PARENT_EFFECTIVE_TIME;
TO_00/HYYMDs MISSING ON = IF CHILD_DATETIME_00 GT END_00 THEN MY_END_DATETIME_00 ELSE CHILD_EFFECTIVE_TIME;
SECS_IN_BED_FOR_00/I10 = IF OCC_00 EQ 1 THEN HDIFF(TO_00, FROM_00, 'SECONDS', 'I10') + 1 ELSE 0;
UTIL_PCT_00/D10.2 = IF OCC_00 EQ 1 THEN (SECS_IN_BED_FOR_00 / 3600) * 100 ELSE 0;
[REPEATED 23 MORE TIMES, INCREMENTING THE HOUR]
END
TABLE FILE DMBEDOCCDW
PRINT
PAT_ENC_CSN_ID
PAT_ID
MY_START_DATE
PARENT_FROM_CALC_DATETIME
PARENT_TO_CALC_DATETIME
OCC_00
FROM_00
TO_00
OCC_00
SECS_IN_BED_FOR_00
UTIL_PCT_00
OCC_01
SECS_IN_BED_FOR_01
UTIL_PCT_01
OCC_02
SECS_IN_BED_FOR_02
UTIL_PCT_02
OCC_03
SECS_IN_BED_FOR_03
UTIL_PCT_03
OCC_04
SECS_IN_BED_FOR_04
UTIL_PCT_04
OCC_05
SECS_IN_BED_FOR_05
UTIL_PCT_05
OCC_06
SECS_IN_BED_FOR_06
UTIL_PCT_06
OCC_07
SECS_IN_BED_FOR_07
UTIL_PCT_07
OCC_08
SECS_IN_BED_FOR_08
UTIL_PCT_08
OCC_09
SECS_IN_BED_FOR_09
UTIL_PCT_09
OCC_10
SECS_IN_BED_FOR_10
UTIL_PCT_10
OCC_11
SECS_IN_BED_FOR_11
UTIL_PCT_11
OCC_12
SECS_IN_BED_FOR_12
UTIL_PCT_12
OCC_13
SECS_IN_BED_FOR_13
UTIL_PCT_13
OCC_14
SECS_IN_BED_FOR_14
UTIL_PCT_14
OCC_15
SECS_IN_BED_FOR_15
UTIL_PCT_15
OCC_16
SECS_IN_BED_FOR_16
UTIL_PCT_16
OCC_17
SECS_IN_BED_FOR_17
UTIL_PCT_17
OCC_18
SECS_IN_BED_FOR_18
UTIL_PCT_18
OCC_19
SECS_IN_BED_FOR_19
UTIL_PCT_19
OCC_20
SECS_IN_BED_FOR_20
UTIL_PCT_20
OCC_21
SECS_IN_BED_FOR_21
UTIL_PCT_21
OCC_22
SECS_IN_BED_FOR_22
UTIL_PCT_22
OCC_23
SECS_IN_BED_FOR_23
UTIL_PCT_23
BY THE_DATE
BY BED_LABEL
WHERE DATE_OCC EQ DT(&MYDATE);
ON TABLE HOLD AS &IHMFD
END
-SET &MYDATE = &MYDATE + 1;
-SET &ILOOPNO = &ILOOPNO + 1;
-IF &ILOOPNO EQ &DAYSTOLOOP GOTO BREAKLOOP3 ELSE GOTO DOLOOP3;
-BREAKLOOP3
-SET &JLOOPNO = 1;
TABLE FILE BTLOOP0
PRINT
*
ON TABLE HOLD AS BT_BED_OCC_BASE
-IF &JLOOPNO EQ &DAYSTOLOOP GOTO BREAKLOOP4 ELSE GOTO DOLOOP4;
-DOLOOP4
MORE
-SET &JHMFD = 'BTLOOP' || &JLOOPNO;
FILE &JHMFD.EVAL
-SET &JLOOPNO = &JLOOPNO + 1;
-IF &JLOOPNO EQ &DAYSTOLOOP GOTO BREAKLOOP4 ELSE GOTO DOLOOP4;
-BREAKLOOP4
END