Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Regarding editable alv

Hi experts!

i am using 'reuse_alv_grid_display' and populating field catalog like

fieldcat-input = 'X'.

and fieldcat-edit = 'X.

so when customer try to input data in the alv field and he press SAVE button then the data goes correctly into the internal table.

but when i try to do it by pressinv OK button data is not available in internal table.

can you guys plz help me out with that.

and second question.

can anyone tell me how to get the fuction code for 'ENTER' is been pressed from keyboard on any field in alv.

thanks in advance.

Tags:
Former Member
Former Member replied

&----


*& Report ZKB_EDIT_ALV

&----


REPORT zkb_edit_alv.

DATA: i_zkb_test TYPE TABLE OF zkb_test,

w_zkb_test TYPE zkb_test.

DATA: o_grid TYPE REF TO cl_gui_alv_grid,

o_container TYPE REF TO cl_gui_custom_container.

DATA: lt_fcat TYPE lvc_t_fcat,

ls_layo TYPE lvc_s_layo,

ls_sort TYPE lvc_s_sort,

lt_sort TYPE lvc_t_sort,

ls_fieldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE.

START-OF-SELECTION.

CALL SCREEN 9000.

&----


*& Module STATUS_9000 OUTPUT

&----


  • text

----


MODULE status_9000 OUTPUT.

SET PF-STATUS '9000'.

  • SET TITLEBAR 'xxx'.

ENDMODULE. " STATUS_9000 OUTPUT

&----


*& Module display_alv_9000 OUTPUT

&----


  • text

----


MODULE display_alv_9000 OUTPUT.

IF o_container IS INITIAL.

SELECT * FROM zkb_test INTO TABLE i_zkb_test.

IF cl_gui_alv_grid=>offline( ) IS INITIAL.

  • Create a custom container control for ALV Control

CREATE OBJECT o_container

EXPORTING

container_name = 'CONTAINER'.

  • Create a ALV Control

CREATE OBJECT o_grid

EXPORTING i_parent = o_container.

PERFORM build_field_catalgue.

CALL METHOD o_grid->set_table_for_first_display

EXPORTING

i_save = 'A'

i_default = 'X'

is_layout = ls_layo

CHANGING

it_outtab = i_zkb_test

it_fieldcatalog = lt_fcat

it_sort = lt_sort[].

ENDIF.

ENDIF.

ENDMODULE. " display_alv_9000 OUTPUT

&----


*& Module user_command_9000 INPUT

&----


  • text

----


MODULE user_command_9000 INPUT.

CASE sy-ucomm .

WHEN 'BACK' OR 'EXIT'.

SET SCREEN 0.

LEAVE SCREEN.

WHEN 'UPDATE'.

CALL METHOD o_grid->check_changed_data.

MODIFY zkb_test FROM TABLE i_zkb_test.

IF sy-subrc EQ 0.

COMMIT WORK AND WAIT.

MESSAGE 'Data updated' TYPE 'I'.

ENDIF.

  • Refresh the same in ALV

CALL METHOD o_grid->refresh_table_display.

ENDCASE.

ENDMODULE. " user_command_9000 INPUT

&----


*& Form build_field_catalgue

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


FORM build_field_catalgue .

DATA: ls_fcat TYPE lvc_s_fcat.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

i_program_name = sy-cprog

i_internal_tabname = 'I_ZKB_TEST'

i_structure_name = 'ZKB_TEST'

i_client_never_display = 'X'

CHANGING

ct_fieldcat = ls_fieldcat[]

EXCEPTIONS

inconsistent_interface = 1

program_error = 2

OTHERS = 3.

IF sy-subrc <> 0.

MESSAGE 'FCAT Error' TYPE 'I'.

EXIT.

ENDIF.

LOOP AT ls_fieldcat.

CLEAR ls_fcat.

ls_fcat-fieldname = ls_fieldcat-fieldname. "Fieldname

ls_fcat-ref_table = ls_fieldcat-tabname. "DDIC ref struct

ls_fcat-inttype = ls_fieldcat-inttype. "Data type

ls_fcat-outputlen = ls_fieldcat-outputlen. "Column width

ls_fcat-coltext = ls_fieldcat-seltext_m. "Column Header

ls_fcat-seltext = ls_fieldcat-seltext_m. "Column Desc

ls_fcat-ref_field = ls_fieldcat-ref_fieldname. "Reference field

ls_fcat-ref_table = ls_fieldcat-ref_tabname. "Reference table

CASE ls_fieldcat-fieldname.

WHEN 'MANDT' OR 'SNO'.

ls_fcat-edit = ' '.

WHEN OTHERS.

ls_fcat-edit = 'X'.

ENDCASE.

APPEND ls_fcat TO lt_fcat.

ENDLOOP.

ENDFORM. " build_field_catalgue

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question