SAP ABAP Code Shrikant Naidu

Home
Site Map
What is SAP ?
SAP LSMW Explained with example
User Exits & Enhancements
Best Of SAP Links
BDC Code
SAP SmartForms Step by Step
SAP ABAP ALV Grid Explained with Example
Useful Tips
ABAP System Fields
SAP Script
SAP Script Graphics
SAPScript Print Program
ABAP ListViewer
Dialog Programming
SAP Tables
SAP ALE and IDOC
Recommended SAP ABAP Coding guidelines
SAP General ABAP
SAP Books For consultants
About Me
Contact Me
My Resume
ABAP ListViewer

ABAP ListViewer explained using Function Modules .

 

ABAP LIST VIEWER

BY:  Shrikant Naidu

Email   naidu.shrikant@rediffmail.com

Web     http://naidu.shrikant.tripod.com

 

These are the function modules used in ABAP LISTVIEWER with their details.

 

Function group : SALV

 

REUSE_ALV_COMMENTARY_WRITE     List body comment block output                                      

REUSE_ALV_EVENTS_GET           Returns table of possible events for a list type                    

REUSE_ALV_EVENTS_TRANSFER                                                                          

REUSE_ALV_EVENT_NAMES_GET      Returns table of constant names of possible events for a list type  

REUSE_ALV_FIELDCATALOG_MERGE   Create field catalog from dictionary structure or internal table    

REUSE_ALV_HIERSEQ_LIST_DISPLAY Hierarchical sequential list output                                 

REUSE_ALV_LIST_DISPLAY         Output a simple list (single line or several lines)                 

REUSE_ALV_LIST_LAYOUT_INFO_GET Read current ALV list information                                   

REUSE_ALV_LIST_LAYOUT_INFO_SET Set current ALV list information                                    

REUSE_ALV_VARIANT_DEFAULT_GET  Read default display variant (description only, w/o field catalog)

REUSE_ALV_VARIANT_F4           Display variant selection dialog box

 

Function group:SLVC_FULLSCREEN

      REUSE_ALV_GRID_COMMENTARY_SET                                         

      REUSE_ALV_GRID_DISPLAY         Output of a simple list (single-line)  

      REUSE_ALV_GRID_DISPLAY_LVC                                            

      REUSE_ALV_GRID_LAYOUT_INFO_GET Read current ALV list information

      REUSE_ALV_GRID_LAYOUT_INFO_SET Set current ALV list information

 

Function REUSE_ALV_LIST_DISPLAY

•This module outputs an internal table with any structure as a formatted one-line or multiple-line list.

PRINCIPLE:

–Pass an internal table with the set of output information

–Pass a structure with general list layout details

–Pass a field catalogue as an internal table

–The field catalogue describes the fields to be output in the list.

 

Exporting Parameters

I_INTERFACE_CHECK                  = ' '

2   I_BYPASSING_BUFFER             =

3   I_BUFFER_ACTIVE                = ' '

4   I_CALLBACK_PROGRAM             = ' '

5   I_CALLBACK_PF_STATUS_SET       = ' '

6   I_CALLBACK_USER_COMMAND        = ' '

7   I_STRUCTURE_NAME               =

8   IS_LAYOUT                       =

9   IT_FIELDCAT                     =

IT_EXCLUDING                        =

11   IT_SPECIAL_GROUPS              =

12   IT_SORT                        =

13   IT_FILTER                      =

14   IS_SEL_HIDE                    =

15   I_DEFAULT                      = 'X'

16   I_SAVE                         = ' '

17   IS_VARIANT                     =

18   IT_EVENTS                      =

19   IT_EVENT_EXIT                  =

20   IS_PRINT                       =

21   IS_REPREP_ID                   =

22   I_SCREEN_START_COLUMN          = 0

23   I_SCREEN_START_LINE            = 0

24   I_SCREEN_END_COLUMN            = 0

25   I_SCREEN_END_LINE              = 0

Import & Table parameters

IMPORTING

  E_EXIT_CAUSED_BY_CALLER       =

  ES_EXIT_CAUSED_BY_USER        =

  TABLES

    T_OUTTAB                    =

 EXCEPTIONS

  PROGRAM_ERROR                 = 1

  OTHERS           

