2013 May 22 7:27 AM
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?
seqno | Month | land cost(local currency) | land cost(in USD) |
1 | Jan | $100.00 | $200.00 |
2 | Feb | $10.00 | $30.00 |
3 | Mar | $40.00 | $70.00 |
4 | Apr | $10.00 | $20.00 |
5 | May | $50.00 | $10.00 |
Transportation cost(local currency) | Transportation cost(in USD) | ||
1 | Jan | $100.00 | $200.00 |
2 | Feb | $10.00 | $30.00 |
3 | Mar | $40.00 | $70.00 |
Expenses(local currency) | Expenses(in USD) | ||
1 | Jan | $100.00 | $200.00 |
2 | Feb | $10.00 | $30.00 |
3 | Mar | $40.00 | $70.00 |
4 | Apr | $10.00 | $20.00 |
5 | May | $50.00 | $10.00 |
2013 May 22 12:16 PM
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 seqno | Month | cost(local currency) | land cost(in USD) |
land cost 1 | Jan | $100.00 | $200.00 |
2 | Feb | $10.00 | $30.00 |
3 | Mar | $40.00 | $70.00 |
4 | Apr | $10.00 | $20.00 |
5 | May | $50.00 | $10.00 |
Transport... 1 | Jan | $100.00 | $200.00 |
2 | Feb | $10.00 | $30.00 |
3 | Mar | $40.00 | $70.00 |
Expenses 1 | Jan | $100.00 | $200.00 |
2 | Feb | $10.00 | $30.00 |
3 | Mar | $40.00 | $70.00 |
4 | Apr | $10.00 | $20.00 |
5 | May | $50.00 | $10.00 |
Thanks and Regards,
Sriranjani Chimakurthy.
2013 May 22 7:35 AM
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.
2013 May 22 7:41 AM
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 :
Regards
SG
2013 May 22 8:34 AM
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
2013 May 22 9:10 AM
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
2013 May 22 9:27 AM
2013 May 22 10:08 AM
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.
2013 May 22 11:09 AM
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
2013 May 22 11:29 AM
*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
2013 May 22 12:16 PM
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 seqno | Month | cost(local currency) | land cost(in USD) |
land cost 1 | Jan | $100.00 | $200.00 |
2 | Feb | $10.00 | $30.00 |
3 | Mar | $40.00 | $70.00 |
4 | Apr | $10.00 | $20.00 |
5 | May | $50.00 | $10.00 |
Transport... 1 | Jan | $100.00 | $200.00 |
2 | Feb | $10.00 | $30.00 |
3 | Mar | $40.00 | $70.00 |
Expenses 1 | Jan | $100.00 | $200.00 |
2 | Feb | $10.00 | $30.00 |
3 | Mar | $40.00 | $70.00 |
4 | Apr | $10.00 | $20.00 |
5 | May | $50.00 | $10.00 |
Thanks and Regards,
Sriranjani Chimakurthy.
2013 May 22 12:56 PM
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.