Application Development and Automation 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: 
Read only

ALV Display

Former Member
0 Likes
1,262

HI Experts,

I have Types (OUTREC) and in that i have data that i fetched from DB tables.

I have defined OUTREC as

DATA: BEGIN OF OUTREC,

BUKRS LIKE BKPF-BUKRS,

BELNR LIKE BKPF-BELNR,

DMBTR(16) TYPE C,

MWSKZ LIKE BSEG-MWSKZ,

MWSTS(16) TYPE C,

END OF OUTREC.

I need to display the result in ALV Grid format. below are my fields.

WRITE: / OUTREC-BUKRS,

OUTREC-BELNR,

OUTREC-DMBTR,

OUTREC-MWSKZ,

OUTREC-MWSTS.

Ple help me. Urgent.

Thanks

Khan

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,208

DATA : t_field TYPE lvc_t_fcat,

t_layout TYPE lvc_s_layo,

wa_field TYPE lvc_s_fcat.

wa_field-fieldname = 'BUKRS'.

wa_field-reptext = 'Com Code'.

wa_field-outputlen = '7'.

APPEND wa_field TO t_field.

CLEAR wa_field.

wa_field-fieldname = 'BELNR'.

wa_field-reptext = 'Doc Numbr'.

wa_field-outputlen = '12'.

APPEND wa_field TO t_field.

CLEAR wa_field.

-


-


t_layout-zbera = 'X'.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'

EXPORTING

is_layout_lvc = t_layout

it_fieldcat_lvc = t_field

i_save = 'X'

TABLES

t_outtab = OUTREC[]

EXCEPTIONS

program_error = 1

OTHERS = 2.

OR

type : BEGIN OF OUTREC,

BUKRS LIKE BKPF-BUKRS,

BELNR LIKE BKPF-BELNR,

DMBTR(16) TYPE C,

MWSKZ LIKE BSEG-MWSKZ,

MWSTS(16) TYPE C,

END OF OUTREC.

data : itab type OUTREC occurs 0.

Just Pass the itab

data: gr_table type ref to cl_salv_table.

call method cl_salv_table=>factory

importing

r_salv_table = gr_table

changing

t_table = itab .

gr_table->display( ).

Thanks,

Durai.V

Edited by: Durai V on Jul 11, 2008 12:19 PM

DATA : t_field TYPE lvc_t_fcat,

t_layout TYPE lvc_s_layo,

wa_field TYPE lvc_s_fcat.

wa_field-fieldname = 'BUKRS'.

wa_field-reptext = 'Com Code'.

wa_field-outputlen = '7'.

APPEND wa_field TO t_field.

CLEAR wa_field.

wa_field-fieldname = 'BELNR'.

wa_field-reptext = 'Doc Numbr'.

wa_field-outputlen = '12'.

APPEND wa_field TO t_field.

CLEAR wa_field.

-


-


t_layout-zbera = 'X'.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'

EXPORTING

is_layout_lvc = t_layout

it_fieldcat_lvc = t_field

i_save = 'X'

TABLES

t_outtab = OUTREC[]

EXCEPTIONS

program_error = 1

OTHERS = 2.

OR

type : BEGIN OF OUTREC,

BUKRS LIKE BKPF-BUKRS,

BELNR LIKE BKPF-BELNR,

DMBTR(16) TYPE C,

MWSKZ LIKE BSEG-MWSKZ,

MWSTS(16) TYPE C,

END OF OUTREC.

data : itab type OUTREC occurs 0.

Just Pass the itab

data: gr_table type ref to cl_salv_table.

call method cl_salv_table=>factory

importing

r_salv_table = gr_table

changing

t_table = itab .

gr_table->display( ).

Thanks,

Durai.V

Edited by: Durai V on Jul 11, 2008 12:19 PM

8 REPLIES 8
Read only

Former Member
0 Likes
1,208

HI,

goto SLIS package --program

there u can get demo for all types of ALV.

Hope it will helpful..

Edited by: prabhu p on Jul 11, 2008 12:01 PM