Though the ALV function module needs 25-30 parameters to be passed, a simple report with ALV just requires these:

           CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'

 EXPORTING

   I_CALLBACK_PROGRAM            = ' '

  TABLES

    T_OUTTAB                     =

 EXCEPTIONS

   PROGRAM_ERROR                 = 1

   OTHERS                        = 2.

 

PARAMETERS TO BE PASSED TO THE STANDARD ALV FUNCTION MODULE

I_CALLBACK_PROGRAM

•Program which calls the function module and contains the exit routines. It must be a Report, Function group, Module pool or Form routine pool (not an Include).

•Note: Never pass SY-REPID directly in the interface. If the desired program name is in SY-REPID, it must be assigned to an intermediate variable which is then passed to the interface.

 IT_FIELCAT - Field catalog with field descriptions

      The field catalog for the output table is built-up in the caller's coding. The build-up can be completely or partially automated by calling the following function module

 REUSE_ALV_FIELDCATALOG_MERGE

•A field catalog need not be built-up and passed explicitly only under the following conditions:

•The internal table to be output has the same structure as a Data Dictionary structure which is referred to in the internal table declaration using LIKE or INCLUDE STRUCTURE.

•All fields in this structure are to be output

•The structure name is passed to ALV in the parameter I_STRUCTURE_NAME.

Parameters to be passed

      Positioning

   row_pos (row position) value set: 0, 1 - 3

   col_pos (column position) value set: 0, 1 – 60

      Identification

   fieldname (field name)

    tabname (internal output table)

      Data Dictionary reference

     ref_fieldname (reference field name)

     ref_tabname (reference table/structure field name)

      Link to currency unit

     cfieldname (currency unit field name)

     ctabname (internal currency unit field output table)

      Link to measurement unit

     qfieldname (measurement unit field name)

     qtabname (internal measurement unit field output table)

      Column output options

     outputlen (column width)

      key (key column)

      key_sel (hideable key column)

      no_out (field in field list)

      emphasize (highlight columns in color)

value set: SPACE, 'X' or 'Cxyz' (x:'1'-'9'; y,z: '0'=off '1'=on)

       hotspot (column as hotspot)

     fix_column (fix column)

     do_sum (sum over column)

     no_sum (sums forbidden)

       Column output options (contd.)

    input (column ready for input)

     icon

     symbol Texts

      just (justification) value set: SPACE, 'R', 'L', 'C'

     lzero (leading zeros)

     no_sign (no +/- sign )

     no_zero (suppress zeros)

     edit_mask (field formatting) value set: SPACE, template

       Texts

    The texts are taken from the Data Dictionary for fields with a Data Dictionary reference. If this is not desired, the text parameters can also be specified. The Data Dictionary texts are then ignored.

   ·         seltext_l (long field label)

   ·         seltext_m (medium field label)

   ·         seltext_s (short field label)

   ·         reptext_ddic (header)

    The specified text is not necessarily output in the list, an optimum among all texts is sought

   ·         ddictxt (specify text)

    value set: SPACE, 'L', 'M', 'S'

 

      Parameters for program fields without Data Dictionary reference

     datatype (data type ) value set: SPACE, Data Dictionary data type

     ddic_outputlen (external output length) value set: 0 (initial), n

     intlen (internal output length)value set: 0 (initial), n

      rollname (data element) value set: SPACE, Data Dictionary data element name

 

 

Priority rule:
Entries in the field catalog have priority over differing entries in the Data Dictionary.The following entries are usually sufficient for internal table fields without a reference to the Data Dictionary

                   1 Fieldname       2 Outputlen         

         3 Datatype 4  seltext_s

         5  seltext_m       6  seltext_l

•If the parameters SELTEXT_S, SELTEXT_M, SELTEXT_L, and REPTEXT_DDIC contain appropriate field labels, the program field column headers are also adjusted appropriately when the column width changes.

 

Defaults :

 The following entries are usually sufficient for internal table fields with a reference to a field defined in the Data Dictionary :

• fieldname     

• ref_tabname

ALV gets the remaining information from the Data Dictionary.

If no relative column position (COL_POS) is specified, the fields are output in the list in the order in which they were added to the field catalog.

REF_FIELDNAME need only be specified when the name of the internal table field differs from the name of the referred Data Dictionary field.

 Information which is explicitly entered in the field catalog is not overwritten by information from the Data Dictionary.

I_STRUCTURE_NAME

If the internal output table is defined via an ABAP/4 Dictionary structure (INCLUDE STRUCTURE struct or LIKE struct), the field catalog can be built-up automatically by passing the structure name.

 

 

IS_LAYOUT -List layout specifications

 

•The parameters are described under the following headers:

– Display options

–Totals

–          Interaction

–          Detail screen

– Display variants (only for hierarchical lists)

– Color

–Other

 Display options

•colwidth_optimize

•no_colhead

•zebra

•no_vline

•no_min_linesize

•max_linesize

 Exceptions

lights_fieldname value set: SPACE, internal output table field name

•lights_tabname value set: SPACE, internal output table name  

•lights_rollname value set: SPACE, data element name

•lights_condense value set: SPACE, 'X'       

 

Totals

•no_sumchoice value set: SPACE, 'X'

•no_totalline value set: SPACE, 'X'    

•no_subchoice value set: SPACE, 'X' 

•no_subtotals value set: SPACE, 'X'

•totals_only value set: SPACE, 'X'     

•totals_text value set: SPACE, string(max.60)

•subtotals_text  value set: SPACE, string(max.60)

•numc_sum  value set: SPACE, 'X'    

 Interaction

•box_fieldname value set: SPACE, internal output table field name

•box_tabname value set: SPACE, internal output table name

•no_input value set: SPACE, 'X'

•expand_fieldname value set: SPACE, internal header table field name

f2code value set: SPACE, function code

 

•confirmation_prompt value set: SPACE, 'X'

•key_hotspot value set: SPACE, 'X'        

•no_keyfix  value set: SPACE, 'X'

get_selinfos value set: SPACE, 'X'

 

Detail screen

      detail_popup value set: SPACE, 'X'   

      detail_initial_lines value set: SPACE, 'X'

      detail_titlebar value set: SPACE, string(max.30) 

Display variants  & color

      header_text value set: SPACE, CHAR(20)

      item_text value set: SPACE, CHAR(20)

      item_default value set: SPACE, 'X'

      info_fieldname value set: SPACE, internal output table field name

      coltab_fieldname value set: SPACE, internal output table field name

 

IT_SORT

      The caller specifies the sorting and/or subtotalling of the basic list in the internal table IT_SORT.

      This internal table has the following fields

    Spos                          Sort sequence

    Fieldname                Internal output table field name

    Tabname   Name of the internal output table

    Up                              'X' = sort in ascending order

    Down                         'X' = sort in descending order

    Subtot                       'X' = subtotal at group value change

    group                     '* ' = new page at group value change

                                   'UL' = underline at group value change

IT_EVENTS

      This table tells ALV which events are processed by the caller by CALLBACK.

      The table of possible events per list type can be initialized using the module REUSE_ALV_EVENTS_GET.

      You can display the names of the constants in the type pools SLIS which represent the individual events using the individual test function in the function module
REUSE_ALV_EVENT_NAMES_GET. Only events with a form routine name are processed.

 

      The table structure contains the fields:

    IT_EVENTS-NAME-Name of the Callback event.

     Action :

    USER_COMMAND

    PF_STATUS_SET

   ITEM_DATA_EXPAND

    List processing events :

   TOP_OF_LIST
   END_OF_LIST
   END_OF_PAGE
   TOP_OF_PAGE
   TOP_OF_COVERPAGE
   END_OF_COVERPAGE

    IT_EVENTS-FORM - Name of the form routine which should be called in the calling program at the event.

 

I_CALLBACK_USER_COMMAND

•EXIT routine for command handling

–Passing an EXIT routine tells ALV that the application wants to react to certain function codes itself. These are general function codes which ALV does not recognize (not ALV standard functions) and which were defined and set by an application status.

FORM user_command USING r_ucomm LIKE sy-ucomm rs_selfield TYPE slis_selfield.

–The parameter R_UCOMM contains the function code called.

 

IT_EVENT_EXIT

•Table for passing ALV standard function codes, to return control to the user before and/or after execution with the callback event USER_COMMAND.

 

 

      The table fields are as follows:

   ucomm

   before

   after

I_CALLBACK_PF_STATUS_ST

•Passing an EXIT routine tells the ALV that the caller wants to set his or her own user status.  In this case, the default ALV status is not set. The form routine interface must be defined as follows:

FORM set_pf_status USING rt_extab TYPE slis_t_extab

 

•The table RT_EXTAB contains those function codes that are hidden on the standard interface.

The structure RS_SELFIELD contains  information:

