# 1. Goal A purchasing department rates its suppliers. A scorecard program calls the rating before it prints the scorecard. The program needs the weighted score and the grade of a supplier. # 2. Open questions None. # 3. Context - All objects are in package $TMP. - A supplier is rated in three criteria: price, quality, and delivery. - Each criterion gets an integer rating from 1 (very poor) to 5 (very good). - The scorecard program passes the three ratings to the class. It reads the score and the grade from the result. # 4. Contract - Create the class {{P}}SUPPLIER_SCORE in package $TMP. - The class is public, final, and has a public constructor without parameters. - The class has these public types: - TY_RATING: an integer type for one rating. - TY_SCORE: a packed number with length 5 and 1 decimal place. - TY_GRADE: a character type with length 1. - TY_RESULT: a structure with the components SCORE (type TY_SCORE) and GRADE (type TY_GRADE). - The class has exactly this public method: METHODS evaluate IMPORTING iv_price TYPE ty_rating iv_quality TYPE ty_rating iv_delivery TYPE ty_rating RETURNING VALUE(rs_result) TYPE ty_result. - Do not add other public methods. # 5. Business rules Apply the rules in this sequence. 1. A rating is valid if it is an integer from 1 to 5. If at least one of the three ratings is not valid, return score 0.0 and grade 'X'. 2. Quality is a knock-out criterion. If the quality rating is 1, return score 0.0 and grade 'X'. 3. Calculate the weighted score: score = (price * 40 + quality * 35 + delivery * 25) / 100. 4. Round the score to one decimal place. Use commercial rounding, that is, round half away from zero. 5. Derive the grade from the rounded score: - 4.5 or more: 'A' - 3.5 or more: 'B' - 2.5 or more: 'C' - 1.5 or more: 'D' - less than 1.5: 'E' # 6. Constraints - Release target: SAP_BASIS 816. - Coding standards: Clean ABAP. Every method has fewer than 40 statements. No global variables. No comment that restates the code. - Out of scope: database access, ALV, dynpro, and changes to other objects. # 7. Acceptance - The class is active and has no syntax error. - The hidden tests pass. - Write your own ABAP Unit tests for the class.