Grouping and Sub total Problem in Template Builder

Hi,
Please help me out to sort the problem am getting in template builder.
am here by attaching the xml and RTF which i have done. please go through the files and help me sort the problem.
<LIST_G_REQ>
<G_REQ>
<BUYER_ID>DENIECE</BUYER_ID>
<BUYER_GROUP>1</BUYER_GROUP>
<BUYER_SUBGROUP>ADMIN</BUYER_SUBGROUP>
<REQ_TOT>1</REQ_TOT>
</G_REQ>
<G_REQ>
<BUYER_ID>THUGHES1</BUYER_ID>
<BUYER_GROUP>1</BUYER_GROUP>
<BUYER_SUBGROUP>ADMIN</BUYER_SUBGROUP>
<REQ_TOT>12</REQ_TOT>
</G_REQ>
<G_REQ>
<BUYER_ID>VACHAVEZ</BUYER_ID>
<BUYER_GROUP>1</BUYER_GROUP>
<BUYER_SUBGROUP>ADMIN</BUYER_SUBGROUP>
<REQ_TOT>19</REQ_TOT>
</G_REQ>
<G_REQ>
<BUYER_ID>KAJIKAWA</BUYER_ID>
<BUYER_GROUP>2</BUYER_GROUP>
<BUYER_SUBGROUP>AP</BUYER_SUBGROUP>
<REQ_TOT>25</REQ_TOT>
</G_REQ>
<G_REQ>
<BUYER_ID>MSVIC</BUYER_ID>
<BUYER_GROUP>2</BUYER_GROUP>
<BUYER_SUBGROUP>AP</BUYER_SUBGROUP>
<REQ_TOT>171</REQ_TOT>
</G_REQ>
<G_REQ>
<BUYER_ID>FESPINOZ</BUYER_ID>
<BUYER_GROUP>3</BUYER_GROUP>
<BUYER_SUBGROUP>C&amp;R</BUYER_SUBGROUP>
<REQ_TOT>19</REQ_TOT>
</G_REQ>
<G_REQ>
<BUYER_ID>ASEJH</BUYER_ID>
<BUYER_GROUP>3</BUYER_GROUP>
<BUYER_SUBGROUP>COMPUTER</BUYER_SUBGROUP>
<REQ_TOT>16</REQ_TOT>
</G_REQ>
<G_REQ>
<BUYER_ID>BFINLEY</BUYER_ID>
<BUYER_GROUP>3</BUYER_GROUP>
<BUYER_SUBGROUP>COMPUTER</BUYER_SUBGROUP>
<REQ_TOT>23</REQ_TOT>
</G_REQ>
<G_REQ>
<BUYER_ID>JSMETANA</BUYER_ID>
<BUYER_GROUP>3</BUYER_GROUP>
<BUYER_SUBGROUP>COMPUTER</BUYER_SUBGROUP>
<REQ_TOT>21</REQ_TOT>
</G_REQ>
<G_REQ>
<BUYER_ID>SAVANCIL</BUYER_ID>
<BUYER_GROUP>3</BUYER_GROUP>
<BUYER_SUBGROUP>COMPUTER</BUYER_SUBGROUP>
<REQ_TOT>84</REQ_TOT>
</G_REQ>
<G_REQ>
<BUYER_ID>CALANE</BUYER_ID>
<BUYER_GROUP>3</BUYER_GROUP>
<BUYER_SUBGROUP>CWA</BUYER_SUBGROUP>
<REQ_TOT>28</REQ_TOT>
</G_REQ>
<G_REQ>
<BUYER_ID>KATHYR</BUYER_ID>
<BUYER_GROUP>3</BUYER_GROUP>
<BUYER_SUBGROUP>CWA</BUYER_SUBGROUP>
<REQ_TOT>13</REQ_TOT>
</G_REQ>
<G_REQ>
<BUYER_ID>STEFANIF</BUYER_ID>
<BUYER_GROUP>3</BUYER_GROUP>
<BUYER_SUBGROUP>CWA</BUYER_SUBGROUP>
<REQ_TOT>1</REQ_TOT>
</G_REQ>
</LIST_G_REQ>
This is my xml file please let me know how to do the groupingbased on "BUYER_SUBGROUP" and also "BUYER_GROUP_TOTAL" and "BUYER_SUBGROUP_TOTAL" in RTF.
Thanks in advance

Hi,
I see that your data is having this format
<LIST_G_REQ>
<G_REQ>
<BUYER_ID>DENIECE</BUYER_ID>
<BUYER_GROUP>1</BUYER_GROUP>
<BUYER_SUBGROUP>ADMIN</BUYER_SUBGROUP>
<REQ_TOT>1</REQ_TOT>
</G_REQ>
</LIST_G_REQ>
So to group by BUYER_SUBGROUP, your code will be
<?for-each-group:G_REC;BUYER_SUBGROUP?>
<?end for-each?>
I dont know what you mean by BUYER_GROUP_TOTAL and BUYER_SUBGROUP_TOTAL here.

