Using SORT function in mapping

Hi,
I am having trouble getting my head around using the SORT function.
My interface is IDOC to File, The IDOC has a repeating segment (PAYLOAD) that can be of 3 types, either type A, B or C (this is set using a "TYPE" field).
In my file structure I have a repeating "ROW" element which has all of the fields for each row.
I want to group all the Type A data together, the Type B together and the Type C.
I have tried the following mapping on the "ROW" element but it doesn't seem to work:
"TYPE"--"sort"Split By Value (Value Change)--collapseContext--"ROW"
for each of the mappings under ROW I just have fields copied directly.
I think I am doing something wrong.
Thanks.

Hi,
   You could make this mapping
     TYPE --- +----------------+     +----------------+
           |                |     |                |
           | Concat         | --- | mySortFunction | --- NAME
           |                |     |                |
     NAME --- +----------------+     +----------------+
     TYPE --- +----------------+     +----------------+
           |                |     |                |
           | Concat         | --- | mySortFunction | --- ADDR
           |                |     |                |
     ADDR --- +----------------+     +----------------+
   Where source code of mySortFunction is like this:
public void mySortFunction(String[] inputValues,ResultList result,Container container){
     for(int i=0;i<inputValues.length;i++)
          if(inputValues<i>.substring(0,1).equals("A"))
               result.addValue(inputValues<i>.substring(1, inputValues<i>.length-1);               
     for(int i=0;i<inputValues.length;i++)
          if(inputValues<i>.substring(0,1).equals("B"))
               result.addValue(inputValues<i>.substring(1, inputValues<i>.length-1);
     for(int i=0;i<inputValues.length;i++)
          if(inputValues<i>.substring(0,1).equals("C"))
               result.addValue(inputValues<i>.substring(1, inputValues<i>.length-1);
   It is very simple. You concat TYPE whit your data, and then you sort all queue, so you have a new sort queue data. You must only then put out data.

Similar Messages

  • Using concat Function in Mapping

    Hello,
    I have a mapping where I'm using the standart concat function to concatenate the content of two queues. Every queue has normally only one entry. When both queues have one entry, it is working without any issues.
    But now my problem: First queue has one entry and second queue has only a supresser. When I want to concatenate both queues, the result is also a supresser. But I'd like to have that the result will be the entry of the first queue when second queue exists of supresser...
    How can I get this realized that the concat function is also working in this case? 
    Is there maybe a workaround?
    Thank you for your help.

    Hi Lukas
    You can add the node function MapwithDefault with default value space after the field which is having suppress value.
    Then add the output of MapwithDefault to the second input of concat function.
    This will generate the output as the value of first field.
    let me know if you have any doubts.

  • DateTrans Function in Mapping

    Hi,
    Am using DateTrans Function in Mapping to convert YYYYMMDD(20100101) to MM/DD/YYYY(01/01/2010).
    In the DateTrans Function Properties, i hv given input date format as (YYMMDD)(no seperator).
    Output date format as (MM/DD/YYYY).
    But, its giving me message as ,
    Runtime exception when processing target-field mapping /ns1:MT_************/DT_Record/gbdat; root message: Unparseable date: "20100101"
    Any idea.....wat might be the issue......

    santosh koraddi wrote:>
    > Hi,
    >
    > Am using DateTrans Function in Mapping to convert YYYYMMDD(20100101) to MM/DD/YYYY(01/01/2010).
    >
    > In the DateTrans Function Properties, i hv given input date format as (YYMMDD)(no seperator).
    > Output date format as (MM/DD/YYYY).
    >
    >
    > But, its giving me message as ,
    >
    > Runtime exception when processing target-field mapping /ns1:MT_************/DT_Record/gbdat; root message: Unparseable date: "20100101"
    Santosh,
    In the input format give date as "yyyyMMdd"
    click on the help icon (little question mark) and remove the date separator "/" and replace with blank.
    In the output format give MM/dd/YYYY and make sure to double check the separator which by default is "/"
    Regards,

  • Error in XSLT mapping while using string functions

    Hi All,
    While using tokenize() and substring-before() functions in XSLT mapping,we are getting an error.The error message is Unexpected symbol "" So while using string functions in XSLT mapping do we have to use any header functions.
    Please through light on syntax etc.,of string functions in XSLT.
    Thanx in advance,
    Lokesh Dhulipudi
    Edited by: LOKESH DHULIPUDI on Dec 27, 2007 7:32 AM

    Hi,
    Hope you have gone thru this help:
    http://w3schools.com/xsl/default.asp
    Rgds, Moorthy

  • How to use node functions in Message mapping !!

    Hi  Gurus,
    I have got one issue in message mapping, please can any one put some ideas on this !!
    Source Structure
    <Group_ZA>  0..unbound
         <D02_ZA>           0.. unbound
             ZA_01             0..1   - QA
             ZA_02             0..1      20
             ZA_03             0..1
             ZA_04             0..1
         </D02_ZA>
         <D02_ZA>          
             ZA_01             0..1     QD
             ZA_02             0..1     40
             ZA_03             0..1
             ZA_04             0..1
         </D02_ZA>
         <D02_ZA>          
             ZA_01             0..1    QN
             ZA_02             0..1     12
             ZA_03             0..1
             ZA_04             0..1
         </D02_ZA>
         <D02_ZA>          
             ZA_01             0..1    QP
             ZA_02             0..1    60
             ZA_03             0..1
             ZA_04             0..1
         </D02_ZA>
          iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
         <D02_ZA>          
             ZA_01             0..1     QA
             ZA_02             0..1      20
             ZA_03             0..1
             ZA_04             0..1
         </D02_ZA>
         <D02_ZA>          
             ZA_01             0..1     QD
             ZA_02             0..1     40
             ZA_03             0..1
             ZA_04             0..1
         </D02_ZA>
         <D02_ZA>          
             ZA_01             0..1    QN
             ZA_02             0..1     12
             ZA_03             0..1
             ZA_04             0..1
         </D02_ZA>
         <D02_ZA>          
             ZA_01             0..1    QP
             ZA_02             0..1    60
             ZA_03             0..1
             ZA_04             0..1
         </D02_ZA>
    iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
    <D02_ZA>          
             ZA_01             0..1    QN
             ZA_02             0..1     12
             ZA_03             0..1
             ZA_04             0..1
         </D02_ZA>
         <D02_ZA>          
             ZA_01             0..1    QP
             ZA_02             0..1    60
             ZA_03             0..1
             ZA_04             0..1
         </D02_ZA>
    iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
    <D02_ZA>          
             ZA_01             0..1     QA
             ZA_02             0..1      20
             ZA_03             0..1
             ZA_04             0..1
         </D02_ZA>
         <D02_ZA>          
             ZA_01             0..1     QD
             ZA_02             0..1     40
             ZA_03             0..1
             ZA_04             0..1
         </D02_ZA>
         <D02_ZA>          
             ZA_01             0..1    QN
             ZA_02             0..1     12
             ZA_03             0..1
             ZA_04             0..1
         </D02_ZA>
         <D02_ZA>          
             ZA_01             0..1    QP
             ZA_02             0..1    60
             ZA_03             0..1
             ZA_04             0..1
         </D02_ZA>
    </Group_ZA>
    Target Structure
    ProductActivityNotification                                                       0..unbound
                          ProductActivity                                                             1..1
                                        Item                                                                 1..unbound
                                              Inventory                                                   0..1
                                                     UnrestrictedUseQuantity                    0..1
    The Group_ZA comes 'n' number of times and D02_ZA comes sometimes 5 times and sometimes 6 times etc.,
    ZA_01 field can come with 5 to 6 different values like 'QA','QD','QN' etc., sometimes ZA_01 comes only 3 times QA,QD,QN.
    if ZA_01 = 'QA' then only  we need to pass   ZA_02 value on to ''UnrestictedUseQuantity'' (target side),
    I mapped the fields, the vlaue ZA_02  passing properly on to 'UnrestictedUseQuantity' when D02_ZA comes 5 or 6 times, all the times 'QA'  value comes into ZA_01 field. In case if QA value missed or doesn't come from source, the Target side ' 'UnrestictedUseQuantity' field last value comes into last but one.
    Ex: QA value is in 3 times, but I have 4 source message on top. values comes into target side like
    20
    20
    20
    suppose to come like
    20
    20
    -- (Space)
    20
    Please required your valuable inputs in bit urget !!
    how to map field level please?
    Many Thanks in Advance
    Kind Regards
    San

    Petre:
    If you want to use standard functions then you try this:
    If-->currentdate -OR- Constant(01.02)
    currentdate -OR- Constant(02.02)   --> OR -->
    currentdate -OR- Constant(03.02)
    Then give some output
    Else give some output
    So give the output for the first two conditions to another OR and the result of the third to the same OR. So whenever the condition is true in any of the condition you will get the THEN value else you will get the ELSE value.
    ---Satish

  • How to use analytical functions inside a mapping

    Hello everybody. Here Isend you a trick that we are using for two years.
    If you want to use a function (for instance :ROW_NUMBER() OVER (PARTITION BY ... ORDER BY ...)) inside a mapping you must create an expression with in the INGRP1 the fields you are going to use in the window function and in the OUTGRP1 the function you want. Create an Out -attribute with the expressión and link it to a distinct operator (using a "distinct" you encapsulte the sql and you will be able to use the function inside a filter - in the where clause.). The distinct can eliminate some register (depends on the function). If you validate the expression an error will appear (don't worry about that, the mapping will be ok).
    But there is a limitation, you will not be able tou sum over, min over, max over (it detect that they are aggregator functions). Other limitation: the debugger doesn't run with this kind of functions.
    Please publish this information on "The Warehouse Builder Utility Exchange". Mi email is [email protected] (if you need more information)

    It is possible to add SUM, MIN, MAX functions also to OWB releases prior to Paris - You have to put them in double quotes - write "MIN" "MAX" "SUM" etc. The rest of the rules (adding cut-off operator after the expression - as DISTINCT, or UNION ALL) is analogical to with ROW_NUMBER()
    That means You can create mapping with following functionality:
    SELECT
    sum (salary) over (partition by DEPARTMENT) department_salary,
    salary,
    employee_id,
    employee_name
    FROM employees_salaries
    writing it this way in OWB:
    SELECT
    "SUM" (salary) over (partition by DEPARTMENT) department_salary,
    salary,
    employee_id,
    employee_name
    FROM employees_salaries
    Regards,
    Martin

  • IDOC to FILE(xml) graphical mapping using node function createIf

    Greetings All,
                My Scenario is Idoc to File(XML)
    Target Structure is 
                           MO_MAT_LAN....................(0: unbound)
                                LAN_KEY.......................(0 :1)
                                DESCRIPTION.................(0 : 1)
    Source MATMAS Idoc
                           E1MAKTM.........................(0 : 99)
                                SPRAS_ISO..................(0 :1) 
                                MAKTX..........................(0 :1)
    initially i had mapped E1MAKTM----->MO_MAT_LAN but i dont want target node MO_MAT_LAN to be created when the SPRAS_ISO is equal to EN
    I have tried using node function createIf but the node is geting created only once although the input stucture is having occurance more than 5.
    Can anyone please help me to achive this.
    Many thanks,
    Rohit

    U have to use:-
    SPRAS_ISO mak the context to E1MAKTM compare (Use equals) it with Constant function EN out put to be given to If without else and in then Give E1MAKTM and map out put of If node to MO_MAT_LAN.
    chirag

  • Sort function in web report using servlet

    Dear all
    Please help me this out. I'm doing an online report using servlet. When the report is displayed as a table on the web, is there a way to have a sort function-when you click on the tabs, it will sort the data accordingly.
    If I didn't state my question clearly, please let me know.
    Thank you all for your kind help!
    Grace

    You could probably do that using Javascript, but it's beyond my competence to even suggest how. Alternatively you could make the tabs behave as buttons that send a "sort me" request to the server, which would send out new, resorted, HTML.

  • How to use or function in Message Mapping?

    Hi! I was wondering if anyone can show me how to use the or function.
    Im trying to match the current date to three possible values so i need three or functions.
    EG. if ( currentDate == 01.02  || currentDate = 02.02  || currentDate = 03.02 ) {
              do something;

    Petre:
    If you want to use standard functions then you try this:
    If-->currentdate -OR- Constant(01.02)
    currentdate -OR- Constant(02.02)   --> OR -->
    currentdate -OR- Constant(03.02)
    Then give some output
    Else give some output
    So give the output for the first two conditions to another OR and the result of the third to the same OR. So whenever the condition is true in any of the condition you will get the THEN value else you will get the ELSE value.
    ---Satish

  • Getting UNCAUGHT_EXCEPTION CX_WD_CONTEXT at using alv sort function

    Dear colleagues,
    I developed a simple application which displays records in an ALV and at lead-selection shows detailed data in a form. Everthing is working fine except one is clicking on the sort functionality at the top of the ALV short dump is thrown.
    In trx ST22 I find :
    The lead selection has not been set. V_DEFAULT
    "UNCAUGHT_EXCEPTION" "CX_WD_CONTEXT"
    "CL_WDR_CONTEXT_NODE===========CP" or "CL_WDR_CONTEXT_NODE===========CM00R"
    "_RAISE_ELEMENT_NOT_FOUND"
    Lead selection is checked and also debugging the code did not bring me any further.
    Any help is greatly appreciated.
    Thanks in advance
    Michael

    Hi Regina,
    first of all thanks for your quick answer and explanation. I'm not sure what you mean with 'register to the standard functions of the ALV' because this is a functionality which works in other ALVs without register any event method to them or do you mean that in my case I have to react to the sorting in a new method in the view controller? Concerning 'refill the subnode via supply function' I'm doing this already.
    Disabling the sorting is no option anymore because the users already know and love this feature
    Regards
    Michael

  • Sort functionality using MULTIPLE columns in a table control

    Hi all,
    I have a custom screen with table control.Now i need to provide SORT functinality in this screen for the columns in the table control.
    My questins:
    1.Is it possible to seelct MULTIPLE columns in a table control for SORTING?If yes,what explicit settings do i need to do while creatng the TABEL CONTROL in the screen?DO I need to select "Column selection " as MULTIPLE??
    2.How do I write the code for SORT functinonality for multiple columns?
    I know how to write the code for SORTING on basis of single column .
    Thanks!

    Hi Rob,
    Thanks for the reply.
    However I was thinking to apply the same logic as for single columns as follows:
    types : begin of ty_fields,
                c_fieldname(20),
               end of ty_fields.
    data  : t_fields type table of ty_fields,
               wa_fields like line of t_fields.
    WHEN 'SORTUP'.(Ascending)
          loop at TABLE tc01-cols INTO wa_tc01  where  selected = 'X'.
          SPLIT wa_tc01-screen-name AT '-' INTO g_help g_fieldname.
          wa_fields-c_fieldname = g_fieldname.
          append wa_fields to t_fields.
          endloop.
          describe table t_fields lines l_index.
          c_count = 1.
          if c_count  <= l_index.
          read table t_fields into wa_fields index c_count.
          case c_count.
          when '1'.
          l_field1 = wa_fields-c_fieldname.
          when '2'.
         l_field2 = wa_fields-c_fieldname.
        and so on depending on the no of columns in the table control...
          endcase.
          endif.
          SORT t_tvbdpl_scr BY  l_fields1 l_fields 2......l_fieldn.
    Let me know if the above method will work!Also for the above method to work will the type of fields(columns on whihc sort function will be applied) matter???
    Thanks again for your time.

  • Error while using sort by key lexicographically

    Hi,
    while sorting records lexicographically using sort by key function, i got the below error.
    RuntimeException in Message-Mapping transformation: Runtime exception during processing target field mapping /ns0:MT_WorkOrderData/MessagePayload/Record/CAUFVD_KTEXT. The message is: Exception:[java.lang.IllegalArgumentException: Cannot parse apple to BigDecimal. ] in class com.sap.aii.mappingtool.flib3.NodeFunctions method sortByKey[com.sap.aii.mappingtool.flib3.Plainer@264b264b, com.sap.aii.mappingtool.flib3.Plainer@42674267]
    i need to sort the input records from a file based on a field which is of type string.
    Thanks in advance,
    Jhansi.

    Jhansi,
    Did u referred the thread:Re: Problem in sorting the records
    Best regards,
    raj.

  • FR Studio 11.1.1.3 : You're not authorized to use this function...

    Hi,
    we have FR Studio (client, v. 11.1.1.3.0238 and Report Server v. 11.1.1.3.0.0301) distributed on Citrix terminal server (windows 2003 32-bit) and on latest 2 prod servers we have this error "You're not authorized to use this function. Contact your administrator." appearing.
    On QA server FR Studio works fine, we had an issue there when we forgot to set ports
    8295-8299 to "listening mode" = they were not defined on FR server's FR_servp.properties config files.
    This is also fixed on Prod FR servers and we have double checked firewalls are open.
    After adding them to QA FR servers we had no issues with FR Studio on QA, but on PROD the issue still exists.
    We have also checked that this shouldn' have anything to do with authentication.
    Odd thing is that we get at least partially same sort of error messages on both working and non-working FRClient.log files.
    On FRClient.log there are for example following records:
    08-04 09:26:11 ERROR ConfigResourceBundle     Could not find fr_configcache.properties file
    08-04 09:26:11 ERROR SerializableResourceBundle     Could not get registry instance
    08-04 09:26:11 ERROR SerializableResourceBundle     java.io.FileNotFoundException: C:\Apps\Hyperion\common\config\9.5.0.0\reg.properties (The system cannot find the file specified)
    com.hyperion.hit.registry.exceptions.RegistryException: java.io.FileNotFoundException: C:\Apps\Hyperion\common\config\9.5.0.0\reg.properties (The system cannot find the file specified)
         at com.hyperion.hit.registry.RegistryUtils.createNewConnection(RegistryUtils.java:158)
         at com.hyperion.hit.registry.RegistryConnection.getInstance(RegistryConnection.java:155)
         at com.hyperion.hit.registry.Registry.getInstance(Registry.java:309).....
    Caused by: java.io.FileNotFoundException: C:\Apps\Hyperion\common\config\9.5.0.0\reg.properties (The system cannot find the file specified)
         at java.io.FileInputStream.open(Native Method)
         at java.io.FileInputStream.<init>(FileInputStream.java:106)
         at com.hyperion.hit.registry.RegistryUtils.createNewConnection(RegistryUtils.java:151)
         ... 15 more
    08-04 09:26:11 ERROR HRResourceBundleFactory     Could not locate registry
    08-04 09:26:11 ERROR HRResourceBundleFactory     5500
    com.hyperion.reporting.util.HyperionReportException: Server not yet configured. Please configure the server.
         at com.hyperion.reporting.config.ConfigResourceBundle.<init>(Unknown Source)
         at com.hyperion.reporting.config.ConfigResourceBundle.getInstance(Unknown Source)
         at com.hyperion.reporting.config.HRResourceBundleFactory.getConfigBundle(Unknown Source)...
    That propably gives already an idea what FR Studio is logging.
    Does anyone have idea about this .properties file for frconfig cache?
    Should that be defined somehow during system configuration as we don't find that from any of our environments?
    Just for additional info:
    We have used following packages and installed HFM Admin Client, FR Studio and EPMA File Generator GUI.
    •     02. installer - V17382-01.zip
    •     03. foundation 1 of 4 - V17397-01.zip
    •     03. foundation 2 of 4 - V17369-01.zip
    •     04. architect - V17398-01.zip
    •     08. financial reporting - V17378-01.zip
    •     11. financial management - V17365-01.zip
    Patches:
    + hfm_11113_50-p9976978_111130_WINNT.zip
    + financial reporting_11113_20-p9657652_11113_WINNT.zip
    During the installation we selected:
    Foundation \
    Performance Management Architect\Performance Management Architect File Generator
    Financial Management\
    Financial Management Client
    Financial ManagementADM Driver
    Financial Reporting\
    Financial Reporting Studio Client
    I noticed that apparently no configuration was run neither in QA or in PROD, not sure though if FR Studio even requires that? HFM Admin Client does work on all environments Citrix servers.
    But in Dev and LAB where FR Studio is working fine - FRClient logs absolutely no recods at all and there we did run configuration to tell which SQL db is on background.
    Not sure though whether that config run has any significance for FR Studio.
    Sorry for extremely long story, but just in case if anybody has faced similar issues and whether there could be something with Windows server settings I should go and check?
    Btw... even adding this fr_configcache.properties manually (to try to highlight FR server name and port) it seems FR Client can't find the file.
    Br, MJK

    Denis,
    Thank you for the prompt reply.
    >
    Denis Konovalov wrote:
    > if those reports were saved with security - you're not goingt o be able to open them with Xi3.1 Deski.
    Forgive me for my mundane question but what does saving with security mean?
    Thanks

  • Sort functionality in Data Grid

    Hi Gurus,
    I am new to this DataGrid control.I want to establish the sort functionality when clicking on the headercolumns as in matrices.
    (ie.When double clicking the header column , sort the data in ascending or descending order of that column) like in system form matrices.
    How ever this is not possible when I tried with grid control.
    The problem I am facing is that I cannot get the column headers of the grid programmatically.(in duble click event or itempressed event)
    Anybody did this one previously? Also how
    we can change the column order of the grid using screen painter?
    The columns that actually come visible in the grid  are actually columns of the linked datatable object.
    In the designer ,there is no "swap" button for column re-ordering.
    Only one way I know is changing the query associated with datatable.
    This is a crucial thing ,since client may ask for re-ordering of columns frequently.
    Can anybody help?
    Regards,
    Deepesh

    Hi Deepesh,
    1. This functionality is not available with the SDK. Thus it's not possible to change it on the fly. Your only option is to change the query associated with datatable (as you mentioned). You may set up a user preference table, that the user can configure with its preference. That's the best you can do.
    2. To swap the columns in screen painter you must use SBO 2005 (it's not available on previous release). What you must do is, click on the one column you want to swap and the other you want to swap and click on the swap button (on the left bottom of the page in the columns tab)

  • How to accumlate and use sort in ALV

    Hi
    I am using collect statement for accumalation.
    but it is not working.
    the code is like this:
      IF NOT p_otrstk  IS INITIAL.
        CLEAR it_zresult_tab1.
        LOOP AT it_mard_tab INTO wa_mard_tab.
          l_tabix = sy-tabix.
          READ TABLE it_zresult_tab1 INTO wa_zresult_tab1
            WITH KEY lgort = s_lgort1
                     lgort = s_lgort2
                     werks = s_werks
                     matnr = s_matnr.
          IF sy-subrc EQ 0.
            wa_zresult_tab1-speme = wa_mard_tab-speme.
            wa_zresult_tab1-umlme = wa_mard_tab-umlme.
            wa_zresult_tab1-insme = wa_mard_tab-insme.
            wa_zresult_tab1-retme = wa_mard_tab-retme.
            COLLECT wa_zresult_tab1 INTO it_zresult_tab1.
          ENDIF.
        ENDLOOP.
      ENDIF.
    do i need to use modify? but it is with modify it is giving dump.
    and how to do subtotals in ALV grid?
    the code is like this:
      IF grid1 IS INITIAL .
    Instantiate the grid container.
        CREATE OBJECT g_custom_container
        EXPORTING container_name = 'CCCONTAINER'.
    *Instantiate the grid itself within the container.
        CREATE OBJECT grid1
        EXPORTING
        i_parent = g_custom_container.
       i_appl_events = 'X'.
    Call method of grid1 class object to build/display the grid.
        CALL METHOD grid1->set_table_for_first_display
        EXPORTING
             i_structure_name = 'ZRESULT_TAB'
             is_variant =  variant
            i_save = 'U'
            is_layout = gs_layout
        CHANGING
            it_outtab = it_zresult_tab
            it_fieldcatalog = gt_fcat
            IT_SORT  = VT_SORT
        EXCEPTIONS
            invalid_parameter_combination = 1
            program_error = 2
            too_many_lines = 3
            OTHERS = 4
        IF sy-subrc <> 0.
          MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
          WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
        ENDIF.
    and in the fieldcatalog
    IF p_some  = 'X'.
      CLEAR: ls_sort.
       t_fcat-no_out     = 'X'.
         ls_sort-fieldname = 'MATNR'.
        ls_sort-subtot    = 'X'.
        APPEND ls_sort TO vt_sort.
    but this is also not working.
    Please help me.....
    Thanks
    Alekhya

    Hi,
    go thru this sample program which uses sort and sums the data
    report  yalv2  .
    declare data areas for listviewer******************
    type-pools:slis.
    data:g_repid like sy-repid,
    gs_layout type slis_layout_alv,
    gt_fieldcat type slis_t_fieldcat_alv,
    fieldcat_ln type slis_fieldcat_alv,
    gt_sort type slis_t_sortinfo_alv,
    gs_sort type slis_sortinfo_alv,
    gt_events type slis_t_event,
    gs_event type slis_alv_event,
    gt_list_top_of_page type slis_t_listheader,
    gs_line type slis_listheader,
    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.
    initialization.
      g_repid = sy-repid.
    start-of-selection.
      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 200 times.
        append itab1.
      enddo.
    end-of-selection.
      <b>perform build_fieldcat.</b> 
      <b>perform build_sortcat.</b>
      perform build_eventcat changing gt_events.
      perform build_commentcat changing gt_list_top_of_page.
      perform call_alv.
    *&      Form  build_fieldcat
          text
    -->  p1        text
    <--  p2        text
    form build_fieldcat .         "data field catalog, explain field desc
                                      "to alv
      fieldcat_ln-fieldname = 'FIELD1'.
      fieldcat_ln-tabname = 'ITAB1'.
      fieldcat_ln-key = ' '.                          "subtotal key
      fieldcat_ln-no_out = ' '.
      fieldcat_ln-seltext_l = 'HEAD1'.
      append fieldcat_ln to gt_fieldcat.
      fieldcat_ln-fieldname = 'FIELD2'.
      fieldcat_ln-tabname = 'ITAB1'.
      fieldcat_ln-no_out = ' '.
      fieldcat_ln-seltext_l = 'HEAD2'.
      append fieldcat_ln to gt_fieldcat.
      fieldcat_ln-fieldname = 'FIELD3'.
      fieldcat_ln-tabname = 'ITAB1'.
      fieldcat_ln-ref_tabname = 'MSEG'.
      fieldcat_ln-ref_fieldname = 'MENGE'.
      fieldcat_ln-no_out = ' '.
      fieldcat_ln-do_sum = 'X'.                       "sum upon display
      append fieldcat_ln to gt_fieldcat.
    endform.                    " build_fieldcat
    *&      Form  build_sortcat
          text
    -->  p1        text
    <--  p2        text
    form build_sortcat .           "data sorting and displaying subtotal
      clear gs_sort.
      gs_sort-fieldname = 'FIELD1'.
      gs_sort-spos = '1'.
      gs_sort-up = 'X'.
      append gs_sort to gt_sort.
      clear gs_sort.
      gs_sort-fieldname = 'FIELD2'.
      gs_sort-spos = '2'.
      gs_sort-up = 'X'.
      append gs_sort to gt_sort.
    endform.                    " build_sortcat
    *&      Form  build_eventcat
          text
         <--P_GT_EVENTS  text
    form build_eventcat  changing lt_events type slis_t_event.
    constants:
    gc_formname_top_of_page type slis_formname value 'TOP-OF-PAGE'.
    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 gs_event.
    if sy-subrc = 0.
    move gc_formname_top_of_page to gs_event-form.
    append gs_event to lt_events.
    endif.
    endform.                    " build_eventcat
    *&      Form  build_commentcat
          text
         <--P_GT_LIST_TOP_OF_PAGE  text
    form build_commentcat  changing gt_top_of_page type slis_t_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.
    clear gs_line.
    gs_line-typ = 'S'.
    gs_line-key = 'STATUS 2'.
    gs_line-info = 'INFO 2'.
    append gs_line to gt_top_of_page.
    endform.                    " build_commentcat
    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.
    *&      Form  call_alv
          text
    -->  p1        text
    <--  p2        text
    form call_alv .
    call function 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
       I_CALLBACK_PROGRAM             = g_repid
       I_STRUCTURE_NAME               = 'ITAB1'
       IS_LAYOUT                      = gs_layout
       IT_FIELDCAT                    = gt_fieldcat
       IT_SORT                        = gt_sort
       IT_EVENTS                      = gt_events
      tables
        t_outtab                       = ITAB1
    endform.                    " call_alv
    Regards,
    Sowjanya.
    Message was edited by: sowjanya suggula

Maybe you are looking for

  • Do I need to manually back up my iphone photos if I have auto downloads already set up in iphoto?

    I'm a relatively new iPhone user. I don't take a ton of photos, but the ones I take are important to me. I've been trying to make sure that photos I take with my phone are backed up and in iPhoto. I have a few questions regarding how it all works. 1)

  • My ipod is not recognised by my computer and will not play at all

    My Ipod is jammed, it will not play on its dock or with ear phones. It just says do not disconnect. I tried to plug it into my computer but Itunes will not pick it up. It is being recognised by windows though. I don't know how to solve this problem a

  • File Upload in Webdynpro ABAP

    Hello, I would like upload a excel file in Webdynpro for ABAP and I get the data in a attribute in the context node. The data is there in Binary format. If it is possible to get the data in the ASC format like the function "ws_upload"? I had tested w

  • Tumblr Dashboard Loads way too many new pages

    When I'm on Tumblr, scrolling through my dashboard, I noticed that after a while it gets very slow. The reason why, is that everytime I scroll down a bit or press the 'j'-key (to go to the next post), firefox/tumblr already loads a next page of my da

  • How do I set file permissions

    I need to rename a file but am getting a file permission error. What can I do?