Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with search help

Former Member
0 Kudos

Hi!, i'm a beginner, and i don't speak english very well, but i have a problem with a search help, sorry for my english. The problem is: I do a alv_grid with abap objects cl_gui_alv_grid and I do the catalog of a internal table with the

gt_fieldcat1-ref_table = 'ZHR_COD_CUAD'.

gt_fieldcat1-ref_field = 'CODCU'.

where zhr_cod_cuad is a database table i do and codcu a field who takes values (A,P,X,LX,XL,TR,M,..). The problem is that when i see the grid ready_for_input, the search help is running well, opens the popup with the values and texts but when I select one value the value not appear in the grid , but if I write a value with the keyboard the value on the grid is modified, so the grid is ready_for_input, but the selection of a value on the search help don't do nothing.

3 REPLIES 3

nablan_umar
Active Contributor
0 Kudos

Hi Xavi,

If I understand you correctly, you have a screen field that have a help values. You have use a method for this screen field to popup a list of possible values. However, when you double-click on the value from the popup, it does not bring back the value to the input screen field. Is this a correct statement?

0 Kudos

Hi Nablan you understand correctly . In that moment i try to do a search help looking the report BCALV_GRID_F4_HELP , but i prefer not to do this... Thanks.

Former Member
0 Kudos

please find below the attached code which will actually pick up the value from the search help from the ALV grid.

tables: v_eger, egerh.

----


  • CLASS lcl_grid DEFINITION

----


  • ........ *

----


class lcl_grid definition.

public section.

data my_grid type ref to cl_gui_alv_grid.

methods : constructor,

display.

endclass.

----


  • CLASS lcl_event DEFINITION

----


  • ........ *

----


class lcl_event definition.

public section.

class-methods : on_f4 for event onf4 of cl_gui_alv_grid

importing sender

e_fieldname

e_fieldvalue

es_row_no

er_event_data

et_bad_cells

e_display,

on_data_changed for event data_changed of cl_gui_alv_grid

importing er_data_changed.

private section.

TYPES: ddshretval_table TYPE TABLE OF ddshretval.

class-methods : my_f4

IMPORTING sender TYPE REF TO cl_gui_alv_grid

et_bad_cells TYPE lvc_t_modi

es_row_no TYPE lvc_s_roid

er_event_data TYPE REF TO cl_alv_event_data

e_display TYPE c

e_fieldname TYPE lvc_fname

EXPORTING lt_f4 TYPE ddshretval_table.

endclass.

DATA: info(80),

ok_code LIKE sy-ucomm.

  • data for grid

DATA: gs_layout TYPE lvc_s_layo,

gt_fieldcat TYPE lvc_t_fcat,

gs_fieldcat TYPE lvc_s_fcat.

DATA: BEGIN OF gt_outtab OCCURS 0.

INCLUDE STRUCTURE v_eger.

DATA: END OF gt_outtab,

gs_outtab LIKE LINE OF gt_outtab.

  • data for event handling

DATA: gs_f4 TYPE lvc_s_f4,

gt_f4 TYPE lvc_t_f4.

  • custom control and grid_application object

DATA: my_container TYPE REF TO cl_gui_custom_container,

my_application TYPE REF TO lcl_grid,

my_event type ref to lcl_event.

PARAMETERS: p_maxrow TYPE i DEFAULT 10.

START-OF-SELECTION.

END-OF-SELECTION.

create object my_event.

CALL SCREEN 200.

&----


*& Module get_data OUTPUT

&----


  • text

----


MODULE get_data OUTPUT.

select * from egerh into table gt_outtab up to p_maxrow rows.

ENDMODULE. " get_data OUTPUT

&----


*& Module show_display OUTPUT

&----


  • text

----


MODULE show_display OUTPUT.

if my_container is initial.

create object my_container exporting container_name = 'CONTAINER'.

create object my_application.

SET HANDLER lcl_event=>on_f4 FOR ALL INSTANCES.

SET HANDLER lcl_event=>on_data_changed FOR ALL INSTANCES.

call method my_application->display.

endif.

ENDMODULE. " show_display OUTPUT

&----


*& Module STATUS_0200 OUTPUT

&----


  • text

----


MODULE STATUS_0200 OUTPUT.

SET PF-STATUS 'STATUS200'.

SET TITLEBAR 'TIT200'.

ENDMODULE. " STATUS_0200 OUTPUT

&----


*& Module USER_COMMAND_0200 INPUT

&----


  • text

----


MODULE USER_COMMAND_0200 INPUT.

CASE ok_code.

WHEN 'BACK'.

LEAVE TO SCREEN 0.

WHEN 'CANC'.

LEAVE PROGRAM.

WHEN 'EXIT'.

LEAVE PROGRAM.

when 'CHNG'.

ENDCASE.

clear ok_code.

ENDMODULE. " USER_COMMAND_0200 INPUT

----


  • CLASS lcl_grid IMPLEMENTATION

----


  • ........ *

----


class lcl_grid implementation.

method constructor.

CREATE OBJECT my_grid

EXPORTING i_parent = my_container.

endmethod.

method display.

  • prepare fieldcatalog

CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'

EXPORTING

i_structure_name = 'EGERH'

CHANGING

ct_fieldcat = gt_fieldcat.

LOOP AT gt_fieldcat INTO gs_fieldcat.

IF gs_fieldcat-fieldname = 'EQUNR'.

gs_fieldcat-edit = 'X'.

gs_fieldcat-f4availabl = 'X'.

MODIFY gt_fieldcat FROM gs_fieldcat INDEX sy-tabix.

elseif gs_fieldcat-fieldname = 'DEVLOC'.

  • gs_fieldcat-edit = 'X'.

