Skip to content

Utility Classes

Ankit Kumar Singh edited this page Sep 9, 2025 · 2 revisions

๐Ÿ› ๏ธ Utility Classes

This page documents the key utility classes used in the Fleet Management System (ABAP RAP v1). These classes provide supporting functionalityโ€”such as test data loadingโ€”to streamline project development and demo scenarios.


๐Ÿš€ Data Initializer: ZAKS_FM_FILL

The class ZAKS_FM_FILL is a public utility class that helps developers and testers quickly populate the core database tables (ZAKS_VEHICLE, ZAKS_TRIP, ZAKS_MAINTENANCE) with rich sample data for demonstration or testing purposes.

โœจ Key Features

  • Resets and refills the main tables with fresh sample records.
  • Implements the standard interface IF_OO_ADT_CLASSRUN for easy execution in ABAP Development Tools (ADT).
  • Covers a wide variety of vehicles, trips, and maintenance examples for comprehensive demo coverage.

๐Ÿ’ป ABAP Definition

CLASS zaks_fm_fill DEFINITION
  PUBLIC
  FINAL
  CREATE PUBLIC .

  PUBLIC SECTION.
    INTERFACES : if_oo_adt_classrun.
ENDCLASS.

โš™๏ธ ABAP Implementation (Core Logic)

CLASS zaks_fm_fill IMPLEMENTATION.
  METHOD if_oo_adt_classrun~main.
    " Clean up previous test/demo data
    DELETE FROM : zaks_vehicle,
                  zaks_trip,
                  zaks_maintenance.

    " Prepare and insert vehicle master data
    DATA : lt_vehicle TYPE TABLE OF zaks_vehicle,
           lt_trip TYPE TABLE OF zaks_trip,
           lt_maintenance TYPE TABLE OF zaks_maintenance.
    DATA(lv_date) = cl_abap_context_info=>get_system_date( ).

    lt_vehicle = VALUE #(
      ( client = sy-mandt vehicle_id = 'V001' regd_no = 'MH12AB1234' vehicle_type = 'CAR'    brand = 'TOYOTA'     model = 'COROLLA'   purchase_date = '20220101' cost_price = 1200000 currency = 'INR' fuel_type = 'P' capacity = '5'   capacity_unit = 'PAX'
        status = 'ACTIVE'   plant = '1000' created_by = sy-uname created_on = lv_date )
      ... " (other vehicle records omitted for brevity)
    ).
    INSERT zaks_vehicle FROM TABLE @lt_vehicle.

    " Prepare and insert trip data
    lt_trip = VALUE #(
      ( client = sy-mandt trip_id = 'T001' vehicle_id = 'V001' driver_id = '88989989' start_date = '20240101' end_date = '20240102'
        origin = 'PUNE' destination = 'MUMBAI' cargo_type = 'GEN' distance_km = 150 created_by = sy-uname created_on = lv_date )
      ... " (other trip records omitted for brevity)
    ).
    INSERT zaks_trip FROM TABLE @lt_trip.

    " Prepare and insert maintenance data
    DATA(lv_next_service) = '20240111'.
    lt_maintenance = VALUE #(
      ( client = sy-mandt vehicle_id = 'V001' maint_id = 'M001' service_date = '20230105' service_type = 'OIL'   service_cost =  5000 currency = 'INR' workshop_name = 'AUTOCARE PUNE'
        odometer_reading = 12000 parts_changed = 'OIL'   warranty_claim = 'N' next_service_date = lv_next_service material_number = 'MAT000001' vendor_number = '0000100001' created_by = sy-uname created_on = lv_date )
      ... " (other maintenance records omitted for brevity)
    ).
    INSERT zaks_maintenance FROM TABLE @lt_maintenance.

    " Return status
    out->write( 'Successful!' ).
  ENDMETHOD.
ENDCLASS.

Note:

  • The value assignments above are truncated for clarity; the actual implementation in /src/classes/zaks_fm_fill.abap provides full sample datasets for each entity.
  • You can execute this class in ADT (Eclipse) using "Run As โ†’ ABAP Application (Console)" to instantly reset your demo data.

๐Ÿ“ Usage

  1. Open the class ZAKS_FM_FILL in ADT (Eclipse).
  2. Right-click and select Run As โ†’ ABAP Application (Console).
  3. The system will clear existing data and refill all tables with demo content.
  4. Check the console for the message:
    Successful!

๐Ÿ“ฆ Location in Repository

src/
โ””โ”€โ”€ classes/
    โ””โ”€โ”€ zaks_fm_fill.abap

This utility is essential for quick onboarding, demos, and test resets. It ensures your Fleet Management System always has meaningful data to work with!

Clone this wiki locally