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

Remove field in Alv grid module pool

Former Member
0 Likes
530

Hi Experts,

I have a requirement where in I need to remove a field on the display screen for a particular record.

In detail..

I have a created a module pool program where in the final out put was shown using CL_gui_alv_grid on the new screen.The normal display will start with a check box(editable),kunnr,ktokd etc..The requirement is for a particular record the check box should either disappear or disable.Please help me out in achieving this.Thanks in advance.

Initially I got very good response from Neha and Satya and felt very confident enough in the fix but I dont know where I am doing wrong the issue is not yet fixed.Satya or Neha can you tell me where am I doing wrong seeing the below code.

types:BEGIN OF lty_final,

chbox TYPE char1,

org_nam TYPE name1_gp,

vkorg TYPE vkorg,

parvw TYPE parvw,

ktokd TYPE ktokd,

kunnr TYPE kunnr,

pr_cnt TYPE char3,

fir_nam TYPE name1_gp,

las_nam TYPE name1_gp,

parau TYPE parau,

telf1 TYPE telf1,

STYLE TYPE lvc_t_styl, " New field added in the structure

END OF lty_final.

data:lt_final type table of lty_final,

ls_final type lty_final.

DATA : ls_stylerow TYPE lvc_s_styl ,

lt_styletab TYPE lvc_t_styl .

loop at lt_final into ls_final. """Final internal table

if ls_final-pr_cnt = lc_yes.

ls_stylerow-FIELDNAME = 'CHBOX'.

ls_stylerow-STYLE = cl_gui_alv_grid=>mc_style_disabled .

APPEND ls_stylerow TO lt_styletab.

CLEAR ls_stylerow.

ls_final-STYLE = LT_STYLETAB.

MODIFY lt_final INDEX sy-tabix FROM ls_final TRANSPORTING style.

endif.

endloop.

gs_layout-zebra = 'X'.

gs_layout-edit = ' '.

gs_layout-no_rowmark = 'X'.

gs_layout-stylefname = 'LT_STYLETAB'.

CALL METHOD grid_display->set_table_for_first_display

EXPORTING

i_save = 'X'

i_default = 'X'

is_layout = gs_layout

CHANGING

it_outtab = lt_final

it_fieldcatalog = gt_fieldcat

EXCEPTIONS

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

OTHERS = 4.

IF sy-subrc NE 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

With Regards,

Srini...

Hi Experts,

I have a requirement where in I need to remove a field on the display screen for a particular record.

In detail..

I have a created a module pool program where in the final out put was shown using CL_gui_alv_grid on the new screen.The normal display will start with a check box(editable),kunnr,ktokd etc..The requirement is for a particular record the check box should either disappear or disable.Please help me out in achieving this.Thanks in advance.

Initially I got very good response from Neha and Satya and felt very confident enough in the fix but I dont know where I am doing wrong the issue is not yet fixed.Satya or Neha can you tell me where am I doing wrong seeing the below code.

types:BEGIN OF lty_final,

chbox TYPE char1,

org_nam TYPE name1_gp,

vkorg TYPE vkorg,

parvw TYPE parvw,

ktokd TYPE ktokd,

kunnr TYPE kunnr,

pr_cnt TYPE char3,

fir_nam TYPE name1_gp,

las_nam TYPE name1_gp,

parau TYPE parau,

telf1 TYPE telf1,

STYLE TYPE lvc_t_styl, " New field added in the structure

END OF lty_final.

data:lt_final type table of lty_final,

ls_final type lty_final.

DATA : ls_stylerow TYPE lvc_s_styl ,

lt_styletab TYPE lvc_t_styl .

loop at lt_final into ls_final. """Final internal table

if ls_final-pr_cnt = lc_yes.

ls_stylerow-FIELDNAME = 'CHBOX'.

ls_stylerow-STYLE = cl_gui_alv_grid=>mc_style_disabled .

APPEND ls_stylerow TO lt_styletab.

CLEAR ls_stylerow.

ls_final-STYLE = LT_STYLETAB.

MODIFY lt_final INDEX sy-tabix FROM ls_final TRANSPORTING style.

endif.

endloop.

gs_layout-zebra = 'X'.

gs_layout-edit = ' '.

gs_layout-no_rowmark = 'X'.

gs_layout-stylefname = 'LT_STYLETAB'.

CALL METHOD grid_display->set_table_for_first_display

EXPORTING

i_save = 'X'

i_default = 'X'

is_layout = gs_layout

CHANGING

it_outtab = lt_final

it_fieldcatalog = gt_fieldcat

EXCEPTIONS

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

OTHERS = 4.

IF sy-subrc NE 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

With Regards,

Srini...

2 REPLIES 2
Read only

Sm1tje
Active Contributor
0 Likes
466

Maybe this sample report can be of some use BCALV_EDIT_05

Read only

Former Member
0 Likes
466

Use the following codes in loop it will work.

Loop at lt_final into ls_final. """Final internal table
if ls_final-pr_cnt = lc_yes.
ls_stylerow-FIELDNAME = 'CHBOX'.
ls_stylerow-STYLE = cl_gui_alv_grid=>mc_style_disabled .
INSERT ls_stylerow  INTO TABLE lt_final-STYLE.                         " use insert
*APPEND ls_stylerow TO lt_styletab.
*CLEAR ls_stylerow.
*ls_final-STYLE = LT_STYLETAB.
*MODIFY lt_final INDEX sy-tabix FROM ls_final TRANSPORTING style.
endif.
endloop.

Regards,

Gurpreet