2020 Dec 15 1:18 AM
Hi All,
I have a requirement to display an alv report for below scenario.
Header1
Details
Footer
---
Header2
Details
Footer.
--
The above no. of blocks may vary based on report selection.
I need to know how can we build multiple field catalogs and pass field catalog and data from my internal table to build the above scenario.
Note: My Internal table is having data in below format and I am using the same to generate output txt file. I need to show the similar details in alv.
Internal Table Data:
Header1
Details Record 1
Details Record 2
Details Record 3
Footer ( remains constant )
Header2
Details Record 1
Details Record 2
Details Record 3
Footer ( remains constant )
and so on..
Thankyou for all your help.
Regards
Dheeraj
2020 Dec 15 1:45 AM
You can do this by using block ALV.
DATA : IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
T_LAYOUT TYPE SLIS_LAYOUT_ALV,
T_EVENT1 TYPE SLIS_T_EVENT,
T_EVENT2 TYPE SLIS_T_EVENT.
DATA : B1_IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
B1_WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
DATA : B2_IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
B2_WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
*&---------------------------------------------------------------------*
*& Form BLOCK1_ALV
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM BLOCK1_ALV.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID.
" Block 1 -
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
IS_LAYOUT = T_LAYOUT
IT_FIELDCAT = B1_IT_FIELDCAT
I_TABNAME = 'BLOCK1'
IT_EVENTS = T_EVENT1
* IT_SORT =
* I_TEXT = ' '
TABLES
T_OUTTAB = BLOCK1
EXCEPTIONS
PROGRAM_ERROR = 1
MAXIMUM_OF_APPENDS_REACHED = 2
OTHERS = 3
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
" Block 2
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
IS_LAYOUT = T_LAYOUT
IT_FIELDCAT = B2_IT_FIELDCAT
I_TABNAME = 'BLOCK2'
IT_EVENTS = T_EVENT2
* IT_SORT =
* I_TEXT = ' '
TABLES
T_OUTTAB = BLOCK2
EXCEPTIONS
PROGRAM_ERROR = 1
MAXIMUM_OF_APPENDS_REACHED = 2
OTHERS = 3
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
* EXPORTING
* I_INTERFACE_CHECK = ' '
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2.
.
ENDFORM. " BLOCK1_ALV
Hi All,
I have a requirement to display an alv report for below scenario.
Header1
Details
Footer
---
Header2
Details
Footer.
--
The above no. of blocks may vary based on report selection.
I need to know how can we build multiple field catalogs and pass field catalog and data from my internal table to build the above scenario.
Note: My Internal table is having data in below format and I am using the same to generate output txt file. I need to show the similar details in alv.
Internal Table Data:
Header1
Details Record 1
Details Record 2
Details Record 3
Footer ( remains constant )
Header2
Details Record 1
Details Record 2
Details Record 3
Footer ( remains constant )
and so on..
Thankyou for all your help.
Regards
Dheeraj
2020 Dec 15 1:45 AM
You can do this by using block ALV.
DATA : IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
T_LAYOUT TYPE SLIS_LAYOUT_ALV,
T_EVENT1 TYPE SLIS_T_EVENT,
T_EVENT2 TYPE SLIS_T_EVENT.
DATA : B1_IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
B1_WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
DATA : B2_IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
B2_WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
*&---------------------------------------------------------------------*
*& Form BLOCK1_ALV
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM BLOCK1_ALV.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID.
" Block 1 -
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
IS_LAYOUT = T_LAYOUT
IT_FIELDCAT = B1_IT_FIELDCAT
I_TABNAME = 'BLOCK1'
IT_EVENTS = T_EVENT1
* IT_SORT =
* I_TEXT = ' '
TABLES
T_OUTTAB = BLOCK1
EXCEPTIONS
PROGRAM_ERROR = 1
MAXIMUM_OF_APPENDS_REACHED = 2
OTHERS = 3
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
" Block 2
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
EXPORTING
IS_LAYOUT = T_LAYOUT
IT_FIELDCAT = B2_IT_FIELDCAT
I_TABNAME = 'BLOCK2'
IT_EVENTS = T_EVENT2
* IT_SORT =
* I_TEXT = ' '
TABLES
T_OUTTAB = BLOCK2
EXCEPTIONS
PROGRAM_ERROR = 1
MAXIMUM_OF_APPENDS_REACHED = 2
OTHERS = 3
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
* EXPORTING
* I_INTERFACE_CHECK = ' '
* EXCEPTIONS
* PROGRAM_ERROR = 1
* OTHERS = 2.
.
ENDFORM. " BLOCK1_ALV
2020 Dec 15 2:02 AM
Thankyou Suresh!
Do you mean B1_IT_FIELDCAT is for header record and B2_IT_FIELDCAT is for detail record?
My actual data is somewhat like below:
1st row is header row and last row is footer. Middle rows are details and they can vary.
This is one block and I can have multiple such blocks of data in my output.
Could you please provide some more details to achieve the desired output?
Appreciate all your help!
Regards,
Dheeraj
2020 Dec 15 2:04 AM
2020 Dec 16 5:55 PM
Thankyou Suresh!
I was able to achieve the required functionality using the ALV Blocked LIST.
Created 3 Field Catalogs ( for header, detail and footer ) with 3 internal tables and Appended appropriate data using FM 'REUSE_ALV_BLOCK_LIST_APPEND'. And Finally using FM 'REUSE_ALV_BLOCK_LIST_DISPLAY' for displaying.
reference: http://saptechnical.com/Tutorials/ALV/BlockedList/DemoPrg.htm
Thanks again!
Regards
Dheeraj
2020 Dec 15 4:44 AM
ALV block, or tab strip, or splitter, etc. What did you search, what did you find, what did you try, what do you think?
2020 Dec 15 9:02 AM
Hint: Look at some samples such as ALV Object Model – Hierarchical Sequential List – The Basics which use CL_SALV_HIERSEQ_TABLE.
2020 Dec 15 1:03 PM
Hi Raymond,
Thankyou for sharing the valuable inputs. This may be helpful at some point.
However for now, my requirement is bit different.
I have the data in the single internal table of type string ( which i am using to generate the output file )
The output is 3 variable rows of data:
1. Type 1 records are Header ( This is not the header of the report ). For example: These record provide the date range and company details etc.
2.Type 2 records are Details. These records have punch in , punch out details for the employees.
3.Type 3 record. This is a constant footer.
I have the entire data in a single table.
These 3 types of records have their own field names ( for example: Type 1 will have, company name, rep id etc. Type 2 will have punch in , punch out etc,)
The only thing that i am looking for is how can I have generate ALV output for above mentioned 3 types of data records and pass their field descriptions accordingly.
The Binding method using Main Class - CL_SALV_HIERSEQ_TABLE should work for 2 variable data records as per example shared by you, however in my case I have 3 types of data records and don't have a common column for 3rd Type ( footer ) to bind. Also not sure if the binding works for more than 2 data records.
I am new to ALV. Any Inputs are highly appreciated!
Thankyou!
2020 Dec 15 1:56 PM
Could you then elaborate on: 'Footer ( remains constant )' - There is no data in this record, it seems only to exist to record the end of a document, why would you display it?
2020 Dec 15 10:36 PM
Hi Raymond,
The client requirement is to display the 3 footer record.
Could you please share some details for alternate method that you have proposed.(html display )
Thankyou!
2020 Dec 16 8:48 AM
Look for some SAP samples at transaction DWDM (Examples and demos by SAP) for sample of gui tree.or a tool such as Abap2Xlxsx
But IMHO if you want a not too complicated ALV report you should use a single format for header/footer an another format for detail so you can use the ALV block/hierarchy tool (and use a total row to simulate the footer display.)
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |