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

Displaying two different ALV Reports

Former Member
0 Likes
1,040

Hi,

I want to display 2 different ALV reports for the radio-buttons which i check.

It should be a report program not nodule -pool program.

Can anyone help me out?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,007

HI,

You can do as below:


if rad1 = 'X'.
"write select code 
"Build the fieldcatalog
"Display the output in alv.
elseif rad2 = 'X'.
"write select code 
"Build the fieldcatalog
"Display the output in alv.
endif.

Thanks,

Sriram Ponna.

10 REPLIES 10
Read only

Former Member
0 Likes
1,007

based on the radio button u build ur field catalagoue and u can display as well

Read only

0 Likes
1,007

Is it that field catalog should be of this type- slis_t_fieldcat_alv. Can u tell me what is the field name.?

Read only

Former Member
0 Likes
1,008

HI,

You can do as below:


if rad1 = 'X'.
"write select code 
"Build the fieldcatalog
"Display the output in alv.
elseif rad2 = 'X'.
"write select code 
"Build the fieldcatalog
"Display the output in alv.
endif.

Thanks,

Sriram Ponna.

Read only

S0025444845
Active Participant
0 Likes
1,007

hi,

you write your logic based on the radio butttons.

like if first radio button is selected.

do something.

and if second is selected.

do other thing.

regards,

Sudha

Read only

venkat_o
Active Contributor
0 Likes
1,007

Hi Poonam, On single output, do u want to see 2 different ALV outputs ? If am not wrong it is possible. Check the sample program and execute .it displays.


REPORT  zvenkat_blocked_alv.

**********************************************************************
* Declarations.
**********************************************************************
* Internal tables
DATA:
      i_0000 TYPE STANDARD TABLE OF pa0000,
      i_0001 TYPE STANDARD TABLE OF pa0001,
      i_0002 TYPE STANDARD TABLE OF pa0002,
      i_0008 TYPE STANDARD TABLE OF pa0008.
*&---------------------------------------------------------------------*
* ALV Declarations
*----------------------------------------------------------------------*
* Types Pools
TYPE-POOLS:
   slis.
* Types
TYPES:
   t_fieldcat         TYPE slis_fieldcat_alv,
   t_events           TYPE slis_alv_event,
   t_layout           TYPE slis_layout_alv.
* Workareas
DATA:
   w_fieldcat1        TYPE t_fieldcat,
   w_fieldcat2        TYPE t_fieldcat,
   w_fieldcat3        TYPE t_fieldcat,
   w_fieldcat4        TYPE t_fieldcat,
   w_events           TYPE t_events,
   w_layout           TYPE t_layout.
* Internal Tables
DATA:
   i_fieldcat1         TYPE STANDARD TABLE OF t_fieldcat,
   i_fieldcat2         TYPE STANDARD TABLE OF t_fieldcat,
   i_fieldcat3         TYPE STANDARD TABLE OF t_fieldcat,
   i_fieldcat4         TYPE STANDARD TABLE OF t_fieldcat,
   i_events            TYPE STANDARD TABLE OF t_events.

**********************************************************************
* start-of-selection.
**********************************************************************
START-OF-SELECTION.
  PERFORM get_data.

**********************************************************************
* end-of-selection.
**********************************************************************
END-OF-SELECTION.
  PERFORM display_data.
**********************************************************************
* FORM    :  get_data
***********************************************************************
FORM get_data.

  SELECT *
  FROM pa0000
  INTO TABLE i_0000 UP TO 10 ROWS.

  SELECT *
    FROM pa0001
    INTO TABLE i_0001 UP TO 10 ROWS.

  SELECT *
    FROM pa0002
    INTO TABLE i_0002 UP TO 10 ROWS.

  SELECT *
    FROM pa0008
    INTO TABLE i_0008 UP TO 10 ROWS.

ENDFORM. "get_data
**********************************************************************
* FORM    :  display_data
***********************************************************************
FORM display_data.

  PERFORM build_fieldcatalog USING 'PA0000' CHANGING i_fieldcat1.
  PERFORM build_fieldcatalog USING 'PA0001' CHANGING i_fieldcat2[].
  PERFORM build_fieldcatalog USING 'PA0002' CHANGING i_fieldcat3[].
  PERFORM build_fieldcatalog USING 'PA0008' CHANGING i_fieldcat4[].
  w_layout-max_linesize = '500'.
  PERFORM display_data_alv.

ENDFORM. "display_data
*&---------------------------------------------------------------------*
*&      Form  display_data_ALV
*&---------------------------------------------------------------------*
FORM display_data_alv .

  DATA:l_program TYPE sy-repid.

  l_program = sy-repid.
  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
    EXPORTING
      i_callback_program = l_program.

  PERFORM build_block_list_append TABLES i_0000[] USING w_layout i_fieldcat1[] 'PA0000' i_events[].
  PERFORM build_block_list_append TABLES i_0001[] USING w_layout i_fieldcat2[] 'PA0001' i_events[].
  PERFORM build_block_list_append TABLES i_0002[] USING w_layout i_fieldcat3[] 'PA0002' i_events[].
  PERFORM build_block_list_append TABLES i_0008[] USING w_layout i_fieldcat4[] 'PA0008' i_events[].

  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'.
  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.                    " display_data_ALV
*&---------------------------------------------------------------------*
*&      Form  build_block_list_append
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_0141   text
*      -->P_0142   text
*      -->P_0143   text
*      -->P_0144   text
*----------------------------------------------------------------------*
FORM build_block_list_append  TABLES outtab USING  layout fieldcat tabname events .


  CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
    EXPORTING
      is_layout                        = layout
      it_fieldcat                      = fieldcat
      i_tabname                        = tabname
      it_events                        = events
    TABLES
      t_outtab                         = outtab.
  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.                    " build_block_list_append
*&---------------------------------------------------------------------*
*&      Form  build_fieldcatalog
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_0113   text
*----------------------------------------------------------------------*
FORM build_fieldcatalog  USING    structure CHANGING i_fieldcat1.
  DATA:l_program TYPE sy-repid.

  l_program = sy-repid.
  CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
      i_program_name   = l_program
      i_structure_name = structure
    CHANGING
      ct_fieldcat      = i_fieldcat1.
  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.                    " build_fieldcatalo 

Regards, Venkat.O

Read only

Former Member
0 Likes
1,007

Hi venkat,

I am displaying two different outputs for two different conditions.

Read only

Former Member
0 Likes
1,007

hi check this...

&----


*& Report ZALV_SAMPLE *

*& *

&----


*& Program for displaying data using function modules : *

*& REUSE_ALV_LIST_DISPLAY *

*& REUSE_ALV_POPUP_TO_SELECT *

*& REUSE_ALV_GRID_DISPLAY *

*& *

&----


report zalv_sample .

tables vbak.

data it_vbak like vbak occurs 0 with header line.

selection-screen begin of block b1 with frame.

parameters: alv1 radiobutton group alv, "REUSE_ALV_LIST_DISPLAY

alv2 radiobutton group alv, "REUSE_ALV_POPUP_TO_SELECT

alv3 radiobutton group alv, "REUSE_ALV_GRID_DISPLAY

alv4 radiobutton group alv. " NORMAL DISPLAY

selection-screen end of block b1.

select * from vbak

into corresponding fields of table it_vbak

up to 10 rows.

if alv1 = 'X'.

perform alv_func1.

elseif alv2 = 'X'.

perform alv_func2.

elseif alv3 = 'X'.

perform alv_func3.

elseif alv4 = 'X'.

perform norm.

endif.

&----


*& Form ALV_FUNC1

&----


form alv_func1 .

call function 'REUSE_ALV_LIST_DISPLAY'

exporting

i_structure_name = 'VBAK'

tables

t_outtab = it_vbak

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. " ALV_FUNC1

&----


*& Form ALV_FUNC2

&----


form alv_func2 .

call function 'REUSE_ALV_POPUP_TO_SELECT'

exporting

i_title = 'SALES ORDER INFO'

i_zebra = 'X'

i_tabname = 1

i_structure_name = 'vbak'

tables

t_outtab = it_vbak

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. " ALV_FUNC2

&----


*& Form ALV_FUNC3

&----


form alv_func3 .

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

i_structure_name = 'vbak'

i_grid_title = 'SALES ORDER INFO'

tables

t_outtab = it_vbak

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. " ALV_FUNC3

&----


*& Form NORM

&----


form norm .

format intensified.

skip 1.

write: /'SALES DOC.',

' Created on ',

' Time',

' Created by',

' Valid from ',

' Sold-to party'.

format intensified off.

skip 2.

loop at it_vbak.

write: / it_vbak-vbeln,' ',

it_vbak-erdat,' ',

it_vbak-erzet,' ',

it_vbak-ernam,' ',

it_vbak-angdt,' ',

it_vbak-kunnr.

endloop.

endform. " NORM

regards,

venkat

Read only

0 Likes
1,006

Hi,

Thanks for the reply. I am using field catalog to display ALV.In this case what should i do?

Read only

Former Member
0 Likes
1,006

That is what everybody is saying...

U use if else statement and declare your different catalogues there...

u create two different catalogues.

Read only

Former Member
0 Likes
1,006

hi poonam,

if you are using funtion module to display ur alv then you should use

DATA: WA_FCAT TYPE SLIS_FIELDCAT_ALV. " work area

DATA: T_FCAT TYPE SLIS_T_FIELDCAT_ALV . "

field catalog internal table

and if you are using class for alv ...

thn use

DATA: FCAT TYPE LVC_T_FCAT.

" field catalog internal table

DATA: WA_FCAT LIKE LINE OF FCAT. work area

this is for LVC_T_FCAT.

the fields of field catlog are

WA_FCAT-TABNAME = 'IT_ITAB' .

WA_FCAT-FIELDNAME = 'NAME'.

WA_FCAT-COLTEXT = 'Name of the extension

WA_FCAT-OUTPUTLEN = 16.

this is SLIS_FIELDCAT_ALV.

WA_FCAT1-TABNAME = TNAME .

WA_FCAT1-FIELDNAME = FNAME .

WA_FCAT1-SELTEXT_L = SELTEXT .

WA_FCAT1-OUTPUTLEN = OPLEN .

now enjoy ...

priyank dixit