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
882

Hello Experts,

I am working on editable alv using cl_gui_alv_grid. I have got a requirement which goes something like this :

when we execute the report then in display nothing will shown, but when the user will enter something in the display,

then it will fetch the corresponding data and will show in the ALV.

For example :

The alv has following fields :

emp number, emp name and emp_budget, when the user will enter the emp_number and press enter then it will get thr corresponding name and budget from the internal table.

so can you give me suggestion about how can I do it and what methods and events will be used.

Any kind of help will be really appreciated.

Regards,

Abhnab Mishra

6 REPLIES 6
Read only

Former Member
0 Likes
769

Hello Abhinav

Can you please explain why do you need an ALV in first place to show the employee details for an employee?

On a second thought, I think your requirement is something like this:

You execute the report. A screen comes up with a blank ALV. The user then adds a blank record to it using some ALV button. In this blank record, only emp_number field will be editable. In this record, the user enters the employee number and press enter and then the other two fields get filled.

Is that correct? I would then tell you how to do it.

Thanks and regards

Anand

Read only

0 Likes
769

Hi Anand,

Thanks for the response.

ALV is clients requirement.

your interpretation of the requirement is absolutely correct.

Can you please tell me how to do it??

Regards

Abhinab

Read only

0 Likes
769

Hi Abhinav,

Ok. If this is the requirement, you need to do the following:

Lets assume, the output internal table associated with ALV is gt_outtab.

1. In the field catalog, set the emp_number field as editable.

2. Add a button, for adding an empty record to gt_outtab, in the ALV toolbar. You can handle the event raised when the user presses this button in the handler of event "user_command".

In this handler, simply ADD INITIAL LINE TO gt_outtab.

For adding the button, you would need event "toolbar".

3. Make the following call to make the ALV editable.

CALL METHOD lo_grid->set_ready_for_input

EXPORTING

i_ready_for_input = 1.

4. To enable the ALV react on user pressing "Enter", make the following call.

CALL METHOD lo_grid->register_edit_event

EXPORTING

i_event_id = cl_gui_alv_grid=>mc_evt_enter.

5. After the user presses "Enter" after entering the employee number in the newly created record, you can you the "data_changed" event to validate the user input, say employee number and then fill the other two fields in event "data_changed_finished" event. Both these events will be called one after the other when the user will press "Enter".

Hope this information will be useful to you.

Best regards

Anand.

[How2SAP.com|http://www.how2sap.com/]

Read only

0 Likes
769

Hi Anand,

Thanks for the useful information.

If you can please explain your POINT 5, it would be really helpful.

Regards

Abhinab Mishra.

Read only

0 Likes
769

Check the demo programs with BCALV_EDIT* available in SAP which might be quite useful in understand programming with ALV.

Read only

Former Member
0 Likes
769

Problem Solved !!