03-22-2020 5:34 AM
Hi, im creating alv report for self learning. When i tried to display the report, the column heading is showing abap dictionary name instead of seltext_m name, was wondering what i have missed
wa_fieldcat-col_pos = '1'.
wa_fieldcat-fieldname = 'matnr'.
wa_fieldcat-seltext_m = 'Material Number'.
wa_fieldcat-reptext_ddic = 'Material Number'.
wa_fieldcat-outputlen = 15.
CLEAR wa_mat.
wa_fieldcat-col_pos = '2'.
wa_fieldcat-fieldname = 'werks'.
wa_fieldcat-seltext_m = 'Plant'.
wa_fieldcat-outputlen = 15.
CLEAR wa_mat.
wa_fieldcat-col_pos = '3'.
wa_fieldcat-fieldname = 'name1'.
wa_fieldcat-seltext_m = 'Plant description'.
wa_fieldcat-outputlen = 15.
CLEAR wa_mat.
wa_fieldcat-col_pos = '4'.
wa_fieldcat-fieldname = 'mtart'.
wa_fieldcat-seltext_m = 'Material Type'.
wa_fieldcat-outputlen = 15.
CLEAR wa_mat.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
I_STRUCTURE_NAME = 'ZMAT' (this is the part i created with structure in data dictionary)
IS_LAYOUT = wa_layout
IT_FIELDCAT = it_fieldcat
IT_SORT = it_sort
TABLES
T_OUTTAB = it_mat
03-22-2020 5:48 AM
Include your internal table name - as below, remove wa_fieldcat-reptext_ddic = 'Material Number'.
alv_fieldcat_line-tabname = 'IT_MAT'.
alv_fieldcat_line-seltext_l = 'Your heading goes here'.
alv_fieldcat_line-fieldname = 'MATNR'.
lpos = lpos + 1.
alv_fieldcat_line-outputlen = 20.
alv_fieldcat_line-col_pos = lpos.
APPEND alv_fieldcat_line TO alv_fieldcat.
CLEAR alv_fieldcat_line.
03-22-2020 7:12 AM
Hi
Please make sure you put interntal table reference at TABNAME
alv_fieldcat_line-tabname = 'IT_MAT'.
alv_fieldcat_line-seltext_l = 'Your heading goes here'.
alv_fieldcat_line-fieldname = 'MATNR'.
lpos = lpos + 1.
alv_fieldcat_line-outputlen = 20.
alv_fieldcat_line-col_pos = lpos.
APPEND alv_fieldcat_line TO alv_fieldcat.
CLEAR alv_fieldcat_line.
03-31-2020 1:35 PM
03-31-2020 3:26 PM
The component TABNAME of the field catalog is ignored for REUSE_ALV_LIST_DISPLAY and REUSE_ALV_GRID_DISPLAY.
(It's only needed for REUSE_ALV_HIERSEQ_LIST_DISPLAY, and its value has to match parameter either I_TABNAME_HEADER or I_TABNAME_ITEM)
03-31-2020 4:57 PM
Dear Sao
Thanks for the reply
Kindly update the Solution and close the thread.
Regards,
Venkat
03-22-2020 10:41 AM
If you learn ABAP, then you'd better learn modern ABAP, not old ABAP 😉
ALV is not really core ABAP but help you understand basic ABAP operations.
Learn with CL_SALV_TABLE, you'll learn Object Orientation.
If you want to learn UI, better learn UI5.
03-22-2020 11:30 AM
By default, the column header is dynamically chosen from DDIC by the ALV Grid, by using the text which has the length close to the width of column (which varies either according to the values in the column, or to the output length you have forced or to the length changed by the user at run time).
If you want to force the one from SELTEXT_M, do this:
wa_fieldcat-seltext_m = 'Material Number'.
wa_fieldcat-ddictext = 'M'. " always use medium text
or from REPTEXT_DDIC, do this:
wa_fieldcat-reptext_ddic = 'Material Number'.
wa_fieldcat-ddictext = 'R'. " always use reptext_ddic
Etc.
Again, if you learn ABAP programming or modern ALV, prefer using modern ABAP (Object Oriented) or CL_SALV_TABLE. If you learn modern UI, learn UI5, not dynpro.
03-31-2020 1:22 PM
Hi Sandra
Thank you for your sharing.
Aside from ooalv, is there any new things i can explore as a abap newbie?
03-31-2020 2:04 PM
Simply look at all SAP current trends (ABAP Programming Model and so on, UI5, Fiori, Restful, CDS, BOPF, ...)