2008 Aug 06 11:21 AM
is it possible to create alv grid dynamically.
the number of grids to be created is based on the value in selection screen.
2008 Aug 06 11:33 AM
Hi Reshma.
I would like to suggest a reference,
[SDN Wiki Code Gallery - Standard Reference for Code Snippet for Dynamic Alv grid|https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/tutorial%2babap%2b-%2bcode%2bfor%2bdynamic%2balv%2bgrid]
Hope that's usefull.
Good Luck & Regards.
Harsh Dave
is it possible to create alv grid dynamically.
the number of grids to be created is based on the value in selection screen.
2008 Aug 06 11:25 AM
it is possible to create a dynamic grid display....search in sdn
look at the program for multiple alvs on one page...BALVBT01
2008 Aug 06 11:26 AM
Here is an example of dynamic ALV:
REPORT z_alv_dynamic_data.
TABLES::
dd02l, " SAP tables
dd03l. " Table Fields
TYPE-POOLS: slis. " ALV Global Types
SELECTION-SCREEN :
BEGIN OF LINE COMMENT 1(35) v_1 FOR FIELD p_table. "#EC NEEDED
PARAMETERS p_table LIKE dd03l-tabname OBLIGATORY MEMORY ID dtb.
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN :
BEGIN OF LINE COMMENT 1(35) v_2 FOR FIELD p_max. "#EC NEEDED
PARAMETERS p_max(2) TYPE n DEFAULT '20' OBLIGATORY.
SELECTION-SCREEN END OF LINE.
----
AT SELECTION-SCREEN.
SELECT SINGLE * FROM dd02l WHERE tabname = p_table
AND as4local = 'A'
AND as4vers = '0000'.
IF SY-SUBRC NE 0.
Table & is not active in the Dictionary
MESSAGE e402(mo) WITH p_table.
ELSEIF dd02l-tabclass = 'INTTAB'.
& is a structure, not a table
MESSAGE e403(mo) WITH p_table.
ENDIF.
----
INITIALIZATION.
v_1 = 'Table'.
v_2 = 'Maximum of records'.
----
START-OF-SELECTION.
PERFORM f_display_data.
----
Form F_DISPLAY_DATA
----
FORM f_display_data.
Macro definition
DEFINE m_sort.
ADD 1 TO ls_sort-spos.
ls_sort-fieldname = &1.
ls_sort-up = 'X'.
APPEND ls_sort TO lt_sort.
END-OF-DEFINITION.
DATA::
l_long TYPE i,
lp_struct TYPE REF TO DATA,
lp_table TYPE REF TO DATA, " Pointer to dynamic table
of_sdescr TYPE REF TO cl_abap_structdescr,
ls_lvc_cat TYPE lvc_s_fcat,
lt_lvc_cat TYPE lvc_t_fcat, " Field catalog
ls_fieldcat TYPE slis_fieldcat_alv,
lt_fieldcat TYPE slis_t_fieldcat_alv, " Field catalog
ls_layout TYPE slis_layout_alv,
lt_sort TYPE slis_t_sortinfo_alv, " Sort table
ls_sort TYPE slis_sortinfo_alv.
FIELD-SYMBOLS:
<fieldcat> TYPE slis_fieldcat_alv,
<lt_data> TYPE TABLE, " Data to display
<fs> TYPE ANY,
<components> TYPE abap_compdescr.
Dynamic creation of a structure
CREATE DATA lp_struct TYPE (p_table).
ASSIGN lp_struct->* TO <fs>.
Fields Structure
of_sdescr ?= cl_abap_typedescr=>describe_by_data( <fs> ).
LOOP AT of_sdescr->components ASSIGNING <components>.
Field MANDT not displayed
IF SY-TABIX = 1 AND <components>-name = 'MANDT'.
CONTINUE. " Next loop
ENDIF.
Build Fieldcatalog
ls_lvc_cat-fieldname = <components>-name.
ls_lvc_cat-ref_table = p_table.
APPEND ls_lvc_cat TO lt_lvc_cat.
Build Fieldcatalog
ls_fieldcat-fieldname = <components>-name.
ls_fieldcat-ref_tabname = p_table.
APPEND ls_fieldcat TO lt_fieldcat.
ENDLOOP.
Create internal table
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING it_fieldcatalog = lt_lvc_cat
IMPORTING ep_table = lp_table.
ASSIGN lp_table->* TO <lt_data>.
Read data
SELECT * FROM (p_table) UP TO p_max ROWS
INTO CORRESPONDING FIELDS OF TABLE <lt_data>
ORDER BY PRIMARY KEY.
IF <lt_data>[] IS INITIAL.
No table entries found for specified key
MESSAGE i429(mo).
EXIT.
ENDIF.
Read key field to Build Sort Table
SELECT * FROM dd03l WHERE tabname = p_table
AND fieldname <> '.INCLUDE'
AND as4vers = '0000'
AND as4local = 'A'
ORDER BY position.
READ TABLE lt_fieldcat ASSIGNING <fieldcat>
WITH KEY fieldname = dd03l-fieldname.
CHECK SY-SUBRC EQ 0.
ADD dd03l-leng TO l_long.
IF dd03l-keyflag = 'X'.
Build Sort Table
m_sort dd03l-fieldname.
<fieldcat>-key = 'X'.
ELSEIF l_long > 150.
<fieldcat>-tech = 'X'.
ENDIF.
ENDSELECT.
ls_layout-zebra = 'X'.
ls_layout-colwidth_optimize = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
is_layout = ls_layout
it_fieldcat = lt_fieldcat
it_sort = lt_sort
TABLES
t_outtab = <lt_data>.
ENDFORM. " F_DISPLAY_DATA
END OF PROGRAM Z_ALV_DYNAMIC_DATA *********************
2008 Aug 06 11:26 AM
You can use Splitter container and you can dynamically pass the count and split the container into parts.
After that you need to assign or create the grids using the parts which you created using splitter container.
2008 Aug 06 11:29 AM
2008 Aug 06 11:33 AM
Hi Reshma.
I would like to suggest a reference,
[SDN Wiki Code Gallery - Standard Reference for Code Snippet for Dynamic Alv grid|https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/tutorial%2babap%2b-%2bcode%2bfor%2bdynamic%2balv%2bgrid]
Hope that's usefull.
Good Luck & Regards.
Harsh Dave
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |