09-26-2006 7:17 PM
I want to use internal table as my structure instead of a dictionary table. Therefore i know i cant use i_structure_name parameter in FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'. Any suggestion or example.
Thanks
Nahman
09-26-2006 7:23 PM
You can use the field catalog. Please see the following example program.
report zrich_0004
no standard page heading.
type-pools slis.
<b>data: fieldcat type slis_t_fieldcat_alv.</b>
data: begin of imara occurs 0,
matnr type mara-matnr,
maktx type makt-maktx,
end of imara.
* Selection Screen
selection-screen begin of block b1 with frame title text-001 .
select-options: s_matnr for imara-matnr .
selection-screen end of block b1.
start-of-selection.
perform get_data.
perform write_report.
************************************************************************
* Get_Data
************************************************************************
form get_data.
select mara~matnr makt~maktx
into corresponding fields of table imara
from mara
inner join makt
on mara~matnr = makt~matnr
where mara~matnr in s_matnr
and makt~spras = sy-langu.
endform.
************************************************************************
* WRITE_REPORT
************************************************************************
form write_report.
<b> perform build_field_catalog.</b>
* CALL ABAP LIST VIEWER (ALV)
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
<b> it_fieldcat = fieldcat</b>
tables
t_outtab = imara.
endform.
************************************************************************
* BUILD_FIELD_CATALOG
************************************************************************
form build_field_catalog.
data: fc_tmp type slis_fieldcat_alv.
clear fieldcat. refresh fieldcat.
<b> clear fc_tmp.
fc_tmp-reptext_ddic = 'Material Number'.
fc_tmp-fieldname = 'MATNR'.
fc_tmp-tabname = 'IMARA'.
fc_tmp-outputlen = '18'.
fc_tmp-col_pos = 2.
append fc_tmp to fieldcat.
clear fc_tmp.
fc_tmp-reptext_ddic = 'Material'.
fc_tmp-fieldname = 'MAKTX'.
fc_tmp-tabname = 'IMARA'.
fc_tmp-outputlen = '40'.
fc_tmp-col_pos = 3.
append fc_tmp to fieldcat.</b>
endform.
Regards,
Rich Heilman
09-26-2006 7:30 PM
Hi
Pass in the internal table name to the FM and manipulate the values in the structure using the texts.
FORM fieldcat_build.
DATA: l_count(2),l_field(8),l_text(8).
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
i_program_name = w_repid
i_structure_name = 'TRDIR'
i_internal_tabname = 'IT_TAB'
i_inclname = w_repid
CHANGING
ct_fieldcat = i_fieldcat_alv .
Modify displayed fields
LOOP AT i_fieldcat_alv INTO w_fieldcat_alv.
CASE w_fieldcat_alv-fieldname.
WHEN 'BELNR'.
w_fieldcat_alv-hotspot = 'X'.
WHEN 'STATUS'.
w_fieldcat_alv-seltext_m = text-td1.
w_fieldcat_alv-seltext_l = text-td1.
w_fieldcat_alv-seltext_s = text-td1.
w_fieldcat_alv-reptext_ddic = text-td1.
WHEN 'STATUS_TEXT'.
w_fieldcat_alv-seltext_m = text-td2.
w_fieldcat_alv-seltext_l = text-td2.
w_fieldcat_alv-seltext_s = text-td2.
w_fieldcat_alv-reptext_ddic = text-td2.
WHEN OTHERS.
ENDCASE.
MODIFY i_fieldcat_alv FROM w_fieldcat_alv.
ENDLOOP.
ENDFORM. "fieldcat_build