12 alv - abap list viewer programming

Upload: raza887

Post on 03-Apr-2018

238 views

Category:

Documents


1 download

TRANSCRIPT

  • 7/29/2019 12 ALV - ABAP List Viewer Programming

    1/5

    3/18/13 ALV - ABAP List Viewer Programming

    www.saptraininghub.com/alv-list-view-programming//

    Sap Training Hub

    Free SAP Training & Tutorials

    What is SAP?

    ABAP

    HR

    FICO

    SD

    Video

    Payroll

    Quiz

    Java

    Testing

    Answers

    ALV ABAP List Viewer Programming

    The common desired features of any report are column alignment, sorting, filtering, subtotals, totals etc. To

    implement these from scratch , a lot of coding effort is to be put. To avoid that we can use a concept called ABAP ListViewer (ALV).

    Using ALV, we can have three types of reports:

    1. Simple Report

    2. Block Report

    3. Hierarchical Sequential Report

    Each of these reports provide function modules which help in producing desired output without much effort. Lets look

    at them in detail -

    Benetech PRA

    www.benetech.com

    Interpretive software for prenatalscreening in 1st and 2nd trimesters

    K&S Associates Inc.

    www.kstrng.comProcess Systems TroubleshootingRefinery & Chemical Workshops

    Go with Gmail

    Mail.Google.com

    Free Email by Google Switch to Gmail,Sign up now!

    http://www.googleadservices.com/pagead/aclk?sa=L&ai=CfkUy_ppGUZblNoGligaxsoCYCrCHvNAD6LvfrE6n7_P9CBADIJvM7yMoA1CelbrBBWDLBKAB2Nnd3gPIAQGoAwHIA9MEqgSMAU_Qg5ySz8OcPIuSJQ1bcri5VMtVer_DrUujWnHDh8shb4X2rVbGjql5hjKZBDUf7dgFg5Ok4BemdsduACcoHQDNN45xAwqC888Mdq2nyZbsmppaRngP-uoInQWVTU4wEbyoDjlNaASj1I5EvTTp8zfK1wzJkYtEwO0kOtDCVzZ0dyA9qPp6XRFQ8vCgiAYBgAeQpqIh&num=3&cid=5GjjCXQ4GFZl3UAg96I2xo3D&sig=AOD64_0vzrr_6S3BXpKIGGJKVZ12HOFyew&client=ca-pub-6330153051175486&adurl=http://ad.doubleclick.net/clk%3B268213466%3B94044324%3Bh&nm=2http://googleads.g.doubleclick.net/aclk?sa=L&ai=C2vG7_ppGUZblNoGligaxsoCYCtDEjfACpKvqggTAjbcBEAEgm8zvIygDUPzrn-b9_____wFgywTIAQGpAndWuMpBYLA-qAMByAPTBKoEjAFP0POKlM_BnDyLkiUNW3K4uVTLVXq_w61Lo1pxw4fLIW-F9q1Wxo6peYYymQQ1H-3YBYOTpOAXpnbHbgAnKB0AzTeOcQMKgvPPDHatp8mW7JqaWkZ4D_rqCJ0FlU1OMBG8qA45TWgEo9SOBL0x6fM3ytcMyZGLRMDtJDrQwlc2dHcgPaj6el0RZO3HiYAHtJLEBw&num=1&sig=AOD64_1BvT80YChfuH0-Qw3ylQqMAZ84Lg&client=ca-pub-6330153051175486&adurl=http://www.benetech.com/pra.htm&nm=2http://www.saptraininghub.com/http://www.google.com/url?ct=abg&q=https://www.google.com/adsense/support/bin/request.py%3Fcontact%3Dabg_afc%26url%3Dhttp://www.saptraininghub.com/alv-list-view-programming/%26gl%3DPK%26hl%3Den%26client%3Dca-pub-6330153051175486%26ai0%3DC2vG7_ppGUZblNoGligaxsoCYCtDEjfACpKvqggTAjbcBEAEgm8zvIygDUPzrn-b9_____wFgywTIAQGpAndWuMpBYLA-qAMByAPTBKoEjAFP0POKlM_BnDyLkiUNW3K4uVTLVXq_w61Lo1pxw4fLIW-F9q1Wxo6peYYymQQ1H-3YBYOTpOAXpnbHbgAnKB0AzTeOcQMKgvPPDHatp8mW7JqaWkZ4D_rqCJ0FlU1OMBG8qA45TWgEo9SOBL0x6fM3ytcMyZGLRMDtJDrQwlc2dHcgPaj6el0RZO3HiYAHtJLEBw%26ai1%3DCUIBx_ppGUZblNoGligaxsoCYCrqm_KYC4quG5inAjbcBEAIgm8zvIygDUJqpjrYCYMsEyAEBqAMByAPTBKoEiQFP0OPpic_CnDyLkiUNW3K4uVTLVXq_w61Lo1pxw4fLIW-F9q1Wxo6peYYymQQ1H-3YBYOTpOAXpnbHbgAnKB0AzTeOcQMKgvPPDHatp8mW7JqaWkZ4D_rqCJ0FlU1OMBG8qA45TWgEo9SObLwv6fP1JyHSzmSIhjXu5M_T0qI1ZAIjPcj8qFLW8YAHotnjIA%26ai2%3DCfkUy_ppGUZblNoGligaxsoCYCrCHvNAD6LvfrE6n7_P9CBADIJvM7yMoA1CelbrBBWDLBKAB2Nnd3gPIAQGoAwHIA9MEqgSMAU_Qg5ySz8OcPIuSJQ1bcri5VMtVer_DrUujWnHDh8shb4X2rVbGjql5hjKZBDUf7dgFg5Ok4BemdsduACcoHQDNN45xAwqC888Mdq2nyZbsmppaRngP-uoInQWVTU4wEbyoDjlNaASj1I5EvTTp8zfK1wzJkYtEwO0kOtDCVzZ0dyA9qPp6XRFQ8vCgiAYBgAeQpqIh&usg=AFQjCNG6nnK161Avmr1KRMpKTvRY2XlJLwhttp://www.googleadservices.com/pagead/aclk?sa=L&ai=CfkUy_ppGUZblNoGligaxsoCYCrCHvNAD6LvfrE6n7_P9CBADIJvM7yMoA1CelbrBBWDLBKAB2Nnd3gPIAQGoAwHIA9MEqgSMAU_Qg5ySz8OcPIuSJQ1bcri5VMtVer_DrUujWnHDh8shb4X2rVbGjql5hjKZBDUf7dgFg5Ok4BemdsduACcoHQDNN45xAwqC888Mdq2nyZbsmppaRngP-uoInQWVTU4wEbyoDjlNaASj1I5EvTTp8zfK1wzJkYtEwO0kOtDCVzZ0dyA9qPp6XRFQ8vCgiAYBgAeQpqIh&num=3&cid=5GjjCXQ4GFZl3UAg96I2xo3D&sig=AOD64_0vzrr_6S3BXpKIGGJKVZ12HOFyew&client=ca-pub-6330153051175486&adurl=http://ad.doubleclick.net/clk%3B268213466%3B94044324%3Bh&nm=2http://googleads.g.doubleclick.net/aclk?sa=L&ai=CUIBx_ppGUZblNoGligaxsoCYCrqm_KYC4quG5inAjbcBEAIgm8zvIygDUJqpjrYCYMsEyAEBqAMByAPTBKoEiQFP0OPpic_CnDyLkiUNW3K4uVTLVXq_w61Lo1pxw4fLIW-F9q1Wxo6peYYymQQ1H-3YBYOTpOAXpnbHbgAnKB0AzTeOcQMKgvPPDHatp8mW7JqaWkZ4D_rqCJ0FlU1OMBG8qA45TWgEo9SObLwv6fP1JyHSzmSIhjXu5M_T0qI1ZAIjPcj8qFLW8YAHotnjIA&num=2&sig=AOD64_18xWdbgDMKnB_M9YRkWmaCfSXP2A&client=ca-pub-6330153051175486&adurl=http://www.kstrng.com&nm=3http://googleads.g.doubleclick.net/aclk?sa=L&ai=C2vG7_ppGUZblNoGligaxsoCYCtDEjfACpKvqggTAjbcBEAEgm8zvIygDUPzrn-b9_____wFgywTIAQGpAndWuMpBYLA-qAMByAPTBKoEjAFP0POKlM_BnDyLkiUNW3K4uVTLVXq_w61Lo1pxw4fLIW-F9q1Wxo6peYYymQQ1H-3YBYOTpOAXpnbHbgAnKB0AzTeOcQMKgvPPDHatp8mW7JqaWkZ4D_rqCJ0FlU1OMBG8qA45TWgEo9SOBL0x6fM3ytcMyZGLRMDtJDrQwlc2dHcgPaj6el0RZO3HiYAHtJLEBw&num=1&sig=AOD64_1BvT80YChfuH0-Qw3ylQqMAZ84Lg&client=ca-pub-6330153051175486&adurl=http://www.benetech.com/pra.htm&nm=2http://www.83answers.com/http://www.guru99.com/http://www.javatutorialhub.com/http://www.saptraininghub.com/quiz/http://www.saptraininghub.com/sap-payroll/http://www.saptraininghub.com/sapvideos/http://www.saptraininghub.com/free-sap-sd-training-course/http://www.saptraininghub.com/sap-fico-training-tutorials/http://www.saptraininghub.com/sap-hcm/http://www.saptraininghub.com/abap-tutorial/http://www.saptraininghub.com/what-is-sap/http://feeds.feedburner.com/SapTrainingHubhttp://www.facebook.com/pages/Sap-Training-Hub/139632216092864http://twitter.com/SAPTHubhttp://www.saptraininghub.com/
  • 7/29/2019 12 ALV - ABAP List Viewer Programming

    2/5

    3/18/13 ALV - ABAP List Viewer Programming

    www.saptraininghub.com/alv-list-view-programming//

    Simple Report

    Important function modules in these report are -

    Reuse_alv_fieldcatalog_merge

    Reuse_alv_list_display

    Reuse_alv_events_get

    Reuse_alv_grid_display

    Reuse_alv_commentary_write

    REUSE_ALV_FIELDCATALOG_MERGE

    This function module is used to populate a field catalog which is essential to display the data in ALV.

    If the output data is from a single dictionary table and all the columns are selected, then we need not exclusively create

    the field catalog. Its enough to mention the table name as a parameter (I_structure_name) in the

    REUSE_ALV_LIST_DISPLAY. But in other cases we need to create it.

    Note : Fieldcatalog can be filled manually also by filling up all the required details into the internal table

    Important parameters in are:

    1. Export:

    I_program_name : report id

    I_internal_tabname : the internal output table

    I_inclname : include or the report name where all the dynamic forms are handled.

    2. Changing

    ct_fieldcat : an internal table with the type SLIS_T_FIELDCAT_ALV which is declared in the type pool SLIS.

    REUSE_ALV_LIST_DISPLAY

    This is the function module which prints the data.

    The important parameters are:

    1. Export:

    I_callback_program : report id

    I_bypassing_buffer : X

    I_buffer_active :

    I_callback_pf_status_set : routine where a user can set his own pf status or change the functionality of the existing

    pf status.

    I_callback_user_command : routine where the function codes are handled.

    I_structure name : name of the dictionary table

    Is_Layout : structure to set the layout of the report

    It_fieldcat : internal table with the list of all fields and their attributes which are to be printed (this table can be

    populated automatically by the function)

  • 7/29/2019 12 ALV - ABAP List Viewer Programming

    3/5

    3/18/13 ALV - ABAP List Viewer Programming

    www.saptraininghub.com/alv-list-view-programming//

    It_events : internal table with a list of all possible events of ALV and their corresponding form names.

    2. Tables:

    a. t_outtab : internal table with the data to be output

    REUSE_ALV_EVENTS_GET:

    Returns table of possible events for a a list type

    1. Import:

    Et_Events :The event table is returned with all possible CALLBACK events for the specified list type (column

    NAME). For events to be processed by the Callback, their FORM field must be filled. If the field is initialized, the

    event is ignored. The entry can be read from the event table, the field FORM filled and the entry modified using

    constants from the type pool SLIS.

    2. Export:

    I_list_type: 0 = simple list REUSE_ALV_LIST_DISPLAY

    1 = hierarchical-sequential list REUSE_ALV_HIERSEQ_LIST_DISPLAY

    2 = simple block list REUSE_ALV_BLOCK_LIST_APPEND

    3 = hierarchical-sequential block list REUSE_ALV_BLOCK_LIST_HS_APPEND

    REUSE_ALV_GRID_DISPLAY

    A new function from ABAP4.6 version, to display the results in grid rather than a preview.

    Parameters : same as reuse_alv_list_display

    Note:Grid cannot handle high volumes. Functions like sort, scrolling down consumes a lot of resources /

    time if the volume of data to be displayed is high. There is no clear cut definition such that if the amount of

    data is X go for list or grid but the developer has to take a call based on his experience. If not sure, then

    list is the better option

    REUSE_ALV_COMMENTARY_WRITE

    This is used in the Top-of-page event to print the headings and other comments for the list.

    Important Parameters

    It_list_commentary : Internal table with the headings of the type slis_t_listheader.

    This internal table has three fields:

    1. Typ : H header, S selection, A action

    2. Key : only when typ is S.

    3. Info : the text to be printed

  • 7/29/2019 12 ALV - ABAP List Viewer Programming

    4/5

    3/18/13 ALV - ABAP List Viewer Programming

    www.saptraininghub.com/alv-list-view-programming//

    Block Report

    This looks like a simple report but this report has the features of sorting and filtering only.This report is used if you have

    to display more than one report on the output. Technically speaking if you have multiple internal table with data to be

    displayed as separate blocks then we go for block report of ALV.

    The important functions used for creating this report are:

    REUSE_ALV_BLOCK_LIST_INIT

    REUSE_ALV_BLOCK_LIST_APPEND

    REUSE_ALV_BLOCK_LIST_DISPLAY

    REUSE_ALV_BLOCK_LIST_INIT

    This function module is used to set the default gui status etc. The parameters are similar to the one used in

    reuse_alv_list_display or reuse_alv_grid_display

    REUSE_ALV_BLOCK_LIST_APPEND

    This function module adds the data to the block.

    Important Parameters

    1.Export :

    is_layout : layout settings for block

    it_fieldcat : field catalog

    I_tabname : internal table name with all all possible events

    2.Tables :

    t_outtab : internal table with output data.

    REUSE_ALV_BLOCK_LIST_DISPLAY

    This function module display the list with data appended by the above function.

    Parameters : All the parameters are optional.

    Hierarchical Reports

    Hierarchical display is used for displaying data that are related. Like sales order and item details. Here sales order

    details can be the header data whereas them items in the sales order can be the item data

    The function module used for this is

    REUSE_ALV_HIERSEQ_LIST_DISPLAY

    Export:

    I_CALLBACK_PROGRAM

  • 7/29/2019 12 ALV - ABAP List Viewer Programming

    5/5

    3/18/13 ALV - ABAP List Viewer Programming

    www.saptraininghub.com/alv-list-view-programming//

    I_CALLBACK_PF_STATUS_SET

    I_CALLBACK_USER_COMMAND

    IS_LAYOUT

    It_fieldcat

    It_events

    I_tabname_header : Name of the internal table in the program containing the output data of the highest hierarchy

    level.

    I_tabname_item : Name of the internal table in the program containing the output data of the lowest hierarchy

    level.

    Is_keyinfo : This structure contains the header and item table field names which link the two tables (shared key).

    Tables

    t_outtab_header : Header table with data to be output

    t_outtab_item : Name of the internal table in the program containing the output data of the lowest hierarchy level.

    All the definitions of internal tables, structures and constants are declared in a type-pool called SLIS. This internal table

    can be populated automatically by using REUSE_ALV_FIELDCATALOG_MERGE.

    Display Variants

    Display variants are used to set the default properties of an alv output like sort criteria, filtering criteria, totaling

    and subtotaling etc

    Display variants can be user specific and standard (standard variants can be used by any user )

    Kind of display variants that can be saved is controlled by the parameter i_save that is passed in function

    modules reuse_alv_list_display / reuse_alv_grid_display

    You can provide an option on the selection screen to select what display variant to be used

    The common function modules related to selecting / validating display variants are

    1. Reuse_alv_variant_default_get

    2. Reuse_alv_variant_f4

    3. Reuse_alv_variant_existence

    Thats all to ABAP- ALV programming!

    You might like:

    Recommended by

    Share6 Tweet0 Share0 +13 Share532

    On January 19, 2011 / ABAP / Comments Off

    How to become SAP

    consultant

    Create Material

    Master for Sales

    View

    How To Delete a

    Client

    What is User and

    Customer Exits

    LSMW Data

    Migration - Step by

    Step

    http://www.saptraininghub.com/lsmw-data-migration-step-by-step/http://www.saptraininghub.com/what-is-user-and-customer-exits/http://www.saptraininghub.com/how-to-delete-a-client/http://www.saptraininghub.com/create-material-master-for-sales-view/http://www.saptraininghub.com/how-to-become-sap-consultant/http://www.saptraininghub.com/lsmw-data-migration-step-by-step/http://www.saptraininghub.com/what-is-user-and-customer-exits/http://www.saptraininghub.com/how-to-delete-a-client/http://www.saptraininghub.com/create-material-master-for-sales-view/http://www.saptraininghub.com/how-to-become-sap-consultant/http://www.saptraininghub.com/abap/