Posted: Tue Jan 15, 2008 2:06 pm Post subject: Switch to ALV List from ALV Grid at runtime
You have developed a ALV GRID report using REUSE_ALV_GRID_DISPLAY function and the report has come out really well. However, some users want to see a ALV list than the grid. Or you have a existing ALV GRID report and the user want to have a ALV List report.
SAP has provided a BADI just for this purpose. The name of the BADI is ALV_SWITCH_GRID_LIST . Now create a implementation for this BADI.
For a given user or specific to a report, you can switch on the flag to produce a ALV list.
Here is the simple code for the report.
Code:
REPORT Y_RAVI_REUSE_ALV.
TYPE-POOLS : SLIS.
DATA : T_DATA TYPE TABLE OF ALV_T_T2,
T_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV.
START-OF-SELECTION.
SELECT * FROM ALV_T_T2 INTO TABLE T_DATA UP TO 30 ROWS.
FIELD-SYMBOLS : <FS_FCAT> LIKE LINE OF T_FIELDCAT.
READ TABLE T_FIELDCAT ASSIGNING <FS_FCAT> with key FIELDNAME = 'PRICE'.
IF SY-SUBRC = 0.
<FS_FCAT>-DO_SUM = 'C'.
ENDIF.
DATA : WA_LAYOUT TYPE SLIS_LAYOUT_ALV.
WA_LAYOUT-allow_switch_to_list = 'X'.
DATA : WA_VARIANT TYPE DISVARIANT.
WA_VARIANT-USERNAME = SY-UNAME.
WA_VARIANT-REPORT = SY-REPID.
Here if you have noticed, there are couple of important parameters that need to be passed. Those are IS_VARAINT and IS_LAYOUT . You have to set this field allow_switch_to_list to 'X' and also pass the username and report name in the IS_VARIANT field if you want to switch to the list based on the conditions.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.