Tuesday, 7 June 2016

ALV report using Autofield catalog


  • "Field catalog decides output field position , length and description of field  etc. based on structure".
  • Function Module : REUSE_ALV_FIELDCATALOG_MERGE .


Steps

  • Go to transaction code SE38.

  • Enter the program name Z or Y<program name>.
  • Select attribute type as Executable program.


  • Click on Save.


Source Code

TYPE-POOLS : SLIS.

DATA BEGIN OF IT OCCURS 0,
        VBELN 
LIKE VBAK-VBELN,
        POSNR 
LIKE VBAP-POSNR,
        VKORG 
LIKE VBAK-VKORG,
        KUNNR 
LIKE VBAK-KUNNR,
        MATNR 
LIKE VBAP-MATNR,
        ARKTX 
LIKE VBAP-ARKTX,
        NETWR 
LIKE VBAP-NETWR,
      
END OF IT.


DATA CT_FIELDCAT TYPE  SLIS_T_FIELDCAT_ALV.
SELECT-OPTIONS S_VBELN FOR IT-VBELN.


START-OF-SELECTION.

SELECT A~VBELN
       POSNR
       VKORG
       KUNNR
       MATNR
       ARKTX
       B
~NETWR INTO TABLE IT FROM VBAK AS A INNER JOIN VBAP AS B
  
ON A~VBELN B~VBELN WHERE A~VBELN IN S_VBELN.


  
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
  
EXPORTING
     I_PROGRAM_NAME               
SY-REPID
    I_INTERNAL_TABNAME           
'IT'
*     I_STRUCTURE_NAME             = 'IT'
*     I_CLIENT_NEVER_DISPLAY       = 'X'
     I_INCLNAME                   
SY-REPID
*     I_BYPASSING_BUFFER           =
*     I_BUFFER_ACTIVE              =
    
changing
      ct_fieldcat                  
CT_FIELDCAT
   
EXCEPTIONS
     INCONSISTENT_INTERFACE       
1
     PROGRAM_ERROR                
2
     
OTHERS                       3
            
.
  
if sy-subrc <> 0.
* Implement suitable error handling here
  
endif.

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                  =
*   I_BACKGROUND_ID                   = ' '
*   I_GRID_TITLE                      =
*   I_GRID_SETTINGS                   =
*   IS_LAYOUT                         =
   IT_FIELDCAT                       
CT_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[]
 
EXCEPTIONS
   PROGRAM_ERROR                     
1
   
OTHERS                            2
          
.
if sy-subrc <> 0.
* Implement suitable error handling here
endif.






Input



Output




2 comments:

  1. TYPE-POOLS : SLIS has to be declared.

    ReplyDelete
    Replies
    1. Declaration of TYPE-POOLS : SLIS require ECC 6.0 , from ECC 7.4 not require

      Delete