Wednesday, 8 June 2016

ALV Interactive Report using 'REUSE_ALV_EVENTS_GET' function module

Steps

  • Go to transaction code SE38.
  • Enter the program name Z or Y<program name>.
  • Click on create button.
  • Enter the tittle and Select attribute type as Executable program.

  • Click on Save.


Source Code

TABLES VBRK.

DATAIT_VBRK TYPE TABLE OF VBRK.

DATA IT_VBRP TYPE TABLE OF VBRP.

DATA IT_LIST TYPE  SLIS_T_LISTHEADER,
       WA_LIST 
LIKE LINE OF IT_LIST.

DATA IT_EVENTS TYPE  SLIS_T_EVENT,
       WA_EVENTS 
LIKE LINE OF IT_EVENTS.
SELECT-OPTIONS S_VBELN FOR VBRK-VBELN.

START-OF-SELECTION.

PERFORM FETCH_DATA USING S_VBELN[] CHANGING IT_VBRK.

PERFORM EVENTS.
PERFORM DISPLAY TABLES IT_VBRK.
*&---------------------------------------------------------------------*
*&      Form  FETCH_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_S_VBELN[]  text
*      <--P_IT_VBRK  text
*----------------------------------------------------------------------*
form FETCH_DATA  using    p_s_vbeln LIKE S_VBELN[]
                 
changing p_it_vbrk LIKE IT_VBRK.

  
SELECT FROM VBRK INTO TABLE P_IT_VBRK WHERE VBELN IN p_s_vbeln .

endform.                    " FETCH_DATA
*&---------------------------------------------------------------------*
*&      Form  DISPLAY
*&---------------------------------------------------------------------*
*       text




*----------------------------------------------------------------------*
*      -->P_IT_VBRK  text
*----------------------------------------------------------------------*
form DISPLAY  tables   p_it_vbrk LIKE IT_VBRK.
                         
"Insert correct name for <...>.

  
call function 'REUSE_ALV_GRID_DISPLAY'
   
EXPORTING
*     I_INTERFACE_CHECK                 = ' '
*     I_BYPASSING_BUFFER                = ' '
*     I_BUFFER_ACTIVE                   = ' '
     I_CALLBACK_PROGRAM                
SY-REPID
*     I_CALLBACK_PF_STATUS_SET          = ' '
*    I_CALLBACK_USER_COMMAND           =
*     I_CALLBACK_TOP_OF_PAGE            =
*     I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
*     I_CALLBACK_HTML_END_OF_LIST       = ' '
     I_STRUCTURE_NAME                  
'VBRK'
*     I_BACKGROUND_ID                   = ' '
*     I_GRID_TITLE                      =
*     I_GRID_SETTINGS                   =
*     IS_LAYOUT                         =
*     IT_FIELDCAT                       =
*     IT_EXCLUDING                      =
*     IT_SPECIAL_GROUPS                 =
*     IT_SORT                           =
*     IT_FILTER                         =
*     IS_SEL_HIDE                       =
*     I_DEFAULT                         = 'X'
*     I_SAVE                            = ' '
*     IS_VARIANT                        =
    IT_EVENTS                         
IT_EVENTS
*     IT_EVENT_EXIT                     =
*     IS_PRINT                          =
*     IS_REPREP_ID                      =
*     I_SCREEN_START_COLUMN             = 0
*     I_SCREEN_START_LINE               = 0
*     I_SCREEN_END_COLUMN               = 0
*     I_SCREEN_END_LINE                 = 0
*     I_HTML_HEIGHT_TOP                 = 0
*     I_HTML_HEIGHT_END                 = 0
*     IT_ALV_GRAPHICS                   =
*     IT_HYPERLINK                      =
*     IT_ADD_FIELDCAT                   =
*     IT_EXCEPT_QINFO                   =
*     IR_SALV_FULLSCREEN_ADAPTER        =
*   IMPORTING
*     E_EXIT_CAUSED_BY_CALLER           =
*     ES_EXIT_CAUSED_BY_USER            =
    
tables
      t_outtab                          
p_it_vbrk
   
EXCEPTIONS
     PROGRAM_ERROR                     
1
     
OTHERS                            2
            
.
  
if sy-subrc <> 0.
* Implement suitable error handling here
  
endif.




endform.                    " DISPLAY
FORM TOP_PAGE .

WA_LIST
-typ 'H'.
WA_LIST
-info 'SALES ORDER REPORT'.
APPEND WA_LIST TO IT_LIST.
CLEAR WA_LIST.