MODIFY gt_fieldcat FROM gs_fieldcat INDEX sy-tabix.

else.

delete gt_fieldcat where fieldname eq gs_fieldcat-fieldname.

ENDIF.

clear gs_fieldcat.

endloop.

CALL METHOD my_grid->set_ready_for_input

EXPORTING

i_ready_for_input = 1.

  • set table for first display

CALL METHOD my_grid->set_table_for_first_display

EXPORTING

  • i_structure_name = 'EGERH'

is_layout = gs_layout

CHANGING

it_outtab = gt_outtab[]

it_fieldcatalog = gt_fieldcat.

CLEAR gt_f4.

gs_f4-fieldname = 'EQUNR'.

gs_f4-register = 'X'.

gs_f4-chngeafter = 'X'.

gs_f4-getbefore = 'X'.

APPEND gs_f4 TO gt_f4.

CALL METHOD my_grid->register_f4_for_fields

EXPORTING

it_f4 = gt_f4.

endmethod.

endclass.

----


  • CLASS lcl_event IMPLEMENTATION

----


  • ........ *

----


class lcl_event implementation.

METHOD on_f4.

DATA: ls_f4 TYPE ddshretval,

lt_f4 TYPE TABLE OF ddshretval.

data ws_devloc like egerh-devloc.

data ws_equnr like egerh-equnr.

data lcl_data_changed type ref to CL_ALV_CHANGED_DATA_PROTOCOL.

FIELD-SYMBOLS: <itab> TYPE lvc_t_modi.

DATA: ls_modi TYPE lvc_s_modi.

  • now I call my personal f4-help

CALL METHOD my_f4

EXPORTING

sender = sender

es_row_no = es_row_no

er_event_data = er_event_data

et_bad_cells = et_bad_cells

e_display = e_display

e_fieldname = e_fieldname

IMPORTING

lt_f4 = lt_f4.

ASSIGN er_event_data->m_data->* TO <itab>.

READ TABLE lt_f4 INTO ls_f4 WITH KEY fieldname = 'EQUNR'.

IF NOT ls_f4 IS INITIAL.

ls_modi-row_id = es_row_no-row_id.

ls_modi-fieldname = 'EQUNR'.

ls_modi-value = ls_f4-fieldval.

APPEND ls_modi TO <itab>.

  • move ls_f4-fieldval to ws_equnr.

*

  • CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

  • EXPORTING

  • INPUT = ws_equnr

  • IMPORTING

  • OUTPUT = ws_equnr.

*

  • select single devloc from egerh

  • into ws_devloc

  • where equnr = ws_equnr

  • and ab le sy-datum

  • and bis ge sy-datum.

  • ls_modi-row_id = es_row_no-row_id.

  • ls_modi-fieldname = 'DEVLOC'.

  • ls_modi-value = ws_devloc.

  • APPEND ls_modi TO <itab>.

*

ENDIF.

er_event_data->m_event_handled = 'X'.

endmethod.

METHOD on_data_changed.

DATA: is_cells TYPE lvc_s_modi.

data ws_devloc like egerh-devloc.

data ws_equnr like egerh-equnr.

LOOP AT er_data_changed->MT_MOD_CELLS INTO is_cells

WHERE fieldname = 'EQUNR'.

move is_cells-value to ws_equnr.

CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'

EXPORTING

INPUT = ws_equnr

IMPORTING

OUTPUT = ws_equnr.

select single devloc from egerh

into ws_devloc where

equnr = ws_equnr

and bis ge sy-datum

and ab le sy-datum.

CALL METHOD er_data_changed->modify_cell

EXPORTING

i_row_id = is_cells-row_id

i_fieldname = 'DEVLOC'

i_value = ws_devloc.

endloop.

endmethod.

METHOD my_f4.

DATA: wa_tab LIKE LINE OF gt_outtab,

lt_fcat TYPE lvc_t_fcat,

ls_fieldcat TYPE lvc_s_fcat,

l_tabname TYPE dd03v-tabname,

l_fieldname TYPE dd03v-fieldname,

l_help_valu TYPE help_info-fldvalue,

lt_bad_cell TYPE lvc_t_modi,

lp_wa TYPE REF TO data.

FIELD-SYMBOLS: <l_field_value> TYPE ANY,

<ls_wa> TYPE ANY.

CALL METHOD sender->get_frontend_fieldcatalog

IMPORTING

et_fieldcatalog = lt_fcat.

READ TABLE gt_outtab INDEX es_row_no-row_id INTO wa_tab.

CREATE DATA lp_wa LIKE LINE OF gt_outtab.

ASSIGN lp_wa->* TO <ls_wa>.

<ls_wa> = wa_tab.

READ TABLE lt_fcat

WITH KEY fieldname = e_fieldname INTO ls_fieldcat.

MOVE ls_fieldcat-ref_table TO l_tabname.

MOVE ls_fieldcat-fieldname TO l_fieldname.

ASSIGN COMPONENT ls_fieldcat-fieldname

OF STRUCTURE wa_tab

TO <l_field_value>.

WRITE <l_field_value> TO l_help_valu.

PERFORM f4_set IN PROGRAM bcalv_f4

USING sender

lt_fcat

lt_bad_cell

es_row_no-row_id

<ls_wa>.

CALL FUNCTION 'F4IF_FIELD_VALUE_REQUEST'

EXPORTING

tabname = l_tabname

fieldname = l_fieldname

display = e_display

callback_program = 'BCALV_F4'

value = l_help_valu

callback_form = 'F4'

TABLES

return_tab = lt_f4.

ENDMETHOD. "my_f4

endclass.