Sub-total in a XML Crosstab report

Hi,
Can anyone help me to get the subtotal for the crosstab within another group report.
Format is like this:
Method
Analysis Unit Test1 Test2 Test3 ....... Avg
Quanity Moisture % 13.35 13.40 13.40 13.38
Ash (db) % 13.35 13.40 13.40 13.38
Protein % 13.35 13.40 13.40 13.38
Weight % 13.35 13.40 13.40 13.38
Edible Broken % 13.35 13.40 13.40 13.38
Discolored % 13.35 13.40 13.40 13.38
Food G % 13.35 13.40 13.40 13.38
Non-Edible Impurities % 13.35 13.40 13.40 13.38
Stones/Soil % 13.35 13.40 13.40 13.38
In the above format, Test method is a group and Analysis is another group. Test1, Test2, Test3... are a cross tab within this group. I am unable to place the subtotal and grand total for the cross tab data.
Thanks.

It has been achieved by using the following XML tag.
<?for-each-group@column:G_NAME;CROSSTAB_COL_NAME?>

Similar Messages

  • How to display sub total text in ALV grid display reporting

    Hi,
    I want to display a text 'SUB TOTAL'  in Sub total  row  of an ALV report.
    Presently I am getting the name of the field used in sorting to get sub totals. But I required to display own text. Could you please give me solution.
    Thanks
    Giridhar Karnam

    For doing this u need to simply modify the layout properties, please award points if found helpful
    DATA: L_LAYOUT TYPE SLIS_LAYOUT_ALV.
    L_LAYOUT-SUBTOTALS_TEXT = 'GEN SUBTOT'.
        CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
          EXPORTING
            I_CALLBACK_PROGRAM = SY-REPID
            IS_LAYOUT          = L_LAYOUT
            IT_FIELDCAT        = IT_FIELDCAT
          TABLES
            T_OUTTAB           = IT_FINAL
          EXCEPTIONS
            PROGRAM_ERROR      = 1
            OTHERS             = 2.

  • Force the Summary Sub totals on same page as the Repeating Group

    Hello folks,
    I have a Group by Left Report where I am showing Patients and the Visits that they have taken for each Department.
    I am then doing a Sub Total of the number of Visits the Patient has taken. I would like to make sure that the sub total shows
    up on the same page as the data in the Repeating Group. I tried using an Anchor but the Report does not like it.
    It gives an Error: REP 1213 - Field references column at a frequency below its group when I anchor from Repeating frame to the sub total footer
    and REP 1814 Report cannot be formatted. Object 'Horizontally' can never fit within 'M_1' when I try to anchor the other way.
    My goal is to show the Sub Totals (Total) on the same page as the Patient and not go to the next page. I have enclosed the single dashed line and the Total (Label and field) in a Frame.
    Output of Report:
    Patient ID     Patient Name              Department              Visit
    ======================================================================
    1001           Mary Poppins              Department 001              3
                                             Department 002              4
                                             Department 003              1
                                             Total                       8
    1002           Peter Pan                 Department 001              2
                                             Department 002              1
                                             Department 003              2
                                             Total                       5
                                             -----------------------------Thanks in advance!

    Pls set the property(page protect of the frame containing both sub total and patient details) to yes.

  • Crosstab report with null or wrong totals

    I have a crosstab report that when I put a field in an item report area and setting <all> for values I get null values and with other fields I get wrong results (less than I wait). If there's no report item, it's return the correct results.
    I have checked the SQL and it not return any null value.
    I believe that the crosstab try to aggragate and sum the null values of the empty cells in my crosstab.
    Anyone knows how to fix it?
    I'm using Discoverer 10g Desktop.

    can you send your xml data and template to [email protected]

  • Short dump when I do total or sub total in the ALV report

    Hi,
    When I do total or sub-total on the currency field in the ALV report, it'll give a short dump like
    " The current application program detected a situation which really
    should not occur. Therefore, a termination with a short dump was
    triggered on purpose by the key word MESSAGE (type X)".
       Short text of error message:
       Technical information about the message:
       Message classe...... "0K"
       Number.............. 000
       Variable 1.......... " "
       Variable 2.......... " "
       Variable 3.......... " "
       Variable 4.......... " "
       Variable 3.......... " "
       Variable 4.......... " "
    Trigger Location of Runtime Error
        Program                                 SAPLSLVC
        Include                                 LSLVCF36
        Row                                     2,726
        Module type                             (FORM)
        Module Name                             FILL_DATA_TABLE
    sometime when I do the page down on the ALV report, the same short dump is coming.
    Can anyone help me out.
    Thanks
    Selva

    Hi,
    I'm getting this short dump in the standard program.
    I'm getting ALV report display perfectly. the problem is, when I do total or subtotal on the currency fields.
    2704
    2705 ************************************
    2706 * Column per Fieldcat Entry
    2707 ************************************
    2708         ls_lvc_data-value = space.
    2709         clear ls_lvc_data-style.
    2710         loop at it_fcat_local assigning <ls_fcat>
    2711                 where tech ne 'X' and no_out ne 'X'.
    2712           if l_invisible eq 'X'.
    2713             clear l_invisible.
    2714             if <ls_fcat>-do_sum is initial.
    2715               continue.
    2716             else.
    2717               clear ls_lvc_data-col_pos.
    2718             endif.
    2719           endif.
    2720
    2721           add 1 to ls_lvc_data-col_pos.
    2722
    2723           assign component <ls_fcat>-fieldname
    2724                            of structure <ls_data> to <l_field_value>.
    2725           if sy-subrc ne 0.
    >>>>>             message x000(0k).
    2727           endif.
    2728
    in this standard program, I'm getting the dump. the line is mentioned above in the code.

  • SSRS 2008 Work order report , in sub total donot want to add the 0 level in ( how to add the expression )

    working in Work order report, this report has different level , for example
    0 level transaction
    1 level transaction
    in subtotal don't want to add 0 level transaction,
    when I did the sub total it added all the level , so in sub total amount double up because of that
    how to add the expression so I can the level 0 take out from sub total , so it does not include in sub total
    can some one please help me with this
    thanks in advance

    Hi Simon_ Hou
    I tried the expr the way you suggested , it did not work  getting  error message,  the exp I added is below
    this the expression I added on sub total where is highlighted in Yellow,  under Cost amount column,
    I really appreciate the help
    =Sum(IIF(Fields!COLLECTREFLEVEL.Value=
    "0",0,Fields!CostAMOUNT.Value),"DataSet1")
    please see below my QUERY, can you please help and let me know what I did wrong in my exp
    SELECT        PRODTABLE.PRODID, PRODCALCTRANS.COSTGROUPID, PRODTABLE.QTYCALC, PRODTABLE.PRODSTATUS, PRODCALCTRANS.COSTAMOUNT,
                             PRODCALCTRANS.COSTMARKUP, PRODCALCTRANS.REALCOSTAMOUNT, PRODCALCTRANS.CALCTYPE, PRODTABLE.DATAAREAID, PRODCALCTRANS.KEY3,
                             PRODCALCTRANS.CONSUMPVARIABLE, PRODCALCTRANS.REALCONSUMP, PRODTABLE.ITEMID, PRODTABLE.SCHEDDATE, PRODTABLE.FINISHEDDATE,
                             PRODCALCTRANS.KEY1, PRODCALCTRANS.TRANSDATE, PRODCALCTRANS.QTY, PRODCALCTRANS.KEY2, PRODCALCTRANS.COLLECTREFLEVEL,
                             PRODCALCTRANS.LINENUM
    FROM            PRODTABLE INNER JOIN
                             PRODCALCTRANS ON PRODTABLE.PRODID = PRODCALCTRANS.PRODID AND PRODTABLE.DATAAREAID = PRODCALCTRANS.DATAAREAID
    WHERE        (PRODTABLE.PRODSTATUS = 7) AND (PRODTABLE.DATAAREAID = N'AR1') AND (PRODTABLE.ITEMID = @itemid) AND
                             (PRODTABLE.FINISHEDDATE >= @Paramfromdate) AND (PRODTABLE.FINISHEDDATE <= @Paramtodate)

  • Only sub total in alv report

    hi,
    I have a report on ALV with sub totals for some fields, it is working fine but my requirement is whether i can get only the sub totals of that report.
    regards,
    Prabhu

    HI
    refer this code.
    REPORT ZALV.
    TYPE-POOLS: SLIS.
    DATA: G_REPID LIKE SY-REPID,
    GS_PRINT            TYPE SLIS_PRINT_ALV,
    GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER,
    GT_EVENTS           TYPE SLIS_T_EVENT,
    GT_SORT             TYPE SLIS_T_SORTINFO_ALV,
    GS_LAYOUT           TYPE SLIS_LAYOUT_ALV,
    GT_FIELDCAT         TYPE SLIS_T_FIELDCAT_ALV,
    FIELDCAT_LN LIKE LINE OF GT_FIELDCAT,
    COL_POS TYPE I.
    DATA: BEGIN OF ITAB,
      FIELD1(5) TYPE C,
      FIELD2(5) TYPE C,
      FIELD3(5) TYPE P DECIMALS 2,
    END OF ITAB.
    DATA: BEGIN OF ITAB1 OCCURS 0.
      INCLUDE STRUCTURE ITAB.
    DATA: END OF ITAB1.
    DATA: BEGIN OF ITAB_FIELDCAT OCCURS 0.
      INCLUDE STRUCTURE ITAB.
    DATA: END OF ITAB_FIELDCAT.
    Print Parameters
    PARAMETERS:
                P_PRINT  AS CHECKBOX DEFAULT ' ', "PRINT IMMEDIATE
                P_NOSINF AS CHECKBOX DEFAULT 'X', "NO SELECTION INFO
                P_NOCOVE AS CHECKBOX DEFAULT ' ', "NO COVER PAGE
                P_NONEWP AS CHECKBOX DEFAULT ' ', "NO NEW PAGE
                P_NOLINF AS CHECKBOX DEFAULT 'X', "NO PRINT LIST INFO
                P_RESERV TYPE I.                  "NO OF FOOTER LINE
    INITIALIZATION.
    G_REPID = SY-REPID.
    PERFORM PRINT_BUILD    USING GS_PRINT.      "Print PARAMETERS
    START-OF-SELECTION.
    TEST DATA
    MOVE 'TEST1' TO ITAB1-FIELD1.
    MOVE 'TEST1' TO ITAB1-FIELD2.
    MOVE '10.00' TO ITAB1-FIELD3.
    APPEND ITAB1.
    MOVE 'TEST2' TO ITAB1-FIELD1.
    MOVE 'TEST2' TO ITAB1-FIELD2.
    MOVE '20.00' TO ITAB1-FIELD3.
    APPEND ITAB1.
    DO 50 TIMES.
      APPEND ITAB1.
    ENDDO.
    END-OF-SELECTION.
    PERFORM BUILD.
    PERFORM EVENTTAB_BUILD CHANGING GT_EVENTS.
    PERFORM COMMENT_BUILD  CHANGING GT_LIST_TOP_OF_PAGE.
    PERFORM CALL_ALV.
    FORM BUILD.
    DATA FIELD CATALOG
    Explain Field Description to ALV
    DATA: FIELDCAT_IN TYPE SLIS_FIELDCAT_ALV.
    CLEAR FIELDCAT_IN.
    FIELDCAT_LN-FIELDNAME = 'FIELD1'.
    FIELDCAT_LN-TABNAME   = 'ITAB1'.
    *FIELDCAT_LN-NO_OUT    = 'X'.  "FIELD NOT DISPLAY, CHOOSE FROM LAYOUT
    FIELDCAT_LN-KEY       = ' '.   "SUBTOTAL KEY
    FIELDCAT_LN-NO_OUT    = ' '.
    FIELDCAT_LN-SELTEXT_L = 'HEAD1'.
    APPEND FIELDCAT_LN TO GT_FIELDCAT.
    CLEAR FIELDCAT_IN.
    FIELDCAT_LN-FIELDNAME = 'FIELD2'.
    FIELDCAT_LN-TABNAME   = 'ITAB1'.
    FIELDCAT_LN-NO_OUT    = 'X'.
    FIELDCAT_LN-SELTEXT_L = 'HEAD2'.
    APPEND FIELDCAT_LN TO GT_FIELDCAT.
    CLEAR FIELDCAT_IN.
    FIELDCAT_LN-FIELDNAME     = 'FIELD3'.
    FIELDCAT_LN-TABNAME       = 'ITAB1'.
    FIELDCAT_LN-REF_FIELDNAME = 'MENGE'. "<- REF FIELD IN THE DICTIONNARY
    FIELDCAT_LN-REF_TABNAME   = 'MSEG'.  "<- REF TABLE IN THE DICTIONNARY
    FIELDCAT_LN-NO_OUT        = ' '.
    FIELDCAT_LN-DO_SUM        = 'X'.   "SUM UPON DISPLAY
    APPEND FIELDCAT_LN TO GT_FIELDCAT.
    DATA SORTING AND SUBTOTAL
    DATA: GS_SORT TYPE SLIS_SORTINFO_ALV.
    CLEAR GS_SORT.
    GS_SORT-FIELDNAME = 'FIELD1'.
    GS_SORT-SPOS      = 1.
    GS_SORT-UP        = 'X'.
    GS_SORT-SUBTOT    = 'X'.
    APPEND GS_SORT TO GT_SORT.
    CLEAR GS_SORT.
    GS_SORT-FIELDNAME = 'FIELD2'.
    GS_SORT-SPOS      = 2.
    GS_SORT-UP        = 'X'.
    *GS_SORT-SUBTOT    = 'X'.
    APPEND GS_SORT TO GT_SORT.
    ENDFORM.
    FORM CALL_ALV.
    ABAP List Viewer
    CALL FUNCTION 'REUSE_ALV_LIST_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_STRUCTURE_NAME = 'ITAB1'
    IS_LAYOUT =  GS_LAYOUT
    IT_FIELDCAT = GT_FIELDCAT[]
    IT_EXCLUDING =
    IT_SPECIAL_GROUPS =
      IT_SORT = GT_SORT[]
    IT_FILTER =
    IS_SEL_HIDE =
    I_DEFAULT = 'X'
    I_SAVE = ' '
    IS_VARIANT =
      IT_EVENTS = GT_EVENTS[]
    IT_EVENT_EXIT =
      IS_PRINT = GS_PRINT
    IS_REPREP_ID =
    I_SCREEN_START_COLUMN = 0
    I_SCREEN_START_LINE = 0
    I_SCREEN_END_COLUMN = 0
    I_SCREEN_END_LINE = 0
    IMPORTING
    E_EXIT_CAUSED_BY_CALLER =
    ES_EXIT_CAUSED_BY_USER =
    TABLES
    T_OUTTAB = ITAB1
    EXCEPTIONS
    PROGRAM_ERROR = 1
    OTHERS = 2.
    ENDFORM.
    HEADER FORM
    FORM EVENTTAB_BUILD CHANGING LT_EVENTS TYPE SLIS_T_EVENT.
    CONSTANTS:
    GC_FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.
    *GC_FORMNAME_END_OF_PAGE TYPE SLIS_FORMNAME VALUE 'END_OF_PAGE'.
      DATA: LS_EVENT TYPE SLIS_ALV_EVENT.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
           EXPORTING
                I_LIST_TYPE = 0
           IMPORTING
                ET_EVENTS   = LT_EVENTS.
      READ TABLE LT_EVENTS WITH KEY NAME =  SLIS_EV_TOP_OF_PAGE
                               INTO LS_EVENT.
      IF SY-SUBRC = 0.
        MOVE GC_FORMNAME_TOP_OF_PAGE TO LS_EVENT-FORM.
        APPEND LS_EVENT TO LT_EVENTS.
      ENDIF.
    define END_OF_PAGE event
    READ TABLE LT_EVENTS WITH KEY NAME =  SLIS_EV_END_OF_PAGE
                             INTO LS_EVENT.
    IF SY-SUBRC = 0.
      MOVE GC_FORMNAME_END_OF_PAGE TO LS_EVENT-FORM.
      APPEND LS_EVENT TO LT_EVENTS.
    ENDIF.
    ENDFORM.
    FORM COMMENT_BUILD CHANGING GT_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.
      DATA: GS_LINE TYPE SLIS_LISTHEADER.
      CLEAR GS_LINE.
      GS_LINE-TYP  = 'H'.
      GS_LINE-INFO = 'HEADER 1'.
      APPEND GS_LINE TO GT_TOP_OF_PAGE.
      CLEAR GS_LINE.
      GS_LINE-TYP  = 'S'.
      GS_LINE-KEY  = 'STATUS 1'.
      GS_LINE-INFO = 'INFO 1'.
      APPEND GS_LINE TO GT_TOP_OF_PAGE.
      GS_LINE-KEY  = 'STATUS 2'.
      GS_LINE-INFO = 'INFO 2'.
      APPEND GS_LINE TO GT_TOP_OF_PAGE.
    CLEAR GS_LINE.
    GS_LINE-TYP  = 'A'.
    GS_LINE-INFO = 'ACTION'.
    APPEND GS_LINE TO  GT_TOP_OF_PAGE.
    ENDFORM.
    FORM TOP_OF_PAGE.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
           EXPORTING
                IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE.
      WRITE: SY-DATUM, 'Page No', SY-PAGNO LEFT-JUSTIFIED.
    ENDFORM.
    FORM END_OF_PAGE.
      WRITE at (sy-linsz) sy-pagno CENTERED.
    ENDFORM.
    PRINT SETTINGS
    FORM PRINT_BUILD USING LS_PRINT TYPE SLIS_PRINT_ALV.
      LS_PRINT-PRINT              = P_PRINT.  "PRINT IMMEDIATE
      LS_PRINT-NO_PRINT_SELINFOS  = P_NOSINF. "NO SELECTION INFO
      LS_PRINT-NO_COVERPAGE       = P_NOCOVE. "NO COVER PAGE
      LS_PRINT-NO_NEW_PAGE        = P_NONEWP.
      LS_PRINT-NO_PRINT_LISTINFOS = P_NOLINF. "NO PRINT LIST INFO
      LS_PRINT-RESERVE_LINES      = P_RESERV.
    ENDFORM.
    *END OF ZALV PROGRAM
    Reward all helpfull answers.
    Regards.
    Jay

  • Hide grand total field on ALV report, But keep the sub total fields

    Dear Experts,
    1) How to hide grand total field on ALV report, But keep the sub total fields.
    2) How to populate rate per ton & calculate total price according to the qty in delivering document.

    Dear Experts,
    1) How to hide grand total field on ALV report, But keep the sub total fields.
    2) How to populate rate per ton & calculate total price according to the qty in delivering document.

  • Urgent: regarding sub total button in alv report

    hi,
    i had made dis report and it is is fine till now,but now i want add the sub total field in it ,by making double click on the field sub-total should be displayed in it.
    here is d code as i had tried the sub - total but when i execute it is giving some diferrent result.
    *& Report  ZTET2
    REPORT  ZTET2.
    TABLES: ISEG,MARA.
    TYPE-POOLS : SLIS.
    DATA : DATE1(15) TYPE C,
    DATE2(15) TYPE C,
    TITLE(65) TYPE C,
    DT(25) TYPE C.
    DATA : ITEVENT TYPE SLIS_T_EVENT.
    DATA: lv_sort TYPE slis_sortinfo_alv,
          t_sort type slis_t_sortinfo_alv.
    DATA : repid LIKE sy-repid.
    INTERNAL TABLE FOR INVENTORY STOCK *****************
    DATA: BEGIN OF ITS1 OCCURS 0,
          MATNR LIKE ISEG-MATNR,
          ITEMID(6) TYPE C,
          MEINS LIKE ISEG-MEINS,
          MENGE LIKE ISEG-MENGE,
          WRTZL LIKE ISEG-WRTZL,
          BUCHM LIKE ISEG-BUCHM,
          WRTBM LIKE ISEG-WRTBM,
          WERKS LIKE ISEG-WERKS,
          BUDAT LIKE ISEG-BUDAT,
          ZLDAT LIKE ISEG-ZLDAT,
          MTART LIKE MARA-MTART,
          ITEMDESC LIKE MAKT-MAKTX,
          DIFFQTY LIKE ISEG-BUCHM,
          DIFFVALUE LIKE ISEG-WRTBM,
          GRUND LIKE ISEG-GRUND,
          GRTXT LIKE T157E-GRTXT,
          BWART LIKE T157E-BWART,
          REAS TYPE C LENGTH 15,
          END OF ITS1.
    data: t_heading type slis_t_listheader.
    SELECTION-SCREEN BEGIN OF BLOCK PAR1 WITH FRAME TITLE TEXT-001.
    *SELECTION-SCREEN : BEGIN OF BLOCK blk1 WITH FRAME TITLE text-001.
    *********PARAMETERS*********
    PARAMETERS : PLANT LIKE ISEG-WERKS OBLIGATORY.
    *********SELECTION SCREEN OPTIONS*********
    SELECT-OPTIONS : R_DATE FOR ISEG-BUDAT OBLIGATORY NO-EXTENSION,
                     M_TYPE  FOR MARA-MTART,
                     IT_M FOR MARA-MATNR.
    *********DEFINING VARIABLES*********
    SELECTION-SCREEN END OF BLOCK par1.
    CONCATENATE R_DATE-LOW6(2) '.' R_DATE-LOW4(2) '.' R_DATE-LOW+0(4) INTO DATE1.
    CONCATENATE R_DATE-HIGH6(2) '.' R_DATE-HIGH4(2) '.' R_DATE-HIGH+0(4) INTO DATE2.
    TOP-OF-PAGE.
      PERFORM PG_HEADER.
       START-OF-SELECTION.
      SELECT AMATNR AMEINS AMENGE AWRTZL ABUCHM AWRTBM AWERKS ABUDAT AZLDAT BMTART AGRUND CBWART
       FROM ISEG AS A INNER JOIN MARA AS B ON BMATNR = AMATNR
       INNER JOIN MSEG AS C ON AMBLNR = CMBLNR
       INTO CORRESPONDING FIELDS OF TABLE ITS1 WHERE BMATNR = AMATNR  AND BMEINS = AMEINS AND AWERKS = PLANT AND ABUDAT IN R_DATE AND BMTART IN M_TYPE AND BMATNR IN IT_M.
    LOOP AT ITS1.
         ITS1-ITEMID = ITS1-MATNR+12(6).
         ITS1-DIFFQTY = ITS1-MENGE - ITS1-BUCHM.
         ITS1-DIFFVALUE = ITS1-WRTZL - ITS1-WRTBM.
         SELECT SINGLE MAKTX FROM MAKT INTO ITS1-ITEMDESC WHERE MATNR = ITS1-MATNR.
         SELECT SINGLE GRTXT INTO ITS1-GRTXT FROM T157E WHERE GRUND = ITS1-GRUND AND SPRAS = 'E' AND BWART = ITS1-BWART.
         MODIFY ITS1.
    ENDLOOP.
    PERFORM PRN_SMSTOCK_ALV.
    WRITING DATA FROM D TABLES**********
    FORM PG_HEADER.
    WRITE : 'PHYSICAL INVENTORY AUDIT REPORT             PLANT : ', PLANT.
    ENDFORM.
    *&      Form  PRN_SMSTOCK_ALV
          text
    -->  p1        text
    <--  p2        text
    form PRN_SMSTOCK_ALV .
    data: w_title   type lvc_title,
          w_repid   type syrepid,
          w_comm    type slis_formname,
          w_status  type slis_formname,
          x_layout  type slis_layout_alv,
          t_event   type slis_t_event,
          t_fieldcat type slis_t_fieldcat_alv,
          t_subtot TYPE slis_t_sortinfo_alv,
          subtot LIKE LINE OF t_subtot.
    refresh t_fieldcat.
    refresh t_event.
    refresh t_sort.
    clear x_layout.
    clear w_title.
      perform set_fieldcat2 using:
    1  'MTART'     'MTART'     'MARA'  '15'  space 'MATERIAL TYPE'        space  space  space space space space space space SPACE t_fieldcat 'L' 'L',
    2  'ITEMID'    'ITEMID'    'MARA'  '7'   space 'ITEM ID'              space  space  space space space space space space SPACE t_fieldcat 'R' 'C',
    3  'ITEMDESC'  'MAKTX'     'MAKT'  '25'  space 'MATERIAL DESCRIPTION' space  space  space space space space space space SPACE t_fieldcat 'L' 'C',
    4  'MEINS'     'MEINS'     'MARA'  '5'   space 'UOM'                  space  space  space space space space space space SPACE t_fieldcat 'C' 'C',
    5  'MENGE'     'MENGE'     'ISEG'  '13'  space 'ORG.INV.QTY'          space  space  space space space space space space SPACE t_fieldcat 'R' 'C',
    6  'WRTZL'     'WRTZL'     'ISEG'  '13'  space 'ORG.INV.VALUE'        space  space  space space space space space space SPACE t_fieldcat 'R' 'C',
    7  'BUCHM'     'BUCHM'     'ISEG'  '13'  space 'PHY.INV.QTY'          space  space  space space space space space space SPACE t_fieldcat 'R' 'C',
    8  'WRTBM'     'WRTBM'     'ISEG'  '13'  space 'PHY.INV.VALUE'        space  space  space space space space space space SPACE t_fieldcat 'R' 'C',
    9  'DIFFQTY'   'MENGE'     'ISEG'  '13'  space 'DIFF.INV.QTY'         space  space  space space space space space space SPACE t_fieldcat 'R' 'C',
    10 'DIFFVALUE' 'WRTZL'     'ISEG'  '13'  space 'DIFF.INV.VALUE'       space  space  space space space space space space SPACE t_fieldcat SPACE 'P',
    11 'BUDAT'     'BUDAT'     'ISEG'  '18'  space 'CORRECTED DATE'       space  space  space space space space space space SPACE t_fieldcat  'C' 'C',
    12 'GRTXT'     'GRTXT'     'ISEG'  '18'  space 'REASON'               space  space  space space space space space space SPACE t_fieldcat  'L' 'L',
    13 'REAS'      'REAS'      'ISEG'  '18'  space 'AUTH.BY'              space  space  space space space space space space SPACE t_fieldcat  'C' 'C'.
    x_layout-zebra = 'X'.
    perform set_top_page_heading using t_heading t_event.
    perform set_events using t_event.
    perform get_subtotals.
      w_status = ''.
      w_repid = sy-repid.
    w_comm   = 'USER_COMMAND'.
      call function 'REUSE_ALV_GRID_DISPLAY'
        exporting
          i_callback_program       = w_repid
          it_fieldcat              = t_fieldcat
          i_Callback_top_of_page   = 'Top-of-page'
          is_layout                = x_layout
          it_sort                  = t_sort
          i_callback_pf_status_set = w_status
          i_callback_user_command  = w_comm
          i_save                   = 'X'
          it_events                = t_event
          i_grid_title             = w_title
          tables
          t_outtab                 = ITS1
          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.
    FORM set_fieldcat2 USING
          p_colpos p_fieldname p_ref_fieldname p_ref_tabname
          p_outputlen p_noout
          p_seltext_m p_seltext_l p_seltext_s p_reptext_ddic p_ddictxt
          p_hotspot p_showasicon p_checkbox p_edit
          p_dosum
        p_subtot
          t_fieldcat TYPE slis_t_fieldcat_alv
          P_JUST
          P_FTYPE.
      DATA: wa_fieldcat TYPE slis_fieldcat_alv.
      CLEAR wa_fieldcat.
    General settings
      wa_fieldcat-fieldname = p_fieldname.
      wa_fieldcat-col_pos = p_colpos.
      wa_fieldcat-no_out = p_noout.
      wa_fieldcat-hotspot = p_hotspot.
      wa_fieldcat-checkbox = p_checkbox.
      wa_fieldcat-icon = p_showasicon.
      wa_fieldcat-do_sum = p_dosum.
    wa_fieldcat-t_subtot = p_subtot.
    Set output length.
      IF NOT p_outputlen IS INITIAL.
        wa_fieldcat-outputlen = p_outputlen.
      ENDIF.
    Set text headers.
    IF NOT p_seltext_m IS INITIAL.
        wa_fieldcat-seltext_m = p_seltext_m.
    ENDIF.
    IF NOT p_seltext_l IS INITIAL.
        wa_fieldcat-seltext_l = p_seltext_l.
    ENDIF.
    IF NOT p_seltext_s IS INITIAL.
        wa_fieldcat-seltext_s = p_seltext_s.
    ENDIF.
      IF NOT p_reptext_ddic IS INITIAL.
        wa_fieldcat-reptext_ddic = p_reptext_ddic.
      ENDIF.
    IF NOT p_ddictxt IS INITIAL.
        wa_fieldcat-ddictxt = p_ddictxt.
    ENDIF.
      IF NOT P_JUST IS INITIAL.
        WA_FIELDCAT-JUST = P_JUST.
      ENDIF.
      IF NOT p_edit IS INITIAL.
        wa_fieldcat-Input     = 'X'.
        wa_fieldcat-edit     = 'X'.
        wa_fieldcat-do_sum = 'x'.
       wa_fieldcat-p_subtot = 'x'.
      ENDIF.
    APPEND wa_fieldcat TO t_fieldcat.
    ENDFORM.                   "set_fieldcat2
    ======================== Subroutines called by ALV ================
    *&      Form  top_of_page
          Called on top_of_page ALV event.
          Prints the heading.
    form top_of_page.
      call function 'REUSE_ALV_COMMENTARY_WRITE'
         exporting
              it_list_commentary = t_heading.
    ENDFORM.
    form set_top_page_heading using t_heading type slis_t_listheader
                                    t_events  type slis_t_event.
    data: x_heading type slis_listheader,
          x_event   type line of slis_t_event.
    Report title
      clear t_heading[].
      clear x_heading.
      x_heading-typ = 'H'.
      x_heading-info = 'PHYSICAL INVENTORY AUDIT REPORT'.
      append x_heading to t_heading.
    Plant Name
    clear x_heading.
      x_heading-typ = 'S'.
      x_heading-key = 'PLANT        : '.
      x_heading-info = PLANT.
      append x_heading to t_heading.
    IF DATE2 = '00.00.0000'.
      CONCATENATE DATE1 'to' DATE1 INTO DT SEPARATED BY SPACE.
    ELSE.
      CONCATENATE DATE1 'to' DATE2 INTO DT SEPARATED BY SPACE.
    ENDIF.
    X_heading-TYP = 'S'.
    X_heading-key = 'PERIOD         :'.
    X_heading-INFO = DT.
    APPEND x_heading TO t_heading.
    Control Date
      clear x_heading.
      x_heading-typ = 'S'.
      x_heading-key = 'CONTROL NO. :'.
      x_heading-info = ' ASDFADDFAAS  DATE : 11.04.2007'.
      append x_heading to t_heading.
    Control date
    clear x_heading.
    x_heading-typ = 'S'.
    x_heading-key = 'CONTROL DATE : '.
    x_heading-info = ''.
    append x_heading to t_heading.
    Time of execution
    clear x_heading.
    x_heading-typ = 'S'.
    x_heading-key = 'DATE : '.
    write sy-DATUM to x_heading-info.
    append x_heading to t_heading.
    Top of page event
      x_event-name = slis_ev_top_of_page.
      x_event-form = 'TOP_OF_PAGE'.
      append x_event to t_events.
    endform.
    FORM get_subtotals.
    CLEAR lv_sort.
    lv_sort-fieldname = 'MENGE'.
    lv_sort-up = 'X'.
    lv_sort-subtot = 'X'.
    APPEND lv_sort TO t_sort.
    clear lv_sort.
    *lv_sort-fieldname = 'MENGE'.
    *lv_sort-tabname = 'ITS1'.
    *lv_sort-subtot = 'X'.
    *APPEND lv_sort TO t_sort.
    lv_sort-fieldname = 'WRTZL'.
    lv_sort-tabname = 'ITS1'.
    lv_sort-subtot = 'X'.
    APPEND lv_sort TO t_sort.
    clear lv_sort.
    lv_sort-fieldname = 'BUCHM'.
    lv_sort-tabname = 'ITS1'.
    lv_sort-subtot = 'X'.
    APPEND lv_sort TO t_sort.
    clear lv_sort.
    lv_sort-fieldname = 'WRTBM'.
    lv_sort-tabname = 'ITS1'.
    lv_sort-subtot = 'X'.
    APPEND lv_sort TO t_sort.
    clear lv_sort.
    lv_sort-fieldname = 'DIFFQTY'.
    lv_sort-tabname = 'ITS1'.
    lv_sort-subtot = 'X'.
    APPEND lv_sort TO t_sort.
    clear lv_sort.
    lv_sort-fieldname = 'DIFFVALUE'.
    lv_sort-tabname = 'ITS1'.
    lv_sort-subtot = 'X'.
    APPEND lv_sort TO t_sort.
    clear lv_sort.
    ENDFORM.
    form set_events using t_events type slis_t_event.
    data: x_event   type line of slis_t_event.
    endform.
    PLZ HELP ME and definately get rewarded.

    hi,
    how did u declared ur internal table?
    Declare a dummy field in your internal table to trigger subtotal text event.
    TYPES: BEGIN OF ty_ekpo,
              lifnr TYPE ekko-lifnr,    "vendor number
              ebeln TYPE ekko-ebeln,    "purchase document number
              ebelp TYPE ekpo-ebelp,    "Item Number of Purchasing Document
              matnr TYPE ekpo-matnr,    "Material Number
              bukrs TYPE ekpo-bukrs,    "Company Code
              werks TYPE ekpo-werks,    "Plant
              d,                        "Dummy field to fire the Subtotal text event
          END OF ty_ekpo.
    Prepare field catalog for that dummyfield also and set attributes like below
    wa_fcat-col_pos = 7.
      wa_fcat-fieldname = 'D'.
      wa_fcat-tabname = 'IT_EKPO'.
      wa_fcat-ref_fieldname = 'NETPR'.
      wa_fcat-ref_tabname = 'EKPO'.
      wa_fcat-no_out = 'X'.
      APPEND wa_fcat TO it_fcat.
    Fill sortinfo table as follows
    wa_sort-spos = 1.
      wa_sort-fieldname = 'LIFNR'.
      wa_sort-tabname = 'IT_EKPO'.
      wa_sort-up = 'X'.
      wa_sort-group = 'UL'.
      APPEND wa_sort TO it_sort.
      CLEAR wa_sort.
      wa_sort-spos = 2.
      wa_sort-fieldname = 'D'.
      wa_sort-tabname = 'IT_EKPO'.
      wa_sort-up = 'X'.
      wa_sort-group = 'UL'.
      wa_sort-subtot = 'X'.
      APPEND wa_sort TO it_sort.
    fill the event table
    wa_event-name = 'SUBTOTAL_TEXT'.  "--> this event is used to trigger subtotal text
      wa_event-form = 'SUBTOTAL'.
      APPEND wa_event TO it_event.
    *&      Form  subtotal
    FORM subtotal USING i_listhead STRUCTURE wa_ekpo  i_subtotal TYPE slis_subtot_text.
      READ TABLE it_sort INTO wa_sort WITH KEY fieldname = 'D'.
      IF sy-subrc = 0.
        IF i_subtotal-criteria = 'D'.
          i_subtotal-display_text_for_subtotal = 'Sub total'.
        ENDIF.
      ENDIF.
    ENDFORM.                    "subtotal
    Thanks & REgards

  • Report Total but no Sub total.

    Hi,
    I have a report ( PL/SQL Function returning SQL Query).
    The query is complicated.
    If value of item :p1 is not null then it returns select col_a , col_b ... from table_a
    but if value of item :p1 is null then it returns select col_a , sum( col_b) , sum(col_c).... from table_a group by col_a
    I went to report attributes and checked SUM for all the fields ( Except the first field )
    Its showing Sub total for each row and grand total..
    Is there a way I can show only grand total and not the sub total.

    1. Yes I'm using "Use generic column Name"
    2. No I'm not using column alias for sum
    3. Further my report uses two lines for Header , for which I am using custom report region.
    Re: Two level row header
    Below is the exact query i'm using for report
    DECLARE
    vc_query VARCHAR2(9000);
    BEGIN
    if :P19_PROJECT_OWNER <> 0 and :P19_PROJECT_OWNER is not null then
    vc_query := 'select * from
    ( select current_status , count , high , medium , low , red , green , yellow , priority_list , ">30 Days" from project_summary where user_id = ' || :P19_PROJECT_OWNER
    || 'union
    select current_status , 0 , 0 , 0 , 0 , 0, 0 , 0, 0, 0 from sr_current_status where current_status not in ( select distinct current_status from project_summary where user_id = ' || :P19_PROJECT_OWNER || ')) where current_status not like ''Closed%''';
    else
    vc_query :='select current_status , sum(count) , sum(high) , sum(medium) , sum(low) , sum(red) , sum(green) , sum(yellow) , sum(priority_list) , sum(">30 Days") from project_summary where current_status not like ''Closed%'' group by current_status';
    end if;
    return vc_query;     
    end;
    Edited by: Shijesh Kumar on Jan 29, 2009 12:19 PM

  • Interactive Report Sub-total and total

    Hi friends,
    I have an employee interactive report with group by job name and also showing the salary sub-total for each and every job(group by).
    I have an requirement like to highlight the sub-total for each and every job with a background color so that the user can identify the sub-total with the color, and also whether it is possible to display an overall total @ last in the report with a label named "Total Salary" in which it calculates the overall salary is also to be highlightened with the background color.
    Also is it possible to display a text "Sub-total" besides each and every salary sub-total  of job(group by). Currently if we display a sum for the salary then im getting the total's but with out a text named total.
    Since i can see the highlighted feature in interactive report but im not sure how to apply it for the sub-total and total column.
    I have reproduced the example in apex.oracle.com
    http://apex.oracle.com/pls/apex/f?p=4550:1:0:::::
    In the application 9494 named "test" in page1.
    Thanks in advance.
    Brgds,
    Mini

    Hi, Mini,
    style=background-color:red;
    But that Total region color dint change.The code for style should be in "Form HTML Element Attributes". However, this changes the background color only for the Total value not for the whole row.
    If you want to change for the whole row, you need to change the template that is selected for the region.
    I changed the region template in your application to "Borderless Region" and made the changes to the "Borderless Region" template, it now shows the background color for Total Value.
    <table class="t20Region t20Borderless #REGION_CSS_CLASSES#" id="#REGION_STATIC_ID#" border="0" cellpadding="0" cellspacing="0" summary="" #REGION_ATTRIBUTES#>
    <thead><tr><th class="t20RegionHeader" id="#REGION_STATIC_ID#_header">#TITLE#</th></tr></thead>
    <tbody id="#REGION_STATIC_ID#_body">
    <tr><td class="t20ButtonHolder">#CLOSE##PREVIOUS##NEXT##DELETE##EDIT##CHANGE##CREATE##CREATE2##EXPAND##COPY##HELP#</td></tr>
    <tr><td class="t20RegionBody" style="background-color:orange">#BODY#</td></tr>
    </tbody>
    </table>The below does the trick. :)
    <tr><td class="t20RegionBody" style="background-color:orange">#BODY#</td></tr>Note: I made the changes to "Borderless Template", but you can copy the template to your own and apply this change.
    Regards,
    Natarajan

  • Creating Weighted Average Sub-Totals in Standard Apex Report

    Based upon the below query, I am trying to have a Standard SQL report produce Weighted Average sub totals for 4 columns
    SELECT   Pool
    , order_by
    , Pool_order
    , Perf_Non_Perf
    , CurrBal
    , LowVal
    , HighVal
    , LossHigh
    , LossLow
    , CalcCurrBal
    , DECODE(CurrBal,0,0,(LowVal/CurrBal * 100 )) AS LowPercent
    , DECODE(CurrBal,0,0,(HighVal/CurrBal * 100 )) AS HighPercent
    , DECODE(CalcCurrBal,0,0,(LossHigh/CalcCurrBal * 100)) AS LossHighPercent
    , DECODE(CalcCurrBal,0,0,(LossLow/CalcCurrBal * 100)) AS LossLowPercent
    From (
    SELECT   Pool
    , 1 as order_by
    , Pool Pool_order
    , Perf_Non_Perf
    , Sum(Current_Balance) AS CurrBal
    , Sum(Low_Value) AS LowVal
    , Sum(High_Value) AS HighVal
    , Sum(Calculated_Cumm_Loss_High) AS LossHigh
    , Sum(Calculated_Cumm_Loss_Low) AS LossLow
    , Sum(Current_Balance_to_Calc_Cumm_L) AS CalcCurrBal
    FROM Current_Data
    GROUP BY Pool, Perf_Non_Perf
    ORDER BY Pool, Perf_Non_Perf DESCThe columns in question are:
    LowPercent
    HighPercent
    LossHighPercent
    LossLowPercent
    Any ideas other than using a union to add the sub-totals in as a separate query (trying to keep this confined to one query if possible)..
    Thank you,
    Tony Miller
    Dallas, TX

    Tony,
    The PL/SQL forum may answer this better but had you considered the ROLLUP or CUBE GROUP BY functions? ROLLUP would look like this in your query:
      SELECT pool,
             order_by,
             pool_order,
             perf_non_perf,
             currbal,
             lowval,
             highval,
             losshigh,
             losslow,
             calccurrbal,
             SUM (DECODE (currbal, 0, 0, (lowval / currbal * 100))) AS lowpercent,
             SUM (DECODE (currbal, 0, 0, (highval / currbal * 100))) AS highpercent,
             SUM (DECODE (calccurrbal, 0, 0, (losshigh / calccurrbal * 100)))
                AS losshighpercent,
             SUM (DECODE (calccurrbal, 0, 0, (losslow / calccurrbal * 100)))
                AS losslowpercent
        FROM (  SELECT pool,
                       1 AS order_by,
                       pool pool_order,
                       perf_non_perf,
                       SUM (current_balance) AS currbal,
                       SUM (low_value) AS lowval,
                       SUM (high_value) AS highval,
                       SUM (calculated_cumm_loss_high) AS losshigh,
                       SUM (calculated_cumm_loss_low) AS losslow,
                       SUM (current_balance_to_calc_cumm_l) AS calccurrbal
                  FROM current_data
              GROUP BY pool, perf_non_perf)
    GROUP BY rollup (pool,
                     order_by,
                     pool_order,
                     perf_non_perf,
                     currbal,
                     lowval,
                     highval,
                     losshigh,
                     losslow,
                     calccurrbal)
    ORDER BY pool, perf_non_perf DESCJeff

  • Doubt about sub totaling in Report Painter

    Hi,
    I am new to the report painter and i want to know that is there a possibility of performing the sub total in the output.
    Suppose,i had defined a row and column and in the row i had given the range of the Account Numbers and in the column i had defined the local currency. As there are a lot of GL Account Numbers i.e. 1000,2000,40000 and so on....
    Is it possible to display the out put on the basis of sub total ? I had seen a sub total button during the creation of report in report painter format and i had defined Account Number to be explode .
    When i execute the report it displays the grand total of the whole accounts.. I want to show sub total also.
    Please provide me guidelines to solve this problem.

    >
    Vijay Babu Dudla wrote:
    > >So better don't give him a chance to create one more thread, please...
    >
    > But he will create one more Account , it is easy for him to post a new Thread with another name.
    Dont worry. Its pretty easy to catch his clone. All his questions follow a pattern. Plus he asks a hundred question on the same issue. Also, he's probably the only ABAPer who extensively works on Report Writers.
    pk

  • Sub Total Button in Report Painter Output

    Hi,
    I am working on the Balance Sheet Report in the Report Painter and i am trying to display the sub totaling display in the output.
    In this i had defined the row which is based on the range of Account Number and it has the series i.e. 100000,30000,200000 etc..
    Is it possible to display the output sub total on the basis of the Account Number Series which is mentioned above. As in a ALV Report we have the sub total button  in report output.
    If it is,then please provide me guidelines for it ......
    Edited by: ricx .s on Jul 29, 2009 6:47 AM

    Hi,
    Try this code,
    it working,
    Data :  X_SORT      TYPE SLIS_SORTINFO_ALV,
    IT_SORT     TYPE SLIS_T_SORTINFO_ALV,
    X_SORT-SPOS = 1.                                " Field number of ALV on which u want to sort
      X_SORT-FIELDNAME = 'SEGMENT' .     " field name
      X_SORT-TABNAME = 'IT_ALV1'(001).  "table name same as ur alv table name
      X_SORT-UP = 'X'.                                   " put up as 'X'
      X_SORT-SUBTOT = 'X'.                      " Sub total allowed
      APPEND X_SORT TO IT_SORT.          "append
      CLEAR X_SORT.                                "clear x_SORT
    "in ALV_GRID_DISPLAY pass the it sort in it_SORT
    IT_SORT                 =   IT_SORT
    Thanks
    Arun Kayal

  • Sub totaling in the ALV report

    Hi,
    My requirement is to display the data in a ALV format. The ALV need to display the sub total. For example if the ALV display the comapny code, the number of the line of the company code need to displayed.
    1000
    1000
    1000
    Sub total 3
    2000
    2000
    2000
    2000
    sub total 4
    I made the changes to display the ALV. Please help mein obtaining the sub total..
    Regards
    Suresh

    HI,
    Below example may clear ur requirement.
    REPORT YMS_ALVSUBTOTAL.
    *REPORT z_alv_sub_totals .
    TYPE-POOLS: slis.
    DATA: BEGIN OF it_output OCCURS 0,
    var1(8) TYPE n,
    var2(10),
    var3 TYPE I,
    END OF it_output.
    DATA: it_fieldcat TYPE slis_t_fieldcat_alv,
    t_fieldcat TYPE slis_fieldcat_alv,
    it_sort TYPE slis_t_sortinfo_alv,
    t_sort TYPE slis_sortinfo_alv,
    v_repid LIKE sy-repid.
    INITIALIZATION.
    v_repid = sy-repid.
    START-OF-SELECTION.
    PERFORM get_data.
    PERFORM sort_fields.
    PERFORM fill_fieldcat.
    PERFORM list_display.
    *& Form GET_DATA
    text
    --> p1 text
    <-- p2 text
    FORM get_data.
    it_output-var1 = 1000.
    it_output-var2 = 'anupama'.
    it_output-var3 = '10000'.
    APPEND it_output.
    CLEAR it_output.
    it_output-var1 = 1000.
    it_output-var2 = 'siddhu'.
    it_output-var3 = '20000'.
    APPEND it_output.
    CLEAR it_output.
    it_output-var1 = 1000.
    it_output-var2 = 'chinni'.
    it_output-var3 = '100000'.
    APPEND it_output.
    CLEAR it_output.
    it_output-var1 = 2000.
    it_output-var2 = 'chicchu'.
    it_output-var3 = '10000'.
    APPEND it_output.
    CLEAR it_output.
    it_output-var1 = 2000.
    it_output-var2 = 'candy'.
    it_output-var3 = '10000'.
    APPEND it_output.
    CLEAR it_output.
    it_output-var1 = 1000.
    it_output-var2 = 'anupama'.
    it_output-var3 = '10000'.
    APPEND it_output.
    CLEAR it_output.
    it_output-var1 = 4000.
    it_output-var2 = 'anupama'.
    it_output-var3 = '10000'.
    APPEND it_output.
    CLEAR it_output.
    ENDFORM. " GET_DATA
    *& Form fill_fieldcat
    text
    --> p1 text
    <-- p2 text
    FORM fill_fieldcat.
    PERFORM fill_fields USING: 'IT_OUTPUT' 'VAR1' 'Variable 1' ' ',
    'IT_OUTPUT' 'VAR2' 'Variable 2' ' ',
    'IT_OUTPUT' 'VAR3' 'Variable 3' 'X'.
    ENDFORM. " fill_fieldcat
    *& Form fill_fields
    text
    -->P_0146 text
    -->P_0147 text
    -->P_0148 text
    -->P_0149 text
    FORM fill_fields USING value(tabname) TYPE slis_tabname
    value(fieldname) TYPE slis_fieldname
    value(seltext_m) LIKE dd03p-scrtext_m
    value(do_sum) TYPE c.
    t_fieldcat-tabname = tabname.
    t_fieldcat-fieldname = fieldname.
    t_fieldcat-seltext_m = seltext_m.
    IF do_sum = 'X'.
    t_fieldcat-datatype = 'CURR'.
    ENDIF.
    t_fieldcat-do_sum = do_sum.
    APPEND t_fieldcat TO it_fieldcat.
    CLEAR t_fieldcat.
    ENDFORM. " fill_fields
    *& Form list_display
    text
    --> p1 text
    <-- p2 text
    FORM list_display.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
    i_callback_program = v_repid
    it_fieldcat = it_fieldcat
    it_sort = it_sort[]
    TABLES
    t_outtab = it_output
    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_display
    *& Form sort_fields
    text
    --> p1 text
    <-- p2 text
    FORM sort_fields.
    t_sort-fieldname = 'VAR1'.
    t_sort-tabname = 'IT_OUTPUT'.
    t_sort-spos = 1.
    t_sort-up = 'X'.
    t_sort-subtot = 'X'.
    APPEND t_sort TO it_sort.
    CLEAR t_sort.
    t_sort-fieldname = 'VAR3'.
    t_sort-tabname = 'IT_OUTPUT'.
    t_sort-spos = 2.
    t_sort-up = 'X'.
    APPEND t_sort TO it_sort.
    CLEAR t_sort.
    ENDFORM. " sort_fields
    Thanks,
    Shankar

Maybe you are looking for