Untitled

mail@pastecode.io avatar
unknown
plain_text
14 days ago
1.8 kB
3
Indexable
Never
CLASS zcl_03_table DEFINITION
  PUBLIC.
  PUBLIC SECTION.
    DATA: it_bookings TYPE TABLE OF apidocs_storage.

    INTERFACES if_oo_adt_classrun.

    CLASS-DATA: out TYPE REF TO if_oo_adt_classrun_out.

    METHODS get
    IMPORTING
        random TYPE string DEFAULT 'idk'.

  PROTECTED SECTION.


ENDCLASS.

CLASS zcl_03_table IMPLEMENTATION.

  METHOD if_oo_adt_classrun~main.

    " Assign out reference
    me->out = out.

    GET TIME STAMP FIELD DATA(zv_tsl).
    it_bookings = VALUE #(
        ( booking  = '1' customername = 'Buchholm' numberofpassengers = '3' emailaddress = 'tester1@flight.example.com'
          country = 'Germany' dateofbooking = '20180213125959' dateoftravel = '20180213125959' cost = '546' currencycode = 'EUR' lastchangedat = zv_tsl )
        ( booking  = '2' customername = 'Jeremias' numberofpassengers = '1' emailaddress = 'tester2@flight.example.com'
          country = 'USA' dateofbooking = '20180313125959' dateoftravel = '20180313125959' cost = '1373' currencycode = 'USD' lastchangedat = zv_tsl )
     ).

    " Delete existing entries
    DELETE FROM apidocs_storage.

    " Insert new table entries
    INSERT apidocs_storage FROM TABLE @it_bookings.

    " Check the result
    SELECT * FROM apidocs_storage INTO TABLE @it_bookings.
    out->write( sy-dbcnt ).
    out->write( 'data inserted successfully!' ).

    " Call get method and pass it_bookings
    me->get( ).

  ENDMETHOD.

  METHOD get.
    DATA: iterate_class TYPE REF TO zcl_02_iterate.
    CREATE OBJECT iterate_class.
*    DATA: ls_booking TYPE apidocs_storage.
*
*
*    out->write( |{ random }| ).
*
*    LOOP AT it_bookings INTO ls_booking.
*
*    out->write( ls_booking-booking ).
*
*    ENDLOOP.

    DATA(output) = iterate_class->test( 'PUNDEH' ).
    out->write( output ).

  ENDMETHOD.

ENDCLASS.
Leave a Comment