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: 

in ALV Reports, i want to edit records manually in out put display

Former Member
0 Kudos

hello all,

in ALV Reports, i want to edit records manually in out put display. how can i do that?

4 REPLIES 4

Former Member
0 Kudos

Hello Swamy,

There is a field called 'edit' in the field catalog, plz use this for your purpose.

Assign points, if helpful.

Rgds,

Raghu.

Former Member
0 Kudos

Hi,

Check out the below threads...

Thanks.

Former Member
0 Kudos

Hi,

Pl. check this sample prog.

REPORT ZALV_DISPLAY_CHANGE.

TABLES :T247.

TYPE-POOLS SLIS. "Type definitions for alv report

DATA: IT_FIELDCAT TYPE LVC_T_FCAT,

WA_FIELDCAT TYPE LVC_S_FCAT.

DATA: WA_LAYOUT TYPE LVC_S_LAYO.

DATA : BEGIN OF IT_FINAL OCCURS 0,

CHECK(1),

CELLTAB TYPE LVC_T_STYL, " Switch between display/change

MNR LIKE T247-MNR,

LTX LIKE T247-LTX,

END OF IT_FINAL.

DATA : WA_FINAL LIKE IT_FINAL.

DATA : W_REPID LIKE SY-REPID.

W_REPID = SY-REPID.

REFRESH IT_FINAL.

SELECT MNR LTX

FROM T247

INTO CORRESPONDING FIELDS OF TABLE IT_FINAL

WHERE SPRAS EQ 'E'.

WA_FIELDCAT-FIELDNAME = 'CHECK'.

WA_FIELDCAT-TABNAME = 'IT_FINAL'.

WA_FIELDCAT-CHECKBOX = 'X'.

WA_FIELDCAT-EDIT = 'X'..

WA_FIELDCAT-OUTPUTLEN = '3'.

WA_FIELDCAT-COL_POS = '1'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-FIELDNAME = 'MNR'.

WA_FIELDCAT-TABNAME = 'IT_FINAL'.

WA_FIELDCAT-OUTPUTLEN = '8'.

WA_FIELDCAT-COL_POS = '2'.

WA_FIELDCAT-REPTEXT = 'Month'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.

WA_FIELDCAT-FIELDNAME = 'LTX'.

WA_FIELDCAT-TABNAME = 'IT_FINAL'.

WA_FIELDCAT-OUTPUTLEN = '20'.

WA_FIELDCAT-COL_POS = '3'.

WA_FIELDCAT-REPTEXT = 'Month Desc'.

APPEND WA_FIELDCAT TO IT_FIELDCAT.

CLEAR WA_FIELDCAT.

DATA: WA_CELLTAB TYPE LVC_S_STYL,

IT_CELLTAB TYPE LVC_T_STYL,

L_INDEX TYPE I.

CLEAR : WA_CELLTAB,WA_FINAL,IT_CELLTAB.

REFRESH IT_CELLTAB.

*Initialize the celltab table

LOOP AT IT_FINAL INTO WA_FINAL.

L_INDEX = SY-TABIX.

WA_CELLTAB-FIELDNAME = 'CHECK'.

WA_CELLTAB-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_ENABLED.

INSERT WA_CELLTAB INTO TABLE IT_CELLTAB.

INSERT LINES OF IT_CELLTAB INTO TABLE WA_FINAL-CELLTAB.

MODIFY IT_FINAL FROM WA_FINAL INDEX L_INDEX.

ENDLOOP.

*Make the first five 5 rows as disabled

CLEAR L_INDEX.

LOOP AT IT_FINAL INTO WA_FINAL.

L_INDEX = SY-TABIX.

IF SY-TABIX LE 5.

LOOP AT WA_FINAL-CELLTAB INTO WA_CELLTAB.

IF WA_CELLTAB-FIELDNAME EQ 'CHECK' .

WA_CELLTAB-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.

MODIFY WA_FINAL-CELLTAB FROM WA_CELLTAB.

MODIFY IT_FINAL INDEX L_INDEX FROM WA_FINAL TRANSPORTING CELLTAB.

ENDIF.

ENDLOOP.

ENDIF.

ENDLOOP.

WA_LAYOUT-BOX_FNAME = 'CHECK'.

WA_LAYOUT-NO_ROWMARK = 'X'.

WA_LAYOUT-STYLEFNAME = 'CELLTAB'.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'

