‎2006 Aug 18 1:11 PM
Hi!
In ALV, how do you create columns and add them so that they are displayed?
We have a list viewer and we want to add a new column to it.
regards
Baran
‎2006 Aug 18 1:29 PM
Hi Baran,
Populate the fieldcatalog seperately like this...
data: WA_FLDCAT_SUMMARY TYPE LVC_S_FCAT,
IT_FLDCAT_SUMMARY TYPE LVC_T_FCAT.
*--populating the fieldcatalog used for displaying summary details
WA_FLDCAT_SUMMARY-FIELDNAME = 'MBDAT'.
WA_FLDCAT_SUMMARY-TABNAME = 'IT_SUMMARY'.
WA_FLDCAT_SUMMARY-REPTEXT = TEXT-002.
WA_FLDCAT_SUMMARY-COL_POS = '1'.
WA_FLDCAT_SUMMARY-OUTPUTLEN = 20.
WA_FLDCAT_SUMMARY-KEY = 'X'.
APPEND WA_FLDCAT_SUMMARY TO IT_FLDCAT_SUMMARY.
CLEAR WA_FLDCAT_SUMMARY.
Now asusal pass this in the method.
*--displaying the summary details
SORT IT_SUMMARY BY MBDAT.
CALL METHOD OBJ_GRID_SUMMARY->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_LAYOUT = X_SUMMARY
CHANGING
IT_FIELDCATALOG = IT_FLDCAT_SUMMARY
IT_OUTTAB = IT_SUMMARY[].
Regards,
Vidya
‎2006 Aug 18 1:14 PM
Hi Baran,
Add that new field in the fieldcatalog and populate the value in the value in the internal table.
loop at it_fieldcatalog into wa_fieldcatalog.
wa_fieldcatalog-fieldname = 'NEW_FIELD'.
wa_fieldcatalog-outputlen = '15'.
append wa_fieldcatalog to it_fieldcatalog.
clear wa_fieldcatalog,
endloop.
‎2006 Aug 18 1:16 PM
thanks for the reply,
do you know which method contains the fieldcatalog?
‎2006 Aug 18 1:19 PM
‎2006 Aug 18 1:38 PM
Hi baran ,
There are alternative ways if you're creating it for use in list viewer you don't have to use methods.
use this for merging fields that you use in your
internal table
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = sy-repid
i_internal_tabname = 'WT_LIST'
i_client_never_display = 'X'
i_inclname = gc_include_name
CHANGING
ct_fieldcat = wt_fcat2
EXCEPTIONS
inconsistent_interface = 1
program_error = 2
OTHERS = 3.
----
if you want to append directly or after the fieldcatalog merge
such as :
CLEAR ws_fcat.
ws_fcat-fieldname = 'BANKN'.
ws_fcat-tabname = 'WT_VENDOR'.
ws_fcat-ref_fieldname = 'BANKN'.
ws_fcat-ref_tabname = 'LFBK'.
ws_fcat-input = wv_edit.
APPEND ws_fcat TO wt_fcat.
*----
hope this helps
‎2006 Aug 18 1:29 PM
Hi Baran,
Populate the fieldcatalog seperately like this...
data: WA_FLDCAT_SUMMARY TYPE LVC_S_FCAT,
IT_FLDCAT_SUMMARY TYPE LVC_T_FCAT.
*--populating the fieldcatalog used for displaying summary details
WA_FLDCAT_SUMMARY-FIELDNAME = 'MBDAT'.
WA_FLDCAT_SUMMARY-TABNAME = 'IT_SUMMARY'.
WA_FLDCAT_SUMMARY-REPTEXT = TEXT-002.
WA_FLDCAT_SUMMARY-COL_POS = '1'.
WA_FLDCAT_SUMMARY-OUTPUTLEN = 20.
WA_FLDCAT_SUMMARY-KEY = 'X'.
APPEND WA_FLDCAT_SUMMARY TO IT_FLDCAT_SUMMARY.
CLEAR WA_FLDCAT_SUMMARY.
Now asusal pass this in the method.
*--displaying the summary details
SORT IT_SUMMARY BY MBDAT.
CALL METHOD OBJ_GRID_SUMMARY->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
IS_LAYOUT = X_SUMMARY
CHANGING
IT_FIELDCATALOG = IT_FLDCAT_SUMMARY
IT_OUTTAB = IT_SUMMARY[].
Regards,
Vidya
‎2006 Aug 18 1:40 PM
Hello Baran
If you ALV list is based on a DDIC structure you can use function module LVC_FIELDCATALOG_MERGE to create the fieldcatalog.
The documentation of the function module says that you can also use a structure defined within your application. However, this poses some restrictions on the structure definition. Therefore I disregard this option and almost always define a DDIC stucture for my ALV lists.
Regards
Uwe
‎2006 Aug 18 2:05 PM
Hello Baran
The function module REUSE_ALV_FIELDCATALOG_MERGE returns the fieldcatalog in table type SLIS_T_FIELDCAT_ALV which is not compatible with the requirements of CL_GUI_ALV_GRID. You have to convert SLIS_T_FIELDCAT_ALV to LVC_T_FCAT in order to use (function module availabe for this conversion).
All these REUSE_... function modules belong to the old-fashioned way to create ALV lists. If you do not have specific requirements (e.g. hierarchical ALV lists) then I recommend to exclusively use ABAP-OO means (classes, e.g. CL_GUI_ALV_GRID) for ALV lists.
At the beginning the effort for learing is higher yet the reward in the long term is a much higher flexibility in coding.
Regards
Uwe