Similar Messages

  • Grouping and Decimal characters in rtf templates.

    Hi guys and girls,
    I’m really struggling with a problem here regarding the decimal characters for the prices in my output.
    I'm using XML Publisher 5.6.3.
    My goal is to control the grouping and decimal character from my template.
    The numbers in the XML data file can either be 10.000,00 or 10,000.00. The format is handled by the users nls_numeric_characters profile option.
    The output of the template shall be based on the locale and not the data generated by Oracle Reports. For example: Reports to US customers shall show the numbers in the following format 10,000.00. Reports to our European customers shall show the numbers in this format 10.000,00.
    How can I achieve this in my templates? Can it be achieved at all?
    Thank you in advance.
    Kenneth Kristoffersen
    Edited by: Kenneth_ on May 19, 2009 1:30 AM

    Hi,
    Thank you for your reply.
    The problem is that the report is generating the output based on the users profile option nls_numeric_characters.
    I have tried to override the users profile option in the before report trigger without any luck. I can alter selects so the query gets the numbers in the right format but then I would have to go through all queryes and reports which seem a bit wrong? Especially for the standard Oracle reports.
    BR Kenneth

  • Creation of new employee groups and sub groups

    Hi All,
    What all the steps should I follow to create new employee groups and sub groups? and  How many structures should I create for this?
    Its urgent pls.......
    Good replies will be rewarded!!!!
    Regards,
    Sita

    Hi
    You can create the employee groups depending up on your clients requirement, Eg: Permanent, Temporary, Seasonal, Trainee, Advisor etc
    And define the employee subgroups and assign them to the employee groups Like
    Enterprise structure>Definition>Human Resource Management-->Employee Groups & Employee Groups
    Enterprise structure>Assignment>Human Resource Management-->Assign employee subgroup to employee group
    you can create employee subgroups depending up on your requirement like asst manager, manager, GM, MD, VP ETC an assign them to the employee subgroups ok.
    Ensure that certain empployee subgroups may not be assigned to employee group based on requiremen, but create all the employee sub groups which is existing in the organization.
    Regards

  • Change employee group and sub group

    Hi all,
    During the new hire if an employees group and subgroup are enetered wrongly, how shouldl they be corrected. We have scenarios when the emplooyes group and sub group are corrected after a month or so and the users want to correct the same
    How do we do it?

    Goto PA40 reselect the same Hire action for this employee and click execute. In IT0000 screen enter the new EG/ESG.
    and save it. Then Save the IT0001, then fill rest of the infotypes.
    If you have already process the payroll and the new Emp group / Sub group is in different payroll area you wont be able to change it.

  • How can I get the second group and report totals in Matrix report?

    Hi,
    I have created a matrix report with 2 break Groups.
    Iam getting columns totals for the first group, but not for the second group and the report totals.
    How can I get the second group and report totals for each month?
    Thanks.
    Ram.

    Hi Ram,
    If you want a total at any group-level, go to the particular group in the data model, insert a summary column in the group, and select
    Reset At > appropriate Group Name
    For report level summaries, you must create the summary column outside of all groups.
    Navneet.

  • BIWS with Breaks and Sub-Total

    Hi All,
    Created a simple report with Breaks and sub-total and then i exported that report block as BIWS. When I test it in the BIWS Manager, I can able to see the break data with sub-totals. But when i try to connect the same BIWS with Dashboard, am getting only the detail rows and am not getting the sub-total rows.
    Please suggest how to go over this issue.Thanks for your time and support.

    You have any idea now  ‘nbLines’ works? If its returning total row count, then i think we can try some options with it. Basically am trying to get data like below to apply combo box selectors on Year and Country.
    Year
    Country
    Sales
    2013
    India
    100
    2013
    US
    200
    2013
    UK
    100
    2013
    Total
    400
    2014
    India
    100
    2014
    US
    200
    2014
    UK
    100
    2014
    Total
    400
    Total
    Total
    800
    But am getting it as below, if i apply combox box on Year and Countyr, am getting blank value in between list of values.
    Year
    Country
    Sales
    2013
    India
    100
    2013
    US
    200
    2013
    UK
    100
    2014
    India
    100
    2014
    US
    200
    2014
    UK
    100
    2013
    Total
    400
    2014
    Total
    400
    Total
    Total
    800
    Thanks

  • Singapore - Employee Group and Sub groups

    Hi Gurus
    While making employee groups and sub group for SG what factors should one keeep in mind??

    Hi,
    When we are assigning the employee groups to sub groups select 25 singapore country allowed in the table V_T503Z.
    that factor we need to remember.
    Good luck
    Devi

  • This is regarding totals and sub totals in sap-scripts

    Hi to all...............
    1...How to print totals and subtotals in sap-scripts? where we have to code the logic.what sort of logic is needed to print the same?
    regards,
    swaminath.

    Hi
    HI,
    To calculate totals and sub totals in sap scripts you have to use subroutines.
    Say if you have to add the unit price (KOMVD-KBERT) then in the main window whereever tat value is picked write this routine
    /: DEFINE &TOT_PRICE&
    /: PERFORM F_GET_PRICE IN PROGRAM <subroutine prog name> /:USING &KOMVD-KBERT& /:CHANGING &TOT_PRICE& /:ENDPERFORM
    Then write the variable where ever you want it to be printed (mostly it will be in footer window)
    Then create subroutine pool program and you have to write the code.
    FORM F_GET_PRICE tables int_cond structure itcsy
    outt_cond structure itcsy. data : value type kbert.
    statics value1 type kbert.
    Read int_cond table index 1.
    value = int_cond-value.
    value1 = value1 + value.
    Read outt_cond table index 1.
    outt_cond-value = value1.
    Modify outt_cond index 1.
    ENDFORM.
    To know more, have a look at this thread ..
    Re: SAP Script: Display Total calculated  on page 2 in page 1
    <b>Reward if usefull</b>

  • Page break for a group and sub group based on page length

    Hi
    I have a requirement where in I need to develop a report which has the following requirement. I am attaching the sample xml and rtf files for reference:
    1) There are 3 groups in the Data Model. G1, G2 and G3. G1 contains G2 and G2 contains G3. I need to display that data in that order in the rtf template. Pretty straight forward.
    2) The tricky part, however, is that the report needs to have a page break on the following conditions:
        a) When the value of col1 changes which is in G1
        b) On col3 (in G2), but only when there is not enough space on the page to accommodate the values present in G3, ie col5 and col6 alongwith the values in G2. This means when the value of col3, which is present in G2, changes and if there is not enough space to accommodate G2 and G3 on the same page, it should break and start on a new page. The table which should come together is marked in grey color in the RTF template.
    What I have done till now to achieve this?
    I have created a parent table with two rows. In the second row I have made sure that the row doesn't break across pages. This is true for all the subsequent tables in the report. Now, in that second row, I have col1 in a nested table within a repeating group G1. Inside G1 there is a nested table for G2 and within G2 I have another table for the group G3. The row is not breaking across pages for all the tables that have been created.
    I have tried all the permutations and combinations of nested tables, keeping G1, G2 and G3 in the same table but different rows, having G1 in one table and nesting G2 and G3 in another, keeping G2 and G3 in a separate table altogether, Keeping G1, G2 and G3 all of them in the separate table. All of them are apparently not working.
    Is there anyway where we can either get hold of the current position of the cursor and the total number of rows on that page? Or any other solution that is possible? Or if I can have to make changes in the data model?
    Thanks a lot in advance
    Sid

    Hello Sid,
    I have checked your report and XML Sample and you haven't linked the fields from XML Sample to your .rtf report.
    You can use <?for-each?> syntax for your groups to print the content.
    I recommend you to review our "Creating RTF templates" manual:
    http://docs.oracle.com/cd/E28280_01/bi.1111/e22254/create_rtf_tmpl.htm#BIPRD2354
    Regards,
    Liviu

  • Totals and Sub-Totals in ALV GRID

    Could anyone advice, how to display sub-totals and totals in ALV Grid(using FM).
    Ex:           value1    value2
                      100        50
                      200        50
        subtotal   300      100
        total                    400
    Thanks in advance...

    Refer below demo code and see perform Sort_list..
    it wil serve ur purpose.
    REPORT  ZGILL_ALV    message-id rp                           .
    type-pools slis.
    tables: zgill_main,zgill_details.
    data z_fieldcat type slis_t_fieldcat_alv.
    data begin of itab occurs 0.
    DATA ICON TYPE ICON-ID.
         include structure zgill_main.
    data salary like zgill_details-salary.
    data end of itab.
    *data itab1 like table of itab with header line.
    data : WA_SORT TYPE SLIS_SORTINFO_ALV,
           IT_SORT TYPE SLIS_T_SORTINFO_ALV,
           WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV,
           IT_FIELDTAB TYPE SLIS_T_FIELDCAT_ALV,
           WA_LAYOUT TYPE SLIS_LAYOUT_ALV.
    PARAMETERS: p_list  radiobutton group A1,
                P_GRID  RADIOBUTTON GROUP A1.
    SELECT-OPTIONS: S_PERNR FOR ZGILL_MAIN-PERNR.
    start-of-selection.
    perform fill_itab.
    perform sort_list.
    **************Start of scenario without container******************************************
    *********Method 1***********
    perform fill_fieldcat.  " Manuallly Preparing Fiedl Catalog
    *********Method 2***********
    *perform fill_fieldcat1 changing z_fieldcat.   "Preparing field catalog with merge function
    perform display_alv.
    *****************end of scenario without container*****************************************
    *&      Form  fill_itab
          text
    -->  p1        text
    <--  p2        text
    form fill_itab .
    *select * from zgill_main up to 20 rows INTO CORRESPONDING FIELDS OF TABLE itab.
    *ITAB1[] = ITAB[].
    select apernr aname aorg adob b~salary INTO CORRESPONDING FIELDS OF TABLE itab
           from zgill_main as a join zgill_details as b on apernr = bpernr
           WHERE A~PERNR IN S_PERNR.
    LOOP AT ITAB.
    IF ITAB-PERNR < 1111.
    ITAB-ICON = '@08@'.
    ELSEIF ITAB-PERNR > 1111 AND ITAB-PERNR < 11111111.
    ITAB-ICON = '@09@'.
    ELSEIF ITAB-PERNR GE 11111111.
    ITAB-ICON = '@0A@'.
    ENDIF.
    MODIFY ITAB INDEX SY-TABIX.
    ENDLOOP.
    endform.                    " fill_itab
    *&      Form  display_alv
          text
    -->  p1        text
    <--  p2        text
    form display_alv .
    data repid like sy-repid.
    REPID = SY-REPID.
    WA_LAYOUT-ZEBRA = 'X'.
    WA_LAYOUT-WINDOW_TITLEBAR = 'GRID DISPLAY'.
    WA_LAYOUT-SUBTOTALS_TEXT = 'SUBTOTAL'.
    WA_LAYOUT-TOTALS_TEXT = 'TOTAL'.
    IF P_GRID = 'X'.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
       I_CALLBACK_PROGRAM                = repid
       IT_FIELDCAT                       = IT_FIELDTAB
       IT_SORT                           = IT_SORT
       IS_LAYOUT                         = WA_LAYOUT
    TABLES
        t_outtab                          = itab[]
    EXCEPTIONS
       PROGRAM_ERROR                     = 1
       OTHERS                            = 2.
    IF sy-subrc <> 0.
       message e016 with 'Error in Display'.
    ENDIF.
    ELSEIF P_LIST = 'X'.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
       I_CALLBACK_PROGRAM                = repid
       IT_FIELDCAT                       = IT_FIELDTAB
       IT_SORT                           = IT_SORT
       IS_LAYOUT                         = WA_LAYOUT
    TABLES
        t_outtab                          = itab[]
    EXCEPTIONS
       PROGRAM_ERROR                     = 1
       OTHERS                            = 2.
    IF sy-subrc <> 0.
       message e016 with 'Error in Display'.
    ENDIF.
    ENDIF.
    endform.                    " display_alv
    *&      Form  fill_fieldcat1
          text
    -->  p1        text
    <--  p2        text
    form fill_fieldcat1  changing d_fcat type slis_t_fieldcat_alv.
    data repid like sy-repid.
    data d_fcat1 type slis_t_fieldcat_alv with header line.
    REPID = SY-REPID.
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
       I_PROGRAM_NAME               = repid
       I_INTERNAL_TABNAME           = 'ITAB'
       I_STRUCTURE_NAME             = 'ZGILL_MAIN'
      I_CLIENT_NEVER_DISPLAY       = 'X'
      I_INCLNAME                   =
      I_BYPASSING_BUFFER           =
      I_BUFFER_ACTIVE              =
    CHANGING
        ct_fieldcat                  = d_fcat[]
    EXCEPTIONS
       INCONSISTENT_INTERFACE       = 1
       PROGRAM_ERROR                = 2
       OTHERS                       = 3.
    IF sy-subrc <> 0.
       message e016 with 'Error in preparing fiedl catalog'.
    ENDIF.
    loop at d_fcat into d_fcat1.
    case d_fcat1-fieldname.
    when 'NAME'.
    d_fcat1-reptext_ddic = 'Emp Name'.
    MODIFY D_FCAT FROM D_FCAT1.
    WHEN 'PERNR'.
    d_fcat1-reptext_ddic = 'Emp Num'.
    MODIFY D_FCAT FROM D_FCAT1.
    WHEN 'ORG'.
    d_fcat1-reptext_ddic = 'Org Unit'.
    MODIFY D_FCAT FROM D_FCAT1.
    endcase.
    clear d_fcat1.
    endloop.
    endform.                    " fill_fieldcat1
    *&      Form  sort_list
          text
    -->  p1        text
    <--  p2        text
    form sort_list .
    CLEAR WA_SORT.
    WA_SORT-FIELDNAME = 'DOB'.
    WA_SORT-SPOS = '1'.
    WA_SORT-UP = 'X'.
    WA_SORT-SUBTOT = 'X'.
    APPEND WA_SORT TO IT_SORT.
    CLEAR WA_SORT.
    WA_SORT-FIELDNAME = 'NAME'.
    WA_SORT-SPOS = '1'.
    WA_SORT-UP = 'X'.
    APPEND WA_SORT TO IT_SORT.
    CLEAR WA_SORT.
    endform.                    " sort_list
    *&      Form  fill_fieldcat
          text
    -->  p1        text
    <--  p2        text
    form fill_fieldcat .
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'ITAB'.
    WA_FIELDCAT-FIELDNAME = 'ICON'.
    WA_FIELDCAT-SELTEXT_L = 'TRAFFIC'.
    WA_FIELDCAT-ICON = 'X'.
    WA_FIELDCAT-ddictxt = 'l'.
    WA_FIELDCAT-COL_POS = 1.
    WA_FIELDCAT-OUTPUTLEN = 10.
    APPEND WA_FIELDCAT TO IT_FIELDTAB.
    CLEAR WA_FIELDCAT .
    WA_FIELDCAT-TABNAME = 'ITAB'.
    WA_FIELDCAT-FIELDNAME = 'PERNR'.
    WA_FIELDCAT-SELTEXT_L = 'EMP NUMBER'.
    WA_FIELDCAT-ddictxt = 'l'.
    WA_FIELDCAT-COL_POS = 2.
    WA_FIELDCAT-OUTPUTLEN = 10.
    APPEND WA_FIELDCAT TO IT_FIELDTAB.
    CLEAR WA_FIELDCAT .
    when 'maktx'.
    WA_FIELDCAT-TABNAME = 'ITAB'.
    WA_FIELDCAT-FIELDNAME = 'NAME'.
    WA_FIELDCAT-SELTEXT_L = 'EMP NAME'.
    WA_FIELDCAT-ddictxt = 'l'.
    WA_FIELDCAT-COL_POS = 3.
    WA_FIELDCAT-OUTPUTLEN = 15.
    APPEND WA_FIELDCAT TO IT_FIELDTAB.
    CLEAR WA_FIELDCAT .
    WA_FIELDCAT-TABNAME = 'ITAB'.
    WA_FIELDCAT-FIELDNAME = 'ORG'.
    WA_FIELDCAT-SELTEXT_L = 'ORG UNIT'.
    WA_FIELDCAT-COL_POS = 4.
    WA_FIELDCAT-OUTPUTLEN = 10.
    APPEND WA_FIELDCAT TO IT_FIELDTAB.
    CLEAR WA_FIELDCAT .
    WA_FIELDCAT-TABNAME = 'ITAB'.
    WA_FIELDCAT-FIELDNAME = 'DOB'.
    WA_FIELDCAT-SELTEXT_L = 'BIRTH DATE'.
    WA_FIELDCAT-COL_POS = 5.
    WA_FIELDCAT-OUTPUTLEN = 12.
    APPEND WA_FIELDCAT TO IT_FIELDTAB.
    CLEAR WA_FIELDCAT .
    WA_FIELDCAT-TABNAME = 'ITAB'.
    WA_FIELDCAT-FIELDNAME = 'SALARY'.
    WA_FIELDCAT-SELTEXT_L = 'SALARY'.
    WA_FIELDCAT-COL_POS = 6.
    WA_FIELDCAT-OUTPUTLEN = 25.
    WA_FIELDCAT-do_sum = 'X'.
    APPEND WA_FIELDCAT TO IT_FIELDTAB.
    endform.                    " fill_fieldcat

  • Regarding totals  and sub totals text in alv

    Hi all,
    i am displaying Totals and subtotals ......but i want to display the text before the the Totals and Subtotals.
    Please help me in regarding this..
    Thanks in advance,
    S.Gangi reddy.

    hi,
    check this report.
    *& Report  ZGM_ALV_SUBTOTAL_TEXT                                       *
    *& Author :
    *& Date :
    *& Description :
    *& Modification History
    REPORT  ZGM_ALV_SUBTOTAL_TEXT                   .
    *& Table declaration
    TABLES: ekko.
    *& Type pool declaration
    TYPE-POOLS: slis. " Type pool for ALV
    *& Selection screen
    SELECT-OPTIONS: s_ebeln FOR ekko-ebeln.
    *& Type declaration
    Type declaration for internal table to store EKPO data
    TYPES: BEGIN OF x_data,
           ebeln  TYPE char30,  " Document no.
           ebelp  TYPE ebelp,   " Item no
           matnr  TYPE matnr,   " Material no
           matnr1 TYPE matnr,   " Material no
           werks  TYPE werks_d, " Plant
           werks1 TYPE werks_d, " Plant
           ntgew  TYPE entge,   " Net weight
           gewe   TYPE egewe,   " Unit of weight                          
           END OF x_data.
    *& Internal table declaration
    DATA:
      i_ekpo TYPE STANDARD TABLE OF x_data INITIAL SIZE 0,
    Internal table for storing field catalog information
      i_fieldcat TYPE slis_t_fieldcat_alv,
    Internal table for Top of Page info. in ALV Display
      i_alv_top_of_page TYPE slis_t_listheader,
    Internal table for ALV Display events
      i_events TYPE slis_t_event,
    Internal table for storing ALV sort information
      i_sort TYPE  slis_t_sortinfo_alv,
      i_event TYPE slis_t_event.
    *& Work area declaration
    DATA:
      wa_ekko TYPE x_data,
      wa_layout     TYPE slis_layout_alv,
      wa_events         TYPE slis_alv_event,
      wa_sort TYPE slis_sortinfo_alv.
    *& Constant declaration
    CONSTANTS:
       c_header   TYPE char1
                  VALUE 'H',                    "Header in ALV
       c_item     TYPE char1
                  VALUE 'S'.
    *& Start-of-selection event
    START-OF-SELECTION.
    Select data from ekpo
      SELECT ebeln " Doc no
             ebelp " Item
             matnr " Material
             matnr " Material
             werks " Plant
             werks " Plant
             ntgew " Quantity
             gewei " Unit
             FROM ekpo
             INTO TABLE i_ekpo
             WHERE ebeln IN s_ebeln
             AND ntgew NE '0.00'.  IF sy-subrc = 0.
        SORT i_ekpo BY ebeln ebelp matnr .
      ENDIF.
    To build the Page header
      PERFORM sub_build_header. "* To prepare field catalog
      PERFORM sub_field_catalog. "* Perform to populate the layout structure
      PERFORM sub_populate_layout."* Perform to populate the sort table.
      PERFORM sub_populate_sort."* Perform to populate ALV event
      PERFORM sub_get_event.
      END-OF-SELECTION.
    * Perform to display ALV report
      PERFORM sub_alv_report_display.
    *&      Form  sub_build_header
          To build the header
          No Parameter
    FORM sub_build_header .
    Local data declaration
      DATA: l_system     TYPE char10 ,          "System id
            l_r_line     TYPE slis_listheader,  "Hold list header
            l_date       TYPE char10,           "Date
            l_time       TYPE char10,           "Time
            l_success_records TYPE i,           "No of success records
            l_title(300) TYPE c.                " Title
    Title  Display
      l_r_line-typ = c_header.               " header
      l_title = 'Test report'(001).
      l_r_line-info = l_title.
      APPEND l_r_line TO i_alv_top_of_page.
      CLEAR l_r_line.
    * Run date Display
      CLEAR l_date.
      l_r_line-typ  = c_item.                " Item
      WRITE: sy-datum  TO l_date MM/DD/YYYY.
      l_r_line-key = 'Run Date :'(002).
      l_r_line-info = l_date.
      APPEND l_r_line TO i_alv_top_of_page.
      CLEAR: l_r_line,
             l_date.ENDFORM.                    " sub_build_header
    *&      Form  sub_field_catalog
          Build Field Catalog
          No Parameter
    FORM sub_field_catalog .
    Build Field Catalog
      PERFORM sub_fill_alv_field_catalog USING:     '01' '01' 'EBELN'
      'I_EKPO' 'L'
         'Doc No'(003) ' ' ' ' ' ' ' ',     '01' '02' 'EBELP' 'I_EKPO' 'L'
         'Item No'(004) 'X' 'X' ' ' ' ',     '01' '03' 'MATNR' 'I_EKPO' 'L'
         'Material No'(005) 'X' 'X' ' ' ' ',     '01' '03' 'MATNR1' 'I_EKPO'
         'L'
         'Material No'(005) ' ' ' ' ' ' ' ',
         '01' '04' 'WERKS' 'I_EKPO' 'L'
         'Plant'(006) 'X' 'X' ' ' ' ',     '01' '04' 'WERKS1' 'I_EKPO' 'L'
         'Plant'(006) ' ' ' ' ' ' ' ',     '01' '05' 'NTGEW' 'I_EKPO' 'R'
         'Net Weight'(007) ' ' ' ' 'GEWE' 'I_EKPO'.ENDFORM.
    " sub_field_catalog*&----
    *&     Form  sub_fill_alv_field_catalog
    *&     For building Field Catalog
    *&     p_rowpos   Row position
    *&     p_colpos   Col position
    *&     p_fldnam   Fldname
    *&     p_tabnam   Tabname
    *&     p_justif   Justification
    *&     p_seltext  Seltext
    *&     p_out      no out
    *&     p_tech     Technical field
    *&     p_qfield   Quantity field
    *&     p_qtab     Quantity table
    FORM sub_fill_alv_field_catalog  USING  p_rowpos    TYPE sycurow
                                            p_colpos    TYPE sycucol
                                            p_fldnam    TYPE fieldname
                                            p_tabnam    TYPE tabname
                                            p_justif    TYPE char1
                                            p_seltext   TYPE dd03p-scrtext_l
                                            p_out       TYPE char1
                                            p_tech      TYPE char1
                                            p_qfield    TYPE slis_fieldname
                                            p_qtab      TYPE slis_tabname.
                                           Local declaration for field
                                           catalog
      DATA: wa_lfl_fcat    TYPE  slis_fieldcat_alv.
      wa_lfl_fcat-row_pos        =  p_rowpos.     "Row
      wa_lfl_fcat-col_pos        =  p_colpos.     "Column
      wa_lfl_fcat-fieldname      =  p_fldnam.     "Field Name
      wa_lfl_fcat-tabname        =  p_tabnam.     "Internal Table Name
      wa_lfl_fcat-just           =  p_justif.     "Screen Justified
      wa_lfl_fcat-seltext_l      =  p_seltext.    "Field Text
      wa_lfl_fcat-no_out         =  p_out.        "No output
      wa_lfl_fcat-tech           =  p_tech.       "Technical field
      wa_lfl_fcat-qfieldname     =  p_qfield.     "Quantity unit
      wa_lfl_fcat-qtabname       =  p_qtab .
      "Quantity table
      IF p_fldnam = 'NTGEW'.
        wa_lfl_fcat-do_sum  = 'X'.
      ENDIF.
      APPEND wa_lfl_fcat TO i_fieldcat.
      CLEAR wa_lfl_fcat.
    ENDFORM.
    " sub_fill_alv_field_catalog*&----
    *&      Form  sub_populate_layout
          Populate ALV layout
          No Parameter
    FORM sub_populate_layout .  CLEAR wa_layout.
      wa_layout-colwidth_optimize = 'X'.
    " Optimization of Col width
    ENDFORM. " sub_populate_layout*&----
    *&      Form  sub_populate_sort
          Populate ALV sort table
          No Parameter
    FORM sub_populate_sort .
    Sort on material
      wa_sort-spos = '01' .
      wa_sort-fieldname = 'MATNR'.
      wa_sort-tabname = 'I_EKPO'.
      wa_sort-up = 'X'.
      wa_sort-subtot = 'X'.
      APPEND wa_sort TO i_sort .
      CLEAR wa_sort.
    Sort on plant
      wa_sort-spos = '02'.
      wa_sort-fieldname = 'WERKS'.
      wa_sort-tabname = 'I_EKPO'.
      wa_sort-up = 'X'.
      wa_sort-subtot = 'X'.
      APPEND wa_sort TO i_sort .
      CLEAR wa_sort.
    ENDFORM.
    " sub_populate_sort*&----
    *&      Form  sub_get_event
          Get ALV grid event and pass the form name to subtotal_text
          event
          No Parameter
    FORM sub_get_event .
      CONSTANTS : c_formname_subtotal_text TYPE slis_formname VALUE
    'SUBTOTAL_TEXT'.  DATA: l_s_event TYPE slis_alv_event.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 4
        IMPORTING
          et_events       = i_event
        EXCEPTIONS
          list_type_wrong = 0
          OTHERS          = 0.
    Subtotal
      READ TABLE i_event  INTO l_s_event
                        WITH KEY name = slis_ev_subtotal_text.
      IF sy-subrc = 0.
        MOVE c_formname_subtotal_text TO l_s_event-form.
        MODIFY i_event FROM l_s_event INDEX sy-tabix.
      ENDIF.ENDFORM.
    " sub_get_event*&----
    *&      Form  sub_alv_report_display
          For ALV Report Display
          No Parameter
    FORM sub_alv_report_display .
      DATA: l_repid TYPE syrepid .
      l_repid = sy-repid .
    This function module for displaying the ALV
    report
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program       = l_repid
          i_callback_top_of_page   = 'SUB_ALV_TOP_OF_PAGE'
          is_layout                = wa_layout
          it_fieldcat              = i_fieldcat
          it_sort = i_sort
          it_events                = i_event
          i_default                = 'X'
          i_save                   = 'A'
        TABLES
          t_outtab                 = i_ekpo
        EXCEPTIONS
          program_error            = 1
          OTHERS                   = 2.
      IF sy-subrc <> 0.
       MESSAGE i000 WITH 'Error in ALV report display'(055).
      ENDIF.
      ENDFORM.
    " sub_alv_report_display*&----
          FORM sub_alv_top_of_page
          Call ALV top of page
          No parameter
    FORM sub_alv_top_of_page.                                   "#EC CALLED*
    *To write header for the ALV
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = i_alv_top_of_page.
    ENDFORM.
    "alv_top_of_page*&----
    *&      Form  subtotal_text
          Build subtotal text
          P_total  Total
          p_subtot_text Subtotal text info
    FORM subtotal_text CHANGING
                   p_total TYPE any
                   p_subtot_text TYPE slis_subtot_text.
    Material level sub total
      IF p_subtot_text-criteria = 'MATNR'.
        p_subtot_text-display_text_for_subtotal
        = 'Material level total'(009).
      ENDIF.
    Plant level sub total
      IF p_subtot_text-criteria = 'WERKS'.
        p_subtot_text-display_text_for_subtotal = 'Plant level total'(010).
      ENDIF.
    ENDFORM.                    "subtotal_textSelection screen:
    \[removed by moderator\]
    Edited by: Jan Stallkamp on Sep 3, 2008 6:17 PM

  • Creation of GL account under main group and sub a/c group

    my name is swetha,
    my clint is asking for creation of GL account in the following manner
    under   account group a sub account group, and under sub account group a GL account .
    like
    account group  (ex: loans)
          sub account group  (ex: vehical loans)
               GL account       (ex: HDFC bank  GL vehical loans)
    could you please help me to configure  if it is possible,  if not plz suggest me the alternate options.  thanks in advance.

    hi Swetha,
    one thing remember u can create all G/L Accounts as  one Group but these sub groups are define in FSV so you can tell them first we can create on group that is loans but at the time of FSV  u can define number of sub groups because gl master account groups are using for number controlling purpose only.what ever groups u are define in FSV that groups only comes at the time of reports ok.

  • Calculate totals and sub totals

    hi everybody
    can u plz suggest me how to write code for getting sub totals and totals
    regards
    hridhaya

    Hello hridhayanjili
    SAP provides us with the ABAP statement <b>COLLECT</b> to summarize totals.
    I will give you an example from which you should be able to develop you own solution.
    Let's assume we have an itab containing materials. The itab has the following line structure: MANDT, MATNR, QUANTITY. To calculate subtotals we require a second itab that is identical to the first one.
    Now here is the coding:
    data:
      gt_itab          TYPE STANDARD TABLE OF <structure>,
      gt_itab_collect  TYPE STANDARD TABLE OF <structure>,
      gt_itab_total    TYPE STANDARD TABLE OF <structure>.
      gs_entry         TYPE <structure>.
    * NOTE: <structure> stands for a named DDIC structure or
    * a type definition, not a field symbol.
    * gt_itab contains our materials
      LOOP AT gt_itab INTO gs_entry.
        COLLECT gs_entry INTO gt_itab_collect.
      ENDLOOP.
    * NOTE: Assuming we had 10 entries in gt_itab of
    * 3 different materials we end up with 3 entries in
    * gt_itab_collect that contain the quantities summarized.
    * To calculate the total one could LOOP over
    * gt_itab_collect and summarize the values. Another way
    * is shown here:
      CLEAR: gs_entry-matnr.
      MODIFY gt_itab FROM gs_entry
        TRANSPORTING matnr
        WHERE ( matnr IS NOT INITIAL ).
    * We clear the material no.
      LOOP AT gt_itab INTO gs_entry.
        COLLECT gs_entry INTO gt_itab_total.
      ENDLOOP. 
    * NOTE: because we have the same value for CLIENT and
    * MATNR in every line we will end up with a single line
    * in gt_itab_total.
    Please read the documentation of the COLLECT statement carefully because the structure of your itab (i.e. the order of the fields, especially those that will be summarized) is important.
    Regards
       Uwe

  • Defining / Assigning Employee Groups and Sub Groups.

    I have defined a Personnel Area for e.g Barron Hotels - London  BH01 and Barron Hotels - Manchester - BH02.  I have also defined  there respective Personnel Subareas.
    What exact steps much I take to define the Employee Group and Employee Sub Groups and how do I link (Assign) them to corresponding  the Personnel Area  and Personnel subareas  defined above.
    Can some one please show me the exact steps. I have heard SM30  and V_503_ALL  mentioned but how  exactly are these used.
    Many thanks.

    Hi Tomuri,
    There is no link between EG-ESGs and Personnel Area -Subareas..  All these form an Enterprise Structure for an organisation and it can be seen against an employee in IT0001 - Org Assignment.
    Well, you have created PA as well as PSAs.  Now what you do is, similarly create EG- ESGs.. say for example..
    Emplyee Groups as A- Associate, B- Managers... etc...
    Employee Subgropus as A1, A2,..  B1, B2.. etc...
    Path: IMG-> Enterprise structure->Definition->Human Resources Management-> Employee Groups and
    -> Employee Subgroups
    When you create Personnel Areas.. you need to assign them to a Company Code...
    Path: IMG-> Enterprise structure->Assignment->Human Resources Management-> Assign Personnel Area to Company Code
    Similarly, when you create Employee Subgroups, you assign it to Employee Groups (EGs)
    Path: IMG-> Enterprise structure->Assignment->Human Resources Management
    -> Assign employee subgroup to employee group
    Next is the table you mentioned in your query... V_503_ALL... this clubs the groupings for -> ES grouping for collective agreement provision, Employee subgroup grouping for primary wage types, time quota types, work schedule etc,,, these are according to company requirements..
    For any further queires, do reply...
    I hope the information proveded helps you...
    Award points if the query was resolved...
    Good luck..
    Regards,
    Shweta

  • Alv sub total problem

    hi,
    in alv i want sub total text for purchase order.
    can you check my code . i am not getting.
    TYPE-POOLS: slis.
    TABLES: ekko,ekpo,eket.
    TYPES: BEGIN OF ty_ekko,
            lifnr TYPE elifn,
            ebeln TYPE ebeln,
            ebeln1 TYPE ebeln,
            bsart TYPE esart,
            ekorg TYPE ekorg,
            ekgrp TYPE bkgrp,
            ernam TYPE ernam,
           END OF ty_ekko,
           BEGIN OF ty_ekpo,
            ebeln TYPE ebeln,
            matnr TYPE matnr,
            ebelp TYPE ebelp,
            ebelp1 TYPE ebelp,
            menge TYPE bstmg,
            meins TYPE bstme,
            netpr TYPE bprei,
            werks TYPE ewerk,
           END OF ty_ekpo,
           BEGIN OF ty_eket,
            ebeln TYPE ebeln,
            ebelp TYPE ebelp,
            etenr TYPE eeten,
            eindt TYPE eindt,
           END OF ty_eket,
           BEGIN OF ty_final,
            slno TYPE sy-dbcnt,
            lifnr TYPE elifn,
            ebeln TYPE ebeln,
            ebeln1 TYPE ebeln,
            bsart TYPE esart,
            ekorg TYPE ekorg,
            ekgrp TYPE bkgrp,
            ernam TYPE ernam,
            matnr TYPE matnr,
            ebelp TYPE ebelp,
            ebelp1 TYPE ebelp,
            menge TYPE bstmg,
            meins TYPE bstme,
            netpr TYPE bprei,
            werks TYPE ewerk,
            eindt TYPE eindt,
           END OF ty_final.
    DATA: it_ekko TYPE STANDARD TABLE OF ty_ekko,
          it_ekpo TYPE STANDARD  TABLE OF ty_ekpo,
          it_eket TYPE STANDARD  TABLE OF ty_eket,
          it_final TYPE STANDARD TABLE OF ty_final,
          it_fieldcat TYPE slis_t_fieldcat_alv,
          it_alv_top_of_page TYPE slis_t_listheader,
          it_sort TYPE  slis_t_sortinfo_alv,
          it_event TYPE slis_t_event,
          l_repid TYPE syrepid,
          slno TYPE i VALUE 1.
    DATA: wa_ekko TYPE ty_ekko,
          wa_ekpo TYPE ty_ekpo,
          wa_eket TYPE ty_eket,
          wa_final TYPE ty_final,
          wa_fieldcat TYPE slis_fieldcat_alv,
          wa_alv_top_of_page TYPE slis_listheader,
          wa_sort TYPE  slis_sortinfo_alv,
          wa_layout   TYPE slis_layout_alv.
         wa_event TYPE slis_alv_event.
    CONSTANTS:
       c_header   TYPE char1
                  VALUE 'H',                    "Header in ALV
       c_item     TYPE char1
                  VALUE 'S'.
    SELECTION-SCREEN BEGIN OF BLOCK blk WITH FRAME TITLE text-001.
    SELECT-OPTIONS: s_aedat FOR ekko-aedat.
    SELECTION-SCREEN END OF BLOCK blk.
    START-OF-SELECTION.
    PERFORM validation.
      PERFORM retrive_data.
      PERFORM sub_build_header.
      PERFORM sub_field_catalog.
      PERFORM sub_populate_layout.
      PERFORM sub_populate_sort.
      PERFORM sub_get_event.
    *END-OF-SELECTION.
    Perform to display ALV report
      PERFORM sub_alv_report_display.
    *FORM validation .
    SELECT SINGLE * FROM ekko WHERE aedat IN s_aedat .
    IF sy-subrc <> 0.
       MESSAGE e001(zram).
    ENDIF.
    *ENDFORM.                    " validation
    FORM retrive_data .
      SELECT lifnr
             ebeln
             ebeln
             bsart
             ekorg
             ekgrp
             ernam FROM ekko INTO TABLE it_ekko
            INTO CORRESPONDING FIELDS OF TABLE it_ekko
             WHERE aedat IN s_aedat .
      IF it_ekko[] IS NOT INITIAL.
        SELECT ebeln
               ebelp
               ebelp
               matnr
               menge
               meins
               netpr
               werks FROM ekpo
               INTO corresponding fields of  TABLE it_ekpo
               FOR ALL ENTRIES IN it_ekko
               WHERE ebeln = it_ekko-ebeln .
          if sy-subrc = 0.
             SELECT ebeln
               ebelp
               etenr
               eindt
               FROM eket INTO  TABLE it_eket
               FOR ALL ENTRIES IN it_ekpo
               WHERE ebeln = it_ekpo-ebeln .
            endif.
      ENDIF.
    ENDIF.
      LOOP AT it_ekko INTO wa_ekko.
        READ TABLE it_ekpo INTO wa_ekpo
                              WITH KEY ebeln = wa_ekko-ebeln.
        READ TABLE it_eket INTO wa_eket
                                WITH KEY ebeln = wa_ekpo-ebeln.
        wa_final-slno  =  slno.
        wa_final-lifnr = wa_ekko-lifnr.
        wa_final-ebeln = wa_ekko-ebeln.
        wa_final-bsart = wa_ekko-bsart.
        wa_final-ekgrp = wa_ekko-ekgrp.
        wa_final-ekorg = wa_ekko-ekorg.
        wa_final-ernam = wa_ekko-ernam.
        wa_final-ebelp = wa_ekpo-ebelp.
        wa_final-matnr = wa_ekpo-matnr.
        wa_final-menge = wa_ekpo-menge.
        wa_final-meins = wa_ekpo-meins.
        wa_final-netpr = wa_ekpo-netpr.
        wa_final-werks = wa_ekpo-werks.
        wa_final-eindt = wa_eket-eindt.
        slno = slno + 1.
        APPEND wa_final TO it_final.
      ENDLOOP.
    ENDFORM.                    " retrive_data
    FORM sub_build_header .
    Local data declaration
      DATA: l_system     TYPE char10 ,          "System id
            l_r_line     TYPE slis_listheader,  "Hold list header
            l_date       TYPE char10,           "Date
            l_time       TYPE char10,           "Time
            l_success_records TYPE i,           "No of success records
            l_title(300) TYPE c.                " Title
    Title  Display
      l_r_line-typ = c_header.               " header
      l_title = 'Test report'(001).
      l_r_line-info = l_title.
      APPEND l_r_line TO it_alv_top_of_page.
      CLEAR l_r_line.
    Run date Display
      CLEAR l_date.
      l_r_line-typ  = c_item.                " Item
      WRITE: sy-datum  TO l_date MM/DD/YYYY.
      l_r_line-key = 'Run Date :'(002).
      l_r_line-info = l_date.
      APPEND l_r_line TO it_alv_top_of_page.
      CLEAR: l_r_line,
             l_date.
    ENDFORM.                    " sub_build_header
    FORM sub_field_catalog .
      REFRESH it_fieldcat.
      wa_fieldcat-row_pos        = '01'.  "  p_rowpos.     "Row
      wa_fieldcat-col_pos        = '01'.       "p_colpos.     "Column
      wa_fieldcat-fieldname      = 'SLNO'.       "p_fldnam.     "Field Name
      wa_fieldcat-tabname        = 'IT_FINAL'.      "p_tabnam.     "Internal Table Name
      wa_fieldcat-just           = ' '.       "p_justif.     "Screen Justified
      wa_fieldcat-seltext_l      = 'SLNo'.       "p_seltext.    "Field Text
      wa_fieldcat-do_sum         = ' '.
      wa_fieldcat-outputlen      = '4'    .
      wa_fieldcat-no_out         = ' '.       "p_out.        "No output
      wa_fieldcat-tech           = ' '.      "p_tech.       "Technical field
      wa_fieldcat-qfieldname     = ' '.       "p_qfield.     "Quantity unit
      wa_fieldcat-qtabname       = ' '.       "p_qtab .      "Quantity table
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-row_pos        = '01'.  "  p_rowpos.     "Row
      wa_fieldcat-col_pos        = '02'.       "p_colpos.     "Column
      wa_fieldcat-fieldname      = 'LIFNR'.       "p_fldnam.     "Field Name
      wa_fieldcat-tabname        = 'IT_FINAL'.      "p_tabnam.     "Internal Table Name
      wa_fieldcat-just           = ' '.       "p_justif.     "Screen Justified
      wa_fieldcat-seltext_l      = 'Supplier Name'.       "p_seltext.    "Field Text
      wa_fieldcat-do_sum         = ' '.
      wa_fieldcat-outputlen      = '12'    .
      wa_fieldcat-no_out         = ' '.       "p_out.        "No output
      wa_fieldcat-tech           = ' '.      "p_tech.       "Technical field
      wa_fieldcat-qfieldname     = ' '.       "p_qfield.     "Quantity unit
      wa_fieldcat-qtabname       = ' '.       "p_qtab .      "Quantity table
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-row_pos        = '01'.  "  p_rowpos.     "Row
      wa_fieldcat-col_pos        = '03'.       "p_colpos.     "Column
      wa_fieldcat-fieldname      = 'EBELN'.       "p_fldnam.     "Field Name
      wa_fieldcat-tabname        = 'IT_FINAL'.      "p_tabnam.     "Internal Table Name
      wa_fieldcat-just           = ' '.       "p_justif.     "Screen Justified
      wa_fieldcat-seltext_l      = 'PO No'.       "p_seltext.    "Field Text
      wa_fieldcat-do_sum         = ' '.
      wa_fieldcat-outputlen      = '15'    .
      wa_fieldcat-no_out         = ' '.       "p_out.        "No output
      wa_fieldcat-tech           = ' '.      "p_tech.       "Technical field
      wa_fieldcat-qfieldname     = ' '.       "p_qfield.     "Quantity unit
      wa_fieldcat-qtabname       = ' '.       "p_qtab .      "Quantity table
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR wa_fieldcat.
      wa_fieldcat-row_pos        = '01'.  "  p_rowpos.     "Row
      wa_fieldcat-col_pos        = '03'.       "p_colpos.     "Column
      wa_fieldcat-fieldname      = 'EBELN1'.       "p_fldnam.     "Field Name
      wa_fieldcat-tabname        = 'IT_FINAL'.      "p_tabnam.     "Internal Table Name
      wa_fieldcat-just           = ' '.       "p_justif.     "Screen Justified
      wa_fieldcat-seltext_l      = 'PO No'.       "p_seltext.    "Field Text
      wa_fieldcat-do_sum         = ' '.
      wa_fieldcat-no_out         = ' '.       "p_out.        "No output
      wa_fieldcat-tech           = 'X'.      "p_tech.       "Technical field
      wa_fieldcat-qfieldname     = ' '.       "p_qfield.     "Quantity unit
      wa_fieldcat-qtabname       = ' '.       "p_qtab .      "Quantity table
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR wa_fieldcat.
    ENDFORM.                    " sub_field_catalog
    FORM sub_populate_layout .
      CLEAR wa_layout.
      wa_layout-colwidth_optimize = 'X'." Optimization of Col width
    ENDFORM.                    " sub_populate_layout
    FORM sub_populate_sort .
    Sort on material
      wa_sort-spos      = '01' .
      wa_sort-fieldname = 'EBELN'.
      wa_sort-tabname   = 'IT_FINAL'.
      wa_sort-up        = 'X'.
      wa_sort-subtot    = 'X'.
      APPEND wa_sort TO it_sort.
      CLEAR wa_sort.
    Sort on plant
      wa_sort-spos      = '02'.
      wa_sort-fieldname = 'EBELP'.
      wa_sort-tabname   = 'IT_FINAL'.
      wa_sort-up        = 'X'.
      wa_sort-subtot    = 'X'.
      APPEND wa_sort TO it_sort.
      CLEAR wa_sort.
    ENDFORM.                    " sub_populate_sort
    FORM sub_get_event .
      CONSTANTS : c_formname_subtotal_text TYPE slis_formname VALUE
                                                      'SUBTOTAL_TEXT'.
      data : wa_event TYPE slis_alv_event.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 4
        IMPORTING
          et_events       = it_event
        EXCEPTIONS
          list_type_wrong = 1
          OTHERS          = 2.
      IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    Subtotal
      READ TABLE it_event  INTO wa_event
                        WITH KEY name = slis_ev_subtotal_text.
      IF sy-subrc = 0.
        MOVE c_formname_subtotal_text TO wa_event-form.
        MODIFY it_event FROM wa_event  INDEX sy-tabix.
      ENDIF.
    ENDFORM.                    " sub_get_event
    FORM sub_alv_report_display .
      l_repid = sy-repid .
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
         i_callback_program                = l_repid
      I_CALLBACK_PF_STATUS_SET          = ' '
      I_CALLBACK_USER_COMMAND           = ' '
         i_callback_top_of_page            = 'SUB_ALV_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_sort
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      i_default                         = 'X'
      i_save                            = 'A'
      IS_VARIANT                        =
      IT_EVENTS                         = i_event
      IT_EVENT_EXIT                     =
      IS_PRINT                          =
      IS_REPREP_ID                      =
      I_SCREEN_START_COLUMN             = 0
      I_SCREEN_START_LINE               = 0
      I_SCREEN_END_COLUMN               = 0
      I_SCREEN_END_LINE                 = 0
      I_HTML_HEIGHT_TOP                 = 0
      I_HTML_HEIGHT_END                 = 0
      IT_ALV_GRAPHICS                   =
      IT_HYPERLINK                      =
      IT_ADD_FIELDCAT                   =
      IT_EXCEPT_QINFO                   =
      IR_SALV_FULLSCREEN_ADAPTER        =
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
        TABLES
          t_outtab                          = it_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.                    " sub_alv_report_display
    FORM sub_alv_top_of_page.                                   "#EC CALLED
    To write header for the ALV
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = it_alv_top_of_page.
    ENDFORM.                    "alv_top_of_page
    FORM subtotal_text CHANGING
                   p_total TYPE any
                   p_subtot_text TYPE slis_subtot_text.
    Material level sub total
      IF p_subtot_text-criteria = 'EBELN'.
        p_subtot_text-display_text_for_subtotal
        = 'The Nett price of PO No'(009).
      ENDIF.
    Plant level sub total
      IF p_subtot_text-criteria = 'EBELP'.
        p_subtot_text-display_text_for_subtotal = 'Total Purchase Order value placed'(010).
      ENDIF.
    ENDFORM.                    "subtotal_text

    hi ,
    try the given below code ...
    "*************INTERNAL TABLE FR SORTING***********************
    DATA: it_sort TYPE slis_t_sortinfo_alv.
    "******** WORK AREA FR FIELD CATALOG *************************
    DATA: wa_sort TYPE slis_sortinfo_alv.
       wa_sort-fieldname = 'EBELN'."field name
      wa_sort-tabname = 'IT_TAB'."internal table name
      wa_sort-up = 'X'.
      wa_sort-subtot ='X'.
      APPEND wa_sort TO it_sort.
      CLEAR wa_sort.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    it_sort                           = it_sort
    ENDFORM.                    "alv
    hope this helps
    Regards
    RItesh J