EXPORTING

I_CALLBACK_PROGRAM = W_REPID

I_GRID_TITLE = 'GRID DISPLAY'

IS_LAYOUT_LVC = WA_LAYOUT

IT_FIELDCAT_LVC = IT_FIELDCAT

TABLES

T_OUTTAB = IT_FINAL

EXCEPTIONS

PROGRAM_ERROR = 1

OTHERS = 2.

Regards,

Joy.

former_member212653
Active Contributor
0 Kudos

*&---------------------------------------------------------------------*
*& Report  ZTEST1
*&
*&---------------------------------------------------------------------*

REPORT  ztest1.
TYPE-POOLS: slis.

DATA:i_sbook TYPE STANDARD TABLE OF sbook INITIAL SIZE 0,
     i_sbook1 TYPE STANDARD TABLE OF sbook INITIAL SIZE 0,
     i_fieldcatalog TYPE slis_t_fieldcat_alv,
     wa_fieldcatalog LIKE LINE OF i_fieldcatalog,
     wa_sbook TYPE sbook.
DATA:wa_layout TYPE slis_layout_alv.

SELECT-OPTIONS:
s_carrid FOR wa_sbook-carrid.

AT SELECTION-SCREEN.
  IF s_carrid IS NOT INITIAL.
    SELECT COUNT( * )
      FROM scarr WHERE carrid IN s_carrid.
    IF sy-subrc <> 0.
      MESSAGE e000(ztest) WITH 'Invalid Airline Code'.

    ENDIF.
  ENDIF.

START-OF-SELECTION.

  SELECT *

    FROM sbook
    INTO TABLE i_sbook
    UP TO 50 ROWS
    WHERE carrid IN s_carrid.
  CHECK sy-subrc = 0.
  i_sbook1[] = i_sbook[].
  DATA: l_repid TYPE syrepid VALUE sy-repid.

  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
      i_program_name               = l_repid
      i_internal_tabname           = 'I_SBOOK'
     i_structure_name             = 'SBOOK'
      i_client_never_display       = 'X'
*   I_INCLNAME                   =
*   I_BYPASSING_BUFFER           =
*   I_BUFFER_ACTIVE              =
    CHANGING
      ct_fieldcat                  = i_fieldcatalog
    EXCEPTIONS
      inconsistent_interface       = 1
      program_error                = 2
      OTHERS                       = 3
            .
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
            WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
  LOOP AT i_fieldcatalog INTO wa_fieldcatalog.
    IF wa_fieldcatalog-fieldname = 'SMOKER'.
      wa_fieldcatalog-edit = 'X'.  " REUSE_ALV_GRID_DISPLAY
*      wa_fieldcatalog-input = 'X'.  " REUSE_ALV_LIST_DISPLAY
    ENDIF.

    MODIFY i_fieldcatalog FROM wa_fieldcatalog TRANSPORTING edit input.
  ENDLOOP.

  wa_layout-window_titlebar = 'My Title'.
  wa_layout-zebra = 'X'.
  wa_layout-colwidth_optimize = 'X'.

  DATA repid TYPE syrepid VALUE sy-repid.
  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program = repid
      i_callback_pf_status_set = 'SET_PF_STATUS'
      i_callback_user_command = 'SUB_USER_COMMAND'
      is_layout        = wa_layout
      it_fieldcat      = i_fieldcatalog
    TABLES
      t_outtab         = i_sbook
    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.


*&---------------------------------------------------------------------*
*&      Form  sub_user_command
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->R_UCOMM      text
*      -->RS_SELFIELD  text
*----------------------------------------------------------------------*
FORM sub_user_command  USING r_ucomm LIKE sy-ucomm
                                   rs_selfield TYPE slis_selfield.
  CASE r_ucomm.
    WHEN '&IC1'.  "Double click
      IF i_sbook1[] NE i_sbook[].
        MESSAGE i001(00) WITH 'Hmm...some data changed'.

      ENDIF.

  ENDCASE.

ENDFORM.                    "sub_user_command
*&---------------------------------------------------------------------*
*&      Form  set_pf_status
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->RT_EXTAB   text
*----------------------------------------------------------------------*
FORM set_pf_status USING rt_extab TYPE slis_t_extab.
  SET PF-STATUS 'ZSTANDARD'.
ENDFORM.                    "set_pf_status