How to read ALV Total

Hi Experts,
                 Am using ALV to calculate total for my field, now my req is i have to read that grand total value into a variable and store it in my ztable..please let me know how to read grand total which am displaying to user .
Regards
Syed

Hi,
The ALV Total will internally be calculated and stored in internal table 't_measure' attribute of method DO_AGGREGATION in class CL_SALV_WD_SERVICE_MANAGER.
There is no provision to retrieve this value( unless you enhance the mentioned class and store the value in some shared object). Even the Total value will be calculating by looping the internal table in the mentioned method.
So , remove the aggregation and calculate the total manually by looping the Internal table in your View controller and store it.
Hope this helps u,
Regards,
Kiran

Similar Messages

  • How to read a total column of a table?

    Hi All,
    I have a requirement where I have a hidden column in a table . I need to read its total value and place it as another fields total value.
    Note : Result table of the page is not an advanced table.
    OAMessageStyledTextBean HiddenAmount =
    (OAMessageStyledTextBean) webBean.findChildRecursive("HiddenAmount");
    if ( HiddenAmount!=null) {
    strHiddenTotal = HiddenAmount.getAttributeValue(HiddenAmount.TABULAR_FUNCTION_SUM)+"";
    strHiddenTotal1 = HiddenAmount.getAttributeValue(HiddenAmount.TABULAR_FUNCTION_SUM)+"";
    strHiddenTotal2 = HiddenAmount.getAttributeValue(TABULAR_FUNCTION_VALUE_ATTR)+"";
    But so far I am getting only null values.
    Thanks in advance
    Deep

    Hi Gaurav,
    Its not a advanced table. I have used the region style: Table. "HiddemAmount" is the column name of type MessageStyledText, for which I want to read total.
    Edited by: user13535721 on Dec 24, 2010 5:25 AM

  • Regarding ALV total

    Hi All,
    I have 2 alvs. Where in each one of them, the total is calculated for one of the fields by using the standard ALV total functionality.
    I need to show the grand total of these two.
    I could not find any method to get the total of that given field of a ALV. We are able to set the total. How to read the total being calculated by the standard functionality. I have checked the field settings but no method returns the total to avoid the looping for these 2 tables to calculate the total.
    Is there any way to get the total caclaulted by the standard functionality for that field.
    Regards,
    Lekha.

    No option found. Wish to see this feature in next release.

  • How to read the check box value in alv report

    hi experts,
    i m working on one alv report where i m using the check box for field selection in alv display.
    but i don't know how to read the only selected fields.
    wa_fieldcat-fieldname = 'BOX'.
      wa_fieldcat-tabname = 'IT_HEADER'.
      wa_fieldcat-seltext_m = 'Box'.
      wa_fieldcat-checkbox = 'X'.
      wa_fieldcat-input = 'X'.
      wa_fieldcat-edit = 'X'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-fieldname = 'AUFNR'.
      wa_fieldcat-tabname = 'IT_HEADER'.
      wa_fieldcat-seltext_m = 'Sales Doc'.
      wa_fieldcat-hotspot = 'X'.
      APPEND wa_fieldcat TO i_fieldcat.
      CLEAR wa_fieldcat.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
         i_callback_program                = v_repid
         I_CALLBACK_PF_STATUS_SET          = 'SET_PF_STATUS'
         i_callback_user_command           = 'USER_COMMAND'
         i_callback_top_of_page            = 'TOP_OF_PAGE'
         it_fieldcat                       = i_fieldcat[]
         i_save                            = 'A'
         it_events                         = v_events
        TABLES
          t_outtab                          = it_header
    EXCEPTIONS
      PROGRAM_ERROR                     = 1
      OTHERS                            = 2
    *&      Form  USER_COMMAND
          text
         -->R_UCOMM    text
         -->,          text
         -->RS_SLEFIELDtext
    FORM user_command USING r_ucomm LIKE sy-ucomm
    rs_selfield TYPE slis_selfield.
      CASE r_ucomm.
    when '&RELEAS'.
    endcase
    endform.
    i gone through some already posted que for same problem i tried options like
    loop at it_header.
    endloop.
    but i m getting box field empty.
    is there i missed something? plz sugeest.. if u have any other solution plz post...

    Have this code in your user command fm:
    * For capturing changed data
      CALL FUNCTION 'GET_GLOBALS_FROM_SLVC_FULLSCR'
        IMPORTING
          e_grid = w_grid.
      CALL METHOD w_grid->check_changed_data
        IMPORTING
          e_valid = w_valid.
      IF w_valid = 'X'.
    loop at itab where mark = 'X'.
    endloop.
    ENDIF.
    Regards,
    Ravi

  • How to get Grand Total Text in ALV GRID

    Hi Folks,
    I am able to get the SUBTOTAL TEXT .....But i need...
    How to get Grand Total Text in ALV GRID Display...
    Can any one give a Solution for this...

    Hi Surendar,
    Check out this code.. this is showing Total Text in Toal line in the very first column.
    REPORT  zsales_ord_det_1                        .
    TABLES: ztable_10.
    TYPE-POOLS: slis.
    DATA: BEGIN OF it OCCURS 0,
    srno(6) type c,
    name LIKE ztable_10-name,
    age LIKE ztable_10-age,
    END OF it.
    DATA : BEGIN OF it_temp OCCURS 0,
    name LIKE ztable_10-name,
    age LIKE ztable_10-age,
    END OF it_temp.
    DATA: i_fieldcat  TYPE slis_t_fieldcat_alv,
          wa_fieldcat TYPE  slis_fieldcat_alv.
    DATA: v_repid LIKE sy-repid,
           i_index TYPE STANDARD TABLE OF i WITH HEADER LINE,
           gs_layout TYPE slis_layout_alv,
           gd_layout TYPE slis_layout_alv,
           i_sort TYPE STANDARD TABLE OF slis_sortinfo_alv,
           wa_sort TYPE slis_sortinfo_alv.
    START-OF-SELECTION.
      v_repid = sy-repid.
      SELECT * FROM ztable_10 INTO TABLE it_temp.
      LOOP AT it_temp .
        it-srno = 'Total'.
        it-name = it_temp-name.
        it-age = it_temp-age.
        APPEND  it.
      ENDLOOP.
    END-OF-SELECTION.
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
       EXPORTING
         i_program_name               = v_repid
         i_internal_tabname           = 'IT'
      I_STRUCTURE_NAME             =
      I_CLIENT_NEVER_DISPLAY       = 'X'
         i_inclname                   = v_repid
      I_BYPASSING_BUFFER           =
      I_BUFFER_ACTIVE              =
        CHANGING
          ct_fieldcat                  = i_fieldcat[]
       EXCEPTIONS
         inconsistent_interface       = 1
         program_error                = 2
         OTHERS                       = 3
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    wa_fieldcat-row_pos = 1.
    wa_fieldcat-col_pos = 1.
    wa_fieldcat-fieldname = 'SRNO'.
    wa_fieldcat-tabname = it.
    append wa_fieldcat to i_fieldcat.
      LOOP AT i_fieldcat INTO wa_fieldcat.
        IF wa_fieldcat-fieldname = 'AGE'.
          wa_fieldcat-do_sum = 'X'.
          MODIFY i_fieldcat FROM wa_fieldcat.
        ENDIF.
       IF wa_fieldcat-fieldname = 'SRNO'.
         Hide this field so that it can display it's content i.e.
            Total text in Subtotal level
        wa_fieldcat-tech = 'X'.
          wa_fieldcat-no_out = 'X'.
          MODIFY i_fieldcat FROM wa_fieldcat TRANSPORTING tech no_out.
       ENDIF.
      ENDLOOP.
    wa_sort-spos = 1.
    wa_sort-fieldname = 'SRNO'.
    wa_sort-up = 'X'.
    wa_sort-subtot = 'X'.
    APPEND wa_sort TO i_sort.
      gd_layout-no_totalline = 'X'.
      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                = '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                                      = gd_layout
         it_fieldcat                                      = i_fieldcat[]
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
         it_sort                           = i_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_HYPERLINK                      =
      IT_ADD_FIELDCAT                   =
      IT_EXCEPT_QINFO                   =
      I_HTML_HEIGHT_TOP                 =
      I_HTML_HEIGHT_END                 =
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
        TABLES
          t_outtab                          = it
       EXCEPTIONS
         program_error                     = 1
         OTHERS                            = 2
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    Regards,
    Seema

  • How to get the total pages in ALV report?

    Hi guys,
    Since I used page breaks can somebody please help me on how to get the total pages in ALV report?sincerely please...thanks guys.

    automatic display total page.
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907
    r

  • WDABAP - How to read data from filtered ALV table

    HI
    In Web Dynpro for ABAP.
    I have a view with an ALV table on it.
    I would like to know how to read the data that's been filtered in the ALV table?
    Regards

    I've managed to find out that during runtime the following code returns a reference to a class pool:
    data: lr_salv_wd_table TYPE REF TO iwci_salv_wd_table.
    lr_salv_wd_table = wd_This->wd_cpIfc_ALV_GRAPHICS_DATA( )
    Two of the attributes of this class pool are:
              <b>IG_COMPONENTCONTROLLER~R_COMPONENT =    </b>                                       
    <b>          IF_COMPONENTCONTROLLER~R_COMPONENT =    </b>
    The attributes, IG_COMPONENTCONTROLLERR_COMPONENT and IF_COMPONENTCONTROLLERR_COMPONENT references a class CL_SALV_WD_C_TABLE. This class has an attribute R_RESULT_DATA which references a class CL_SALV_WD_RESULT_DATA_TABLE. The attribute T_RESULT_DATA contains the filtered data.
    Now I need to find out how I can access these attributes in the view.
    Regards

  • Webdynpro ABAP - ALV how can i display Total of Column

    Hi friends,
    Webdynpro ABAP - ALV how can i display Total of Columns.
    Please tell me any metod is there or any solution.
    Thanks,
    Kumar.

    Hi
    You can take help of following code snippet to create totals for a particular column
    Data: lr_function_settings TYPE REF TO CL_SALV_WD_CONFIG_TABLE.
      DATA: lr_column_settings TYPE REF TO if_salv_wd_column_settings,
            lr_column          TYPE REF TO cl_salv_wd_column,
            lt_column type salv_wd_t_column_ref,
            ls_column type salv_wd_s_column_ref.
    Data:  lr_field_amnt type REF TO CL_SALV_WD_FIELD.
    * get reference of ALV component
      lr_salv_wd_table = wd_this->wd_cpifc_OVERVIEW_EARNED_ALV( ).
      wd_this->alv_config_table = lr_salv_wd_table->get_model( ).
    *  get function settings
      lr_function_settings ?= wd_this->alv_config_table.
    * display columns in correct order
      lr_column_settings ?= wd_this->alv_config_table.
      lt_column = lr_column_settings->get_columns( ).
      loop at lt_column into ls_column.
    CASE ls_column-id.
    when 'AMOUNT'
    * aggregate field
            CALL METHOD LR_FUNCTION_SETTINGS->IF_SALV_WD_FIELD_SETTINGS~GET_FIELD
              EXPORTING
                FIELDNAME = 'AMOUNT'
              RECEIVING
                VALUE     = lr_field_amnt.
    * create aggregate rule as total
            CALL METHOD LR_FIELD_AMNT->IF_SALV_WD_AGGR~CREATE_AGGR_RULE
              EXPORTING
                AGGREGATION_TYPE = IF_SALV_WD_C_AGGREGATION=>AGGRTYPE_TOTAL
              RECEIVING
                VALUE            = lv_aggr_rule.
    endcase.
    Regards
    Manas DUa

  • How to read output rows in alv

    I have made alv grid. i have given checkbox for user to select the row.
      so how to read the selected rows.

    hi
    *REPORT YMS_ALVINTER.
    *& tables declaration
    TABLES: VBRK,VBRP.
    *& type-pools declaration
    TYPE-POOLS: SLIS.
    *& data declaration
    DATA: G_REPID TYPE SY-REPID.
    DATA : IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV, "mara
    WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
    WA_LAYOUT TYPE SLIS_LAYOUT_ALV,
    WA_EVENT TYPE SLIS_ALV_EVENT,
    T_EVENT TYPE SLIS_T_EVENT.
    DATA: V_VBELN LIKE VBRK-VBELN,
    V_MATNR LIKE VBRP-MATNR.
    DATA: BEGIN OF IT_VBRK OCCURS 0,
    VBELN LIKE VBRK-VBELN,
    WAERK LIKE VBRK-WAERK,
    VKORG LIKE VBRK-VKORG,
    FKDAT LIKE VBRK-FKDAT,
    BUKRS LIKE VBRK-BUKRS,
    NETWR LIKE VBRK-NETWR,
    END OF IT_VBRK.
    DATA: BEGIN OF IT_VBRP OCCURS 0,
    VBELN LIKE VBRP-VBELN,
    POSNR LIKE VBRP-POSNR,
    FKIMG LIKE VBRP-FKIMG,
    VRKME LIKE VBRP-VRKME,
    NETWR LIKE VBRP-NETWR,
    MATNR LIKE VBRP-MATNR,
    ARKTX LIKE VBRP-ARKTX,
    END OF IT_VBRP.
    *& selection screen
    SELECTION-SCREEN BEGIN OF BLOCK B WITH FRAME TITLE TEXT-001.
    SELECT-OPTIONS: S_VBELN FOR VBRK-VBELN,
    S_FKDAT FOR VBRK-FKDAT,
    S_MATNR FOR VBRP-MATNR.
    SELECTION-SCREEN END OF BLOCK B.
    **INITIALIZATION.
    INITIALIZATION.
    G_REPID = SY-REPID.
    S_FKDAT-LOW = SY-DATUM - 200.
    S_FKDAT-HIGH = SY-DATUM.
    APPEND S_FKDAT.
    ***AT SELECTION-SCREEN.
    AT SELECTION-SCREEN.
    IF NOT S_VBELN IS INITIAL.
    SELECT SINGLE VBELN FROM VBRK
    INTO V_VBELN
    WHERE VBELN IN S_VBELN.
    IF SY-SUBRC <> 0.
    MESSAGE E001(ZZ2).
    ENDIF.
    ENDIF.
    IF NOT S_MATNR IS INITIAL.
    SELECT SINGLE MATNR FROM MARA
    INTO V_MATNR
    WHERE MATNR IN S_MATNR.
    IF SY-SUBRC <> 0.
    MESSAGE E001(ZZ2).
    ENDIF.
    ENDIF.
    ***START-OF-SELECTION.
    START-OF-SELECTION.
    PERFORM GET_DATA_VBRK.
    *& Form GET_DATA_VBRK
    text
    --> p1 text
    <-- p2 text
    FORM GET_DATA_VBRK .
    SELECT VBELN
    WAERK
    VKORG
    FKDAT
    BUKRS
    NETWR
    INTO TABLE IT_VBRK
    FROM VBRK
    WHERE VBELN IN S_VBELN
    AND FKDAT IN S_FKDAT.
    ENDFORM. " GET_DATA_VBRK
    *& Form GET_DATA_VBRP
    text
    --> p1 text
    <-- p2 text
    FORM GET_DATA_VBRP .
    SELECT VBELN
    POSNR
    FKIMG
    VRKME
    NETWR
    MATNR
    ARKTX
    FROM VBRP
    INTO TABLE IT_VBRP
    WHERE VBELN = IT_VBRK-VBELN.
    ENDFORM. " GET_DATA_VBRP
    ***END-OF-SELECTION.
    END-OF-SELECTION.
    PERFORM EVENT_LIST.
    PERFORM GET_FIELD_CATALOG.
    PERFORM LIST_DISP .
    *& Form list_disp
    text
    FORM LIST_DISP .
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    I_INTERFACE_CHECK = ' '
    I_BYPASSING_BUFFER = ' '
    I_BUFFER_ACTIVE = ' '
    I_CALLBACK_PROGRAM = G_REPID
    I_CALLBACK_PF_STATUS_SET = 'POPUP'
    I_CALLBACK_USER_COMMAND = '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 = WA_LAYOUT
    IT_FIELDCAT = IT_FIELDCAT
    IT_EXCLUDING =
    IT_SPECIAL_GROUPS =
    IT_SORT =
    IT_FILTER =
    IS_SEL_HIDE =
    I_DEFAULT = 'X'
    I_SAVE = ' '
    IS_VARIANT =
    IT_EVENTS =
    IT_EVENT_EXIT =
    IS_PRINT =
    IS_REPREP_ID =
    I_SCREEN_START_COLUMN = 0
    I_SCREEN_START_LINE = 0
    I_SCREEN_END_COLUMN = 0
    I_SCREEN_END_LINE = 0
    IT_ALV_GRAPHICS =
    IT_HYPERLINK =
    IT_ADD_FIELDCAT =
    IT_EXCEPT_QINFO =
    I_HTML_HEIGHT_TOP =
    I_HTML_HEIGHT_END =
    IMPORTING
    E_EXIT_CAUSED_BY_CALLER =
    ES_EXIT_CAUSED_BY_USER =
    TABLES
    T_OUTTAB = IT_VBRK
    EXCEPTIONS
    PROGRAM_ERROR = 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.
    ENDFORM. " LIST_DISP
    *& Form GET_FIELD_CATALOG
    text
    --> p1 text
    <-- p2 text
    FORM GET_FIELD_CATALOG .
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
    I_PROGRAM_NAME = G_REPID
    I_INTERNAL_TABNAME = 'IT_VBRK'
    I_STRUCTURE_NAME =
    I_CLIENT_NEVER_DISPLAY = 'X'
    I_INCLNAME = G_REPID
    I_BYPASSING_BUFFER =
    I_BUFFER_ACTIVE =
    CHANGING
    CT_FIELDCAT = IT_FIELDCAT
    EXCEPTIONS
    INCONSISTENT_INTERFACE = 1
    PROGRAM_ERROR = 2
    OTHERS = 3
    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_FIELD_CATALOG
    *& Form event_list
    text
    --> p1 text
    <-- p2 text
    FORM EVENT_LIST .
    CLEAR WA_EVENT.
    WA_EVENT-NAME = 'USER_COMMAND'.
    WA_EVENT-FORM = 'USER_COMMAND'.
    APPEND WA_EVENT TO T_EVENT.
    CLEAR WA_EVENT.
    ENDFORM. " event_list
    *& Form user_command
    text
    -->R_UCOMM text
    -->RS_SELFIELDtext
    FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
    RS_SELFIELD TYPE SLIS_SELFIELD.
    CASE R_UCOMM.
    WHEN '&IC1'.
    READ TABLE IT_VBRK INDEX RS_SELFIELD-TABINDEX.
    PERFORM GET_DATA_VBRP.
    PERFORM BUILD_FIELDCATALOG_VBRP .
    PERFORM DISPLAY_ALV_VBRP.
    ENDCASE.
    ENDFORM. "user_command
    *& Form BUILD_FIELDCATALOG_VBRP
    text
    --> p1 text
    <-- p2 text
    FORM BUILD_FIELDCATALOG_VBRP .
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
    I_PROGRAM_NAME = G_REPID
    I_INTERNAL_TABNAME = 'IT_VBRP'
    I_STRUCTURE_NAME =
    I_CLIENT_NEVER_DISPLAY = 'X'
    I_INCLNAME = G_REPID
    I_BYPASSING_BUFFER =
    I_BUFFER_ACTIVE =
    CHANGING
    CT_FIELDCAT = IT_FIELDCAT
    EXCEPTIONS
    INCONSISTENT_INTERFACE = 1
    PROGRAM_ERROR = 2
    OTHERS = 3
    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. " BUILD_FIELDCATALOG_VBRP
    *& Form DISPLAY_ALV_VBRP
    text
    --> p1 text
    <-- p2 text
    FORM DISPLAY_ALV_VBRP .
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    I_INTERFACE_CHECK = ' '
    I_BYPASSING_BUFFER = ' '
    I_BUFFER_ACTIVE = ' '
    I_CALLBACK_PROGRAM = G_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 = IT_FIELDCAT
    IT_EXCLUDING =
    IT_SPECIAL_GROUPS =
    IT_SORT =
    IT_FILTER =
    IS_SEL_HIDE =
    I_DEFAULT = 'X'
    I_SAVE = ' '
    IS_VARIANT =
    IT_EVENTS =
    IT_EVENT_EXIT =
    IS_PRINT =
    IS_REPREP_ID =
    I_SCREEN_START_COLUMN = 0
    I_SCREEN_START_LINE = 0
    I_SCREEN_END_COLUMN = 0
    I_SCREEN_END_LINE = 0
    IT_ALV_GRAPHICS =
    IT_HYPERLINK =
    IT_ADD_FIELDCAT =
    IT_EXCEPT_QINFO =
    I_HTML_HEIGHT_TOP =
    I_HTML_HEIGHT_END =
    IMPORTING
    E_EXIT_CAUSED_BY_CALLER =
    ES_EXIT_CAUSED_BY_USER =
    TABLES
    T_OUTTAB = IT_VBRP
    EXCEPTIONS
    PROGRAM_ERROR = 1
    OTHERS = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDFORM. " DISPLAY_ALV_VBRP
    Message was edited by:
            Rammohan Nagam
    Message was edited by:
            Rammohan Nagam

  • How to read green light from ALV list display during BDC

    Hi,
    I am currently writing a BDC on CK11 transaction, after the user enters all the data he has to check log for any errors. The log is shown using ALV LIST DISPLAY and the errors are identified by RED lights on ALV LIST DISPLAY. At this point in BDC i have to either save or exit depending the status lights shown on the screen.
    Does anybody has any idea on how to read these lights from the screen ?
    thanks
    Udai

    Hi,
    I agree with Rich here. Never seen this done before (and I'm pretty sure you can't do it), but if someone has a funky way of doing it please share!
    Cheers,
    Pat.

  • How to use alv in progrmm

    hi all
    thanks in advance
    how to use alv in programm please can any one send me simple example of alv
    thanks

    Hi,
    Refer this code. If u find it useful, reward points.
    TYPE-POOLS: slis.
         Data Declaration
    DATA: wa_layout       TYPE slis_layout_alv, "Layout structure
          it_fieldcatalog TYPE slis_t_fieldcat_alv, " Fieldcatlog IT
          wa_fieldcatalog TYPE slis_fieldcat_alv, " Fieldcatlog WA
          lt_event TYPE slis_t_event, "for capturing page events
          ls_event TYPE slis_alv_event. " WA for Page Events
    Data: l_syrep type sy-repid,
          l_tcode type sy-tcode.
    *& I N I T I A L I Z A T I O N                                         *
    INITIALIZATION .
    l_syrep = sy-repid.
    l_tcode = sy-tcode.
    *&               AT SELECTION-SCREEN                                   *
    AT SELECTION-SCREEN.
    *&               START-OF-SELECTION                                    *
    START-OF-SELECTION.
    *&               END-OF-SELECTION                                      *
    END-OF-SELECTION.
       PERFORM build_layout.
       PERFORM build_catlog.
       PERFORM build_events.
    *&               AT LINE-SELECTION                                     *
    AT LINE-SELECTION.
    *&      Form  build_layout
          Building the Layout
    FORM build_layout .
    wa_layout-ZEBRA = 'X'.
    wa_layout-NO_VLINE = 'X'.
    wa_layout-NO_HLINE = 'X'.
    wa_layout-CELL_MERGE = 'X'.
    wa_layout-EDIT = 'X'.
    wa_layout-WINDOW_TITLEBAR = ''.
    wa_layout-NO_ULINE_HS = 'X'.
    wa_layout-LIGHTS_FIELDNAME = ''.
    wa_layout-LIGHTS_TABNAME = ''.
    wa_layout-LIGHTS_ROLLNAME = ''.
    wa_layout-LIGHTS_CONDENSE = 'X'.
    wa_layout-NO_TOTALLINE = 'X'.
    wa_layout-NO_SUBTOTALS = 'X'.
    wa_layout-TOTALS_BEFORE_ITEMS = 'X'.
    wa_layout-TOTALS_ONLY = 'X'.
    wa_layout-TOTALS_TEXT = ''.
    wa_layout-SUBTOTALS_TEXT = ''.
    wa_layout-BOX_FIELDNAME = ''.
    wa_layout-BOX_TABNAME = ''.
    wa_layout-BOX_ROLLNAME = ''.
    wa_layout-CONFIRMATION_PROMPT = 'X'.
    wa_layout-HEADER_TEXT = ''.
    ENDFORM.                    " build_layout
    *&      Form  build_catlog
          Building the Field Catlog
    FORM build_catlog .
    wa_fieldcatalog-ROW_POS = 0.
    wa_fieldcatalog-COL_POS = 0.
    wa_fieldcatalog-FIELDNAME = ''.
    wa_fieldcatalog-TABNAME = ''.
    wa_fieldcatalog-CHECKBOX = 'X'.
    wa_fieldcatalog-DO_SUM = 'X'.
    wa_fieldcatalog-OUTPUTLEN = ''.
    wa_fieldcatalog-wa_fieldcatalog-OFFSET = ''.
    wa_fieldcatalog-SELTEXT_L = ''.
    wa_fieldcatalog-SELTEXT_M =''.
    wa_fieldcatalog-SELTEXT_S =''.
    wa_fieldcatalog-REF_FIELDNAME =''.
    wa_fieldcatalog-REF_TABNAME = ''.
    wa_fieldcatalog-NO_SUM ='X'.
    wa_fieldcatalog-EDIT ='X'.
    wa_fieldcatalog-HOTSPOT = 'X'.
    APPEND  wa_fieldcatalog TO it_fieldcatalog.
    CLEAR   wa_fieldcatalog.
    ENDFORM.                    " build_catlog
    *&      Form  build_events
          Building the Events
    FORM build_events .
    Get all possible events
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 0
        IMPORTING
          et_events       = lt_event
        EXCEPTIONS
          list_type_wrong = 1
          OTHERS          = 2.
      IF sy-subrc <> 0.
      ENDIF.
    Specify events used in selection screen
      READ TABLE lt_event WITH KEY name = slis_ev_top_of_page
                         INTO ls_event.
      IF sy-subrc = 0.
        ls_event-form = 'TOP_OF_PAGE'.
        MODIFY lt_event FROM ls_event INDEX sy-tabix.
        CLEAR ls_event.
      ENDIF.
      READ TABLE lt_event WITH KEY name = slis_ev_end_of_list
                         INTO ls_event.
      IF sy-subrc = 0.
        ls_event-form = 'END_OF_LIST'.
        MODIFY lt_event FROM ls_event INDEX sy-tabix.
        CLEAR ls_event.
      ENDIF.
    ENDFORM.                    " build_events
    *&      Form  TOP_OF_PAGE
    To display top of the page
    FORM top_of_page .
    data: lt_top_of_page type slis_t_listheader,
           ls_line type slis_listheader.
      clear ls_line.
      ls_line-typ  = 'H'.
      ls_line-info = ''.
      append ls_line to lt_top_of_page.
      clear ls_line.
      ls_line-typ  = 'S'.
      ls_line-key  = ''.
      ls_line-info = ''.
      append ls_line to lt_top_of_page.
      clear ls_line.
      ls_line-typ  = 'A'.
      ls_line-info = ''.
      append ls_line to  lt_top_of_page.
      clear ls_line.
       CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary       = lt_top_of_page
      I_LOGO                   =
      I_END_OF_LIST_GRID       =
    ENDFORM.                    " TOP_OF_PAGE
    *&      Form  end-of-list
    To display the totals at the end of the list
    FORM end_of_list .
    ENDFORM.                    " end-of-list
    *&      Form  set_pf_status
          Set the Pf Status
    FORM pf_status USING pa_extab TYPE slis_t_extab.
       SET PF-STATUS 'ZXXXX'.
    ENDFORM.                    "SET_PF_STATUS
    *&      Form  user_command
          To Catch the User Events
         -->PA_UCOMM     text
         -->PA_SELFIELD  text
    FORM user_command USING pa_ucomm TYPE syucomm
                            pa_selfield TYPE slis_selfield.
      CASE pa_ucomm.
          WHEN '&IC1'.
              CLEAR gs_output .
              READ TABLE gt_output INTO gs_output INDEX pa_selfield-tabindex .
              CASE pa_selfield-fieldname .
              ENDCASE.
          WHEN 'XXX'.
          WHEN 'XXX'.
      ENDCASE.
    ENDFORM.                    "USER_COMMAND

  • How to send ALV Grid report to Email?

    hai all,
    How to send ALV Grid report to Email.
    please its very urgent.....

    Hi,
    when u run the Alv, u will button 'Mail Recepiant' in tool bar.When u click it and enter to new screen, go to the Recipient Tab(down) enter ur maild id and click 'Send' button on tool bar.
    or.
    if u want to send the Alv content to mail id thru prg, go thru the following code.
                              TABLES
    TABLES: BSID. " Accounting: Secondary Index for Customers.
                              TYPE-POOLS
    TYPE-POOLS: SLIS.
                              INTERNAL TABLES
        Internal table to hold Customer data.
    DATA: BEGIN OF TB_BSID OCCURS 0,
            BUKRS   LIKE BSID-BUKRS,    " Company code
            KUNNR   LIKE BSID-KUNNR,    " Customer number
            AUGDT   LIKE BSID-AUGDT,    " Clearing Date
            BLDAT   LIKE BSID-BLDAT,    " Doc date in document
            SHKZG   LIKE BSID-SHKZG,    " Debit/credit indicator
            DMBTR   LIKE BSID-DMBTR,    " Amount in local currency
            ZFBDT   LIKE BSID-ZFBDT,    " Baseline date for due date calc
            ZBD1T   LIKE BSID-ZBD1T,    " Cash discount days 1
            ZBD2T   LIKE BSID-ZBD2T,    " Cash discount days 2
            ZBD3T   LIKE BSID-ZBD3T,    " Net Payment Terms Period
            REBZG   LIKE BSID-REBZG,    " No Of the Inv the Tran Belongs to
            REBZT   LIKE BSID-REBZT,    " Follow-On Document Type
          END OF TB_BSID.
        Internal table to hold Open Items.
    DATA: TB_BSID_OPEN LIKE TABLE OF TB_BSID WITH HEADER LINE.
        Internal table to hold Cleared Items.
    DATA: TB_BSAD_CLEAR LIKE TABLE OF TB_BSID WITH HEADER LINE.
        Internal table to hold General Data in Customer Master
    DATA: BEGIN OF TB_KNA1 OCCURS 0,
            KUNNR LIKE KNA1-KUNNR,      " Customer Number
            NAME1 LIKE KNA1-NAME1,      " Name Line 1
            TELF1 LIKE KNA1-TELF1,      " Telephone Number
            ADRNR LIKE KNA1-ADRNR,      " Address
          END OF TB_KNA1.
        Internal table to hold Customer Master (Company Code)
    DATA: BEGIN OF TB_KNB1 OCCURS 0,
            KUNNR LIKE KNB1-KUNNR,     " Customer Number
            BUKRS LIKE KNB1-BUKRS,     " Company code
            ERDAT LIKE KNB1-ERDAT,     " Rec Created Date
            ZAMIB LIKE KNB1-ZAMIB,     " DMS Managed Indicator
          END OF TB_KNB1.
        Internal table to hold Final Output Data
    DATA: BEGIN OF TB_FINAL OCCURS 0,
            KUNNR           LIKE KNA1-KUNNR, " Customer Number
            NAME1           LIKE KNA1-NAME1, " Name Line 1
            ADDRESS1(25)    TYPE C,          " Address line 1
            ADDRESS2(25)    TYPE C,          " Address line 2
            ADDRESS3(25)    TYPE C,          " Address line 3
            ADDRESS4(25)    TYPE C,          " Address line 4
            PHONE           LIKE KNA1-TELF1, " Telephone Number
            DAYS_SLOW(3)    TYPE C,          " Days Slow
            LAST_DATE(8)    TYPE C,          " Date of Last Invoice
            AVG(4)          TYPE C,          " Average Days to Pay
            CURRENT(10)     TYPE N,          " Current
            AVG_1_30(10)    TYPE N,          " 1-30 past due
            AVG_31_60(10)   TYPE N,          " 31-60 past due
            AVG_61_90(10)   TYPE N,          " 61-90 past due
            AVG_90G(10)     TYPE N,          " 90+ past due
          END OF TB_FINAL.
         ALV Internal tables
    DATA : TB_FIELDCAT       TYPE SLIS_T_FIELDCAT_ALV,  " Field Catalog
           TB_EVENTS         TYPE SLIS_T_EVENT,         " ALV Events
           TB_COMMENTS       TYPE SLIS_T_LISTHEADER.    " Comment
        Internal tables for the sending mail data
    DATA: TB_OBJPACK  TYPE SOPCKLSTI1 OCCURS 2  WITH HEADER LINE,
          TB_OBJHEAD  TYPE SOLISTI1   OCCURS 1  WITH HEADER LINE,
          TB_OBJTXT   TYPE SOLISTI1   OCCURS 10 WITH HEADER LINE,
          TB_RECLIST  TYPE SOMLRECI1  OCCURS 5  WITH HEADER LINE,
          TB_OBJBIN   LIKE SOLISTI1   OCCURS 0  WITH HEADER LINE,
          TB_DOC_CHNG TYPE SODOCCHGI1.
        Internal table to get mail Receivers Address
    DATA: TB_ZRECEIVE LIKE YSMTP_ADDRESS OCCURS 0 WITH HEADER LINE.
                               STRUCTURES
    DATA: X_SADR            TYPE SADR,                 " For Address
          X_FIELDCAT        TYPE SLIS_FIELDCAT_ALV,    " For Field Catalog
          X_LAYOUT          TYPE SLIS_LAYOUT_ALV,      " For Layout
          X_EVENTS          TYPE SLIS_ALV_EVENT,       " For Events
          X_COMMENTS        TYPE SLIS_LISTHEADER,      " For Comments
          X_ADDR1_SEL       LIKE ADDR1_SEL,            " For Address
          WA_FAEDE          TYPE FAEDE.                " For FAEDE struct
                               VARIABLES
    DATA: G_REPID        LIKE SY-REPID,             " Prog ID
          G_DAYS_SLOW(3) TYPE N,                    " Days Slow
          G_OPEN         TYPE I,                    " Counter
          G_AVG(4)       TYPE C,                    " Avg Days
          G_COUNT        TYPE I,                    " Counter
          G_TITLE        TYPE SOLISTI1-LINE,        " Description
          G_TAB_LINES    TYPE SY-TABIX,             " Internal data count
          G_REC_COUNT    TYPE I,                    " Total records
          G_CURR_BAL     TYPE N,                    " Account balance
          G_FILE_NAME    LIKE EDI_PATH-PTHNAM.      " Output File Name
                               CONSTANTS
    CONSTANTS: C_D            TYPE C VALUE 'D',     " Account type
               C_X            TYPE C VALUE 'X',     " Check Value
               C_0(4)         TYPE N VALUE '0.00',  " Constant for char
               C_1(2)         TYPE C VALUE '01',    " Posting key const
               C_H            TYPE C VALUE 'H',     " For Commenet-Type
               C_TXT(3)       TYPE N VALUE 'TXT',   " File type
               C_RAW(3)       TYPE C VALUE 'RAW',   " File type
               C_DELIMITER    TYPE X VALUE '09',    " ASCII CODE LINE
               C_TOP_OF_PAGE  TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE',
               C_INTERFACE    TYPE YWFSALOFFICNOTIF-INTERFACE_ID VALUE 'AP',
               C_FILENAME(20) TYPE N VALUE 'TEXT.TXT'," File name
               C_TITLE(30)    TYPE N VALUE 'Z21614_DB_CREDIT_AGENCY',
               C_Z001 TYPE RF035-RASID VALUE 'Z001'." Net 30/60/90/120/150
                               SELECTION SCREEN.
    Selection Screen for Selection Criteria.
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-T01.
    SELECT-OPTIONS:  S_BUKRS FOR  BSID-BUKRS OBLIGATORY,    " Company Code
                     S_BLDAT FOR  BSID-BLDAT," OBLIGATORY,  " Doc Date
                     S_KUNNR FOR  BSID-KUNNR,               " Cust No
                     S_ZUONR FOR  BSID-ZUONR.               " Assignment
    PARAMETERS:      P_GRACE(2)   TYPE N OBLIGATORY,        " Grace Days
                     P_ZAMIB LIKE KNB1-ZAMIB AS CHECKBOX.   " DMS Indicator
    SELECTION-SCREEN END OF BLOCK B1.
    Selection Screen for Output Options.
    SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-T02.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN POSITION 01.
    PARAMETERS: P_REPORT RADIOBUTTON GROUP R1.             " Report Only
    SELECTION-SCREEN COMMENT 5(25) TEXT-016.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN POSITION 01.
    PARAMETERS: P_DOWN RADIOBUTTON GROUP R1.               " Dwnld to Unix
    SELECTION-SCREEN COMMENT 5(25) TEXT-017.
    SELECTION-SCREEN POSITION 30.
    PARAMETERS: P_FILE LIKE FILENAME-FILEINTERN DEFAULT
                                 'Z21614_DB_CREDIT_AGENCY'. " File Name
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN END OF BLOCK B2.
    Selection Screen for E-mail.
    SELECTION-SCREEN BEGIN OF BLOCK B3 WITH FRAME TITLE TEXT-T03.
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN POSITION 01.
    PARAMETERS: P_EMAIL AS CHECKBOX.                        " E-mail
    SELECTION-SCREEN COMMENT 5(25) TEXT-018.
    SELECTION-SCREEN END OF LINE.
    SELECTION-SCREEN END OF BLOCK B3.
                               INITIALIZATION
    INITIALIZATION.
      G_REPID = SY-REPID.
                   AT SELECTION SCREEN.                                  *
    AT SELECTION-SCREEN.
    Validation of selection screen entries
    perform validate_data.
                               START-OF-SELECTION
    START-OF-SELECTION.
    Select Data from Customer Master (Company Code)
      PERFORM SELECT_KNB1.
    Select Custmer Open Items.
      PERFORM SELECT_CUSTOMER_OPEN_ITEMS.
    Select Custmer Cleared Items.
      PERFORM SELECT_CUSTOMER_CLEARED_ITEMS.
    Select General Data in Customer Master
      PERFORM SELECT_KNA1.
    Populate Final Output Data.
      PERFORM POPULATE_TB_FINAL.
                       End of selection                                  *
    END-OF-SELECTION.
    If both display report and send email is checked
      IF P_REPORT = C_X AND P_EMAIL  = C_X.
        MESSAGE E999 WITH
          'Select One Among Report Only & Send E-mail'(023).
    When Radiobutton for Email or if the program is run background
      ELSEIF ( P_EMAIL = C_X OR SY-BATCH = C_X ).
      To send the mail
        PERFORM SEND_EMAIL.
      ELSEIF P_REPORT = C_X .
      To display the Final Output data using ALV's
        PERFORM DISPLAY_ALV_REPORT.
      ENDIF.
    Transfering data to file when downloading to Unix
      IF P_DOWN = C_X.
        IF G_REC_COUNT IS INITIAL.
          MESSAGE I999 WITH
            'No Records Found For Selection Criteria'(024).
          EXIT.
        ELSE.
          IF NOT G_FILE_NAME IS INITIAL.
          Trasefering data to file
            PERFORM TRANSFER_DATA_FILE.
          Interface Audit report
            PERFORM WRITE_REPORT.
          ENDIF.
        ENDIF.
      ENDIF.
                              F O R M S
    *&      Form  VALIDATE_DATA
          Validating selection-screen entries
    FORM VALIDATE_DATA.
    Local variables
      DATA : L_BUKRS LIKE BSEG-BUKRS,          " For Company Code
             L_KUNNR LIKE BSEG-KUNNR.          " For Customer Number
    Validate the Company code.
      SELECT SINGLE BUKRS
        INTO L_BUKRS
        FROM T001
       WHERE BUKRS IN S_BUKRS.
      IF SY-SUBRC <> 0.
        MESSAGE E999 WITH 'Enter valid Company Code'(025).
      ENDIF.
    Validate the Customer number
      IF NOT S_KUNNR[] IS INITIAL.
        SELECT SINGLE KUNNR
          INTO L_KUNNR
          FROM KNA1
         WHERE KUNNR IN S_KUNNR.
        IF SY-SUBRC <> 0.
          MESSAGE E999 WITH 'Enter valid Customer Number'(026).
        ENDIF.
      ENDIF.
    ENDFORM.                    " VALIDATE_DATA
    *&      Form  SELECT_KNB1
          Select Data from Customer Master (Company Code)
    FORM SELECT_KNB1 .
      CLEAR: TB_KNB1,
             TB_KNB1[].
      SELECT KUNNR
             BUKRS
             ERDAT
             ZAMIB
             FROM KNB1
             INTO TABLE TB_KNB1
             WHERE BUKRS IN S_BUKRS
               AND KUNNR IN S_KUNNR.
      IF SY-SUBRC = 0.
      Sort TB_KNB1 by Customer no & Rec Created Date
        SORT TB_KNB1 BY KUNNR ERDAT DESCENDING.
      ENDIF.
    ENDFORM.                    " SELECT_KNB1
    *&      Form  SELECT_CUSTOMER_OPEN_ITEMS
          Select Custmer Open Items.
    FORM SELECT_CUSTOMER_OPEN_ITEMS .
      CLEAR: TB_BSID,
             TB_BSID[].
      SELECT  A~BUKRS
              B~KUNNR
              B~AUGDT
              B~BLDAT
              B~SHKZG
              B~DMBTR
              B~ZFBDT
              B~ZBD1T
              B~ZBD2T
              B~ZBD3T
              B~REBZG
              B~REBZT
         INTO TABLE TB_BSID
         FROM BKPF AS A JOIN BSID AS B
           ON ABUKRS = BBUKRS
          AND ABELNR = BBELNR
          AND AGJAHR = BGJAHR
        WHERE A~BUKRS IN S_BUKRS
          AND A~BLDAT IN S_BLDAT
          AND B~KUNNR IN S_KUNNR
          AND B~ZUONR IN S_ZUONR
          AND B~BSCHL = C_1.
      IF SY-SUBRC = 0.
      DMS Managed Indicator  = ‘X’.
        IF P_ZAMIB = C_X.
          LOOP AT TB_KNB1 WHERE ZAMIB = SPACE.
            DELETE TB_BSID WHERE BUKRS = TB_KNB1-BUKRS
                             AND KUNNR = TB_KNB1-KUNNR.
          ENDLOOP.
        ENDIF.
      Transfering Open Items from TB_BSID to TB_BSID_OPEN
        TB_BSID_OPEN[] = TB_BSID[].
      ENDIF.
    ENDFORM.                    " SELECT_CUSTOMER_OPEN_ITEMS
    *&      Form  SELECT_CUSTOMER_CLEARED_ITEMS
          Select Custmer Cleared Items.
    FORM SELECT_CUSTOMER_CLEARED_ITEMS .
      CLEAR: TB_BSAD_CLEAR,
             TB_BSAD_CLEAR[].
      SELECT   A~BUKRS
               B~KUNNR
               B~AUGDT
               B~BLDAT
               B~SHKZG
               B~DMBTR
               B~ZFBDT
               B~ZBD1T
               B~ZBD2T
               B~ZBD3T
               B~REBZG
               B~REBZT
          INTO TABLE TB_BSAD_CLEAR
          FROM BKPF AS A JOIN BSAD AS B
            ON ABUKRS = BBUKRS
          AND  ABELNR = BBELNR
          AND  AGJAHR = BGJAHR
         WHERE A~BUKRS IN S_BUKRS
           AND A~BLDAT IN S_BLDAT
           AND B~KUNNR IN S_KUNNR
           AND B~ZUONR IN S_ZUONR
           AND B~BSCHL = C_1.
      IF SY-SUBRC = 0.
      DMS Managed Indicator = ‘X’.
        IF P_ZAMIB = C_X.
          LOOP AT TB_KNB1 WHERE ZAMIB = SPACE.
            DELETE TB_BSID WHERE BUKRS = TB_KNB1-BUKRS
                             AND KUNNR = TB_KNB1-KUNNR.
          ENDLOOP.
        ENDIF.
      Sort TB_BSID_CLEAR by Customer number
        SORT TB_BSAD_CLEAR BY KUNNR.
      ENDIF.
    Append lines of TB_BSID_CLEAR to table TB_BSID
      APPEND LINES OF TB_BSAD_CLEAR TO TB_BSID.
    Sort TB_BSID by Cust num AND Doc date in document
      SORT TB_BSID BY KUNNR BLDAT.
    ENDFORM.                    " SELECT_CUSTOMER_CLEARED_ITEMS
    *&      Form  SELECT_KNA1
          Select General Data in Customer Master
    FORM SELECT_KNA1.
      CLEAR: TB_KNA1,
             TB_KNA1[].
      SELECT  KUNNR
              NAME1
              TELF1
              ADRNR
         INTO TABLE TB_KNA1
         FROM KNA1
        WHERE KUNNR IN S_KUNNR.
      IF SY-SUBRC <> 0.
      ENDIF.
    ENDFORM.                    " SELECT_KNA1
    *&      Form  POPULATE_TB_FINAL
          Populate Final Output Data.
    FORM POPULATE_TB_FINAL.
    Local variable
      DATA: L_DAYS_SLOW(3) TYPE N.       " Days Slow
      CLEAR: TB_FINAL,
             TB_FINAL[].
      LOOP AT TB_KNA1.
      Move-corresponding TB_KNA1 to TB_FINAL.
        TB_FINAL-KUNNR = TB_KNA1-KUNNR.  " Customer Number
        TB_FINAL-NAME1 = TB_KNA1-NAME1.  " Name Line 1
        TB_FINAL-PHONE = TB_KNA1-TELF1.  " Telephone Number
      To get Customer Address.
        PERFORM GET_CUSTOMER_ADDRESS.
      To get Date of Last Invoice.
        READ TABLE TB_BSID WITH KEY KUNNR = TB_KNA1-KUNNR.
        IF SY-SUBRC = 0.
          TB_FINAL-LAST_DATE = TB_BSID-BLDAT.
        ENDIF.
      To get past due and current details.
        PERFORM GET_PAST_DUE_CURRENT.
      To get Days Slow.
        CLEAR WA_FAEDE .
        LOOP AT TB_BSID_OPEN WHERE KUNNR = TB_KNA1-KUNNR.
          WA_FAEDE-SHKZG = TB_BSID-SHKZG.
          WA_FAEDE-ZFBDT = TB_BSID-ZFBDT.
          WA_FAEDE-ZBD1T = TB_BSID-ZBD1T.
          WA_FAEDE-ZBD2T = TB_BSID-ZBD2T.
          WA_FAEDE-ZBD3T = TB_BSID-ZBD3T.
          WA_FAEDE-REBZG = TB_BSID-REBZG.
          WA_FAEDE-REBZT = TB_BSID-REBZT.
          WA_FAEDE-KOART = C_D.
        To Determine Due Date.
          CALL FUNCTION 'DETERMINE_DUE_DATE'
               EXPORTING
                    I_FAEDE                    = WA_FAEDE
               IMPORTING
                    E_FAEDE                    = WA_FAEDE
               EXCEPTIONS
                    ACCOUNT_TYPE_NOT_SUPPORTED = 1
                    OTHERS                     = 2.
          IF SY-SUBRC <> 0.
            CLEAR WA_FAEDE.
            MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                  WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
          ENDIF.
          CLEAR: L_DAYS_SLOW.
          L_DAYS_SLOW = SY-DATUM - WA_FAEDE-NETDT - P_GRACE.
          G_DAYS_SLOW = G_DAYS_SLOW + ABS( L_DAYS_SLOW ).
          G_OPEN      = G_OPEN + 1.
        ENDLOOP.
        IF G_OPEN IS INITIAL.
          TB_FINAL-DAYS_SLOW = G_DAYS_SLOW / G_OPEN.  " Days Slow
        ENDIF.
      To get Average days to Pay.
        PERFORM GET_AVG_DAYS_PAY.
      Calculating total records .
        G_REC_COUNT = G_REC_COUNT + 1.
        APPEND TB_FINAL.
        CLEAR  TB_FINAL.
      ENDLOOP.
    Current account balance.
      G_CURR_BAL   = TB_FINAL-CURRENT + TB_FINAL-AVG_1_30  +
                                        TB_FINAL-AVG_31_60 +
                                        TB_FINAL-AVG_61_90 +
                                        TB_FINAL-AVG_90G   .
    ENDFORM.                    " POPULATE_TB_FINAL
    *&      Form  GET_PAST_DUE_CURRENT
          To get past due and current details.
    FORM GET_PAST_DUE_CURRENT.
        Local Varaibles.
      DATA: L_RF035_SFAE1 TYPE RF035-SFAE1,
            L_RF035_SFAE2 TYPE RF035-SFAE2,
            L_RF035_SFAE3 TYPE RF035-SFAE3,
            L_RF035_SFAE4 TYPE RF035-SFAE4,
            L_RF035_SFAE5 TYPE RF035-SFAE5,
            L_RF035_SFAE6 TYPE RF035-SFAE6,
            L_RF035_SFAEL TYPE RF035-SFAEL,
            L_RF035_SNFA1 TYPE RF035-SNFA1,
            L_RF035_SNFA2 TYPE RF035-SNFA2,
            L_RF035_SNFA3 TYPE RF035-SNFA3,
            L_RF035_SNFA4 TYPE RF035-SNFA4,
            L_RF035_SNFA5 TYPE RF035-SNFA5,
            L_RF035_SNFA6 TYPE RF035-SNFA6,
            L_RF035_SNFAE TYPE RF035-SNFAE.
      LOOP AT TB_KNB1 WHERE KUNNR = TB_KNA1-KUNNR.
        CALL FUNCTION 'CUSTOMER_DUE_DATE_ANALYSIS'
             EXPORTING
                  BUKRS          = TB_KNB1-BUKRS
                KKBER          = ' '
                  KUNNR          = TB_KNB1-KUNNR
                  RASID          = C_Z001
             IMPORTING
                  SFAE1          = L_RF035_SFAE1
                  SFAE2          = L_RF035_SFAE2
                  SFAE3          = L_RF035_SFAE3
                  SFAE4          = L_RF035_SFAE4
                  SFAE5          = L_RF035_SFAE5
                  SFAE6          = L_RF035_SFAE6
                  SFAEL          = L_RF035_SFAEL
                  SNFA1          = L_RF035_SNFA1
                  SNFA2          = L_RF035_SNFA2
                  SNFA3          = L_RF035_SNFA3
                  SNFA4          = L_RF035_SNFA4
                  SNFA5          = L_RF035_SNFA5
                  SNFA6          = L_RF035_SNFA6
                  SNFAE          = L_RF035_SNFAE
             EXCEPTIONS
                  INVALID_RASTER = 1
                  NO_OPEN_ITEMS  = 2
                  OTHERS         = 3
        IF SY-SUBRC = 0.
          TB_FINAL-AVG_1_30  = TB_FINAL-AVG_1_30  + L_RF035_SFAE1.
          TB_FINAL-AVG_31_60 = TB_FINAL-AVG_31_60 + L_RF035_SFAE2.
          TB_FINAL-AVG_61_90 = TB_FINAL-AVG_61_90 + L_RF035_SFAE3.
          TB_FINAL-AVG_90G   = TB_FINAL-AVG_90G   + L_RF035_SFAE4
                                                  + L_RF035_SFAE5
                                                  + L_RF035_SFAE6.
          TB_FINAL-CURRENT  = TB_FINAL-CURRENT    + L_RF035_SNFAE.
        ELSE.
          MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
                  WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    " GET_PAST_DUE_CURRENT
    *&      Form  GET_CUSTOMER_ADDRESS
          To get Customer Address.
    FORM GET_CUSTOMER_ADDRESS.
      X_ADDR1_SEL-ADDRNUMBER = TB_KNA1-ADRNR.
      CALL FUNCTION 'ADDR_GET'
           EXPORTING
                ADDRESS_SELECTION = X_ADDR1_SEL
           IMPORTING
                SADR              = X_SADR
           EXCEPTIONS
                PARAMETER_ERROR   = 1
                ADDRESS_NOT_EXIST = 2
                VERSION_NOT_EXIST = 3
                INTERNAL_ERROR    = 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.
      ADDRESS LINE 1.
      TB_FINAL-ADDRESS1 = X_SADR-STRAS.
      ADDRESS LINE 2.
      CONCATENATE X_SADR-PFACH 'CODE' X_SADR-PSTL2 INTO TB_FINAL-ADDRESS2
                                                      SEPARATED BY SPACE.
      ADDRESS LINE 3.
      CONCATENATE  X_SADR-ORT01 X_SADR-ORT02 ',' X_SADR-REGIO X_SADR-PSTLZ
                                INTO TB_FINAL-ADDRESS3 SEPARATED BY SPACE.
      ADDRESS LINE 4.
      TB_FINAL-ADDRESS4 = X_SADR-LAND1.
    ENDFORM.                    " GET_CUSTOMER_ADDRESS
    *&      Form  GET_AVG_DAYS_PAY
          To get Average days to Pay.
    FORM GET_AVG_DAYS_PAY.
    *Local variable
      DATA: L_DAYS TYPE N .                            " Number of Days
      LOOP AT TB_BSAD_CLEAR WHERE KUNNR = TB_KNA1-KUNNR.
        L_DAYS  = TB_BSAD_CLEAR-AUGDT - TB_BSAD_CLEAR-BLDAT.
        G_AVG   = G_AVG + L_DAYS.
        G_COUNT = G_COUNT + 1.
      ENDLOOP.
      IF NOT G_COUNT IS INITIAL.
        TB_FINAL-AVG = G_AVG / G_COUNT. " Average days to Pay.
      ENDIF.
    ENDFORM.                    " GET_AVG_DAYS_PAY
    *&      Form  DISPLAY_ALV_REPORT
          text
    FORM DISPLAY_ALV_REPORT.
    For Populating Field Catalog.
      PERFORM RPT_BUILD_FIELDCATLOG.
    For Modifying Field Catalog.
      PERFORM RPT_MODIFY_FIELDCATLOG.
    For TOP_OF_PAGE Event.
      PERFORM RPT_GET_EVENTS.
    For Displaying Output in Grid Format.
      PERFORM RPT_GRID_DISPLAY.
    ENDFORM.                    " DISPLAY_ALV_REPORT
    *&      Form  RPT_BUILD_FIELDCATLOG
          text
    FORM RPT_BUILD_FIELDCATLOG.
    To build the Field Catlog.
      DATA : L_TABNAME TYPE SLIS_TABNAME.  " Table Name
      L_TABNAME = 'TB_FINAL'.
      REFRESH : TB_FIELDCAT.
      CLEAR   : TB_FIELDCAT.
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
           EXPORTING
                I_PROGRAM_NAME         = G_REPID
                I_INTERNAL_TABNAME     = L_TABNAME
                I_INCLNAME             = G_REPID
           CHANGING
                CT_FIELDCAT            = TB_FIELDCAT
           EXCEPTIONS
                INCONSISTENT_INTERFACE = 1
                PROGRAM_ERROR          = 2
                OTHERS                 = 3.
      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.                    " RPT_BUILD_FIELDCATLOG
    *&      Form  RPT_MODIFY_FIELDCATLOG
          text
    FORM RPT_MODIFY_FIELDCATLOG.
    Getting the Header Text for the Coloumns
      DATA : L_TABIX LIKE SY-TABIX,            " Index
             L_DDICTXT TYPE C  VALUE 'L'.      " Flag
    Getting the Header Text for the Coloumns
      LOOP AT TB_FIELDCAT INTO X_FIELDCAT.
        CLEAR L_TABIX.
        L_TABIX = SY-TABIX.
        CASE X_FIELDCAT-FIELDNAME.
          WHEN 'KUNNR'.                                   " Customer Number
            X_FIELDCAT-SELTEXT_L = 'Customer Number'(001).
            X_FIELDCAT-DDICTXT   =  L_DDICTXT.
          WHEN 'NAME1'.                                   " Name Line 1
            X_FIELDCAT-SELTEXT_L = 'Name'(002).
            X_FIELDCAT-DDICTXT   =  L_DDICTXT.
          WHEN 'ADDRESS1'.                                " Address line 1
            X_FIELDCAT-SELTEXT_L = 'Address 1'(003).
            X_FIELDCAT-DDICTXT   =  L_DDICTXT.
          WHEN 'ADDRESS2'.                                " Address line 2
            X_FIELDCAT-SELTEXT_L = 'Address 2'(004).
            X_FIELDCAT-DDICTXT   =  L_DDICTXT.
          WHEN 'ADDRESS3'.                                " Address line 3
            X_FIELDCAT-SELTEXT_L = 'Address 3'(005).
            X_FIELDCAT-DDICTXT   =  L_DDICTXT.
          WHEN 'ADDRESS4'.                                " Address line 4
            X_FIELDCAT-SELTEXT_L = 'Address 4'(006).
            X_FIELDCAT-DDICTXT   =  L_DDICTXT.
          WHEN 'PHONE'.                                   " Telephone Number
            X_FIELDCAT-SELTEXT_L = 'Telephone Number'(007).
            X_FIELDCAT-DDICTXT   =  L_DDICTXT.
          WHEN 'DAYS_SLOW'.                               " Days Slow
            X_FIELDCAT-SELTEXT_L = 'Days Slow'(008).
            X_FIELDCAT-DDICTXT      =  L_DDICTXT.
          WHEN 'LAST_DATE'.                         " Date of Last Invoice
            X_FIELDCAT-SELTEXT_L = 'Date of Last Invoice'(009).
            X_FIELDCAT-DDICTXT   =  L_DDICTXT.
          WHEN 'AVG'.                               " Average Days to Pay
            X_FIELDCAT-SELTEXT_L = 'Average Days to Pay'(010).
            X_FIELDCAT-DDICTXT   =  L_DDICTXT.
          WHEN 'CURRENT'.                  " Current
            X_FIELDCAT-SELTEXT_L = 'Aging Category 1'(011).
            X_FIELDCAT-DDICTXT   =  L_DDICTXT.
          WHEN 'AVG_1_30'.                  " 1-30 past due
            X_FIELDCAT-SELTEXT_L = 'Aging Category 2'(012).
            X_FIELDCAT-DDICTXT   =  L_DDICTXT.
          WHEN 'AVG_31_60'.                  " 31-60 past due
            X_FIELDCAT-SELTEXT_L = 'Aging Category 3'(013).
            X_FIELDCAT-DDICTXT   =  L_DDICTXT.
          WHEN 'AVG_61_90'.                  " 61-90 past due
            X_FIELDCAT-SELTEXT_L = 'Aging Category 4'(014).
            X_FIELDCAT-DDICTXT   =  L_DDICTXT.
          WHEN 'AVG_90G'.                  " 90+ past due
            X_FIELDCAT-SELTEXT_L = 'Aging Category 5'(015).
            X_FIELDCAT-DDICTXT   =  L_DDICTXT.
        ENDCASE.
        MODIFY TB_FIELDCAT FROM X_FIELDCAT INDEX L_TABIX.
      ENDLOOP.
    ENDFORM.                    " RPT_MODIFY_FIELDCATLOG
    *&      Form  RPT_GET_EVENTS
          text
    FORM RPT_GET_EVENTS.
      DATA : L_TABIX TYPE SY-TABIX.                " Index
      CLEAR   : TB_EVENTS,
                TB_EVENTS[].
    To get the events from this function module
    for ALV display
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
           EXPORTING
                I_LIST_TYPE     = 0
           IMPORTING
                ET_EVENTS       = TB_EVENTS
           EXCEPTIONS
                LIST_TYPE_WRONG = 1
                OTHERS          = 2.
      IF SY-SUBRC <> 0.
        MESSAGE I999 WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    Modifing Top of Page event
      READ TABLE TB_EVENTS WITH KEY NAME = SLIS_EV_TOP_OF_PAGE
                          INTO X_EVENTS.
      IF SY-SUBRC = 0.
        CLEAR L_TABIX.
        L_TABIX = SY-TABIX.
        X_EVENTS-FORM = C_TOP_OF_PAGE.
        MODIFY TB_EVENTS FROM X_EVENTS INDEX L_TABIX.
        CLEAR  X_EVENTS.
      ENDIF.
    ENDFORM.                    " RPT_GET_EVENTS
    *&      Form  TOP_OF_PAGE
          Top Of Page for the ALV format
    FORM  TOP_OF_PAGE.
      REFRESH TB_COMMENTS.
    For heading
      CLEAR   X_COMMENTS.
      X_COMMENTS-TYP  = C_H.
      X_COMMENTS-INFO = 'D&B Credit Agency Interface'(019).
      APPEND X_COMMENTS TO TB_COMMENTS.
    This module outputs formatted simple header information at TOP-OF-PAGE
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
           EXPORTING
                IT_LIST_COMMENTARY = TB_COMMENTS.
    ENDFORM.                          " TOP_OF_PAGE
    *&      Form  RPT_GRID_DISPLAY
          text
    FORM RPT_GRID_DISPLAY.
    Layout Settings
      CLEAR X_LAYOUT.
      X_LAYOUT-ZEBRA = 'X'.
      X_LAYOUT-COLWIDTH_OPTIMIZE = C_X.
      X_LAYOUT-NO_COLHEAD        = SPACE.
    To Display the Output in ALV Format
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
           EXPORTING
                I_CALLBACK_PROGRAM = G_REPID
                IS_LAYOUT          = X_LAYOUT
                IT_FIELDCAT        = TB_FIELDCAT
                IT_EVENTS          = TB_EVENTS
           TABLES
                T_OUTTAB           = TB_FINAL
           EXCEPTIONS
                PROGRAM_ERROR      = 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.
    ENDFORM.                    " RPT_GRID_DISPLAY
    *&      Form  SEND_EMAIL
          text
    -->  p1        text
    <--  p2        text
    FORM SEND_EMAIL.
    Prepare the mail
      PERFORM SEND_MAIL USING C_INTERFACE.
    Sending the mail to Receivers
      PERFORM SENDING_MAIL.
    ENDFORM.                    " SEND_EMAIL
    *&      Form  SEND_MAIL
         Sending the Mail
    FORM SEND_MAIL USING  P_C_INTERFACE TYPE YWFSALOFFICNOTIF-INTERFACE_ID.
    Populating Report name
      G_TITLE = C_TITLE.
      PERFORM POPULATE_EMAIL_REF_DATA USING G_TITLE.
      IF NOT G_REC_COUNT IS INITIAL.
      To populate the data to table tb_objbin
        PERFORM POPULATE_DATA_OBJBIN.
      To get the attached file for the mail
        CLEAR G_TAB_LINES.
        DESCRIBE TABLE TB_OBJBIN LINES G_TAB_LINES.
        TB_OBJHEAD = C_FILENAME.
        APPEND TB_OBJHEAD.
        CLEAR TB_OBJHEAD.
      Creation of the entry for the mail
        TB_OBJPACK-TRANSF_BIN = C_X.
        TB_OBJPACK-HEAD_START = C_1.
        TB_OBJPACK-HEAD_NUM   = C_1.
        TB_OBJPACK-BODY_START = C_1.
        TB_OBJPACK-BODY_NUM   = G_TAB_LINES.
        TB_OBJPACK-DOC_TYPE   = C_TXT.
        TB_OBJPACK-OBJ_NAME   = G_REPID.
        TB_OBJPACK-OBJ_DESCR  = 'Interface Audit Report'(020).
        TB_OBJPACK-DOC_SIZE   = G_TAB_LINES * 255.
        APPEND TB_OBJPACK.
      ENDIF.
    ENDFORM.                    " SEND_MAIL
    *&      Form  SENDING_MAIL
    FORM SENDING_MAIL.
    Function Module to send mail along with attached file
      CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
           EXPORTING
                DOCUMENT_DATA              = TB_DOC_CHNG
           TABLES
                PACKING_LIST               = TB_OBJPACK
                OBJECT_HEADER              = TB_OBJHEAD
                CONTENTS_BIN               = TB_OBJBIN
                CONTENTS_TXT               = TB_OBJTXT
                RECEIVERS                  = TB_RECLIST
           EXCEPTIONS
                TOO_MANY_RECEIVERS         = 1
                DOCUMENT_NOT_SENT          = 2
                DOCUMENT_TYPE_NOT_EXIST    = 3
                OPERATION_NO_AUTHORIZATION = 4
                PARAMETER_ERROR            = 5
                X_ERROR                    = 6
                ENQUEUE_ERROR              = 7
                OTHERS                     = 8.
      CASE SY-SUBRC.
        WHEN 0.
          MESSAGE S999 WITH 'Mail has been sucessfully sent'(029).
        WHEN 1.
          MESSAGE S999 WITH 'Too Many Parameters'(030).
        WHEN 2.
          MESSAGE S999 WITH 'Doc Could Not Be Sent'(031).
        WHEN 4.
          MESSAGE S999 WITH 'No Authority To Send'(032).
        WHEN 99.
          MESSAGE S999 WITH 'Error While Sending'(033).
      ENDCASE.
    ENDFORM.                    " SENDING_MAIL
    *&      Form  POPULATE_EMAIL_REF_DATA
       Poplulating the body of the mail
    FORM POPULATE_EMAIL_REF_DATA USING TEXT TYPE SOLISTI1-LINE.
    Setting up Mail Subject
      TB_DOC_CHNG-OBJ_DESCR = 'Interface Audit Report'(020).
    Populating body of the mail
      TB_OBJTXT-LINE = 'Interface Audit Report'(020).
      APPEND TB_OBJTXT.
      CLEAR: TB_OBJTXT.
      DESCRIBE TABLE TB_OBJTXT LINES G_TAB_LINES.
      READ TABLE TB_OBJTXT INDEX G_TAB_LINES.
    *To determine the document size
    TB_DOC_CHNG-DOC_SIZE = ( G_TAB_LINES - 1 ) * 255 + STRLEN( TB_OBJTXT ).
    Creation of the entry for the Mail Contents
      CLEAR TB_OBJPACK-TRANSF_BIN.
      TB_OBJPACK-HEAD_START = C_1.
      TB_OBJPACK-HEAD_NUM = C_0.
      TB_OBJPACK-BODY_START = C_1.
      TB_OBJPACK-BODY_NUM = G_TAB_LINES.
      TB_OBJPACK-DOC_TYPE = C_RAW.
      APPEND TB_OBJPACK.
    ENDFORM.                    " POPULATE_EMAIL_REF_DATA
    *&      Form  POPULATE_DATA_OBJBIN
          Populating table for file attachment

  • ALV Totals , Subtotals for a particular field in ALV Grid report

    Hi,
    I have an issue in ALV totals and subtotals.
    Scenario is like this.
    i have a vendor data to be pulled out of SAP and to be shown in the form of report.
    i am populating all the data and doing do_sum based on Vendor ( has expansin & collapse option ) and display the number of reports .
    Vendor -
    100
    Vendor1 -
    1
    Vendor2----
    2.
    Vendor100----
    100.
    but my problem is in the same report i have a date field .
    if i have a five vendors created on 03/03/2008. in the same report for the date field having ( expansion & collapse ) , when i expand based on that date can i be able to sum up all the vendors created on 03/03/2008 and display in the same report along with the vendor count.
    Let me know . Thank you in advance
    Regards,
    Ry

    Hi Roby,
    Have a look at this sample code
    It will help u,
    REPORT ZIN_FI_AGEING
           message-id zbdc
           no standard page heading.
    Title                   : For Ageing Details
    Author                  :
    Date                    : 22/11/2004
    Transport/Correction Id :
    Clarify case ID         :
    Application             : FI
    Program Type            :
    Frequency               :
    Purpose                 :
    Comments                :
    Request No              :
      TABLES DELCARATIONS
    Tables: zzgeinz9a,    "Actual line item table
            t001.         "Plants/Branches
      ALV TTPE DELCARATIONS
    type-pools: slis.
    *Type Declarations for Field Catalog
    data : i_fldcat_head type slis_t_fieldcat_alv,
           wa_fldcat_head type slis_fieldcat_alv.
    *Type Declarations for ALV Events
    data : i_events type slis_t_event,
           wa_event like line of i_events.
    *Type Declarations for Layout Design
    data : wa_layout type slis_layout_alv.
    *Type Declarations for Sorting Fields
    data:  it_sort type slis_sortinfo_alv occurs 0 with header line.
    *Type Declarations for Displaying Images on Grid
    data : i_comment type slis_t_listheader,
           wa_comment type slis_listheader.
    *Type Declarations for Grouping fields
    data : wa_group type slis_sp_group_alv,
           i_group type slis_t_sp_group_alv.
      DATA DELCARATIONS
    data: v_flag,                 "Status Flag
          v_repid like sy-repid,  "Program Name
          p_year(4) type c,       "Year
          v_due_days type i.      "To hold the due days
      CONSTANTS DELCARATIONS
    constants: c_x type c value 'X',
               c_bukrs(4) type c value '0373'.
      INTERNAL TABLES DELCARATIONS
    *--Internal table to hold the required data
    data: begin of it_final_vendor occurs 0,
            rzzlifnr    like zzgeinz9a-rzzlifnr,  "Vendor
            name1       like lfa1-name1,          "Vendor Name
            docnr       like zzgeinz9a-DOCNR,     "Accounting Doc No
            refdocnr    like zzgeinz9a-REFDOCNR,  "Reference document no
            belnr       like bkpf-belnr,          "FI Doc No
            doc_date    like bkpf-awkey,          "Document Date
            zbd1t       like bsik-zbd1t,          "Cash discount days 1
            bldat       like bkpf-bldat,          "Document Date
            due_date    like bkpf-bldat,          "Due Date
            due_days    type i,                   "Due Days
            rzz_ebeln   like zzgeinz9a-rzz_ebeln, "P.O. Ref No
            not_due     like zzgeinz9a-hsl,       "Not Yet Due
            hsl         like zzgeinz9a-hsl,       "local currency
            found       type c,                   "Existance Flag
          end of it_final_vendor.
    data: begin of it_final_vendor_temp occurs 0,
            rzzlifnr    like zzgeinz9a-rzzlifnr,  "Vendor
            name1       like lfa1-name1,          "Vendor Name
            belnr       like bkpf-belnr,          "FI Doc No
            bldat       like bkpf-bldat,          "Document Date
            rzz_ebeln   like zzgeinz9a-rzz_ebeln, "P.O. Ref No
            hsl        like zzgeinz9a-hsl,        "local currency
            due_date    like bkpf-bldat,          "Due Date
            due_days    type i,                   "Due Days
            not_due     like zzgeinz9a-hsl,       "Not Yet Due
            buck_0_30   like zzgeinz9a-hsl,       "Invoiceamt in localcurr
            buck_31_60  like zzgeinz9a-hsl,       "Invoiceamt in localcurr
            buck_61_90  like zzgeinz9a-hsl,       "Invoiceamt in localcurr
            buck_91_180 like zzgeinz9a-hsl,       "Invoiceamt in localcurr
            buck_180    like zzgeinz9a-hsl,       "Invoiceamt in localcurr
            docnr       like zzgeinz9a-DOCNR,     "Accounting Doc No
            refdocnr    like zzgeinz9a-REFDOCNR,  "Reference document no
            doc_date    like bkpf-awkey,          "Document Date
            found       type c,                   "Existance Flag
          end of it_final_vendor_temp.
    data: begin of it_final_customer occurs 0,
            rzzkunnr    like zzgeinz9a-rzzkunnr,  "Customer
            name1       like kna1-name1,          "Customer Name
            docnr       like zzgeinz9a-DOCNR,     "Accounting Doc No
            refdocnr    like zzgeinz9a-REFDOCNR,  "Reference document no
            belnr       like bkpf-belnr,          "FI Doc No
            doc_date    like bkpf-awkey,          "Document Date
            zbd1t       like bsik-zbd1t,          "Cash discount days 1
            bldat       like bkpf-bldat,          "Document Date
            due_date    like bkpf-bldat,          "Due Date
            due_days    type i,                   "Due Days
            rzz_ebeln   like zzgeinz9a-rzz_ebeln, "P.O. Ref No
            not_due     like zzgeinz9a-hsl,       "Not Yet Due
            hsl         like zzgeinz9a-hsl,       "local currency
            found       type c,                   "Existance Flag
          end of it_final_customer.
    data: begin of it_final_customer_temp occurs 0,
            rzzkunnr    like zzgeinz9a-rzzkunnr,  "Customer
            name1       like kna1-name1,          "Customer Name
            belnr       like bkpf-belnr,          "FI Doc No
            bldat       like bkpf-bldat,          "Document Date
            rzz_ebeln   like zzgeinz9a-rzz_ebeln, "P.O. Ref No
            hsl        like zzgeinz9a-hsl,        "local currency
            due_date    like bkpf-bldat,          "Due Date
            due_days    type i,                   "Due Days
            not_due     like zzgeinz9a-hsl,       "Not Yet Due
            buck_0_30   like zzgeinz9a-hsl,       "Invoiceamt in localcurr
            buck_31_60  like zzgeinz9a-hsl,       "Invoiceamt in localcurr
            buck_61_90  like zzgeinz9a-hsl,       "Invoiceamt in localcurr
            buck_91_180 like zzgeinz9a-hsl,       "Invoiceamt in localcurr
            buck_180    like zzgeinz9a-hsl,       "Invoiceamt in localcurr
            docnr       like zzgeinz9a-DOCNR,     "Accounting Doc No
            refdocnr    like zzgeinz9a-REFDOCNR,  "Reference document no
            doc_date    like bkpf-awkey,          "Document Date
            found       type c,                   "Existance Flag
          end of it_final_customer_temp.
    *--Internal Table to hold the Cash discount days 1 for Vendors
    data: begin of it_final_bsik occurs 0,
            belnr like bsik-belnr,
            zbd1t like bsik-zbd1t,
          end of it_final_bsik.
    *--Internal Table to hold the Cash discount days 1 for Customers
    data: begin of it_final_bsid occurs 0,
            belnr like bsid-belnr,
            zbd1t like bsid-zbd1t,
          end of it_final_bsid.
      INITIALIZATION
    v_repid = sy-repid.
      SELECTION SCREEN
    selection-screen: begin of block b1 with frame title text-h01.
    selection-screen skip.
    select-options: s_vendor for zzgeinz9a-rzzlifnr modif id ven.
    parameters: p_comp1 like t001-bukrs modif id ven.
    parameters: p_rundt1 like bkpf-bldat modif id ven.
    select-options: s_cust for zzgeinz9a-rzzkunnr modif id cst.
    parameters: p_comp2 like t001-bukrs modif id cst.
    parameters: p_rundt2 like bkpf-bldat modif id cst.
    selection-screen skip.
    selection-screen: begin of block b2 with frame title text-h02.
    parameters : p_vendor radiobutton group gr1 default 'X'
                                      user-command test,
                 p_cust  radiobutton group gr1.
    selection-screen: end of block b2.
    selection-screen: end of block b1.
    **************************AT Selection Screen OutPut ******************
    at selection-screen output.
      loop at screen.
        if p_cust = 'X'.
          if screen-group1 = 'VEN'.
            screen-active = '0'.
            screen-input = '0'.
            screen-output = '0'.
            screen-invisible = '0'.
          endif.
        elseif p_vendor = 'X'.
          if screen-group1 = 'CST'.
            screen-active = '0'.
            screen-input = '0'.
            screen-output = '0'.
            screen-invisible = '0'.
          endif.
        endif.
        modify screen.
      endloop.
      SELECTION SCREEN ON
    at selection-screen on s_vendor.
    *--Validating Vendor
      if not s_vendor[] is initial.
        perform validate_s_vendor.
      endif.
    at selection-screen on s_cust.
    *--Validating Customer
      if not s_cust[] is initial.
        perform validate_s_cust.
      endif.
    at selection-screen on p_comp1.
    *--Validating Company Code.
      if not p_comp1 is initial.
        perform validate_p_comp1.
      endif.
    at selection-screen on p_comp2.
    *--Validating Company Code.
      if not p_comp2 is initial.
        perform validate_p_comp2.
      endif.
      START OF SELECTION
    start-of-selection.
    if p_vendor = 'X'.
       perform get_vendor_data.
    elseif p_cust = 'X'.
       perform get_customer_data.
    endif.
      END OF SELECTION
    end-of-selection.
    if p_vendor = 'X'.
    *--Generating the output for vendor
      perform generate_field_catalog_vendor.
      perform get_events_vendor.
      perform generate_layout_vendor.
      perform generate_sort_vendor.
      perform generate_group_vendor.
      perform disp_alv_grid_vendor.
    elseif p_cust = 'X'.
    *--Generating the output for customer
      perform generate_field_catalog_cust.
      perform get_events_customer.
      perform generate_layout_customer.
      perform generate_sort_customer.
      perform generate_group_customer.
      perform disp_alv_grid_customer.
    endif.
    *&      Form  validate_s_vendor
          Validating the Vendor
    form validate_s_vendor.
      select rzzlifnr up to 1 rows
      into (zzgeinz9a-rzzlifnr)
      from zzgeinz9a
      where rzzlifnr in s_vendor.
      endselect.
      if sy-subrc ne 0.
        message e004 with 'Invalid Range of Vendor'(002)
    s_vendor-low 'To'(006) s_vendor-high.
      endif.
    endform.                    " validate_s_vendor
    *&      Form  validate_s_cust
          Validating the Customer
    form validate_s_cust.
       select rzzkunnr up to 1 rows
       into (zzgeinz9a-rzzkunnr)
       from zzgeinz9a
       where rzzkunnr in s_cust.
       endselect.
       if sy-subrc ne 0.
         message e004 with 'Invalid Range of Customer'(005)
    s_cust-low 'To'(006) s_cust-high.
      endif.
    endform.                    " validate_s_cust
    *&      Form  validate_p_comp1
          Validating the Company Code
    form validate_p_comp1.
      select single bukrs
             into   (t001-bukrs)
             from   t001
             where  bukrs eq p_comp1.
      if sy-subrc ne 0.
        message e004 with 'Company Code'(004) p_comp1 'Does not Exists'(003)
      endif.
    endform.                    " validate_p_comp1
    *&      Form  validate_p_comp2
          Validating the Company Code
    form validate_p_comp2.
      select single bukrs
             into   (t001-bukrs)
             from   t001
             where  bukrs eq p_comp2.
      if sy-subrc ne 0.
        message e004 with 'Company Code'(004) p_comp2 'Does not Exists'(003)
      endif.
    endform.                    " validate_p_comp2
    *&      Form  get_vendor_data
          Getting the Vendor Related Docs
    form get_vendor_data.
    select a~rzzlifnr
            b~name1
            a~docnr
            a~refdocnr
            a~rzz_ebeln
            a~hsl
        into corresponding fields of table it_final_vendor
        from zzgeinz9a as a
        inner join lfa1 as b
        on arzzlifnr = blifnr
        where rzzlifnr in s_vendor
        and   rbukrs   eq p_comp1.
        if sy-subrc eq 0.
          v_flag = 'X'.
          p_year = sy-datum+0(4).
          perform get_doc_date using p_comp1
                                     p_year.
          perform move_records.
          sort it_final_vendor by rzzlifnr.
          perform generate_data.
        else.
          v_flag = space.
        endif.
    endform.                    " get_vendor_data
    *&      Form  get_customer_data
          Getting the Customer Related Docs
    form get_customer_data.
    select a~rzzkunnr
            b~name1
            a~docnr
            a~refdocnr
            a~rzz_ebeln
            a~hsl
        into corresponding fields of table it_final_customer
        from zzgeinz9a as a
        inner join kna1 as b
        on arzzkunnr = bkunnr
        where rzzkunnr in s_cust
        and   rbukrs   eq p_comp2.
        if sy-subrc eq 0.
          v_flag = 'X'.
          p_year = sy-datum+0(4).
          perform get_doc_date_cust using p_comp2
                                          p_year.
          perform move_records_cust.
          sort it_final_customer by rzzkunnr.
          perform generate_data_cust.
        else.
          v_flag = space.
        endif.
    endform.                    " get_customer_data
    *&      Form  get_doc_date
          Getting the Document Date and FI Doc No
         -->P_P_COMP1 Company Code
         -->P_P_YEAR  Fiscal Year
    form get_doc_date using    p_p_comp1
                               p_p_year.
      loop at it_final_vendor.
        concatenate it_final_vendor-refdocnr '*' into
    it_final_vendor-doc_date.
        modify it_final_vendor index sy-tabix.
    endloop.
    clear it_final_vendor.
    data: v_doc_date(11) type c,
          v_belnr like bkpf-belnr,
          v_bldat like bkpf-bldat.
          loop at it_final_vendor.
           concatenate it_final_vendor-refdocnr '%' into v_doc_date.
            select single belnr
                          bldat
                   into corresponding fields of it_final_vendor
                   from bkpf
                   where bukrs eq p_p_comp1
                   and   gjahr eq p_p_year
                   and   awkey like v_doc_date.
                   modify it_final_vendor.
           endloop.
        clear:it_final_vendor.
    endform.                    " get_doc_date
    *&      Form  move_records
          Moving records to final internal table
    form move_records.
    *--Checking the existance of belnr in bsik
    clear it_final_vendor.
      select belnr
             zbd1t
             into table it_final_bsik
             from bsik
             for all entries in it_final_vendor
             where belnr eq it_final_vendor-belnr
             and   bukrs eq c_bukrs.
    clear it_final_bsik.
      loop at it_final_vendor.
        read table it_final_bsik with key belnr = it_final_vendor-belnr.
        if sy-subrc eq 0.
          it_final_vendor-zbd1t = it_final_bsik-zbd1t.
          it_final_vendor-due_date = it_final_vendor-bldat +
    it_final_bsik-zbd1t.
          it_final_vendor-found    = 'X'.
          modify it_final_vendor.
        endif.
      endloop.
    endform.                    " move_records
    *&      Form  generate_data
          Segregating the records based on due_date
    form generate_data.
      delete it_final_vendor[] where found ne 'X'.
      sort it_final_vendor by belnr.
      loop at it_final_vendor.
        if it_final_vendor-due_date > p_rundt1.
          move-corresponding it_final_vendor to it_final_vendor_temp.
          move it_final_vendor-hsl to it_final_vendor_temp-not_due.
        elseif it_final_vendor-due_date < p_rundt1.
          it_final_vendor-due_days = p_rundt1 - it_final_vendor-DUE_DATE.
        endif.
    *--filling 0-30 bucket.
        if it_final_vendor-due_days ge 0 AND it_final_vendor-due_days le 30.
          move-corresponding it_final_vendor to it_final_vendor_temp.
          move it_final_vendor-hsl to it_final_vendor_temp-buck_0_30.
    *--filling 31-60 bucket.
    elseif it_final_vendor-due_days ge 31 AND it_final_vendor-due_days le 60
          move-corresponding it_final_vendor to it_final_vendor_temp.
          move it_final_vendor-hsl to it_final_vendor_temp-buck_31_60.
    *--filling 61-90 bucket.
    elseif it_final_vendor-due_days ge 61 AND it_final_vendor-due_days le 90
          move-corresponding it_final_vendor to it_final_vendor_temp.
          move it_final_vendor-hsl to it_final_vendor_temp-buck_61_90.
    *--filling 91-180 bucket.
        elseif it_final_vendor-due_days ge 91 AND it_final_vendor-due_days
    le 180.
          move-corresponding it_final_vendor to it_final_vendor_temp.
          move it_final_vendor-hsl to it_final_vendor_temp-buck_91_180.
    *--filling 180 bucket.
        elseif it_final_vendor-due_days gt 180.
          move-corresponding it_final_vendor to it_final_vendor_temp.
          move it_final_vendor-hsl to it_final_vendor_temp-buck_180.
        endif.
         append it_final_vendor_temp.
         clear it_final_vendor_temp.
      endloop.
    endform.                    " generate_data
    *&      Form  DISP_ALV_GRID_VENDOR
          Displaying the output in grid For Vendor
    form DISP_ALV_GRID_VENDOR.
    *--Generating the OUTPUT GRID FOR VENDOR
      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                         = wa_layout
          IT_FIELDCAT                       = i_fldcat_head
        IT_EXCLUDING                      =
          IT_SPECIAL_GROUPS                 = i_group
          IT_SORT                           = it_sort[]
        IT_FILTER                         =
        IS_SEL_HIDE                       =
        I_DEFAULT                         = 'X'
        I_SAVE                            = ' '
        IS_VARIANT                        =
          IT_EVENTS                         = i_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                          = it_final_vendor_temp
       EXCEPTIONS
         PROGRAM_ERROR                     = 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.
    endform.                    " DISP_ALV_GRID
    *&      Form  get_doc_date_cust
          text
         -->P_P_COMP2 Company Code
         -->P_P_YEAR  Fiscal Year
    form get_doc_date_cust using    p_p_comp2
                                    p_p_year.
      loop at it_final_customer.
        concatenate it_final_customer-refdocnr '*' into
    it_final_customer-doc_date.
        modify it_final_customer index sy-tabix.
    endloop.
    clear it_final_customer.
    data: v_doc_date(11) type c,
          v_belnr like bkpf-belnr,
          v_bldat like bkpf-bldat.
          loop at it_final_customer.
           concatenate it_final_customer-refdocnr '%' into v_doc_date.
            select single belnr
                          bldat
                   into corresponding fields of it_final_customer
                   from bkpf
                   where bukrs eq p_p_comp2
                   and   gjahr eq p_p_year
                   and   awkey like v_doc_date.
                   modify it_final_customer.
           endloop.
        clear:it_final_customer.
    endform.                    " get_doc_date_cust
    *&      Form  move_records_cust
          Moving Customer Data to Final Internal Table
    form move_records_cust.
    *--Checking the existance of belnr in bsid
      select belnr
             zbd1t
             into table it_final_bsid
             from bsid
             for all entries in it_final_customer
             where belnr eq it_final_customer-belnr
             and   bukrs eq c_bukrs.
    clear it_final_bsid.
      loop at it_final_customer.
        read table it_final_bsid with key belnr = it_final_customer-belnr.
        if sy-subrc eq 0.
          it_final_customer-zbd1t    = it_final_bsid-zbd1t.
          it_final_customer-due_date = it_final_customer-bldat +
    it_final_bsid-zbd1t.
          it_final_customer-found    = 'X'.
          modify it_final_customer.
        endif.
      endloop.
    endform.                    " move_records_cust
    *&      Form  generate_data_cust
          Generating the Customer Output
    form generate_data_cust.
      delete it_final_customer[] where found ne 'X'.
      sort it_final_customer by belnr.
      loop at it_final_customer.
        if it_final_customer-due_date > p_rundt2.
         move-corresponding it_final_customer to it_final_customer_temp.
         move it_final_customer-hsl to it_final_customer_temp-not_due.
        elseif it_final_customer-due_date < p_rundt2.
         it_final_customer-due_days = p_rundt2 - it_final_customer-DUE_DATE.
        endif.
    *--filling 0-30 bucket.
    if it_final_customer-due_days ge 0 AND it_final_customer-due_days le 30
          move-corresponding it_final_customer to it_final_customer_temp.
          move it_final_customer-hsl to it_final_customer_temp-buck_0_30.
    *--filling 31-60 bucket.
    elseif it_final_customer-due_days ge 31 AND it_final_customer-due_days
    le 60
          move-corresponding it_final_customer to it_final_customer_temp.
          move it_final_customer-hsl to it_final_customer_temp-buck_31_60.
    *--filling 61-90 bucket.
    elseif it_final_customer-due_days ge 61 AND it_final_customer-due_days
    le 90
          move-corresponding it_final_customer to it_final_customer_temp.
          move it_final_customer-hsl to it_final_customer_temp-buck_61_90.
    *--filling 91-180 bucket.
        elseif it_final_customer-due_days ge 91 AND
    it_final_customer-due_days
    le 180.
          move-corresponding it_final_customer to it_final_customer_temp.
          move it_final_customer-hsl to it_final_customer_temp-buck_91_180.
    *--filling 180 bucket.
        elseif it_final_customer-due_days gt 180.
          move-corresponding it_final_customer to it_final_customer_temp.
          move it_final_customer-hsl to it_final_customer_temp-buck_180.
        endif.
         append it_final_customer_temp.
         clear it_final_customer_temp.
      endloop.
    endform.                    " generate_data_cust
    *&      Form  generate_field_catalog_vendor
          Generating the Field Catalog for Vendor
    form generate_field_catalog_vendor.
      call function 'REUSE_ALV_FIELDCATALOG_MERGE'
       EXPORTING
          I_PROGRAM_NAME               = v_repid
          I_INTERNAL_TABNAME           = 'IT_FINAL_VENDOR_TEMP'
        I_STRUCTURE_NAME             =
        I_CLIENT_NEVER_DISPLAY       = 'X'
          I_INCLNAME                   = v_repid
        I_BYPASSING_BUFFER           =
        I_BUFFER_ACTIVE              =
        changing
          ct_fieldcat                  = i_fldcat_head
       EXCEPTIONS
         INCONSISTENT_INTERFACE       = 1
         PROGRAM_ERROR                = 2
         OTHERS                       = 3
      if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      endif.
      if not i_fldcat_head[] is initial.
        loop at i_fldcat_head into wa_fldcat_head.
        case wa_fldcat_head-fieldname.
         when 'RZZLIFNR'.
            wa_fldcat_head-col_pos = '1'.
            wa_fldcat_head-ref_tabname = ' '.
            wa_fldcat_head-seltext_m  = 'Vendor No'(001).
            wa_fldcat_head-ddictxt = 'M'.
            wa_fldcat_head-outputlen = '12'.
         when 'NAME1'.
            wa_fldcat_head-col_pos = '2'.
            wa_fldcat_head-seltext_m  = 'Vendor Name'(007).
            wa_fldcat_head-ddictxt = 'M'.
            wa_fldcat_head-outputlen = '35'.
         when 'BELNR'.
            wa_fldcat_head-col_pos = '3'.
            wa_fldcat_head-seltext_m  = 'Invoice No'(008).
            wa_fldcat_head-ddictxt = 'M'.
            wa_fldcat_head-outputlen = '12'.
            wa_fldcat_head-KEY       = ' '.
         when 'BLDAT'.
            wa_fldcat_head-col_pos = '4'.
            wa_fldcat_head-seltext_m  = 'Document Date'(009).
            wa_fldcat_head-ddictxt = 'M'.
            wa_fldcat_head-outputlen = '13'.
            wa_fldcat_head-ref_tabname = ' '.
         when 'RZZ_EBELN'.
            wa_fldcat_head-col_pos = '5'.
            wa_fldcat_head-seltext_m  = 'PO.Ref.No'(010).
            wa_fldcat_head-ddictxt = 'M'.
            wa_fldcat_head-outputlen = '13'.
            wa_fldcat_head-ref_tabname = ' '.
         when 'HSL'.
            wa_fldcat_head-col_pos = '6'.
            wa_fldcat_head-seltext_m  = 'Invoice Amount'(011).
            wa_fldcat_head-ddictxt = 'M'.
            wa_fldcat_head-outputlen = '16'.
            wa_fldcat_head-do_sum = 'X'.
         when 'DUE_DATE'.
            wa_fldcat_head-col_pos = '7'.
            wa_fldcat_head-seltext_m  = 'Due Date'(012).
            wa_fldcat_head-ddictxt = 'M'.
            wa_fldcat_head-outputlen = '12'.
            wa_fldcat_head-ref_tabname = ' '.
         when 'DUE_DAYS'.
            wa_fldcat_head-col_pos = '8'.
            wa_fldcat_head-seltext_m  = 'Due Days'(013).
            wa_fldcat_head-ddictxt = 'M'.
            wa_fldcat_head-outputlen = '9'.
         when 'NOT_DUE'.
            wa_fldcat_head-col_pos = '9'.
            wa_fldcat_head-seltext_m  = 'Not Due'(014).
            wa_fldcat_head-ddictxt = 'M'.
            wa_fldcat_head-outputlen = '16'.
            wa_fldcat_head-do_sum = 'X'.
         when 'BUCK_0_30'.
            wa_fldcat_head-col_pos = '10'.
            wa_fldcat_head-seltext_m  = '0 To 30'(015).
            wa_fldcat_head-ddictxt = 'M'.
            wa_fldcat_head-outputlen = '16'.
            wa_fldcat_head-do_sum = 'X'.
         when 'BUCK_31_60'.
            wa_fldcat_head-col_pos = '11'.
            wa_fldcat_head-seltext_m  = '31 To 60'(016).
            wa_fldcat_head-ddictxt = 'M'.
            wa_fldcat_head-outputlen = '16'.
            wa_fldcat_head-do_sum = 'X'.
         when 'BUCK_61_90'.
            wa_fldcat_head-col_pos = '12'.
            wa_fldcat_head-seltext_m  = '61 To 90'(017).
            wa_fldcat_head-ddictxt = 'M'.
            wa_fldcat_head-outputlen = '16'.
            wa_fldcat_head-do_sum = 'X'.
         when 'BUCK_91_180'.
            wa_fldcat_head-col_pos = '13'.
            wa_fldcat_head-seltext_m  = '91 To 180'(018).
            wa_fldcat_head-ddictxt = 'M'.
            wa_fldcat_head-outputlen = '16'.
            wa_fldcat_head-do_sum = 'X'.
         when 'BUCK_180'.
            wa_fldcat_head-col_pos = '14'.
            wa_fldcat_head-seltext_m  = 'Beyond 180'(019).
            wa_fldcat_head-ddictxt = 'M'.
            wa_fldcat_head-outputlen = '16'.
            wa_fldcat_head-do_sum = 'X'.
        when 'DOCNR'.
            wa_fldcat_head-no_out = 'X'.
        when 'REFDOCNR'.
            wa_fldcat_head-no_out = 'X'.
        when 'DOC_DATE'.
            wa_fldcat_head-no_out = 'X'.
        when 'FOUND'.
            wa_fldcat_head-no_out = 'X'.
         endcase.
         modify i_fldcat_head from wa_fldcat_head index sy-tabix.
        endloop.
      endif.
    endform.                    " generate_field_catalog_vendor
    *&      Form  get_events_vendor
          Getting ALV Events
    form get_events_vendor.
        call function 'REUSE_ALV_EVENTS_GET'
      EXPORTING
        I_LIST_TYPE           = 0
       importing
         et_events             = i_events
      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.
      if not i_events[] is initial.
       read table i_events into wa_event with key name = 'TOP_OF_PAGE'(024)
       wa_event-form = 'GENERATE_USERCOMMAND'.
       modify i_events from wa_event index sy-tabix.
       read table i_events into wa_event with key name = 'END_OF_LIST'(025)
       wa_event-form = 'GENERATE_USERCOMMAND_FOOTER'.
       modify i_events from wa_event index sy-tabix.
      endif.
    endform.                    " get_events_vendor
    *&      Form  GENERATE_USERCOMMAND
          Displaying Header-Text and Logo on Grid
    form generate_usercommand .
      clear i_comment[].
      wa_comment-typ = 'H'.
      wa_comment-info = 'Vendor Ageing Report'(026).
      append wa_comment to i_comment.
      call function 'REUSE_ALV_COMMENTARY_WRITE'
        exporting
          it_list_commentary = i_comment
          i_logo             = 'ENJOYSAP_LOGO'
        I_END_OF_LIST_GRID       = 'X'
    endform.                    " GENERATE_USERCOMMAND
    *&      Form  GENERATE_USERCOMMAND_FOOTER
          Displaying Footer-Text on Grid
    form generate_usercommand_footer.
      clear i_comment[].
      clear wa_comment.
      wa_comment-typ = 'S'.
      wa_comment-key = 'GE-Betz'(027).
      append wa_comment to i_comment.
      call function 'REUSE_ALV_COMMENTARY_WRITE'
        exporting
          it_list_commentary       = i_comment
        I_LOGO                  = ''
          i_end_of_list_grid       = 'X'.
    endform.                    " GENERATE_USERCOMMAND_FOOTER
    *&      Form  generate_layout_vendor
          Generating the ALV Layout
    form generate_layout_vendor.
      WA_LAYOUT-COLWIDTH_OPTIMIZE = 'X'.     "OPTIMIZING FIELD WIDTH
      wa_layout-zebra = 'X'.                  "PUTTING ZEBRA COLORS
      wa_layout-confirmation_prompt = 'X'.    "DISPLAYS CONFIRMATION DIALOG
      wa_layout-totals_text = 'Totals'(028).       "DISPLAYS TOTALS TEXT
      wa_layout-subtotals_text = 'Sub Totals'(029)."DISPLAYS SUBTOTALS TEXT
    endform.                    " generate_layout_vendor
    *&      Form  generate_sort_vendor
          Sorting the Internal Table by Vendor
    form generate_sort_vendor.
      it_sort-fieldname = 'RZZLIFNR'.
      it_sort-tabname = 'IT_FINAL_VENDOR_TEMP'.
      it_sort-up = 'X'.
      it_sort-subtot = 'X'.
      append it_sort.
    endform.                    " generate_sort_vendor
    *&      Form  generate_group_vendor
          Grouping the Data
    form generate_group_vendor.
      clear i_group.
      wa_group-sp_group = 'A'.
      wa_group-text  = 'RZZLIFNR'.
      append wa_group to i_group.
    endform.                    " generate_group_vendor
    *&      Form  GENERATE_FIELD_CATALOG_CUST
          Generating Field Catalog for Customer
    form GENERATE_FIELD_CATALOG_CUST.
      call function 'REUSE_ALV_FIELDCATALOG_MERGE'
       EXPORTING
          I_PROGRAM_NAME               = v_repid
          I_INTERNAL_TABNAME           = 'IT_FINAL_CUSTOMER_TEMP'
        I_STRUCTURE_NAME             =
        I_CLIENT_NEVER_DISPLAY       = 'X'
          I_INCLNAME                   = v_repid
        I_BYPASSING_BUFFER           =
        I_BUFFER_ACTIVE              =
        changing
          ct_fieldcat                  = i_fldcat_head
       EXCEPTIONS
         INCONSISTENT_INTERFACE       = 1
         PROGRAM_ERROR                = 2
         OTHERS                       = 3
      if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      endif.
      if not i_fldcat_head[] is initial.
        loop at i_fldcat_head into wa_fldcat_head.
        case wa_fldcat_head-fieldname.
         when 'RZZKUNNR'.
            wa_fldcat_head-col_pos = '1'.
            wa_fldcat_head-ref_tabname = ' '.
            wa_fldcat_head-seltext_m  = 'Customer No'(020).
            wa_fldcat_head-ddictxt = 'M'.
            wa_fldcat_head-outputlen = '12'.
         when 'NAME1'.
            wa_fldcat_head-col_pos = '2'.
            wa_fldcat_head-seltext_m  = 'Customer Name'(021).
            wa_fldcat_head-ddictxt = 'M'.
            wa_fldcat_head-outputlen = '35'.
         when 'BELNR'.
            wa_fldcat_head-col_pos = '3'.
            wa_fldcat_head-seltext_m  = 'Invoice No'(008).
            wa_fldcat_head-ddictxt = 'M'.
            wa_fldcat_head-outputlen = '12'.
            wa_fldcat_head-KEY       = ' '.
         when 'BLDAT'.
            wa_fldcat_head-col_pos = '4'.
            wa_fldcat_head-seltext_m  = 'Document Date'(009).
            wa_fldcat_head-ddictxt = 'M'.
            wa_fldcat_head-outputlen = '13'.
            wa_fldcat_head-ref_tabname = ' '.
         when 'RZZ_EBELN'.
            wa_fldcat_head-col_pos = '5'.
            wa_fldcat_head-seltext_m  = 'PO.Ref.No'(010).
            wa_fldcat_head-ddictxt = 'M'.
            wa_fldcat_head-outputlen = '13'.
            wa_fldcat_head-ref_tabname = ' '.
         when 'HSL'.
            wa_fldcat_head-col_pos = '6'.
            wa_fldcat_head-seltext_m  = 'Invoice Amount'(011).
            wa_fldcat_head-ddictxt = 'M'.
            wa_fldcat_head-outputlen = '16'.
            wa_fldcat_head-do_sum = 'X'.
         when 'DUE_DATE'.
            wa_fldcat_head-col_pos = '7'.
            wa_fldcat_head-seltext_m  = 'Due Date'(012).
            wa_fldcat_head-ddictxt = 'M'.
            wa_fldcat_head-outputlen = '12'.
            wa_fldcat_head-ref_tabname = ' '.
         when 'DUE_DAYS'.
            wa_fldcat_head-col_pos = '8'.
            wa_fldcat_head-seltext_m  = 'Due Days'(013).
            wa_fldcat_head-ddictxt = 'M'.
            wa_fldcat_head-outputlen = '9'.
         when 'NOT_DUE'.
            wa_fldcat_head-col_pos = '9'.
            wa_fldcat_head-seltext_m  = 'Not Due'(014).
            wa_fldcat_head-ddictxt = 'M'.
            wa_fldcat_head-outputlen = '16'.
            wa_fldcat_head-do_sum = 'X'.
         when 'BUCK_0_30'.
            wa_fldcat_head-col_pos = '10'.
            wa_fldcat_head-seltext_m  = '0 To 30'(015).
            wa_fldcat_head-ddictxt = 'M'.
            wa_fldcat_head-outputlen = '16'.
            wa_fldcat_head-do_sum = 'X'.
         when 'BUCK_31_60'.
            wa_fldcat_head-col_pos = '11'.
            wa_fldcat_head-seltext_m  = '31 To 60'(016).
            wa_fldcat_head-ddictxt = 'M'.
            wa_fldcat_head-outputlen = '16'.
            wa_fldcat_head-do_sum = 'X'.
         when 'BUCK_61_90'.
            wa_fldcat_head-col_pos = '12'.
            wa_fldcat_head-seltext_m  = '61 To 90'(017).
            wa_fldcat_head-ddictxt = 'M'.
            wa_fldcat_head-outputlen = '16'.
            wa_fldcat_head-do_sum = 'X'.
         when 'BUCK_91_180'.
            wa_fldcat_head-col_pos = '13'.
            wa_fldcat_head-seltext_m  = '91 To 180'(018).
            wa_fldcat_head-ddictxt = 'M'.
            wa_fldcat_head-outputlen = '16'.
            wa_fldcat_head-do_sum = 'X'.
         when 'BUCK_180'.
            wa_fldcat_head-col_pos = '14'.
            wa_fldcat_head-seltext_m  = 'Beyond 180'(019).
            wa_fldcat_head-ddictxt = 'M'.
            wa_fldcat_head-outputlen = '16'.
            wa_fldcat_head-do_sum = 'X'.
        when 'DOCNR'.
            wa_fldcat_head-no_out = 'X'.
        when 'REFDOCNR'.
            wa_fldcat_head-no_out = 'X'.
        when 'DOC_DATE'.
            wa_fldcat_head-no_out = 'X'.
        when 'FOUND'.
            wa_fldcat_head-no_out = 'X'.
         endcase.
         modify i_fldcat_head from wa_fldcat_head index sy-tabix.
        endloop.
      endif.
    endform.                    " GENERATE_FIELD_CATALOG_CUST
    *&      Form  get_events_customer
          Getting ALV Events
    form get_events_customer.
        call function 'REUSE_ALV_EVENTS_GET'
      EXPORTING
        I_LIST_TYPE           = 0
       importing
         et_events             = i_events
      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.
      if not i_events[] is initial.
       read table i_events into wa_event with key name = 'TOP_OF_PAGE'(024)
       wa_event-form = 'GENERATE_USERCOMMAND_CUST'.
       modify i_events from wa_event index sy-tabix.
       read table i_events into wa_event with key na

  • Here's how to do ALV (OO) with dynamic fcat, int table and editable data

    Hi everybody
    Here's a more useful approach to ALV grid with OO using dynamic table, data NOT from DDIC, dynamic FCAT and how to get changed lines from the grid when ENTER key is pressed.
    It's really not too dificult but I think this is more useful than the ever present SFLIGHT methods from the demos.
    This also defines a subclass of cl_gui_alv_grid so you can access the protected attributes / methods of that class.
    You don't need to add the class via SE24 -- done fron this ABAP.
    When you run it click Edit for the first time.
    After editing data press ENTER and the break point should bring you into the relevant method.
    Code developed on NW2004S trial version but also works on rel 6.40 on a "Real" system.
    The code should work without any changes on any system >=6.40.
    All you need to do is to create a blank screen 100 via SE51  with a custom container on it called CCONTAINER1.
    The rest of the code can just be uploaded into your system using the SE38 upload facility.
    When running the program click on the EDIT button to enable the edit functionality of the grid.
    Change your data and when you press ENTER you should get the break-point where you can see the original table and changed rows.
    This program is actually quite general as it covers Dynamic tables, building a dynamic fcat where your table fields are NOT in the DDIC, intercepting the ENTER key via using an event, and accessing the protected attributes of the cl_gui_alv_grid by defining a subclass of this class in the abap.
    I've seen various questions relating to all these functions but none in my view ever answers the questions in a simple manner. I hope this simple program will answer all these and show how using OO ALV is actually quite easy and people shouldn't be scared of using OO.
    Have fun and award points if useful.
    Cheers
    Jimbo.
    <b>PROGRAM zdynfieldcat.
    Simple test of dynamic ITAB with user defined (not ddic) fields
    Build dynamic fcat
    use ALV grid to display and edit.
    *When edit mode set to 1 toolbar gives possibility of adding and
    *deleting rows.
    *Define subclass of cl_gui_alv_grid so we can use protected attributes
    *and methods.
    Add event handler to intercept user entering data and pressing the
    *ENTER key.
    When enter key is pressed get actual value of NEW table (all rows)
    rather than just the changed data.
    *use new RTTI functionality to retrieve internal table structure
    *details.
    Create a blank screen 100  with a custom container called CCONTAINER1.
    James Hawthorne
    include <icon>.
    define  any old internal structure  NOT in DDIC
    types: begin of s_elements,
           anyfield1(20) type c,
           anyfield2(20) type c,
           anyfield3(20) type c,
           anyfield4(20) type c,
           anyfield5(11) type n,
           end of s_elements.
    types:  lt_rows  type lvc_t_roid.
    Note new RTTI functionality allows field detail retrieval
    at runtime for dynamic tables.
    data:   wa_element type s_elements ,
            wa_data type s_elements,
            c_index type sy-index,
            c_dec2 type s_elements-anyfield5,
            wa_it_fldcat type lvc_s_fcat,
            it_fldcat type lvc_t_fcat,
            lr_rtti_struc TYPE REF TO cl_abap_structdescr,    "RTTI
            lt_comp TYPE cl_abap_structdescr=>component_table,"RTTI
            ls_comp LIKE LINE OF lt_comp,                     "RTTI
            zog  like line of lr_rtti_struc->components,      "RTTI
            struct_grid_lset type lvc_s_layo,
            l_valid  type c,
            new_table type ref to data.
    field-symbols: <dyn_table> type standard table,
                   <actual_tab> type standard table,
                   <fs1> type ANY,
                   <FS2> TYPE TABLE.
    data: grid_container1 type ref to cl_gui_custom_container.
    class lcl_grid_event_receiver definition deferred.
    data: g_event_receiver type ref to lcl_grid_event_receiver.
    data: ls_modcell type LVC_S_MODI,
          stab type ref to data,
          sdog type  s_elements.      .
    class lcl_grid_event_receiver definition.
      public section.
        methods:
        handle_data_changed
             for event data_changed of cl_gui_alv_grid
                 importing er_data_changed,
           toolbar for event toolbar of cl_gui_alv_grid
                     importing e_object
                               e_interactive,
          user_command for event user_command of cl_gui_alv_grid
                     importing e_ucomm.
    endclass.
    *implementation of Grid event-handler class
    class lcl_grid_event_receiver implementation.
    method handle_data_changed.
    code whatever required after data entry.
    various possibilites here as you can get back Cell(s) changed
    columns or the entire updated table.
    Data validation is also possible here.
    perform check_data using er_data_changed.
    endmethod.
    Method for handling all creation/modification calls to the toolbar
      method toolbar.
        data : ls_toolbar type stb_button.
    Define Custom Button in the toolbar
        clear ls_toolbar.
        move 0 to ls_toolbar-butn_type.
        move 'EDIT' to ls_toolbar-function.
        move space to ls_toolbar-disabled.
        move 'Edit' to ls_toolbar-text.
        move icon_change_text to ls_toolbar-icon.
        move 'Click2Edit' to ls_toolbar-quickinfo.
        append ls_toolbar to e_object->mt_toolbar.
        clear ls_toolbar.
        move 0 to ls_toolbar-butn_type.
        move 'UPDA' to ls_toolbar-function.
        move space to ls_toolbar-disabled.
        move 'Update' to ls_toolbar-text.
        move icon_system_save to ls_toolbar-icon.
        move 'Click2Update' to ls_toolbar-quickinfo.
        append ls_toolbar to e_object->mt_toolbar.
        clear ls_toolbar.
        move 0 to ls_toolbar-butn_type.
        move 'EXIT' to ls_toolbar-function.
        move space to ls_toolbar-disabled.
        move 'Exit' to ls_toolbar-text.
        move icon_system_end to ls_toolbar-icon.
        move 'Click2Exit' to ls_toolbar-quickinfo.
        append ls_toolbar to e_object->mt_toolbar.
      endmethod.
      method user_command.
        case e_ucomm .
          when 'EDIT'.          "From Tool bar
            perform set_input.
             perform init_grid.
          when 'UPDA'.          "From Tool bar
            perform refresh_disp.
            perform update_table.
          when 'EXIT'.          "From Tool bar
            leave program.
        endcase.
      endmethod.
    endclass.
    class zcltest definition inheriting from  cl_gui_alv_grid.
    define this as a subclass so we can access the protected attributes
    of the superclass cl_gui_alv_grid
    public section.
    methods: constructor, disp_tab.
    endclass.
    need this now to instantiate object
    as we are using subclass rather than the main cl_gui_alv_grid.
    class zcltest implementation.
    METHOD constructor.
    CALL METHOD super->constructor
            exporting i_appl_events = 'X'
               i_parent = grid_container1.
    endmethod.
    method disp_tab.
    FIELD-SYMBOLS: <outtab> TYPE STANDARD TABLE.
    break-point 1.
    mt_outtab is the data table held as a protected attribute
    in class cl_gui_alv_grid.
    ASSIGN me->mt_outtab->* TO <outtab>.  "Original data
    do whatever you want with <outtab>
    contains data BEFORE changes each time.
    Note that NEW (Changed) table has been obtained already by
    call to form check_data USING P_ER_DATA_CHANGED
             TYPE REF TO CL_ALV_CHANGED_DATA_PROTOCOL.
    Entered data is in table defined by <fs2>
    In this method you can compare original and changed data.
    Easier than messing around with individual cells.
    do what you want with data in <fs2>  validate / update / merge etc
    endmethod.
    endclass.
    data :
        ok_code like sy-ucomm,
        save_ok like sy-ucomm,
        i4 type int4,
    Container Object [grid_container]
    now created via method constructor
    in the subclass zcltest.
    Control Object [grid]
    grid1 type ref to zcltest,
    Event-Handler Object [grid_handler]
    grid_handler type ref to lcl_grid_event_receiver.
    start-of-selection.
    call screen 100.
    module status_0100 output.
    now display it as grid
    if grid_container1 is initial.
        create object grid_container1
            exporting
              container_name = 'CCONTAINER1'.
        create object grid1.
         break-point 1.
        create object grid_handler.
        set handler:
           grid_handler->user_command for grid1,
           grid_handler->toolbar for grid1,
           grid_handler->handle_data_changed for grid1.
    perform create_dynamic_fcat.
    perform create_dynamic_itab.
    perform populate_dynamic_itab.
    perform init_grid.
    perform register_enter_event.
    set off ready for input initially
    i4 = 0.
      call method grid1->set_ready_for_input
             exporting
               i_ready_for_input = i4.
    endif.
    endmodule.
    module user_command_0100 input.
    *PAI not needed in OO ALV anymore as User Commands are handled as events
    *in method user_command.
    *we can also get control if the Data entered and the ENTER is pressed by
    *raising an event.
    Control then returns to method handle_data_changed.
    endmodule.
    form create_dynamic_fcat.
    get structure of our user table for building field catalog
    Use the RTTI functionality
    lr_rtti_struc ?= cl_abap_structdescr=>describe_by_data( wa_data ).
    Build field catalog just use basic data here
    colour specific columns as well
    loop at lr_rtti_struc->components into zog.
    c_index = c_index + 1.
    clear wa_it_fldcat.
      wa_it_fldcat-fieldname = zog-name .
      wa_it_fldcat-datatype =  zog-type_kind.
      wa_it_fldcat-inttype =   zog-type_kind.
      wa_it_fldcat-intlen =    zog-length.
      wa_it_fldcat-decimals =  zog-decimals.
      wa_it_fldcat-lowercase = 'X'.
      if c_index eq 2.
      wa_it_fldcat-emphasize = 'C411'.
         endif.
        if c_index eq 3.
      wa_it_fldcat-emphasize = 'C511'.
       endif.
      append wa_it_fldcat to it_fldcat .
    endloop.
    endform.
    form create_dynamic_itab.
    Create dynamic internal table and assign to field sysmbol.
    Use dynamic field catalog just built.
    call method cl_alv_table_create=>create_dynamic_table
                 exporting
                    it_fieldcatalog = it_fldcat
                 importing
                    ep_table        = new_table.
    assign new_table->* to <dyn_table>.
    endform.
    form populate_dynamic_itab.
    load up a line of the dynamic table
    c_dec2 = c_dec2 + 11.
    wa_element-anyfield1 = 'Tabbies'.
    wa_element-anyfield2 = 'ger.shepards'.
    wa_element-anyfield3  = 'White mice'.
    wa_element-anyfield4 =  'Any old text'.
    wa_element-anyfield5 =  c_dec2.
    append  wa_element to <dyn_table>.
    endform.
    form check_data USING P_ER_DATA_CHANGED
               TYPE REF TO CL_ALV_CHANGED_DATA_PROTOCOL.
    Get altered data back
      ASSIGN   p_er_data_changed->mp_mod_rows TO <FS1>.
    stab =       p_er_data_changed->mp_mod_rows.
    ASSIGN STAB->* TO <FS2>.
    LOOP AT <FS2> INTO sdog.
    ALV grid display with altered data is now in <fs2>.
    do any extra processing you want here
    endloop.
    now display new table
    call method grid1->disp_tab.
    endform.
    form exit_program.
      call method grid_container1->free.
      call method cl_gui_cfw=>flush.
      leave program.
    endform.
    form refresh_disp.
      call method grid1->refresh_table_display.
    endform.
    form update_table.
    The dynamic table here is the changed table read from the grid
    after user has changed it
    Data can be saved to DB or whatever.
    loop at <dyn_table> into wa_element.
    do what you want with the data here
    endloop.
    switch off edit mode again for next function
    i4 = 0.
      call method grid1->set_ready_for_input
          exporting
              i_ready_for_input = i4.
    endform.
    form set_input.
    i4 = 1.
      call method grid1->set_ready_for_input
         exporting
           i_ready_for_input = i4.
    endform.
    form switch_input.
    if i4 = 1.
    i4 = 0.
    else.
    i4 = 1.
    endif.
      call method grid1->set_ready_for_input
         exporting
           i_ready_for_input = i4.
    endform.
    form init_grid.
    Enabling the grid to edit mode,
         struct_grid_lset-edit = 'X'. "To enable editing in ALV
         struct_grid_lset-grid_title  = 'Jimbos Test'.
         call method grid1->set_table_for_first_display
           exporting
             is_layout           = struct_grid_lset
           changing
             it_outtab             =  <dyn_table>
             it_fieldcatalog       =  it_fldcat.
    endform.
    form register_enter_event.
    call method grid1->register_edit_event
                   exporting
                      i_event_id = cl_gui_alv_grid=>mc_evt_enter.
    Instantiate the event or it won't work.
    create object g_event_receiver.
    set handler g_event_receiver->handle_data_changed for grid1.
    endform.</b>

    Hi there
    IE7 doesn't give me the add new page option and I get 404 error when trying to access the "How to contribute" section.
    I'll load up Firefox later (this browser usually works when IE7 doesn't always work properly).
    I'll copy the stuff to the wiki when I've got the browser sorted out.
    Cheers
    jimbp

  • Why is my macbook pro running slow.  It runs slow even if only one app is open, especially if it's a browser.  I don't know how to read Etrecheck, but was hoping someone who does can help me out.  Would be super grateful.  :-)

    Hi.  This is my first time posting.  My Macbook Pro with Os X Mavericks has been running super slow since before I installed Mavericks so I'm pretty sure it's not the OS that has the problem.  It runs slow even if only one app is open, especially if it's a browser, particulary google chrome.  If mail is open...forget about it, down to a crawl.  I don't know how to read Etrecheck, but was hoping someone who does can help me out.  Would be super grateful.  :-)
    P.S. - Also, it sounds like something is loose inside my mac.  How should I proceed?
    Thanks in advance.
    Hardware Information:
              MacBook Pro (13-inch, Late 2011)
              MacBook Pro - model: MacBookPro8,1
              1 2.8 GHz Intel Core i7 CPU: 2 cores
              4 GB RAM
    Video Information:
              Intel HD Graphics 3000 - VRAM: 384 MB
    System Software:
              OS X 10.9.2 (13C1021) - Uptime: 0 days 23:21:37
    Disk Information:
              APPLE HDD HTS547575A9E384 disk0 : (750.16 GB)
                        EFI (disk0s1) <not mounted>: 209.7 MB
                        Macintosh HD (disk0s2) / [Startup]: 749.3 GB (603.2 GB free)
                        Recovery HD (disk0s3) <not mounted>: 650 MB
              MATSHITADVD-R   UJ-8A8 
    USB Information:
              Apple Inc. Apple Internal Keyboard / Trackpad
              Apple Inc. BRCM2070 Hub
                        Apple Inc. Bluetooth USB Host Controller
              Apple Inc. FaceTime HD Camera (Built-in)
              Apple Computer, Inc. IR Receiver
    Thunderbolt Information:
              Apple Inc. thunderbolt_bus
    Gatekeeper:
              Mac App Store and identified developers
    Kernel Extensions:
              [not loaded] com.leapfrog.driver.LfConnectDriver (1.8.0 - SDK 10.7) Support
              [not loaded] com.seagate.driver.PowSecDriverCore (5.0.1) Support
              [not loaded] com.seagate.driver.PowSecLeafDriver_10_4 (5.0.1) Support
              [not loaded] com.seagate.driver.PowSecLeafDriver_10_5 (5.0.1) Support
              [not loaded] com.seagate.driver.SeagateDriveIcons (5.0.1) Support
    Problem System Launch Daemons:
              [failed] com.apple.wdhelper.plist
    Problem System Launch Agents:
              [loaded] com.paragon.NTFS.auth.plist Support
    Launch Daemons:
              [loaded] com.adobe.fpsaud.plist Support
              [loaded] com.google.keystone.daemon.plist Support
              [loaded] com.leapfrog.connect.shell.plist Support
              [loaded] com.macpaw.CleanMyMac2.Agent.plist Support
              [loaded] com.microsoft.office.licensing.helper.plist Support
              [running] com.sophos.autoupdate.plist Support
              [running] com.sophos.intercheck.plist Support
              [running] com.sophos.notification.plist Support
    Launch Agents:
              [not loaded] com.adobe.AAM.Updater-1.0.plist Support
              [loaded] com.google.keystone.agent.plist Support
              [running] com.seagate.SeagateStorageGauge.plist Support
              [running] com.sophos.uiserver.plist Support
              [running] org.chromium.chromoting.plist Support
    User Launch Agents:
              [loaded] com.adobe.AAM.Updater-1.0.plist Support
              [loaded] com.adobe.ARM.[...].plist Support
              [failed] com.adobe.ARM.[...].plist Support
              [loaded] com.facebook.videochat.[redacted].plist Support
              [loaded] com.macpaw.CleanMyMac2Helper.diskSpaceWatcher.plist Support
              [loaded] com.macpaw.CleanMyMac2Helper.scheduledScan.plist Support
              [loaded] com.macpaw.CleanMyMac2Helper.trashWatcher.plist Support
    User Login Items:
              Activity Monitor
              Dropbox
              Google Drive
              younity
              EvernoteHelper
    Internet Plug-ins:
              o1dbrowserplugin: Version: 5.2.4.18058 Support
              nplastpass: Version: 2.5.5 Support
              Default Browser: Version: 537 - SDK 10.9
              AdobePDFViewerNPAPI: Version: 11.0.06 - SDK 10.6 Support
              FlashPlayer-10.6: Version: 13.0.0.206 - SDK 10.6 Support
              Silverlight: Version: 5.1.20125.0 - SDK 10.6 Support
              Flash Player: Version: 13.0.0.206 - SDK 10.6 Support
              QuickTime Plugin: Version: 7.7.3
              googletalkbrowserplugin: Version: 5.2.4.18058 Support
              SharePointBrowserPlugin: Version: 14.4.1 - SDK 10.6 Support
              AdobePDFViewer: Version: 11.0.06 - SDK 10.6 Support
              JavaAppletPlugin: Version: 14.9.0 - SDK 10.7 Check version
    Safari Extensions:
              Slick Savings: Version: 1.0
              Slick Savings: Version: 1.0
              Surfon: Version: 1.2.2
              Pearltrees Extension: Version: 6.0.13
              Mindomo Bookmarks: Version: 1.0
              Ebay Shopping Assistant: Version: 1.1
              Zootool: Version: 0.7
              Amazon Shopping Assistant: Version: 1.1
              Pocket: Version: 1.7.1
              Searchme: Version: 1.3
    Audio Plug-ins:
              BluetoothAudioPlugIn: Version: 1.0 - SDK 10.9
              AirPlay: Version: 2.0 - SDK 10.9
              AppleAVBAudio: Version: 203.2 - SDK 10.9
              iSightAudio: Version: 7.7.3 - SDK 10.9
    iTunes Plug-ins:
              Quartz Composer Visualizer: Version: 1.4 - SDK 10.9
    User iTunes Plug-ins:
              TuneUp Visualizer: Version: 2.4.0 - SDK 10.6 Support
    User Internet Plug-ins:
              Picasa: Version: 1.0 - SDK 10.4 Support
    3rd Party Preference Panes:
              remoting_host_prefpane  Support
              Flash Player  Support
              Paragon NTFS for Mac ® OS X  Support
    Time Machine:
              Mobile backups: ON
              Auto backup: YES
              Volumes being backed up:
                        Macintosh HD: Disk size: 697.84 GB Disk used: 136.06 GB
              Destinations:
                        NO NAME [Local] (Last used)
                        Total size: 3.41 GB
                        Total number of backups: (null)
                        Size of backup disk: Too small
                                  Backup size 3.41 GB < (Disk used 136.06 GB X 3)
              Time Machine details may not be accurate.
              All volumes being backed up may not be listed.
    Top Processes by CPU:
                   6%          Activity Monitor
                   5%          WindowServer
                   1%          InterCheck
                   1%          sysmond
                   0%          ocspd
    Top Processes by Memory:
              152 MB          Finder
              115 MB          HelpViewer
              111 MB          mds_stores
              86 MB          InterCheck
              57 MB          WindowServer
    Virtual Memory Information:
              983 MB          Free RAM
              1.03 GB          Active RAM
              584 MB          Inactive RAM
              1.01 GB          Wired RAM
              17.41 GB          Page-ins
              222 MB          Page-outs

    Launch the Console application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Console in the icon grid.
    Make sure the title of the Console window is All Messages. If it isn't, select All Messages from the SYSTEM LOG QUERIES menu on the left. If you don't see that menu, select
    View ▹ Show Log List
    from the menu bar.
    Click the Clear Display icon in the toolbar. Then try the action that you're having trouble with again. Select any messages that appear in the Console window. Copy them to the Clipboard by pressing the key combination command-C. Paste into a reply to this message by pressing command-V.
    When posting a log extract, be selective. In most cases, a few dozen lines are more than enough.
    Please do not indiscriminately dump thousands of lines from the log into this discussion.
    Important: Some private information, such as your name, may appear in the log. Anonymize before posting.

Maybe you are looking for