‎2007 Dec 07 5:14 PM
Hii all...
My scenario is to Create an Interactive Report for displaying Vendor information. Based on the selection made the corresponding Vendor Bank Details are listed such that the line selected in the basic list was visible along with the secondary list.Can nebody pls guide me how to start with...
Regards,
jothi
‎2007 Dec 07 6:23 PM
in that case you will have to send us your spec or atleast selection screen parameters and output parameters which you want to display on output and what type of output you want? alv grid, hierarchy, list or tree?
Why dont you try the following code.
Go to se38 and create a yreport or zreport - make it executable in attributes -
paste this report in your newly created program, rename the report name in the report.
execute it or debug it. you will now get the output in alv grid.
All you have to enter is material number and plant or material number or just plant and execute it. It has simple blocks with some of the descriptions.
-
Documentation on SALV GRID.
Create a report from SE38. Save in local objects.
Upload the program which is at the bottom of this document. You dont have to create any screen as you create for other ALV grid. This it creates a container on default screen. You dont have to take care of any other coding to run in background. SALV will take care of all those things.
These two parameters are important to create a ALV GRID in SALV.
Let us see what these parameters are.
DATA : gr_table TYPE REF TO cl_salv_table.
DATA : gr_functions TYPE REF TO cl_salv_functions_list.
GR_TABLE: This is referenced to CL_SALV_TABLE. This is actual class which will take care of displaying grid on the screen. There is nothing much code involved in SALV.
GR_FUNCTIONS: This is referenced to CL_SAL_FUNCTIONS_LIST which will take care of the functions like Sort, Filter, saving locally.
You have to use DATA: lr_aggregations TYPE REF TO cl_salv_aggregations.
To handle the subtotals.
You need the following two parameters to handle the layout which will allow user to save their own layout and of course you can assign your own layout to restrict the output fields.
DATA: lr_layout TYPE REF TO cl_salv_layout,
Ls_key TYPE salv_s_layout_key.
Please note, I did not put any code for events like hotspot handle and double click event and etc.
Here is the code. This is very simple program and you have to activate all functions and events and need to write code for layout handling.
TYPES: BEGIN OF t_mara,
matnr TYPE matnr,
mbrsh TYPE mbrsh,
meins TYPE meins,
END OF t_mara.
DATA : it_mara TYPE TABLE OF t_mara,
wa_mara TYPE t_mara.
**SALV
DATA : gr_table TYPE REF TO cl_salv_table.
DATA : gr_functions TYPE REF TO cl_salv_functions_list.
*******************************************************************
SELECTION_SCREEN
*******************************************************************
SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: p_matnr TYPE matnr OBLIGATORY.
SELECTION-SCREEN : END OF BLOCK b1.
*******************************************************************
AT-SELECTION
*******************************************************************
AT SELECTION-SCREEN.
*******************************************************************
START-OF-SELECTION
*******************************************************************
START-OF-SELECTION.
PERFORM get_data.
perform salv.
&----
*& Form get_data
&----
FORM get_data .
SELECT matnr mbrsh meins INTO TABLE it_mara FROM mara where matnr = p_matnr.
ENDFORM. " get_data
&----
*& Form salv
&----
FORM salv .
DATA: lref TYPE REF TO cx_root .
DATA: lr_layout TYPE REF TO cl_salv_layout,
ls_key TYPE salv_s_layout_key.
TRY.
cl_salv_table=>factory(
IMPORTING
r_salv_table = gr_table
CHANGING
t_table = it_mara ).
CATCH cx_salv_msg INTO lref.
ENDTRY.
***Sub Total
PERFORM sub_total.
***Layout
lr_layout = gr_table->get_layout( ).
ls_key-report = sy-cprog.
lr_layout->set_key( ls_key ).
lr_layout->set_default( 'X' ).
lr_layout->set_save_restriction( if_salv_c_layout=>restrict_none ).
***toolbar
gr_functions = gr_table->get_functions( ).
gr_functions->set_all( 'X' ).
*final display
gr_table->display( ).
ENDFORM. " salv
&----
*& Form sub_total
&----
FORM sub_total .
DATA: lr_aggregations TYPE REF TO cl_salv_aggregations.
lr_aggregations = gr_table->get_aggregations( ).
lr_aggregations->clear( ).
uncomment the following to do subtotals and pass your table field.
TRY.
lr_aggregations->add_aggregation( columnname = 'Z_BALANCE_REM' ).
CATCH cx_salv_not_found cx_salv_data_error cx_salv_existing.
ENDTRY.
TRY.
lr_aggregations->add_aggregation( columnname = 'Z_PAY_AMT' ).
CATCH cx_salv_not_found cx_salv_data_error cx_salv_existing.
ENDTRY.
ENDFORM. " sub_total
Please try yourself first.
‎2007 Dec 07 5:28 PM
Well, what kind of report and what kind help you are seeking here? is it select statement help or do you want from scratch. Please refer, the following standard test report and read the coments in the reports.
SALV_DEMO_HIERSEQ_SIMPLE Demonstration of Simple Call of Sequential Lists
SALV_DEMO_TABLE_REAL_SIMPLE Most Simple Call of the ALV OM
SALV_DEMO_TABLE_SIMPLE Demonstration of Simplest ALV OM Call
SALV_DEMO_TREE_SIMPLE Demonstration Program for ALV OM Tree
SALV_SIMPLE_GRID_CALL
‎2007 Dec 07 5:50 PM
hii..
well tanx for ur immd response.. I need help from scratch..
regards,
jothi
‎2007 Dec 07 6:23 PM
in that case you will have to send us your spec or atleast selection screen parameters and output parameters which you want to display on output and what type of output you want? alv grid, hierarchy, list or tree?
Why dont you try the following code.
Go to se38 and create a yreport or zreport - make it executable in attributes -
paste this report in your newly created program, rename the report name in the report.
execute it or debug it. you will now get the output in alv grid.
All you have to enter is material number and plant or material number or just plant and execute it. It has simple blocks with some of the descriptions.
-
Documentation on SALV GRID.
Create a report from SE38. Save in local objects.
Upload the program which is at the bottom of this document. You dont have to create any screen as you create for other ALV grid. This it creates a container on default screen. You dont have to take care of any other coding to run in background. SALV will take care of all those things.
These two parameters are important to create a ALV GRID in SALV.
Let us see what these parameters are.
DATA : gr_table TYPE REF TO cl_salv_table.
DATA : gr_functions TYPE REF TO cl_salv_functions_list.
GR_TABLE: This is referenced to CL_SALV_TABLE. This is actual class which will take care of displaying grid on the screen. There is nothing much code involved in SALV.
GR_FUNCTIONS: This is referenced to CL_SAL_FUNCTIONS_LIST which will take care of the functions like Sort, Filter, saving locally.
You have to use DATA: lr_aggregations TYPE REF TO cl_salv_aggregations.
To handle the subtotals.
You need the following two parameters to handle the layout which will allow user to save their own layout and of course you can assign your own layout to restrict the output fields.
DATA: lr_layout TYPE REF TO cl_salv_layout,
Ls_key TYPE salv_s_layout_key.
Please note, I did not put any code for events like hotspot handle and double click event and etc.
Here is the code. This is very simple program and you have to activate all functions and events and need to write code for layout handling.
TYPES: BEGIN OF t_mara,
matnr TYPE matnr,
mbrsh TYPE mbrsh,
meins TYPE meins,
END OF t_mara.
DATA : it_mara TYPE TABLE OF t_mara,
wa_mara TYPE t_mara.
**SALV
DATA : gr_table TYPE REF TO cl_salv_table.
DATA : gr_functions TYPE REF TO cl_salv_functions_list.
*******************************************************************
SELECTION_SCREEN
*******************************************************************
SELECTION-SCREEN : BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
PARAMETERS: p_matnr TYPE matnr OBLIGATORY.
SELECTION-SCREEN : END OF BLOCK b1.
*******************************************************************
AT-SELECTION
*******************************************************************
AT SELECTION-SCREEN.
*******************************************************************
START-OF-SELECTION
*******************************************************************
START-OF-SELECTION.
PERFORM get_data.
perform salv.
&----
*& Form get_data
&----
FORM get_data .
SELECT matnr mbrsh meins INTO TABLE it_mara FROM mara where matnr = p_matnr.
ENDFORM. " get_data
&----
*& Form salv
&----
FORM salv .
DATA: lref TYPE REF TO cx_root .
DATA: lr_layout TYPE REF TO cl_salv_layout,
ls_key TYPE salv_s_layout_key.
TRY.
cl_salv_table=>factory(
IMPORTING
r_salv_table = gr_table
CHANGING
t_table = it_mara ).
CATCH cx_salv_msg INTO lref.
ENDTRY.
***Sub Total
PERFORM sub_total.
***Layout
lr_layout = gr_table->get_layout( ).
ls_key-report = sy-cprog.
lr_layout->set_key( ls_key ).
lr_layout->set_default( 'X' ).
lr_layout->set_save_restriction( if_salv_c_layout=>restrict_none ).
***toolbar
gr_functions = gr_table->get_functions( ).
gr_functions->set_all( 'X' ).
*final display
gr_table->display( ).
ENDFORM. " salv
&----
*& Form sub_total
&----
FORM sub_total .
DATA: lr_aggregations TYPE REF TO cl_salv_aggregations.
lr_aggregations = gr_table->get_aggregations( ).
lr_aggregations->clear( ).
uncomment the following to do subtotals and pass your table field.
TRY.
lr_aggregations->add_aggregation( columnname = 'Z_BALANCE_REM' ).
CATCH cx_salv_not_found cx_salv_data_error cx_salv_existing.
ENDTRY.
TRY.
lr_aggregations->add_aggregation( columnname = 'Z_PAY_AMT' ).
CATCH cx_salv_not_found cx_salv_data_error cx_salv_existing.
ENDTRY.
ENDFORM. " sub_total
Please try yourself first.