1 Introduction
The ALV provides Events, which allows users to add information to the List at different rendering time points.
Goals of the ALV Form:
• UI independent information for rendering
• The information is displayed in agreement with the SAP agronomical guideline
The base Element of the ALV Form is the abstract class CL_SALV_FORM_ELEMENT.
This base Element (CL_SALV_FORM_ELEMENT) describes the information to be displayed. There are two major Element types:
• Layout Element (CL_SALV_FORM_ELEMENT_LAYOUT): the base layout element for describing a table or a flow of information
• Textual Element (CL_SALV_FORM_ELEMENT_TEXTUAL): the base element for text elements. Text Elements supported are:
o Label (CL_SALV_FORM_LABEL)
o Text (CL_SALV_FORM_TEXT)
o Header information (CL_SALV_FORM_HEADER_INFO)
o Action information (CL_SALV_FORM_ACTION_INFO)
2 Step-by-Step Description how to Replace
1) Have a look at the original output and ensure you that the converted output has the same lines and texts arrangements
2) Identify used ‘REUSE_ALV_COMMENTARY_WRITE’ calls within your programs, especially in the subroutines TOP_OF_PAGE (Grid) and TOP_OF_LIST (Simple List)
3) Comment the ‘REUSE_ALV_COMMENTARY_WRITE’
4) Search and comment all the used variables, subroutine / function module calls, text-elements and internal tables, which are used exclusively for the ‘REUSE_ALV_COMMENTARY_WRITE’ output.
5) Please insert the necessary coding and data-elements for “ALV Form”. This is done within the TOP_OF_PAGE subroutine for ALV GRID and in the TOP_OF_LIST subroutine for Simple List
6) Delete all unused (commented) variables, calls and tables (step 3&4).
7) ! Ensure that you have inserted all newly created text-elements for this process in your report documentation
8) Test the output and compare with the original one
3 Coding and Functionality of “ALV Form” (easy)
CREATE OBJECT lr_grid.
lr_label = lr_grid->create_label(
row = 1
column = 1
text = constant1).
lr_text = lr_grid->create_text(
row = 1
column = 2
text = variable1).
*... set label for text
lr_label->set_label_for( lr_text ).
lr_label = lr_grid->create_label(
row = 2
column = 1
text = text-003).
lr_text = lr_grid->create_text(
row = 2
column = 2
text = variable2).
*... set label for text
lr_label->set_label_for( lr_text ).
CALL METHOD cl_salv_form_content=>set
EXPORTING
value = lr_grid.
To 1: Declare the necessary type with reference to the used class locally (within FORM top_of_page or top_of_list).
To 2: Create the object which will be filled in part 3.
To 3: In this section, you need to define the exact data to be displayed and the layout / formatting of the same. The coding in BLACK is fixed – do not alter this code. The code in BLUE is variable and your action is needed here.
The „ lr_grid->create_label“ statement creates the label – usually at the beginning left of each line
The „lr_grid->create_text“ statement creates the text, which usually stand right to the label and specifies the label by a value
You can combine both as it is needed and as it’s making sense.
In „row“ and „column“ you enter the exact position of label or text. Attention: Elements will automatically aligned!
Example, 1st line: Label row 1, column 1 / Text row 1, column 2
Label and text will be automatically aligned by system. Please see label „abc“ and text „21“.
For „text“ please insert the formerly used data elements. They could be
- text element
- variable/constant
- internal table value ...
Do not use hard coded statements!
To 4: If your row contains label and text data, which belong together, please add this statement to link them.
To 5: If all your formatting is done, call the necessary method (cl_salv_form_content=>set ) with exactly the same coding as in the section 4.
Addition to 3: If an empty line is needed please use following statement:
*... create empty line.
lr_grid->add_row( ).
4 Coding and Functionality of “ALV Form” with header line / action item
If you need a header line and/or an action item, please cf. the example coding below:
DATA: lr_content TYPE REF TO cl_salv_form_element,
lr_outer_grid TYPE REF TO cl_salv_form_layout_grid,
lr_inner_grid TYPE REF TO cl_salv_form_layout_grid,
lr_flow TYPE REF TO cl_salv_form_layout_flow,
lr_label TYPE REF TO cl_salv_form_label,
lr_text TYPE REF TO cl_salv_form_text,
lr_header TYPE REF TO cl_salv_form_header_info,
lr_action TYPE REF TO cl_salv_form_action_info.
*********************************************************************
* create OUTER_GRID as top_of_page object
*********************************************************************
CREATE OBJECT lr_outer_grid.
*********************************************************************
**... in the cell [1,1] of outer_grid a flow information is set
*********************************************************************
lr_flow = lr_outer_grid->create_flow(
row = 1
column = 1 ).
*.. create header information
lr_header = lr_flow->create_header_information(
text ='This a a long header line as flow information').
*********************************************************************
*... in the cell [2,1] of outer_grid grid information is set
*********************************************************************
lr_inner_grid = lr_outer_grid->create_grid(
row = 2
column = 1 ).
*... create empty line in inner_grid_
lr_inner_grid->add_row( ).
*... create lable information in inner_grid
lr_label = lr_inner_grid->create_label(
row = 2
column = 1
text = 'LABLE' ).
*... create text information in inner_grid
lr_text = lr_inner_grid->create_text(
row = 2
column = 2
text = 'Herr Mayer' ).
*... set label for text
lr_label->set_label_for( lr_text ).
*... create empty line in innner_grid
lr_inner_grid->add_row( ).
*********************************************************************
*... in the cell [3,1] of outer_grid low information is set
*********************************************************************
lr_flow = lr_outer_grid->create_flow(
row = 3
column = 1 ).
*... create action information
lr_action = lr_flow->create_action_information(
text ='Action in cell [3,1]').
*********************************************************************
*.. set content
*********************************************************************
lr_content = lr_outer_grid.
cl_salv_form_content=>set( lr_content ).
ENDFORM. "TOP_OF_PAGE
"
RELATED POSTS
No comments :
Post a Comment