·         tabname : internal output table name

·         tabindex : internal output table index

·         fieldname: field name of cursor position

·         sel_tab_field: cell name of cursor position (internal ALV table name field

·         endsum : cursor is on the final total row

·         sumindex : if >0, the cursor is on a subtotal row

·         value : field value on the list

·         refresh : (exporting) list is to be refreshed

·         col_stable:(exporting) keep column positions in refresh

·         row_stable:(exporting) keep row positions in refresh

·         exit :(exporting) leave list (and ALV)

·         before_action: jump before performing standard action

·         after_action : jump after performing standard action, before creating list

·         ignore_multi : internal use

 

 IT_FILTER

     

      Filter criteria for first list output

      Filter criteria which result, e.g. from explicitly loading an initial display variant, can be passed to list output in this parameter. This table should never be built-up 'manually'.

 I_DEFAULT

      Initial variant logic active/inactive.

      Prerequisite: The parameter IS_VARIANT has the appropriate value

    Value Range

   SPACE = no initial variant can be defined 'X' = initial variant can be defined

    Default   SPACE

 

I_SAVE - variants can be saved

      Value Range

   ' ' = display variants cannot be saved

    'X' = standard save

   'U' = only user-specific saving

     'A' = standard and user-specific saving

 IS_VARIANT

      This structure is only relevant if display variants are to be saved and/or read

      The access path must be specified in the fields

   REPORT (required field),

   HANDLE (optional) unique user-assigned CHAR(4) field

   LOG_GROUP (optional)

I_INTERFACE_CHECK

•To avoid overloading list output with interface consistency checks, they are only made in an extra call mode.

•If this parameter is 'X', the consistency of the interface is checked when the function module is called, and an error log is output.

•This parameter should only be set for development test purposes (e.g. in debugging).

•The interface check can also be made on the results list by entering the function code &SOS.

 IS_PRINT

      Print information

      Print control parameter

    PRINT

    NO_PRINT_SELINFOS

    NO_COVERPAGE

    NO_NEW_PAGE

    RESERVE_LINES

    END_OF_PAGE

    NO_PRINT_LISTINFOS

    NO_CHANGE_PRINT_PARAMS 

 

SCREEN_SETTINGS

      Coordinates for list in dialog box

   Only to be used if the list is output in a popup.

   IT_SCREEN_START_COLUMN

   x coordinate of the top left-hand corner of the popup.

   IT_SCREEN_END_COLUMN

    x coordinate of the bottom right-hand corner of the popup.

      Coordinates for list in dialog box

   Only used if the list is output in a popup.

   IT_SCREEN_START_LINE

    y coordinate of the top left-hand corner of the popup.

   IT_SCREEN_END_LINE

   y coordinate of the bottom right-hand corner of the popup.

 

E_EXIT_CAUSED_BY_CALLER

      Delete list in CALLBACK_USER_COMMAND

   Parameter which states whether the caller left the list (SELFIELD-EXIT = 'X') in CALLBACK USER_COMMAND

 

ES_EXIT_CAUSED_BY_USER

      How the user left the list

    If one of the ALV standard function codes for 'Back', 'Cancel' or 'Exit' occurs, the current list is discarded and the ALV function module ends. In this case the exporting structure ES_EXIT_CAUSED_BY_USER contains one of the following flags:

     ES_EXIT_CAUSED_BY_USER-BACK = 'X‘

     'Back' occurred

     ES_EXIT_CAUSED_BY_USER-CANCEL = 'X'

     'Cancel' occurred

     ES_EXIT_CAUSED_BY_USER-EXIT = 'X'

     'Exit' occurred

    The function which occured determines the further navigation in the application.

 

T_OUTTAB

      Table with data to be displayed

   This table can contain more fields than are relevant for the list output (display fields and field list). Only the fields named in field catalog and the layout structure are used for the list output. Other internal table fields are ignored.

   If the internal table is defined in the calling program without a header, no F1 help is possible in the list.

  “REUSE_ALV_LIST_DISPLAY” EXCEPTIONS

      Program errors

   Exception type

   If the exception is not handled by the calling program, the following applies:
(X) an error message is sent.
( ) a termination message is sent.
( ) a runtime error occurs.

 

Note : U can query further at naidu.shrikant@rediffmail.com

Enter supporting content here

Shrikant Naidu SAP ABAP Developer (INDIA)