Skip to Content
author's profile photo Former Member
Former Member

define my class

I defined a class in my program.When I check the program it always has some problems.

Here is my program:

&----


*& Report ZTESTWZJ

*&

&----


*&

*&

&----


REPORT ztestwzj.

INCLUDE zmyinclude.

TYPES: BEGIN OF mytype,

carrid LIKE sflight-carrid,

connid LIKE sflight-connid,

fldate LIKE sflight-fldate,

price LIKE sflight-price,

END OF mytype.

DATA itab TYPE TABLE OF mytype.

DATA wa_itab LIKE LINE OF itab.

DATA ok_code TYPE sy-ucomm.

DATA mycontainer TYPE REF TO cl_gui_custom_container.

DATA myalv TYPE REF TO cl_gui_alv_grid.

DATA fieldcat TYPE lvc_t_fcat.

DATA wacat TYPE lvc_s_fcat.

DATA myevent TYPE REF TO myclass.

CREATE OBJECT myevent.

SELECT carrid connid fldate price

FROM sflight

INTO wa_itab.

APPEND wa_itab TO itab.

ENDSELECT.

CLEAR wacat.

wacat-fieldname = 'CARRID'.

wacat-ref_field = 'CARRID'.

wacat-ref_table = 'SFLIGHT'.

wacat-coltext = '航线承运人'.

APPEND wacat TO fieldcat.

CLEAR wacat.

wacat-fieldname = 'CONNID'.

wacat-ref_field = 'CONNID'.

wacat-ref_table = 'SFLIGHT'.

wacat-coltext = '航班连接'.

APPEND wacat TO fieldcat.

CLEAR wacat.

wacat-fieldname = 'FLDATE'.

wacat-ref_field = 'FLDATE'.

wacat-ref_table = 'SFLIGHT'.

wacat-coltext = '航班日期'.

APPEND wacat TO fieldcat.

CLEAR wacat.

wacat-fieldname = 'PRICE'.

wacat-ref_field = 'PRICE'.

wacat-ref_table = 'SFLIGHT'.

wacat-coltext = '航空运费'.

APPEND wacat TO fieldcat.

CALL SCREEN 0100.

&----


*& Module STATUS_0100 OUTPUT

&----


  • text

----


MODULE status_0100 OUTPUT.

SET PF-STATUS 'MYSTATUS'.

IF myalv IS INITIAL.

CREATE OBJECT mycontainer

EXPORTING container_name = 'CONTAINER1'.

CREATE OBJECT myalv

EXPORTING i_parent = mycontainer.

ENDIF.

CALL METHOD myalv->set_table_for_first_display

  • EXPORTING

  • I_BUFFER_ACTIVE =

  • I_BYPASSING_BUFFER =

  • I_CONSISTENCY_CHECK =

  • I_STRUCTURE_NAME =

  • IS_VARIANT =

  • I_SAVE =

  • I_DEFAULT = 'X'

  • IS_LAYOUT =

  • IS_PRINT =

  • IT_SPECIAL_GROUPS =

  • IT_TOOLBAR_EXCLUDING =

  • IT_HYPERLINK =

  • IT_ALV_GRAPHICS =

  • IT_EXCEPT_QINFO =

  • IR_SALV_ADAPTER =

CHANGING

it_outtab = itab

it_fieldcatalog = fieldcat

  • IT_SORT =

  • IT_FILTER =

  • EXCEPTIONS

  • INVALID_PARAMETER_COMBINATION = 1

  • PROGRAM_ERROR = 2

  • TOO_MANY_LINES = 3

  • others = 4

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

SET HANDLER myevent->handle_top_page FOR myalv .

  • SET TITLEBAR 'xxx'.

ENDMODULE. " STATUS_0100 OUTPUT

&----


*& Module USER_COMMAND_0100 INPUT

&----


  • text

----


MODULE user_command_0100 INPUT.

CASE ok_code.

WHEN 'BACK'.

SET SCREEN 0.

ENDCASE.

ENDMODULE. " USER_COMMAND_0100 INPUT

my class is defined in the include file:

&----


*& &#21253;&#25324; ZMYINCLUDE

&----


CLASS myclass DEFINITION.

PUBLIC SECTION.

METHODS handle_top_page FOR EVENT print_top_of_page OF cl_gui_alv_grid .

ENDCLASS. "zmyclass DEFINITION

----


  • CLASS myclass IMPLEMENTATION

----


*

----


CLASS myclass IMPLEMENTATION.

METHOD handle_top_page.

WRITE:/ 'hahahaahahahahahahahahaahahahahaha'.

WRITE:/ 'hahahaahahahahahahahahaahahahahaha'.

WRITE:/ 'hahahaahahahahahahahahaahahahahaha'.

WRITE:/ 'hahahaahahahahahahahahaahahahahaha'.

WRITE:/ 'hahahaahahahahahahahahaahahahahaha'.

WRITE:/ 'hahahaahahahahahahahahaahahahahaha'.

WRITE:/ 'hahahaahahahahahahahahaahahahahaha'.

WRITE:/ 'hahahaahahahahahahahahaahahahahaha'.

ENDMETHOD. "handle_top_page

ENDCLASS. "myclass IMPLEMENTATION

when I click "check" button,it has an error"Statement is not accessible."

I don't know why...

Please help me, thanks

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Sep 22, 2006 at 03:09 AM

    Hi,

    Before the write statement..have the code

    LEAVE TO LIST-PROCESSING..

    Thanks,

    Naren

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Sep 22, 2006 at 03:59 AM

    Hi,

    I tried with the same code, I haven't got any error messgae.

    It has got activated.

    Make sure that u first activate the include created and then come and activate the program.

    Hope this solves your problem.

    Reward points if this helps.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 22, 2006 at 04:03 AM

    hi

    good

    you can go through this weblog, which ll give you clear idea about using of OOPS concept in ABAP.

    /people/sap.user72/blog/2005/05/10/a-small-tip-for-the-beginners-in-oo-abap

    THANKS

    MRUTYUN^

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 14, 2006 at 10:10 AM

    Hello Lupin

    The reason for the error "Statement is not accessible." is a missing statement in your report. You should always separate the DATA section of your report from the "Coding" section using <b>START-OF-SELECTION.</b>

    When I took the BC412 course (dealing with Controls) this was one of the very first remarks of our teacher.

    This error will only occur if you are using classes in your report. However, I recommend to use START-OF-SELECTION always because it helps to structure the coding.

    In method HANDLE_TOP_OF_PAGE no additional statement is required. If you switch from the Grid display to the list output your text will be displayed on top of the list.

    Regards

    Uwe

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.