2006 Jan 20 4:16 PM
hi,
I am passing the below statemnt to pass the field name and description to the sub_fieldcat.
since the report has got 100 fields i need to write for all the 100 fields like this, is there any possiblity to pass the field name and the description with less coding
PERFORM SUB_FIELDCAT USING '' 'BUDAT' 'Posting Date' G_COL 'X'.
ADD 1 TO G_COL.
.
.
.
.
FORM SUB_FIELDCAT USING L_TABNAME TYPE SLIS_TABNAME
L_FNAME TYPE SLIS_FIELDNAME
L_SEL TYPE DD03P-SCRTEXT_L
L_COL TYPE I
L_KEY TYPE C.
I_FIELDCATTAB_WA-REF_TABNAME = L_TABNAME.
I_FIELDCATTAB_WA-FIELDNAME = L_FNAME.
I_FIELDCATTAB_WA-SELTEXT_L = L_SEL.
I_FIELDCATTAB_WA-COL_POS = L_COL.
I_FIELDCATTAB_WA-KEY = L_KEY.
APPEND I_FIELDCATTAB_WA TO I_FIELDCATTAB.
ENDFORM. " SUB_FIELDCAT
2006 Jan 20 4:28 PM
Hi ,
Use function : REUSE_ALV_FIELDCATALOG_MERGE
Please note that your own logic required only if you want to changes the field description or length.
Lanka
Hi Anitha,
1. To the FM
we just need to pass the
internal table Name
( There is no need to use the parameter
I_STRUCTURE_NAME )
I_INTERNAL_TABNAME Is very important.
2. While declaring the internal table,
u can use any number of fields.
But make sure they are
declare using LIKE
eg.
bukrs like t001-bukrs
(do not use type)
3. Rest the FM will take care !
PS:
Important parameters are:
i_program_name,
i_internal_tabname = 'ITAB'
i_inclname = prg
where prg is sy-repid
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = prg
i_internal_tabname = 'ITAB'
i_inclname = prg
CHANGING
ct_fieldcat = alvfc
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
regards,
amit m.
Message was edited by: Amit Mittal
Message was edited by: Amit Mittal
2006 Jan 20 4:19 PM
HI Anitha,
1. REUSE_ALV_FIELDCATALOG_MERGE
why don't u use this standard FM
to build field catalogue.
2. Ur logic will be required
only for those fields, which
are different from abap dictionary !
regards,
amit m.
2006 Jan 20 4:31 PM
thanks for the reply, i am using 3 table fields . Can u show me a small example of passing 3 tables to the REUSE_ALV_FIELDCATALOG_MERGE.
I need to display all the fields from the 3 tables, these are the 3 tables RBKP_V, RSEG and RBCO.
It will be good if u provide me with the coding.
2006 Jan 20 4:34 PM
Hi Anitha,
use this :
DATA: ITAB_FLDCAT TYPE SLIS_T_FIELDCAT_ALV,
'TAB_DATA' = your internal table . you have to pass this value in Quotes .
G_REPID : Sy-program
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = G_REPID
I_INTERNAL_TABNAME = 'TAB_DATA'
I_INCLNAME = G_REPID
CHANGING
CT_FIELDCAT = ITAB_FLDCAT
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
Lanka
2006 Jan 20 4:37 PM
Hi Anitha,
1. To the FM
we just need to pass the
internal table Name
( There is no need to use the parameter
I_STRUCTURE_NAME )
I_INTERNAL_TABNAME Is very important.
2. While declaring the internal table,
u can use any number of fields.
But make sure they are
declare using LIKE
eg.
bukrs like t001-bukrs
(do not use type)
3. Rest the FM will take care !
PS:
Important parameters are:
i_program_name,
i_internal_tabname = 'ITAB'
i_inclname = prg
where prg is sy-repid
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = prg
i_internal_tabname = 'ITAB'
i_inclname = prg
CHANGING
ct_fieldcat = alvfc
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
regards,
amit m.
Message was edited by: Amit Mittal
Message was edited by: Amit Mittal
2006 Jan 20 4:49 PM
What is the structure of your internal table that is passed to the ALV grid function module? Is it simply
data: begin of itab occurs 0.
include structure RBKP_V.
include structure RSEG.
include structure RBCO.
data: end of itab.?
If so, then this should help.
data l_repid like sy-repid.
l_repid = sy-repid.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_program_name = l_repid
i_internal_tabname = 'ITAB'
* I_STRUCTURE_NAME =
* I_CLIENT_NEVER_DISPLAY = 'X'
i_inclname = l_repid
i_bypassing_buffer = 'X'
* I_BUFFER_ACTIVE =
changing
ct_fieldcat = fieldcat
exceptions
inconsistent_interface = 1
program_error = 2
others = 3.
2006 Jan 21 7:52 AM
thanks a lot for ur reply, i am able to do but since i am using alv grid display only few fields i am able to display the result of the fields are gone what can be the soluyion to display maore than 200 fields
2006 Jan 21 8:32 AM
Hi anitha,
1. At a time there is a limit
how many columns can be displayed.
2. It is better that
a Layout is selected/saved
to display REQUIERD fields
from the all 200 fields.
3. I mean,
all 200 fileds will be there in alv.
But the user can SAVE HIS OWN Layout
where he can CHOOSE from these 200 fields,
and display required fields only !
regards,
amit m.
2006 Jan 20 4:28 PM
Hi ,
Use function : REUSE_ALV_FIELDCATALOG_MERGE
Please note that your own logic required only if you want to changes the field description or length.
Lanka
2006 Jan 20 5:17 PM
u can do something like this using macros, this will also reduce ur code
*declare this before ur selection screen code
DEFINE add_catalog.
clear wa_fieldcat.
wa_fieldcat-fieldname = &1.
wa_fieldcat-seltext_l = &2.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
END-OF-DEFINITION.
*u can write this code in start of selection
CLEAR it_fieldcat.
REFRESH it_fieldcat.
add_catalog:
'FIELD1' 'field 1',
'FIELD2' 'field 2'.
u can exted this to how many attributes of fieldcatalog u want
2006 Jan 20 5:44 PM
if you don't use function fieldcat_merge or any other of the suggested automatic ways, you could still simplofy your SUB_FIELDCAT a little: G_COL is not necessary if you append the fields in the desired sequence. Then use
PERFORM USING:
'' 'BUDAT' 'Posting Date' 'X',
'' 'FIELD' 'what ever' ' ',
...
'' 'LAST' 'last field' ' '.
The method of passing program name and table name to the ALV display function did not work too good for me: Declaration must be LIKE, TYPE is not recognized and it works for global tables only.
I developed a routine generating a complete fieldcatalog using DDIC or tech information of all fields in the internal table ragrdless of their declaration. The routine uses the DESCRIBE statement - I wonder why SAP is unable to do that. I used it the last 3 years - no problems.
Sorry I won't post her because it's about 150 lines of code. I use it in every ALV report.
regards,
Clemens
| User | Count |
|---|---|
| 6 | |
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |