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

ALV new row insert.

Former Member
0 Likes
1,898

Hi all,

I have an alv grid implemented through class cl_gui_alv_grid.

i am trying to inset new rows into the alv.I want the key fields of only the inserted rows to be editable and not the key fields of the already existing records.

If any one can give any link which has a detailed instruction and concepts for this.

there is one program <b>BCALV_EDIT_04</b> which could not help me in having an idea for doing it .

regards

Sandeep

Hi all,

I have an alv grid implemented through class cl_gui_alv_grid.

i am trying to inset new rows into the alv.I want the key fields of only the inserted rows to be editable and not the key fields of the already existing records.

If any one can give any link which has a detailed instruction and concepts for this.

there is one program <b>BCALV_EDIT_04</b> which could not help me in having an idea for doing it .

regards

Sandeep

2 REPLIES 2
Read only

Former Member
0 Likes
700

Hi sandeep,

You can insert the work area into the internal table.

Like..

INSERT workarea INTO itab INDEX 3.

However, when you are trying to insert blank lines and display the same on the output, the display might create a problem, if the user tries to use the SORT / Total functions of the ALV Grid.

Once the internal table is updated, you can use the method REFRESH_TABLE_DISPLAY to refresh the screen data.

Hope this will help u.

Regards,

Kumar

Read only

Former Member
0 Likes
700

the answer to ur question is make use of styles .

firstly change the structure of ur internal table which u display in grid as follows

data: begin of line ,

line type s_tab ,

styletab type lvc_t_styl ,

end of line ,

itab type line occurs 0 ." this is the table to be displayed in the grid .

now first u fill ur internal table with all the details u need to display .

and mark all the key fields of ur table in field catalouge as editable .

the before set table for first display call this subroutine .

form styletab .

DATA: STYLE TYPE LVC_S_STYL ,

itab_style type lvc_t_styl .

FIELD-SYMBOLS: <WA_ITEM> LIKE GS_ITEM1 .

LOOP AT itab ASSIGNING <WA_ITEM> .

refresh itab_style .

IF NOT <WA_ITEM>-key_field1 IS INITIAL .

clear ls_style .

S_STYLE-FIELDNAME = 'key_field1'.

s_STYLE-style = cl_gui_alv_grid=>mc_style_DISABLED.

append s_style to itab_style .

ELSE .

S_STYLE-FIELDNAME = 'key_field1'.

s_STYLE-style = cl_gui_alv_grid=>mc_style_ENABLED.

APPEND S_STYLE TO itab_style .

ENDIF .

IF NOT <WA_ITEM>-key_field2 IS INITIAL .

clear ls_style .

S_STYLE-FIELDNAME = 'key_field2'.

s_STYLE-style = cl_gui_alv_grid=>mc_style_DISABLED.

append s_style to itab_style .

ELSEIF <WA_ITEM>-key_field2 IS INITIAL .

clear ls_style .

S_STYLE-FIELDNAME = 'key_field2'.

s_STYLE-style = cl_gui_alv_grid=>mc_style_ENABLED.

append s_style to itab_style .

ENDIF .

<lwa_item>-style_tab = lt_style .

ENDLOOP .

endform .

u hav to call this subroutine every time u refresh ur grid .

as all ur fields in field catalouge r editable wen u create new line the key fields will be initial and the above subroutine wil make them editable .

one more thing refresh this style table evrty time u call this subroutine .

and the table type lvc_t_styl is sorted table so plz enter the entries in sorted order .

i hope this should solve ur problem ..

if helpful then plz rewadr points .

if any doubts then i wud be glad to clarify them .

regards ,

swapnil .