Hi Shankara,
Use the event 'BEFORE_LINE_OUTPUT' and write a small routine to verify if it is the same or different material and based on that you can enable or disable the description.
Another way would be to modify your internal table in such a way that only the first record per material will have the description and all other records for that material are blanked out.
Srinivas
Sort your ALV by using the IT_SORT parameter. This will help you with the ALV grid. This will not help you if you want this functionality in the LIST display of the ALV grid. You cannot use the AT NEW functionality with ALV grid.
Here is a short sample of what I'm talking about.
report zrich_0007. tables: mara. * Global ALV Data Declarations type-pools slis. * Miscellanous Data Declarations data: fieldcat type slis_t_fieldcat_alv. * Internal Tables data: begin of ialv occurs 0, matnr type mara-matnr, mtart type mara-mtart, werks type marc-werks, maktx type makt-maktx, end of ialv . select-options: s_mtart for ialv-mtart. start-of-selection. perform get_data. perform call_alv. ********************************************************************* * FORM GET_DATA. ********************************************************************* form get_data. select * into corresponding fields of table ialv from mara inner join marc on mara~matnr = marc~matnr where mara~mtart in s_mtart. loop at ialv. * Get material description select single maktx into ialv-maktx from makt where matnr = ialv-matnr and spras = sy-langu. modify ialv. endloop. sort ialv ascending by matnr werks. endform. ************************************************************************ * CALL_ALV ************************************************************************ form call_alv. data: it_sort type slis_t_sortinfo_alv. data: wa_sort like line of it_sort. wa_sort-spos = '1'. wa_sort-fieldname = 'MATNR'. wa_sort-tabname = 'IALV'. wa_sort-up = 'X'. append wa_sort to it_sort. wa_sort-spos = '2'. wa_sort-fieldname = 'MAKTX'. wa_sort-tabname = 'IALV'. wa_sort-up = 'X'. append wa_sort to it_sort. perform build_field_catalog. * Call ABAP List Viewer (ALV) call function 'REUSE_ALV_GRID_DISPLAY' exporting it_fieldcat = fieldcat it_sort = it_sort tables t_outtab = ialv. endform. ************************************************************************ * Form BUILD_Fieldcatalog - Set Up Columns/Headers ************************************************************************ form build_field_catalog. data: ls_fcat type slis_t_fieldcat_alv with header line. data: columnno(3) type n value '0'. refresh: fieldcat. clear: ls_fcat. ls_fcat-reptext_ddic = 'Material'. ls_fcat-fieldname = 'MATNR'. ls_fcat-outputlen = '18'. columnno = columnno + 1. ls_fcat-col_pos = columnno. ls_fcat-ref_fieldname = 'MATNR'. ls_fcat-ref_tabname = 'MARA'. append ls_fcat to fieldcat. clear: ls_fcat. ls_fcat-reptext_ddic = 'Plant'. ls_fcat-fieldname = 'WERKS'. ls_fcat-outputlen = '4'. columnno = columnno + 1. ls_fcat-col_pos = columnno. append ls_fcat to fieldcat. clear: ls_fcat. ls_fcat-reptext_ddic = 'Description'. ls_fcat-fieldname = 'MAKTX'. ls_fcat-outputlen = '30'. columnno = columnno + 1. ls_fcat-col_pos = columnno. append ls_fcat to fieldcat. endform.
Regards,
Rich Heilman
Message was edited by: Rich Heilman
Message was edited by: Rich Heilman
Add a comment