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: 

fm REUSE_ALV_FIELDCATALOG_MERGE

former_member647278
Participant
0 Kudos

fm REUSE_ALV_FIELDCATALOG_MERGE

how do I use this fm with my internal report structure?

DATA: BEGIN OF gt_tmp OCCURS 0,

xblnr TYPE char40,
budat TYPE char40,

......

DATA END OF gt_tmp.

but using the "type" because all fields must be char40 and not like a field

5 REPLIES 5

DominikTylczyn
Active Contributor
0 Kudos

Hello nick.reyan

The straight, a bit blunt answer here is "you don't".

Look at the documentation of the function. It clearly states that to use internal structure to create a field catalog, the structure has to be defined with LIKE or INCLUDE STRUCTURE statements, not TYPE. Also it says that the variant with internal structure is not optimal in terms of performance and should only be used for rapid prototyping.

Hence you have two options: either redefine your internal table with LIKE or INCLUDE STRUCTURE statements or use DDIC structure or table to define the field catalog.

Best regards

Dominik Tylczynski

michael_piesche
Active Contributor

Can you show what you have actually achieved already and why exactly it doesnt work (syntax or runtime error).

But before, try the following:

DATA: BEGIN OF gt_tmp OCCURS 0,
        xblnr like TOAMS-PARA_NAME, " not nice, but it is referencing a CHAR40
        budat like TOAMS-PARA_NAME,
        " ...
      END OF gt_tmp.

" ...

call function 'REUSE_ALV_FIELDCATALOG_MERGE'
  exporting
    i_program_name         = sy-repid
    i_internal_tabname     = 'GT_TMP'
    i_inclname             = sy-repid
  changing
    ct_fieldcat            = ct_fieldcatalog
  exceptions
    inconsistent_interface = 1
    program_error          = 2
    others                 = 3.<br>

Also, try to search the community for answers first, before posting the question:

And one more thing, the FMs for ALV are very old school. Try to use the OOs for ALV next time.

  • look for Demo Reports in SE38:
    BCALV* using class CL_GUI_ALV_GRID (ALV List Viewer)
    SALV_DEMO* using class CL_SALV_TABLE (Simple ALV for simple Tables)

Sandra_Rossi
Active Contributor
0 Kudos

If the variable name containing the columns of the ALV is named XXXX and is defined in the program ZPROGRAM, in the include ZINCL:

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
  EXPORTING
    I_PROGRAM_NAME     = 'ZPROGRAM'
    I_INTERNAL_TABNAME = 'XXXX'
    I_INCL_NAME        = 'ZINCL'
    ...

XXXX should be declared as a global variable and with the following syntaxes (only few are permitted; note that a standalone type is permitted only with DATA):

1. Either defining free components (LIKE for reference to DDIC table or structure, TYPE for internal types - With or without OCCURS 0):

DATA : BEGIN OF xxxx OCCURS 0,
    test1 LIKE scarr-carrid,
    test2 TYPE i.
    INCLUDE STRUCTURE sflight.
DATA: curr(3) TYPE c,
      END OF xxxx.

2. or based on an existing DDIC table or structure (with or without OCCURS 0 - NB: this case is not interesting because the parameter I_STRUCTURE_NAME = 'BSEG' can be used instead of I_INTERNAL_TABNAME):

DATA xxxx TYPE scarr OCCURS 0.

NB:

1) The ABAP include must have its source code not wider than 72 characters or there is a short dump.

2) During the development, REUSE_ALV_FIELDCATALOG_MERGE may ignore the latest changes to the structure of the variable because the result of the first call is buffered. The buffer may be ignored by executing this line before the call:

SET PARAMETER ID 'ALVBUFFER' ID sy-datum.

That is a really good answer.

The code in original question uses CHAR40 data element not an internal type. It might be a tiny pesky bug to spot.

michael_piesche
Active Contributor
0 Kudos

nick.reyan, please follow up on your open question.

  • comment answers or your question if there are still open issues.
  • otherwise mark an answer as accepted if it helped you solve your problem
  • or post an answer of yourself and accept it if you found another useful solution yourself
  • or redirect your question to another question that is related and was useful to solve your problem
  • in the end, close your question