Can we create ALV report in CO module

Hi All,
Can we create ALV reports in CO( controlling area ) module like MM and SD.
i m new to CO module, pls suggest me in this case.
my requirement is to generate a report on ' estate general charges by company'
Thanks
Mona

Hi,
look whatever the module may be , if you store your result in an internal table , you can display it with ALV.
ALV is, as you know, nothing but a way to display list in better way. SO get your data and design a field catalog according and use any ALV disply function to display it.
Regards,
Anirban

Similar Messages

  • Need to create alv report to show pan card number.

    Hi,
    I need to create alv report to show employee and vendor  name , number ,  Pan card number .This is for hr module.
    could any one tell me table and fields for this and how I can relate them with foriegn and primary key.
    Regards,
    Moderator Message: Do your own work
    Edited by: kishan P on Oct 5, 2010 10:38 AM

    Yes, but it only has one generic Date column, no start date and end date. I can't use that twice in the prompt. Although I can specify it to be 'between', but I'm not sure I can pass values to both variables like that.
    Currently I have used Campaign Start Date and Campaign End Date to enter values in calender format to the variables.

  • I m in urgent need of sme alv reports in sd module so plz hlp me out.

    i m in urgent need of sme alv reports in sd module so plz hlp me out.
    if possible plz provide explanation so tht i can understand it fast and well.

    check with below standard reports :
    Sales summary - VC/2
    Display Customer Hierarchy - VDH2
    Display Condition record report - V/I6
    Pricing Report - V/LD
    Create Net Price List - V_NL
    List customer material info - VD59
    List of sales order - VA05
    List of Billing documents - VF05
    Inquiries list - VA15
    Quotation List - VA25
    Incomplete Sales orders - V.02
    Backorders - V.15
    <b>Outbound Delivery Monitor - VL06o
    Incomplete delivery - V_UC</b>Customer
    Returns-Analysis - MC+A
    Customer Analysis- Sales - MC+E
    Customer Analysis- Cr. Memo - MC+I
    Deliveries-Due list - VL04
    Billing due list - VF04
    Incomplete Billing documents - MCV9
    Customer Analysis-Basic List - MCTA
    Material Analysis(SIS) - MCTC
    Sales org analysis - MCTE
    Sales org analysis-Invoiced sales - MC+2
    Material Analysis-Incoming orders - MC(E
    General- List of Outbound deliveries - VL06f
    Material Returns-Analysis - MC+M
    Material Analysis- Invoiced Sales - MC+Q
    Variant configuration Analysis - MC(B
    Sales org analysis-Incoming orders - MC(I
    Sales org analysis-Returns - MC+Y
    Sales office Analysis- Invoiced Sales - MC-E
    Sales office Analysis- Returns - MC-A
    Shipping point Analysis - MC(U
    Shipping point Analysis-Returns - MC-O
    <b>Blocked orders - V.14</b>
    Order Within time period - SD01
    Duplicate Sales orders in period - SDD1
    Display Delivery Changes - VL22
    Simple example what  i did - Monthly Sales Report
    TYPE-POOLS
    type-pools : slis.
    Tables
    tables : VBAK,
             VBAP.
    Internal table for VBAK Table
    data : begin of i_vbak occurs 0,
           vbeln like vbak-vbeln,
           bstnk like vbak-bstnk,
           vdatu like vbak-vdatu,
           end of i_vbak.
    Internal table for VBAP and MATNR
    data : begin of i_vbap occurs 0,
           vbeln like vbap-vbeln,
           matnr like vbap-matnr,
           kdmat like vbap-kdmat,
           kwmeng like vbap-kwmeng,
           netpr like vbap-netpr,
           maktx like makt-maktx,
           end of i_vbap.
    Internal tables
    data : begin of i_sales occurs 0,
           vdatu like vbak-vdatu,
           bstnk like vbak-bstnk,
           matnr like vbap-matnr,
           maktx like makt-maktx,
           kdmat like vbap-kdmat,
           kwmeng like vbap-kwmeng,
           netpr  like vbap-netpr,
           end of i_sales.
    Variable for ALV
    data : v_repid like sy-repid,
           gt_fieldcat    type slis_t_fieldcat_alv.
    Selection-screen
    selection-screen : begin of block blk with frame title text-001.
    select-options : s_vbeln for vbak-vbeln,
                     s_erdat for vbak-erdat,
                     s_ernam for vbak-ernam,
                     s_vdatu for vbak-vdatu obligatory,
                     s_BSTNK for vbak-BSTNK,
                     s_KUNNR for vbak-kunnr,
                     s_matnr for vbap-matnr,
                     s_KDMAT for vbap-KDMAT.
    selection-screen : end of block blk.
    Initilization
    initialization.
      v_repid = sy-repid.
    S T A R T  -  O F  -  S E L E C T I O N ****************
    start-of-selection.
    Get the data from VBAK and VBAP Tables
      perform get_vbak_vbap.
    E N D  -  O F  -  S E L E C T I O N *****************
    end-of-selection.
    Display the data
      perform dispolay_data.
    *&      Form  get_vbak_vbap
          Get the data from VBAK and VBAP Table
    FORM get_vbak_vbap.
    Get the data from VBAK Table
      select vbeln bstnk vdatu from vbak into table i_vbak
                         where vbeln in s_vbeln
                         and   bstnk in s_bstnk
                         and   vdatu in s_vdatu
                         and   kunnr in s_kunnr
                         and   erdat in s_erdat
                         and   ernam in s_ernam.
      if sy-subrc ne 0.
        message e000(zwave) with 'No data found for given selection'.
      endif.
    Get the data from VBAP Table
      select avbeln amatnr akdmat akwmeng a~netpr
             b~maktx into table i_vbap
             from vbap as a inner join makt as b on bmatnr = amatnr
             for all entries in i_vbak
             where a~vbeln in s_vbeln
             and   a~kdmat in s_kdmat
             and   a~abgru = space
             and   a~matnr in s_matnr
             and   a~matnr ne '000000000000009999'
             and   a~matnr ne '000000000000004444'
             and   a~matnr ne '000000000000008888'
             and   a~matnr ne '000000000000001111'
             and   a~werks = '1000'
             and   b~spras = 'E'
             and   a~vbeln = i_vbak-vbeln.
      if sy-subrc ne 0.
        message e000(zwave) with 'No data found for given selection'.
      endif.
      sort i_vbak by vbeln.
      sort i_vbap by vbeln matnr.
      loop at i_vbap.
        read table i_vbak with key vbeln = i_vbap-vbeln
                                binary search.
        if sy-subrc eq 0.
          i_sales-bstnk = i_vbak-bstnk.
          i_sales-vdatu = i_vbak-vdatu.
          i_sales-matnr = i_vbap-matnr.
          i_sales-kdmat = i_vbap-kdmat.
          i_sales-maktx = i_vbap-maktx.
          i_sales-netpr = i_vbap-netpr.
          i_sales-kwmeng = i_vbap-kwmeng.
          append i_sales.
        else.
          continue.
        endif.
        clear : i_sales,
                i_vbap,
                i_vbak.
      endloop.
      sort i_sales by vdatu bstnk matnr.
      refresh : i_vbap,
                i_vbak.
    ENDFORM.                    " get_vbak_vbap
    *&      Form  dispolay_data
          Display the data
    FORM dispolay_data.
    Fill the Fiedlcat
      PERFORM fieldcat_init  using gt_fieldcat[].
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                =
      I_BUFFER_ACTIVE                   = ' '
          I_CALLBACK_PROGRAM                = v_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                       = gt_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
      IT_ALV_GRAPHICS                   =
      IT_ADD_FIELDCAT                   =
      IT_HYPERLINK                      =
      I_HTML_HEIGHT_TOP                 =
      I_HTML_HEIGHT_END                 =
      IT_EXCEPT_QINFO                   =
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
        TABLES
          T_OUTTAB                          = i_sales
    EXCEPTIONS
      PROGRAM_ERROR                     = 1
      OTHERS                            = 2
    ENDFORM.                    " dispolay_data
    *&      Form  fieldcat_init
          text
         -->P_GT_FIELDCAT[]  text
    FORM fieldcat_init USING  e01_lt_fieldcat type slis_t_fieldcat_alv.
      DATA: LS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
    Delivery Date
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-FIELDNAME    = 'VDATU'.
      LS_FIELDCAT-OUTPUTLEN    = 12.
      LS_FIELDCAT-TABNAME    = 'I_SALES'.
      ls_fieldcat-seltext_L = 'Delivery Date'.
      APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
    Purchase Order #Material Description
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-FIELDNAME    = 'BSTNK'.
      LS_FIELDCAT-OUTPUTLEN    = 25.
      LS_FIELDCAT-TABNAME    = 'I_SALES'.
      ls_fieldcat-seltext_L = 'Purchase Order #'.
      APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
    Material
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-REF_FIELDNAME    = 'MATNR'.
      LS_FIELDCAT-REF_TABNAME    = 'MARA'.
      LS_FIELDCAT-FIELDNAME    = 'MATNR'.
      LS_FIELDCAT-TABNAME    = 'I_SALES'.
      ls_fieldcat-seltext_L = 'Material #'.
      ls_fieldcat-seltext_M = 'Material #'.
      ls_fieldcat-seltext_S = 'Material #'.
      APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
    Material Description
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-FIELDNAME    = 'MAKTX'.
      LS_FIELDCAT-OUTPUTLEN    = 40.
      LS_FIELDCAT-TABNAME    = 'I_SALES'.
      ls_fieldcat-seltext_L = 'Material Description'.
      APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
    Customer Material #
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-FIELDNAME    = 'KDMAT'.
      LS_FIELDCAT-OUTPUTLEN    = 35.
      LS_FIELDCAT-TABNAME    = 'I_SALES'.
      ls_fieldcat-seltext_L = 'Customer material no.'.
      APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
    Quantity
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-FIELDNAME    = 'KWMENG'.
      LS_FIELDCAT-OUTPUTLEN    = 15.
      LS_FIELDCAT-TABNAME    = 'I_SALES'.
      ls_fieldcat-seltext_L = 'Quantity'.
      APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
    Net Price
      CLEAR LS_FIELDCAT.
      LS_FIELDCAT-FIELDNAME    = 'NETPR'.
      LS_FIELDCAT-OUTPUTLEN    = 15.
      LS_FIELDCAT-TABNAME    = 'I_SALES'.
      ls_fieldcat-seltext_L = 'Net Price'.
      APPEND LS_FIELDCAT TO E01_LT_FIELDCAT.
    ENDFORM.                    " fieldcat_init
    Thanks
    Seshu

  • Example of  a Simple ALV Report using Function Modules (not OO)

    Hi,
    I am new to ABAP. Where can I get a proper Example of  a Simple ALV Report using Function Modules?  I searched the forum but did not find a proper solution. Kindly help.
    Smruthi.
    Edited by: Smruthi Acharya on Jan 29, 2009 7:13 PM

    Hi,
    Use this demo code:-
    REPORT  z_alv01 MESSAGE-ID zmsg.
    *          TABLES
    TABLES : ekpo.
    *          TYPE POOLS
    TYPE-POOLS : slis.
    *          TYPE DECLARATION
    TYPES : BEGIN OF t_ekpo,
              ebeln TYPE ekpo-ebeln,
              ebelp TYPE ekpo-ebelp,
              matnr TYPE ekpo-matnr,
              werks TYPE ekpo-werks,
              menge TYPE ekpo-menge,
            END OF t_ekpo.
    *          PARAMETERS
    PARAMETERS : s_var TYPE disvariant-variant.
    *          DATA DECLARATION
    *VARIABLES
    DATA : check(1),
           rep_id TYPE sy-repid.
    *INTERNAL TABLE TYPE OF ZEKPO
    DATA : it_ekpo TYPE STANDARD TABLE OF t_ekpo WITH HEADER LINE.
    *FIELD CATALOG
    DATA : it_field TYPE slis_t_fieldcat_alv,
           wa_field TYPE slis_fieldcat_alv.
    *SORTING
    DATA : it_sort TYPE slis_t_sortinfo_alv,
           wa_sort TYPE slis_sortinfo_alv.
    *FOR TOP OF THE PAGE
    DATA : it_top TYPE slis_t_listheader,
           wa_top TYPE slis_listheader.
    *FOR END OF THE PAGE
    DATA : it_end TYPE slis_t_listheader,
           wa_end TYPE slis_listheader.
    *TO CAPTURE EVENTS AND HANDLE
    DATA : it_event TYPE slis_t_event,
           wa_event TYPE slis_alv_event.
    *FOR GRID TITLE
    DATA : wa_title TYPE lvc_title.
    *FOR LAYOUT
    DATA : wa_layout TYPE slis_layout_alv.
    *FOR EXCLUDING STANDARD BUTTON FROM ALV TOOLBAR
    DATA : it_exclude TYPE slis_t_extab,
           wa_exclude TYPE slis_extab.
    *FOR VARIANT
    DATA : wa_variant TYPE disvariant.
    *          INITIALIZATION
    INITIALIZATION.
      check = 'X'.
      rep_id = sy-repid.
      wa_variant-report = sy-repid.
    *GET DEFUALT ON THE SELECTION SCREEN FOR DEFAULT DISPLAY
      CALL FUNCTION 'REUSE_ALV_VARIANT_DEFAULT_GET'
        EXPORTING
          i_save        = 'A'
        CHANGING
          cs_variant    = wa_variant
        EXCEPTIONS
          wrong_input   = 1
          not_found     = 2
          program_error = 3
          OTHERS        = 4.
      IF sy-subrc = 0.               " IF DEFAULT VARIANT FOUND
        s_var = wa_variant-variant.  " PASS THE DEFAULT VARIANT TO THE SELECTION SCREEN FIELD
      ENDIF.
    *          AT-SELECTION SCREEN ON VALUE REQUEST
    *          TO GET THE F4 HELP FOR VARIANT
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR s_var.
      CALL FUNCTION 'REUSE_ALV_VARIANT_F4'
        EXPORTING
          is_variant                = wa_variant
    *   I_TABNAME_HEADER          =
    *   I_TABNAME_ITEM            =
    *   IT_DEFAULT_FIELDCAT       =
         i_save                    = 'A'
    *   I_DISPLAY_VIA_GRID        = ' '
       IMPORTING
    *   E_EXIT                    =
         es_variant                = wa_variant
       EXCEPTIONS
         not_found                 = 1
         program_error             = 2
         OTHERS                    = 3.
      IF sy-subrc = 0.
        s_var = wa_variant-variant. " PASS THE SELECTED VARIANT TO THE SELECTION SCREEN FIELD
      ENDIF.
    *          AT-SELECTION SCREEN
    *          TO CHECK THE EXISTENCE FOR VARIANT
    AT SELECTION-SCREEN.
      wa_variant-variant = s_var.
      CALL FUNCTION 'REUSE_ALV_VARIANT_EXISTENCE'
        EXPORTING
          i_save        = 'A'
        CHANGING
          cs_variant    = wa_variant
        EXCEPTIONS
          wrong_input   = 1
          not_found     = 2
          program_error = 3
          OTHERS        = 4.
      IF sy-subrc <> 0.
        MESSAGE w001.
      ENDIF.
    *          START OF SELECTION
    START-OF-SELECTION.
      SELECT ebeln
             ebelp
             matnr
             werks
             menge
             FROM ekpo
             INTO TABLE it_ekpo.
    *          FIELD CATALOG
      wa_field-fieldname = 'EBELN'.
      wa_field-tabname = 'IT_TAB'.
      wa_field-outputlen = 10.
      wa_field-seltext_l = 'PO #'.
      APPEND wa_field TO it_field.
      CLEAR wa_field.
      wa_field-fieldname = 'EBELP'.
      wa_field-tabname = 'IT_TAB'.
      wa_field-outputlen = 10.
      wa_field-seltext_l = 'Line Item'.
      APPEND wa_field TO it_field.
      CLEAR wa_field.
      wa_field-fieldname = 'MATNR'.
      wa_field-tabname = 'IT_TAB'.
      wa_field-outputlen = 15.
      wa_field-seltext_l = 'Material'.
    *  wa_field-input = check.
    *  wa_field-edit = check.
      APPEND wa_field TO it_field.
      CLEAR wa_field.
      wa_field-fieldname = 'WERKS'.
      wa_field-tabname = 'IT_TAB'.
      wa_field-outputlen = 6.
      wa_field-seltext_l = 'Plant'.
    *  wa_field-input = check.
    *  wa_field-edit = check.
      APPEND wa_field TO it_field.
      CLEAR wa_field.
      wa_field-fieldname = 'MENGE'.
      wa_field-tabname = 'IT_TAB'.
      wa_field-outputlen = 10.
      wa_field-seltext_l = 'Qty.'.
    *  wa_field-input = check.
    *  wa_field-edit = check.
      wa_field-do_sum = check.
      APPEND wa_field TO it_field.
      CLEAR wa_field.
    *          SORT W.R.T. PURCHASE ORDER NUMBER
      wa_sort-spos = 1.
      wa_sort-fieldname = 'EBELN'.
      wa_sort-tabname = 'IT_EKPO'.
      wa_sort-up = check.
      wa_sort-subtot = check.
      APPEND wa_sort TO it_sort.
      CLEAR wa_sort.
    *          FOR GRID TITLE
      wa_title = 'Hello'.
    *          FOR LAYOUT
      wa_layout-zebra = check.
    *          FOR EXCLUDING STANDARD BUTTONS FROM ALV TOOLBAR
      wa_exclude-fcode = '&OUP'.
      APPEND wa_exclude TO it_exclude.
      CLEAR wa_exclude.
      wa_exclude-fcode = '&ODN'.
      APPEND wa_exclude TO it_exclude.
      CLEAR wa_exclude.
      wa_exclude-fcode = '&OAD'.
      APPEND wa_exclude TO it_exclude.
      CLEAR wa_exclude.
    *  wa_exclude-fcode = '&AVE'.
    *  APPEND wa_exclude TO it_exclude.
    *  CLEAR wa_exclude.
      wa_exclude-fcode = '&INFO'.
      APPEND wa_exclude TO it_exclude.
      CLEAR wa_exclude.
    *          POPULATE ALL EVENTS INTO INTERNAL TABLE
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 0
        IMPORTING
          et_events       = it_event
        EXCEPTIONS
          list_type_wrong = 1
          OTHERS          = 2.
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      READ TABLE it_event INTO wa_event WITH KEY name = 'END_OF_LIST'.
      wa_event-form = 'END'.
      MODIFY it_event FROM wa_event INDEX sy-tabix.
      CLEAR wa_event.
    *          DISPLAY RECORDS IN ALV GRID
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
    *   I_INTERFACE_CHECK                 = ' '
    *   I_BYPASSING_BUFFER                = ' '
    *   I_BUFFER_ACTIVE                   = ' '
       i_callback_program                = rep_id
    *   i_callback_pf_status_set          = 'PF'
       i_callback_user_command           = 'COMMAND'
       i_callback_top_of_page            = 'TOP'
    *   I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
    *   I_CALLBACK_HTML_END_OF_LIST       = ' '
    *   I_STRUCTURE_NAME                  =
    *   I_BACKGROUND_ID                   = ' '
       i_grid_title                      = wa_title
    *   I_GRID_SETTINGS                   =
       is_layout                         = wa_layout
       it_fieldcat                       = it_field
       it_excluding                      = it_exclude
    *   IT_SPECIAL_GROUPS                 =
       it_sort                           = it_sort
    *   IT_FILTER                         =
    *   IS_SEL_HIDE                       =
    *   I_DEFAULT                         = 'X'
       i_save                            = 'A'
       is_variant                        = wa_variant
       it_events                         = it_event
    *   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_ekpo
    EXCEPTIONS
       program_error                     = 1
       OTHERS                            = 2.
      IF sy-subrc <> 0.
      ENDIF.
    *&      Form  top
    *       TO WRITE THE HEADER
    FORM top.
      REFRESH it_top.
      wa_top-typ = 'S'.
      wa_top-key = text-001.
      wa_top-info = rep_id.
      APPEND wa_top TO it_top.
      CLEAR wa_top.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary       = it_top
    *   I_LOGO                   =
    *   I_END_OF_LIST_GRID       =
    *   I_ALV_FORM               =
    ENDFORM.                    "top
    *&      Form  end
    *       TO WRITE THE FOOTER
    FORM end.
      REFRESH it_end.
      wa_end-typ = 'S'.
      wa_end-key = text-001.
      wa_end-info = rep_id.
      APPEND wa_end TO it_end.
      CLEAR wa_end.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary       = it_end
    *   I_LOGO                   =
    *   I_END_OF_LIST_GRID       =
    *   I_ALV_FORM               =
    ENDFORM.                    "end
    *&      Form  pf
    *       FOR PF-STATUS WITH USER DEFINED BUTTONS
    *      -->RT_EXTAB   text
    FORM pf USING rt_extab TYPE slis_t_extab.
      SET PF-STATUS 'ZTG_PF_ALV'.
    ENDFORM.                    "pf
    *&      Form  command
    *       TO HANDLE USER ACTIONS AGAINST PF-STATUS
    *      -->UCOMM      text
    *      -->SELFIELD   text
    FORM command USING ucomm LIKE sy-ucomm selfield TYPE slis_selfield.
      DATA : ok_code TYPE sy-ucomm.
      ok_code = ucomm.
      CASE ok_code.
        WHEN 'T_DOWN'.
          CALL FUNCTION 'POPUP_TO_INFORM'
            EXPORTING
              titel = 'HELLO'
              txt1  = 'USER COMMAND'
              txt2  = 'TOTAL DOWN'.
        WHEN 'DOWN'.
          CALL FUNCTION 'POPUP_TO_INFORM'
            EXPORTING
              titel = 'HELLO'
              txt1  = 'USER COMMAND'
              txt2  = 'DOWN'.
        WHEN 'UP'.
          CALL FUNCTION 'POPUP_TO_INFORM'
            EXPORTING
              titel = 'HELLO'
              txt1  = 'USER COMMAND'
              txt2  = 'UP'.
        WHEN 'T_UP'.
          CALL FUNCTION 'POPUP_TO_INFORM'
            EXPORTING
              titel = 'HELLO'
              txt1  = 'USER COMMAND'
              txt2  = 'TOTAL UP'.
      ENDCASE.
    ENDFORM.                    "command
    Hope this helps you.
    Thanks & Regards,
    Tarun Gambhir

  • Can we run alv reports in background

    hi all
    can we run alv reports in background

    Hi
    Yes You can
    see this
    Many a times there is a requirement to display ALV Grid (not ALV List) in the background Job. I have checked the SDN Forum for the same and it has been mentioned that ALV Grid cannot be displayed in Background, but the list output of ALV is possible. So user won’t have the actual Grid interface but the List interface.
    There is a workaround to display ALV Grid in Background Job. The only restriction is you can’t schedule the job through SM36. You need to execute the transaction of the report program, fill in the selection screen data and hit Execute.
    The job would be executed in background. User will be able to see the Job Log and Job Status after executing the program. User doesn’t have to go to SM37 to view the job status/log. Once the Job Status is changed to “COMPLETED”, user can click on “DISPLAY SPOOL” to view the ALV Grid.
    Limitations:
    Can’t schedulea background job
    The session should be active until the background job is completed. If the session is closed, then user won’t be able to check the output in ALV Grid. User would be able to check the output through spool or SM37
    Advantages:
    If the spool width is greater than 255 characters, then the entire width could be seen in the output because the output is directed to an ALV Grid and not to spool
    Interface of ALV Grid is available instead of ALV List even though it’s a background job.
    Program won’t give the TIME OUT error
    Steps Required:
    1. Once you execute the program, the following screen would be displayed
    2. Click “Display Job Status” to check the Status of the Background Job
    3. Click on “Display the Job Log” to check the Log
    4. Click on “Display Job Status” to check the Job Status
    5. Click on “DISPLAY SPOOL” to check the spool content once the Job Status is changed to “COMPLETED”. Output is displayed in ALV Grid
    Programs:
    1.  Two different programs needs to be created
    ZPROGRAM_ONE: This is the 1st program, where the selection screen and all the data validations would be done. Error handling for invalid data should be done in this program.
    Once the data validation is done, this program would call the 2nd program ZPROGEAM_TWO. Build the logic to display ALV Grid in this program. The logic will only display ALV in foreground and it won’t be reflected in the spool.
    ZPROGRAM_TWO: This program would fetch all the data and do all the processing. If you want the spool output along with ALV Grid output, then build the logic in this program to display ALV Grid.
    *& Report  ZPROGRAM_ONE                                                *
    REPORT  zprogram_one                            .
    PRASHANT PATIL
    TABLES : mara,
             tsp01.
    type-pools:slis.
    TYPES : BEGIN OF t_mara,
              matnr   TYPE mara-matnr,
              ersda   TYPE mara-ersda,
              ernam   TYPE mara-ernam,
              laeda   TYPE mara-laeda,
            END OF t_mara.
    DATA : i_mara       TYPE STANDARD TABLE OF t_mara,
           wa_mara      TYPE t_mara,
           wa_index     TYPE indx,        " For Index details
           wa_index_key TYPE indx-srtfd VALUE 'PRG_ONE',
           i_jobsteplist     TYPE STANDARD TABLE OF tbtcstep, " For spool number
           wa_params         TYPE pri_params,  " To Get Print Parameters
           wa_jobhead        TYPE tbtcjob,     " To know the status of job
           wa_jobsteplist    TYPE tbtcstep,    " To know the spool
           w_jobname         TYPE tbtco-jobname,  " Job name for bckgrnd job
           w_jobcount        TYPE tbtco-jobcount, " Unique id for bckgrd job
           w_path            TYPE string,         " Upload path
           w_lsind           TYPE sy-lsind,       " Index
           wa_seltab         TYPE rsparams,
           i_seltab          TYPE STANDARD TABLE OF rsparams,
           wa_index1         TYPE indx,        " For Index details
           wa_index_key1     TYPE indx-srtfd VALUE 'PRG_TWO',
           i_fieldcat        TYPE slis_t_fieldcat_alv,
           wa_fieldcat       LIKE LINE OF i_fieldcat.
            CONSTANTS DECLARATION                                        *
    CONSTANTS :
             c_a(1) TYPE c VALUE 'A',
             c_m(1) TYPE c VALUE 'M',
             c_l(1) TYPE c VALUE 'L',
             c_c(1) TYPE c VALUE 'C',
             c_zfdr(4) TYPE c VALUE 'ZFDR',
             c_x(1)    TYPE c VALUE 'X',
             c_locl(4) TYPE c VALUE 'LOCL', " Destination is LOCAL
             c_f(1)    TYPE c VALUE 'F',   " Job Status - Failed
             c_s(1)    TYPE c VALUE 'S',
             c_p(1)    TYPE c VALUE 'P'.
    SELECTION SCREEN PARAMETERS
    SELECT-OPTIONS : s_matnr FOR mara-matnr.
    START-OF-SELECTION.
    Before the export, fill the data fields before CLUSTR
      wa_index-aedat = sy-datum.
      wa_index-usera = sy-uname.
      EXPORT s_matnr
           TO DATABASE indx(st) FROM wa_index ID wa_index_key.
    To Open the Job for background processing
      PERFORM open_job.
    To get the print parameters
      PERFORM get_print_parameters.
    Submit the job in background
      PERFORM job_submit.
    Close the background job
      PERFORM job_close.
    This is the output screen with the buttons ********
    Create 3 buttons DISPLAY SPOOL, STATUS, JOBLOG
      SET PF-STATUS 'ZS001'.
      WRITE: / 'The program is submitted in Background'.
      WRITE: / 'Press DISPLAY SPOOL to see the spool'.
      WRITE: / 'Press STATUS to see the status of the background'.
    AT USER-COMMAND.
    If user presses the 'BACK' button
      IF sy-ucomm = 'BAK'.
        IF  wa_jobhead-status = c_f OR
            wa_jobhead-status = c_a.
          LEAVE TO SCREEN 0.
        ENDIF.
      ENDIF.
    If the user presses the 'DISPLAY SPOOL' Button
      IF sy-ucomm = 'DISPLAY'.
        PERFORM display_spool.
      ENDIF.
    If the user presses the 'JOB STATUS' Button
      IF sy-ucomm = 'STATUS'.
        PERFORM display_status.
      ENDIF.
    If the user presses the 'JOB LOG' Button
      IF sy-ucomm = 'JOBLOG'.
        PERFORM display_job_log.
      ENDIF.
    *&      Form  open_job
          text
    -->  p1        text
    <--  p2        text
    FORM open_job .
    This is to Create a new job which is to be submitted in background to
    process sales order/delivery/invoice
    Here we would get a unique id ( Jobcount ) which identifies our job
    along with the job name which we have assigned to our job
      CONCATENATE sy-uname
                  sy-datum
                  sy-uzeit
                          INTO w_jobname .  " Assign unique jobname
      CALL FUNCTION 'JOB_OPEN'
       EXPORTING
      DELANFREP              = ' '
      JOBGROUP               = ' '
        jobname                = w_jobname
      SDLSTRTDT              = NO_DATE
      SDLSTRTTM              = NO_TIME
      JOBCLASS               =
      IMPORTING
       jobcount                = w_jobcount
    CHANGING
      RET                    =
    EXCEPTIONS
       cant_create_job        = 1
       invalid_job_data       = 2
       jobname_missing        = 3
       OTHERS                 = 4
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                    " open_job
    *&      Form  get_print_parameters
          text
    -->  p1        text
    <--  p2        text
    FORM get_print_parameters .
      DATA : l_valid TYPE c.
    This is to get the Print Parameters for the job which is to be
    submitted in background to process sales order/delivery/invoice
      CALL FUNCTION 'GET_PRINT_PARAMETERS'
       EXPORTING
      ARCHIVE_ID                   = C_CHAR_UNKNOWN
      ARCHIVE_INFO                 = C_CHAR_UNKNOWN
      ARCHIVE_MODE                 = C_CHAR_UNKNOWN
      ARCHIVE_TEXT                 = C_CHAR_UNKNOWN
      AR_OBJECT                    = C_CHAR_UNKNOWN
      ARCHIVE_REPORT               = C_CHAR_UNKNOWN
      AUTHORITY                    = C_CHAR_UNKNOWN
      COPIES                       = C_NUM3_UNKNOWN
      COVER_PAGE                   = C_CHAR_UNKNOWN
      DATA_SET                     = C_CHAR_UNKNOWN
      DEPARTMENT                   = C_CHAR_UNKNOWN
          destination                  = c_locl " LOCL
      EXPIRATION                   = C_NUM1_UNKNOWN
          immediately                  = space
      IN_ARCHIVE_PARAMETERS        = ' '
      IN_PARAMETERS                = ' '
      LAYOUT                       = C_CHAR_UNKNOWN
      LINE_COUNT                   = C_INT_UNKNOWN
      LINE_SIZE                    = C_INT_UNKNOWN
      LIST_NAME                    = C_CHAR_UNKNOWN
      LIST_TEXT                    = C_CHAR_UNKNOWN
      MODE                         = ' '
          new_list_id                  = c_x
      PROTECT_LIST                 = C_CHAR_UNKNOWN
          no_dialog                    = c_x
      RECEIVER                     = C_CHAR_UNKNOWN
      RELEASE                      = C_CHAR_UNKNOWN
      REPORT                       = C_CHAR_UNKNOWN
      SAP_COVER_PAGE               = C_CHAR_UNKNOWN
      HOST_COVER_PAGE              = C_CHAR_UNKNOWN
      PRIORITY                     = C_NUM1_UNKNOWN
      SAP_OBJECT                   = C_CHAR_UNKNOWN
      TYPE                         = C_CHAR_UNKNOWN
          user                         = sy-uname
      USE_OLD_LAYOUT               = ' '
      UC_DISPLAY_MODE              = C_CHAR_UNKNOWN
      DRAFT                        = C_CHAR_UNKNOWN
      ABAP_LIST                    = ' '
      USE_ARCHIVENAME_DEF          = ' '
      DEFAULT_SPOOL_SIZE           = C_CHAR_UNKNOWN
      PO_FAX_STORE                 = ' '
      NO_FRAMES                    = C_CHAR_UNKNOWN
       IMPORTING
      OUT_ARCHIVE_PARAMETERS       =
          out_parameters               = wa_params
       valid                        = l_valid
       EXCEPTIONS
         archive_info_not_found       = 1
         invalid_print_params         = 2
         invalid_archive_params       = 3
         OTHERS                       = 4
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                    " get_print_parameters
    *&      Form  job_submit
          text
    -->  p1        text
    <--  p2        text
    FORM job_submit .
    The job which we have created & the unique id ( jobcount ) which we
    have got identifies our job. Hence those parameters are passed along
    with the name of the background program "ZPROGRAM_TWO"
    The job is submitted in background.
      CALL FUNCTION 'JOB_SUBMIT'
        EXPORTING
      ARCPARAMS                         =
        authcknam                         = sy-uname
      COMMANDNAME                       = ' '
      OPERATINGSYSTEM                   = ' '
      EXTPGM_NAME                       = ' '
      EXTPGM_PARAM                      = ' '
      EXTPGM_SET_TRACE_ON               = ' '
      EXTPGM_STDERR_IN_JOBLOG           = 'X'
      EXTPGM_STDOUT_IN_JOBLOG           = 'X'
      EXTPGM_SYSTEM                     = ' '
      EXTPGM_RFCDEST                    = ' '
      EXTPGM_WAIT_FOR_TERMINATION       = 'X'
        jobcount                          = w_jobcount
        jobname                           = w_jobname
      LANGUAGE                          = SY-LANGU
        priparams                         = wa_params
        report                            = 'ZPROGRAM_TWO'
      VARIANT                           = ' '
    IMPORTING
      STEP_NUMBER                       =
       EXCEPTIONS
         bad_priparams                     = 1
         bad_xpgflags                      = 2
         invalid_jobdata                   = 3
         jobname_missing                   = 4
         job_notex                         = 5
         job_submit_failed                 = 6
         lock_failed                       = 7
         program_missing                   = 8
         prog_abap_and_extpg_set           = 9
         OTHERS                            = 10
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                    " job_submit
    *&      Form  job_close
          text
    -->  p1        text
    <--  p2        text
    FORM job_close .
    Once the job is submitted in background then the job is closed
      CALL FUNCTION 'JOB_CLOSE'
        EXPORTING
      AT_OPMODE                         = ' '
      AT_OPMODE_PERIODIC                = ' '
      CALENDAR_ID                       = ' '
      EVENT_ID                          = ' '
      EVENT_PARAM                       = ' '
      EVENT_PERIODIC                    = ' '
        jobcount                          = w_jobcount
        jobname                           = w_jobname
      LASTSTRTDT                        = NO_DATE
      LASTSTRTTM                        = NO_TIME
      PRDDAYS                           = 0
      PRDHOURS                          = 0
      PRDMINS                           = 0
      PRDMONTHS                         = 0
      PRDWEEKS                          = 0
      PREDJOB_CHECKSTAT                 = ' '
      PRED_JOBCOUNT                     = ' '
      PRED_JOBNAME                      = ' '
      SDLSTRTDT                         = NO_DATE
      SDLSTRTTM                         = NO_TIME
      STARTDATE_RESTRICTION             = BTC_PROCESS_ALWAYS
        strtimmed                         = c_x
      TARGETSYSTEM                      = ' '
      START_ON_WORKDAY_NOT_BEFORE       = SY-DATUM
      START_ON_WORKDAY_NR               = 0
      WORKDAY_COUNT_DIRECTION           = 0
      RECIPIENT_OBJ                     =
      TARGETSERVER                      = ' '
      DONT_RELEASE                      = ' '
      TARGETGROUP                       = ' '
      DIRECT_START                      =
    IMPORTING
      JOB_WAS_RELEASED                  =
    CHANGING
      RET                               =
       EXCEPTIONS
         cant_start_immediate              = 1
         invalid_startdate                 = 2
         jobname_missing                   = 3
         job_close_failed                  = 4
         job_nosteps                       = 5
         job_notex                         = 6
         lock_failed                       = 7
         invalid_target                    = 8
         OTHERS                            = 9
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                    " job_close
    *&      Form  display_spool
          text
    -->  p1        text
    <--  p2        text
    FORM display_spool .
    To Read the Job to get the spool details
      DATA : l_rqident TYPE tsp01-rqident, " Spool Number
             l_spoolno TYPE tsp01_sp0r-rqid_char.
      CLEAR : l_rqident,
              w_lsind,
              wa_jobsteplist.
      REFRESH : i_jobsteplist.
      SET PF-STATUS 'ZAR02'.
    Get the Spool Number
      CALL FUNCTION 'BP_JOB_READ'
        EXPORTING
          job_read_jobcount           = w_jobcount
          job_read_jobname            = w_jobname
          job_read_opcode             = '20'
        JOB_STEP_NUMBER             =
       IMPORTING
         job_read_jobhead            = wa_jobhead
       TABLES
         job_read_steplist           = i_jobsteplist
    CHANGING
       RET                         =
       EXCEPTIONS
         invalid_opcode              = 1
         job_doesnt_exist            = 2
         job_doesnt_have_steps       = 3
         OTHERS                      = 4
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    Read the Job Step list to get the spool number
      READ TABLE i_jobsteplist INTO wa_jobsteplist INDEX 1.
      CHECK wa_jobsteplist-listident <> space.
    Spool Number
      l_rqident = wa_jobsteplist-listident.
      MOVE l_rqident TO l_spoolno.
    Check the spool in TSP01
      SELECT SINGLE * FROM tsp01 WHERE rqident = l_rqident.
      IF  sy-subrc = 0.
        LEAVE TO LIST-PROCESSING.
        CALL FUNCTION 'RSPO_R_RDELETE_SPOOLREQ'
          EXPORTING
            spoolid       = l_spoolno
        IMPORTING
          RC            =
          STATUS        =
        PERFORM show_alv.
      ENDIF.
      w_lsind = sy-lsind.
      IF sy-lsind GE 19.
        sy-lsind = 1.
      ENDIF.
    ENDFORM.                    " display_spool
    *&      Form  show_alv
          text
    -->  p1        text
    <--  p2        text
    FORM show_alv .
    Before the import, fill the data fields before CLUSTR.
      wa_index1-aedat = sy-datum.
      wa_index1-usera = sy-uname.
    To Import the selection screen data from Calling Program
      IMPORT i_mara
      FROM DATABASE indx(st) ID wa_index_key1 TO wa_index1.
      FREE MEMORY ID wa_index_key1.
    This prepares the field-catalog for ALV.
      PERFORM prepare_fieldcatalog.
    This displays the output in  ALV format .
      PERFORM display_alv.
    ENDFORM.                    " show_alv
    *&      Form  display_status
          text
    -->  p1        text
    <--  p2        text
    FORM display_status .
    To Display the STATUS of the JOB which is exectued in background
      CLEAR : wa_jobsteplist.
      REFRESH : i_jobsteplist.
      WRITE:/ 'DISPLAYING JOB STATUS'.
      CALL FUNCTION 'BP_JOB_READ'
        EXPORTING
          job_read_jobcount           = w_jobcount
          job_read_jobname            = w_jobname
          job_read_opcode             = '20'
        JOB_STEP_NUMBER             =
       IMPORTING
         job_read_jobhead            = wa_jobhead
       TABLES
         job_read_steplist           = i_jobsteplist
    CHANGING
       RET                         =
       EXCEPTIONS
         invalid_opcode              = 1
         job_doesnt_exist            = 2
         job_doesnt_have_steps       = 3
         OTHERS                      = 4
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    To Display the status text as per the status type
      CASE wa_jobhead-status.
        WHEN 'S'. WRITE: / 'Scheduled'.
        WHEN 'R'. WRITE: / 'Released'.
        WHEN 'F'. WRITE: / 'Completed'.
        WHEN 'A'. WRITE: / 'Cancelled'.
        WHEN OTHERS.
      ENDCASE.
      IF sy-lsind GE 19.
        sy-lsind = 1.
      ENDIF.
    ENDFORM.                    " display_status
    *&      Form  display_job_log
          text
    -->  p1        text
    <--  p2        text
    FORM display_job_log .
    To display the log of the background program
      LEAVE TO LIST-PROCESSING.
      CALL FUNCTION 'BP_JOBLOG_SHOW_SM37B'
        EXPORTING
          client                    = sy-mandt
          jobcount                  = w_jobcount
          joblogid                  = ' '
          jobname                   = w_jobname
        EXCEPTIONS
          error_reading_jobdata     = 1
          error_reading_joblog_data = 2
          jobcount_missing          = 3
          joblog_does_not_exist     = 4
          joblog_is_empty           = 5
          joblog_show_canceled      = 6
          jobname_missing           = 7
          job_does_not_exist        = 8
          no_joblog_there_yet       = 9
          no_show_privilege_given   = 10
          OTHERS                    = 11.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                    " display_job_log
    *&      Form  prepare_fieldcatalog
          text
    -->  p1        text
    <--  p2        text
    FORM prepare_fieldcatalog .
      CLEAR wa_fieldcat.
      wa_fieldcat-fieldname    = 'MATNR'.
      wa_fieldcat-tabname      = 'I_MARA'.
      wa_fieldcat-reptext_ddic = 'Material no.'.
      wa_fieldcat-outputlen    = '18'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-fieldname    = 'ERSDA'.
      wa_fieldcat-tabname      = 'I_MARA'.
      wa_fieldcat-reptext_ddic = 'Creation date'.
      wa_fieldcat-outputlen    = '10'.
      APPEND  wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-fieldname    = 'ERNAM'.
      wa_fieldcat-tabname      = 'I_MARA'.
      wa_fieldcat-reptext_ddic = 'Name of Person'.
      wa_fieldcat-outputlen    = '10'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-fieldname    = 'LAEDA'.
      wa_fieldcat-tabname      = 'I_MARA'.
      wa_fieldcat-reptext_ddic = ' Last Change'.
      wa_fieldcat-outputlen    = '10'.
      APPEND  wa_fieldcat TO i_fieldcat.
    ENDFORM.                    " prepare_fieldcatalog
    *&      Form  display_alv
          text
    -->  p1        text
    <--  p2        text
    FORM display_alv .
    Call ABAP List Viewer (ALV)
      call function 'REUSE_ALV_GRID_DISPLAY'
        exporting
          it_fieldcat  = i_fieldcat
        tables
          t_outtab     = i_mara.
    ENDFORM.                    " display_alv
    •     ZPROGRAM_TWO: This is the 2nd program which would be called from program ZPROGRAM_ONE.
    *& Report  ZPROGRAM_TWO                                                *
    REPORT  zprogram_two                            .
    PRASHANT PATIL
    TABLES : mara.
    TYPE-POOLS:slis.
    TYPES : BEGIN OF t_mara,
              matnr   TYPE mara-matnr,
              ersda   TYPE mara-ersda,
              ernam   TYPE mara-ernam,
              laeda   TYPE mara-laeda,
            END OF t_mara.
    DATA : i_mara        TYPE STANDARD TABLE OF t_mara,
           wa_mara       TYPE t_mara,
           wa_index      TYPE indx,        " For Index details
           wa_index_key  TYPE indx-srtfd VALUE 'PRG_ONE',
           wa_index1     TYPE indx,        " For Index details
           wa_index_key1 TYPE indx-srtfd VALUE 'PRG_TWO',
           i_fieldcat        TYPE slis_t_fieldcat_alv,
           wa_fieldcat       LIKE LINE OF i_fieldcat.
    SELECT-OPTIONS : s_matnr FOR mara-matnr.
    Before the import, fill the data fields before CLUSTR.
    wa_index-aedat = sy-datum.
    wa_index-usera = sy-uname.
    To Import the selection screen data from Calling Program
    IMPORT s_matnr
    FROM DATABASE indx(st) ID wa_index_key TO wa_index.
    FREE MEMORY ID wa_index_key.
    SELECT matnr
           ersda
           ernam
           laeda
           FROM mara
           INTO TABLE i_mara
           WHERE matnr IN s_matnr.
    PERFORM prepare_fieldcatalog.
    PERFORM display_alv.
    Before the export, fill the data fields before CLUSTR
    wa_index1-aedat = sy-datum.
    wa_index1-usera = sy-uname.
    EXPORT i_mara
    TO DATABASE indx(st) FROM wa_index1 ID wa_index_key1.
    *&      Form  prepare_fieldcatalog
          text
    -->  p1        text
    <--  p2        text
    FORM prepare_fieldcatalog .
      CLEAR wa_fieldcat.
      wa_fieldcat-fieldname    = 'MATNR'.
      wa_fieldcat-tabname      = 'I_MARA'.
      wa_fieldcat-outputlen    = '18'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-fieldname    = 'ERSDA'.
      wa_fieldcat-tabname      = 'I_MARA'.
      wa_fieldcat-outputlen    = '10'.
      APPEND  wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-fieldname    = 'ERNAM'.
      wa_fieldcat-tabname      = 'I_MARA'.
      wa_fieldcat-outputlen    = '10'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-fieldname    = 'LAEDA'.
      wa_fieldcat-tabname      = 'I_MARA'.
      wa_fieldcat-outputlen    = '10'.
      APPEND  wa_fieldcat TO i_fieldcat.
    ENDFORM.                    " prepare_fieldcatalog
    *&      Form  display_alv
          text
    -->  p1        text
    <--  p2        text
    FORM display_alv .
    Call ABAP List Viewer (ALV)
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          it_fieldcat = i_fieldcat
        TABLES
          t_outtab    = i_mara.
    ENDFORM.                    " display_alv
    its possible to display ALV Grid using OO ALV. Following code can be used instead of FM.
    In the PBO, add following code
    SET PF-STATUS 'ZSTAT'.
    If program is executed in background
    CALL METHOD cl_gui_alv_grid=>offline
    RECEIVING
    e_offline = off.
    IF off IS INITIAL.
    IF container1 IS INITIAL.
    CREATE OBJECT container1
    EXPORTING
    container_name = 'CC_ALV1' .
    ENDIF.
    ENDIF.
    CREATE OBJECT g_grid1
    EXPORTING
    i_parent = container1.
    CALL METHOD g_grid1->set_table_for_first_display
    EXPORTING
    I_BUFFER_ACTIVE =
    I_BYPASSING_BUFFER =
    I_CONSISTENCY_CHECK =
    I_STRUCTURE_NAME =
    IS_VARIANT =
    i_save = 'A'
    i_default = ' '
    is_layout =
    is_print =
    IT_SPECIAL_GROUPS =
    it_toolbar_excluding =
    IT_HYPERLINK =
    IT_ALV_GRAPHICS =
    IT_EXCEPT_QINFO =
    CHANGING
    it_outtab = i_output
    it_fieldcatalog = i_fieldcatalog
    IT_SORT =
    IT_FILTER =
    EXCEPTIONS
    invalid_parameter_combination = 1
    program_error = 2
    too_many_lines = 3
    OTHERS = 4
    IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    Reward points if useful
    Regards
    Anji

  • How can we edit alv report output.

    hi all,
    how can we edit alv report output

    \[removed by moderator as it was just a copy and paste answer of someone else's work without giving a source\]
    Edited by: Jan Stallkamp on Aug 25, 2008 4:35 PM

  • Creating ALV reports using OOP concept

    After creating many reports i found out that 90% of the coding in a report is copy paste i.e. only 10% of coding effort is required which includes
        creating the custom data types and internal table variables  ...
        populating the data
        creating screen,GUI status and GUI title
    Just copy paste the below code and do as stated  :
    *ALV TEMPLATE
    *create screen no. 2000
    *change flow logic in screen if necessary
    *create GUI status and GUI title
    *change selection texts and text symbols*
    REPORT  Y_TEMPLATE_ALV.
    TABLES : ."use if range of values required on selection screen.
    DATA: zcl_alvgrid        TYPE REF TO cl_gui_alv_grid,
           zcl_ccontainer     TYPE REF TO cl_gui_docking_container,
           wa_layout    TYPE lvc_s_layo,
           it_fieldcat  TYPE STANDARD TABLE OF lvc_s_fcat,
           wa_fieldcat  TYPE lvc_s_fcat,
           z_document         TYPE REF TO cl_dd_document,
           o_docking TYPE REF TO cl_gui_docking_container,"Docking Container
           o_split TYPE REF TO cl_gui_easy_splitter_container, "Splitter
           o_top_container TYPE REF TO cl_gui_container,   "Top Container
           o_bottom_container TYPE REF TO cl_gui_container."Bottom Container
    TYPES : BEGIN OF TY_FINAL,
    "All columns which are to be displayed in the report should be included here
    END OF TY_FINAL.
    *Add additional Internal Tables's if data is to be extracted from multiple tables
    *Then loop at main table and Read the other tables
    DATA :IT_DATA TYPE STANDARD TABLE OF , "data extracted from tables can be stored in this internal table variable ..
           WA_DATA TYPE ,
           iT_alv      TYPE STANDARD TABLE OF TY_FINAL, " pass to  the method SET_TABLE_FOR_FIRST_DISPLAY of class
    ZCL_ALVGRID [Already done ; its  just fyi]
           WA_alv      TYPE                   TY_FINAL.
    DATA :V_CLN(255) TYPE C, " For no. of records
           V_LINE TYPE I. " for conversion of integer to character
    *                 Selection Screen                                     *
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    PARAMETERS:
    SELECT-OPTIONS: " PARAMETERS and Range on selection screen
    SELECTION-SCREEN END OF BLOCK B1.
    AT SELECTION-SCREEN OUTPUT.
    *                        START  OF  SELECTION                          *
    START-OF-SELECTION.
    *  SELECT * FROM INTO CORRESPONDING FIELDS OF TABLE IT_DATA WHERE ....in ....
       IF SY-SUBRC = 0.
         LOOP AT IT_DATA INTO WA_DATA.
           MOVE-CORRESPONDING WA_DATA TO wa_alv. " if data is fetched from only one table
           APPEND wa_alv TO it_alv.
           CLEAR : wa_alv,WA_DATA.
         ENDLOOP.
         DESCRIBE TABLE it_alv LINES V_LINE.
         V_CLN = V_LINE.
       ENDIF.
    END-OF-SELECTION.
       PERFORM DISPLAY_ALV.
    *&      Module  STATUS  OUTPUT
    *       text
    MODULE STATUS_2000 OUTPUT.
       SET PF-STATUS 'STATUS'.
       SET TITLEBAR 'ALV'.
    *  ** Creating Docking Container
       CREATE OBJECT o_docking
       EXPORTING
    *    side = cl_gui_docking_container=>dock_at_right
         ratio = '95'.
       IF sy-subrc EQ 0.
    * Splitting the Docking container
         CREATE OBJECT o_split
         EXPORTING
           parent        = o_docking
           sash_position = 05 "Position of Splitter Bar (in Percent)
           with_border   = 0. "With Border = 1 Without Border = 0
    *   Placing the containers in the splitter
         o_top_container = o_split->top_left_container .
         o_bottom_container = o_split->bottom_right_container .
    *   Creating the document
         CREATE OBJECT z_document
         EXPORTING
           style = 'ALV_GRID'.
       ENDIF.
    * Calling the methods for dynamic text
       CALL METHOD z_document->add_text
       EXPORTING
         TEXT         = 'No. of Records:'
         sap_emphasis = cl_dd_area=>strong. " For bold
    * Adding GAP
       CALL METHOD z_document->add_gap
       EXPORTING
         width = 10.
    * Adding Text
       CALL METHOD z_document->add_text
       EXPORTING
         TEXT = v_cln.
    * Adding Line
       CALL METHOD z_document->new_line.
    * Display the data
       CALL METHOD z_document->display_document
       EXPORTING
         parent = o_top_container.
       IF zcl_alvgrid IS INITIAL .
    *----Creating ALV Grid instance
         CREATE OBJECT zcl_alvgrid
         EXPORTING
           i_parent          = o_bottom_container
         EXCEPTIONS
           error_cntl_create = 1
           error_cntl_init   = 2
           error_cntl_link   = 3
           error_dp_create   = 4
           OTHERS            = 5.
         IF sy-subrc <> 0.
           MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
           WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
         ENDIF.
    * Calling the method of ALV to process top of page
         CALL METHOD zcl_alvgrid->list_processing_events
         EXPORTING
           i_event_name = 'TOP_OF_PAGE'
           i_dyndoc_id  = z_document.
    * Preparing field catalog.
         PERFORM T_FIELDCAT USING:
                    '1'        'BRNCD'      'BRAND'.
    *          'Column no' 'FIELDNAME' 'Column Heading' 
         WA_LAYOUT-CWIDTH_OPT = 'X'.
         WA_LAYOUT-ZEBRA = 'X'.
         WA_LAYOUT-SEL_MODE =  'A'.
    * Setting table for first display
         CALL METHOD ZCL_ALVGRID->SET_TABLE_FOR_FIRST_DISPLAY
         EXPORTING
           IS_LAYOUT                     = WA_LAYOUT
         CHANGING
           IT_OUTTAB                     = it_alv
           IT_FIELDCATALOG               = IT_FIELDCAT
         EXCEPTIONS
           INVALID_PARAMETER_COMBINATION = 1
           PROGRAM_ERROR                 = 2
           TOO_MANY_LINES                = 3
           OTHERS                        = 4.
         IF SY-SUBRC <> 0.
           MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
           WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
         ENDIF.
       ELSE.
         CALL METHOD ZCL_ALVGRID->REFRESH_TABLE_DISPLAY
         EXCEPTIONS
           FINISHED = 1
           OTHERS   = 2.
         IF SY-SUBRC <> 0.
           MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
           WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
         ENDIF.
       ENDIF.
    ENDMODULE.                 " STATUS  OUTPUT
    MODULE USER_COMMAND_2000 INPUT.
       DATA: V_OK_CODE TYPE SY-UCOMM,
             V_SAVE_OK TYPE SY-UCOMM.
       V_OK_CODE = SY-UCOMM.
       V_SAVE_OK = V_OK_CODE.
       CASE SY-UCOMM.
         WHEN 'BACK'.
           SET SCREEN 1000.
         WHEN 'EXIT'.
           LEAVE program.
         WHEN OTHERS.
           SET SCREEN 1000.
       ENDCASE.
       CLEAR V_SAVE_OK.
       SET SCREEN 0.
       LEAVE SCREEN.
    ENDMODULE.                 " USER_COMMAND_2000  INPUT
    *&      Form  T_FIELDCAT
    *       text
    *      -->x   text
    *      -->y   text
    *      -->z   text
    FORM T_FIELDCAT  USING VALUE(X) TYPE ANY
           VALUE(Y) TYPE ANY
           VALUE(Z) TYPE ANY.
       WA_FIELDCAT-COL_POS = X.
       WA_FIELDCAT-FIELDNAME = Y.
       WA_FIELDCAT-COLTEXT  = Z.
       APPEND WA_FIELDCAT TO IT_FIELDCAT.
       CLEAR WA_FIELDCAT.
    ENDFORM.                      " T_FIELDCAT
    *&      Form  DISPLAY_ALV
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM DISPLAY_ALV .
       IF NOT it_alv[] IS INITIAL.
         CALL SCREEN 2000.
       ELSE.
         MESSAGE 'No data for Display' TYPE 'I'.
       ENDIF.
    ENDFORM.                    " DISPLAY_ALV

    Hello Jay,
    Calling methods, creating instances, casting etc are not OOP. When you say you've developed an OO-report you think OO, refer to this blog to see what i mean - Global Data in ABAP OO Programs
    BR,
    Suhas

  • Create alv report

    hi friends,
    i have urgent reqirement pls help on this topic
    ·     Created an ALV report that displays Purchase document details in hierarchical manner using predefined function modules.
    thanks
    ravi

    Hi Ravi,
    Check this example.
    *& Report  ZDEMO_ALVTREE                                               *
    *& Example of a simple ALV Grid Report                                 *
    *& The basic requirement for this demo is to display a number of       *
    *& fields from the EKPO and EKKO table in a tree structure.            *
                             Amendment History                           *
    REPORT  zdemo_alvgrid                 .
    *Data Declaration
    TABLES:     ekko.
    TYPE-POOLS: slis.                                 "ALV Declarations
    TYPES: BEGIN OF t_ekko,
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
      statu TYPE ekpo-statu,
      aedat TYPE ekpo-aedat,
      matnr TYPE ekpo-matnr,
      menge TYPE ekpo-menge,
      meins TYPE ekpo-meins,
      netpr TYPE ekpo-netpr,
      peinh TYPE ekpo-peinh,
    END OF t_ekko.
    DATA: it_ekko     TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
          it_ekpo     TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
          it_emptytab TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
          wa_ekko     TYPE t_ekko,
          wa_ekpo     TYPE t_ekko.
    DATA: ok_code like sy-ucomm,           "OK-Code
          save_ok like sy-ucomm.
    *ALV data declarations
    DATA: fieldcatalog  TYPE lvc_t_fcat WITH HEADER LINE.
    DATA: gd_fieldcat   TYPE lvc_t_fcat,
          gd_tab_group  TYPE slis_t_sp_group_alv,
          gd_layout     TYPE slis_layout_alv.
    *ALVtree data declarations
    CLASS cl_gui_column_tree DEFINITION LOAD.
    CLASS cl_gui_cfw DEFINITION LOAD.
    DATA: gd_tree             TYPE REF TO cl_gui_alv_tree,
          gd_hierarchy_header TYPE treev_hhdr,
          gd_report_title     TYPE slis_t_listheader,
          gd_logo             TYPE sdydo_value,
          gd_variant          TYPE disvariant.
    *Create container for alv-tree
    DATA: l_tree_container_name(30) TYPE c,
          l_custom_container        TYPE REF TO cl_gui_custom_container.
    *Includes
    *INCLUDE ZDEMO_ALVTREEO01. "Screen PBO Modules
    *INCLUDE ZDEMO_ALVTREEI01. "Screen PAI Modules
    *INCLUDE ZDEMO_ALVTREEF01. "ABAP Subroutines(FORMS)
    *Start-of-selection.
    START-OF-SELECTION.
    ALVtree setup data
        PERFORM data_retrieval.
        PERFORM build_fieldcatalog.
        PERFORM build_layout.
        PERFORM build_hierarchy_header CHANGING gd_hierarchy_header.
        PERFORM build_report_title USING gd_report_title gd_logo.
        PERFORM build_variant.
    Display ALVtree report
      call screen 100.
    *&      Form  DATA_RETRIEVAL
          Retrieve data into Internal tables
    FORM data_retrieval.
      SELECT ebeln
       UP TO 10 ROWS
        FROM ekko
        INTO corresponding fields of TABLE it_ekko.
      loop at it_ekko into wa_ekko.
        SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh
          FROM ekpo
          appending TABLE it_ekpo
         where ebeln eq wa_ekko-ebeln.
      endloop.
    ENDFORM.                    " DATA_RETRIEVAL
    *&      Form  BUILD_FIELDCATALOG
          Build Fieldcatalog for ALV Report
    FORM build_fieldcatalog.
    Please not there are a number of differences between the structure of
    ALVtree fieldcatalogs and ALVgrid fieldcatalogs.
    For example the field seltext_m is replace by scrtext_m in ALVtree.
      fieldcatalog-fieldname   = 'EBELN'.           "Field name in itab
      fieldcatalog-scrtext_m   = 'Purchase Order'.  "Column text
      fieldcatalog-col_pos     = 0.                 "Column position
      fieldcatalog-outputlen   = 15.                "Column width
      fieldcatalog-emphasize   = 'X'.               "Emphasize  (X or SPACE)
      fieldcatalog-key         = 'X'.               "Key Field? (X or SPACE)
    fieldcatalog-do_sum      = 'X'.              "Sum Column?
    fieldcatalog-no_zero     = 'X'.              "Don't display if zero
      APPEND fieldcatalog TO gd_fieldcat.
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'EBELP'.
      fieldcatalog-scrtext_m   = 'PO Iten'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = 1.
      APPEND fieldcatalog TO gd_fieldcat..
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'STATU'.
      fieldcatalog-scrtext_m   = 'Status'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = 2.
      APPEND fieldcatalog TO gd_fieldcat..
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'AEDAT'.
      fieldcatalog-scrtext_m   = 'Item change date'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = 3.
      APPEND fieldcatalog TO gd_fieldcat..
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'MATNR'.
      fieldcatalog-scrtext_m   = 'Material Number'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = 4.
      APPEND fieldcatalog TO gd_fieldcat..
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'MENGE'.
      fieldcatalog-scrtext_m   = 'PO quantity'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = 5.
      APPEND fieldcatalog TO gd_fieldcat..
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'MEINS'.
      fieldcatalog-scrtext_m   = 'Order Unit'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = 6.
      APPEND fieldcatalog TO gd_fieldcat..
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'NETPR'.
      fieldcatalog-scrtext_m   = 'Net Price'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = 7.
      fieldcatalog-datatype     = 'CURR'.
      APPEND fieldcatalog TO gd_fieldcat..
      CLEAR  fieldcatalog.
      fieldcatalog-fieldname   = 'PEINH'.
      fieldcatalog-scrtext_m   = 'Price Unit'.
      fieldcatalog-outputlen   = 15.
      fieldcatalog-col_pos     = 8.
      APPEND fieldcatalog TO gd_fieldcat..
      CLEAR  fieldcatalog.
    ENDFORM.                    " BUILD_FIELDCATALOG
    *&      Form  BUILD_LAYOUT
          Build layout for ALV grid report
    FORM build_layout.
      gd_layout-no_input          = 'X'.
      gd_layout-colwidth_optimize = 'X'.
      gd_layout-totals_text       = 'Totals'(201).
    gd_layout-totals_only        = 'X'.
    gd_layout-f2code            = 'DISP'.  "Sets fcode for when double
                                            "click(press f2)
    gd_layout-zebra             = 'X'.
    gd_layout-group_change_edit = 'X'.
    gd_layout-header_text       = 'helllllo'.
    ENDFORM.                    " BUILD_LAYOUT
    *&      Form  build_hierarchy_header
          build hierarchy-header-information
         -->P_L_HIERARCHY_HEADER  structure for hierarchy-header
    FORM build_hierarchy_header CHANGING
                                   p_hierarchy_header TYPE treev_hhdr.
      p_hierarchy_header-heading = 'Hierarchy Header'(013).
      p_hierarchy_header-tooltip = 'This is the Hierarchy Header !'(014).
      p_hierarchy_header-width = 30.
      p_hierarchy_header-width_pix = ''.
    ENDFORM.                               " build_hierarchy_header
    *&      Form  BUILD_REPORT_TITLE
          Build table for ALVtree header
    <->  p1        Header details
    <->  p2        Logo value
    FORM build_report_title CHANGING
          pt_report_title  TYPE slis_t_listheader
          pa_logo             TYPE sdydo_value.
      DATA: ls_line TYPE slis_listheader,
            ld_date(10) TYPE c.
    List Heading Line(TYPE H)
      CLEAR ls_line.
      ls_line-typ  = 'H'.
    ls_line-key     "Not Used For This Type(H)
      ls_line-info = 'PO ALVTree Display'.
      APPEND ls_line TO pt_report_title.
    Status Line(TYPE S)
      ld_date(2) = sy-datum+6(2).
      ld_date+2(1) = '/'.
      ld_date3(2) = sy-datum4(2).
      ld_date+5(1) = '/'.
      ld_date+6(4) = sy-datum(4).
      ls_line-typ  = 'S'.
      ls_line-key  = 'Date'.
      ls_line-info = ld_date.
      APPEND ls_line TO pt_report_title.
    Action Line(TYPE A)
      CLEAR ls_line.
      ls_line-typ  = 'A'.
      CONCATENATE 'Report: ' sy-repid INTO ls_line-info  SEPARATED BY space.
      APPEND ls_line TO pt_report_title.
    ENDFORM.
    *&      Form  BUILD_VARIANT
          Build variant
    form build_variant.
    Set repid for storing variants
      gd_variant-report = sy-repid.
    endform.                    " BUILD_VARIANT
    *Includes
    *include zdemo_alvtreeo01. "Screen PBO Modules
    *include zdemo_alvtreei01. "Screen PAI Modules
    *include zdemo_alvtreef01. "ABAP Subroutines(FORMS)
    *Start-of-selection.
    start-of-selection.
    Screen flow logic code
    PROCESS BEFORE OUTPUT.
    MODULE STATUS_0100.
    PROCESS AFTER INPUT.
    MODULE USER_COMMAND_0100.
    ***INCLUDE Z......O01 .
    *&      Module  STATUS_0100  OUTPUT
          PBO Module
    module status_0100 output.
    SET PF-STATUS 'xxxxxxxx'.
    SET TITLEBAR 'xxx'.
    endmodule.                 " STATUS_0100  OUTPUT
    ***INCLUDE Z......I01 .
    *&      Module  USER_COMMAND_0100  INPUT
          PAI Module
    module user_command_0100 input.
    endmodule.                 " USER_COMMAND_0100  INPUT
       INCLUDE Z......I01                                                *
    *&      Module  USER_COMMAND_0100  INPUT
          text
    module user_command_0100 input.
      DATA return TYPE REF TO cl_gui_event.
      save_ok = ok_code.
      case ok_code.
        when 'BACK' or '%EX' or 'RW'.
        Exit program
          leave to screen 0.
      Process ALVtree user actions     
        when others.
          call method cl_gui_cfw=>get_current_event_object
                  receiving
                     event_object = return.
          call method cl_gui_cfw=>dispatch.
      endcase.
    endmodule.                 " USER_COMMAND_0100  INPUT
    Add following code to 'STATUS_0100'(PBO module)
      Create container for alv-tree
        PERFORM create_alvtree_container.
    Add following code to 'Z......F01' INCLUDE
    *&      Form  CREATE_ALVTREE_CONTAINER
          Create container for alv-tree
    FORM create_alvtree_container.
      gd_tree_container_name = 'SCREEN_CONTAINER'.
      create object gd_custom_container
          exporting
                container_name = gd_tree_container_name
          exceptions
                cntl_error                  = 1
                cntl_system_error           = 2
                create_error                = 3
                lifetime_error              = 4
                lifetime_dynpro_dynpro_link = 5.
      if sy-subrc <> 0.
        message x208(00) with 'ERROR'.                        
      endif.
    ENDFORM.
    Add following code to 'STATUS_0100'(PBO module)
    Create tree control
    PERFORM create_object_in_container.
    Add following code to 'Z......F01' INCLUDE
    *&      Form  CREATE_OBJECT_IN_CONTAINER
          Create ALVtree control
    FORM create_object_in_container.
      create object gd_tree
        exporting
            parent              = gd_custom_container
            node_selection_mode = cl_gui_column_tree=>node_sel_mode_single
            item_selection      = 'X'
            no_html_header      = ''
            no_toolbar          = ''
        exceptions
            cntl_error                   = 1
            cntl_system_error            = 2
            create_error                 = 3
            lifetime_error               = 4
            illegal_node_selection_mode  = 5
            failed                       = 6
            illegal_column_name          = 7.
      if sy-subrc <> 0.
        message x208(00) with 'ERROR'.                        
      endif.
    ENDFORM.
    Add following code to 'STATUS_0100'(PBO module)
    Create empty ALVtree control ready for first display
      PERFORM create_empty_alvtree_control.
    Add following code to 'Z......F01' INCLUDE
    *&      Form  CREATE_EMPTY_ALVTREE_CONTROL
          Create empty tree control
    FORM create_empty_alvtree_control.
    Create emty tree-control
      CLEAR: it_emptytab.
      REFRESH: it_emptytab.
      CALL METHOD gd_tree->set_table_for_first_display
         EXPORTING
                   is_hierarchy_header  = gd_hierarchy_header
                   it_list_commentary   = gd_report_title
                   i_logo               = gd_logo
                  i_background_id      = 'ALV_BACKGROUND'
                   i_save               = 'A'
                   is_variant            = gd_variant
         CHANGING
                   it_outtab            =  it_emptytab      "Must be empty
                   it_fieldcatalog      =  gd_fieldcat.
    ENDFORM.                    " CREATE_EMPTY_ALVTREE_CONTROL
    Add following code to 'STATUS_0100'(PBO module)
    Create ALVtree Hierarchy
      PERFORM create_alvtree_hierarchy.
    Add following code to 'Z......F01' INCLUDE
    *&      Form  CREATE_ALVTREE_HIERARCHY
          text
          Builds ALV tree display, (inserts nodes, subnodes etc)
    form create_alvtree_hierarchy.
      data: ls_sflight type sflight,
            lt_sflight type sflight occurs 0.
      data: ld_ebeln_key type lvc_nkey,
            ld_ebelp_key type lvc_nkey.
      loop at it_ekko into wa_ekko.
        perform add_ekko_node using      wa_ekko
                                changing ld_ebeln_key.
        loop at it_ekpo into wa_ekpo where ebeln eq wa_ekko-ebeln.
          perform add_ekpo_line using      wa_ekpo
                                           ld_ebeln_key
                                  changing ld_ebelp_key.
        endloop.
      endloop.
    calculate totals
      call method gd_tree->update_calculations.
    this method must be called to send the data to the frontend
      call method gd_tree->frontend_update.
    endform.                    " CREATE_ALVTREE_HIERARCHY
    *&      Form  ADD_EKKO_NODE
          text
         -->P_WA_EKPO  text
         -->P_0553   text
         <--P_EBELN_KEY  text
    form add_ekko_node using    ps_ekko like wa_ekko
                                value(p_relate_key)
                       changing p_node_key.
    data: ld_node_text type lvc_value,
           ls_sflight type sflight.
    Set item-layout
      data: lt_item_layout type lvc_t_layi,
            ls_item_layout type lvc_s_layi.
      ls_item_layout-t_image   = '@3P@'.
      ls_item_layout-fieldname = gd_tree->c_hierarchy_column_name.
      ls_item_layout-style     = cl_gui_column_tree=>style_default.
      ld_node_text             = ps_ekko-ebeln.
      append ls_item_layout to lt_item_layout.
    Add node
      call method gd_tree->add_node
        exporting
              i_relat_node_key = p_relate_key
              i_relationship   = cl_gui_column_tree=>relat_last_child
              i_node_text      = ld_node_text
              is_outtab_line   = ps_ekko
              it_item_layout   = lt_item_layout
           importing
              e_new_node_key = p_node_key.
    endform.                    " ADD_EKKO_NODE
    *&      Form  ADD_EKPO_LINE
          text
         -->P_WA_EKPO  text
         -->P_LD_EBELN_KEY  text
         <--P_LD_EBELP_KEY  text
    form add_ekpo_line using    ps_ekpo like wa_ekpo
                                value(p_relate_key)
                       changing p_node_key.
    data: ld_node_text type lvc_value,
           ls_sflight type sflight.
    Set item-layout
      data: lt_item_layout type lvc_t_layi,
            ls_item_layout type lvc_s_layi.
      ls_item_layout-t_image   = '@3P@'.
      ls_item_layout-fieldname = gd_tree->c_hierarchy_column_name.
      ls_item_layout-style     = cl_gui_column_tree=>style_default.
      ld_node_text             = ps_ekpo-ebelp.
      append ls_item_layout to lt_item_layout.
    Add node
      call method gd_tree->add_node
        exporting
              i_relat_node_key = p_relate_key
              i_relationship   = cl_gui_column_tree=>relat_last_child
              i_node_text      = ld_node_text
              is_outtab_line   = ps_ekpo
              it_item_layout   = lt_item_layout
           importing
              e_new_node_key = p_node_key.
    endform.                    " ADD_EKPO_LINE
    ***INCLUDE ZDEMO_ALVTREEO01 .
    *&      Module  STATUS_0100  OUTPUT
          text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'STATUS1'.
    SET TITLEBAR 'xxx'.
    If ALVtree already exists then it  mush not be re-created as this
    will cause a runtime error.
      IF gd_tree IS INITIAL.
      Create ALVtree (must be performed within screen PBO module)
        PERFORM create_alvtree_container.
        PERFORM create_object_in_container.
        PERFORM create_empty_alvtree_control.
        PERFORM create_alvtree_hierarchy.
      ENDIF.
      CALL METHOD cl_gui_cfw=>flush.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    ***INCLUDE ZDEMO_ALVTREEO01 .
    *&      Module  STATUS_0100  OUTPUT
          text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'STATUS1'.
    SET TITLEBAR 'xxx'.
    If ALVtree already exists then it  mush not be re-created as this
    will cause a runtime error.
      IF gd_tree IS INITIAL.
    Create ALVtree (must be performed within screen PBO module)
        PERFORM create_alvtree_container.
        PERFORM create_object_in_container.
        PERFORM create_empty_alvtree_control.
        PERFORM create_alvtree_hierarchy.
      ENDIF.
      CALL METHOD cl_gui_cfw=>flush.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    or
    The following code allows the easy creation of the example ALVtree report. Simply copy and past it into
    the appropriate includes(PBO and FORM).
      INCLUDE ZDEMO_ALVTREEF01                                           *
    *&      Form  CREATE_ALVTREE_CONTAINER
          Create container for ALVtree report
    form create_alvtree_container.
    Create container for alv-tree
      gd_tree_container_name = 'SCREEN_CONTAINER'.
      create object gd_custom_container
          exporting
                container_name = gd_tree_container_name
          exceptions
                cntl_error                  = 1
                cntl_system_error           = 2
                create_error                = 3
                lifetime_error              = 4
                lifetime_dynpro_dynpro_link = 5.
      if sy-subrc <> 0.
        message x208(00) with 'ERROR'.
      endif.
    endform.                    " CREATE_ALVTREE_CONTAINER
    *&      Form  CREATE_OBJECT_IN_CONTAINER
          Create ALVtree object in container
    form create_object_in_container.
    Create tree control
      create object gd_tree
        exporting
            parent              = gd_custom_container
            node_selection_mode = cl_gui_column_tree=>node_sel_mode_single
            item_selection      = 'X'
            no_html_header      = ''
            no_toolbar          = ''
        exceptions
            cntl_error                   = 1
            cntl_system_error            = 2
            create_error                 = 3
            lifetime_error               = 4
            illegal_node_selection_mode  = 5
            failed                       = 6
            illegal_column_name          = 7.
      if sy-subrc <> 0.
        message x208(00) with 'ERROR'.
      endif.
    endform.                    " CREATE_OBJECT_IN_CONTAINER
    *&      Form  BUILD_REPORT_TITLE
          Build table for ALVtree header
    <->  p1        Header details
    <->  p2        Logo value
    FORM build_report_title CHANGING
          pt_report_title  TYPE slis_t_listheader
          pa_logo             TYPE sdydo_value.
      DATA: ls_line TYPE slis_listheader,
            ld_date(10) TYPE c.
    List Heading Line(TYPE H)
      CLEAR ls_line.
      ls_line-typ  = 'H'.
    ls_line-key     "Not Used For This Type(H)
      ls_line-info = 'PO ALVTree Display'.
      APPEND ls_line TO pt_report_title.
    Status Line(TYPE S)
      ld_date(2) = sy-datum+6(2).
      ld_date+2(1) = '/'.
      ld_date3(2) = sy-datum4(2).
      ld_date+5(1) = '/'.
      ld_date+6(4) = sy-datum(4).
      ls_line-typ  = 'S'.
      ls_line-key  = 'Date'.
      ls_line-info = ld_date.
      APPEND ls_line TO pt_report_title.
    Action Line(TYPE A)
      CLEAR ls_line.
      ls_line-typ  = 'A'.
      CONCATENATE 'Report: ' sy-repid INTO ls_line-info  SEPARATED BY space.
      APPEND ls_line TO pt_report_title.
    ENDFORM.                    " BUILD_REPORT_TITLE
    *&      Form  CREATE_EMPTY_ALVTREE_CONTROL
          Create empty tree control
    FORM create_empty_alvtree_control.
    Create emty tree-control
      CLEAR: it_emptytab.
      REFRESH: it_emptytab.
      CALL METHOD gd_tree->set_table_for_first_display
         EXPORTING
                   is_hierarchy_header  = gd_hierarchy_header
                   it_list_commentary   = gd_report_title
                   i_logo               = gd_logo
                  i_background_id      = 'ALV_BACKGROUND'
                   i_save               = 'A'
                   is_variant            = gd_variant
         CHANGING
                   it_outtab            =  it_emptytab      "Must be empty
                   it_fieldcatalog      =  gd_fieldcat.
    ENDFORM.                    " CREATE_EMPTY_ALVTREE_CONTROL
    *&      Form  CREATE_ALVTREE_HIERARCHY
          text
          Builds ALV tree display, (inserts nodes, subnodes etc)
    form create_alvtree_hierarchy.
      data: ls_sflight type sflight,
            lt_sflight type sflight occurs 0.
      data: ld_ebeln_key type lvc_nkey,
            ld_ebelp_key type lvc_nkey.
      loop at it_ekko into wa_ekko.
        perform add_ekko_node using      wa_ekko
                                changing ld_ebeln_key.
        loop at it_ekpo into wa_ekpo where ebeln eq wa_ekko-ebeln.
          perform add_ekpo_line using      wa_ekpo
                                           ld_ebeln_key
                                  changing ld_ebelp_key.
        endloop.
      endloop.
    calculate totals
      call method gd_tree->update_calculations.
    this method must be called to send the data to the frontend
      call method gd_tree->frontend_update.
    endform.                    " CREATE_ALVTREE_HIERARCHY
    *&      Form  ADD_EKKO_NODE
          text
         -->P_WA_EKPO  text
         -->P_0553   text
         <--P_EBELN_KEY  text
    form add_ekko_node using    ps_ekko like wa_ekko
                                value(p_relate_key)
                       changing p_node_key.
    data: ld_node_text type lvc_value,
           ls_sflight type sflight.
    Set item-layout
      data: lt_item_layout type lvc_t_layi,
            ls_item_layout type lvc_s_layi.
      ls_item_layout-t_image   = '@3P@'.
      ls_item_layout-fieldname = gd_tree->c_hierarchy_column_name.
      ls_item_layout-style     = cl_gui_column_tree=>style_default.
      ld_node_text             = ps_ekko-ebeln.
      append ls_item_layout to lt_item_layout.
    Add node
      call method gd_tree->add_node
        exporting
              i_relat_node_key = p_relate_key
              i_relationship   = cl_gui_column_tree=>relat_last_child
              i_node_text      = ld_node_text
              is_outtab_line   = ps_ekko
              it_item_layout   = lt_item_layout
           importing
              e_new_node_key = p_node_key.
    endform.                    " ADD_EKKO_NODE
    *&      Form  ADD_EKPO_LINE
          text
         -->P_WA_EKPO  text
         -->P_LD_EBELN_KEY  text
         <--P_LD_EBELP_KEY  text
    form add_ekpo_line using    ps_ekpo like wa_ekpo
                                value(p_relate_key)
                       changing p_node_key.
    data: ld_node_text type lvc_value,
           ls_sflight type sflight.
    Set item-layout
      data: lt_item_layout type lvc_t_layi,
            ls_item_layout type lvc_s_layi.
      ls_item_layout-t_image   = '@3P@'.
      ls_item_layout-fieldname = gd_tree->c_hierarchy_column_name.
      ls_item_layout-style     = cl_gui_column_tree=>style_default.
      ld_node_text             = ps_ekpo-ebelp.
      append ls_item_layout to lt_item_layout.
    Add node
      call method gd_tree->add_node
        exporting
              i_relat_node_key = p_relate_key
              i_relationship   = cl_gui_column_tree=>relat_last_child
              i_node_text      = ld_node_text
              is_outtab_line   = ps_ekpo
              it_item_layout   = lt_item_layout
           importing
              e_new_node_key = p_node_key.
    endform.                    " ADD_EKPO_LINE
    Reward if useful.
    Regards,
    Chitra

  • How to edit ALV report using function modules

    I have a ALV report , i want to edit the report
    using function modules.
    how can i do that...
    Edited by: ms kumar on Mar 6, 2008 3:24 PM

    hi i had used this report with the check box,
    using the fm of alvs.....
    *& Report  ZZZ00
    REPORT  ZPR_02.
    TYPE-POOLS: SLIS.
    TABLES:pa0002,pa0008.
    data:begin of it_pa0002 occurs 0,
         checkbox,
         pernr like pa0002-pernr,
         begda like pa0002-begda,
         endda like pa0002-endda,
         vorna like pa0002-vorna,
         nachn like pa0002-nachn,
         end of it_pa0002.
    data:begin of it_pa00021 occurs 0,
         pernr like pa0002-pernr,
         begda like pa0002-begda,
         endda like pa0002-endda,
         vorna like pa0002-vorna,
         nachn like pa0002-nachn,
         expand TYPE xfeld value 'X',
         end of it_pa00021.
    data:begin of it_pa0008 occurs 0,
         pernr like pa0008-pernr,
         begda like pa0008-begda,
         endda like pa0008-endda,
         ANSAL like pa0008-ANSAL,
         LGA01 like pa0008-LGA01,
         BET01 LIKE PA0008-BET01,
         end of it_pa0008.
    DATA: IT_FIELD_CAT TYPE SLIS_T_FIELDCAT_ALV,
          IT_FIELD_CAT1 TYPE SLIS_T_FIELDCAT_ALV,
          IT_LAYOUT1 TYPE SLIS_LAYOUT_ALV,
          WA_FIELD_CAT TYPE SLIS_FIELDCAT_ALV,
          WA_FIELD_CAT1 TYPE SLIS_FIELDCAT_ALV,
          IT_LAYOUT TYPE SLIS_LAYOUT_ALV,
          IT_EVENTS TYPE SLIS_T_EVENT,
          WA_EVENTS TYPE SLIS_ALV_EVENT,
          IT_HEADER TYPE SLIS_T_LISTHEADER,
          WA_HEADER TYPE SLIS_LISTHEADER,
          wa_keyinfo TYPE slis_keyinfo_alv.
    CONSTANTS:c VALUE 'X'.
    SELECT-OPTIONS: S_pernr FOR pa0002-pernr.
    START-OF-SELECTION.
      SET PF-STATUS 'DATA' .
      PERFORM GET_DATA.
      PERFORM BUILD_FIELD_CAT.
      PERFORM GET_EVENTS.
      PERFORM DISPLAY_DATA.
    *&      Form  get_data
          text
    FORM GET_DATA .
      SELECT pernr
             begda
             endda
             vorna
             nachn
             FROM pa0002
             INTO CORRESPONDING FIELDS OF TABLE IT_pa0002
             WHERE pernr IN S_pernr.
    ENDFORM.                    " get_data
    *&      Form  build_field_cat
          text
    FORM BUILD_FIELD_CAT .
        wa_field_cat-tabname = 'PA0002'.
      WA_FIELD_CAT-FIELDNAME = 'CHECKBOX'.
      wa_field_cat-ref_tabname = 'IT_PA0002'.
      WA_FIELD_CAT-REPTEXT_DDIC = 'Check Box'.
      APPEND WA_FIELD_CAT TO IT_FIELD_CAT.
      CLEAR WA_FIELD_CAT.
        wa_field_cat-tabname = 'PA0002'.
      WA_FIELD_CAT-FIELDNAME = 'PERNR'.
        wa_field_cat-ref_tabname = 'IT_PA0002'.
      WA_FIELD_CAT-REPTEXT_DDIC = 'Personnel no'.
      APPEND WA_FIELD_CAT TO IT_FIELD_CAT.
      CLEAR WA_FIELD_CAT.
        wa_field_cat-tabname = 'PA0002'.
      WA_FIELD_CAT-FIELDNAME = 'BEGDA'.
      wa_field_cat-ref_tabname = 'IT_PA0002'.
      WA_FIELD_CAT-REPTEXT_DDIC = 'Start date'.
      APPEND WA_FIELD_CAT TO IT_FIELD_CAT.
      CLEAR WA_FIELD_CAT.
        wa_field_cat-tabname = 'PA0002'.
      WA_FIELD_CAT-FIELDNAME = 'ENDDA'.
      wa_field_cat-ref_tabname = 'IT_PA0002'.
      WA_FIELD_CAT-REPTEXT_DDIC = 'End date'.
      APPEND WA_FIELD_CAT TO IT_FIELD_CAT.
      CLEAR WA_FIELD_CAT.
        wa_field_cat-tabname = 'PA0002'.
      WA_FIELD_CAT-FIELDNAME = 'VORNA'.
      wa_field_cat-ref_tabname = 'IT_PA0002'.
      WA_FIELD_CAT-REPTEXT_DDIC = 'First name'.
      APPEND WA_FIELD_CAT TO IT_FIELD_CAT.
      CLEAR WA_FIELD_CAT.
        wa_field_cat-tabname = 'PA0002'.
      WA_FIELD_CAT-FIELDNAME = 'NACHN'.
        wa_field_cat-ref_tabname = 'IT_PA0002'.
      WA_FIELD_CAT-REPTEXT_DDIC = 'Last name'.
      APPEND WA_FIELD_CAT TO IT_FIELD_CAT.
      CLEAR WA_FIELD_CAT.
        wa_field_cat1-tabname = 'PA0002'.
      WA_FIELD_CAT1-FIELDNAME = 'PERNR'.
        wa_field_cat1-ref_tabname = 'IT_PA00021'.
      WA_FIELD_CAT1-REPTEXT_DDIC = 'Personnel no'.
      APPEND WA_FIELD_CAT1 TO IT_FIELD_CAT1.
      CLEAR WA_FIELD_CAT1.
        wa_field_cat1-tabname = 'PA0002'.
      WA_FIELD_CAT1-FIELDNAME = 'BEGDA'.
        wa_field_cat1-ref_tabname = 'IT_PA00021'.
      WA_FIELD_CAT1-REPTEXT_DDIC = 'Start date'.
      APPEND WA_FIELD_CAT1 TO IT_FIELD_CAT1.
      CLEAR WA_FIELD_CAT1.
        wa_field_cat1-tabname = 'PA0002'.
      WA_FIELD_CAT1-FIELDNAME = 'ENDDA'.
        wa_field_cat1-ref_tabname = 'IT_PA00021'.
      WA_FIELD_CAT1-REPTEXT_DDIC = 'End date'.
      APPEND WA_FIELD_CAT1 TO IT_FIELD_CAT1.
      CLEAR WA_FIELD_CAT1.
        wa_field_cat1-tabname = 'PA0002'.
      WA_FIELD_CAT1-FIELDNAME = 'VORNA'.
        wa_field_cat1-ref_tabname = 'IT_PA00021'.
      WA_FIELD_CAT1-REPTEXT_DDIC = 'First name'.
      APPEND WA_FIELD_CAT1 TO IT_FIELD_CAT1.
      CLEAR WA_FIELD_CAT.
        wa_field_cat1-tabname = 'PA0002'.
      WA_FIELD_CAT1-FIELDNAME = 'NACHN'.
        wa_field_cat1-ref_tabname = 'IT_PA00021'.
      WA_FIELD_CAT1-REPTEXT_DDIC = 'Last name'.
      APPEND WA_FIELD_CAT1 TO IT_FIELD_CAT1.
      CLEAR WA_FIELD_CAT1.
        wa_field_cat1-tabname = 'PA0008'.
        wa_field_cat1-fieldname = 'PERNR'.
          wa_field_cat-ref_tabname = 'IT_PA0008'.
        wa_field_cat1-REPTEXT_DDIC = 'personnelno'.
        APPEND wa_field_cat1 TO it_field_cat1.
       CLEAR WA_FIELD_CAT1.
        wa_field_cat1-tabname = 'PA0008'.
        wa_field_cat1-fieldname = 'BEGDA'.
          wa_field_cat-ref_tabname = 'IT_PA0008'.
        wa_field_cat1-REPTEXT_DDIC = 'begindate'.
        APPEND wa_field_cat1 TO it_field_cat1.
        CLEAR WA_FIELD_CAT1.
        wa_field_cat1-tabname = 'PA0008'.
        wa_field_cat1-fieldname = 'ENDDA'.
          wa_field_cat-ref_tabname = 'IT_PA0008'.
        wa_field_cat1-REPTEXT_DDIC = 'enddate'.
        APPEND wa_field_cat1 TO it_field_cat1.
        CLEAR WA_FIELD_CAT1.
        wa_field_cat1-tabname = 'PA0008'.
        wa_field_cat1-fieldname = 'ANSAL'.
          wa_field_cat-ref_tabname = 'IT_PA0008'.
        wa_field_cat1-REPTEXT_DDIC = 'annualsalary'.
        APPEND wa_field_cat1 TO it_field_cat1.
        CLEAR WA_FIELD_CAT1.
        wa_field_cat1-tabname = 'PA0008'.
        wa_field_cat1-fieldname = 'LGA01'.
          wa_field_cat-ref_tabname = 'IT_PA0008'.
        wa_field_cat1-REPTEXT_DDIC = 'wagetype'.
        APPEND wa_field_cat1 TO it_field_cat1.
        CLEAR WA_FIELD_CAT1.
        wa_field_cat1-tabname = 'PA0008'.
        wa_field_cat1-fieldname = 'BET01'.
          wa_field_cat-ref_tabname = 'IT_PA0008'.
        wa_field_cat1-REPTEXT_DDIC = 'Amount'.
        APPEND wa_field_cat1 TO it_field_cat1.
        CLEAR WA_FIELD_CAT1.
    ENDFORM.                    " build_field_cat
    *&      Form  display_data
          text
    FORM DISPLAY_DATA .
    it_layout-box_fieldname = 'CHECKBOX'.
    it_layout-EDIT = 'X'.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          I_CALLBACK_PROGRAM             = SY-REPID
          I_CALLBACK_PF_STATUS_SET       = 'PF_STATUS'
          I_CALLBACK_USER_COMMAND        = 'USER_COMMAND'
          IT_FIELDCAT                    = IT_FIELD_CAT
          IS_LAYOUT                      = IT_LAYOUT
          IT_EVENTS                      = IT_EVENTS
        TABLES
          T_OUTTAB           = IT_pa0002.
    ENDFORM.                    " display_data
    *&      Form  get_events
          text
    FORM GET_EVENTS .
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
       IMPORTING
         ET_EVENTS             = IT_EVENTS .
      READ TABLE IT_EVENTS INTO WA_EVENTS
                           WITH KEY NAME = SLIS_EV_TOP_OF_PAGE.
      IF SY-SUBRC = 0.
        WA_EVENTS-FORM = 'TOP_OF_PAGE'.
        MODIFY IT_EVENTS FROM WA_EVENTS INDEX SY-TABIX.
      ENDIF.
    ENDFORM.                    " get_events
    *&      Form  top_of_page
          text
    FORM TOP_OF_PAGE.
      WA_HEADER-TYP = 'H'.
      WA_HEADER-INFO = 'EMPLOYEE DATA'.
      APPEND WA_HEADER TO IT_HEADER.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          IT_LIST_COMMENTARY       = IT_HEADER
    ENDFORM. "top_of_page
    *&      Form  GUI_SET
    FORM GUI_SET USING RT_EXTAB TYPE SLIS_T_EXTAB .
      SET PF-STATUS 'DATA' .
    ENDFORM.                    "GUI_SET
    *&      Form  USER_COMMAND
    FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
                            R_SELFIELD TYPE SLIS_SELFIELD.
    DATA:V_PERNR LIKE PA0002-PERNR.
      CASE R_UCOMM.
        WHEN 'DET'.
    DATA: V_FLAG.
      clear : v_flag.
    LOOP AT IT_PA0002.
         if it_PA0002-checkbox =  'X'.
                   v_flag = 'X'.
              v_pernr = IT_PA0002-PERNR.
    SELECT  PERNR
            BEGDA
            ENDDA
            VORNA
            NACHN
            FROM PA0002
            INTO CORRESPONDING FIELDS OF TABLE IT_PA00021
            WHERE PERNR = V_PERNR.
    SORT IT_PA00021 BY PERNR.
    DELETE ADJACENT DUPLICATES FROM IT_PA00021 COMPARING PERNR.
    READ TABLE IT_PA00021 INDEX 1.
    SELECT PERNR
           BEGDA
           ENDDA
           ANSAL
           LGA01
           BET01
           FROM PA0008
           INTO TABLE IT_PA0008
           FOR ALL ENTRIES IN IT_PA00021
           WHERE PERNR = IT_PA00021-PERNR.
              if not it_PA0008[] Is initial.
              SORT IT_PA0008 BY PERNR.
             delete adjacent duplicates from  it_PA0008 comparing pernr.
              READ TABLE IT_PA0008 INDEX 1.
              endif.
            endif.
         enddo.
      it_layout1-group_change_edit = c.
      it_layout1-colwidth_optimize = c.
      it_layout1-zebra             = c.
      it_layout1-detail_popup      = c.
      it_layout1-get_selinfos      = c.
      it_layout-expand_fieldname  = 'EXPAND'.
      wa_keyinfo-header01 = 'PERNR'.
      wa_keyinfo-item01 = 'PERNR'.
    IF NOT V_FLAG IS INITIAL.
    CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'
      EXPORTING
       I_CALLBACK_PROGRAM             = SY-REPID
        IS_LAYOUT                      = IT_LAYOUT1
       IT_FIELDCAT                    =  IT_FIELD_CAT1
        I_TABNAME_HEADER               = 'PA0002'
        I_TABNAME_ITEM                 = 'PA0008'
        IS_KEYINFO                     = wa_keyinfo
        TABLES
        T_OUTTAB_HEADER                = IT_PA00021
        T_OUTTAB_ITEM                  = IT_PA0008.
    ENDIF.
    CLEAR: IT_PA00021,IT_PA0002,IT_PA0008.
    ENDLOOP.
    WHEN 'BACK'.
    EXIT.
    ENDCASE.
    ENDFORM.                    "USER_COMMAND
    reward points if useful,
    venkat.

  • How can I create a Report from a SWT-Application?

    Post Author: mkoch
    CA Forum: JAVA
    I'm a Developer and new to Crystal Reports and I have the job to create a Report from a SWT-Application.The report-files ( *.rpt) were created with Crystal Reports 10 or 11.> I'm not sure but I have access to a machine where Crystal Reports 10 Developer an Crystal Reports 11 Runtime are installed.Can anybody describe in detail how I can start the creation of a report from my Java-Application?> What libraries are needed, where can I get them and so on.I saw in the CR10-Setup that there is a Java-feature - but unfortunately this is not installed on my test-machine.--> Is it necessary to install this feature or can I get this files on businessobjects.com?Is it possible to start the report-creation from command-line?I saw a Java-example on the internet which uses Report.exe - but I haven't found this on my machine.I hope, that somebody can help me.GreetingsMarkus

    Inv. #
    Item
    Sale Price
    Lisa
    Oct Sold 12
    Oct Sold 12-2
    Oct Sold 12-3
    149
    Vase Lidded
    25
    201
    Bird
    7
    7
    202
    Bird
    7
    203
    Bird
    7
    204
    Bird
    7
    7
    205
    Bird
    7
    7
    206
    Bird
    7
    7
    207
    Bird
    7
    207
    Bird
    7
    7
    208
    Bird
    7
    7
    209
    Bird
    7
    7
    This is my very simple inventory.  On previous program I could sort by those items that did not have any figure in the row across.  Then I could print a report of open inventory.  Such as 149 Lidded Vase has not sales amount in the four colums across, thus it is open inventory.  How can I capture all those items in one report?

  • Can we create a report that show us all comments created for a specific MP

    Hi All,
    I have created documents for multiprovider.
    Now, I want to know whether we can create a report that shows all the documents created on this multiprovider or not.
    Your help will be rewarded.
    Regards,
    Haritha.

    Check out this post: http://forums.adobe.com/message/4399918#4399918
    You can use skip logic to get the desired effect. If you have problems do it just reply back.
    Randy

  • How can I create a report with a specified format in Answers

    Hello Everyone!
    I want to create a request in Answers gives me a report format like this:
    http://i25.tinypic.com/t6p0ee.jpg
    How can I achieve this?
    Please help!
    -D

    Thanks for quick replies. I think I was not able to give a lot of details.
    So, I am selecting a country, region, branch (branches can be multiple)
    The report is grouped by Branch (I get details of each individual projects within each of the branch, the total sales of individual projects and then total sales of the branch)
    The report then further gives me sum of sales of the branches that selected in my query.
    In the end I want the report to look similar to the pic I posted.
    Thanks!
    -D

  • ALV Report in PP module

    Hi everyone.
    I need to develop an ALV report. Select options are -
    AFPO-DWERK (plant) (Obligatory)
    AFPO-AUFNR (Prd Ord Num) (optional)
    AFKO-STLBEZ (Mat Nr) (optional)
    S022-ARBPL (Work Center) (optional)
    I have extracted all open production orders from AUFK and placed them in an internal table.
    Now how can I filter this list to the select options.
    Please help me.
    Related Tables  - AUFK, AFPO, AFKO.
    Thanks,
    Lakshmi

    just go to www.alvrobot.com.ar
    and the page will generate the code for you....

  • Can I create a report based on Non-Oracle template?

    Hi:
    I have a Microsoft Word document that contains the entire layout of a report I need to create with Oracle Report 6i. I know that I can create a report based on a template, but as I understand it, I am limited to using Oracle Reports templates. Does Reports support using foreign templates? Thanks for any word in this manner.
    Thomas Morgan
    :)

    oracle reports does not support using ms word documents as templates. there is a product in the oracle applications stack, XML publisher, that allows you to inject data into a word template.
    thanks,
    ph.

  • Can we create complete report in OOPs

    Hi,
    Could you please advice if we can code the complete report in SE24 and call it in SE38 report..
    For ex. I have a report followed by ALV output..now can i write everything in a Z Object (from decalration to output ) ..
    Kindly suggest if it is a good strategy than simply using standard objects in report editor.
    If possible, request you to provide a sample report using complete OOPs approach.
    Thanks,
    Gaurav

    Yes...the entire thing, INCLUDING SELECTION SCREEN, can be written in OO.  I haven't tried building the whole thing in SE24, then executing....what's the point?  A report may be pretty much one-off, but utilize pieces of classes.
    SAP Press recent manual "Official ABAP Progamming Guidlines" contains an example using Separation of Concerns/Software Layering approach that includes a selection screen call in the Presentation layer.  It can be done!  What I don't see is an easy or elegant way to re-process the selection screen if I must reject what the user has input and get different values....
    In that program, BTW, the start of selection event contains only:
    report->main( ).
    Main might look like:
    (from my program, not their version).  E-me if you want the entire program.
    class report definition.
      public section.
        class-methods main.
    endclass.                    "report DEFINITION
    class report implementation.
      method main.
        data: gt_itab   type table of gtyp_itab,
              so_tstmp  type table of iseldats,
              rpt_tab   type table of gtyp_rpt.
        data: rc      type sy-subrc.
        gui_level=>get_input_parms( ).  "calls selection screen!
        gui_level=>create_date_table(
                 changing so_tstmp = so_tstmp ).
        persistence_level=>get_data_from_db(
                      exporting so_tstmp = so_tstmp
                      importing gt_itab = gt_itab
                                     rc = rc ).
        if rc eq 0.
          apps_level=>sort_itab(
                  changing gt_itab = gt_itab ).
          apps_level=>build_report_table(
                  changing gt_itab = gt_itab
                           rpt_tab = rpt_tab ).
          if sy-subrc eq 0.
            gui_level=>display_alv_form( rpt_tab  ).
          endif.
        endif.
      endmethod.                    "main
    endclass.                    "report IMPLEMENTATION

Maybe you are looking for

  • For iTunes Match, how come some songs "match" on an album and other songs on the same album "upload" without matching?

    For iTunes Match, how come some songs "match" on an album and other songs on the same album "upload" without matching?  All songs are available on iTunes.  I don't get it!  Any way to manually match songs that iTunes apparently can't match?  I have h

  • Problem running batch file or OS command on XE database

    Hello, I´m trying to do the following, run a OS command from the database, especifically a 10g XE database and Windows XP sp3, since the database itself does not provide a Host command I did a C program and compiled it into a dll and then running an

  • Pdf mail lay out issue

    I developed a from in smart form to send it as PDF attachment in email. It worked fine but I have a issue. When I send PDF it send in the way the the layout was designed but if some user sends it the fields are printed zigzag. Alignment is getting me

  • Microsoft Office 2003

    Hi,  I recently purchased a new computer to replace my other one that died of old age. I was running Windows XP professional and I had Microsoft Office 2003 on it. My new computer is running Windows 7 but no Office. So I installed my Microsoft Office

  • How do you change quiz questions to look like your PowerPoint template without doing it manually on

    We have a customized PowerPoint template with our branding colors and font applied. We need the Presenter quiz questions to have the same customized look. We need the questions to appear differently than the default, and we need our branding colors a