Page 1 of 1

Queries regarding usage of REUSE_ALV_FIELDCATALOG_MERGE

Posted: Tue Aug 16, 2005 6:42 am
by freddie4fingers
I am declaring an internal table as follows:

data: begin of itab,
matnr LIKE mseg-matnr,
menge LIKE mseg-menge,
maktx LIKE makt-maktx,
bwart LIKE mseg-bwart,
budat LIKE mkpf-budat,
todcbu LIKE mseg-menge,
mtdcbu LIKE mseg-menge,
tdispatch LIKE mseg-menge,
mtdispatch LIKE mseg-menge,
cbuyard LIKE mseg-menge,
end of itab.

*start-of-selection*
*end-of-selection*

here i use REUSE_ALV_FIELDCATALOG_MERGE
EXPORTING
I_PROGRAM_NAME = repid
I_INTERNAL_TABNAME = 'ITAB'
I_INCLNAME = repid
CHANGING
CT_FIELDCAT = fieldcat
but no row is appended to fieldcat.

does this function work for internal tables declared with data dict. line types or structures???

Posted: Tue Aug 16, 2005 6:57 am
by christmaslights
You seem to have missed out parameter I_STRUCTURE_NAME. I think this needs to hold the data dictionary structure your field catalogue is to be based on.

Posted: Tue Aug 16, 2005 7:12 am
by freddie4fingers
christmaslights wrote:You seem to have missed out parameter I_STRUCTURE_NAME. I think this needs to hold the data dictionary structure your field catalogue is to be based on.
This is the internal table I want to display in ALV control. There is no data dict. structure my fieldcatalog is to b based on.

Posted: Tue Aug 16, 2005 7:45 am
by christmaslights
I've never tried using the function with just an internal table. The documentation says it should work....but if you can't make it work just create a structure in the dictionary and base your itab on that, because using a dictionary structure will definitely work.

Posted: Tue Aug 16, 2005 8:24 am
by RosieBrent
You have to build your fieldcatalog data manually if you are not using a DDIC structure, then don't call REUSE_ALV_FIELDCATALOG_MERGE, just pass it directly to your ALV List / Grid call.

Hope this helps.

Besserwessi

Posted: Wed Aug 17, 2005 9:24 am
by Guest
Data definition must be set in an include.

Code: Select all

REPORT Z_TEST.

INCLUDE z_test_incl.
TYPE-POOLS: slis.
DATA fcat TYPE slis_t_fieldcat_alv.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
 EXPORTING
   i_program_name               = 'Z_TEST'
   i_internal_tabname           = 'ITAB'
*   I_STRUCTURE_NAME             =
*   I_CLIENT_NEVER_DISPLAY       = 'X'
    i_inclname                   = 'Z_TEST_INCL'
*   I_BYPASSING_BUFFER           =
*   I_BUFFER_ACTIVE              =
  CHANGING
    ct_fieldcat                  = fcat
 EXCEPTIONS
   inconsistent_interface       = 1
   program_error                = 2
   OTHERS                       = 3
          .
IF sy-subrc <> 0.
  MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Include Z_TEST_INCL.

Code: Select all

DATA: BEGIN OF itab ,
matnr LIKE mseg-matnr,
menge LIKE mseg-menge,
maktx LIKE makt-maktx,
bwart LIKE mseg-bwart,
budat LIKE mkpf-budat,
todcbu LIKE mseg-menge,
mtdcbu LIKE mseg-menge,
tdispatch LIKE mseg-menge,
mtdispatch LIKE mseg-menge,
cbuyard LIKE mseg-menge,
END OF itab.

Posted: Wed Aug 17, 2005 9:32 am
by Yessir
Always better alternatives possible.

For internal tables in reports (not Data Dictionary Object) data definition must be set in TOP-Include or set in an include, which name will be set as parameter 'incl_name' in this FM.

Data definition has to use 'LIKE' Statement or 'INCLUDE' never 'TYPE'.

Performance is better if you need a data dictionary object.

Posted: Wed Aug 17, 2005 9:33 am
by RosieBrent
The above is not true. It only has to be in an include if you pass an include name to the FM. If you do not, your data declaration can be in your main program.

