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

How to create a structure manually for ALV?

I want to use internal table as my structure instead of a dictionary table. Therefore i know i cant use i_structure_name parameter in FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'. Any suggestion or example.

Thanks

Nahman

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Sep 26, 2006 at 06:23 PM

    You can use the field catalog. Please see the following example program.

    
    report zrich_0004
           no standard page heading.
    
    type-pools slis.
    
    <b>data: fieldcat type slis_t_fieldcat_alv.</b>
    
    data: begin of imara occurs 0,
          matnr type mara-matnr,
          maktx type makt-maktx,
          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 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.
    
    <b>  perform build_field_catalog.</b>
    
    * CALL ABAP LIST VIEWER (ALV)
      call function 'REUSE_ALV_GRID_DISPLAY'
           exporting
    <b>            it_fieldcat = fieldcat</b>
           tables
                t_outtab    = imara.
    
    endform.
    
    ************************************************************************
    * BUILD_FIELD_CATALOG
    ************************************************************************
    form build_field_catalog.
    
      data: fc_tmp type slis_fieldcat_alv.
      clear fieldcat. refresh fieldcat.
    
    <b>  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    = 'Material'.
      fc_tmp-fieldname  = 'MAKTX'.
      fc_tmp-tabname   = 'IMARA'.
      fc_tmp-outputlen  = '40'.
      fc_tmp-col_pos    = 3.
      append fc_tmp to fieldcat.</b>
    
    endform.
    
    

    Regards,

    Rich Heilman

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Sep 26, 2006 at 06:30 PM

    Hi

    Pass in the internal table name to the FM and manipulate the values in the structure using the texts.

    FORM fieldcat_build.

    DATA: l_count(2),l_field(8),l_text(8).

    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

    EXPORTING

    i_program_name = w_repid

    • i_structure_name = 'TRDIR'

    i_internal_tabname = 'IT_TAB'

    i_inclname = w_repid

    CHANGING

    ct_fieldcat = i_fieldcat_alv .

    • Modify displayed fields

    LOOP AT i_fieldcat_alv INTO w_fieldcat_alv.

    CASE w_fieldcat_alv-fieldname.

    WHEN 'BELNR'.

    w_fieldcat_alv-hotspot = 'X'.

    WHEN 'STATUS'.

    w_fieldcat_alv-seltext_m = text-td1.

    w_fieldcat_alv-seltext_l = text-td1.

    w_fieldcat_alv-seltext_s = text-td1.

    w_fieldcat_alv-reptext_ddic = text-td1.

    WHEN 'STATUS_TEXT'.

    w_fieldcat_alv-seltext_m = text-td2.

    w_fieldcat_alv-seltext_l = text-td2.

    w_fieldcat_alv-seltext_s = text-td2.

    w_fieldcat_alv-reptext_ddic = text-td2.

    WHEN OTHERS.

    ENDCASE.

    MODIFY i_fieldcat_alv FROM w_fieldcat_alv.

    ENDLOOP.

    ENDFORM. "fieldcat_build

    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.