Read only

Former Member
0 Likes
1,209

DATA : t_field TYPE lvc_t_fcat,

t_layout TYPE lvc_s_layo,

wa_field TYPE lvc_s_fcat.

wa_field-fieldname = 'BUKRS'.

wa_field-reptext = 'Com Code'.

wa_field-outputlen = '7'.

APPEND wa_field TO t_field.

CLEAR wa_field.

wa_field-fieldname = 'BELNR'.

wa_field-reptext = 'Doc Numbr'.

wa_field-outputlen = '12'.

APPEND wa_field TO t_field.

CLEAR wa_field.

-


-


t_layout-zbera = 'X'.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'

EXPORTING

is_layout_lvc = t_layout

it_fieldcat_lvc = t_field

i_save = 'X'

TABLES

t_outtab = OUTREC[]

EXCEPTIONS

program_error = 1

OTHERS = 2.

OR

type : BEGIN OF OUTREC,

BUKRS LIKE BKPF-BUKRS,

BELNR LIKE BKPF-BELNR,

DMBTR(16) TYPE C,

MWSKZ LIKE BSEG-MWSKZ,

MWSTS(16) TYPE C,

END OF OUTREC.

data : itab type OUTREC occurs 0.

Just Pass the itab

data: gr_table type ref to cl_salv_table.

call method cl_salv_table=>factory

importing

r_salv_table = gr_table

changing

t_table = itab .

gr_table->display( ).

Thanks,

Durai.V

Edited by: Durai V on Jul 11, 2008 12:19 PM

Read only

0 Likes
1,208

HI Durai, I have applied ur first approach as

******************************************

DATA : t_field TYPE lvc_t_fcat,

t_layout TYPE lvc_s_layo,

wa_field TYPE lvc_s_fcat.

wa_field-fieldname = 'BUKRS'.

wa_field-reptext = 'Com Code'.

wa_field-outputlen = '7'.

APPEND wa_field TO t_field.

CLEAR wa_field.

wa_field-fieldname = 'BELNR'.

wa_field-reptext = 'Doc Numbr'.

wa_field-outputlen = '12'.

APPEND wa_field TO t_field.

CLEAR wa_field.

-


-


t_layout-zbera = 'X'.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'

EXPORTING

is_layout_lvc = t_layout

it_fieldcat_lvc = t_field

i_save = 'X'

TABLES

t_outtab = OUTREC[]

EXCEPTIONS

program_error = 1

OTHERS = 2.

**************************************

But on syntex check, it says that Outrec is not internal table. Occurs n specification is missing.

What I can do in that. I dont want to change the OUTREC decleration.

Plz help.

Thanks.

Khan

Read only

0 Likes
1,208

Hi

DATA: BEGIN OF OUTREC occurs 0,

BUKRS LIKE BKPF-BUKRS,

BELNR LIKE BKPF-BELNR,

DMBTR(16) TYPE C,

MWSKZ LIKE BSEG-MWSKZ,

MWSTS(16) TYPE C,

END OF OUTREC.

ADD occurs 0

Thanks,

Durai.V

Read only

Former Member
0 Likes
1,208

Hi,

TABLES:

***********************************************************************

************************************************************************

DECLARATION OF TYPE-POOL

*THIS TYPE-POOL CONTAINS THE EVENTS,

************************************************************************

TYPE-POOLS : slis.

************************************************************************

DECLARATION OF EVENTS

************************************************************************

DATA: i_event TYPE slis_t_event.

DATA: t_event TYPE slis_alv_event.

************************************************************************

DECLARATION OF LIST HEADER

************************************************************************

DATA: i_listheader TYPE slis_t_listheader.

************************************************************************

DECLARATION OF FIELD CATALOG FOR SCREEN 1

************************************************************************

DATA: i_fldcat TYPE slis_t_fieldcat_alv WITH HEADER LINE.

************************************************************************

DECLARATION OF FIELD CATALOG FOR SCREEN 2

************************************************************************

DECLARATION OF FIELD LAYOUT

