Focal Point
[SOLVED] Generating and Printing Grades

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

May 23, 2017, 02:46 PM
Terri1977
[SOLVED] Generating and Printing Grades
I have a WebFocus program that pulls grades. The issue is the table has repeating. Therefore, if the person took a course, received a grade, then the grade was updated or change, then there are several entries. I want it to give me the last (final) grade. In one of the tables there is a field called SHRTCKG_GRDE_CODE_FINAL but it pulls all the entries.

I need help so that it gives me the final grade per person per course per term.

Below is the program and some of the output:

I have adjusted it so that you can see the multiple entries for grades.

SET ALL = ON

JOIN PIDM_KEY IN AS_STUDENT_REGISTRATION_DETAIL TO SHRTCKG_PIDM IN SHRTCKG

DEFINE FILE AS_STUDENT_REGISTRATION_DETAIL
SEM/A15 = IF EDIT('&TERM', '$$$$99') EQ '60' THEN 'MAIN FALL' ELSE
IF EDIT('&TERM', '$$$$99') EQ '20' THEN 'MAIN SPRING' ELSE
IF EDIT('&TERM', '$$$$99') EQ '30' THEN 'MAIN SUMMER I' ELSE
IF EDIT('&TERM', '$$$$99') EQ '40' THEN 'MAIN SUMMER II' ELSE
IF EDIT('&TERM', '$$$$99') EQ '65' THEN 'FT SAM Fall/Win' ELSE
IF EDIT('&TERM', '$$$$99') EQ '25' THEN 'FT SAM Win/Spr' ELSE
IF EDIT('&TERM', '$$$$99') EQ '35' THEN 'FT SAM Spr/Sum' ELSE
IF EDIT('&TERM', '$$$$99') EQ '45' THEN 'FT SAM Sum/Fall' ELSE ' ';
YR1/A4 = EDIT('&TERM', '9999');
COURSE/A12 = SUBJ_CODE || COURSE_NUMBER || SECTION_NUMBER ;
COURSE1/A12 = IF SUBJ_CODE = 'CSC' THEN EDIT (COURSE , '999-999-999') ELSE
IF SUBJ_CODE = 'MIS' THEN EDIT (COURSE , '999-999-999') ELSE
IF SUBJ_CODE = 'HCM' THEN EDIT (COURSE , '999-999-999') ELSE
IF SUBJ_CODE = 'ART' THEN EDIT (COURSE , '999-999-999') ELSE EDIT( COURSE , '9999-999-999' ) ;
INSTRUCTOR/A77 = INSTRUCTOR_LAST_NAME || (', ' | INSTRUCTOR_FIRST_NAME);
INSTNAME/A20 = EDIT(INSTRUCTOR, '99999999999999999999');
STUDENT/A77 = LAST_NAME || (', ' | FIRST_NAME);
STUNAME/A30 = EDIT(STUDENT, '999999999999999999999999999999');
END


TABLE FILE AS_STUDENT_REGISTRATION_DETAIL
PRINT SHRTCKG_GRDE_CODE_FINAL AS 'GRADE'
BY COURSE1 AS 'COURSE'
BY INSTRUCTOR
BY CRN_KEY AS 'CRN'
BY STUDENT
BY ID
BY HIGHEST SHRTCKG_ACTIVITY_DATE
BY CLAS_DESC AS 'CLASS'
BY COURSE1 NOPRINT
WHERE TERM_CODE_KEY EQ '&TERM'
AND SHRTCKG_TERM_CODE EQ '&TERM'
AND REGISTERED_IND EQ 'Y'
AND ENROLLED_IND EQ 'Y'
AND SHRTCKG_GMOD_CODE EQ '0'
AND SECTION_NUMBER EQ 'D1' OR 'D2' OR 'D3' OR 'D4' OR 'D5' OR 'DE' OR 'D0' OR 'D5' OR 'D6' OR 'D41' OR 'D42' OR 'D43' OR 'D44' OR 'D45' OR 'D46' OR 'D47' OR 'D48' OR 'D49' OR '0D1' OR '0D2' OR '0D3' OR '0D4' OR '0D5'
AND COURSE_NUMBER IS-FROM '100' TO '299'
END

-*********This is a sample output *************-

CHEM-101-D1 Brown, Laura 3038 Alleye, Shari D14781867 2016/08/26 00:00:00 Senior WUA
WUA
2016/08/08 11:00:15 Senior FN
2016/08/08 10:59:49 Senior FN
Amko, Sam D14751203 2016/08/08 10:59:49 Senior A
2016/08/04 07:47:02 Senior B
Beck, Danita D14751887 2016/08/08 10:59:50 Senior A
Blow, Tim D14751696 2016/08/26 00:00:00 Senior WUA
WUA
2016/08/08 10:59:56 Senior FN
2016/08/08 10:59:50 Senior FN
Cole, Mya D14767317 2016/08/26 00:00:00 Sophomore WUA
WUA
2016/08/08 10:59:50 Sophomore FN
2016/08/04 07:46:52 Sophomore FN

This message has been edited. Last edited by: FP Mod Chuck,
May 23, 2017, 03:24 PM
MartinY
Please us the code tag, last icon from ribbon
</>
to embrace your code and sample data.

It gives you ability to indent and align.

Also what is what on your sample output. There is no title.

You have twice BY COURSE1 where the second is NOPRINT, so no need for it since the first one is BY COURSE1 why have it as the last one and NOPRINT ?

You PRINT SHRTCKG_GRDE_CODE_FINAL so all possible value will be displayed.
You may need an aggregation verb such as MAX or LST (or use SUM instead of PRINT) but since it's an alpha field, may not work as expected.
It will be better if you can have a numeric grade matching the alpha one. That way you'll be able to
 PRINT MAX.NUMGRADE NOPRINT
       SHRTCKG_GRDE_CODE_FINAL AS 'GRADE'

But still, it depends on the BY fields used. That could make the whole difference.

This message has been edited. Last edited by: MartinY,


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 23, 2017, 03:49 PM
Tom Flynn
TABLE FILE AS_STUDENT_REGISTRATION_DETAIL
SUM
SHRTCKG_GRDE_CODE_FINAL AS 'GRADE'
BY COURSE1 AS 'COURSE'
BY INSTRUCTOR
BY CRN_KEY AS 'CRN'
BY STUDENT
BY ID
BY HIGHEST 1 SHRTCKG_ACTIVITY_DATE
BY CLAS_DESC AS 'CLASS'
BY COURSE1 NOPRINT
WHERE TERM_CODE_KEY EQ '&TERM'
AND SHRTCKG_TERM_CODE EQ '&TERM'
AND REGISTERED_IND EQ 'Y'
AND ENROLLED_IND EQ 'Y'
AND SHRTCKG_GMOD_CODE EQ '0'
AND SECTION_NUMBER EQ 'D1' OR 'D2' OR 'D3' OR 'D4' OR 'D5' OR 'DE' OR 'D0' OR 'D5' OR 'D6' OR 'D41' OR 'D42' OR 'D43' OR 'D44' OR 'D45' OR 'D46' OR 'D47' OR 'D48' OR 'D49' OR '0D1' OR '0D2' OR '0D3' OR '0D4' OR '0D5'
AND COURSE_NUMBER IS-FROM '100' TO '299'
END


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
May 24, 2017, 12:33 PM
Terri1977
Thank you so much Tom.

I think that did the trick.


WebFOCUS 8
Windows, All Outputs