Application Development 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: 

ALV List Display Problem

Former Member
0 Kudos

Hi All,

Please help me in finding out this. I need the alv output in this format.

Material Brand

10000 B100

empty B101

empty B102

10001 C100

empty C101

Actually the brand no is coming to the corner. so i specified the material as empty.In the empty place i dont want anything.

How to do this in alv list display. If it is not possible in ALV List display guide me in Grid display.Its urgent.

Thanks a lot guys.

Best Regards,

Vijay.

2 REPLIES 2

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

In the grid display, just sort on the material field. I am not sure if this works in the list display.

Regards,

Rich Heilman

0 Kudos

Here is a sample program which implements a sort programatically.



report zrich_0004
       no standard page heading.

type-pools slis.

data: fieldcat type slis_t_fieldcat_alv.
data: sort     type slis_t_sortinfo_alv.

data: begin of imara occurs 0,
      matnr type mara-matnr,
      labor type mara-labor,
      end of imara.

* Selection Screen
selection-screen begin of block b1 with frame title text-001 .
select-options: s_matnr for imara-matnr .
selection-screen end of block b1.

start-of-selection.

  perform get_data.
  perform write_report.

************************************************************************
*  Get_Data
************************************************************************
form get_data.

  select  mara~matnr mara~matkl mara~labor mara~brgew makt~maktx
            into corresponding fields of table imara
              from mara
               inner join makt
                 on mara~matnr = makt~matnr
                    where mara~matnr in s_matnr
                      and makt~spras = sy-langu.

endform.

************************************************************************
*  WRITE_REPORT
************************************************************************
form write_report.

  perform build_field_catalog.
  perform build_sort.

* CALL ABAP LIST VIEWER (ALV)
  call function 'REUSE_ALV_GRID_DISPLAY'
       exporting
            it_sort     = sort
            it_fieldcat = fieldcat
       tables
            t_outtab    = imara.

endform.

************************************************************************
* BUILD_FIELD_CATALOG
************************************************************************
form build_field_catalog.

  data: fc_tmp type slis_t_fieldcat_alv with header line.
  clear: fieldcat. refresh: fieldcat.

  clear: fc_tmp.
  fc_tmp-reptext_ddic    = 'Material Number'.
  fc_tmp-fieldname  = 'MATNR'.
  fc_tmp-tabname   = 'IMARA'.
  fc_tmp-outputlen  = '18'.
  fc_tmp-col_pos    = 2.
  append fc_tmp to fieldcat.

  clear: fc_tmp.
  fc_tmp-reptext_ddic    = 'Sort Group'.
  fc_tmp-fieldname  = 'LABOR'.
  fc_tmp-tabname   = 'IMARA'.
  fc_tmp-outputlen  = '12'.
  fc_tmp-col_pos    = 3.
  append fc_tmp to fieldcat.


endform.

************************************************************************
*       FORM build_sort                                                *
************************************************************************
form build_sort.

  data: tmp_sort type line of slis_t_sortinfo_alv.

  clear sort. refresh sort.

  clear tmp_sort.
  tmp_sort-fieldname = 'MATNR'.
  tmp_sort-tabname   = 'IALV'.
  tmp_sort-up        = 'X'.
  append tmp_sort to sort.


endform.

Regards,

Rich Heilman