Попробовал. Версия 4.6С.
Сделал код таким, чтобы не было других синтаксических ошибок:
Code:
REPORT ZTEST .
parameters: sp_belnr type bkpf-belnr obligatory.
*---------------------------------------------------------------------*
* CLASS lcl_handler DEFINITION
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
class lcl_handler definition.
protected section.
methods: select_data
importing i_belnr type bkpf-belnr
EXCEPTIONS not_found.
private section.
data: at_data type table of bkpf.
methods: write_data.
endclass.
*---------------------------------------------------------------------*
* CLASS lcl DEFINITION
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
class lcl definition.
public section.
class-data: handler type ref to lcl_handler %_friend.
class-methods: class_constructor.
endclass.
*---------------------------------------------------------------------*
* CLASS lcl IMPLEMENTATION
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
class lcl implementation.
method class_constructor.
create object lcl=>handler.
endmethod.
endclass.
*---------------------------------------------------------------------*
* CLASS lcl_handler IMPLEMENTATION
*---------------------------------------------------------------------*
* ........ *
*---------------------------------------------------------------------*
class lcl_handler implementation.
method select_data.
if i_belnr is initial.
message s600(rf) with 'Укажите №' raising not_found.
endif.
free: me->at_data.
select belnr gjahr bukrs
into corresponding fields of table me->at_data
from bkpf
where belnr = i_belnr.
if not sy-subrc is initial.
message s600(rf) with 'Документы не найдены' raising not_found.
endif.
endmethod.
method write_data.
data: ls_data type bkpf.
loop at me->at_data
into ls_data.
write: / ls_data-bukrs, ls_data-gjahr, ls_data-belnr.
endloop.
endmethod.
endclass.
start-of-selection.
call method lcl=>handler->select_data " с другом такой вызов возможен
exporting
i_ebeln = sp_ebeln
exceptions
others = 1.
if not sy-subrc is initial.
* message id sy-msgid type sy-msgty.
exit.
endif.
end-of-selection.
call method lcl=>handler->write_data. " и такой тоже
free: lcl=>handler->at_data. " и на это не должен ругаться
В результате то, о чем Вы говорили, так и не получилось.
1.
call method lcl=>handler->select_data " с другом такой вызов возможен
На этой строке говорит:
Цитата:
Access to protected method "SELECT_DATA" is not allowed.
2.
call method lcl=>handler->write_data. " и такой тоже
На этой строке говорит:
Цитата:
You cannot access private method "WRITE_DATA" is not allowed.
3.
free: lcl=>handler->at_data. " и на это не должен ругаться
На этой строке говорит:
Цитата:
Access to private attribute "AT_DATA" is not allowed.
О чем я в начале темы и спрашивал.
Цитата:
Цитата:
Adding the %_FRIEND addition to the DATA ... TYPE REF TO class statement lets you access all the methods and data elements of the class class.
Только вот к приватной секции я все равно доступ не получил.