Application Development and Automation 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: 
Read only

Editable ALV

Former Member
0 Likes
500

Hi,

Please send me some sample programs about Editable ALV (that too with out using OOPS concept). Actually my query is, i have to display some records in ALV grid from a selected table. In output screen if i change some values, that changed values must be stored in to that database table.

Regards,

Eashwar S.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
465
3 REPLIES 3
Read only

former_member632991
Active Contributor
0 Likes
465

Hi,

for making some field aditable in alv, the property for that field in fieldcatalog needs to be set as

fieldcatalog-fieldname = 'CHECK'.

<b>FIELDCATALOG-EDIT = 'X' .</b>

and then u have to update the internal table also for that use usercommand

FORM FORM_USER_COMMAND USING R_UCOMM LIKE SY-UCOMM

RS_SELFIELD TYPE SLIS_SELFIELD..

DATA: GD_REPID LIKE SY-REPID, "Exists

REF_GRID TYPE REF TO CL_GUI_ALV_GRID. "new *then insert the

"FOLLOWING CODE IN YOUR USER_COMMAND ROUTINE...

IF REF_GRID IS INITIAL.

CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'

IMPORTING

E_GRID = REF_GRID.

ENDIF.

IF NOT REF_GRID IS INITIAL.

<b>CALL METHOD REF_GRID->CHECK_CHANGED_DATA</b> .

<b>this will update the changed data in the internal table</b>

ENDIF.

rs_sELFIELD-refresh = 'X'.

now update the data base table from internal table

Hope it helps.

Regards,

Sonika

Read only

Former Member
0 Likes
466
Read only

Former Member
0 Likes
465
DATA: g_container TYPE scrfname VALUE 'CUSTOM CONTROL',
      g_custom_container TYPE REF TO cl_gui_custom_container,
      g_grid  TYPE REF TO cl_gui_alv_grid,
      gs_layout TYPE lvc_s_layo,
      ok_code LIKE sy-ucomm,
      save_ok LIKE sy-ucomm.
.

DATA: gt_outtab TYPE TABLE OF sflight.


*---------------------------------------------------------------------*
*       MAIN                                                          *
*---------------------------------------------------------------------*
CALL SCREEN 100 STARTING AT 1 1..

*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*

MODULE status_0100 OUTPUT.
  SET PF-STATUS 'MAIN100'.
  SET TITLEBAR 'MAIN100'.

ENDMODULE.                 " STATUS_0100  OUTPUT

*&---------------------------------------------------------------------*
*&      Module  pbo  OUTPUT
*&---------------------------------------------------------------------*
MODULE pbo OUTPUT.

  IF g_custom_container IS INITIAL.

    CREATE OBJECT g_custom_container
      EXPORTING
        container_name              = g_container
      EXCEPTIONS
        cntl_error                  = 1
        cntl_system_error           = 2
        create_error                = 3
        lifetime_error              = 4
        lifetime_dynpro_dynpro_link = 5
        OTHERS                      = 6.
    IF sy-subrc <> 0.
*      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.


    CREATE OBJECT g_grid
      EXPORTING
        i_parent          = g_custom_container
      EXCEPTIONS
        error_cntl_create = 1
        error_cntl_init   = 2
        error_cntl_link   = 3
        error_dp_create   = 4
        OTHERS            = 5 .
    IF sy-subrc <> 0.
*      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

    gs_layout-edit = 'X'.

    SELECT * FROM sflight INTO TABLE gt_outtab UP TO 10 ROWS.

*§1.Set status of all cells to editable using the layout structure.
    CALL METHOD g_grid->set_table_for_first_display
      EXPORTING
        i_structure_name              = 'SFLIGHT'
        is_layout                     = gs_layout
      CHANGING
        it_outtab                     = gt_outtab
      EXCEPTIONS
        invalid_parameter_combination = 1
        program_error                 = 2
        too_many_lines                = 3
        OTHERS                        = 4.
    IF sy-subrc <> 0.
*      MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*                 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

*§2.Use SET_READY_FOR_INPUT to allow editing initially.
    CALL METHOD g_grid->set_ready_for_input
      EXPORTING
        i_ready_for_input = 1.

  ENDIF.
ENDMODULE.                 " pbo  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  pai  INPUT
*&---------------------------------------------------------------------*
MODULE pai INPUT.
  save_ok = ok_code.
  CLEAR ok_code.
  CASE save_ok.
    WHEN 'EXIT'.
      PERFORM exit_program.
    WHEN 'SWITCH'.
      PERFORM switch_edit_mode.
    WHEN OTHERS.
*     do nothing
  ENDCASE.
ENDMODULE.                 " pai  INPUT
*&---------------------------------------------------------------------*
*&      Form  exit_program
*&---------------------------------------------------------------------*
FORM exit_program .
  LEAVE PROGRAM.
ENDFORM.                    " exit_program
*&---------------------------------------------------------------------*
*&      Form  switch_edit_mode
*&---------------------------------------------------------------------*
FORM switch_edit_mode .

*§3.Use IS_READY_FOR_INPUT to fetch current substate of editable cells.
  IF g_grid->is_ready_for_input( ) EQ 0.
    CALL METHOD g_grid->set_ready_for_input
      EXPORTING
        i_ready_for_input = 1.
  ELSE.
    CALL METHOD g_grid->set_ready_for_input
      EXPORTING
        i_ready_for_input = 0.
  ENDIF.
ENDFORM.                    " switch_edit_mode