REPORT zabapobjapi_demo.

CLASS lcl_app DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS clas RAISING cx_static_check.
    CLASS-METHODS prog RAISING cx_static_check.
ENDCLASS.

CLASS lcl_app IMPLEMENTATION.
  METHOD clas.
    DATA(repo) = NEW zcl_abapobjapi_repo( package = 'ZABAPOBJAPI_TESTS_CREATED' ).

    repo->add_object( NEW zcl_abapobjapi_clas(
                     name      = 'ZABAPOBJAPI_CLAS'
                     package   = 'ZABAPOBJAPI_TESTS_CREATED'
                     descript  = 'Class Generated by abapObjAPI'
                     source_code = value #(
                    ( |CLASS ZABAPOBJAPI_CLAS DEFINITION   | )
                    ( |  PUBLIC                            | )
                    ( |  ABSTRACT                          | )
                    ( |  FOR TESTING                       | )
                    ( |  DURATION SHORT                    | )
                    ( |  RISK LEVEL HARMLESS.              | )
                    ( |                                    | )
                    ( |  PRIVATE SECTION.                  | )
                    ( |    METHODS test FOR TESTING.       | )
                    ( |                                    | )
                    ( |ENDCLASS.                           | )
                    ( |                                    | )
                    ( |CLASS ZABAPOBJAPI_CLAS IMPLEMENTATION.| )
                    ( |                                    | )
                    ( |  METHOD test.                      | )
                    ( |    " test                          | )
                    ( |  ENDMETHOD.                        | )
                    ( |                                    | )
                    ( |ENDCLASS.                           | ) ) ) ).

    repo->deserialize( is_checks = VALUE #( transport       = VALUE #( transport = 'NPLK900050' required = abap_true )
                                            warning_package = repo->get_overwrite_all( ) ) ).

  ENDMETHOD.

  METHOD prog.

    DATA(repo) = NEW zcl_abapobjapi_repo( package = 'ZABAPOBJAPI_TESTS_CREATED' ).

    repo->add_object( NEW zcl_abapobjapi_prog(
        name      = 'ZABAPOBJAPI_PROG'
        descript  = 'Program Generated by abapObjAPI'
        type      = '1'
        package   = 'ZABAPOBJAPI_TESTS_CREATED'
        source_code = VALUE #(
                ( |REPORT test.| )
                ( |WRITE 'hello world'.| ) ) ) ).

    repo->deserialize( is_checks = VALUE #( transport       = VALUE #( transport = 'NPLK900050' required = abap_true )
                                            warning_package = repo->get_overwrite_all( ) ) ).

  ENDMETHOD.

ENDCLASS.

START-OF-SELECTION.
  TRY.
      lcl_app=>prog( ).
      lcl_app=>clas( ).
    CATCH cx_root INTO DATA(lx).
      MESSAGE lx TYPE 'I'.
  ENDTRY.
