‎2009 Mar 03 6:40 AM
Hi abapers,
I got a scenario where there are two fields in a row.
when one field is edited and updated the other fields data should be modified.
For ex
Field1 field2
INR invalid country code
afte editing
field1 field2
US OK
Can any guideme in this case
‎2009 Mar 03 6:44 AM
Hi,
Use this code, its working:-
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program = v_rep_id " report id
i_callback_pf_status_set = 'PF' " for PF-STATUS
i_callback_user_command = 'USER_COMMAND' " for User-Command
is_layout = wa_layout " for layout
it_fieldcat = it_field " field catalog
it_sort = it_sort " sort info
TABLES
t_outtab = it_final " internal table
EXCEPTIONS
program_error = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. " ALV_DISPLAY
*&---------------------------------------------------------------------*
*& Form USER_COMMAND
*&---------------------------------------------------------------------*
* SUB-ROUTINE USER_COMMAND IS USED TO HANDLE THE USER ACTION
* AND EXECUTE THE APPROPIATE CODE
*----------------------------------------------------------------------*
* -->LV_OKCODE used to capture the function code
* of the user-defined push-buttons
* -->L_SELFIELD text
*----------------------------------------------------------------------*
FORM user_command USING lv_okcode LIKE sy-ucomm l_selfield TYPE slis_selfield.
* assign the function code to variable v_okcode
lv_okcode = sy-ucomm.
* handle the code execution based on the function code encountered
CASE lv_okcode.
* when the function code is SAVE then modify records
WHEN 'SAVE'. "when user clicks SAVE button
* to reflect the data changed into internal table
DATA : ref_grid TYPE REF TO cl_gui_alv_grid. "new
IF ref_grid IS INITIAL.
CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
IMPORTING
e_grid = ref_grid.
ENDIF.
IF NOT ref_grid IS INITIAL.
CALL METHOD ref_grid->check_changed_data.
ENDIF.
"internal table modified from alv output
* refresh the ALV Grid output from internal table
l_selfield-refresh = c_check.
"at this point alv is displayed with new text
ENDCASE.
ENDFORM. "USER_COMMAND
Regards,
Tarun
Edited by: Tarun Gambhir on Mar 3, 2009 12:16 PM
‎2009 Mar 03 6:50 AM
‎2009 Mar 03 6:58 AM
Hi,
Include a SAVE button in pf-status while creating pf-status and take its function code as SAVE, and when user changes data in alv and clicks SAVE button then the data from the alv will be modified to the internal table.
To create a pf-status for alv:-
goto se41 --> create a pf-status for your program --> goto menu extras --> click adjust template --> select list viewer
Now you will get a standard pf status. Delete the buttons that you dnt want to use and also you can add your own customized buttons. Give the function code for standard SAVE button as SAVE and activate the pf-status.
In the program apply this pf status to your report output as:-
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_pf_status_set = 'PF' " for PF-STATUS
*&---------------------------------------------------------------------*
*& Form pf
*&---------------------------------------------------------------------*
* SUB-ROUTINE PF IS USED TO SET THE PF-STATUS OF THE SCREEN
* ON WHICH THE ALV GRID IS DISPLAYED
*----------------------------------------------------------------------*
* -->RT_EXTAB
*----------------------------------------------------------------------*
FORM pf USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'ZTG_STAT'. "pf-status name
ENDFORM. "pf
Now you will have a pf status created by you applied on the report output.
Change the data and click SAVE button to save the modified data from alv to internal table using the code in previous reply.
Hope this helps you.
Regards,
Tarun
‎2009 Mar 03 6:58 AM
Hi,
In case of oops ALV u can do the following,
Create a class :-
CLASS cl_event_receiver DEFINITION.
PRIVATE SECTION.
DATA: error_in_data TYPE c.
METHODS
perform_checks
IMPORTING
pr_data_changed TYPE REF TO cl_alv_changed_data_protocol.
METHODS:
get_cell_values
IMPORTING
row_id TYPE int4
pr_data_changed TYPE REF TO cl_alv_changed_data_protocol
EXPORTING
w_key TYPE cuinst.
ENDCLASS.
under which create a method:-
CLASS cl_event_receiver IMPLEMENTATION.
METHOD handle_data_changed.
error_in_data = space.
CALL METHOD perform_checks( er_data_changed ).
IF error_in_data = 'X'.
CALL METHOD er_data_changed->display_protocol.
ENDIF.
ENDMETHOD. "handle_data_changed
METHOD get_cell_values.
CALL METHOD pr_data_changed->get_cell_value
EXPORTING
i_row_id = row_id
i_fieldname = 'CARRID'
IMPORTING
e_value = w_key.
ENDMETHOD. "GET_CELL_VALUES
ENDCLASS.
METHOD perform_checks.
PERFORM data_checks USING pr_data_changed
CHANGING error_in_data.
ENDMETHOD. "perform_checks
Then in the subroutine part:-
FORM data_checks USING pr_data_changed
CHANGING error_in_data.
FIELD-SYMBOLS: <l_fs> TYPE ANY.
LOOP AT p_data_changed->mt_mod_cells INTO ls_good.
CLEAR:l_htype.
CASE ls_good-fieldname.
WHEN 'FIELDNAME'
CHECK ls_good-value IS NOT INITIAL.
IF sy-subrc NE 0.
PERFORM add_entry USING text-m02 ls_good-fieldname
ls_good-row_id p_data_changed.
p_error = 'X'.
ENDIF.
FORM add_entry USING p_text p_fieldname p_rowid
p_data_changed TYPE REF TO
cl_alv_changed_data_protocol.
CALL METHOD p_data_changed->add_protocol_entry
EXPORTING
i_msgid = '0K'
i_msgno = '000'
i_msgty = 'E'
i_msgv1 = p_text
i_fieldname = p_fieldname
i_row_id = p_rowid.
ENDFORM . "ADD_ENTRY
endcase.
ENDLOOP.
ENDFORM.
Revert back in case of further help.
Thanks & Regards,
Ruchi Tiwari
Edited by: Ruchi Tiwari on Mar 3, 2009 7:59 AM
‎2009 Mar 03 7:01 AM
dear,
for editable field do jus one thing
in fieldcatalog add jus one code
wa_disp-edit = 'X'.
CLEAR wa_disp.
wa_disp-fieldname = 'TAX_D'.
wa_disp-scrtext_l = text-012.
wa_disp-edit = 'X'.
APPEND wa_disp TO it_disp.
for saving put
i_save = 'A'
in below FM
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
i_callback_program = g_repid
I_CALLBACK_PF_STATUS_SET = ' '
I_CALLBACK_USER_COMMAND = ' '
I_CALLBACK_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_TOP_OF_PAGE = ' '
I_CALLBACK_HTML_END_OF_LIST = ' '
I_STRUCTURE_NAME =
I_BACKGROUND_ID = ' '
I_GRID_TITLE =
I_GRID_SETTINGS =
is_layout = ls_layout
it_fieldcat = lt_fieldcat
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
i_save = 'A'
is_variant = ls_variant
it_events = gt_events[]
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IT_ALV_GRAPHICS =
IT_ADD_FIELDCAT =
IT_HYPERLINK =
I_HTML_HEIGHT_TOP =
I_HTML_HEIGHT_END =
IT_EXCEPT_QINFO =
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
t_outtab = it_data
EXCEPTIONS
program_error = 1
OTHERS = 2
Regards
vijay
.