Code:
REPORT zpp_copydata_mrp5_vs_12.
TABLES: zppmrp5, zppmrp5_12, mard, makt.
type-pools: slis.
TYPE-POOLS: vrm.
TYPES: BEGIN OF ty_mpr5vs12,"gt_result_tab,
datuv TYPE zppmrp5_tmp1-datuv, "Дата
seqnr TYPE zppmrp5-seqnr, "Порядковый номер
matnr TYPE zppmrp5-matnr, "Изделие
werks_1 TYPE zppmrp5-werks_1, "Завод
matnr_1 TYPE zppmrp5-matnr_1, "ДСЕ
matnr_2 TYPE zppmrp5-matnr_2, "УЗЕЛ
maktg TYPE zpp_result_tab_mpr5vs12-maktg, "Название материала большими буквами для кода поиска
lgort_1 TYPE zppmrp5-lgort_1, "Склад отправитель
lgort_2 TYPE zppmrp5-lgort_2, "Склад получатель
arbpl_1 TYPE zppmrp5-arbpl_1, "Цех изготовитель
arbpl_2 TYPE zppmrp5-arbpl_2, "Цех потребитель
gamng_td TYPE zppmrp5-gamng, "Нормативная потребность
gamng_1_td TYPE zppmrp5_12-gamng, "Нормативная потребность за прошедший период
gamng_ld TYPE zppmrp5-gamng_1, "Подать в цех-потребитель(месяц)
gamng_1_ld TYPE zppmrp5_12-gamng_1, "Подать в цех-потребитель(месяц) за прошедший период
pbdnr TYPE zppmrp5-pbdnr, "Номер плана потребности
zbesk TYPE zppmrp5-zbesk, "Вид заготовки в концерне
elevel TYPE zppmrp5-elevel, "Уровень при разузловании
ia TYPE zppmrp5-ia, "Внутренний узел (индикатор)
id TYPE icon_d,"zppmrp5-id, "ID
count TYPE zppmrp5-ch, "Счетчик
cellcolor TYPE lvc_t_scol, "ячейка для цвета
END OF ty_mpr5vs12."gt_result_tab.
*DATA: gs_result_tab TYPE TABLE OF gt_result_tab.
DATA: gt_result_tab TYPE TABLE OF ty_mpr5vs12.
DATA g_tabname(20).
DATA:
list TYPE vrm_values,
value LIKE LINE OF list.
DATA:
go_navigation_profile TYPE REF TO if_navp.
PARAMETERS:
p_save TYPE navp_save_mode NO-DISPLAY DEFAULT if_navp=>save_all,
p_dfault TYPE navp_default_mode NO-DISPLAY DEFAULT if_navp=>default_auto,
p_profil TYPE navp_profile_name NO-DISPLAY DEFAULT ''.
DATA: ok_code LIKE sy-ucomm,
g_container TYPE scrfname VALUE 'GRID1',
grid1 TYPE REF TO cl_gui_alv_grid,
gt_fieldcat TYPE lvc_t_fcat," каталог полей
gs_layout TYPE lvc_s_layo,
gs_variant TYPE disvariant,
gt_excluding TYPE ui_functions,
gt_sort TYPE lvc_t_sort,
gs_sort TYPE lvc_s_sort,
gt_filter TYPE lvc_t_filt,
gs_filter TYPE lvc_s_filt,
gt_okcode TYPE navp_t_okcode,
w_cellcolor TYPE lvc_s_scol,
t_cellcolor TYPE lvc_t_scol,
g_custom_container TYPE REF TO cl_gui_custom_container.
DATA l_elevel LIKE zppmrp5-elevel.
RANGES r_elevel FOR l_elevel.
FIELD-SYMBOLS: <fs_fieldcat> TYPE lvc_s_fcat,
<gs_result_tab> LIKE LINE OF gt_result_tab.
*
PARAMETERS: p_list_a TYPE char7 AS LISTBOX VISIBLE LENGTH 10
OBLIGATORY DEFAULT '001'
USER-COMMAND change_p_list_a. " список
SELECTION-SCREEN BEGIN OF BLOCK selection1 WITH FRAME TITLE text-008.
SELECT-OPTIONS so_matnr FOR zppmrp5-matnr. "Изделие
SELECT-OPTIONS so_mat1 FOR zppmrp5-matnr_1. "ДСЕ
SELECT-OPTIONS so_mat2 FOR zppmrp5-matnr_2. "Узел
SELECT-OPTIONS so_arb1 FOR zppmrp5-arbpl_1. "Цех изготовитель
SELECT-OPTIONS so_arb2 FOR zppmrp5-arbpl_2. "Цех потребитель
SELECT-OPTIONS so_pbdnr FOR zppmrp5-pbdnr. "План потребности
SELECT-OPTIONS so_zbesk FOR zppmrp5-zbesk. "Вид заготовки в концерне
SELECTION-SCREEN END OF BLOCK selection1.
SELECTION-SCREEN BEGIN OF BLOCK parametrs-block WITH FRAME TITLE text-007.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 1.
PARAMETERS p_chbox AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN COMMENT 10(24) text-001 FOR FIELD p_chbox.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 1.
PARAMETERS p_cb6 AS CHECKBOX.
SELECTION-SCREEN COMMENT 10(25) text-009 FOR FIELD p_cb6.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN POSITION 1.
PARAMETERS: p_cb1 AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN COMMENT 5(14) text-002 FOR FIELD p_cb1.
PARAMETERS: p_cb2 AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN COMMENT 23(15) text-003 FOR FIELD p_cb2.
PARAMETERS: p_cb3 AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN COMMENT 42(15) text-004 FOR FIELD p_cb3.
PARAMETERS: p_cb4 AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN COMMENT 62(14) text-005 FOR FIELD p_cb4.
PARAMETERS: p_cb5 AS CHECKBOX DEFAULT 'X'.
SELECTION-SCREEN COMMENT 79(12) text-006 FOR FIELD p_cb5.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF BLOCK parametrs-block.
INITIALIZATION.
CLEAR value.
REFRESH list.
value-key = '001'.
value-text = 'Сегодня'.
APPEND value TO list.
value-key = '002'.
value-text = 'июль 2018'.
APPEND value TO list.
value-key = '003'.
value-text = 'май 2018'.
APPEND value TO list.
CALL FUNCTION 'VRM_SET_VALUES'
EXPORTING
id = 'P_LIST_A'
values = list.
START-OF-SELECTION.
CASE p_list_a.
WHEN '001'. "g_tabname = 'ZPP_MRP5'.
WHEN '002'. "g_tabname = 'ZPPMRP5_TMP1'.
WHEN '003'. "g_tabname = 'ZPPMRP5_YEAR'.
ENDCASE.
IF p_chbox = 'X'.
r_elevel-low = 1.
r_elevel-option = 'EQ'.
r_elevel-sign = 'I'.
APPEND r_elevel.
CLEAR r_elevel.
ELSE.
CLEAR r_elevel.
ENDIF.
SELECT zppmrp5~matnr_1
zppmrp5~datuv
zppmrp5~matnr_2
zppmrp5~matnr
zppmrp5~werks_1
zppmrp5~arbpl_1
zppmrp5~arbpl_2
zppmrp5~lgort_1
zppmrp5~lgort_2
zppmrp5~seqnr
zppmrp5~elevel
zppmrp5~pbdnr
zppmrp5~zbesk
zppmrp5~ia
* zppmrp5~ENTMG
makt~maktg
zppmrp5~gamng AS gamng_td
zppmrp5~gamng_1 AS gamng_1_td
zppmrp5_tmp1~gamng AS gamng_ld
zppmrp5_tmp1~gamng_1 AS gamng_1_ld
INTO CORRESPONDING FIELDS OF TABLE gt_result_tab
FROM zppmrp5
LEFT
JOIN zppmrp5_tmp1 ON zppmrp5_tmp1~matnr = zppmrp5~matnr
AND zppmrp5_tmp1~matnr_1 = zppmrp5~matnr_1
AND zppmrp5_tmp1~matnr_2 = zppmrp5~matnr_2
AND zppmrp5_tmp1~arbpl_1 = zppmrp5~arbpl_1
AND zppmrp5_tmp1~arbpl_2 = zppmrp5~arbpl_2
AND zppmrp5_tmp1~seqnr = zppmrp5~seqnr
AND zppmrp5_tmp1~werks_1 = zppmrp5~werks_1
AND zppmrp5_tmp1~pbdnr = zppmrp5~pbdnr
AND zppmrp5_tmp1~elevel = zppmrp5~elevel
AND zppmrp5_tmp1~lgort_1 = zppmrp5~lgort_1
AND zppmrp5_tmp1~lgort_2 = zppmrp5~lgort_2
INNER
JOIN makt ON makt~matnr = zppmrp5~matnr_1
WHERE "zppmrp5~elevel = 1 AND
zppmrp5~elevel IN r_elevel AND
zppmrp5~matnr_1 IN so_mat1 AND
zppmrp5~matnr_2 IN so_mat2 AND
zppmrp5~matnr IN so_matnr AND
zppmrp5~arbpl_1 IN so_arb1 AND
zppmrp5~arbpl_2 IN so_arb2 AND
zppmrp5~zbesk IN so_zbesk.
SELECT zppmrp5_tmp1~matnr_1
zppmrp5_tmp1~matnr_2
zppmrp5_tmp1~werks_1
zppmrp5_tmp1~matnr
zppmrp5_tmp1~arbpl_1
zppmrp5_tmp1~arbpl_2
zppmrp5_tmp1~datuv
zppmrp5_tmp1~seqnr
zppmrp5_tmp1~elevel
zppmrp5_tmp1~pbdnr
zppmrp5_tmp1~gamng AS gamng_ld
zppmrp5_tmp1~gamng_1 AS gamng_1_ld
zppmrp5_tmp1~zbesk
zppmrp5_tmp1~ia
zppmrp5_tmp1~lgort_1
zppmrp5_tmp1~lgort_2
makt~maktg
zppmrp5~gamng AS gamng_td
zppmrp5~gamng_1 AS gamng_1_td
APPENDING CORRESPONDING FIELDS OF TABLE gt_result_tab
FROM zppmrp5_tmp1
LEFT
JOIN zppmrp5 ON zppmrp5~matnr = zppmrp5_tmp1~matnr
AND zppmrp5~matnr_1 = zppmrp5_tmp1~matnr_1
AND zppmrp5~matnr_2 = zppmrp5_tmp1~matnr_2
AND zppmrp5~arbpl_1 = zppmrp5_tmp1~arbpl_1
AND zppmrp5~arbpl_2 = zppmrp5_tmp1~arbpl_2
AND zppmrp5~lgort_1 = zppmrp5_tmp1~lgort_1
AND zppmrp5~lgort_2 = zppmrp5_tmp1~lgort_2
AND zppmrp5~seqnr = zppmrp5_tmp1~seqnr
AND zppmrp5~werks_1 = zppmrp5_tmp1~werks_1
AND zppmrp5~pbdnr = zppmrp5_tmp1~pbdnr
AND zppmrp5~elevel = zppmrp5_tmp1~elevel
INNER
JOIN makt ON makt~matnr = zppmrp5_tmp1~matnr_1
WHERE "zppmrp5_tmp1~elevel = 1 AND
zppmrp5_tmp1~elevel IN r_elevel AND
zppmrp5_tmp1~matnr_1 IN so_mat1 AND
zppmrp5_tmp1~matnr_2 IN so_mat2 AND
zppmrp5_tmp1~matnr IN so_matnr AND
zppmrp5_tmp1~arbpl_1 IN so_arb1 AND
zppmrp5_tmp1~arbpl_2 IN so_arb2 AND
zppmrp5_tmp1~zbesk IN so_zbesk.
SORT gt_result_tab BY matnr matnr_1 arbpl_1 arbpl_2 seqnr werks_1 pbdnr elevel.
DELETE ADJACENT DUPLICATES FROM gt_result_tab COMPARING matnr matnr_1 arbpl_1 arbpl_2 seqnr werks_1 lgort_1 lgort_2 pbdnr elevel.
LOOP AT gt_result_tab ASSIGNING <gs_result_tab>.
CLEAR: <gs_result_tab>-cellcolor.
IF <gs_result_tab>-gamng_td EQ <gs_result_tab>-gamng_ld. "AND <gs_result_tab>-gamng_1_td EQ <gs_result_tab>-gamng_1_ld.
<gs_result_tab>-id = '@1G@'. "'@1G@' =
ELSEIF <gs_result_tab>-gamng_td EQ 0 AND <gs_result_tab>-gamng_ld GT 0.
<gs_result_tab>-id = '@05@'. "'@1J@' <
ELSEIF <gs_result_tab>-gamng_td GT 0 AND <gs_result_tab>-gamng_ld EQ 0.
<gs_result_tab>-id = '@04@'. "'@1I@' >
ELSEIF <gs_result_tab>-gamng_td GT <gs_result_tab>-gamng_ld." or <gs_result_tab>-gamng_1 GT <gs_result_tab>-gamng_1_L.
<gs_result_tab>-id = '@1I@'. "@04@ +
ELSEIF <gs_result_tab>-gamng_td LT <gs_result_tab>-gamng_ld." or <gs_result_tab>-gamng_1 LT <gs_result_tab>-gamng_1_L.
<gs_result_tab>-id = '@1J@'. "@05@ -
ENDIF.
* Colour code : *
* Colour is a 4-char field where : *
* - 1st char = C (color property) *
* - 2nd char = color code (from 0 to 7) *
* 0 = background color *
* 1 = blue *
* 2 = gray *
* 3 = yellow *
* 4 = blue/gray *
* 5 = green *
* 6 = red *
* 7 = orange *
* - 3rd char = intensified (0=off, 1=on) *
* - 4th char = inverse display (0=off, 1=on) *
<gs_result_tab>-count = 1.
IF <gs_result_tab>-gamng_1_td IS NOT INITIAL.
w_cellcolor-fname = 'GAMNG_1_TD'.
w_cellcolor-color-col = '2'.
w_cellcolor-color-inv = '0'.
w_cellcolor-color-int = '1'.
APPEND w_cellcolor TO t_cellcolor.
ENDIF.
IF <gs_result_tab>-gamng_td IS NOT INITIAL.
w_cellcolor-fname = 'GAMNG_TD'.
w_cellcolor-color-col = '2'.
w_cellcolor-color-inv = '0'.
w_cellcolor-color-int = '1'.
APPEND w_cellcolor TO t_cellcolor.
ENDIF.
IF <gs_result_tab>-gamng_td IS NOT INITIAL.
w_cellcolor-fname = 'GAMNG_1_LD'.
w_cellcolor-color-col = '3'.
w_cellcolor-color-inv = '0'.
w_cellcolor-color-int = '0'.
APPEND w_cellcolor TO t_cellcolor.
ENDIF.
IF <gs_result_tab>-gamng_td IS NOT INITIAL.
w_cellcolor-fname = 'GAMNG_LD'.
w_cellcolor-color-col = '3'.
w_cellcolor-color-inv = '0'.
w_cellcolor-color-int = '0'.
APPEND w_cellcolor TO t_cellcolor.
ENDIF.
* append w_cellcolor to t_cellcolor.
APPEND LINES OF t_cellcolor TO <gs_result_tab>-cellcolor.
ENDLOOP.
IF p_cb6 IS NOT INITIAL.
DELETE gt_result_tab WHERE ia EQ 'X'.
ENDIF.
IF p_chbox IS NOT INITIAL.
DELETE gt_result_tab WHERE elevel NE 1.
ENDIF.
IF p_cb1 IS INITIAL.
DELETE gt_result_tab WHERE id EQ '@1G@'.
ENDIF.
IF p_cb2 IS INITIAL.
DELETE gt_result_tab WHERE id EQ '@1I@'.
ENDIF.
IF p_cb3 IS INITIAL.
DELETE gt_result_tab WHERE id EQ '@1J@'.
ENDIF.
IF p_cb4 IS INITIAL.
DELETE gt_result_tab WHERE id EQ '@04@'.
ENDIF.
IF p_cb5 IS INITIAL.
DELETE gt_result_tab WHERE id EQ '@05@'.
ENDIF.
PERFORM get_fieldcatalog.
CALL SCREEN 101.
*&---------------------------------------------------------------------*
*& Form GET_FIELDCATALOG
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM get_fieldcatalog.
DATA lin TYPE i.
FIELD-SYMBOLS:
<fs_fcat> LIKE LINE OF gt_fieldcat.
CLEAR gt_fieldcat[].
"Получаем FIELD-каталог по структуре-------------------
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'ZPP_RESULT_TAB_MPR5VS12'(007)
* i_internal_tabname = gt_result_tab[]
i_bypassing_buffer = 'X'
CHANGING
ct_fieldcat = gt_fieldcat[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
"Редактируем FIELD-каталог-----------------------
* LOOP AT gt_fieldcat ASSIGNING <fs_fieldcat>.
* <fs_fieldcat>-col_opt = 'X'.
* ENDLOOP.
* describe table gt_fieldcat lines lin.
* append initial line to gt_fieldcat assigning <fs_fieldcat>.
* <fs_fieldcat>-fieldname = 'CELLCOLOR'. " TYPE LVC_T_SCOL,
* <fs_fieldcat>-col_pos = lin + 1.
* <fs_fieldcat>-tabname = '1'.
* unassign <fs_fieldcat>.
ENDFORM. " GET_FIELDCATALOG
INCLUDE zpp_mrp5vs12_def_impl.
*INCLUDE zforms_mrp5_vs12.
INCLUDE zpbos_pais_mrp5_vs12.
INCLUDE zpp_copydata_mrp5_vs_12_stao01.
INCLUDE zpp_copydata_mrp5_vs_12_usei01.
и иклюд
Code:
*&---------------------------------------------------------------------*
*& Include ZPBOS_PAIS
*&---------------------------------------------------------------------*
*---------------------------------------------------------------------*
* MODULE PBO OUTPUT *
*---------------------------------------------------------------------*
MODULE PBO OUTPUT.
SET PF-STATUS 'MRP5_VS_12'.
SET TITLEBAR 'MRP5_VS_12'.
DATA:
l_save TYPE char1,
ls_variant TYPE disvariant.
* ls_layout TYPE lvc_s_layo.
IF G_CUSTOM_CONTAINER IS INITIAL.
CREATE OBJECT G_CUSTOM_CONTAINER
EXPORTING CONTAINER_NAME = G_CONTAINER.
CREATE OBJECT GRID1
EXPORTING I_PARENT = G_CUSTOM_CONTAINER.
* связиваем "обработчик" событий с "гридом"
* SET HANDLER lcl_events=>on_toolbar FOR GRID1.
* SET HANDLER lcl_events=>on_user_command FOR GRID1.
* SET HANDLER lcl_events=>on_mouse_dbl_click FOR GRID1.
* SET HANDLER lcl_events=>on_after_user_command FOR GRID1.
CALL METHOD GRID1->register_edit_event "After return key
EXPORTING i_event_id = cl_gui_alv_grid=>mc_evt_enter.
CALL METHOD GRID1->register_edit_event "cursor is moved to another field
EXPORTING i_event_id = cl_gui_alv_grid=>mc_evt_modified.
ls_variant-report = sy-repid.
* PERFORM get_fieldcatalog.
* ls_layout-sel_mode = 'A'. " 'E' for only one
ls_variant-variant = p_profil.
CLEAR: gt_excluding.
APPEND cl_gui_alv_grid=>mc_fc_info TO gt_excluding.
go_navigation_profile = cl_navp_factory=>factory(
io_alv = GRID1
is_profile_key = ls_variant
iv_default = p_dfault
iv_save_mode = p_save
it_table = gt_result_tab ).
* iv_disable_call_transaction = p_trans
* iv_disable_call_okcode = p_okcode
* iv_disable_call_class = p_class ).
gs_variant-username = sy-uname.
gs_variant-report = sy-repid.
gs_layout-CWIDTH_OPT = 'X'.
* gs_layout-no_rowmark = ''.
* gs_layout-cwidth_opt = 'X'.
* gs_layout-sel_mode = ' '.
* gs_layout-numc_total = 'X'.
gs_layout-CTAB_FNAME = 'CELLCOLOR'.
* gs_LAYOUT-coltab_fieldname = 'CELLCOLOR'. "CTAB_FNAME.
CALL METHOD GRID1->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING it_toolbar_excluding = gt_excluding
is_variant = gs_variant
is_layout = gs_layout
i_save = 'A'
i_default = 'X'
CHANGING IT_OUTTAB = gt_result_tab "gt_fieldcat
* it_filter = gt_filter
* it_sort = gt_sort
it_fieldcatalog = gt_fieldcat[].
ENDIF.
ENDMODULE.
*---------------------------------------------------------------------*
* MODULE PAI INPUT *
*---------------------------------------------------------------------*
MODULE PAI INPUT.
DATA: answer TYPE c VALUE space.
CASE sy-ucomm." Обработка событий кнопок
WHEN 'EXIT'.
PERFORM EXIT_PROGRAM.
WHEN OTHERS.
* do nothing
ENDCASE.
ENDMODULE.
*---------------------------------------------------------------------*
* FORM EXIT_PROGRAM *
*---------------------------------------------------------------------*
FORM EXIT_PROGRAM.
SET SCREEN 0.
LEAVE SCREEN.
LEAVE PROGRAM.
ENDFORM.
На девелоперском манданте все отлично работает, закрашивается. При переносе на тестовый - уже не закрашивается. При переносе на продакшн, вовсе ошибка.
Не нашел нужной ноты
Что еще можно сделать?
видел примеры с salv, но хотелось бы в рамках alv остаться