Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

z_first_program

Former Member
0 Likes
623

Hello everyone,

I just started my abap object programming and I have a error that according to the book code is ok, but does not run, compiles but crashes.

Does anyone sees something wrong with it?

Thanks in advance

Carlos


*&---------------------------------------------------------------------*
*& Report  Z_MYFIRST_PROGRAM                                           *
*&                                                                     *
*&---------------------------------------------------------------------*
*&                                                                     *
*&                                                                     *
*&---------------------------------------------------------------------*

REPORT  z_myfirst_program.

*---------------------------------------------------------------------*
*       CLASS appliction DEFINITION
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
CLASS application DEFINITION.
  PUBLIC SECTION.

    METHODS: consturctor,
    read_data IMPORTING l_carrid TYPE spfli-carrid,
    fill_list.

  PRIVATE SECTION.

    DATA: spfli_tab TYPE TABLE OF spfli,
    container TYPE REF TO cl_gui_custom_container,
    alv_list TYPE REF TO cl_gui_alv_grid.

ENDCLASS.

*---------------------------------------------------------------------*
*       CLASS appliction IMPLEMENTATION
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
CLASS application IMPLEMENTATION.
  METHOD consturctor.

    CREATE OBJECT container
      EXPORTING container_name = 'LIST_AREA'.

    CREATE OBJECT alv_list
      EXPORTING i_parent = container.

    CALL METHOD alv_list->set_table_for_first_display
      EXPORTING i_structure_name = 'SPFLI'
      CHANGING it_outtab = spfli_tab.

  ENDMETHOD.

  METHOD read_data.

    SELECT *
    FROM spfli
    INTO TABLE spfli_tab
    WHERE carrid = l_carrid.

  ENDMETHOD.

  METHOD fill_list.

       CALL METHOD alv_list->refresh_table_display.   "<< CRASHES HERE
                                     "OBJECTS_OBJREF_NOT ASSIGNED
  ENDMETHOD.

ENDCLASS.

TABLES spfli.

DATA object_ref TYPE REF TO application.

START-OF-SELECTION.
  CREATE OBJECT  object_ref.
  CALL SCREEN 100.


*---------------------------------------------------------------------*
*       MODULE satus_100 OUTPUT                                       *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'SCREEN_100'.

    CALL METHOD object_ref->fill_list.

ENDMODULE.

*---------------------------------------------------------------------*
*       MODULE user_command_0100 INPUT                                *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
  IF sy-ucomm = 'BACK' OR
     sy-ucomm = 'EXIT' OR
     sy-ucomm = 'CANCEL'.
    LEAVE PROGRAM.
  ELSE.
    CALL METHOD object_ref->read_data
    EXPORTING l_carrid = spfli-carrid.
  ENDIF.
ENDMODULE.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
584

The constructor name is misspelled:

METHODS: consturctor,

and

METHOD consturctor.

should read

METHODS: constructor,

and

METHOD constructor.

Because it is misspelled, it is not being executed when the object is created.

Let us know how it goes.

3 REPLIES 3
Read only

Former Member
0 Likes
585

The constructor name is misspelled:

METHODS: consturctor,

and

METHOD consturctor.

should read

METHODS: constructor,

and

METHOD constructor.

Because it is misspelled, it is not being executed when the object is created.

Let us know how it goes.

Read only

0 Likes
584

Hi charles,

I must say that Charles has an amazing eye for detail !!

Regards,

Anand Mandalika.

Read only

0 Likes
584

Charles,

Thank you very much and I am very sorry about this silly error. But, since I am new on this I just panic and started looking for a different cause than syntax.

Thanks again

Carlos