WA_LIST
-typ 'S'.
CONCATENATE SY-DATUM+6(2':' SY-DATUM+4(2':' SY-DATUM(4)
INTO WA_LIST-info.
APPEND WA_LIST TO IT_LIST.
CLEAR WA_LIST.


  call function 'REUSE_ALV_COMMENTARY_WRITE'
    
exporting
      it_list_commentary       
IT_LIST
     I_LOGO                   
'MYLOGO'
*     I_END_OF_LIST_GRID       =
*     I_ALV_FORM               =
            
.
CLEAR IT_LIST.
ENDFORM.

FORM INT1 USING RCOM TYPE SY-UCOMM
                SEL 
TYPE SLIS_SELFIELD.

  
DATA NUM(10TYPE N.
  NUM 
SEL-VALUE.
SELECT FROM VBRP INTO TABLE IT_VBRP WHERE VBELN NUM .

  
call function 'REUSE_ALV_GRID_DISPLAY'
   
EXPORTING
*     I_INTERFACE_CHECK                 = ' '
*     I_BYPASSING_BUFFER                = ' '
*     I_BUFFER_ACTIVE                   = ' '
     I_CALLBACK_PROGRAM                
SY-REPID
*     I_CALLBACK_PF_STATUS_SET          = ' '
*     I_CALLBACK_USER_COMMAND           = ' '
*     I_CALLBACK_TOP_OF_PAGE            = ' '
*     I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
*     I_CALLBACK_HTML_END_OF_LIST       = ' '
     I_STRUCTURE_NAME                  
'VBRP'
*     I_BACKGROUND_ID                   = ' '
*     I_GRID_TITLE                      =
*     I_GRID_SETTINGS                   =
*     IS_LAYOUT                         =
*     IT_FIELDCAT                       =
*     IT_EXCLUDING                      =
*     IT_SPECIAL_GROUPS                 =
*     IT_SORT                           =
*     IT_FILTER                         =
*     IS_SEL_HIDE                       =
*     I_DEFAULT                         = 'X'
*     I_SAVE                            = ' '
*     IS_VARIANT                        =
*     IT_EVENTS                         =
*     IT_EVENT_EXIT                     =
*     IS_PRINT                          =
*     IS_REPREP_ID                      =
*     I_SCREEN_START_COLUMN             = 0
*     I_SCREEN_START_LINE               = 0
*     I_SCREEN_END_COLUMN               = 0
*     I_SCREEN_END_LINE                 = 0
*     I_HTML_HEIGHT_TOP                 = 0
*     I_HTML_HEIGHT_END                 = 0
*     IT_ALV_GRAPHICS                   =
*     IT_HYPERLINK                      =
*     IT_ADD_FIELDCAT                   =
*     IT_EXCEPT_QINFO                   =
*     IR_SALV_FULLSCREEN_ADAPTER        =
*   IMPORTING
*     E_EXIT_CAUSED_BY_CALLER           =
*     ES_EXIT_CAUSED_BY_USER            =
    
tables
      t_outtab                          
IT_VBRP
   
EXCEPTIONS
     PROGRAM_ERROR                     
1
     
OTHERS                            2
            
.
  
if sy-subrc <> 0.
* Implement suitable error handling here
  
endif.



ENDFORM.
*&---------------------------------------------------------------------*
*&      Form  EVENTS
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
form EVENTS .

  
call function 'REUSE_ALV_EVENTS_GET'
*   EXPORTING
*     I_LIST_TYPE           = 0
   
IMPORTING
     ET_EVENTS             
IT_EVENTS
   
EXCEPTIONS
     LIST_TYPE_WRONG       
1
     
OTHERS                2
            
.
  
if sy-subrc <> 0.
* Implement suitable error handling here
  
endif.

CLEAR WA_EVENTS.
READ TABLE  IT_EVENTS INTO WA_EVENTS WITH  KEY NAME 'TOP_OF_PAGE'.
IF SY-SUBRC 0.
WA_EVENTS
-FORM 'TOP_PAGE'.
MODIFY IT_EVENTS FROM WA_EVENTS INDEX SY-TABIX.
ENDIF.


CLEAR WA_EVENTS.
READ TABLE  IT_EVENTS INTO WA_EVENTS WITH  KEY NAME 'USER_COMMAND'.
IF SY-SUBRC 0.
WA_EVENTS
-FORM 'INT1'.
MODIFY IT_EVENTS FROM WA_EVENTS INDEX SY-TABIX.
ENDIF.



endform.                    " EVENTS



  • Save->Check->Activate->Execute.

Input


Output


  • Double click on any line.




No comments:

Post a Comment