05-20-2009 8:51 AM
Hi All,
I am creating a dynamic table using method cl_alv_table_create=>create_dynamic_table.
The normal structure gets created. but now I want to creat a Deep structure for having information of colors also for each column. So I want to add a COLTAB type LVC_T_SCOL for colors information .
How should I create this using above method?
Rgds,
Madhuri
05-20-2009 10:05 AM
Hi,
Creat two field cats one with all the dynamic fields Fcat_1 and other with all the dynamic fields with your deep strcu fcat_2
CLEAR wa_fieldcat.
wa_fieldcat-inttype = 'C'.
wa_fieldcat-outputlen = '10'.
wa_fieldcat-fieldname = 'T_CELLTAB'.
wa_fieldcat-ref_field = 'CELLTAB'.
wa_fieldcat-ref_table = 'ZCELLTAB'.
APPEND wa_fieldcat TO fcat_2.
CLEAR wa_fieldcat.
ZCELLTAB is table type of your deep strc
call the method create_dynamic_table with the fcat_2
DATA : wa_is_layout TYPE lvc_s_layo.
wa_is_layout-stylefname = 'T_CELLTAB'.
wa_is_layout-col_opt = 'X'.
and for to display using set_table_for_first_display use
Fact_1.
05-20-2009 8:59 AM
Hello Madhuri
All you need to know can be found at:
[Creating Flat and Complex Internal Tables Dynamically using RTTI|https://wiki.sdn.sap.com/wiki/display/Snippets/CreatingFlatandComplexInternalTablesDynamicallyusingRTTI]
The coding requires that your SAP basis release >= 6.20.
Regards
Uwe
05-20-2009 9:35 AM
Hi Uwe,
Thanks for the instant reply. I want to create this as interactive ALV. If user clicks on one of the record, its next details should get displayed in another ALV format. Will it be possible using this method?
Thanks once again,
Rgds,
MAdhuri
05-20-2009 10:05 AM
Hi,
Creat two field cats one with all the dynamic fields Fcat_1 and other with all the dynamic fields with your deep strcu fcat_2
CLEAR wa_fieldcat.
wa_fieldcat-inttype = 'C'.
wa_fieldcat-outputlen = '10'.
wa_fieldcat-fieldname = 'T_CELLTAB'.
wa_fieldcat-ref_field = 'CELLTAB'.
wa_fieldcat-ref_table = 'ZCELLTAB'.
APPEND wa_fieldcat TO fcat_2.
CLEAR wa_fieldcat.
ZCELLTAB is table type of your deep strc
call the method create_dynamic_table with the fcat_2
DATA : wa_is_layout TYPE lvc_s_layo.
wa_is_layout-stylefname = 'T_CELLTAB'.
wa_is_layout-col_opt = 'X'.
and for to display using set_table_for_first_display use
Fact_1.
05-20-2009 11:18 AM
Hi Sai,
Will you please explore this more?
I want to show the material characteristic values for which I am creating table dynamically. now I want to show those characteristics in red which are failing otherwise green (LVC_T_SCOL). So I want color table to be for each row. And after displaying this report, I need to have facility to double click on one particular record to go to the next level report which is the comparison of material batch results with its specifications .
Rgds,
Madhuri
Edited by: madhuri sonawane on May 20, 2009 3:51 PM
05-20-2009 1:27 PM
Madhuri,
I did the same but instead of color i made it editable depending on the condition in my dynamic ALV Report which we have used as interface to update database.
first Creat Structure ZCELLTAB with field name as CELLTAB and component type as LVC_T_SCOL
Then, create two filedcat (FCAT_1 and FCAT_2) with all the Dynamic fields and in only FACT_2 fieldcat add one more field ,
wa_fieldcat-inttype = 'C'.
wa_fieldcat-outputlen = '10'.
wa_fieldcat-fieldname = 'T_CELLTAB'.
wa_fieldcat-ref_field = 'CELLTAB'.
wa_fieldcat-ref_table = 'ZCELLTAB'.
APPEND wa_fieldcat TO FCAT_2.
CLEAR wa_fieldcat.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = FCAT_2
IMPORTING
ep_table = dyn_table
EXCEPTIONS
generate_subpool_dir_full = 1
OTHERS = 2.
ASSIGN dyn_table->* TO <it_600>.
Create dynamic work area and assign to Field Symbol
CREATE DATA dyn_line LIKE LINE OF <it_600> .
ASSIGN dyn_line->* TO <wa_600> .
*but to display with FCAT_1
CALL METHOD alv_grid_600->set_table_for_first_display
EXPORTING
is_layout = wa_is_layout
it_toolbar_excluding = it_exclude_300
CHANGING
it_outtab = <it_600>
it_fieldcatalog = FCAT_1.
and while filling the values in the into dynamci internal table
ASSIGN COMPONENT 'T_CELLTAB' OF STRUCTURE <wa_600> TO <t_celltab>.
CLEAR wa_celltab.
wa_celltab-FNAME = wa_material-matnr.
wa_celltab-COLOR-COL = 5 .
INSERT wa_celltab INTO TABLE <t_celltab>.
I hope u understood .
05-21-2009 12:24 PM
05-07-2010 4:56 AM
HI Sai,
I have similar situation where I want to disable or enable the cells based on condtion.
In your source code, how you are inserting the <t_celltab> values in to the dynamic field symbol table <it_100>.
Thanks,
Kumar.
05-07-2010 6:03 AM
Hi venn,
Using field symbols assign the field "T_CELLTAB" (Deep structure) of the dynamic internal table work area into a field symbols of type table of cell tab and insert the values in to cell tab as below.
Data : <t_celltab> type lvc_t_styl.
DATA :lt_celltab TYPE lvc_t_styl.
DATA wa_celltab TYPE LINE OF lvc_t_styl
*<wa_600> dynamic internal table work area.
ASSIGN COMPONENT 'T_CELLTAB' OF STRUCTURE <wa_600> TO <t_celltab>.
CLEAR wa_celltab.
wa_celltab-fieldname = name.
for disableu2026
wa_celltab-style = cl_gui_alv_grid=>mc_style_disabled.
For enable.
wa_celltab-style = cl_gui_alv_grid=>mc_style_enabled.
INSERT wa_celltab INTO TABLE <t_celltab>.
Regards,
Saikumar B
05-07-2010 3:10 PM
I created a zcelltab structure as below. But while creating dynamic internal table, I received the error with
'Type "ZCELLTAB" is unknown 68 ZCELLTAB-CELLTAB
Here is the code.
DATA: BEGIN OF ZCELLTAB,
CELLTAB LIKE LVC_S_STYL,
END OF ZCELLTAB.
FIELD-SYMBOLS <T_CELLTAB> TYPE LVC_T_STYL.
DATA : LT_CELLTAB TYPE LVC_T_STYL.
DATA: WA_CELLTAB TYPE LINE OF LVC_T_STYL.
DATA: GT_FCAT1 TYPE LVC_T_FCAT,
GW_FCAT1 TYPE LVC_S_FCAT,
GT_FCAT2 TYPE LVC_T_FCAT,
GW_FCAT2 TYPE LVC_S_FCAT.
After filling the FCAT1, I added the field in FCAT2 like below
GT_FCAT2[ ] = GT_FCAT1[ ].
G_TABIX = G_TABIX + 1.
GW_FCAT2-INTTYPE = 'C'.
MOVE G_TABIX TO GW_FCAT2-COL_POS.
GW_FCAT2-OUTPUTLEN = '10'.
GW_FCAT2-FIELDNAME = 'T_CELLTAB'.
GW_FCAT2-TABNAME = 'ZCELLTAB'.
GW_FCAT2-REF_FIELD = 'CELLTAB'.
GW_FCAT2-REF_TABLE = 'ZCELLTAB'.
APPEND GW_FCAT2 TO GT_FCAT2
CLEAR GW_FCAT2.
While calling the below method, the error with
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
IT_FIELDCATALOG = GT_FCAT2
IMPORTING
EP_TABLE = GT_REQ.
ASSIGN GT_REQ->* TO <F_TAB>.
CREATE DATA GWA_REQ LIKE LINE OF <F_TAB>.
ASSIGN GWA_REQ->* TO <F_WA>.
LOOP AT ITAB.
ASSIGN COMPONENT 'MATNR' OF STRUCTURE <F_WA> TO <F_VAL>
<F_VAL> = ITAB-MATNR.
IF ITAB-MATNR IS INITIAL.
ASSIGN COMPONENT 'T_CELLTAB' OF STRUCTURE <F_WA> TO <T_CELLTAB>
CLEAR WA_CELLTAB.
WA_CELLTAB-FIELDNAME = 'MATNR'.
WA_CELLTAB-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
INSERT WA_CELLTAB INTO TABLE <T_CELLTAB>.
ENDIF.
APPEND <F_WA> TO <F_TAB>
ENDLOOP.
CALL METHOD GR_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_CONSISTENCY_CHECK = G_CONSISTENCY_CHECK
IT_TOOLBAR_EXCLUDING = G_EXCLUDE
I_SAVE = G_SAVE
I_DEFAULT = 'X'
IS_LAYOUT = G_LAYOUT
CHANGING
IT_OUTTAB = <F_TAB>
IT_FIELDCATALOG = F_CAT1.
Please let me know where I was wrong.
Should I remove the T_CELLTAB as the field name is not mentioned in the structure 'ZCELLTAB'.
Thanks,
Kumar.
Edited by: venn e on May 7, 2010 4:10 PM
05-07-2010 3:11 PM
created a zcelltab structure as below. But while creating dynamic internal table, I received the error with
'Type "ZCELLTAB" is unknown 68 ZCELLTAB-CELLTAB
Here is the code.
DATA: BEGIN OF ZCELLTAB,
CELLTAB LIKE LVC_S_STYL,
END OF ZCELLTAB.
FIELD-SYMBOLS <T_CELLTAB> TYPE LVC_T_STYL.
DATA : LT_CELLTAB TYPE LVC_T_STYL.
DATA: WA_CELLTAB TYPE LINE OF LVC_T_STYL.
DATA: GT_FCAT1 TYPE LVC_T_FCAT,
GW_FCAT1 TYPE LVC_S_FCAT,
GT_FCAT2 TYPE LVC_T_FCAT,
GW_FCAT2 TYPE LVC_S_FCAT.
After filling the FCAT1, I added the field in FCAT2 like below
GT_FCAT2[ ] = GT_FCAT1[ ].
G_TABIX = G_TABIX + 1.
GW_FCAT2-INTTYPE = 'C'.
MOVE G_TABIX TO GW_FCAT2-COL_POS.
GW_FCAT2-OUTPUTLEN = '10'.
GW_FCAT2-FIELDNAME = 'T_CELLTAB'.
GW_FCAT2-TABNAME = 'ZCELLTAB'.
GW_FCAT2-REF_FIELD = 'CELLTAB'.
GW_FCAT2-REF_TABLE = 'ZCELLTAB'.
APPEND GW_FCAT2 TO GT_FCAT2
CLEAR GW_FCAT2.
While calling the below method, the error with
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
IT_FIELDCATALOG = GT_FCAT2
IMPORTING
EP_TABLE = GT_REQ.
ASSIGN GT_REQ->* TO <F_TAB>.
CREATE DATA GWA_REQ LIKE LINE OF <F_TAB>.
ASSIGN GWA_REQ->* TO <F_WA>.
LOOP AT ITAB.
ASSIGN COMPONENT 'MATNR' OF STRUCTURE <F_WA> TO <F_VAL>
<F_VAL> = ITAB-MATNR.
IF ITAB-MATNR IS INITIAL.
ASSIGN COMPONENT 'T_CELLTAB' OF STRUCTURE <F_WA> TO <T_CELLTAB>
CLEAR WA_CELLTAB.
WA_CELLTAB-FIELDNAME = 'MATNR'.
WA_CELLTAB-STYLE = CL_GUI_ALV_GRID=>MC_STYLE_DISABLED.
INSERT WA_CELLTAB INTO TABLE <T_CELLTAB>.
ENDIF.
APPEND <F_WA> TO <F_TAB>
ENDLOOP.
CALL METHOD GR_GRID->SET_TABLE_FOR_FIRST_DISPLAY
EXPORTING
I_CONSISTENCY_CHECK = G_CONSISTENCY_CHECK
IT_TOOLBAR_EXCLUDING = G_EXCLUDE
I_SAVE = G_SAVE
I_DEFAULT = 'X'
IS_LAYOUT = G_LAYOUT
CHANGING
IT_OUTTAB = <F_TAB>
IT_FIELDCATALOG = F_CAT1.
Please let me know where I was wrong.
Should I remove the T_CELLTAB as the field name is not mentioned in the structure 'ZCELLTAB'.
Thanks,
Kumar.
05-10-2010 6:43 AM
Hi,
Create a Table type with "ZCELLTAB" with field "CELLTAB" of type LVC_S_STYL in SE11.
Regards,
Saikumar