Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
kasralikarpratik
Explorer
There are many way's to display ALV. Either using REUSE_ALV function modules or CL_GUI_ALV_GRID class. But these methods somehow doesn't give you easy option to display internal table directly in ALV format. You need to either build field catalog, layouts and sometime custom containers. 

If you want to display the ALV with many other functionalities like adding buttons/ events and also editable options you may need to write some more logic but Most of the requirements are just to display the result and not doing much. For example, displaying log or normal report to show material data or customer data. in these scenario's below logic will help you.

The option i am using here is CL_SALV_TABLE.

Here you go 

Step 1:
  CL_SALV_TABLE=>FACTORY( IMPORTING R_SALV_TABLE = GREF_TABLE
CHANGING T_TABLE = IM_TABLE ).

Step 2:
GREF_TABLE->DISPLAY( ).

That's it. It will show you result in ALV format. Here GREF_TABLE refers to CL_SALV_TABLE

In this case it will take the data element field labels will be used as it is to display the ALV. In most of the scenario's it will be the same. If you want to change the column you can definitely do it using CL_SALV_COLUMNS_TABLE and CL_SALV_COLUMN
DATA(GREF_COLUMNS) = GREF_TABLE->GET_COLUMNS( ).

DATA(GREF_COLUMN) = GREF_COLUMNS->GET_COLUMN( COLUMNNAME = 'COLUMN NAME' ).

GREF_COLUMN->SET_SHORT_TEXT( 'COLUMN SHORT TEXT' ).
GREF_COLUMN->SET_MEDIUM_TEXT( 'COLUMN MEDIUM TEXT' ).
GREF_COLUMN->SET_LONG_TEXT( 'COLUMN LONG TEXT' ).

You can also set status for your ALV report
GREF_TABLE->SET_SCREEN_STATUS( EXPORTING REPORT        = 'SAPLKKBL'
PFSTATUS = 'STD_LIGHT_FULLSCREEN'
SET_FUNCTIONS = GREF_TABLE->C_FUNCTIONS_ALL ).

Conclusion:

You can use many way's to display the report but this one I felt the easiest approach to display ALV with very few lines of code.

See you all in next post.
14 Comments