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

Multiple Input Rows In ALV Grid (Editable)

Former Member
0 Likes
3,092

Hi,

I have an editable ALV grid and need to have multiple blank rows ready for input. Something similar to what happens when you click the "New Entries" button in SM30 (Table Maintainance).

There is a local function for appending lines in the ALV grid toolbar but this only allows a single entry.

I have replaced the local function with my own button (same icon etc) and on user_command event, I am appending several blank lines to my output table.

However these lines are not being shown on the screen. I have looked through the layout and field catalog but there is no field to allow blank lines to be shown.

My 2 questions are:

1. Is there some standard way of entering multiple entries in ALV Grid Editable.

2. If not then how to allow blank lines to be shown as ready for input.

Also if someone could suggest a way to do error checking for all entries on the screen especially duplicate entries I will be extremely grateful.

Many Thanks,

Preet

9 REPLIES 9
Read only

Former Member
0 Likes
1,931

Hi Preet,

What you can do is to append empty lines to your final internal table itself and see if your able to achieve your requirement.

Read only

0 Likes
1,931

Hi ,

I did try to append lines to my internal table at the "user_command" event.

The grid does not show the lines.

In the event data_changed I can see the blank lines in the debugger. I have also set the style for the blank lines to be enabled for the specific cells as required. Still doesnt seem to display it.

I remember that when using the REUSE Functions you could set a field to allow initial lines to be displayed. But in the LVC_ field catalog and layouts there doesnt seem to be any such field.

Thanks,

Preet

Read only

Former Member
0 Likes
1,931

Hi,

populate blank rows(how many ever you want append them and give the option

layout-edit = 'X'.

and pass the layout to FM,

regards

vijay

Read only

0 Likes
1,931

Hi,

I think I got a solution.

In the user_command event calling the method of the grid "refresh_table_display" shows multiple input rows.

Thanks for the help.

Is there any specific method or event to validate the input rows on the grid?

Many Thanks,

Preet

Read only

0 Likes
1,931

hi,

there is no method or event to validate,

you just need to loop the output internal table and need to validate.

regards

vijay

Read only

0 Likes
1,931

Hi Preet,

Use the following method for change entries :

  • If all entries are ok, ALV transferes new values to the output

  • table which you then can modify.

CALL METHOD G_GRID->CHECK_CHANGED_DATA

IMPORTING

E_VALID = L_VALID.

IF L_VALID EQ 'X'.

LOOP AT PT_OUTTAB INTO LS_OUTTAB.

---Move your change enteries to another internal table...

ENDIF.

Hope this will help you.

Lanka

Read only

0 Likes
1,931

Hi, Preet!

If you find answer(s) useful, it would be nice to reward points.

Thanks!

Regards,

Igor

Read only

Former Member
0 Likes
1,931

Hi,

You can use DATA_CHANGED event to validate input data before PAI is executed.

Regards,

Rao A

Read only

0 Likes
1,931

Hi, Preet!

You can easily do whatever checks you wish. You should declare an event handling method for event DATA_CHANGED and call the ADD_PROTOCOL_ENTRY method of the ER_DATA_CHANGED event parameter (it's an object of the class CL_ALV_CHANGED_DATA_PROTOCOL). You must not forget to set handler for your ALV grid.

For example, this piece of code checks for all changed fields resulting in error message if they are initial. In short, this makes all the fields obligatory.

METHODS: on_data_changed FOR EVENT data_changed OF cl_gui_alv_grid IMPORTING er_data_changed.
...
SET HANDLER your_object->on_data_changed FOR your_alv_grid.
...
METHOD on_data_changed.
DATA: s_mod_cell TYPE lvc_s_modi.
LOOP AT er_data_changed->mt_mod_cells INTO s_mod_cell.
    IF s_mod_cell-value IS INITIAL.
*       issue message 'Make an entry in all required fields'
        CALL METHOD er_data_changed->add_protocol_entry
          EXPORTING i_msgid     = '00' 
                    i_msgno     = '055' 
                    i_msgty     = 'E'
                    i_fieldname = s_mod_cell-fieldname
                    i_row_id    = s_mod_cell-row_id.
    ENDIF.
ENDMETHOD.

Furthermore, if you make your class inherited from CL_GUI_ALV_GRID you can make use of protected attribute MT_OUTTAB which is a data object referencing your output table. Then you can have:

FIELD-SYMBOLS: <outtab> TYPE STANDARD TABLE.
ASSIGN me->mt_outtab->* TO <outtab>.
* do whatever you want with <outtab>

Hope this helps.

Kind regards,

Igor

P.S. Regarding the blank lines that you need, what's wrong with standard ALV grid buttons "Append row" and "Insert row" which appear whenever the grid is editable (unless you deliberately remove them)? They work just fine with me (just like on SM30). I don't see reason for programatically appending lines to your internal table.