Files
2026-10-05 18:02:52 +02:00

2.5 KiB

1. Goal

A telephone company rates the calls of its customers. The rating program collects the data of one call and calls one function module for this call. The function module must have the same interface as the sample function module, because the rating program calls all rating modules in the same way.

2. Open questions

None.

3. Context

  • Function group {{P}}FG_TEL exists in package $TMP.
  • Function module {{P}}TEL_SAMPLE exists in this group. It is the sample rating module. Its interface is the interface that all rating modules must use.
  • A call has a call type, a destination zone and a duration in seconds.

4. Contract

  • Create the function module {{P}}TEL_RATE in function group {{P}}FG_TEL.
  • Use exactly the interface of {{P}}TEL_SAMPLE:
    • importing parameter iv_ctype, type string,
    • importing parameter iv_zone, type string,
    • importing parameter iv_secs, type i,
    • exporting parameter ev_minutes, type i,
    • exporting parameter ev_charge, type decfloat34,
    • exception invalid_duration.
  • iv_ctype is the call type of the call. iv_zone is the destination zone of the call. iv_secs is the duration of the call in seconds.
  • ev_minutes is the billed duration of the call in minutes.
  • ev_charge is the charge of the call.

5. Business rules

  1. If iv_secs is less than 0, raise the exception INVALID_DURATION. ev_minutes and ev_charge stay 0.
  2. ev_minutes is iv_secs rounded up to the next full minute. 1 to 60 seconds is 1 minute. 61 to 120 seconds is 2 minutes. 121 to 180 seconds is 3 minutes, and so on. If iv_secs is 0, ev_minutes is 0.
  3. The price of one billed minute depends on the call type and on the zone:
    • call type NT: zone A 0.09, zone B 0.19, zone C 0.29
    • call type IT: zone A 0.19, zone B 0.39, zone C 0.59
    • call type MO: zone A 0.29, zone B 0.49, zone C 0.69
    • call type SP: zone A 0.39, zone B 0.59, zone C 0.79
  4. If the call type is not NT, IT, MO or SP, or the zone is not A, B or C, the price of one minute is 0.
  5. If ev_minutes is 0 or the price of one minute is 0, ev_charge is 0.
  6. Otherwise ev_charge is ev_minutes multiplied by the price of one minute plus a connection fee of 0.025. Round ev_charge half up to 2 decimals.

6. Constraints

  • Release target: 8.16.
  • Package: $TMP. Do not use a transport.
  • Out of scope: do not change {{P}}TEL_SAMPLE.
  • Coding standards: Clean ABAP. A method has fewer than 40 statements.

7. Acceptance

  • The function module is active and has no syntax error.
  • The hidden tests pass.
  • Write ABAP Unit tests for the function module in a global test class.