Maybe you are looking for

  • Official way to transfer video from iPhone 3GS to PC??

    Okay I've read multiple threads online about this and everyone provides 3rd-party application solutions where the applications cost $20 or more. I would imagine there is a simple solution to this problem considering there MUST be some integrated abil

  • How to descrbe a ref cursor from a PL/SQL prog?

    Hi, here is a sample of the my problem let suppose a table country : create table country(country_code VARCHAR2(3), country_name VARCHAR2(50)); then a package containing different procedures among them, this one : PL/SQL prog create or replace packag

  • Lightroom on both a PC and Mac

    I'm looking to buy Lightroom, however currently I am using a Windows laptop (Windows 7) but will be looking to move to a Mac in a few months. If i bought Lightroom for my windows machine, could I then later move the license over and use it on the Mac

  • Connect multiple headsets (BT) at once?

    I'm not talking pairing, I already have multiple bt devices paired. I'm actually trying to connect to two bt headsets at once ie: stream music from ipod on iphone 4 to two separate headsets. Possible? willing to jb if necessary. PS, if I go into sett

  • My Macbook pro keeps freezing (os Lion & latest update)

    firstly  I will say  the biggest mistake I ever made was to change my OS from snow leopard a year ago to lion . Now using lion slowed my system drastically  and there was the ocassionally freezing that I learnt to live with but now it has Just gotten