ЭКРАНЫ ДИАЛОГА (SE51)
Логика ДинПро не содержит объявлений данных.
Основные блоки обработки в логике ДинПро:
PROCESS BEFORE OUTPUT
PROCESS AFTER INPUT
PROCESS ON HELP-REQUEST. – событие для выбора значений по F4…
PROCESS ON VALUE-REQUEST. – событие для вывода справки по F1
-
Ключевое слово
Назначение
MODULE
Вызывает диалоговый модуль в ABAP программе FIELD
Обозначает точку переноса содержимого поля
ON
Используется в сочетании с FIELD VALUES
Используется в сочетании c FIELD CHAIN
Стартует цепочку обработки полей ENDCHAIN
Завершает цепочку обработки полей CALL
Вызывает подэкран LOOP
Цикл обработки экранной таблицы ENDLOOP
Завершает цикл обработки экранной таблицы
Пример:
PROCESS BEFORE OUTPUT.
MODULE INIT_SCREEN_100.
MODULE STATUS_0100.
LOOP AT ITAB WITH CONTROL
MODULE SET_VALUES.
ENDLOOP.
PROCESS AFTER INPUT.
MODULE CLEAR_OK_CODE.
MODULE CANCEL AT EXIT-COMMAND.
LOOP AT ITAB.
MODULE GET_DATA.
FIELD F1 MODULE CHECK_F1.
CHAIN.
FIELD F2, F3.
MODULE CHECK_FIELDS1.
FIELD F4, F5.
MODULE CHECK_FIELDS2.
ENDCHAIN.
ENDLOOP.
MODULE USER_COMMAND_0100.
PROCESS ON HELP-REQUEST.
PROCESS ON VALUE-REQUEST.
ПРИМЕР ЭКРАНА ИСПОЛЬЗУЮЩЕГО ГЛОБАЛЬНУЮ ПЕРЕМЕННУЮ ТАБЛИЦУ ДЛЯ ПОИСКА ВНЕЙ
ИПОЛЬЗУЕТСЯ GUI – STATUS, ЭКРАН, PBO И PAI ТРАНЗАКЦИИ
*&———————————————————————*
*& Report Z_TEST_SCREEN_NIK
*&
*&———————————————————————*
*&
*&
*&———————————————————————*
REPORT z_test_screen_nik.
TABLES: zavto.
DATA ztab TYPE TABLE OF zavto.
DATA comm LIKE sy–ucomm.
START-OF-SELECTION.
* zavto-name = ‘car’.
CALL SCREEN 100.
MODULE status_0100 OUTPUT.
SET PF-STATUS ‘ZSTAT_100’.
* SET TITLEBAR ‘xxx’.
ENDMODULE. ” STATUS_0100 OUTPUT
MODULE user_command_0100 INPUT.
CASE comm.
WHEN ‘BACK’.
LEAVE TO SCREEN 0.
WHEN OTHERS.
ENDCASE.
CLEAR comm.
ENDMODULE. ” USER_COMMAND_0100 INPUT
MODULE oncheckname INPUT.
SELECT SINGLE * FROM zavto INTO zavto WHERE name = zavto–name.
IF sy–subrc <> 0 .
ENDIF.
ENDMODULE. ” ONCHECKNAME INPUT
MODULE outcheckname OUTPUT.
” SELECT SINGLE * FROM zavto INTO zavto WHERE name = zavto-name.
ENDMODULE. ” CHECKNAME OUTPUT
LOOP AT SCREEN. Программное изменение атрибутов объектов на экране (PBO)
LOOP AT SCREEN.
IF screen–group1 EQ ‘MAS’.
screen–input = ‘1’.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
пример использования
экран (in PBO):
FIELD zavto–total_mass MODULE CHECKMASS.
pbo:
MODULE outcheckname OUTPUT.
SELECT SINGLE * FROM zavto INTO zavto WHERE name = zavto–name.
ENDMODULE.
ИСКЛЮЧИТЬ КНОПКУ SAVE из МЕНЮ GUI-STATUS для всех экранов кроме первого (PBO)
MODULE status_0100 OUTPUT.
IF sy–dynnr = 0100. “переменная SY-dynnr – текущий экран
SET PF-STATUS ‘ZSTAT_100’ .
ELSE.
SET PF-STATUS ‘ZSTAT_100’ EXCLUDING ‘SAVE’.
ENDIF.
* SET TITLEBAR ‘xxx’.
ENDMODULE.
CL_ALV_GRID На классах
*&———————————————————————*
*& Report Z_TEST_CL_ALV_NIK
*&
*&———————————————————————*
*&
*&
*&———————————————————————*
REPORT z_test_cl_alv_nik.
TABLES: zavto.
DATA: gs_fieldcatalog TYPE lvc_s_fcat OCCURS 0 WITH HEADER LINE,
gv_fcat LIKE LINE OF gs_fieldcatalog,
gs_layout TYPE lvc_s_layo.
DATA: g_container TYPE scrfname VALUE ‘CONT’,
g_custom_container TYPE REF TO cl_gui_custom_container,
g_grid TYPE REF TO cl_gui_alv_grid.
DATA comm LIKE sy–ucomm.
DATA ztab TYPE TABLE OF zavto WITH HEADER LINE.
START-OF-SELECTION.
SELECT * FROM zavto INTO TABLE ztab.
CALL SCREEN 100.
MODULE status_0100 OUTPUT.
SET PF-STATUS ‘ZSTAT’.
IF g_custom_container IS INITIAL.
CREATE OBJECT g_custom_container EXPORTING container_name = g_container.
CREATE OBJECT g_grid EXPORTING i_parent = g_custom_container.
PERFORM u_prepare_fieldcatalog.
gs_layout–zebra = ‘X’.
“gs_layout-edit = ‘X’. ” Makes all Grid editable
CALL METHOD g_grid->set_table_for_first_display
EXPORTING
is_layout = gs_layout
CHANGING
it_fieldcatalog = gs_fieldcatalog[]
it_outtab = ztab[]. ” Data
ELSE.
CALL METHOD g_grid->refresh_table_display.
ENDIF.
* SET TITLEBAR ‘xxx’.
ENDMODULE. ” STATUS_0100 OUTPUT
MODULE user_command_0100 INPUT.
CASE comm.
WHEN ‘BACK’.
LEAVE TO SCREEN 0.
WHEN OTHERS.
ENDCASE.
CLEAR comm.
ENDMODULE. ” USER_COMMAND_0100 INPUT
FORM U_PREPARE_FIELDCATALOG.
CLEAR gv_fcat.
gv_fcat–fieldname = ‘MANDT’.
gv_fcat–tabname = ‘VBAP’.
gv_fcat–col_pos = 0.
gv_fcat–coltext = ‘MANDT’.
gv_fcat–no_out = ‘X’. ” Do not Display Column
INSERT gv_fcat INTO TABLE gs_fieldcatalog.
CLEAR gv_fcat.
gv_fcat–fieldname = ‘name’.
gv_fcat–tabname = ‘VBAP’.
gv_fcat–col_pos = 1.
gv_fcat–coltext = ‘name’.
INSERT gv_fcat INTO TABLE gs_fieldcatalog.
CLEAR gv_fcat.
gv_fcat–fieldname = ‘total_mass’.
gv_fcat–tabname = ‘VBAP’.
gv_fcat–col_pos = 2.
gv_fcat–coltext = ‘total_mass’.
INSERT gv_fcat INTO TABLE gs_fieldcatalog.
CLEAR gv_fcat.
gv_fcat–fieldname = ‘car_mass’.
gv_fcat–tabname = ‘VBAP’.
gv_fcat–col_pos = 3.
gv_fcat–coltext = ‘car_mass’.
INSERT gv_fcat INTO TABLE gs_fieldcatalog.
ENDFORM.
SPLIT Две таблицы
Создали два контейнера : Heading И MAIN_CONT.
*&———————————————————————*
*& Report Z_TEST_SPLITTER
*&
*&———————————————————————*
*&
*&
*&———————————————————————*
REPORT z_test_splitter.
DATA comm LIKE sy–ucomm.
DATA o_cc TYPE REF TO cl_gui_custom_container .
DATA o_sc TYPE REF TO cl_gui_splitter_container .
DATA o_part1 TYPE REF TO cl_gui_container .
DATA o_part2 TYPE REF TO cl_gui_container .
DATA alv_grid1 TYPE REF TO cl_gui_alv_grid .
DATA alv_grid2 TYPE REF TO cl_gui_alv_grid .
DATA i_mara TYPE TABLE OF zavto .
DATA i_makt TYPE TABLE OF zavto .
DATA dd TYPE REF TO cl_dd_document.
START-OF-SELECTION.
CALL SCREEN 100.
MODULE status_0100 OUTPUT.
SET PF-STATUS ‘ZGUI’.
PERFORM create_objects.
PERFORM spli_main_cont .
PERFORM disp_heading.
PERFORM disp_alv1 .
PERFORM disp_alv2 .
SET TITLEBAR ‘xxx’.
ENDMODULE. ” STATUS_0100 OUTPUT
MODULE user_command_0100 INPUT.
CASE comm.
WHEN ‘BACK’.
LEAVE TO SCREEN 0.
WHEN OTHERS.
ENDCASE.
ENDMODULE. ” USER_COMMAND_0100 INPUT
FORM create_objects.
CREATE OBJECT o_cc
EXPORTING
container_name = ‘MAIN_CONT’.
CREATE OBJECT dd.
ENDFORM.
FORM spli_main_cont.
CREATE OBJECT o_sc
EXPORTING
parent = o_cc
rows = 2
columns = 1.
CALL METHOD o_sc->get_container
EXPORTING
row = 1
column = 1
RECEIVING
container = o_part1.
CALL METHOD o_sc->get_container
EXPORTING
row = 2
column = 1
RECEIVING
container = o_part2.
ENDFORM.
FORM disp_alv1.
CREATE OBJECT alv_grid1
EXPORTING
i_parent = o_part1.
SELECT * FROM zavto
INTO TABLE i_mara.
CALL METHOD alv_grid1->set_table_for_first_display
EXPORTING
i_structure_name = ‘ZAVTO’
CHANGING
it_outtab = i_mara.
ENDFORM.
FORM disp_alv2.
CREATE OBJECT alv_grid2
EXPORTING
i_parent = o_part2.
SELECT * FROM zavto
INTO TABLE i_makt.
CALL METHOD alv_grid2->set_table_for_first_display
EXPORTING
i_structure_name = ‘ZAVTO’
CHANGING
it_outtab = i_makt.
ENDFORM.
FORM DISP_HEADING.
DATA: HEAD TYPE SDYDO_ATTRIBUTE.
HEAD = CL_DD_DOCUMENT=>HEADING.
CALL METHOD DD->ADD_TEXT
EXPORTING
“TEXT = ‘MATERIAL MASTER REPORT’
SAP_STYLE = HEAD.
CALL METHOD DD->DISPLAY_DOCUMENT
EXPORTING
CONTAINER = ‘HEADING’.
ENDFORM.
HTML Viewer
*&———————————————————————*
*& Report Z_TEST_HTML_VIEW_NIK
*&
*&———————————————————————*
*&
*&
*&———————————————————————*
REPORT z_test_html_view_nik.
DATA comm LIKE sy–ucomm.
DATA: ref_cont TYPE REF TO cl_gui_custom_container,
ref_html TYPE REF TO cl_gui_html_viewer.
START-OF-SELECTION.
CALL SCREEN 100.
MODULE status_0100 OUTPUT.
SET PF-STATUS ‘ZSTAT’.
PERFORM create_objects.
* SET TITLEBAR ‘xxx’.
ENDMODULE. ” STATUS_0100 OUTPUT
MODULE user_command_0100 INPUT.
CASE comm.
WHEN ‘BACK’.
LEAVE TO SCREEN 0.
WHEN OTHERS.
ENDCASE.
ENDMODULE. ” USER_COMMAND_0100 INPUT
FORM create_objects.
CREATE OBJECT ref_cont
EXPORTING
container_name = ‘CONT’
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6.
IF sy–subrc <> 0.
ENDIF.
CREATE OBJECT ref_html
EXPORTING
parent = ref_cont
EXCEPTIONS
OTHERS = 1.
CALl METHOD ref_html->show_url
EXPORTING
url = ‘http://www.norbit.ru’.
IF sy–subrc <> 0.
ENDIF.
ENDFORM.