************************************************************************

DATA: i_layout TYPE slis_layout_alv.

************************************************************************

SORTING OF OUTPUT

************************************************************************

DATA: i_sort TYPE slis_t_sortinfo_alv.

DATA: t_list_top_of_page TYPE slis_t_listheader.

DATA: BEGIN OF OUTREC,

BUKRS LIKE BKPF-BUKRS,

BELNR LIKE BKPF-BELNR,

DMBTR(16) TYPE C,

MWSKZ LIKE BSEG-MWSKZ,

MWSTS(16) TYPE C,

END OF OUTREC.

Start-of-selection.

perform dataselect.

perform fieldcatlog.

perform display.

FORM fld_cat USING p_i_fldcat TYPE slis_t_fieldcat_alv.

CLEAR i_fldcat.

i_fldcat-fieldname = 'BUKRS'. "FIELD FOR WHICH CATALOG ID FILLED

i_fldcat-tabname = 'IT_BKPF'."TABLE NAME

i_fldcat-seltext_m = 'Ccod'.

i_fldcat-col_pos = 1. " POSITION OF THE COLUMN.

i_fldcat-outputlen = 5. " SET THE OUTPUT LENGTH.

  • i_fldcat-emphasize = 'X'. " COLOR OF THIS COLUMN.

  • i_fldcat-key = 'X'. " SO THAT THIS FIELD IS NOT

  • "SCROLLABLE AND HIDDABLE.

i_fldcat-just(1) = 'L'.

APPEND i_fldcat.

CLEAR i_fldcat.

i_fldcat-fieldname = 'BELNR'. "FIELD FOR WHICH CATALOG ID FILLED

i_fldcat-tabname = 'IT_BKPF'."TABLE NAME

i_fldcat-seltext_m = 'Doc.No'.

i_fldcat-col_pos = 2. " POSITION OF THE COLUMN.

i_fldcat-outputlen = 10. " SET THE OUTPUT LENGTH.

  • i_fldcat-emphasize = 'X'. " COLOR OF THIS COLUMN.

  • i_fldcat-key = 'X'. " SO THAT THIS FIELD IS NOT

  • "SCROLLABLE AND HIDDABLE.

i_fldcat-just(1) = 'L'.

APPEND i_fldcat.

CLEAR i_fldcat.

i_fldcat-fieldname = 'DMBTR'. "FIELD FOR WHICH CATALOG ID FILLED

i_fldcat-tabname = 'IT_BKPF'.

i_fldcat-seltext_m = 'Vendor'.

i_fldcat-col_pos = 3. " POSITION OF THE COLUMN.

i_fldcat-outputlen = 10. " SET THE OUTPUT LENGTH.

  • i_fldcat-emphasize = 'X'. read table VBRP'.

  • i_fldcat-just(1) = 'L'.

APPEND i_fldcat.

FORM fld_cat USING p_i_fldcat TYPE slis_t_fieldcat_alv.

CLEAR i_fldcat.

i_fldcat-fieldname = 'MWSKZ'. "FIELD FOR WHICH CATALOG ID FILLED

i_fldcat-tabname = 'IT_BKPF'."TABLE NAME

i_fldcat-seltext_m = 'Ccod'.

i_fldcat-col_pos = 1. " POSITION OF THE COLUMN.

i_fldcat-outputlen = 5. " SET THE OUTPUT LENGTH.

  • i_fldcat-emphasize = 'X'. " COLOR OF THIS COLUMN.

  • i_fldcat-key = 'X'. " SO THAT THIS FIELD IS NOT

  • "SCROLLABLE AND HIDDABLE.

i_fldcat-just(1) = 'L'.

APPEND i_fldcat.

CLEAR i_fldcat.

i_fldcat-fieldname = 'MWSTS'. "FIELD FOR WHICH CATALOG ID FILLED

i_fldcat-tabname = 'IT_BKPF'."TABLE NAME

i_fldcat-seltext_m = 'Doc.No'.

