2010 Aug 24 2:01 PM
Hi gurus,
In a custom report I defined a message table in this way:
TYPES: BEGIN OF tytbl_output,
msgtype TYPE bapi_mtype,
argument TYPE symsgv,
msgtext TYPE bapi_msg,
END OF tytbl_output.
DATA: output_table TYPE TABLE OF tytbl_output WITH HEADER LINE.
At the end of the code, I'd like to show the above table in an ALV representation.
In order to obtain this, I tried to build a field catalog in this way:
* Create Fieldcatalogue from internal table
i_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = i_repid
I_INTERNAL_TABNAME = 'OUTPUT_TABLE'
I_INCLNAME = i_repid
CHANGING
CT_FIELDCAT = int_fcat
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
but the above call returns me an int_fcat table completely empty. Can anyone help me finding what's the matter?
Thanks in advance.
2010 Aug 24 2:06 PM
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = i_repid
"Check whether this is getting populated correctly
I_INTERNAL_TABNAME = 'OUTPUT_TABLE'
I_INCLNAME = i_repid "try commenting this
CHANGING
CT_FIELDCAT = int_fcat
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
Edited by: Rob Burbank on Aug 24, 2010 9:47 AM
2010 Aug 24 2:06 PM
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = i_repid
"Check whether this is getting populated correctly
I_INTERNAL_TABNAME = 'OUTPUT_TABLE'
I_INCLNAME = i_repid "try commenting this
CHANGING
CT_FIELDCAT = int_fcat
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
Edited by: Rob Burbank on Aug 24, 2010 9:47 AM
2010 Aug 24 2:10 PM
>
>
> I_INCLNAME = i_repid "try commenting this >
tried, same as before; int_fcat is empty. Maybe is this problem related to the way I use to define the itab?
2010 Aug 24 2:10 PM
Hi Matteo,
The output table parameter for building an ALV fildcatalogue has to be a DDIC dictionary/structure:
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = i_repid
*I_INTERNAL_TABNAME = 'OUTPUT_TABLE'*
I_INCLNAME = i_repid
CHANGING
CT_FIELDCAT = int_fcat
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
You have to define OUTPUT_TABLE at SAP DDIC (SE11 t-code) or build the fieldcatalogue by hand.
I hope it helps. Kind regards.
Edited by: MMP on Aug 24, 2010 3:10 PM
2010 Aug 24 2:18 PM
>
> Hi Matteo,
>
> The output table parameter for building an ALV fildcatalogue has to be a DDIC dictionary/structure:
Hi MMP and thanks for your help,
are you sure about it? I found some examples on how to display a custom or dynamic iTab using ALV which not refers to any DB structure/table.
Anyway, if that's the case and assuming you're right, how could I define a simple fieldcatalog table for my itab? It's just made up by three fields, it shouldn't be that complicated I guess... any example, particularly showing which fields for fieldcatalog are mandatory ?
Thanks in advance
M.
2010 Aug 24 2:31 PM
Instead of refering the fields directly to the data element, refer it to a table field and try.
It can also be used for custom internal tables.
2010 Aug 24 2:41 PM
>
> Instead of refering the fields directly to the data element, refer it to a table field and try.
> It can also be used for custom internal tables.
Done as follows:
TYPES: BEGIN OF tytbl_output,
msgtype LIKE BBPD_LA_MESSAGE-MSGTY, "TYPE bapi_mtype,
argument LIKE BBPD_LA_MESSAGE-MSGV1, "TYPE symsgv,
msgtext LIKE BBPD_LA_MESSAGE-MESSAGE, "TYPE bapi_msg,
END OF tytbl_output.
DATA: output_table TYPE TABLE OF tytbl_output WITH HEADER LINE.
without success; still int_fcat's empty.
Any other idea? Thanks again...
2010 Aug 24 2:52 PM
THis works ... but try to build it of your own , because LIKE & HEADER LINES statements are obsolete
TYPE-POOLS:slis.
DATA:g_repid TYPE sy-repid.
DATA:pt_fieldcatalog TYPE slis_t_fieldcat_alv.
data: BEGIN OF WA1,
msgtype LIKE BAPIRET2-TYPE, "TYPE bapi_mtype,
argument LIKE BAPIRET2-MESSAGE_V1, "TYPE symsgv,
msgtext LIKE BAPIRET2-MESSAGE, "TYPE bapi_msg,
END OF WA1.
DATA: it like TABLE OF wa1 with header line.
g_repid = sy-repid.
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = g_repid
i_internal_tabname = 'WA1'
i_inclname = g_repid
CHANGING
ct_fieldcat = pt_fieldcatalog
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
2010 Aug 24 2:40 PM
TYPES: BEGIN OF tytbl_output,
msgtype TYPE bapi_mtype,
argument TYPE symsgv,
msgtext TYPE bapi_msg,
END OF tytbl_output.
Change it as
TYPES: BEGIN OF tytbl_output,
msgtype LIKE <struname>-bapi_mtype,
argument LIKE <struname>-symsgv,
msgtext LIKE <struname>-bapi_msg,
END OF tytbl_output.
2010 Aug 24 3:09 PM
First read the FM documentation
Dictionary references are only considered if the keywords LIKE or INCLUDE STRUCTURE (not TYPE) are used.
So you must rely to an old school definition like DATA: BEGIN OF ITAB OCCURS 0, FIELD LIKE DDIC_REFERENCE, END OF ITAB. which is now obsolete...
- It is much easier to create a structure via SE11 and use it, it solve also problem linked to unit, currency and the like, and can be reusable, is easier maintained...
- If you don't want to create a structure fill a fieldcatalog in your program.
Regards,
Raymond
2010 Aug 24 3:22 PM
Hi all and thanks for your help!
All the above sketch of code didn't solve the job.
I managed however to obtain my desiderata building manually the field catalogue.
Here's my solution:
DATA: go_layout TYPE lvc_s_layo,
lt_sort TYPE lvc_t_sort,
wa_sort TYPE LINE OF lvc_t_sort,
lt_exclude TYPE ui_functions,
wa_exclude TYPE ui_func,
lt_fieldcatalog TYPE lvc_t_fcat,
wa_fieldcatalog TYPE LINE OF lvc_t_fcat,
go_container TYPE REF TO cl_gui_container,
go_alv TYPE REF TO cl_gui_alv_grid.
go_layout-zebra = 'X'.
go_layout-grid_title = 'Log messaggi'.
wa_fieldcatalog-fieldname = 'MSGTYPE'.
wa_fieldcatalog-ref_table = 'OUTPUT_TABLE'.
wa_fieldcatalog-ref_field = 'MSGTYPE'.
wa_fieldcatalog-scrtext_l = 'Tipologia errore'.
wa_fieldcatalog-coltext = 'Tipologia errore'.
wa_fieldcatalog-emphasize = 'X'.
wa_fieldcatalog-outputlen = 1.
APPEND wa_fieldcatalog TO lt_fieldcatalog.
CLEAR wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'ARGUMENT'.
wa_fieldcatalog-ref_table = 'OUTPUT_TABLE'.
wa_fieldcatalog-ref_field = 'MSGID'.
wa_fieldcatalog-scrtext_l = 'Argomento'.
wa_fieldcatalog-coltext = 'Argomento'.
wa_fieldcatalog-outputlen = 50.
APPEND wa_fieldcatalog TO lt_fieldcatalog.
CLEAR wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'MSGTEXT'.
wa_fieldcatalog-ref_table = 'OUTPUT_TABLE'.
wa_fieldcatalog-ref_field = 'MSGTEXT'.
wa_fieldcatalog-scrtext_l = 'Testo del messaggio'.
wa_fieldcatalog-coltext = 'Testo del messaggio'.
wa_fieldcatalog-outputlen = 220.
APPEND wa_fieldcatalog TO lt_fieldcatalog.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
EXPORTING
i_grid_title = go_layout-grid_title
is_layout_lvc = go_layout
it_fieldcat_lvc = lt_fieldcatalog
TABLES
t_outtab = output_table
.
Thanks to you all again for your support