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

Conditinal Editable Alv

Former Member
0 Likes
838

Hi Experts!!

I have designed one alv having PO Quantity which is editable.

Same time i want restrict 2nos of PO (says 40000000145. 400000000544), as "not Editable".

How to restrict that....

Same way i want to design Table Control Conditinal Editable Fields.

How to do that...

Thanks in Advance.

1 ACCEPTED SOLUTION
Read only

uwe_schieferstein
Active Contributor
0 Likes
819

Hello Anee

Sample report PROGRAM BCALV_EDIT_02 shows you all you need to know about editability on cell level in ALV grids.


PROGRAM BCALV_EDIT_02.
*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
* Purpose:
* ~~~~~~~~
* This report illustrates how to set chosen cells of an
* ALV Grid Control editable. (See BCALV_EDIT_01 for an overview
* of possible states).
* Remark: You may set the states for chosen columns using field
*         EDIT of the fieldcatalog, see BCALV_EDIT_03.
*-----------------------------------------------------------------
* To check program behavior
* ~~~~~~~~~~~~~~~~~~~~~~~~~
* Switch to the state editable and ready for input.
* You may then change the
* price of flights where the capacity of a plane is greater or equal
* than 300 seats.
*-----------------------------------------------------------------
* Essential steps (search for '§')
* ~~~~~~~~~~~~~~~
* 1.Extend your output table for a field, e.g., CELLTAB, that holds
*   information about the edit status of each cell for the
*   corresponding row (the table type is SORTED!).
* 2.After selecting data, set edit status for each row in a loop
*   according to field SEATSMAX.
* 2a.Use attribute CL_GUI_ALV_GRID=>MC_STYLE_ENABLED to set a cell
*    to status "editable".
* 2b.Use attribute CL_GUI_ALV_GRID=>MC_STYLE_DISABLED to set a cell
*    to status "non-editable".
* 2c.Copy your celltab to the celltab of the current row of gt_outtab.
* 3.Provide the fieldname of the celltab field by using field
*   STYLEFNAME of the layout structure.
*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
...

Regards

Uwe

Hi Experts!!

I have designed one alv having PO Quantity which is editable.

Same time i want restrict 2nos of PO (says 40000000145. 400000000544), as "not Editable".

How to restrict that....

Same way i want to design Table Control Conditinal Editable Fields.

How to do that...

Thanks in Advance.

5 REPLIES 5
Read only

Former Member
0 Likes
819

Hi,

Check the following link:

http://sapdev.co.uk/reporting/alv/alvgrid_editable.htm

Regards,

Bhaskar

Read only

former_member5472
Active Contributor
0 Likes
819

Hi anee,

You can follow the following steps to code your requirement

you must be aware of the method


  CALL METHOD g_grid1->set_table_for_first_display
    EXPORTING
      is_layout            = gs_layout_grid
      it_toolbar_excluding = gt_exclude_grid
    CHANGING
      it_fieldcatalog      = gt_fieldcat_batch
    it_outtab            =        gt_list[].

you need to pupulate proper values to make specific cells as non-editable/editable

1. declare gt_list as

DATA BEGIN OF gt_list OCCURS 0.

INCLUDE STRUCTURE zbm_ast_assum.

DATA cellstyles TYPE lvc_t_styl.

DATA END OF gt_list.

here in your structure add new table field called cellstyles.

2. make gs_layout_grid

the grid layout table as of type 'CELLSTYLES'


gs_layout_grid-stylefname = 'CELLSTYLES'.

3. make field catalog for all columns as editable.

4. now code to make specific cells as non-editable


data ls_stylerow type lvc_s_styl
data lt_styletab type lvc_t_styl

  LOOP AT gt_list INTO ls_listrow.
    IF ls_listrow-zassum = 'P_032'.
      ls_stylerow-fieldname = 'ZASSET'.
note :here i m making field zasset as non-editable when my data in another field zassum is P_032
in your case you can put condition as per your requirements

      ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.
      APPEND ls_stylerow TO lt_styletab.
    ENDIF.
 INSERT LINES OF lt_styletab INTO ls_listrow-cellstyles INDEX sy-tabix.
    MODIFY gt_list FROM ls_listrow.
  ENDLOOP


5.  CALL METHOD g_grid1->set_frontend_fieldcatalog
    EXPORTING
      it_fieldcatalog = gt_fieldcat_batch.

  CALL METHOD g_grid1->set_table_for_first_display
    EXPORTING
      is_layout            = gs_layout_grid
      it_toolbar_excluding = gt_exclude_grid
    CHANGING
      it_fieldcatalog      = gt_fieldcat_batch
    it_outtab            =        gt_list[].

6. last step is to refresh the display


  CALL METHOD g_grid1->refresh_table_display.
  CALL METHOD g_grid1->set_ready_for_input
    EXPORTING
      i_ready_for_input = '1'.

follow the sequence and you will get the results.

thanks

pratyush

Read only

0 Likes
819

Could you send me complete code piyush.

Thanks for repling.

Read only

uwe_schieferstein
Active Contributor
0 Likes
820

Hello Anee

Sample report PROGRAM BCALV_EDIT_02 shows you all you need to know about editability on cell level in ALV grids.


PROGRAM BCALV_EDIT_02.
*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
* Purpose:
* ~~~~~~~~
* This report illustrates how to set chosen cells of an
* ALV Grid Control editable. (See BCALV_EDIT_01 for an overview
* of possible states).
* Remark: You may set the states for chosen columns using field
*         EDIT of the fieldcatalog, see BCALV_EDIT_03.
*-----------------------------------------------------------------
* To check program behavior
* ~~~~~~~~~~~~~~~~~~~~~~~~~
* Switch to the state editable and ready for input.
* You may then change the
* price of flights where the capacity of a plane is greater or equal
* than 300 seats.
*-----------------------------------------------------------------
* Essential steps (search for '§')
* ~~~~~~~~~~~~~~~
* 1.Extend your output table for a field, e.g., CELLTAB, that holds
*   information about the edit status of each cell for the
*   corresponding row (the table type is SORTED!).
* 2.After selecting data, set edit status for each row in a loop
*   according to field SEATSMAX.
* 2a.Use attribute CL_GUI_ALV_GRID=>MC_STYLE_ENABLED to set a cell
*    to status "editable".
* 2b.Use attribute CL_GUI_ALV_GRID=>MC_STYLE_DISABLED to set a cell
*    to status "non-editable".
* 2c.Copy your celltab to the celltab of the current row of gt_outtab.
* 3.Provide the fieldname of the celltab field by using field
*   STYLEFNAME of the layout structure.
*&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
...

Regards

Uwe

Read only

Former Member
0 Likes
819

fatch only 2 rows with index soo u can edit only 2