2013 Feb 08 6:19 AM
Hi All,
I am working on a scenario where I have to display data(say materials) horizontally. So the columns in the ALV grid will be decided at run time.
Please find the pseudo code below.
Step1: Creating Field catalog
DO lf_line TIMES.
CONCATENATE 'MATNR' lf_count INTO lv_fieldname.
CONDENSE lv_fieldname NO-GAPS.
ls_fcat-fieldname = lv_fieldname.
ls_fcat-seltext = lv_fieldname.
ls_fcat-datatype = 'CHAR'.
ls_fcat-outputlen = 30.
ls_fcat-col_pos = sy-index.
lf_count = lf_count + 1.
APPEND ls_fcat TO gt_fldcat1.
ENDDO.
Step2: Creating data table dynamically
I am using cl_alv_table_create=>create_dynamic_table to get the ref of the table.
Then I am creating table using field symbols and populating the table <fs_table>.
Step3: Display the ALV grid
I am using the below code
CALL METHOD z_grid2->set_table_for_first_display
EXPORTING
is_variant = gs_variant
is_layout = ls_layout
CHANGING
it_outtab = <fs_table>
it_fieldcatalog = gt_fldcat1.
The above code is not working for me. Is there anything I am doing wrong here.
The same code works if I am passing ls_fcat-fieldname = 'MATNR' . But this will be correct only if there is one column.
For that reason I need to concatenate and assign to filedname.
Thanks,
Vijetha.
2013 Feb 08 7:09 AM
Does <fs_table> look the way you expected it to look? Also, not sure if this is going to make any difference, but does the ALV class give you the same issues? It's not dependent on the field catalogue, just accepts whatever table you throw at it.
DATA alv TYPE REF TO cl_salv_table.
TRY.
cl_salv_table=>factory(
IMPORTING
r_salv_table = alv
CHANGING
t_table = <fs_table> ).
CATCH cx_salv_msg. "#EC NO_HANDLER
ENDTRY.
alv->display( ).
2013 Feb 08 7:09 AM
Does <fs_table> look the way you expected it to look? Also, not sure if this is going to make any difference, but does the ALV class give you the same issues? It's not dependent on the field catalogue, just accepts whatever table you throw at it.
DATA alv TYPE REF TO cl_salv_table.
TRY.
cl_salv_table=>factory(
IMPORTING
r_salv_table = alv
CHANGING
t_table = <fs_table> ).
CATCH cx_salv_msg. "#EC NO_HANDLER
ENDTRY.
alv->display( ).
2013 Feb 08 8:50 AM
Hello,
I was able to solve the issue using CL_SALV_TABEL.
DATA alv TYPE REF TO cl_salv_table.
TRY.
cl_salv_table=>factory(
EXPORTING
r_container = z_cont_head "Splitter container ref
IMPORTING
r_salv_table = alv
CHANGING
t_table = <fs_table> ).
CATCH cx_salv_msg. "#EC NO_HANDLER
ENDTRY.
alv->display( ).
Thanks,
Vijetha
2013 Feb 08 7:18 AM
2013 Feb 08 8:56 AM
Thanks for asking. I am able to populate the table.Gird is not showing any data and there is no exception raised.
Now I am able to populate it using CL_SALV_TABLE.
Regards,
Vijetha