2007 Dec 20 11:11 AM
1.Why do we need REUSE_ALV_FIELDCATALOG_MERGE?
I have done a sample program which travel from first list to second list.Simple steps are:
w_program = sy-repid
1.collect data from mara and put into internal table 1.
2.Displayed report using REUSE_ALV_GRID_DISPLAY passing PICK command,callback program=w_program.
3.Get selected row using Form Pick command.....
4.Update the internal table 2,with data from makt.
5.call function REUSE_ALV_FIELDCATALOG_MERGE getting T_FIELDCAT value.
w_program = sy-repid
6.Dispaly report using REUSE_ALV_GRID_DISPLAY passing internal table 2,callbackprogram=w_program.
a)I dont understand the usage of REUSE_ALV_FIELDCATALOG_MERGE.Can anyone tell me usage of that?
b)I think Sy-repid fetches current report id.Please tell me the role of "w_program=sy-repid" in the above program.
C)I tried 3 stages report.Mara->Makt->Mard.The flow was REUSE_ALV_GRID_DISPLAY->REUSE_ALV_FIELDCATALOG_MERGE->REUSE_ALV_GRID_DISPLAY->REUSE_ALV_FIELDCATALOG->REUSE_ALV_GRID_DISPLAY
but error occured,So I removed 2nd FM(fieldcatalog)
REUSE_ALV_GRID_DISPLAY->REUSE_ALV_GRID_DISPLAY->REUSE_ALV_FIELDCATALOG->REUSE_ALV_GRID_DISPLAY
Its working now?Any suggestions
2007 Dec 20 11:36 AM
Hi Gopi,
REUSE_ALV_FIELDCATALOG_MERGE is used for retrieve a catalog structure from a table defined in the Importing paramater DB Table/Internal Table, It will Partially help to Create a Fieldcatalog.
SY-REPID is the Name of the current ABAP program, It will Identify the Main progrma after call the FM.
Kanagaraja L
2007 Dec 31 9:01 AM
hi,
A field catalog is prepared using the internal table (I_FIELDCAT) of type SLIS_T_FIELDCAT_ALV. Field catalog containing descriptions of the list output fields (usually a subset of the internal output table fields).
A field catalog is required for every ALV list output to add desired functionality (i.e. Key, Hotspot, Specific headings, Justify, Col. position etc) to certain fields of the output. If not mentioned specifically, then the defaults are taken. The possible values and defaults are listed below.
The field catalog for the output table is built-up in the caller's coding. The build-up can be completely or partially automated by calling the REUSE_ALV_FIELDCATALOG_MERGE module.
The minimal field catalog is documented below. This can be done in a routine using a local variable. The user can use the other optional parameters to assign output attributes to different fields in the output, which differ from the default.
A field catalog need not be built-up and passed explicitly only under the following conditions:
1. The internal table to be output has the same structure as a Data Dictionary structure which is referred to in the internal table declaration using LIKE or INCLUDE STRUCTURE. In this case the attributes of the different fields is taken directly from the table and the attributes (key fields, length, texts etc) need to state explicitly.
2. all fields in this structure are to be output
3. The structure name is passed to ALV in the parameter I_STRUCTURE_NAME of the function module REUSE_ALV_LIST_DISPLAY.
-
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = V_REPID
I_INTERNAL_TABNAME =
I_STRUCTURE_NAME = 'ZCRICKET'
I_CLIENT_NEVER_DISPLAY = 'X'
I_INCLNAME =
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE =
CHANGING
CT_FIELDCAT = I_FIELDCAT
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.
reward if useful
rgds
Umakanth
2007 Dec 31 10:31 AM
Hi,
normally we can generate field catalog by our self by
using structure 'slis_fieldcat_alv'
which have fields like fieldname , itabname, edit, do_sum...etc.
here we r generating work area and appending to internal table of type 'slis_t_fieldcat_alv' to format the data output.
2. But instead of above u can also generate fieldcatalog by using function module 'REUSE_ALV_FIELDCATALOG_MERGE' HERE
U R PASSING TWO PARAMETERS to this FM
ie.
IMPORT
u r internal table
EXPORT
fieldcatalog internal table of type slis_t_fieldcat_alv.
here output of this consist field catalog itab with format of data to display on grid or list.
then u can directly pass to FM
REUSE_ALV_GRID_DISPLAY or REUSE_ALV_LIST_DISPLAY
Edited by: vijay Mekala on Dec 31, 2007 11:31 AM
2008 Jan 04 9:42 AM
I should forget that old Dinosaur way of doing it.
The method I'm showing below will work for almost ANY structure you care to name whether or not the fields are in the data dictionary.
I create a dynamic FCAT and dynamic table based on the FCAT and then populate it.
You can create field catalogs dynamically quite simply by using the new RTTI facility available from 4.6C onwards.
(From here it's only a small step to dynamic tables and EASY ALV grid displays)
Example to create dynamic FCAT and table and populate it with 200 entries from VAPMA
PROGRAM ZZ_BUILD_FLDCATALOG.
tables: vapma.
* Define any structure
types: begin of s_elements,
vbeln type vapma-vbeln,
posnr type vapma-posnr,
matnr type vapma-matnr,
kunnr type vapma-kunnr,
werks type vapma-werks,
vkorg type vapma-vkorg,
vkbur type vapma-vkbur,
status type c,
end of s_elements.
* end of your structure
data lr_rtti_struc type ref to cl_abap_structdescr .
data:
zog like line of lr_rtti_struc->components .
data:
zogt like table of zog,
wa_it_fldcat type lvc_s_fcat,
it_fldcat type lvc_t_fcat ,
dy_line type ref to data,
dy_table type ref to data.
data: dref type ref to data.
field-symbols: <fs> type any,
<dyn_table> type standard table,
<dyn_wa>.
*now I want to build a field catalog
* First get your data structure into a field symbol
create data dref type s_elements.
assign dref->* to <fs>.
lr_rtti_struc ?= cl_abap_structdescr=>describe_by_data( <fs> ).
zogt[] = lr_rtti_struc->components.
loop at zogt into zog.
clear wa_it_fldcat.
wa_it_fldcat-fieldname = zog-name .
wa_it_fldcat-datatype = zog-type_kind.
wa_it_fldcat-inttype = zog-type_kind.
wa_it_fldcat-intlen = zog-length.
wa_it_fldcat-decimals = zog-decimals.
wa_it_fldcat-coltext = zog-name.
wa_it_fldcat-lowercase = 'X'.
append wa_it_fldcat to it_fldcat .
endloop.
* Let's create a dynamic table and populate it
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = it_fldcat
importing
ep_table = dy_table.
assign dy_table->* to <dyn_table>.
create data dy_line like line of <dyn_table>.
assign dy_line->* to <dyn_wa>.
select vbeln posnr matnr kunnr werks vkorg vkbur
up to 200 rows
from vapma
into corresponding fields of table <dyn_table>.
from here you can pass your table to a GRID for display etc etc.
Cheers
Jimbo