Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

ALV Report

vallamuthu_madheswaran2
Active Contributor
0 Kudos

Hi friends,

I am using the below code now i want the result in ALV Grid. is it possible? please giv the solution.

DATA BEGIN OF itab_list OCCURS 0.

INCLUDE STRUCTURE abaplist.

DATA END OF itab_list.

DATA: BEGIN OF vlist OCCURS 0,

field1(1000) TYPE c,

END OF vlist.

SUBMIT rahafa01 EXPORTING LIST TO MEMORY VIA SELECTION-SCREEN AND RETURN.

CALL FUNCTION 'LIST_FROM_MEMORY'

TABLES

listobject = itab_list

EXCEPTIONS

not_found = 4

OTHERS = 8.

CALL FUNCTION 'LIST_TO_ASCI'

EXPORTING

list_index = -1

  • with_line_break = ' '

TABLES

listasci = vlist

listobject = itab_list

EXCEPTIONS

empty_list = 1

list_index_invalid = 2

OTHERS = 3.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

IF sy-subrc NE '0'.

WRITE:/ 'LIST_TO_ASCI error !! ', sy-subrc.

ELSE.

LOOP AT vlist.

WRITE:/ vlist-field1.

MOVE vlist-field1 TO i_main.

APPEND i_main.

ENDLOOP.

CLEAR vlist. REFRESH vlist.

WRITE: ' success '.

ENDIF.

Thanks & Regards,

Vallamuthu.M

3 REPLIES 3

Former Member
0 Kudos

Hi

you can not get the result in ALV grid or ALV list. If you want to disply any data using ALV, you need use ALV function modules. then only it is possible. Otherwise you have to design the gird by writing the code. It will take hell lot of days to write it.

So take what ever data you want to disply as report in one internal table. pass this internal table to standard ALV grid function modul REUSE_ALV_GRID_DISPLY. then it will display as you like. But u need to take care more things to use this function module like field catologs and all.

Please check with small example and reward if it dose.

Thanks

Siva Kumar

TYPE-POOLS: slis.

TABLES: mara.

TYPES: BEGIN OF tp_mara,

matnr LIKE mara-matnr,

ersda LIKE mara-ersda,

ernam LIKE mara-ernam,

laeda LIKE mara-laeda,

aenam LIKE mara-aenam,

END OF tp_mara.

DATA: tbl_mara TYPE tp_mara OCCURS 0 WITH HEADER LINE,

tbl_fieldcat TYPE slis_t_fieldcat_alv.

DATA: wa_fieldcat TYPE slis_fieldcat_alv.

DATA: w_repid LIKE sy-repid,

w_pos TYPE i VALUE 1.

DATA: l_t_events TYPE slis_t_event,

l_f_layout TYPE slis_layout_alv.

  • Initialization fieldcatalog

INITIALIZATION.

w_repid = sy-repid.

PERFORM fill_layout CHANGING

l_f_layout.

PERFORM fill_events CHANGING

l_t_events.

PERFORM fieldcat_init USING tbl_fieldcat[].

  • Data selection

START-OF-SELECTION.

PERFORM select_data.

  • Display list

END-OF-SELECTION.

CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

  • CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = w_repid

IS_LAYOUT = l_f_layout

it_fieldcat = tbl_fieldcat[]

IT_EVENTS = l_t_events[]

TABLES

t_outtab = tbl_mara[].

&----


*& Form FIELDCAT_INIT

&----


  • text

----


  • -->P_GT_FIELDCAT[] text

----


FORM fieldcat_init USING p_tbl_fieldcat TYPE slis_t_fieldcat_alv.

CLEAR wa_fieldcat.

wa_fieldcat-col_pos = w_pos.

wa_fieldcat-fieldname = 'MATNR'.

wa_fieldcat-ref_fieldname = 'MATNR'.

wa_fieldcat-ref_tabname = 'MARA'.

wa_fieldcat-key = 'X'.

APPEND wa_fieldcat TO p_tbl_fieldcat.

CLEAR wa_fieldcat.

w_pos = w_pos + 1.

wa_fieldcat-col_pos = w_pos.

wa_fieldcat-fieldname = 'ERSDA'.

wa_fieldcat-ref_fieldname = 'ERSDA'.

wa_fieldcat-ref_tabname = 'MARA'.

APPEND wa_fieldcat TO p_tbl_fieldcat.

CLEAR wa_fieldcat.

w_pos = w_pos + 1.

wa_fieldcat-col_pos = w_pos.

wa_fieldcat-fieldname = 'ERNAM'.

wa_fieldcat-ref_fieldname = 'ERNAM'.

wa_fieldcat-ref_tabname = 'MARA'.

APPEND wa_fieldcat TO p_tbl_fieldcat.

CLEAR wa_fieldcat.

w_pos = w_pos + 1.

wa_fieldcat-col_pos = w_pos.

wa_fieldcat-fieldname = 'LAEDA'.

wa_fieldcat-ref_fieldname = 'LAEDA'.

wa_fieldcat-ref_tabname = 'MARA'.

APPEND wa_fieldcat TO p_tbl_fieldcat.

CLEAR wa_fieldcat.

w_pos = w_pos + 1.

wa_fieldcat-col_pos = w_pos.

wa_fieldcat-fieldname = 'AENAM'.

wa_fieldcat-ref_fieldname = 'AENAM'.

wa_fieldcat-ref_tabname = 'MARA'.

APPEND wa_fieldcat TO p_tbl_fieldcat.

ENDFORM. " FIELDCAT_INIT

&----


*& Form SELECT_DATA

&----


  • text

----


  • -->P_TBL_MARA text

----


FORM select_data.

SELECT matnr

ersda

ernam

laeda

aenam FROM mara INTO TABLE tbl_mara

WHERE matkl EQ '10171702'.

ENDFORM. " SELECT_DATA

&----


*& Form fill_events

&----


  • text

----


  • <--P_L_T_EVENTS text

----


FORM fill_events CHANGING c_t_events TYPE slis_t_event.

DATA: l_f_events LIKE LINE OF c_t_events.

l_f_events-name = 'TOP_OF_PAGE'.

l_f_events-form = 'TOP_OF_PAGE'.

APPEND l_f_events TO c_t_events.

ENDFORM. " fill_events

----


  • FORM TOP_OF_PAGE *

----


  • CallBack Routine for TOP-OF-PAGE event *

----


FORM top_of_page.

DATA: l_title LIKE sy-title.

*--- Get Report Title if available

*--- Display title and general information

NEW-LINE NO-SCROLLING.

WRITE: 10 'SAMPLE PROGRAM'. "text-003.

NEW-LINE NO-SCROLLING.

WRITE: 01 sy-datum,

13 sy-uzeit,

23 sy-title,

75 sy-pagno.

NEW-LINE SCROLLING.

ENDFORM. " TOP_OF_PAGE

&----


*& Form FILL_LAYOUT

&----


  • Define List Layout *

----


  • --> C_F_LAYOUT *

----


FORM fill_layout CHANGING c_f_layout TYPE slis_layout_alv.

CALL FUNCTION 'FM_ALV_LAYOUT'

CHANGING

c_f_layout = c_f_layout.

Former Member
0 Kudos

hi

good

go through this link,hope this will give you clear idea about the ALV GRID.

http://www.erpgenie.com/abap/controls/alvgrid.htm

thanks

mrutyun^

vallamuthu_madheswaran2
Active Contributor
0 Kudos

solved my self