Queries regarding usage of REUSE_ALV_FIELDCATALOG_MERGE

Development (ABAP Development WorkBench, ABAP/4 programming)

Moderators: Snowy, thx4allthefish, YuriT, Gothmog

Post Reply
freddie4fingers

Queries regarding usage of REUSE_ALV_FIELDCATALOG_MERGE

Post by freddie4fingers » Tue Aug 16, 2005 6:42 am

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???

christmaslights
Posts: 857
Joined: Wed Jun 16, 2004 5:13 am
Location: Hampshire, England

Post by christmaslights » Tue Aug 16, 2005 6:57 am

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.

freddie4fingers

Post by freddie4fingers » Tue Aug 16, 2005 7:12 am

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.

christmaslights
Posts: 857
Joined: Wed Jun 16, 2004 5:13 am
Location: Hampshire, England

Post by christmaslights » Tue Aug 16, 2005 7:45 am

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.

RosieBrent
Posts: 6197
Joined: Mon Oct 21, 2002 3:04 am
Location: Darlington
Contact:

Post by RosieBrent » Tue Aug 16, 2005 8:24 am

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.
Kind Regards

Rosie Brent

Please remember to search the forum and check the FAQ before posting questions, thank you.

Tuly Idiot most of the time, part-time Guru Image

Guest

Besserwessi

Post by Guest » Wed Aug 17, 2005 9:24 am

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.

Yessir

Post by Yessir » Wed Aug 17, 2005 9:32 am

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.

RosieBrent
Posts: 6197
Joined: Mon Oct 21, 2002 3:04 am
Location: Darlington
Contact:

Post by RosieBrent » Wed Aug 17, 2005 9:33 am

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.
Kind Regards

Rosie Brent

Please remember to search the forum and check the FAQ before posting questions, thank you.

Tuly Idiot most of the time, part-time Guru Image

RoadRunner
Posts: 5
Joined: Mon May 23, 2005 2:19 am
Contact:

Post by RoadRunner » Sat Mar 18, 2006 5:18 am

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?

Femmy
Posts: 4
Joined: Mon Mar 20, 2006 10:14 am

Post by Femmy » Mon Mar 20, 2006 10:22 am

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
Femmy

sapfans_user
Posts: 200
Joined: Thu Oct 05, 2006 12:50 pm

Post by sapfans_user » Wed Nov 29, 2006 1:47 pm

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?

eml
Posts: 32
Joined: Thu Jan 05, 2006 8:15 pm
Location: Philippines

Re: Queries regarding usage of REUSE_ALV_FIELDCATALOG_MERGE

Post by eml » Sun Nov 25, 2007 10:02 pm

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.

Rich
Posts: 7116
Joined: Thu Oct 31, 2002 4:47 pm
Location: Liverpool
Contact:

Re: Queries regarding usage of REUSE_ALV_FIELDCATALOG_MERGE

Post by Rich » Mon Nov 26, 2007 3:01 am

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.
Regards

Rich

Image
Abap KC:http://www.richard-harper.me.uk/Kb
SFMDR:http://www.se37.com

Post Reply