Professional Documents
Culture Documents
Alv Edit
Alv Edit
data
w_std_before type c,
w_std_after type c,
w_act_before type c,
w_act_after type c,
w_time type tims,
w_rptime(8) type c,
w_error type c,
w_ls_line type slis_listheader,
it_fieldcat type table of slis_fieldcat_alv,
it_events type table of slis_alv_event,
it_list_top_of_page type table of slis_listheader.
at selection-screen on variant.
perform alv_pre_selection.
at selection-screen on value-request for variant.
perform alv_f4_variant.
start-of-selection.
PERFORM get_data.
perform fieldcat_init using it_fieldcat.
perform build_layout.
perform eventtab_build using it_events.
perform comment_build using it_list_top_of_page.
perform call_alv.
TOP-OF-PAGE.
perform top_OF_page.
*&---------------------------------------------------------------------*
*&
Form alv_pre_selection
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
form alv_pre_selection .
w_variant-report = sy-repid.
*&---------------------------------------------------------------------*
*&
Form fieldcat_init
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
*
-->P_IT_FIELDCAT text
*----------------------------------------------------------------------*
form fieldcat_init using
rt_fieldcat type slis_t_fieldcat_alv.
perform fill_field using : 'WERKS' 'Plant' '' '',
'MBLNR' 'Mat.Doc.' '' '',
'MJAHR' 'Mat.Year' '' '',
'BWART' 'Movement Type' '' '',
'MATNR' 'MATERIAL' 'X' '',
'MENGE' 'QTY' '' '',
'CHK' 'Select' 'X' 'X'.
endform.
" fieldcat_init
*&---------------------------------------------------------------------*
*&
Form eventtab_build
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
*
-->P_IT_EVENTS text
*----------------------------------------------------------------------*
form eventtab_build using lt_events type slis_t_event.
data: ls_event type slis_alv_event.
call function 'REUSE_ALV_EVENTS_GET'
exporting
i_list_type = 0
importing
et_events
= lt_events.
read table lt_events with key name =
into ls_event.
slis_ev_top_of_page
if sy-subrc = 0.
move c_formname_top_of_page to ls_event-form.
append ls_event to lt_events.
endif.
endform.
" eventtab_build
*&---------------------------------------------------------------------*
*&
Form comment_build
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
*
-->P_IT_LIST_TOP_OF_PAGE text
*----------------------------------------------------------------------*
form comment_build using
lt_top_of_page type slis_t_listheader.
data: ls_line type slis_listheader,
str(50) type c,
date1(15) type c,
date2(15) type c.
write sy-datum dd/mm/yy to w_rpdate.
write so_prdat-low dd/mm/yyyy to date1.
write sy-uzeit to w_rptime using edit mask '__:__:__'.
ls_line-typ = 'H'.
ls_line-info+1(40) = 'Daily Production MIS Report'(004).
append ls_line to lt_top_of_page.
clear ls_line.
ls_line-typ = 'S'.
ls_line-info(20) = text-009.
if so_prdat-high is initial.
ls_line-info+20(10) = date1.
else.
write so_prdat-high dd/mm/yyyy to date2.
concatenate date1 ' To ' date2 into str separated by space.
ls_line-info+20(40) = str.
endif.
append ls_line to it_list_top_of_page.
clear ls_line.
ls_line-typ = 'S'.
ls_line-info(20) = text-007.
ls_line-info+20(10) = w_rpdate.
ls_line-info+35(15) = text-008.
ls_line-info+50(10) = w_rptime.
append ls_line to it_list_top_of_page.
clear ls_line.
endform.
" comment_build
*&---------------------------------------------------------------------*
*&
Form call_alv
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
form call_alv .
BREAK SAPDEV3.
w_repid = sy-repid.
if ( p_grid = 'X' ).
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program
= w_repid
it_fieldcat
= it_fieldcat
is_layout
= gd_layout
it_events
= it_events
i_save
= 'A'
is_variant
= w_variant
i_callback_user_command = 'VALIDATE_COMMAND'
tables
t_outtab
= it_mseg.
else.
call function 'REUSE_ALV_LIST_DISPLAY'
exporting
i_callback_program
= w_repid
it_fieldcat
= it_fieldcat
it_events
= it_events
i_callback_user_command = w_user_command
i_save
= 'A'
is_variant
= w_variant
tables
t_outtab
= it_mseg.
endif.
endform.
" call_alv
*&---------------------------------------------------------------------*
*&
Form fill_field
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
*
-->P_0266
text
*
-->P_0267
text
*----------------------------------------------------------------------*
form fill_field using
p_tab_field_name p_ref_field_name EDIT chk.
data: ls_fieldcat type slis_fieldcat_alv.
clear ls_fieldcat.
w_pos = w_pos + 1.
ls_fieldcat-col_pos
= w_pos.
ls_fieldcat-fieldname
= p_tab_field_name.
ls_fieldcat-ref_fieldname = p_ref_field_name.
ls_fieldcat-EDIT
= EDIT.
ls_fieldcat-checkbox
= chk.
* ls_fieldcat-ref_tabname
= p_ref_field_table.
* ls_fieldcat-seltext_s
= p_short_text.
* ls_fieldcat-seltext_m
= p_short_text.
* ls_fieldcat-seltext_l
= p_qfieldname.
* ls_fieldcat-reptext_ddic = p_short_text.
* ls_fieldcat-key
= p_key_field_flag.
* ls_fieldcat-cfieldname
= p_cfieldname.
* ls_fieldcat-qfieldname
= p_qfieldname.
* ls_fieldcat-outputlen
= p_outputlen.
* ls_fieldcat-datatype
= p_datatype.
* ls_fieldcat-inttype
= p_inttype .
append ls_fieldcat to it_fieldcat.
endform.
" fill_field
*&---------------------------------------------------------------------*
*&
Form get_data
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
* --> p1
text
* <-- p2
text
*----------------------------------------------------------------------*
form get_data .
select * from mseg
INTO CORRESPONDING FIELDS OF TABLE it_msEg
where matnr in so_matnr
AND werks = plant
AND BWART IN SO_BWART.
endform.
" get_data
*&--------------------------------------------------------------------*
*&
Form VALIDATE_COMMAND
*&--------------------------------------------------------------------*
*
text
*---------------------------------------------------------------------*
*
-->R_UCOMM
text
*
-->SEL_FIELD text
*---------------------------------------------------------------------*
FORM validate_command USING r_ucomm TYPE sy-ucomm
sel_field TYPE slis_selfield.
BREAK SAPDEV3.
DATA :it_grid TYPE REF TO cl_gui_alv_grid.
DATA : is_valid.
* CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
*
IMPORTING
*
*
e_grid
= it_grid.
**
*
* CALL METHOD it_grid->check_changed_data
*
IMPORTING
*
e_valid
= is_valid .
CASE r_ucomm.
WHEN '&DATA_SAVE'.
ENDCASE.
ENDFORM.
"validate_command
*&---------------------------------------------------------------------*
*&
Form BUILD_LAYOUT
*&---------------------------------------------------------------------*
*
Build layout for ALV grid report
*----------------------------------------------------------------------*
form build_layout.
BREAK SAPDEV3.
gd_layout-box_fieldname
= 'SEL'.
"set field name to store row selection
* gd_layout-edit
= 'X'. "makes whole ALV table editable
gd_layout-zebra
= 'X'.
endform.
" BUILD_LAYOUT