04-17-2009 4:22 AM
Hi,
I have added a new field into a existing ALV report.
and defind a doamain and data element for it..with Value Range 'X' - Yes AND ' ' -No.
in my report i have changed paramter 'F4AVAILABLE' = 1 . for this field.
and in the report output i m getting F4 help for this field..
and when i click on the F4 .. gettin the pop-up with those values..
but when i double click it i couldnt palce the value in the column.
Can anyone help me how to capture the seleted row and place the value..
Edited by: Guru Ram on Apr 17, 2009 5:43 AM
04-17-2009 4:58 AM
Hi,
To capture the value selected in F4 help, you will have to use a method on_double_click
METHOD definition:
METHODS: on_double_click FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING es_row_no.
METHOD implementation
METHOD on_double_click.
* If not already caught by your own f4 help, check whether
* the triggered cell was ready for input by using e_display
* and if not, exit.
IF f4_params-g_display EQ 'X'.
LEAVE SCREEN.
ENDIF.
* After the user selected a value, pass it to the ALV Grid Control:
* Define a field symbol of type: LVC_T_MODI and a structure of
* type LVC_S_MODI to pass the value later on.
FIELD-SYMBOLS <itab> TYPE lvc_t_modi.
DATA: ls_modi TYPE lvc_s_modi,
ls_f4_itab TYPE gt_itab_type.
* Dereference attribute M_DATA into your field symbol and add
* the selected value to the table to which this symbol points to.
ASSIGN f4_params-g_event_data->m_data->* TO <itab>.
ls_modi-row_id = f4_params-g_row_no-row_id.
ls_modi-fieldname = f4_params-g_fieldname.
CLEAR ls_f4_itab.
READ TABLE f4_itab INTO ls_f4_itab INDEX es_row_no-row_id.
CASE f4_params-g_fieldname.
* On Expense Type
WHEN 'EX_TYPE'.
ls_modi-value = ls_f4_itab-ex_type.
LEAVE SCREEN.
ENDCASE.
ENDMETHOD. "on_double_click
Set handler
SET HANDLER me->on_double_click FOR g_c_f4_alv.
04-17-2009 4:58 AM
Hi,
To capture the value selected in F4 help, you will have to use a method on_double_click
METHOD definition:
METHODS: on_double_click FOR EVENT double_click OF cl_gui_alv_grid
IMPORTING es_row_no.
METHOD implementation
METHOD on_double_click.
* If not already caught by your own f4 help, check whether
* the triggered cell was ready for input by using e_display
* and if not, exit.
IF f4_params-g_display EQ 'X'.
LEAVE SCREEN.
ENDIF.
* After the user selected a value, pass it to the ALV Grid Control:
* Define a field symbol of type: LVC_T_MODI and a structure of
* type LVC_S_MODI to pass the value later on.
FIELD-SYMBOLS <itab> TYPE lvc_t_modi.
DATA: ls_modi TYPE lvc_s_modi,
ls_f4_itab TYPE gt_itab_type.
* Dereference attribute M_DATA into your field symbol and add
* the selected value to the table to which this symbol points to.
ASSIGN f4_params-g_event_data->m_data->* TO <itab>.
ls_modi-row_id = f4_params-g_row_no-row_id.
ls_modi-fieldname = f4_params-g_fieldname.
CLEAR ls_f4_itab.
READ TABLE f4_itab INTO ls_f4_itab INDEX es_row_no-row_id.
CASE f4_params-g_fieldname.
* On Expense Type
WHEN 'EX_TYPE'.
ls_modi-value = ls_f4_itab-ex_type.
LEAVE SCREEN.
ENDCASE.
ENDMETHOD. "on_double_click
Set handler
SET HANDLER me->on_double_click FOR g_c_f4_alv.
04-17-2009 5:02 AM
Hi,
Thanks.
ls_f4_itab TYPE gt_itab_type. - what is the type of gt_itab_type.
04-17-2009 5:08 AM
below is my code.
*&---------------------------------------------------------------------*
*& Report ZTEST_ALV_DROP_DOWN *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT ZTEST_ALV_DROP_DOWN .
tables : nfal.
TYPE-POOLS : slis,szal,icon.
types : begin of ty_data.
Include structure ztest_drop1.
types: end of ty_data.
*types : begin of ty_data,
* falnr like nfal-falnr,
* ind(3),
* end of ty_data.
*DATA : begin of it occurs 0,
* falnr like nfal-falnr,
* ind,
* end of it.
data : it type standard table of ty_data.
DATA: it_fcat TYPE slis_t_fieldcat_alv,
wa_fcat LIKE LINE OF it_fcat.
DATA: g_custom_container TYPE REF TO cl_gui_custom_container.
DATA: g_container TYPE scrfname VALUE 'CUST_CONTAINER'.
DATA: gc_x VALUE 'X'.
select-options : p_inst for nfal-einri.
select falnr from nfal into table it where einri in p_inst.
DATA : LT_FCAT TYPE LVC_T_FCAT.
DATA: ls_fcat TYPE lvc_s_fcat.
DATA: g_grid TYPE REF TO cl_gui_alv_grid.
DATA: ls_layout TYPE lvc_s_layo,
lt_exclude TYPE ui_functions.
CLASS lcl_event_receiver DEFINITION DEFERRED.
DATA: g_event_receiver TYPE REF TO lcl_event_receiver.
DATA:l_indi type ZTEST_DROP1-indi.
*----------------------------------------------------------------------
* Classes Definition
CLASS lcl_event_receiver DEFINITION.
PUBLIC SECTION.
METHODS: handle_data_changed
FOR EVENT data_changed OF cl_gui_alv_grid
IMPORTING
er_data_changed.
* METHODS: on_double_click FOR EVENT double_click OF cl_gui_alv_grid
* IMPORTING es_row_no.
PRIVATE SECTION.
DATA: error_in_data TYPE c.
data: pr_data_changed TYPE REF TO cl_alv_changed_data_protocol.
METHODS: place_value
IMPORTING
ps_good_material TYPE lvc_s_modi
pr_data_changed TYPE REF TO cl_alv_changed_data_protocol.
ENDCLASS. "LCL_EVENT_RECEIVER
CLASS lcl_event_receiver IMPLEMENTATION.
METHOD handle_data_changed.
DATA: ls_good TYPE lvc_s_modi.
error_in_data = space.
IF error_in_data = gc_x.
CALL METHOD er_data_changed->display_protocol.
ENDIF.
* CALL METHOD pr_data_changed->get_cell_value
* EXPORTING
* i_row_id = '2'
* i_fieldname = 'INDI'
* IMPORTING
* e_value = l_indi.
IF error_in_data = gc_x.
CALL METHOD er_data_changed->display_protocol.
ENDIF.
ENDMETHOD. "HANDLE_DATA_CHANGED
method place_value.
CALL METHOD pr_data_changed->modify_cell
EXPORTING
i_row_id = '2'
i_fieldname = 'INDI'
i_value = 'X'.
ENDMETHOD.
*METHOD on_double_click.
*
** If not already caught by your own f4 help, check whether
** the triggered cell was ready for input by using e_display
** and if not, exit.
** IF f4_params-g_display EQ 'X'.
** LEAVE SCREEN.
** ENDIF.
*
** After the user selected a value, pass it to the ALV Grid Control:
** Define a field symbol of type: LVC_T_MODI and a structure of
** type LVC_S_MODI to pass the value later on.
* FIELD-SYMBOLS <itab> TYPE lvc_t_modi.
* DATA: ls_modi TYPE lvc_s_modi,
* ls_f4_itab TYPE gt_itab_type.
*
** Dereference attribute M_DATA into your field symbol and add
** the selected value to the table to which this symbol points to.
* ASSIGN f4_params-g_event_data->m_data->* TO <itab>.
* ls_modi-row_id = f4_params-g_row_no-row_id.
* ls_modi-fieldname = f4_params-g_fieldname.
*
* CLEAR ls_f4_itab.
* READ TABLE f4_itab INTO ls_f4_itab INDEX es_row_no-row_id.
*
* CASE f4_params-g_fieldname.
** On Expense Type
* WHEN 'EX_TYPE'.
* ls_modi-value = ls_f4_itab-ex_type.
*
*
* LEAVE SCREEN.
* ENDMETHOD. "on_double_click
ENDCLASS.
START-OF-SELECTION.
call screen 100.
END-OF-SELECTION.
*&---------------------------------------------------------------------*
*& Module BPO OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE BPO OUTPUT.
PERFORM f_pbo_set .
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.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'ZTEST_DROP1'
CHANGING
ct_fieldcat = lt_fcat[]
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
loop at lt_fcat into ls_fcat.
case ls_fcat-fieldname.
WHEN 'INDI'.
ls_fcat-outputlen = 5.
ls_fcat-f4availabl = '1'.
* ls_fcat-edit = 'X'.
modify lt_fcat from ls_fcat.
endcase.
endloop.
* PERFORM f_exclude_tb_functions
* CHANGING lt_exclude.
CALL METHOD g_grid->set_table_for_first_display
EXPORTING
is_layout = ls_layout
it_toolbar_excluding = lt_exclude
CHANGING
it_fieldcatalog = lt_fcat
it_outtab = it[].
* CALL METHOD g_grid->set_ready_for_input
* EXPORTING
* i_ready_for_input = 1.
*
* CALL METHOD g_grid->register_edit_event
* EXPORTING
* i_event_id = cl_gui_alv_grid=>mc_evt_enter.
*
CREATE OBJECT g_event_receiver.
SET HANDLER g_event_receiver->handle_data_changed FOR g_grid.
*
* CREATE OBJECT g_event_receiver.
* SET HANDLER g_event_receiver->place_value FOR g_grid.
*
endif.
ENDMODULE. " BPO OUTPUT
*FORM f_exclude_tb_functions CHANGING pt_exclude TYPE ui_functions.
* DATA: ls_exclude TYPE ui_func.
* REFRESH: pt_exclude.
* ls_exclude = cl_gui_alv_grid=>mc_fc_loc_cut.
* APPEND ls_exclude TO pt_exclude.
* ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy_row.
* APPEND ls_exclude TO pt_exclude.
*ENDFORM.
*&---------------------------------------------------------------------*
*& Form f_pbo_set
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM f_pbo_set .
DATA: lt_excl TYPE TABLE OF sy-ucomm,
lc_mode(10) TYPE c.
SET PF-STATUS 'MAIN100' EXCLUDING lt_excl.
SET TITLEBAR 'MAIN100'.
ENDFORM. " f_pbo_set
04-17-2009 7:14 AM
Hi,
gt_itab is the table of type the one used for the F4 help. in my case it has one file ex_type which contains the values for F4 help .
I hope its clear.
Regards,
Mansi.
04-17-2009 6:12 AM
Hi Guru,
hope the code solves the issue...
TYPE-POOLS SLIS.
DATA: BEGIN OF <internal table> OCCURS 0,
BUKRS LIKE T001-BUKRS,
BUTXT LIKE T001-BUTXT,
END OF internal table.
PARAMETERS: P_BUKRS TYPE BUKRS.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_BUKRS.
PERFORM F4_FOR_BUKRS.
*&---------------------------------------------------------------------*
*& Form F4_FOR_BUKRS
*----------------------------------------------------------------------*
FORM F4_FOR_BUKRS.
DATA: IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE,
ES_SELFIELD TYPE SLIS_SELFIELD. * Get data
SELECT BUKRS
BUTXT
FROM T001
INTO TABLE <internal table>
up to 10 rows . * Get field
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = SY-REPID
I_INTERNAL_TABNAME = 'ITAB'
CHANGING
CT_FIELDCAT = IT_FIELDCAT[].
LOOP AT IT_FIELDCAT.
IT_FIELDCAT-KEY = SPACE.
IF IT_FIELDCAT-FIELDNAME = 'BUTXT'.
IT_FIELDCAT-EMPHASIZE = 'C710'.
ENDIF.
IF IT_FIELDCAT-FIELDNAME = 'BUKRS'.
IT_FIELDCAT-EMPHASIZE = 'C610'.
ENDIF.
MODIFY IT_FIELDCAT.
ENDLOOP.
CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'
EXPORTING
I_TITLE = 'THIS IS FOR F4 IN COLOR'
I_TABNAME = 'ITAB'
IT_FIELDCAT = IT_FIELDCAT[]
IMPORTING
ES_SELFIELD = ES_SELFIELD
TABLES
T_OUTTAB = internal table.
ENDFORM. " F4_FOR_BUKRS
thanks
ravi
04-17-2009 6:57 AM
Thanks.
But i m using Object oriented approach.. for ALV Display....