Issue in ALV Grid Grand Totals

Hi Friends,
   Hwo can i display  grand total text in ALV Grid? Eventhough i am using Totals_text parameter in layout i am unable to display.  any one vcan help me out in this refgard.
if pos send the code
Regards,
Vijay

<REMOVED BY MODERATOR>
SAMPLE PROGRAM:
REPORT ysalesorder_alv_subtotals.
* Type Pools
TYPE-POOLS:slis.
* Tables
TABLES: vbak, "Sales Document: Header Data
vbap. "Sales Document: Item Data
* Global Structures
DATA:gt_fieldcat TYPE slis_t_fieldcat_alv,
wa_fieldcat TYPE slis_fieldcat_alv,
gt_sortcat TYPE slis_t_sortinfo_alv,
wa_sortcat LIKE LINE OF gt_sortcat.
* Internal Table
DATA: BEGIN OF gt_salesorder OCCURS 0,
vbeln LIKE vbak-vbeln, " Sales Document Number
posnr LIKE vbap-posnr, " Sales Doc Item
netwr LIKE vbap-netwr, " Net Value
END OF gt_salesorder.
* SELECT OPTIONS
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME
TITLE text-001.
SELECT-OPTIONS: s_vbeln FOR vbak-vbeln. " Sales Document
Number.
SELECTION-SCREEN END OF BLOCK b1.
* Initialization
INITIALIZATION.
PERFORM initialization.
* Start Of Selection
START-OF-SELECTION.
PERFORM field_catalog. "For Structure Creation
PERFORM fetch_data. "Get the Data From DB Table
PERFORM sorting USING gt_sortcat.
* End Of Selection
END-OF-SELECTION.
PERFORM display_data.
*& Form initialization
* text
* --> p1 text
* <-- p2 text
FORM initialization .
s_vbeln-sign = 'I'.
s_vbeln-option = 'BT'.
s_vbeln-low = '4969'.
s_vbeln-high = '5000'.
APPEND s_vbeln.
ENDFORM. " initialization
*& Form field_catalog
* text
* --> p1 text
* <-- p2 text
FORM field_catalog .
REFRESH : gt_fieldcat.
CLEAR : wa_fieldcat.
wa_fieldcat-col_pos = '1'. "Column Position
wa_fieldcat-tabname = 'IT_SALESORDER'. "Internal Table
wa_fieldcat-fieldname = 'VBELN'. "Field Name
wa_fieldcat-key = 'X'. "Blue Color
wa_fieldcat-seltext_m = 'Sales Doc No'. "Display Text In Screen
APPEND wa_fieldcat TO gt_fieldcat.
CLEAR wa_fieldcat.
wa_fieldcat-col_pos = '2'. "Column Position
wa_fieldcat-tabname = 'IT_SALESORDER'. "Internal Table Name
wa_fieldcat-fieldname = 'POSNR'. "Field Name
wa_fieldcat-seltext_m = 'Sales Doc Item'."Display Text In Screen
APPEND wa_fieldcat TO gt_fieldcat.
CLEAR wa_fieldcat.
*SubTotal on the Field NETWR
wa_fieldcat-col_pos = '3'. "Column Position
wa_fieldcat-tabname = 'IT_SALESORDER'. "Internal Table
wa_fieldcat-fieldname = 'NETWR'. "Field Name
wa_fieldcat-do_sum = 'X'. "Sum
wa_fieldcat-seltext_m = 'Net Value'. "Display Text In Screen
APPEND wa_fieldcat TO gt_fieldcat.
CLEAR wa_fieldcat.
ENDFORM. " field_catalog
*& Form sorting
* text
* -->P_IT_SORTCAT text
FORM sorting USING p_it_sortcat TYPE slis_t_sortinfo_alv.
CLEAR wa_sortcat.
wa_sortcat-fieldname = 'VBELN'.
wa_sortcat-up ='X'.
wa_sortcat-subtot = 'X'.
APPEND wa_sortcat TO p_it_sortcat.
ENDFORM. " sorting
*& Form display_data
* text
* --> p1 text
* <-- p2 text
FORM display_data .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK = ' '
* I_BYPASSING_BUFFER = ' '
* I_BUFFER_ACTIVE = ' '
i_callback_program = sy-repid
* I_CALLBACK_PF_STATUS_SET = ' '
* I_CALLBACK_USER_COMMAND = ' '
* I_CALLBACK_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_TOP_OF_PAGE = ' '
* I_CALLBACK_HTML_END_OF_LIST = ' '
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID = ' '
* I_GRID_TITLE =
* I_GRID_SETTINGS =
* IS_LAYOUT =
it_fieldcat = gt_fieldcat
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
it_sort = gt_sortcat
* 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 = gt_salesorder
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_data
*& Form fetch_data
* text
* --> p1 text
* <-- p2 text
FORM fetch_data .
REFRESH : gt_salesorder.
CLEAR : gt_salesorder.
SELECT a~vbeln
posnr
b~netwr
FROM vbak AS a
INNER JOIN vbap AS b ON a~vbeln = b~vbeln
INTO TABLE gt_salesorder
WHERE a~vbeln IN s_vbeln.
ENDFORM. " fetch_data
Edited by: Alvaro Tejada Galindo on Apr 11, 2008 12:24 PM

Similar Messages

  • Issue with ALV grid print preview/spool

    Hello everyone,
    I am working on a report and I am having some issues with ALV grid. Currently in our DEV and QA environments the user can run the report, view the ALV grid, and print the grid without any issues.
    However this isn't the case in the Prod environment. The user is able to run the report and view the grid without any issues. But when they click print preview or click print, the spool is incorrect. It shows the proper values from the grid, but the first field is reduced in length. Rather than showing a numeric field of length 10 it shows 99999999# or 99999999...
    The programs are identical through every environment, including user parameters, formats, and spool settings. I have been told printing grids may have some issues, does anyone have any advice or dealt with this issue before?
    I appreciate the help.
    Thanks,
    C

    I was waiting to hear from the functional team on the matter and no one has mentioned any more issues.  I am assuming the problem is solved.  I just noticed the thread was still un-answered and wanted to give an update. 
    Thank you for you help Vijay.
    Regards
    C

  • ALV Grid sub total issue

    Hi SAP Experts,
    Currently I have ALV Grid table as below as example :
    FIELD1
    FIELD2
    Account
    Amount
    1. Rev
    1.Rev
    Acct1
    100.00
    1. Rev
    1.Rev
    Acct2
    50.00
    Subtotal FIELD2 (1.Rev)
    150.00
    Subtotal FIELD1 (1.Rev)
    150.00
    2. Cost
    2.1 Cost1
    Acct3
    100.00
    2. Cost
    2.1 Cost1
    Acct4
    75.00
    Subtotal FIELD2  (2.1 Cost1)
    175.00
    2. Cost
    2.2 Cost2
    Acct5
    25.00
    Subtotal FIELD2 (2.2 Cost 2)
    25.00
    | Subtotal FIELD1 (2.Cost)                | 200.00             |          
    I have 2 questions.
    First, as you can see, I have 2 subtotal for 1.Rev eventhough 1.Rev actually only need one subtotal because there is no subgroup for 1.Rev. Is it possible to have only one subtotal for this 1.Rev but I still maintained 2 subtotal for 2.Cost because 2.Cost has subgroup?
    My 2nd issue is I need to insert another row exactly below Subtotal FIELD1 (2.Cost) row like this:
    Gross Margin
    (Some formula)
    This row does not come from any sub total. The problem is I can not just insert this column and put Gross Margin description in FIELD1 because I will have 3 row like below :
    Gross Margin
    (Formula)
    Subtotal FIELD2 (blank)
    (Formula) sub total
    Subtotal FIELD1 (Gross Margin)
    (Formula) sub total
    Is there any way I can insert Gross Margin Row without creating new subtotal for it so it will only have one line in the ALV Grid table? Please help. Thank you.
    Regards,
    Abraham

    Hi Vijay.
    I'm not posting this before I search everywhere and this is not the first time I post in this forum so I know what I should do before posting. If I miss something, maybe you can give me at least a hint whether it can be done or not.
    This report that I am using is ALV Grid using REUSE_ALV_GRID_DISPLAY function module and not OOP using dialog module. I never said I need sample code because I only want to know is there a way to do that using ALV Grid which until now I will say that SAP ALV grid has this limitation where you can not insert row without including it in the subtotal.
    So, I would be very thankful if someone can give me some clarity on this thing and Vijay, if you really don't know what is the answer, I really appreciate if you can hold your self from making that kind of reply. It does not need experienced ABAP Consultant to write such remarks. Thanks.
    Regards,
    Abraham

  • In ALV  grid  report, totals of columns display at end of report

    Hi.....!
           In ALV report i want to display grand totals in end of list and also i want to output display ALV report in page by page

    Hi,
    this the code i am sending it may help you.
    DATA : wa_sort TYPE slis_sortinfo_alv.
    DATA : it_sort TYPE slis_t_sortinfo_alv. " for sorting
    PERFORM sub_total USING '<field based on wich you want sort(say key field>>'.
    FORM sub_total USING value(p_sortfld) .
      wa_sort-fieldname = p_sortfld.
      wa_sort-subtot = 'X'.
      wa_sort-up = 'X'.
      APPEND wa_sort TO it_sort
    and then is main function module for display grid or list.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
          EXPORTING
            i_callback_program     = wa_pgm
            i_callback_top_of_page
            ='TOP_OF_PAGE'
            i_grid_title           = text-016
            it_fieldcat            = it_fieldcat
           <b> it_sort                = it_sort</b>
            i_default              = 'X'
            i_save                 = 'A'
          TABLES
            t_outtab               = it_final.

  • ALV subtotal & grand total

    Hi experts,
    I have a ALV display which displays subtotals & grandtotals. I only want the subtotals, How can I supress the grantotal?
    ex.
    DOC num 50003859
    200 USD
    300 USD
    subtotal = 500
    DOC num 50005469
    600 USD
    subtotal = 600
    Grandtotal = 1100 <- I dont want this to show.

    Hi,
    You can do as below for Subtotal and suppress the grand total.
    data :gt_sort TYPE slis_t_sortinfo_alv,
    DATA: ls_sort TYPE slis_sortinfo_alv.
    CLEAR ls_sort.
    ls_sort-fieldname = 'BELNR'.
    ls_sort-up = 'X'.
    ls_sort-subtot = 'X'.
    APPEND ls_sort TO gt_sort.
    And pass gt_sort to grid display export parameter IT_sort.
    And to suppress the grandtotal.
    in the layout use the below code :
    wa_layout-no_totalline = 'X'.
    Thanks,
    Sriram Ponna.

  • Filter Issue in ALV Grid

    I am displaying the table in ALV Grid format. I have 4 fields in the table. The filter works for the first 3 fields, but doesnot work for the last field.
    Please let me know what might be the issue.
    Find the table declaration and the table population as in the below code
    TYPES : BEGIN OF ty_message,
              avm_nr  TYPE avm_nr,
              motiv   TYPE motiv_nr,
              text    TYPE t100-text,
              msg     TYPE merep_orderstat,
            END OF ty_message.
    DATA: gt_message TYPE STANDARD TABLE OF ty_message,
              gs_message TYPE ty_message.
        gs_message-avm_nr   = gs_upload-avm_nr.
        gs_message-motiv      = gs_upload-motiv.
        gs_message-text        = 'Order Successfully Changed'.
        gs_message-msg       = 'Success'.
        APPEND gs_message TO gt_message.
        CLEAR gs_message.
    Regards,
    Salil

    Since the field MSG refer to MEREP_ORDERSTAT which is CHAR10, it will convert the content to UpperCase.
    So, try like:
        gs_message-avm_nr   = gs_upload-avm_nr.
        gs_message-motiv      = gs_upload-motiv.
        gs_message-text        = 'Order Successfully Changed'.
        gs_message-msg       = 'SUCCESS'.
        APPEND gs_message TO gt_message.
        CLEAR gs_message.
    Regards,
    Naimesh Patel

  • Issue with ALV Grid and events

    Hi,
    I am creating an ALV Grid with fields Matnr,Charg,Labst,Meins. The first three fields are editable and the last (MEINS) is read only.
    Now I am trying to fill the MEINS field programmaticly after entering the MATNR and confirm with enter/return.
    I think that I have to "overload" the enter event of the alv grid to fill the MEINS everytime when a MATNR was entered. But I don't know how I could implementing this. Could you give me a hint how I could solve this problem?
    (The behavior should look like in transaction MIGO)
    Thanks

    Hi Alex
    When you press enter an event is triggerd and function code is filled in sy-ucoom or you can say in ok_code. At that time PAI event occurs. In PAI of that screen you need to check ok_code and load new data in table which you passed to ALV and also refresh the ALV.
    data: ok_code like sy-ucomm.
    PAI----screen 100
    case ok_code.
    when 'ENTER'.
    select data
    and refresh ALV
    then again call
    funtion to display ALV
    Regards
    Aditya

  • Alv Grid Sub Total

    Hi All
           I am have done an object in alv grid where it is working fine but what i want i am giving a sample please do let tell me how to do
    OUTPUT
    DATE       TIME-ENTRY  ACM-NO   CHARG    SHIFT   MACHINE-SPEED STANDARD-D    ACTUALL-DIPS   DOWNTIME-MINS  DOWN-TIME-IN%
    2009/08/23 00:45:41    ACMA01   910808   B             27.090      2,167           2,120              10            2.08
    2009/08/23 08:38:45    ACMA01   910808   C             27.090      2,167           1,459             157           32.71
                                    910808                             4,334           3,579             167
    2009/08/23 08:51:59    ACMA01   910809   C             27.090      2,167             141             449           93.54
    2009/08/23 17:24:39    ACMA01   910809   A             27.090      2,167           2,113              12            2.50
                                    910809                             4,334           2,254             461
    2009/08/23 00:48:56    ACMA02   920810   B             25.700      2,056           2,015              10            2.08
    2009/08/23 09:07:02    ACMA02   920810   C             25.700      2,056           2,043               3            0.63
    2009/08/23 17:27:04    ACMA02   920810   A             25.700      2,056             421             382           79.58
    2009/08/23 17:27:12    ACMA02   920810   A             25.700      2,056             421             382           79.58
                                    920810                             8,224           4,900             777
    2009/08/23 17:30:12    ACMA02   920811   A             25.700      2,056           1,335             168           35.00
                                    920811                             2,056           1,335             168
    In Down time in %  i want to do a bit of calculation
        X = 3579(ACCTUALL DIPS)/4334(STANDARD DIPS)    
        X = .0852 * 100 = 82.5 - 100
        X = -17.4%( This should display in DOWN-TIME-IN%)
    This will be Similar Calculation only number of lines will reduce to make it clear i gave in this way
    Waiting for Reply
    Thank's In Advance
    Sravya
    Edited by: Sravya Ch on Aug 24, 2009 7:41 AM

    Hi Rajihta
           I think you did not under stand what I want clearly
      DATE       TIME-ENTRY  ACM-NO   CHARG    SHIFT   MACHINE-SPEED STANDARD-D    ACTUALL-DIPS   DOWNTIME-MINS  DOWN-TIME-IN
      2009/08/23 00:45:41    ACMA01   910808   B             27.090      2,167           2,120              10            2.08
      2009/08/23 08:38:45    ACMA01   910808   C             27.090      2,167           1,459             157           32.71
    *                                 910808                             4,334           3,579             167            *17%*
    So how to do for  that 17% .i have just eneterd it now(every thing is from SAP other than that 17%)

  • Performance issue with ALV Grid in Module Pool

    Hi Experts,
    I am using an editable ALV Grid on a screen. This ALV does not have too many fields and is called in modal dialog box.
    I call this screen from a standard transaction. The problem is this screen is taking 3-4 seconds to load. I checked that fetching the data is not a problem and only after the call screen statement, the processing becomes very slow. Is this due to ALV grid. Please help as this is urgently needed and I cannot change from ALV to table control. Please suggest if anything can b done?
    Regards
    Satish

    Hi Satish,
    I hope there is a chance to do the SET_TABLE_FOR_FIRST_DISPLAY or preparation of field catalog earlier, i.e. in INITILIZATION event and then later just exchange table contents before display. That will reduce time.
    Regards,
    Clemens

  • Field Catelog Issue for ALV Grid

    Hi,
    I have generated the ALV Dynamically based on the Date Range entered on the selection screen, now I am able to fill the values into the structure also, here my problem is date is like S858-spbup ( mm/yyyy format), what ever the values I have moved is S858-umwavwr(Currency values), now I want to sub total these values. Since my field catelog is date format that is why it is not doing subtotals.
    code is
        gs_fc-seltext_l = date.
        gs_fc-seltext_m = date.
        gs_fc-seltext_s = date.
        gs_fc-ref_fieldname = 'umwavwr'.
        gs_fc-ref_tabname = 'S858'.
        gs_fc-do_sum = 'X'.
        gs_fc-outputlen = 20.
        APPEND gs_fc TO gt_fc.
    it is doing subtotal but the issue is in ALV header it is not displaying like date (for example 06/2005),instead it is displaying the name as ref_fieldname text. How to resolve this issue. Please help me.
    Thanks & Regards,
    Sivaram Kandula

    Hi Rich,
    Thanks for your speedy reply. But in my case scenario is different.
    if i remove the ref_fieldname = date means it is dumping bcz,
    output is like this
    suppose my input is 06/2005 to 08/2005
    CSR   District  06/2005 07/2005 08/2005 totals
    xxx   newyork    30.00    3.00   5.00    38.00
    xxx   newyork    40.00    5.00   6.00    20.00
    xxx              70.00    8.00  11.00    58.00
    now I am able to display the output like this, but the problem here is i am unable to subtotal these, bcz my field catelog is date type that is why do_sum is not working, that is why I took ref_feield name as UMWAVWR and S858, it is subtotaling but I am unable to see the header like above, instead it is displaying like
    CSR  District   invoice:Cost  invoice:Cost Invoice:cost tot
    so please advise me how to proceed further.
    Thanks & Regards,
    Sivaram Kandula

  • Layout Issue In ALV Grid

    Dear All,
    I have made an editable ALV andafter entreing data and successful update it will show another ALV.
    The issue is that user has saved different Layouts for the 2 ALV's and made it user specific. But again when the report is executed then the 2 saved layouts are not coming.
    The respective layout should come for the 2 ALVs.
    Thanks & Regards,
    Bharti Jain

    Hi, let us try with the following code,
    type-pools SLIS.
    data : lv_vbeln type vbak-vbeln.
    select-options : so_vbeln for lv_vbeln.
    initialization.
    so_vbeln-low = '4970'.
    so_vbeln-high = '4975'.
    append so_vbeln.
    types : begin of ty_vbak,
             vbeln type vbak-vbeln,
             erdat type vbak-erdat,
             erzet type vbak-erzet,
             ernam type vbak-ernam,
           end of ty_vbak.
    data : lt_vbak type standard table of ty_vbak,
           ls_vbak type ty_vbak.
    data : ls_variant like DISVARIANT.
    data : ls_layo type  SLIS_LAYOUT_ALV.
    data : lt_fcat type SLIS_T_FIELDCAT_alv.
    start-of-selection.
    perform getvbak.
    if sy-subrc eq 0.
    perform displayvbak.
    endif.
    FORM GETVBAK .
    select vbeln erdat erzet ernam from vbak
      into table lt_vbak
      where vbeln in so_vbeln.
    ENDFORM.                    " GETVBAK
    FORM DISPLAYVBAK .
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
       I_CALLBACK_PROGRAM                = sy-repid
       I_STRUCTURE_NAME                  = 'ZMYVBAk'
       IS_LAYOUT                         = ls_layo
       IT_FIELDCAT                       = lt_fcat[]
       I_SAVE                            = 'X'
       IS_VARIANT                        = ls_variant
      TABLES
        T_OUTTAB                          = lt_vbak[].
    ENDFORM.                    " DISPLAYVBAK
    After execution select the fields which you want to hide and after that goto SETTINGS menu -->Layout --->save it
    it will ask the save variant and name .
    After that goto layout management and select the variant which you created and execute the alv program
    then you can observe the fields will hide .
    Thanks & Regards,
    Raghunadh . K

  • ALV grid sub-totals

    Hi All,
          I have written a code to show sub totals in ALV.
    But, is there any way by which I can show *Only the sub total
    lines* and not the individual line items that form the sub total ?
    e.g.:-
    KeyField1  KeyField2  Field1  Field2
    A                  1             10       12
    A                  1             15         8
    SUBTOTAL                 25       20
    B                  2             15       12
    SUBTOTAL                 15       12
    C                  1             10         8
    C                  2               8        12
    C                  3               7         2
    SUBTOTAL                  25       22
    Now I want only the SUBTOTAL rows to be visible in ALV not the individual rows as follows :-
    KeyField1  KeyField2  Field1  Field2
    SUBTOTAL                 25       20
    SUBTOTAL                 15       12
    SUBTOTAL                  25       22
    Regards,
    Ashish

    hi check this..in this only subtotals are shown if u click on the subtotal it will show the detailed list for that subtotal..
    *& Report  ZVG_ALV_SLIST2                                              *
    report  zvg_alv_slist2                          .
    ALV
    type-pools: slis.
    G L O B A L   I N T E R N  A L   T A B L E S
    data: gt_fieldcat type slis_t_fieldcat_alv,
          gs_layout   type slis_layout_alv,
          gt_events   type slis_t_event.
    data: it_sort type slis_t_sortinfo_alv ,
          wa_sort type slis_sortinfo_alv .
    data: gs_print type slis_print_alv.
    data: begin of it_sflight occurs 0,
            carrid     like sflight-carrid,
            connid     like sflight-connid,
            fldate     like sflight-fldate,
            price      like sflight-price,
            planetype  like sflight-planetype,
            seatsmax   like sflight-seatsmax,
            seatsocc   like sflight-seatsocc,
            paymentsum like sflight-paymentsum,
         end of it_sflight.
    *DATA: GI_SFLIGHT LIKE STANDARD TABLE OF ST_SFLIGHT.
    data: g_repid like sy-repid.
    data: gt_list_top_of_page type slis_t_listheader.
    data: v_total(5).
    start-of-selection.
      g_repid = sy-repid.
      perform init_fieldcat  using gt_fieldcat[].
      perform build_eventtab using gt_events[].
      perform build_comment  using gt_list_top_of_page[].
      perform get_data.
      perform set_layout using gs_layout.
    SORTING
      clear wa_sort.
      wa_sort-fieldname = 'CARRID'.
      wa_sort-up = 'X'.
      wa_sort-group = '*'.
      wa_sort-subtot = 'X'.
      append wa_sort to it_sort.
      clear wa_sort.
      wa_sort-fieldname = 'CONNID'.
      wa_sort-up = 'X'.
      wa_sort-group = 'UL'.
      wa_sort-subtot = 'X'.
      append wa_sort to it_sort.
    DISPLAY LIST
      call function 'REUSE_ALV_LIST_DISPLAY'
        exporting
          i_interface_check       = ' '
          i_callback_program      = g_repid
          i_callback_user_command = 'USER_COMMAND'
          is_layout               = gs_layout
          it_fieldcat             = gt_fieldcat[]
          it_sort                 = it_sort[]
          it_events               = gt_events
          is_print                = gs_print
        tables
          t_outtab                = it_sflight
        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.
    *&      Form  INIT_FIELDCAT
    form init_fieldcat using    p_gt_fieldcat type slis_t_fieldcat_alv.
      data: ls_fieldcat type slis_fieldcat_alv,
            l_index type sy-tabix.
      data :rep like sy-repid.
      rep = sy-repid.
      call function 'REUSE_ALV_FIELDCATALOG_MERGE'
        exporting
          i_program_name         = rep
          i_internal_tabname     = 'IT_SFLIGHT'
          i_inclname             = rep
        changing
          ct_fieldcat            = gt_fieldcat
        exceptions
          inconsistent_interface = 1
          program_error          = 2
          others                 = 3.
      if sy-subrc <> 0.
        message id sy-msgid type 'S' number sy-msgno
             with sy-msgv1 sy-msgv2 sy-msgv3 sy-subrc.
      endif.
      sort gt_fieldcat by col_pos.
      loop at gt_fieldcat into ls_fieldcat.
        l_index = sy-tabix.
        if ls_fieldcat-fieldname = 'PRICE'.
          ls_fieldcat-do_sum = 'X'.
          ls_fieldcat-sp_group = 'X'.
          modify gt_fieldcat from ls_fieldcat index l_index .
        endif.
      endloop.
    endform.                    " INIT_FIELDCAT
    *&      Form  BUILD_EVENTTAB
    form build_eventtab using  p_gt_events type slis_t_event.
      data: ls_event type slis_alv_event.
      clear ls_event.
      ls_event-name = slis_ev_top_of_page.
      ls_event-form = 'XTOP_OF_PAGE'.
      append ls_event to p_gt_events.
      clear ls_event.
      ls_event-name = slis_ev_top_of_list.
      ls_event-form = 'XTOP_OF_LIST'.
      append ls_event to p_gt_events.
      clear ls_event.
      clear ls_event.
      ls_event-name = slis_ev_end_of_page.
      ls_event-form = 'XEND_OF_PAGE'.
      append ls_event to p_gt_events.
      ls_event-name = slis_ev_end_of_list.
      ls_event-form = 'XEND_OF_LIST'.
      append ls_event to p_gt_events.
      clear ls_event.
    endform.                    " BUILD_EVENTTAB
    *&      Form  BUILD_COMMENT
    form build_comment using   p_gt_list_top_of_page type slis_t_listheader.
      data: ls_line type slis_listheader.
      ls_line-typ = 'H'." = Header, S = Selection, A = Action
      ls_line-key = 'KEY'.
      ls_line-info = 'INFO'.
      append ls_line to p_gt_list_top_of_page.
    endform.                    " BUILD_COMMENT
    *&      Form  SELECTION
    form get_data..
    data: l_rows type i value 3.
    Read data from table SFLIGHT
      select carrid
             connid
             fldate
             price
             planetype
             seatsmax
             seatsocc
             paymentsum
         from sflight
         into table it_sflight.
        up to l_rows rows.
      sort it_sflight.
    endform.                    " SELECTION
    *&      Form  SET_LAYOUT
    form set_layout using  p_gs_layout type slis_layout_alv.
    *  P_GS_LAYOUT-F2CODE            = P_F2CODE.
      p_gs_layout-zebra          = 'X'.
      p_gs_layout-colwidth_optimize = 'X'.
      p_gs_layout-no_input          = 'X'.
      p_gs_layout-no_colhead        = space.
      p_gs_layout-totals_text       = 'Total Price'.
      p_gs_layout-subtotals_text    = 'Sub Total'.
      p_gs_layout-totals_only       = 'X'.
      p_gs_layout-key_hotspot       = 'X'.
      p_gs_layout-detail_popup      = 'X'.
      p_gs_layout-no_subtotals      = space.
      p_gs_layout-expand_all        = 'X'.
      p_gs_layout-group_buttons     = 'X'."space.
    endform.                    " SET_LAYOUT
          FORM XTOP_OF_PAGE                                             *
    form xtop_of_page.
    data : lv_page(5),
            lv_text(20).
      MOVE SY-PAGNO TO LV_PAGE.
      write:/  'X_TOP_OF_PAGE'.
    endform.                    "xtop_of_page
          FORM XTOP_OF_LIST                                             *
    form xtop_of_list.
      write:/  'X_TOP_OF_LIST'.
    endform.                    "xtop_of_list
          FORM XEND_OF_PAGE                                             *
    form xend_of_page.
      write:/  'X_END_OF_PAGE'.
    endform.                    "xend_of_page
          FORM XEND_OF_LIST                                             *
    form xend_of_list.
      write:/  'X_END_OF_LIST'.
      data : lv_page(5),
             lv_text(20).
      data : l_lines type i,
             l_line  type i.
      clear v_total.
      write sy-pagno to v_total left-justified.
    export v_total to memory id 'V_TOTAL'.
      do sy-pagno times.
        lv_page = sy-index.
        concatenate 'Page' lv_page 'of' v_total
             into lv_text separated by space.
        if sy-index = 1.
          read line 2 of page sy-index.
        else.
          read line 1 of page sy-index.
       endif.
        sy-lisel+60(20) = lv_text.
          modify current line .
      enddo.
    endform.                    "xend_of_list
          USER_COMMAND                                             *
    form user_command  using r_ucomm like sy-ucomm
                              rs_selfield type slis_selfield.
      case r_ucomm.
        when 'EXIT'.
          leave to screen 0.
        when '&IC1'.
          data: text(256),text1(6),text2(5).
          move rs_selfield-tabindex to text1.
          move rs_selfield-sumindex to text2.
          concatenate  'Double clicked on (field:'
                        rs_selfield-fieldname
                        'Value:'
                        rs_selfield-value
                        text1
                        text2
                        into text
                        separated by space.
          call function 'POPUP_TO_DISPLAY_TEXT'
            exporting
              textline1 = text.
      endcase.
    endform.                    "user_command
    regards,
    venkat.

  • Web Dynpro ALV grid sub totals

    Hi,
    I have managed to get totals working with web dynpro ALV using code like this :
      DATA: lr_field TYPE REF TO cl_salv_wd_field.
    For total calculations...
      lo_value->if_salv_wd_std_functions~set_aggregation_allowed( abap_true ).
      lr_field = lo_value->if_salv_wd_field_settings~get_field( 'N_OF_DLRS' ).
      lr_field->if_salv_wd_aggr~create_aggr_rule( aggregation_type = if_salv_wd_c_aggregation=>aggrtype_total ).
    Please can someone advise how i can do subtotals also.  Thanks
    Edited by: Samir Vora on Jul 15, 2009 12:40 PM

    Hi,
    For creating subtotals, you can have a look at following article:
    [Tutorial for Creation Subtotals using ALV|https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/user-interface-technology/wd%20abap/tutorial%20for%20creating%20totals%20and%20subtotals%20using%20alv.pdf].
    Hope this helps.
    Regards
    Manas Dua

  • Back button issue in ALV Grid(Factory method)

    Hi All,
    I have displayed a report using factory method(CL_SALV_TABLE).In that i have added buttons in application bar too.So when clicking on refresh button ALV should display again with latest number of records,that is working fine but when clicking on back button it should go to selection screen instead of that it is going a step back and displaying previous list of grid and then back and then selection screen.
    Can any one help me how to directly go to input selection screen instead of going step back...
    Regards,
    Ram

    HI,
    Use this syntax (CALL SELECTION-SCREEN 1000)...Try this one
    regards,
    balaji

  • ALV Grid - Subtotal & total to be shown at the top of the table

    Hi,
    I am using function module 'REUSE_ALV_GRID_DISPLAY' to display a table, and I count subtotals and total for some fields. The total is always shown at the bottom of the table, and subtotals are always shown after the rows that subtotals are calculated for. Is there a way to make it so that the total is always shown at the top of the table, and subtotals are shown before the rows that subtotals are calculated for?
    Thank you,
    Jake Alexander

    GW_LAYOUT-TOTALS_BEFORE_ITEMS = 'X'.
    Regards
    Sreekanth

