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:
&----
*& 包括 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
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.
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