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

about REUSE_ALV_FIELDCATALOG_MERGE?

Hi friends,

I am using function module to detemine fields. REUSE_ALV_FIELDCATALOG_MERGE

you people might be known already it should work only when the internal table fields declared with LIKE.

data: begin of itab occurs 0,

MATERIAL like mara-matnr,

DESC like makt-maktx,

end of itab.

it will not work if you declared fields with TYPE.

data: begin of itab occurs 0,

MATERIAL(18) type c,

DESC(40) type c,

end of itab.

Could you pls let me know, how to use REUSE_ALV_FIELDCATALOG_MERGE function module... if the internal table fields declared using types.

or is there any function module or anything is available to find out field names?

Thanks in advance

Regards

Raghu

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Jun 13, 2008 at 02:51 PM

    Hi Raghunath,

    That is the reason we generally dont use in our programming.

    we need to defin the tables with like only

    Please check this link

    This is the example with LIKE keyword

    *data definition
    
    tables:
    marav. "Table MARA and table MAKT
    
    *---------------------------------------------------------------------*
    * Data to be displayed in ALV
    * Using the following syntax, REUSE_ALV_FIELDCATALOG_MERGE can auto-
    * matically determine the fieldstructure from this source program
    Data:
    begin of imat occurs 100,
    matnr like marav-matnr, "Material number
    maktx like marav-maktx, "Material short text
    matkl like marav-matkl, "Material group (so you can test to make
                            " intermediate sums)
    ntgew like marav-ntgew, "Net weight, numeric field (so you can test to
                            "make sums)
    gewei like marav-gewei, "weight unit (just to be complete)
    end of imat.
    
    *---------------------------------------------------------------------*
    * Other data needed
    * field to store report name
    data i_repid like sy-repid.
    * field to check table length
    data i_lines like sy-tabix.
    
    *---------------------------------------------------------------------*
    * Data for ALV display
    TYPE-POOLS: SLIS.
    data int_fcat type SLIS_T_FIELDCAT_ALV.
    
    *---------------------------------------------------------------------*
    select-options:
    s_matnr for marav-matnr matchcode object MAT1.
    
    *---------------------------------------------------------------------*
    start-of-selection.
    
    * read data into table imat
      select * from marav
      into corresponding fields of table imat
      where
      matnr in s_matnr.
    
    * Check if material was found
      clear i_lines.
      describe table imat lines i_lines.
      if i_lines lt 1.
    *   Using hardcoded write here for easy upload
        write: /
        'No materials found.'.
        exit.
      endif.
    
    end-of-selection.
    *---------------------------------------------------------------------*
    *
    * Now, we start with ALV
    *
    *---------------------------------------------------------------------*
    *
    *
    * To use ALV, we need a DDIC-structure or a thing called Fieldcatalogue.
    * The fieldcatalouge can be generated by FUNCTION
    * 'REUSE_ALV_FIELDCATALOG_MERGE' from an internal table from any
    * report source, including this report.
    * The only problem one might have is that the report and table names
    * need to be in capital letters. (I had it :-( )
    *
    *
    *---------------------------------------------------------------------*
    
    * Store report name
      i_repid = sy-repid.
    
    * Create Fieldcatalogue from internal table
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
           EXPORTING
                I_PROGRAM_NAME         = i_repid
                I_INTERNAL_TABNAME     = 'IMAT'  "capital letters!
                I_INCLNAME             = i_repid
           CHANGING
                CT_FIELDCAT            = int_fcat
           EXCEPTIONS
                INCONSISTENT_INTERFACE = 1
                PROGRAM_ERROR          = 2
                OTHERS                 = 3.
    *explanations:
    *    I_PROGRAM_NAME is the program which calls this function
    *
    *    I_INTERNAL_TABNAME is the name of the internal table which you want
    *                       to display in ALV
    *
    *    I_INCLNAME is the ABAP-source where the internal table is defined
    *               (DATA....)
    *      CT_FIELDCAT contains the Fieldcatalouge that we need later for
    *      ALV display
    
    
      IF SY-SUBRC <> 0.
        write: /
        'Returncode',
        sy-subrc,
        'from FUNCTION REUSE_ALV_FIELDCATALOG_MERGE'.
      ENDIF.
    
    *This was the fieldcatlogue
    *---------------------------------------------------------------------*
    *
    * And now, we are ready to display our list
    
    * Call for ALV list display
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
           EXPORTING
    *            I_CALLBACK_PROGRAM = 'Z_ALV_SIMPLE_EXAMPLE_WITH_ITAB'
                I_CALLBACK_PROGRAM = i_repid
                IT_FIELDCAT        = int_fcat
                I_SAVE             = 'A'
           TABLES
                T_OUTTAB           = imat
           EXCEPTIONS
                PROGRAM_ERROR      = 1
                OTHERS             = 2.
    *
    *explanations:
    *    I_CALLBACK_PROGRAM is the program which calls this function
    *
    *    IT_FIELDCAT (just made by REUSE_ALV_FIELDCATALOG_MERGE) contains
    *                 now the data definition needed for display
    *
    *    I_SAVE allows the user to save his own layouts
    *
    *      T_OUTTAB contains the data to be displayed in ALV
    
    
      IF SY-SUBRC <> 0.
        write: /
        'Returncode',
        sy-subrc,
        'from FUNCTION REUSE_ALV_LIST_DISPLAY'.
      ENDIF.

    Best regards,

    raam

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 13, 2008 at 02:53 PM

    Hi ,

    Check the below code ....You will get all answers you have ....

    _----


    tables: marav. "Table MARA and table MAKT

    ----


    • Data to be displayed in ALV

    • Using the following syntax, REUSE_ALV_FIELDCATALOG_MERGE can auto-

    • matically determine the fieldstructure from this source program

    Data:

    begin of imat occurs 100,

    matnr like marav-matnr,

    maktx like marav-maktx,

    matkl like marav-matkl,

    ntgew like marav-ntgew,

    gewei like marav-gewei,

    end of imat.

    ----


    • Other data needed

    • field to store report name

    data i_repid like sy-repid.

    • field to check table length

    data i_lines like sy-tabix.

    ----


    • Data for ALV display

    TYPE-POOLS: SLIS.

    data int_fcat type SLIS_T_FIELDCAT_ALV.

    ----


    select-options:

    s_matnr for marav-matnr." matchcode object MAT1

    ----


    start-of-selection.

    • read data into table imat

    select * from marav

    into corresponding fields of table imat

    where

    matnr in s_matnr.

    • Check if material was found

    clear i_lines.

    describe table imat lines i_lines.

    if i_lines lt 1.

    • Using hardcoded write here for easy upload

    write: /

    'No materials found.'.

    exit.

    endif.

    end-of-selection.

    ----


    *

    • Now, we start with ALV

    *

    ----


    *

    *

    • To use ALV, we need a DDIC-structure or a thing called Fieldcatalogue.

    • The fieldcatalouge can be generated by FUNCTION

    • 'REUSE_ALV_FIELDCATALOG_MERGE' from an internal table from any

    • report source, including this report.

    • The only problem one might have is that the report and table names

    • need to be in capital letters. (I had it 😔 )

    *

    *

    ----


    • Store report name

    i_repid = sy-repid.

    • Create Fieldcatalogue from internal table

    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

    EXPORTING

    I_PROGRAM_NAME = i_repid

    I_INTERNAL_TABNAME = 'IMAT' "capital letters!

    I_INCLNAME = i_repid

    CHANGING

    CT_FIELDCAT = int_fcat

    EXCEPTIONS

    INCONSISTENT_INTERFACE = 1

    PROGRAM_ERROR = 2

    OTHERS = 3.

    *explanations:

    • I_PROGRAM_NAME is the program which calls this function

    *

    • I_INTERNAL_TABNAME is the name of the internal table which you want

    • to display in ALV

    *

    • I_INCLNAME is the ABAP-source where the internal table is defined

    • (DATA....)

    • CT_FIELDCAT contains the Fieldcatalouge that we need later for

    • ALV display

    IF SY-SUBRC <> 0.

    write: /

    'Returncode',

    sy-subrc,

    'from FUNCTION REUSE_ALV_FIELDCATALOG_MERGE'.

    ENDIF.

    *This was the fieldcatlogue

    ----


    *

    • And now, we are ready to display our list

    • Call for ALV list display

    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

    EXPORTING

    I_CALLBACK_PROGRAM = i_repid

    IT_FIELDCAT = int_fcat

    I_SAVE = 'A'

    TABLES

    T_OUTTAB = imat

    EXCEPTIONS

    PROGRAM_ERROR = 1

    OTHERS = 2.

    *

    *explanations:

    • I_CALLBACK_PROGRAM is the program which calls this function

    *

    • IT_FIELDCAT (just made by REUSE_ALV_FIELDCATALOG_MERGE) contains

    • now the data definition needed for display

    *

    • I_SAVE allows the user to save his own layouts

    *

    • T_OUTTAB contains the data to be displayed in ALV

    IF SY-SUBRC <> 0.

    write: /

    'Returncode',

    sy-subrc,

    'from FUNCTION REUSE_ALV_LIST_DISPLAY'.

    ENDIF.

    _----


    Reward If useful

    Thanks

    Jagadeesh.G

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jun 13, 2008 at 02:58 PM

    Hi,

    In cases where you ahve internal table with fields declared using types, you have to build your own field catalog.

    Here are the different ways of building your field catalog:

    http://www.sapdevelopment.co.uk/reporting/alv/alv_variousfcat.htm

    Regards,

    Ravi Kanth Talagana

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jun 14, 2008 at 04:27 AM

    Hi,

    For your problem the solutions is develope field catalog manually.

    You can get the solution. Pass this fieldcatalog to ur grid/list function module

    Regards,

    Chandu

    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.