ALV With Editable F4
ALV With Editable F4
ALV With Editable F4
INITIALIZATION.
*start of selection event
START-OF-SELECTION.
*select the infotypes maintained
SELECT infty
pnnnn
zrmkz
zeitb
dname
davo
davoe
FROM t582a UP TO 10 ROWS
INTO CORRESPONDING FIELDS OF TABLE it_table.
* *Select the infotype texts
IF it_table[] IS NOT INITIAL.
SELECT itext
infty
sprsl
FROM t582s
INTO CORRESPONDING FIELDS OF TABLE it_ittext
FOR ALL ENTRIES IN it_table
WHERE infty = it_table-infty
AND sprsl = 'E'.
ENDIF.
*Apppending the data to the internal table of ALV output
LOOP AT it_table INTO wa_table.
wa_output-infty = wa_table-infty.
wa_output-pnnnn = wa_table-pnnnn.
wa_output-zrmkz = wa_table-zrmkz.
wa_output-zeitb = wa_table-zeitb.
wa_output-dname = wa_table-dname.
wa_output-davo = wa_table-davo.
wa_output-davoe = wa_table-davoe.
* For texts
READ TABLE it_ittext INTO wa_ittext WITH KEY infty = wa_table-infty.
wa_output-itext = wa_ittext-itext.
APPEND wa_output TO it_output.
CLEAR wa_output.
ENDLOOP.
* Calling the ALV screen with custom container
CALL SCREEN 0600.
*On this statement double click it takes you to the screen painter SE51.
*Enter the attributes
*Create a Custom container and name it CCONT and OK code as OK_CODE.
*Save check and Activate the screen painter.
*Now a normal screen with number 600 is created which holds the ALV grid.
* PBO of the actual screen ,
* Here we can give a title and customized menus
*create 2 buttons with function code 'SAVE' and 'EXIT'.
* GIVE A SUITABLE TITLE
*&---------------------------------------------------------------------*
*&
Module STATUS_0600 OUTPUT
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
MODULE status_0600 OUTPUT.
SET PF-STATUS 'DISP'.
SET TITLEBAR 'ALVF4'.
ENDMODULE.
" STATUS_0600 OUTPUT
* calling the PBO module ALV_GRID.
*&---------------------------------------------------------------------*
*&
Module PBO OUTPUT
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
MODULE pbo OUTPUT.
*Creating objects of the container
CLEAR lv_fldcat.
lv_fldcat-row_pos
= '1'.
lv_fldcat-col_pos
= '5'.
lv_fldcat-fieldname = 'ZRMKZ'.
lv_fldcat-tabname
= 'IT_OUTPUT'.
lv_fldcat-outputlen = 1.
lv_fldcat-scrtext_m = 'PERIOD'.
lv_fldcat-icon = ''.
APPEND lv_fldcat TO it_fcat.
CLEAR lv_fldcat.
lv_fldcat-row_pos
= '1'.
lv_fldcat-col_pos
= '6'.
lv_fldcat-fieldname = 'ZEITB'.
lv_fldcat-tabname
= 'IT_OUTPUT'.
lv_fldcat-outputlen = 5.
lv_fldcat-scrtext_m = 'Time constraint'.
lv_fldcat-edit = 'X'.
*To avail the existing F4 help these are to
*be given in the field catalogue
lv_fldcat-f4availabl = 'X'.
lv_fldcat-ref_table = 'T582A'.
lv_fldcat-ref_field = 'ZEITB'.
APPEND lv_fldcat TO it_fcat.
CLEAR lv_fldcat.
lv_fldcat-row_pos
= '1'.
lv_fldcat-col_pos
= '7'.
lv_fldcat-fieldname = 'DNAME'.
lv_fldcat-tabname
= 'IT_OUTPUT'.
lv_fldcat-outputlen = 15.
lv_fldcat-scrtext_m = 'Dialogmodule'.
lv_fldcat-icon = ''.
APPEND lv_fldcat TO it_fcat.
CLEAR lv_fldcat.
lv_fldcat-row_pos
= '1'.
lv_fldcat-col_pos
= '8'.
lv_fldcat-fieldname = 'DAVO'.
lv_fldcat-tabname
= 'IT_OUTPUT'.
lv_fldcat-outputlen = 15.
lv_fldcat-scrtext_m = 'Start'.
lv_fldcat-edit = 'X'.
APPEND lv_fldcat TO it_fcat.
CLEAR lv_fldcat.
lv_fldcat-row_pos
= '1'.
lv_fldcat-col_pos
= '9'.
lv_fldcat-fieldname = 'DAVOE'.
lv_fldcat-tabname
= 'IT_OUTPUT'.
lv_fldcat-outputlen = 15.
lv_fldcat-scrtext_m = 'End'.
lv_fldcat-icon = ''.
APPEND lv_fldcat TO it_fcat.
CLEAR lv_fldcat.
*To create drop down for the field 'DAVO'
* with our own f4 help
ty_dropdown-handle = '1'.
ty_dropdown-value = ' '.
APPEND ty_dropdown TO it_dropdown.
ty_dropdown-handle = '1'.
ty_dropdown-value = '1'.
APPEND ty_dropdown TO it_dropdown.
ty_dropdown-handle = '1'.
ty_dropdown-value = '2'.
APPEND ty_dropdown TO it_dropdown.
ty_dropdown-handle = '1'.
ty_dropdown-value = '3'.
APPEND ty_dropdown TO it_dropdown.
CALL METHOD c_alvgd->set_drop_down_table
EXPORTING
it_drop_down = it_dropdown.
LOOP AT it_fcat INTO lv_fldcat.
CASE lv_fldcat-fieldname.
** To assign dropdown in the fieldcataogue
WHEN 'DAVO'.
lv_fldcat-drdn_hndl = '1'.
lv_fldcat-outputlen = 15.
MODIFY it_fcat FROM lv_fldcat.
ENDCASE.
ENDLOOP.
ENDFORM.
" alv_build_fieldcat
*&---------------------------------------------------------------------*
*&
Form alv_report_layout
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
*
<--P_IT_LAYOUT text
*----------------------------------------------------------------------*
*Subroutine for setting alv layout
FORM alv_report_layout.
it_layout-cwidth_opt = 'X'.
it_layout-col_opt = 'X'.
it_layout-zebra = 'X'.
ENDFORM.
" alv_report_layout
* PAI module of the screen created. In case we use an interactive ALV or
*for additional functionalities we can create OK codes
*and based on the user command we can do the coding.
*&---------------------------------------------------------------------*
*&
Module PAI INPUT
*&---------------------------------------------------------------------*
*
text
*----------------------------------------------------------------------*
MODULE pai INPUT.
*To change the existing values and refresh the grid
*And only values in the dropdown or in the default
*F4 can be given , else no action takes place for the dropdown
*and error is thrown for the default F4 help and font changes to red
*and on still saving, value is not changed
c_alvgd->check_changed_data( ).
*Based on the user input
*When user clicks 'SAVE;
CASE ok_code.
WHEN 'SAVE'.
*A pop up is called to confirm the saving of changed data
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
titlebar
= 'SAVING DATA'
text_question = 'Continue?'
icon_button_1 = 'icon_booking_ok'
IMPORTING
answer
= gstring
EXCEPTIONS
text_not_found = 1
OTHERS
= 2.
IF sy-subrc NE 0.
*
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*When the User clicks 'YES'
IF ( gstring = '1' ).
MESSAGE 'Saved' TYPE 'S'.
*Now the changed data is stored in the it_pbo internal table
it_pbo = it_output.
*Subroutine to display the ALV with changed data.
PERFORM redisplay.
ELSE.
*When user clicks NO or Cancel
Output.
Default
F4
F4
HELP
for
help
dropdown
After editing the values and clicking SAVE,
the
in
field
TC
the