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

OOPS: Editing data in basic List.

former_member307726
Participant
0 Likes
706

Hi Experts,

Can any one solve my problem?

I have displayed data using u2018CL_GUI_ALV_GRID=>SET_TABLE_FOR_FIRST_DISPLAYu2019. But my requirement is after the end of the last row one line should come in editable mode. User has to enter new values. One push button should be provided say u2018DISPu2019. After entering the values if he click u2018DISPu2019 the new values should be displayed in disabled mode. Then again after the end of all rows a new line should come in editable mode to give new values.

If it is possible in OOPS please give a clear idea to do this.

Thanks in Advance,

Regards,

Kumar

1 ACCEPTED SOLUTION
Read only

jayanthi_jayaraman
Active Contributor
0 Likes
668

Hi,

Once the button is clicked, in PAI, use describe statement to find out the no. of records and then make the fieldcatalog for all the fields for the last line.

TYPES : BEGIN OF ty.
   .....
* For cell editing and displaying cell as push button
TYPES : cellstyles TYPE lvc_t_styl,
        END OF ty.

Data w_style TYPE lvc_s_styl.

Set the layout stylefname as CELLSTYLES.
* Setting layout
  w_layout-stylefname = 'CELLSTYLES' ."cell-push button and edit

* Making a particular cell as non-editable and other editable
  CLEAR w_style.
  w_style-fieldname = 'ERNAM'.
  w_style-style = cl_gui_alv_grid=>mc_style_disabled.
  REFRESH wa-cellstyles.
  APPEND w_style TO wa-cellstyles.
  MODIFY itab FROM wa INDEX 3 TRANSPORTING cellstyles.

6 REPLIES 6
Read only

Sm1tje
Active Contributor
0 Likes
668

I can't give you any exact code for your requirement, but I want to refer to some sample report provided by SAP to get into editable ALV:

in SE38 enter BCALV_EDIT* and press F4. These report should definitely give you the necessary insights.

Read only

Former Member
0 Likes
668

Please follow the following steps to get you requirement.

1. Append one empty record in your internal table at last.

2. Display the record using ALV Gird Control methods.

3. Call the proper methods for Edit in ALV Grid.

4. Declare the Data change and User comment event for ALV Grid.

I hope if you done this way you will achieve your expectation. If you see the some sample code in the following program.

BCALV_GRID_EDIT.

If you are not able to identify, Please let me know, I will help more on this.

-


Ravi.

Read only

jayanthi_jayaraman
Active Contributor
0 Likes
669

Hi,

Once the button is clicked, in PAI, use describe statement to find out the no. of records and then make the fieldcatalog for all the fields for the last line.

TYPES : BEGIN OF ty.
   .....
* For cell editing and displaying cell as push button
TYPES : cellstyles TYPE lvc_t_styl,
        END OF ty.

Data w_style TYPE lvc_s_styl.

Set the layout stylefname as CELLSTYLES.
* Setting layout
  w_layout-stylefname = 'CELLSTYLES' ."cell-push button and edit

* Making a particular cell as non-editable and other editable
  CLEAR w_style.
  w_style-fieldname = 'ERNAM'.
  w_style-style = cl_gui_alv_grid=>mc_style_disabled.
  REFRESH wa-cellstyles.
  APPEND w_style TO wa-cellstyles.
  MODIFY itab FROM wa INDEX 3 TRANSPORTING cellstyles.

Read only

0 Likes
668

Thank you Jayanthi,

Still I have small problem on this...

I am able to pass only one entry in 'wa-cellstyles'.

Suppose I have 5 fileds in row.. I cannot disable more than one field in a row.

My requirement is I have to diable more than one fields in a row.

After passing the two or three entries to 'wa-cellstyles', while modifying the 'itab' it is giving short dump.

Please solve my problem.

Thanks & Regards,

Kumar.

Read only

0 Likes
668

Hello Kumar

There is one big error in the coding which explains your dump:


TYPES : BEGIN OF ty.
   .....
* For cell editing and displaying cell as push button
TYPES : cellstyles TYPE lvc_t_styl,  " <<< SORTED table type !!!
        END OF ty.
 
Data w_style TYPE lvc_s_styl.
 
Set the layout stylefname as CELLSTYLES.
* Setting layout
  w_layout-stylefname = 'CELLSTYLES' ."cell-push button and edit
 
* Making a particular cell as non-editable and other editable
  CLEAR w_style.
  w_style-fieldname = 'ERNAM'.
  w_style-style = cl_gui_alv_grid=>mc_style_disabled.
  REFRESH wa-cellstyles.
"  APPEND w_style TO wa-cellstyles.            " <<< wrong
  INSERT w_style INTO TABLE wa-cellstyles. " <<< correct 
"  MODIFY itab FROM wa INDEX 3 TRANSPORTING cellstyles.

Regards

Uwe

Read only

0 Likes
668

Thank you My problem is solved