MFUT_TESTFLYER.cbl
program-id. MFUT_TESTFLYER.
working-storage section.
copy "mfunit.cpy".
copy "GetFlyerLevel.cpy" replacing ==:prefix:== by ==ws==.
01 ws-expected-award-level td-flyer-status.
01 ws-earned td-flyer-status-points.
01 mfu-dd-InitialStatus is MFU-DD-VALUE external.
01 mfu-dd-FinalStatus is MFU-DD-VALUE external.
01 mfu-dd-InitialPoints is MFU-DD-VALUE external.
01 mfu-dd-EarnedPoints is MFU-DD-VALUE external.
procedure division.
move mfu-dd-InitialStatus to ws-award-level
move mfu-dd-FinalStatus to ws-expected-award-level
move function numval(mfu-dd-InitialPoints) to ws-award-points
move function numval(mfu-dd-EarnedPoints) to ws-earned
$if show-progress defined
display " Data data driven test for " MFU-DD-DIAG-MSG
$end
call "GetFlyerLevel" using
by reference ws-flyer-info
by reference ws-earned
end-call
if ws-award-level not equal ws-expected-award-level
goback returning MFU-FAIL-RETURN-CODE
end-if
goback returning MFU-PASS-RETURN-CODE.
entry "MFUM_TESTFLYER".
move "csv:FrequentFlyer.csv" to MFU-MD-TESTDATA
goback.
end program.
GetFlyerLevel.cbl
program-id. GetFlyerLevel.
linkage section.
copy "GetFlyerLevel.cpy" replacing ==:prefix:== by ==lnk==.
01 lnk-extra-status-points td-flyer-status-points.
procedure division using lnk-flyer-info, lnk-extra-status-points.
add lnk-extra-status-points to lnk-award-points
evaluate lnk-award-points
when < 300
move "Bronze" to lnk-award-level
when >= 300 and < 700
move "Silver" to lnk-award-level
when >= 700 and < 1500
move "Gold" to lnk-award-level
when >= 1500 and < 10000
move "Platinum" to lnk-award-level
when other
move "Diamond" to lnk-award-level
end-evaluate
end program.
GetFlyerLevel.cpy
01 td-flyer-status-points pic 9(9) typedef.
01 td-flyer-status pic x(20) typedef.
01 :prefix:-flyer-info.
03 :prefix:-award-level td-flyer-status.
03 :prefix:-award-points td-flyer-status-points.
FrequentFlyer.csv
InitialStatus,InitialPoints,EarnedPoints,Deductions,FinalStatus
Bronze,0,100,0,Bronze
Bronze,0,300,50,Silver
Bronze,100,200,66,Silver
Bronze,0,700,1,Gold
Bronze,0,1500,800,Platinum
Platinum,1600,12000,600,Diamond