Skip to Content
author's profile photo Former Member
Former Member

At new .....statement in ALV

I have created an ALV report . In the report, the requirement is to display the material name and its description whenever it changes. How can i use the at new matnr...or on change of matnr in an ALV report ..

Please help me out..

Thanking you in advance ,

Shankar

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Posted on Jan 27, 2005 at 08:17 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jan 27, 2005 at 08:35 PM

    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
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.