Posted: Sat Mar 18, 2006 5:18 am
by RoadRunner
Excuse me for 'upping' the topic again but i can't see the answer has been given. I too need to build a field catalogue for an internal table because it's not worth to create ddic structure for EVERY itab i use for output in alv.
I passed to REUSE_ALV_FIELDCATALOG_MERGE sy-repid as I_PROGRAM_NAME and my itab name as I_INTERNAL_TABNAME (it is declared in corresponding top-include), but ct_fieldcat remains empty, sy-subrc = 0.
When using LVC_FIELDCATALOG_MERGE with same I_INTERNAL_TABNAME i get sy-subrc = 1 (exception INCONSISTENT_INTERFACE).
Does anyone have any suggestions?

Posted: Mon Mar 20, 2006 10:22 am
by Femmy
You have to build the field catalogue yourself.
See code:

FORM build_fieldcat CHANGING pt_fieldcat TYPE lvc_t_fcat.

DATA ls_fcat TYPE lvc_s_fcat.

CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = 'ZMMSCPREQUESTS'
CHANGING
ct_fieldcat = pt_fieldcat.

* Put an extra entry in the fieldcatalog for the vendor field
ls_fcat-fieldname = 'LIFNR'.
ls_fcat-reptext = 'Vendor' .
ls_fcat-scrtext_s = 'Vendor'.
ls_fcat-col_pos = '6'. "Tab 6 on ALV screen
INSERT ls_fcat INTO TABLE pt_fieldcat.

ENDFORM

I have used a table for the function. But added later an extra field to the field catalog (field was not in table). I have given the positon of that field and the name of the column. It is possible NOT to use the function 'LVC_FIELDCATALOG_MERGE' and to simply one for one fill the field catalog table with fields (as I did with the Vendor field). Takes more time, but it works.

Regards
Femmy

Posted: Wed Nov 29, 2006 1:47 pm
by sapfans_user
I too have tried to use this, and if I declare the ITAB in an include,
the field catalog gets created fine.
However I do not understand what is the criteria on which
REUSE_ALV_FIELDCATALOG_MERGE decides which fields of the
ITAB should be key and which ones should not?

REUSE_ALV_FIELDCATALOG_MERGE is returning me a field
catalog which has first 4 fields marked as key, the 5th one is
non key and then the sixth one is key again!!!

Can anyone please help?

Re: Queries regarding usage of REUSE_ALV_FIELDCATALOG_MERGE

Posted: Sun Nov 25, 2007 10:02 pm
by eml
freddie4fingers wrote:I am declaring an internal table as follows:

data: begin of itab OCCURS 0,
matnr LIKE mseg-matnr,
menge LIKE mseg-menge,
maktx LIKE makt-maktx,
bwart LIKE mseg-bwart,
budat LIKE mkpf-budat,
todcbu LIKE mseg-menge,
mtdcbu LIKE mseg-menge,
tdispatch LIKE mseg-menge,
mtdispatch LIKE mseg-menge,
cbuyard LIKE mseg-menge,
end of itab.
...
try adding the OCCURS n to your internal table declaration as shown in bold font in the quote above.

Re: Queries regarding usage of REUSE_ALV_FIELDCATALOG_MERGE

Posted: Mon Nov 26, 2007 3:01 am
by Rich
eml wrote:
freddie4fingers wrote:I am declaring an internal table as follows:

data: begin of itab OCCURS 0,
matnr LIKE mseg-matnr,
menge LIKE mseg-menge,
maktx LIKE makt-maktx,
bwart LIKE mseg-bwart,
budat LIKE mkpf-budat,
todcbu LIKE mseg-menge,
mtdcbu LIKE mseg-menge,
tdispatch LIKE mseg-menge,
mtdispatch LIKE mseg-menge,
cbuyard LIKE mseg-menge,
end of itab.
...
try adding the OCCURS n to your internal table declaration as shown in bold font in the quote above.
Duh!

Look at the date of the original post. I would think he would have found out by now how to do this.