Maybe you are looking for

  • Late 2008-09 MacBook Pro Broken Hinge

    This machine has been about as babied as a machine can be yet this week the hinge has started breaking in a corner until it's broken completey. It's so obvious that there is some glue failure. You can see it. It's like brittle ""Gorilla Glue". I took

  • Passing array of UDT in web service method

    I have a backend Java class with method that takes an array of User Defined Type: public example.ws2j.service.StatusCodeVO[] getAllStatusCodes(DepartmentCodeVO[] deptCode) StatusCodeVO[] resp = new StatusCodeVO[2]; resp[0].setName("Christy"); resp[0]

  • Does WAAZ allow multiple SP online tenants to connect to?

    We have a requirement for two SP online environments: 1 strictly internal, 1 with an option to share with externals. Both environments need to have a different URL. In both environments, I want to give all internal users a SSO experience. I read in b

  • Rendering After Effects Comps can be very slow

    I have a PP CS6 project which has quite a few in-line After Effects comps in the main sequence.  The are all image stabilisation (for clips which are are of a different size of the sequence).  When I render then most of fairly quick (several frames a

  • Uploading into database table from text file using tab (GUI_UPLOAD)

    i have small doubt i have 3 fiels in text file using tab as separator i need to update into database table 'ZABPSP_01' from 's.txt' located in local disk. My code is below. Please let me know the correction. Awaiting for ur response. Thanks in advanc