i_fldcat-col_pos = 2. " POSITION OF THE COLUMN.

i_fldcat-outputlen = 10. " SET THE OUTPUT LENGTH.

  • i_fldcat-emphasize = 'X'. " COLOR OF THIS COLUMN.

  • i_fldcat-key = 'X'. " SO THAT THIS FIELD IS NOT

  • "SCROLLABLE AND HIDDABLE.

i_fldcat-just(1) = 'L'.

APPEND i_fldcat.

FORM call_alv .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

i_callback_program = sy-repid

  • I_CALLBACK_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

i_grid_title = 'TRANSACTION REPORT for Non SAP non Auto'

  • I_GRID_SETTINGS =

is_layout = i_layout

it_fieldcat = i_fldcat[]

  • IT_SORT =

it_events = i_event[]

TABLES

t_outtab = it_bkpf

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

  • OTHERS = 2

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDFORM. " CALL_ALV

Thanks & Regards,

Y.R.Prem Kumar

Read only

Former Member
0 Likes
1,208

HI check this.

report .

type-pools:slis.

data: it_fieldcat type slis_t_fieldcat_alv,

is_layout type slis_layout_alv,

wa_fieldcat type slIS_fieldcat_alv.

DATA: BEGIN OF OUTREC1,

BUKRS LIKE BKPF-BUKRS,

BELNR LIKE BKPF-BELNR,

DMBTR(16) TYPE C,

MWSKZ LIKE BSEG-MWSKZ,

MWSTS(16) TYPE C,

END OF OUTREC1.

DATA: OUTREC LIKE OUTREC1 OCCURS 0 WITH HEADER LINE .

outrec-BUKRS = '1000'.

outrec-belnr = '00000001'.

outrec-dmbtr = 'test'.

outrec-mwskz = 'test'.

outrec-mwsts = '0032'.

append outrec.

outrec-BUKRS = '1001'.

outrec-belnr = '00000002'.

outrec-dmbtr = 'test'.

outrec-mwskz = 'test'.

outrec-mwsts = '0032'.

append outrec.

outrec-BUKRS = '1002'.

outrec-belnr = '00000003'.

outrec-dmbtr = 'test'.

outrec-mwskz = 'test'.

outrec-mwsts = '0032'.

append outrec.

wa_fieldcat-fieldname = 'BUKRS'.

wa_fieldcat-reptext_ddic = 'COMP'.

append wa_fieldcat to it_fieldcat.

wa_fieldcat-fieldname = 'BELNR'.

wa_fieldcat-reptext_ddic = 'NUMBER'.

append wa_fieldcat to it_fieldcat.

wa_fieldcat-fieldname = 'DMBTR'.

wa_fieldcat-reptext_ddic = 'TEST'.

append wa_fieldcat to it_fieldcat.

wa_fieldcat-fieldname = 'MWSKZ'.

wa_fieldcat-reptext_ddic = 'TEST'.

append wa_fieldcat to it_fieldcat.

wa_fieldcat-fieldname = 'MWSTS'.

wa_fieldcat-reptext_ddic = 'TEST'.

append wa_fieldcat to it_fieldcat.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

IS_LAYOUT = IS_LAYOUT

IT_FIELDCAT = IT_FIELDCAT

TABLES

t_outtab = OUTREC .

Read only

Former Member
0 Likes
1,208

hi,

after writing down your query ( dumping data into outrec)

you can use these function module,

TYPE-POOLS:slis.

DATA : I_FIELDCAT TYPE slis_t_fieldcat_alv .

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

EXPORTING

I_PROGRAM_NAME = 'ZPROGRAM_NAME' < YOUR REPORT NAME >

I_INTERNAL_TABNAME = 'OUTREC'

I_INCLNAME = sy-repid

CHANGING

ct_fieldcat = I_FIELDCAT.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

I_CALLBACK_PROGRAM = 'ZPROGRAM_NAME' < NAME OF YOUR REPORT>

IT_FIELDCAT = I_FIELDCAT

TABLES

t_outtab = OUTREC.