‎2005 Oct 17 9:19 AM
HI,
I wanted to write a report with two selection-screen blocks...fo example..
selection-screen begin of block1.
s_matnr for mara-matnr.
-
-
selecion-screen end of block1.
selection-screen begin of block2.
s_kunnr for knc1-kunnr.
-
-
selecion-screen end of block2.
In ALV
if i select block1 select-options i'll get one result.
if i select block2 select-options i'll get anoter result.
can tell me the how to write the code in ALV grid and send me if u have any sample code.
Thanks in advance,
raju.
‎2005 Oct 17 9:26 AM
hi,
try with this
data : itab like mara occurs 0.
if not s_matnr[] is initial and............
if block 1 is selected
select * into itab where matnr in s_matnr
else not s_kunnr[] is initial and............
if block 2 is selected
select * into itab where matnr in s_kunnr
endif.
is this helpful ?
cheers,
sasi
‎2005 Oct 17 9:26 AM
hi,
try with this
data : itab like mara occurs 0.
if not s_matnr[] is initial and............
if block 1 is selected
select * into itab where matnr in s_matnr
else not s_kunnr[] is initial and............
if block 2 is selected
select * into itab where matnr in s_kunnr
endif.
is this helpful ?
cheers,
sasi
‎2005 Oct 17 9:33 AM
Hi,
U can process this either using TAB strip ALV or simple ALV.
U should have a checkbox or radio butons so that u can process.
if not block1 is initial.
perform get_data1.
In this perform get the data in an output table that u r passing it for final display.
elseif not block2 is initial.
perform get_data2.
In this perform get the data in an output table that u r passing it for final display.
endif.
But u can keep the sample output table so that u can pass a single table in the output so that u can avoid confusion.
http://www.sapdevelopment.co.uk/reporting/alvhome.htm
For TABSTRIP refer this link
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/abap/abap-co... code sample for tab strip in alv.pdf
‎2005 Oct 17 9:36 AM
just create ascreen with number 0100 and create one custom container in that screen with name 'ALV_CONTAINER'
REPORT zanid_test MESSAGE-ID zz.
TABLES: zsflight.
*----
G L O B A L I N T E R N A L T A B L E S
*----
DATA: gi_sflight TYPE STANDARD TABLE OF sflight.
*----
G L O B A L D A T A
*----
DATA: ok_code LIKE sy-ucomm,
g_wa_sflight LIKE sflight.
Declare reference variables to the ALV grid and the container
DATA:
go_grid TYPE REF TO cl_gui_alv_grid,
go_custom_container TYPE REF TO cl_gui_custom_container.
*----
S T A R T - O F - S E L E C T I O N.
*----
START-OF-SELECTION.
SET SCREEN '100'.
&----
*& Module USER_COMMAND_0100 INPUT
&----
MODULE user_command_0100 INPUT.
CASE ok_code.
WHEN 'EXIT'.
LEAVE TO SCREEN 0.
ENDCASE.
ENDMODULE. " USER_COMMAND_0100 INPUT
&----
*& Module STATUS_0100 OUTPUT
&----
MODULE status_0100 OUTPUT.
Create objects
IF go_custom_container IS INITIAL.
CREATE OBJECT go_custom_container
EXPORTING container_name = 'ALV_CONTAINER'.
CREATE OBJECT go_grid
EXPORTING
i_parent = go_custom_container.
PERFORM load_data_into_grid.
ENDIF.
ENDMODULE. " STATUS_0100 OUTPUT
&----
*& Form load_data_into_grid
&----
----
FORM load_data_into_grid.
Read data from table SFLIGHT
SELECT *
FROM zsflight
INTO TABLE gi_sflight.
Load data into the grid and display them
CALL METHOD go_grid->set_table_for_first_display
EXPORTING i_structure_name = 'SFLIGHT'
CHANGING it_outtab = gi_sflight.
ENDFORM. " load_data_into_grid
‎2005 Oct 17 9:46 AM
Hi,
You can try something like this.
If not ( s_matnr[] is initial and s_kunnr[] is initial ).
*That's you have entered in both the blocks
select * from mara into table itab
where matnr in s_matnr
and matnr in s_kunnr.
elseif ( s_matnr[] is initial and s_kunnr[] is initial ).
*That's you haven't entered in both the blocks
select * from mara into table itab .
elseif ( s_matnr[] is initial ).
*You have entered kunnr
select * from mara into table itab
where matnr in s_kunnr.
else.
*you have entered matnr
select * from mara into table itab
where matnr in s_matnr.
endif.
Kindly reward points if it is helpful.
‎2005 Oct 17 10:09 AM
Hi,
check this it may help you.
*&---------------------------------------------------------------------*
*& Report Y_TWOSELECTIONS *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT Y_TWOSELECTIONS .
type-pools slis.
data: fieldcat type slis_t_fieldcat_alv.
data: sort type slis_t_sortinfo_alv.
data : begin of wa,
matnr type mara-matnr,
kunnr type knc1-kunnr.
data :end of wa.
data : itab like table of wa.
SELECTION-SCREEN BEGIN OF BLOCK A WITH FRAME.
SELECT-OPTIONS : s_matnr for wa-matnr.
SELECTION-SCREEN END OF BLOCK A.
SELECTION-SCREEN BEGIN OF BLOCK A1 WITH FRAME.
SELECT-OPTIONS : s_kunnr for wa-kunnr.
SELECTION-SCREEN END OF BLOCK A1.
Start-of-selection.
if not s_matnr is initial.
select * from mara into corresponding fields of wa where matnr in
s_matnr.
append wa to itab.
endselect.
elseif not s_kunnr is initial.
select * from knc1 into corresponding fields of wa where kunnr in
s_kunnr.
append wa to itab.
endselect.
endif.
perform write_report.
form write_report.
if not s_matnr is initial.
perform build_field_catalog.
elseif not s_kunnr is initial.
perform build_field_catalog1.
endif.
* perform build_sort.
* CALL ABAP LIST VIEWER (ALV)
call function 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
it_fieldcat = fieldcat
it_sort = sort
TABLES
t_outtab = itab.
endform.
************************************************************************
*BUILD_FIELD_CATALOG
************************************************************************
form build_field_catalog.
data: fc_tmp type slis_t_fieldcat_alv with header line.
clear: fieldcat.
refresh: fieldcat.
clear: fc_tmp.
fc_tmp-reptext_ddic = 'Material Number'.
fc_tmp-fieldname = 'matnr'.
fc_tmp-tabname = 'ITAB'.
fc_tmp-outputlen = '8'.
fc_tmp-col_pos = 2.
append fc_tmp to fieldcat.
endform.
*
************************************************************************
*
*BUILD_FIELD_CATALOG
************************************************************************
form build_field_catalog1.
data: fc_tmp type slis_t_fieldcat_alv with header line.
clear: fieldcat.
refresh: fieldcat.
clear: fc_tmp.
fc_tmp-reptext_ddic = 'Customer Number'.
fc_tmp-fieldname = 'kunnr'.
fc_tmp-tabname = 'ITAB'.
fc_tmp-outputlen = '8'.
fc_tmp-col_pos = 2.
append fc_tmp to fieldcat.
endform.regards,
‎2005 Oct 17 2:49 PM
Program everything as you would for a normal ALV Grid report, declaring container, instantiating cl_gui_alv_grid etc,...
When calling method 'set_table_for_first_display', use different parameters based on selection.
IF BLK1 = 'X'
CALL METHOD go_grid->set_table_for_first_display
EXPORTING i_structure_name = 'BLK1STRUCTURE'
CHANGING it_outtab = BLK1TAB.
ELSE.
CALL METHOD go_grid->set_table_for_first_display
EXPORTING i_structure_name = 'BLK2STRUCTURE'
CHANGING it_outtab = BLK2TAB.
endif.
‎2005 Oct 17 3:52 PM
Are you using function module or OO classes? What you can do is define a field symbol as "FIELD-SYMBOLS: <itab> TYPE ANY TABLE." and assign your internal table based on the block selected on the selection screen as below.
IF not s_matnr[] IS INITIAL.
ASSIGN i_matnrs[] TO <itab>.
*-- prepare the field catalogue for showing the materials
PERFORM prepare_fieldcat USING 'M'.
ELSEif not s_kunnr[] is initial.
ASSIGN i_kunnrs[] TO <itab>.
*-- prepare the field catalogue for showing the customers
PERFORM prepare_fieldcat USING 'C'.
ENDIF.
In your PERFORM prepare_fieldcat, you will always refresh the field catalog and then depending on the flag, prepare the field catalog for showing that internal table.
Then call the FM for showing the grid by passing your field symbol.