Welcome To My BLOG

This site is to give a brief idea for the abap learners who are looking for some real time programs .It consists of collection of programs from my side . I hope these programs are very much used for all of the learners. Please check the links for any information in ABAP.
Please vote for my Blog. And please input me on this mail addrssess.Email me

Share this link with your friends

http://www.rebtel.com/u/15163104576

For every friend who signs up using this link and makes a payment, we'll give you 8 €!


Wednesday, September 22, 2010

Dynamic Alv grid

REPORT zdynamic_alv_sample.

TYPE-POOLS : abap.

FIELD-SYMBOLS: TYPE STANDARD TABLE,
,
.

DATA: it_table TYPE REF TO data,
it_line TYPE REF TO data,
xfc TYPE lvc_s_fcat,
ifc TYPE lvc_t_fcat.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
PARAMETERS: p_table(30) TYPE c DEFAULT 'T001'.
SELECTION-SCREEN END OF BLOCK b1.

START-OF-SELECTION.

PERFORM get_structure.
PERFORM create_dynamic_itab.
PERFORM get_data.
PERFORM write_out.


*&---------------------------------------------------------------------*
*& Form get_structure
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM get_structure.

DATA : idetails TYPE abap_compdescr_tab,
xdetails TYPE abap_compdescr.

DATA : ref_table_des TYPE REF TO cl_abap_structdescr.

* Get the structure of the table.
ref_table_des ?=
cl_abap_typedescr=>describe_by_name( p_table ).
idetails[] = ref_table_des->components[].

LOOP AT idetails INTO xdetails.
CLEAR xfc.
xfc-fieldname = xdetails-name .
xfc-datatype = xdetails-type_kind.
xfc-inttype = xdetails-type_kind.
xfc-intlen = xdetails-length.
xfc-decimals = xdetails-decimals.
APPEND xfc TO ifc.
ENDLOOP.

ENDFORM. "get_structure

*&---------------------------------------------------------------------*
*& Form create_dynamic_itab
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM create_dynamic_itab.

* Create dynamic internal table and assign to FS
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = ifc
IMPORTING
ep_table = it_table.

ASSIGN it_table->* TO .

* Create dynamic work area and assign to FS
CREATE DATA it_line LIKE LINE OF .
ASSIGN it_line->* TO .

ENDFORM. "create_dynamic_itab



*&---------------------------------------------------------------------*
*& Form get_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM get_data.

* Select Data from table.
SELECT * INTO TABLE
FROM (p_table).

ENDFORM. "get_data

*&---------------------------------------------------------------------*
*& Form write_out
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM write_out.
* Print data from table.
call function 'reuse_alv_grid_display'.
*pass as internal table to the function **

ENDFORM. "write_out

No comments: