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: 

Issue in alv grid report output format

venkata_reddy6
Participant
0 Kudos
311

Hi All,

I have a requirement that alv report output with multiple line headers in single output as shown below.

can we achieve this in alv grid or using classes?

seqnoMonthland cost(local currency)land cost(in USD)
1Jan$100.00$200.00
2Feb$10.00$30.00
3Mar$40.00$70.00
4Apr$10.00$20.00
5May$50.00$10.00


Transportation cost(local currency)Transportation cost(in USD)
1Jan$100.00$200.00
2Feb$10.00$30.00
3Mar$40.00$70.00


Expenses(local currency)Expenses(in USD)
1Jan$100.00$200.00
2Feb$10.00$30.00
3Mar$40.00$70.00
4Apr$10.00$20.00
5May$50.00$10.00
1 ACCEPTED SOLUTION

former_member186077
Active Participant
0 Kudos
246

Hi,

Another way would be to keep the descriptions as well as another column, and keep cost in local currency , cost in usd.

You can group by the description , seq no, column so that it looks like below.

description seqnoMonthcost(local currency)land cost(in USD)
land cost      1Jan$100.00$200.00
                       2Feb$10.00$30.00
                       3Mar$40.00$70.00
                       4Apr$10.00$20.00
                       5May$50.00$10.00


Transport...  1Jan$100.00$200.00
                       2Feb$10.00$30.00
                       3Mar$40.00$70.00




Expenses    1Jan$100.00$200.00
                       2Feb$10.00$30.00
                       3Mar$40.00$70.00
                        4Apr$10.00$20.00
                        5May$50.00$10.00

Thanks and Regards,

Sriranjani Chimakurthy.

10 REPLIES 10

Former Member
0 Kudos
246

Hi Venkata,

I am not sure if you can do this using ALV Grid. Probably you can do this with Blocklist ALV or classical ALV.

Reagards,

DN.

Former Member
0 Kudos
246

Hi Venkata,

Use radio button for each heading and execute it ( separate output ).i am not sure you able to use different heading in same ALV.

Eg :

  • land cost
  • Transportation cost
  • Expenses

Regards

SG

Former Member
0 Kudos
246

Hi venkata,

It is possible in interactive report,1st display you will maintained land,transport and exp.

then click on land,it give all land details and click back it will come 1st screen.then your choices

Former Member
0 Kudos
246

Hi Venkata Reddy,

I dont think that the way you said to be outptu is really possible, Instead u can do the other ways as below:

1) As upender as has proposed , u could go with interactive ALV.

2) maintain three radio button s on selection screen..then you can take the data based on the radio button selected and display that ALV list.

3) it could also be done using FM's

REUSE_ALV_BLOCK_LIST_INIT

REUSE_ALV_BLOCK_LIST_APPEND

REUSE_ALV_BLOCK_LIST_DISPLAY

in this case u can hav all the thre lists at once on the screen.

Hope this would give u some idea on your requirement...

Regards,

Azhar

PeterJonker
Active Contributor
0 Kudos
246

It is certainly possible.  Check this discussion:

http://scn.sap.com/message/392805#392805

Former Member
0 Kudos
246

Hi Venkata,

You can achieve this using different containers. But I am not sure will this can be your requirement.

Split the container into 3 sub containers, then try to display different header in each container with the data.

Former Member
0 Kudos
246

we can us the below FMs to display multiple Headerline records in ALV

REUSE_ALV_BLOCK_LIST_INIT

REUSE_ALV_BLOCK_LIST_APPEND

REUSE_ALV_BLOCK_LIST_DISPLAY

0 Kudos
246

*REPORT  zalv_block_report.

TABLES ekko.

hi venkat ,

               i pasted sample code of block  alv list using ekko and ekpo tables, Hope this can full fill your requirement.

TYPE-POOLS slis.

*TO CREATE INTERNAL TABLE IT_EKKO OF STRUCTURE EKKO

DATA it_ekko TYPE TABLE OF ekko.

*TO CREATE INTERNAL TABLE IT_EKPO OF STRUCTURE EKPO

DATA it_ekpo TYPE TABLE OF ekpo.

*TO CREATE FIELDCATALOG IT_FCAT1 BASED OF DDIC STRUCTURE EKKO

DATA it_fcat1 TYPE slis_t_fieldcat_alv.

*TO CREATE FIELDCATALOG IT_FCAT2 BASED OF DDIC STRUCTURE EKPO

DATA it_fcat2 TYPE slis_t_fieldcat_alv.

*TO CREATE INTERNAL TABLE IT_EVENTS OF STRUCTURE SLIS_T_EVENT

DATA it_events TYPE slis_t_event.

*TO CREATE WORK AREA WA_LAYOUT OF STRUCTURE SLIS_LAYOUT_ALV

DATA wa_layout TYPE slis_layout_alv.

*TO CREATE VARIABLE TO STORE THE CURRENT PROGRAM

DATA v_program LIKE sy-repid .

*TO PROVIDE RANGE OF INPUT FIELDS TO ENTER PO NUMBERS

SELECT-OPTIONS s_ebeln FOR ekko-ebeln.

START-OF-SELECTION.

   PERFORM get_data.

   PERFORM init_alv_block_list.

   PERFORM build_fcat1.

   PERFORM append_it_ekko_alv_blck_list.

   PERFORM build_fcat2.

   PERFORM append_it_ekpo_alv_blck_list.

   PERFORM display_alv_block_list.

*&---------------------------------------------------------------------*

*&      Form  GET_DATA

*&---------------------------------------------------------------------*

FORM get_data .

*TO GET PURCHASE DOCUMENT HEADER DATA FROM DBTABLE EKKO INTO INTERNAL

*TABLE IT_EKKO

   SELECT *

     FROM ekko

     INTO TABLE it_ekko

       WHERE ebeln IN s_ebeln.

   IF it_ekko IS NOT INITIAL.

*TO GET PURCHASE DOCUMENT ITEM DATA FROM DBTABLE EKPO INTO INTERNAL

*TABLE IT_EKPO

     SELECT *

       FROM ekpo

       INTO TABLE it_ekpo

       FOR ALL ENTRIES IN it_ekko

         WHERE ebeln = it_ekko-ebeln.

   ENDIF.

   v_program = sy-repid.

ENDFORM.                    " GET_DATA

*&---------------------------------------------------------------------*

*&      Form  INIT_ALV_BLOCK_LIST

*&---------------------------------------------------------------------*

FORM init_alv_block_list .

*REUSE_ALV_BLOCK_LIST_INIT:THIS FUNCTION MODULE IS USED TO INITIALIZE

*ALV BLOCK LIST

   CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'

     EXPORTING

       i_callback_program = v_program.

ENDFORM.                    " INIT_ALV_BLOCK_LIST

*&---------------------------------------------------------------------*

*&      Form  BUILD_FCAT1

*&---------------------------------------------------------------------*

FORM build_fcat1 .

*REUSE_ALV_FIELDCATALOG_MERGE:THIS FUNCTION MODULE IS USED TO BUILD

*FIELDCATALOG BASED ABAP DICTIONARY STRUCTURE EKKO

   CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

     EXPORTING

       i_program_name         = v_program

       i_structure_name       = 'EKKO'

     CHANGING

       ct_fieldcat            = it_fcat1

     EXCEPTIONS

       inconsistent_interface = 1

       program_error          = 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.

ENDFORM.                    " BUILD_FCAT1

*&---------------------------------------------------------------------*

*&      Form  APPEND_IT_EKKO_ALV_BLCK_LIST

*&---------------------------------------------------------------------*

FORM append_it_ekko_alv_blck_list .

*REUSE_ALV_BLOCK_LIST_APPEND:THIS FUNCTION MODULE IS USED TO APPEND

*INTERNAL TABLE IT_EKKO DATA TO ALV BLOCK LIST

   CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

     EXPORTING

       is_layout                  = wa_layout

       it_fieldcat                = it_fcat1

       i_tabname                  = 'IT_EKKO'

       it_events                  = it_events

     TABLES

       t_outtab                   = it_ekko

     EXCEPTIONS

       program_error              = 1

       maximum_of_appends_reached = 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.

ENDFORM.                    " APPEND_IT_EKKO_ALV_BLCK_LIST

*&---------------------------------------------------------------------*

*&      Form  BUILD_FCAT2

*&---------------------------------------------------------------------*

FORM build_fcat2 .

*REUSE_ALV_FIELDCATALOG_MERGE:THIS FUNCTION MODULE IS USED TO BUILD

*FIELDCATALOG BASED ABAP DICTIONARY STRUCTURE EKPO

   CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'

     EXPORTING

       i_program_name         = v_program

       i_structure_name       = 'EKPO'

     CHANGING

       ct_fieldcat            = it_fcat2

     EXCEPTIONS

       inconsistent_interface = 1

       program_error          = 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.

ENDFORM.                    " BUILD_FCAT2

*&---------------------------------------------------------------------*

*&      Form  APPEND_IT_EKPO_ALV_BLCK_LIST

*&---------------------------------------------------------------------*

FORM append_it_ekpo_alv_blck_list .

*REUSE_ALV_BLOCK_LIST_APPEND:THIS FUNCTION MODULE IS USED TO APPEND

*INTERNAL TABLE IT_EKPO DATA TO ALV BLOCK LIST

   CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'

     EXPORTING

       is_layout                  = wa_layout

       it_fieldcat                = it_fcat2

       i_tabname                  = 'IT_EKPO'

       it_events                  = it_events

     TABLES

       t_outtab                   = it_ekpo

     EXCEPTIONS

       program_error              = 1

       maximum_of_appends_reached = 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.

ENDFORM.                    " APPEND_IT_EKPO_ALV_BLCK_LIST

*&---------------------------------------------------------------------*

*&      Form  DISPLAY_ALV_BLOCK_LIST

*&---------------------------------------------------------------------*

FORM display_alv_block_list .

*REUSE_ALV_BLOCK_LIST_DISPLAY:THIS FUNCTION MODULE IS USED TO DISPLAY

*ALV BLOCK LIST

   CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'

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

former_member186077
Active Participant
0 Kudos
247

Hi,

Another way would be to keep the descriptions as well as another column, and keep cost in local currency , cost in usd.

You can group by the description , seq no, column so that it looks like below.

description seqnoMonthcost(local currency)land cost(in USD)
land cost      1Jan$100.00$200.00
                       2Feb$10.00$30.00
                       3Mar$40.00$70.00
                       4Apr$10.00$20.00
                       5May$50.00$10.00


Transport...  1Jan$100.00$200.00
                       2Feb$10.00$30.00
                       3Mar$40.00$70.00




Expenses    1Jan$100.00$200.00
                       2Feb$10.00$30.00
                       3Mar$40.00$70.00
                        4Apr$10.00$20.00
                        5May$50.00$10.00

Thanks and Regards,

Sriranjani Chimakurthy.

former_member209119
Active Participant
0 Kudos
246

Hi,

The best and easiest approach would be to use 'Block List Display'.

Use the below mentioned FMs-

REUSE_ALV_BLOCK_LIST_INIT :           Once, to initialize the list

REUSE_ALV_BLOCK_LIST_APPEND : Number of times, to append all yout tables one by one

REUSE_ALV_BLOCK_LIST_DISPLAY : Once, to display data on screen.