Sort logic required

Hi
I have this requirement in which I have to order by ascending or descending based on the values of a column but the group boundaries should be as it is.
e.g.
Column1 Column2 Column3
111 646483 A Group 1
011 84834 B
011 457845 C Group 2
011 788807 D
001 84844 E Group 3
001 94949 F
001 111333 G
011 734734 H Group3
011 884848 I
I need to sort based on column2 but the group boundaries should not be voilated The expected output is like this.
Column1 Column2 Column3
111 646483 A Group 1
011 788807 D
011 457845 C
011 84834 B Group 2
001 111333 G
001 94949 F Group 3
001 84844 E
011 884848 I Group 4
011 734734 H
Group indicators is not in a column that is what I have displayed as a facilitator to show the requirement
Gaurav

-- test data:
scott@ORA92> SELECT GROUPING (user_identifier)
  2           || GROUPING (user_identifier1)
  3           || GROUPING (user_identifier2) AS LVL,
  4           CASE GROUPING (user_identifier)
  5             || GROUPING (user_identifier1)
  6             || GROUPING (user_identifier2)
  7           WHEN '111'
  8           THEN 'Total'
  9           WHEN '011'
10           THEN user_identifier
11           WHEN '001'
12           THEN user_identifier1
13           END AS NAME,
14           SUM (total_salary) AS AMOUNT
15  FROM   your_table
16  GROUP BY CUBE (user_identifier, user_identifier1, user_identifier2)
17  HAVING GROUPING (user_identifier)
18           || GROUPING (user_identifier1)
19           || GROUPING (user_identifier2) = '111'
20  OR     GROUPING (user_identifier)
21           || GROUPING (user_identifier1)
22           || GROUPING (user_identifier2) = '011'
23  OR     (GROUPING (user_identifier)
24            || GROUPING (user_identifier1)
25            || GROUPING (user_identifier2) = '001'
26            AND  user_identifier = 'Gaurav')
27  /
LVL NAME                                               AMOUNT
111 Total                                        436628862.38
011 Bill                                           7114641.52
011 Henry                                         81237540.82
011 James                                           300888.31
011 Shyam                                        309625409.17
011 Claret                                         9545506.32
011 Gaurav                                        28804876.24
001 Ron                                              40147.00
001 Tom                                             106186.00
001 Peter                                         28658543.24
10 rows selected.
-- ascending amount:
scott@ORA92> SELECT lvl, name, amount
  2  FROM   (SELECT lvl, name, amount, user_identifier, user_identifier1,
  3                SUM (amount) OVER (PARTITION BY user_identifier) AS ui_tot_sal
  4            FROM   (SELECT GROUPING (user_identifier)
  5                     || GROUPING (user_identifier1)
  6                     || GROUPING (user_identifier2) AS LVL,
  7                     CASE GROUPING (user_identifier)
  8                       || GROUPING (user_identifier1)
  9                       || GROUPING (user_identifier2)
10                     WHEN '111' THEN 'Total'
11                     WHEN '011' THEN user_identifier
12                     WHEN '001' THEN user_identifier1
13                     END AS NAME,
14                     SUM (total_salary) AS AMOUNT,
15                     user_identifier,
16                     user_identifier1
17                 FROM   your_table
18                 GROUP  BY CUBE (user_identifier, user_identifier1, user_identifier2)
19                 HAVING GROUPING (user_identifier)
20                     || GROUPING (user_identifier1)
21                     || GROUPING (user_identifier2) = '111'
22                 OR     GROUPING (user_identifier)
23                     || GROUPING (user_identifier1)
24                     || GROUPING (user_identifier2) = '011'
25                 OR     (GROUPING (user_identifier)
26                     || GROUPING (user_identifier1)
27                     || GROUPING (user_identifier2) = '001'
28                     AND  user_identifier = 'Gaurav')))
29  ORDER  BY DECODE (user_identifier, NULL, 0, ui_tot_sal),
30              DECODE (user_identifier1, NULL, 0, amount)
31  /
LVL NAME                                               AMOUNT
111 Total                                        436628862.38
011 James                                           300888.31
011 Bill                                           7114641.52
011 Claret                                         9545506.32
011 Gaurav                                        28804876.24
001 Ron                                              40147.00
001 Tom                                             106186.00
001 Peter                                         28658543.24
011 Henry                                         81237540.82
011 Shyam                                        309625409.17
10 rows selected.
-- descending amount:
scott@ORA92> SELECT lvl, name, amount
  2  FROM   (SELECT lvl, name, amount, user_identifier, user_identifier1,
  3                SUM (amount) OVER (PARTITION BY user_identifier) AS ui_tot_sal,
  4                MAX (amount) OVER () AS max_tot_sal
  5            FROM   (SELECT GROUPING (user_identifier)
  6                     || GROUPING (user_identifier1)
  7                     || GROUPING (user_identifier2) AS LVL,
  8                     CASE GROUPING (user_identifier)
  9                       || GROUPING (user_identifier1)
10                       || GROUPING (user_identifier2)
11                     WHEN '111' THEN 'Total'
12                     WHEN '011' THEN user_identifier
13                     WHEN '001' THEN user_identifier1
14                     END AS NAME,
15                     SUM (total_salary) AS AMOUNT,
16                     user_identifier,
17                     user_identifier1
18                 FROM   your_table
19                 GROUP  BY CUBE (user_identifier, user_identifier1, user_identifier2)
20                 HAVING GROUPING (user_identifier)
21                     || GROUPING (user_identifier1)
22                     || GROUPING (user_identifier2) = '111'
23                 OR     GROUPING (user_identifier)
24                     || GROUPING (user_identifier1)
25                     || GROUPING (user_identifier2) = '011'
26                 OR     (GROUPING (user_identifier)
27                     || GROUPING (user_identifier1)
28                     || GROUPING (user_identifier2) = '001'
29                     AND  user_identifier = 'Gaurav')))
30  ORDER  BY DECODE (user_identifier, NULL, max_tot_sal, ui_tot_sal) DESC,
31              DECODE (user_identifier1, NULL, max_tot_sal, amount) DESC
32  /
LVL NAME                                               AMOUNT
111 Total                                        436628862.38
011 Shyam                                        309625409.17
011 Henry                                         81237540.82
011 Gaurav                                        28804876.24
001 Peter                                         28658543.24
001 Tom                                             106186.00
001 Ron                                              40147.00
011 Claret                                         9545506.32
011 Bill                                           7114641.52
011 James                                           300888.31
10 rows selected.

Similar Messages

  • Logic required  for Sort in ALV

    Hi All,
    I am dowloding the ALV report layout in excel sheet thorough mailing functionality.
    I want to implenemnt the dynamic sort. Here I am writing this.but i want the logic for below code.
          CALL FUNCTION 'LT_DBDATA_READ_FROM_LTDX'
            EXPORTING
      I_TOOL             = 'LT'
              IS_VARKEY          = W_VARKEY_EU
            TABLES
              T_DBFIELDCAT       = IT_DBFIELDCAT_EU
            T_DBSORTINFO       =  IT_DBSORTINFO
             T_DBFILTER         = IT_FILTER_LAYOUT
             T_DBLAYOUT         = IT_DB_LAYOUT.
    LIT_DBSORTINFO[] = IT_DBSORTINFO[].
        SORT LIT_DBSORTINFO[] BY KEY1.
        DELETE ADJACENT DUPLICATES FROM LIT_DBSORTINFO[] COMPARING KEY1.
        LOOP AT LIT_DBSORTINFO[].
          CLEAR: LW_SPOS,
                 LW_UP,
                 LW_DOWN,
                 LW_SUBTOT,
                 LW_COMP,
                 LW_EXPA,
                 LW_GROUP.
          CLEAR IT_DBSORTINFO[].
          READ TABLE IT_DBSORTINFO WITH KEY
                                    KEY1  = LIT_DBSORTINFO-KEY1
                                    PARAM = 'SPOS'.
          IF SY-SUBRC = 0.
            LW_SPOS = IT_DBSORTINFO-VALUE.
          ENDIF.
          CLEAR IT_DBSORTINFO.
          READ TABLE IT_DBSORTINFO WITH KEY
                                    KEY1  = LIT_DBSORTINFO-KEY1
                                    PARAM = 'UP'.
          IF SY-SUBRC = 0.
            LW_UP = IT_DBSORTINFO-VALUE.
          ENDIF.
          CLEAR IT_DBSORTINFO.
          READ TABLE IT_DBSORTINFO WITH KEY
                                    KEY1  = LIT_DBSORTINFO-KEY1
                                    PARAM = 'DOWN'.
          IF SY-SUBRC = 0.
            LW_DOWN = IT_DBSORTINFO-VALUE.
          ENDIF.
          CLEAR IT_DBSORTINFO.
          READ TABLE IT_DBSORTINFO WITH KEY
                                    KEY1  = LIT_DBSORTINFO-KEY1
                                    PARAM = 'SUBTOT'.
          IF SY-SUBRC = 0.
            LW_SUBTOT = IT_DBSORTINFO-VALUE.
          ENDIF.
          CLEAR IT_DBSORTINFO.
          READ TABLE IT_DBSORTINFO WITH KEY
                                    KEY1  = LIT_DBSORTINFO-KEY1
                                    PARAM = 'COMP'.
          IF SY-SUBRC = 0.
            LW_COMP = IT_DBSORTINFO-VALUE.
          ENDIF.
          CLEAR IT_DBSORTINFO.
          READ TABLE IT_DBSORTINFO WITH KEY
                                    KEY1  = LIT_DBSORTINFO-KEY1
                                    PARAM = 'EXPA'.
          IF SY-SUBRC = 0.
            LW_EXPA = IT_DBSORTINFO-VALUE.
          ENDIF.
          CLEAR IT_DBSORTINFO.
          READ TABLE IT_DBSORTINFO WITH KEY
                                    KEY1  = LIT_DBSORTINFO-KEY1
                                    PARAM = 'GROUP'.
          IF SY-SUBRC = 0.
            LW_GROUP = IT_DBSORTINFO-VALUE.
          ENDIF.
          LOOP AT IT_ALV_DATA FROM W_LOOP_FROM_EU TO W_LOOP_TO_EU.
            LW_TABIX = SY-TABIX.
            READ TABLE IT_FIELDCAT INTO LW_FIELDCAT WITH KEY
                               FIELDNAME = LIT_DBSORTINFO-KEY1.
            IF SY-SUBRC = 0.
              ASSIGN COMPONENT SY-TABIX OF
                         STRUCTURE IT_ALV_DATA TO <LFS>.
              IF SY-SUBRC = 0.
                CLEAR LW_CHAR.
                LW_CHAR = <LFS>.
                  IF LW_SPOS= 'SPOS'.
                  LOGIC Required
                    ENDIF.
                  ELSEIF LW_OPTION = 'DOWN'.
                 LOgic required
                    ENDIF.
                        ENDIF.
          ENDLOOP.
        ENDLOOP.
    regards,
    Ajay reddy

    Hai,
    Let
    1)general data
    2)all customers
    3)company code data
    4)sales organization data
    are the check box names,Then
    Just use the piece  of code below:
    <b>IF general data = 'X'.
       COUNT = COUNT + 1.
    ENDIF.
    IF all_customers = 'X'.
       COUNT = COUNT + 1.
    ENDIF.
    IF company_code_data = 'X'.
       COUNT = COUNT + 1.
    ENDIF.
    IF sales_organization_data = 'X'.
       COUNT = COUNT + 1.
    ENDIF.</b>
    Now check whether more than one Check Boxes are selected or not
    <b>IF COUNT GT 1.
    "* Do the oprations  what ever you want here  
    ENDIF.</b>
    <b>Reward points if it helps you.</b>
    Regds,
    Rama chary.Pammi

  • Change Default Sort Logic Of ADF Table?

    Hello All,
    In my application is an ADF table with lots of rows. The default sort logic for one of the columns is from 'Oldest to Newest'. The user has to click on the sort again to get 'Newest to Olderst'. This takes away a lot of time.
    How can I change the default sort logic to 'Newest to Oldest' ?
    Thanks,

    Is this jdeveloper 11.1.1.2?
    What is the problem with the normal scenario - just add 'order by' the view object clause?
    The table offers ascending and descending ordering.

  • ALV ...Logic required

    Hi every body,
       I have one requirement like an alv report will display
    output which contains a material number.
    <b>If i click On the material number it shud go to MM03...Accounting view
    Logic required for this.</b>I am a beginner ...Plz help me...
    Thanks in advance.
    Message was edited by: raja gurrala

    Hi,
    See the code sample,
    INCLUDE <icon>.
    * Predefine a local class for event handling to allow the
    * declaration of a reference variable before the class is defined.
    CLASS lcl_event_receiver DEFINITION DEFERRED.
    DATA : o_alvgrid          TYPE REF TO cl_gui_alv_grid ,
           o_dockingcontainer TYPE REF TO cl_gui_docking_container ,
           o_eventreceiver    TYPE REF TO lcl_event_receiver,
           wa_layout TYPE lvc_s_layo ,
           wa_variant TYPE disvariant.
    CONSTANTS : c_a(1) TYPE c VALUE 'A' ,                     " All Layouts
                c_x(1) TYPE c VALUE 'X'.
    CLASS lcl_event_receiver DEFINITION.
      PUBLIC SECTION.
        CLASS-METHODS:
    * Hot Spot Click
           handle_hotspot
             FOR EVENT hotspot_click OF cl_gui_alv_grid
                IMPORTING e_row_id
                          e_column_id
                          es_row_no,
    * Double Click
    handle_double_click
          FOR EVENT double_click OF cl_gui_alv_grid
              IMPORTING e_row
                        e_column
                        es_row_no,
    ENDCLASS.                    "lcl_event_receiver DEFINITION
    * Implementation
    CLASS lcl_event_receiver IMPLEMENTATION.
    *&      Method handle_hotspot
    * This method is called when the user clicks on a hotspot to drill down.
    * The following types are exported from the ALV
    * LVC_S_ROW
    * LVC_S_COL
    * LVC_S_ROID
      METHOD handle_hotspot.
    * The hotspot processing coded in the form below.
        PERFORM f9900_handle_hotspot USING e_row_id
                                           e_column_id
                                           es_row_no.
      ENDMETHOD.                    "handle_hotspot
    *&      Method handle_double_click
      METHOD handle_double_click.
    * The double click processing should be coded in the form below.
        PERFORM f9901_handle_double_click USING e_row
                                                e_column
                                                es_row_no.
      ENDMETHOD.                    "HANDLE_DOUBLE_CLICK
    FORM f9900_handle_hotspot  USING    p_row_id
                                        p_column_id
                                        p_row_no.
    *Read internal table for proper value.
      READ TABLE  i_output
                  INDEX p_row_id
                  INTO wa_output.
    * Call the transaction MMBE
      SET PARAMETER ID 'MAT' FIELD wa_output-matnr.
      CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN .
    ENDFORM.                    " f9900_handle_hotspot
    *&      Form  f9901_handle_double_click
    *       Double Click
    FORM f9901_handle_double_click  USING    p_row
                                             p_column
                                             p_row_no.
      READ TABLE i_output INDEX p_row INTO wa_output.
      CASE p_column.
        WHEN 'MATNR'.
          IF NOT wa_output-matnr IS INITIAL.
            SET PARAMETER ID 'MAT' FIELD wa_output-matnr.
            CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN .
          ENDIF.
      ENDCASE.
    ENDFORM.                    " f9901_handle_double_click
    U can use either hot spot or double click event.
    If u r using hotspot set the hotspot = 'X' in fieldcatalog.
    Hope this helps.
    OR another method without oops concept
    FORM user_command USING r_ucomm LIKE sy-ucomm
                      rs_selfield TYPE slis_selfield.
    data:lv_matnr    LIKE v_mmim_lc-matnr,   "Material
    read table i_output into w_output index rs_selfield-tabindex.
    lv_matnr = w_output-matnr.
    SET PARAMETER ID 'MAT' FIELD lv_matnr.
    CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN .
    Clear:     lv_matnr.
    ENDFORM.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
    *   I_INTERFACE_CHECK                 = ' '
    *   I_BYPASSING_BUFFER                =
    *   I_BUFFER_ACTIVE                   = ' '
         i_callback_program                = v_repid
         i_callback_pf_status_set          = 'SET_PF_STATUS'
    <b>     i_callback_user_command           = 'USER_COMMAND'</b>
         i_background_id        = 'ALV_BACKGROUND'
        IS_LAYOUT               = I_LAYOUT
        it_fieldcat             = i_fieldcat "field catalog
       I_SAVE                   = 'A'
       IS_VARIANT               = G_VARIANT
        TABLES
            t_outtab                       = i_output "output table
       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.
    Kindly reward points if this helps u, revert back with queries.
    Message was edited by: Judith Jessie Selvi

  • Tables Proration/Spliting Logic required

    Hi Friends
    I have 3 internal tables:
    IT_0001:
    PERNR     BEGDA     ENDDA     WERKS     BTRTL     ABKRS     KOSTL     ORGEH
    10774     20080101     20081028     US11     14     CB          0
    10774     20081029     99991231     US11     14     CB     1125100     30084829
    IT_0008_1:
    PERNR     BEGDA     ENDDA     TRFGR     BAND1
    10774     20080101     20080803     1     1
    IT_0008:
    PERNR     BEGDA     ENDDA     TRFST     BAND
    10774     20080804     20081231     6     6
    WITH THE ABOVE TABLES COMBINATION,BY SPLITING THE TABLES BASED ON BEGDA,ENDDA
    MY FINAL TABLE HAS TO COME AS FOLLOWS:
    IT_FINAL:
    PERNR     BEGDA     ENDDA     WERKS     BTRTL     MOLGA     BAND     BONUSPRCNTAGE
    10774     20080101     20080803     US11     14     10     1     8
    10774     20080804     20081028     US11     14     10     6     8
    10774     20081029     20081231     US11     14     10     6     8
    Can any one please provide me the logic for this.
    Thanks for your cooperation.
    Regards,
    Sree

    Hi Gourav
    Thanks for your suggestion!
    Let me ask the same question in this way then:
    Please correct me the code where I am wrong:
    Logic for Proration calculation for Bonus Percentage when Band
          maintained in TRFGR field.
                SORT it_0001_1 BY pernr begda endda.
                SORT it_0008_1 BY pernr begda endda.
                LOOP AT it_0001_1 INTO wa_0001_1.
                  LOOP AT it_0008_1 INTO wa_0008_1 WHERE pernr = wa_0001_1-pernr.
    To check the end date is 12/31/9999, if yes then set it to bonus year end date
                    IF wa_0008_1-endda = c_year OR wa_0008_1-endda0(4) > gv_endyear0(4).
                      wa_0008_1-endda = c_aug_e.
                      MODIFY it_0008_1 FROM wa_0008_1 TRANSPORTING endda.
                    ELSEIF wa_0001_1-endda = c_year.
                      wa_0001_1-endda = gv_endyear.
                    ENDIF.
    ***Condition to split the records based on the records in PA0001 and Pa0008 tables data
                    IF wa_0001_1-begda >= wa_0008_1-begda AND wa_0001_1-endda = wa_0008_1-endda.
                      wa_final-pernr = wa_0001_1-pernr.
                      wa_final-begda = wa_0001_1-begda.
                      wa_final-endda = wa_0001_1-endda.
                      wa_final-werks = wa_0001_1-werks.
                      wa_final-btrtl = wa_0001_1-btrtl.
                      wa_final-kostl = wa_0001_1-kostl.
                      IF wa_0001_1-kostl IS NOT INITIAL.
                        APPEND wa_final TO it_final.
                      ELSE.
                        APPEND wa_final TO it_costcenter.
                      ENDIF.
                      EXIT.
                    ELSEIF wa_0001_1-begda >= wa_0008_1-begda AND wa_0001_1-endda > wa_0008_1-endda.
                      wa_final-pernr = wa_0001_1-pernr.
                      wa_final-begda = wa_0001_1-begda.
                      wa_final-endda = wa_0008_1-endda.
                      wa_final-werks = wa_0001_1-werks.
                      wa_final-btrtl = wa_0001_1-btrtl.
                      wa_final-kostl = wa_0001_1-kostl.
                      IF wa_final-begda < wa_final-endda.
                        IF wa_0001_1-kostl IS NOT INITIAL.
                          APPEND wa_final TO it_final.
                        ELSE.
                          APPEND wa_final TO it_costcenter.
                        ENDIF.
                        gv_date  = wa_0008_1-endda.
                        IF ( gv_date+4(4) EQ c_leap ).           " to check date is feb 28th
                          gv_mod = wa_0008_1-endda+0(4) MOD 4.
                          gv_mod1 = wa_0008_1-endda+0(4) MOD 4.
                          IF ( gv_mod EQ 0  OR gv_mod1 EQ 0 ).   " to check for leap year
                            wa_0008_1-endda+4(4) = c_leap1.
                            wa_final-pernr = wa_0001_1-pernr.
                            wa_final-begda = wa_0008_1-endda.
                            wa_final-endda = wa_0001_1-endda.
                            wa_final-werks = wa_0001_1-werks.
                            wa_final-btrtl = wa_0001_1-btrtl.
                            wa_final-kostl = wa_0001_1-kostl.
                            IF wa_0001_1-kostl IS NOT INITIAL.
                              APPEND wa_final TO it_final.
                            ELSE.
                              APPEND wa_final TO it_costcenter.
                            ENDIF.
                          ENDIF.
                        ENDIF.
                      ENDIF.
                      EXIT.
                    ELSEIF wa_0001_1-begda >= wa_0008_1-begda AND wa_0001_1-endda < wa_0008_1-endda.
                      wa_final-pernr = wa_0001_1-pernr.
                      wa_final-begda = wa_0001_1-begda.
                      wa_final-endda = wa_0001_1-endda.
                      wa_final-werks = wa_0001_1-werks.
                      wa_final-btrtl = wa_0001_1-btrtl.
                      wa_final-kostl = wa_0001_1-kostl.
                      IF wa_final-begda < wa_final-endda.
                        IF wa_0001_1-kostl IS NOT INITIAL.
                          APPEND wa_final TO it_final.
                        ELSE.
                          APPEND wa_final TO it_costcenter.
                        ENDIF.
                        gv_date  = wa_0008_1-endda.
                        IF ( gv_date+4(4) EQ c_leap ).             " to check date is feb 29th
                          gv_mod = wa_0008_1-endda+0(4) MOD 4.
                          gv_mod1 = wa_0008_1-endda+0(4) MOD 4.
                          IF ( gv_mod EQ 0  OR gv_mod1 EQ 0 ).     " to check for leap year
                            wa_0008_1-endda+4(4) = c_leap1.
                            wa_final-pernr = wa_0001_1-pernr.
                            wa_final-begda = wa_0008_1-endda.
                            wa_final-endda = wa_0001_1-endda.
                            wa_final-werks = wa_0001_1-werks.
                            wa_final-btrtl = wa_0001_1-btrtl.
                            wa_final-kostl = wa_0001_1-kostl.
                            IF wa_0001_1-kostl IS NOT INITIAL.
                              APPEND wa_final TO it_final.
                            ELSE.
                              APPEND wa_final TO it_costcenter.
                            ENDIF.
                          ENDIF.
                        ELSEIF wa_0001_1-begda >= wa_0008_1-begda AND wa_0001_1-endda >= wa_0008_1-endda.
                          wa_final-pernr = wa_0001_1-pernr.
                          wa_final-begda = wa_0001_1-endda + 1.
                          wa_final-endda = wa_0008_1-endda.
                          wa_final-werks = wa_0001_1-werks.
                          wa_final-btrtl = wa_0001_1-btrtl.
                          wa_final-kostl = wa_0001_1-kostl.
                          IF wa_0001_1-kostl IS NOT INITIAL.
                            APPEND wa_final TO it_final.
                          ELSE.
                            APPEND wa_final TO it_costcenter.
                          ENDIF.
                        ENDIF.
                      ENDIF.
                      EXIT.
                    ENDIF.
                    CLEAR: wa_0008_1,
                           gv_date.
                  ENDLOOP.
    ***** 23/07/2008
                  LOOP AT it_0008 INTO wa_0008 WHERE pernr = wa_0001_1-pernr.
    To check the end date is 12/31/9999, if yes then set it to bonus year end date
                    IF wa_0008-endda = c_year OR wa_0008-endda0(4) > c_end0(4).
                      wa_0008-endda = c_end.
                      MODIFY it_0008 FROM wa_0008 TRANSPORTING endda.
                    ELSEIF wa_0001_1-endda = c_year.
                      wa_0001_1-endda = c_end.
                    ENDIF.
    ***Condition to split the records based on the records in PA0001 and Pa0008 tables data
                    IF wa_0001_1-begda <= wa_0008-begda AND wa_0001_1-endda = wa_0008-endda.
                      wa_final-pernr = wa_0001_1-pernr.
                      wa_final-begda = wa_0008-begda. "CHANGED FROM 0001 TO 0008
                      wa_final-endda = wa_0008-endda. "CHANGED FROM 0001 TO 0008
                      wa_final-werks = wa_0001_1-werks.
                      wa_final-btrtl = wa_0001_1-btrtl.
                      wa_final-kostl = wa_0001_1-kostl.
                      IF wa_0001_1-kostl IS NOT INITIAL.
                        APPEND wa_final TO it_final.
                      ELSE.
                        APPEND wa_final TO it_costcenter.
                      ENDIF.
                      EXIT.
                    ELSEIF wa_0001_1-begda <= wa_0008-begda AND wa_0001_1-endda > wa_0008-endda.
                      wa_final-pernr = wa_0001_1-pernr.
                      wa_final-begda = wa_0008-begda. "look here
                      wa_final-endda = wa_0008-endda.
                      wa_final-werks = wa_0001_1-werks.
                      wa_final-btrtl = wa_0001_1-btrtl.
                      wa_final-kostl = wa_0001_1-kostl.
                      IF wa_final-begda < wa_final-endda.
                        IF wa_0001_1-kostl IS NOT INITIAL.
                          APPEND wa_final TO it_final.
                        ELSE.
                          APPEND wa_final TO it_costcenter.
                        ENDIF.
                      ENDIF.
                    ELSEIF wa_0001_1-begda <= wa_0008-begda AND wa_0001_1-endda < wa_0008-endda.
                      wa_final-pernr = wa_0001_1-pernr.
                      wa_final-begda = wa_0008-begda.
                      wa_final-endda = wa_0001_1-endda.
                      wa_final-werks = wa_0001_1-werks.
                      wa_final-btrtl = wa_0001_1-btrtl.
                      wa_final-kostl = wa_0001_1-kostl.
                      IF wa_final-begda < wa_final-endda.
                        IF wa_0001_1-kostl IS NOT INITIAL.
                          APPEND wa_final TO it_final.
                        ELSE.
                          APPEND wa_final TO it_costcenter.
                        ENDIF.
                      ENDIF.
                    ENDIF.
                  ENDLOOP.
    ****23/07/2007
                ENDLOOP.
    ***Updating the IT_0001_1 and IT_COSTCENTER tables with band information.
                IF it_final[] IS NOT INITIAL.
                  LOOP AT it_final INTO wa_final.
                    gv_tabix = sy-tabix.
                    LOOP AT it_0008_1 INTO wa_0008_1  WHERE pernr EQ wa_final-pernr
                                                      AND   begda LE wa_final-begda
                                                      AND   endda GE wa_final-endda.
                      READ TABLE it_cgroup INTO wa_cgroup WITH KEY werks = wa_final-werks
                                                                   btrtl = wa_final-btrtl.
                      IF sy-subrc EQ 0.
                        wa_final-band = wa_0008_1-trfgr.
                        wa_final-molga = wa_cgroup-molga.
                        MODIFY it_final FROM wa_final INDEX gv_tabix TRANSPORTING band molga.
                        CLEAR: wa_0008_1,
                               wa_final,
                               gv_tabix.
                      ENDIF.
                    ENDLOOP.
      ***TRFST CALCULATION.
                    LOOP AT it_0008 INTO wa_0008  WHERE pernr EQ wa_final-pernr
                                                  AND   begda LE wa_final-begda
                                                  AND   endda GE wa_final-endda.
                      READ TABLE it_cgroup INTO wa_cgroup WITH KEY werks = wa_final-werks
                                                                   btrtl = wa_final-btrtl.
                      IF sy-subrc EQ 0.
                        wa_final-band = wa_0008-trfst.
                        wa_final-molga = wa_cgroup-molga.
                        MODIFY it_final FROM wa_final INDEX gv_tabix TRANSPORTING band molga.
                        CLEAR: wa_0008,
                               wa_final,
                               gv_tabix.
                      ENDIF.
                    ENDLOOP.
                    CLEAR: wa_final.
                  ENDLOOP.
                ENDIF.
    Actually I have developed code but it's not giving the required results.
    That's why I asked for the solution .My intension in asking the solution is to get various types of approaches of the solution but not to waste the comunity time.
    Anyhow thanks!
    Regards,
    Sree

  • Logic Required

    Hi All,
    Pl find the requirement below.
    We have a inventory report in that we were showing the stock as on date and the value of that stock.
    This inventory data ( Stock Only) will come from AFS( SAP System) as well as Non-SAP System.To calculate the stock value we are capturing the Moving avarage value from MBEW Table ( Data Source : 0MAT_PLANT_ATTR).It's kf so i have added KF in the 0MAT_PLANT and directly i was inserting this in Query level and doing caluclation.
    Issue : In MBEW Table level moving average price will be maintained at material level and it will contain only the latest price.Means If moving price changes several times in MBEW table it will contain latest one and it will be updated the same in BI also.When i am calculating the inventory for back months it will take the new price and stock value will come .This should not happen.
    Ex :
    Material                Month         Stock           Moving avarage  Price        Value
    A                           jUL'10             10             120 /-                            10*120
    B                          SEP'10              10              150                              10*150
    As per the above example if i run report in Jul'10        value will come as 1200   after two months i will go back and check the value of stock for Jul'2010 will be 1500.But actually it was 1200.
    Solution : As informed by FS-Consultants there is one more table MBEWH contains historic information moving avarage prise based on period and month.But when i have chaked there is no standard extractorbased on MBEWH and how can i include in the reporting(How to impliment the logic).
    Regards
    Ramakanth.

    Hi All,
    Pl find the requirement below.
    We have a inventory report in that we were showing the stock as on date and the value of that stock.
    This inventory data ( Stock Only) will come from AFS( SAP System) as well as Non-SAP System.To calculate the stock value we are capturing the Moving avarage value from MBEW Table ( Data Source : 0MAT_PLANT_ATTR).It's kf so i have added KF in the 0MAT_PLANT and directly i was inserting this in Query level and doing caluclation.
    Issue : In MBEW Table level moving average price will be maintained at material level and it will contain only the latest price.Means If moving price changes several times in MBEW table it will contain latest one and it will be updated the same in BI also.When i am calculating the inventory for back months it will take the new price and stock value will come .This should not happen.
    Ex :
    Material                Month         Stock           Moving avarage  Price        Value
    A                           jUL'10             10             120 /-                            10*120
    B                          SEP'10              10              150                              10*150
    As per the above example if i run report in Jul'10        value will come as 1200   after two months i will go back and check the value of stock for Jul'2010 will be 1500.But actually it was 1200.
    Solution : As informed by FS-Consultants there is one more table MBEWH contains historic information moving avarage prise based on period and month.But when i have chaked there is no standard extractorbased on MBEWH and how can i include in the reporting(How to impliment the logic).
    Regards
    Ramakanth.

  • Adding new value in Pick list and sorted logic on basis of new value.

    Hi All,
    I have a requirement where I have to add a new value in seeded OAMessageBean and sort the page contents on basis of selected value.
    I see in about this page and found out that no VO is attached with this field.
    I assume that it attached somewhere in controller and tried to find out there but cannot able to find it there.Is there any way to find the VO which is attached to this bean?
    Also how to add a new values in this seeded picklist as I can able to get handle to OAMessageBean in custom controller.
    Please Help.
    Regards,
    889254

    Hi Peddi,
    Thanks a lot for your reply,
    I tried to open that page in jdeveloper but I dont see any choice bean on the page.Also tried to open CO attached to this page but no clue.As I am able to the get handle of this choicebean in controller.Is there any way I can find out which VO attached to this choiceBean.
    I tried using below depricated method and it is returning null
    messageField.getListViewObject();
    My another question is Can we add new value to choice bean In CO.
    I tried to add it by below methods but these are not reflecting in the application.
    messageField.addOption("TEMP");
    messageField.addIndexedChild("TEMP");
    Regards,
    889254

  • Logic required to findout "Release To Date" of the Purchase order

    Hi
    We are developing a custom program to release purchase orders as per clients requirements. In that, in the output, we need to display the "Release To Date" of the purchase order. Consider the release codes are R1,R2& R3, and currently the PO is released by R1, then we need to show "Release To Date" as R1. Simillerly once R2 also released the PO, we need to show "R1 R2" in the Release To Date field. This you can see in the Release Tab of the PO.
    Now we need to adopt the same logic in our custom program also. Which table i can find the release to date details. The latest release code of the PO also good enough to build the logic to findout the "Release To Date"
    Any pointers would be of great help.
    Thanks
    Venkat.

    Hi Venkat,
    Check up these tables
    T16FC, T16FD, T16FG, V_T16FC
    Regards,
    Hareesha
    If it's help's reward the pts

  • Logic required for a Internal table  issue

    Hi All,
    I have 2 internal table. I need STLNR value to another internal table. Both having same field. But while reading from one internal table to another internal table using IDNRK key, One idnrk having 2 different stlnr value. But its taking only one. How to take both the values?
    The internal table value like below.
    it_stpo--> This is first table, Here one Idnrk having different stlnr value. I need the same in to next table. Here i read with idnrk field but its taking one stlnr value only into next table.
    How to change the logic ?
    Below is it_stpo table and next one is it_mbew_1
    it_stpo
    STLNR     IDNRK             MENGE
    17224     00439RM1     2.3
    17225     00439RM1     4.2
    172333     00849RM2     5.6
    172158     00432TM3     7.2
    152164     00583RM4     8.4
    176123     00583RM4     2.3
    it_mbew_1
    STLNR     IDNRK             STPRS
         00439RM1     111.22
         00439RM1     126.45
         00849RM2     3.3364
         00432TM3     15.5888
         00583RM4     0
         00583RM4     0.235
    My logic like below,
              SORT it_stpo BY idnrk.
              SORT it_mbew_1 BY matnr.
              LOOP AT it_mbew_1 INTO wa_mbew_1.
                READ TABLE it_stpo INTO wa_stpo WITH KEY idnrk = wa_mbew_1-matnr BINARY SEARCH.
                IF sy-subrc = 0.
                  wa_mbew_1-stlnr = wa_stpo-stlnr.
                  MODIFY it_mbew_1 FROM wa_mbew_1 TRANSPORTING stlnr WHERE matnr = wa_mbew_1-matnr.
                ENDIF.
              ENDLOOP.
    Kindly help us.
    Mohana

    Try below logic.
    add one more field to it_stpo flag type char01.
    update the field with value 'X'.
    SORT it_stpo BY idnrk.
              SORT it_mbew_1 BY matnr.
              LOOP AT it_mbew_1 INTO wa_mbew_1.
                CLEAR WA_STPO.
                READ TABLE it_stpo INTO wa_stpo WITH KEY idnrk = wa_mbew_1-matnr                                                                               
    flag = 'X'.
                if sy-subrc eq 0.
                         move ' ' to wa_stpo-flag.
                         modify it_stpo from wa_stpo index sy-tabix.
                          wa_mbew_1-stlnr = wa_stpo-stlnr.
                         MODIFY it_mbew_1 FROM wa_mbew_1 TRANSPORTING stlnr WHERE matnr = wa_mbew_1-matnr.
                 endif.
              ENDLOOP.
    Regards
    Vinod

  • OTM - How can I sort the requirements when importing from CSV ?

    Hi,
    I am able to upload requirements into OTM, in a tree structure.
    But even though I am giving a "ViewOrder" column in my .xls/.csv file, the requirements do not get uploaded in the same order.
    Whats happening is, when the xls/csv is converted to xml, the vieworder tag isnt included, and in turn doesnt get posted to DB either.
    I also tried modifying a previously saved mapping file, by manually adding ViewOrder=ViewOrder and saving it.
    On selection it only accept sheets containing the column, but still it gets discarded during conversion.
    Is there any way to expand the set of required fields during upload, to include View Order?
    Is there any other way to ensure that the excel data gets uploaded in the same order as listed?

    Have you explored the options in the View -> Sort Photos menu?
    Regards
    TD

  • Program logic required

    Hi all,
    I have requirement saying that transfer data from one program to another transaction selection screen.
    Requirement is.
    In a programi will l have final data in one internal table.
    This data i need to send it for another program selection screen as input.
    Please provide me the logic.
    Thanks in advance

    use the first program as an include for the second program
    then in the intilisation of the second program
    use the values of the internal table of 1st program.
    regards,
    srinivas
    <b>*reward for useful answers*</b>

  • Programming Logic required for pulling the records for past month /week

    Hi All
    I need help in the SQL programming logic.
    Oracle Database Version: 10.2.0.3.0
    Requirement
    In a data warehouse environment, I need to programme for weekly and monthly automated batch jobs to insert the data from Data_tbl to Reporting_tbl for generating reports. Tables descriptions are given below.
    Table1 - Data_tbl (Source table –this table gets updated everyday).
    Record_dt     first_name     last_name
    Table2 - Reporting_tbl_(Target table)
    Cycle_dt     first_name     last_name
    1. Monthly Report
    In the SQL Query, I have where clause condition—
    Where Record_dt >=’01-nov-08’ and record_dt<=’30-nov-08’
    Using the above condition in development, I am pulling the data from source table for the past month data. This will be repeated every month and it should be automated.
    i.e., if I run this report any time in dec 2008, it should pick records of dates from Nov 01st to Nov 30th 2008. if I run this report any time in Jan 2009, it should pick records of dates from Dec 01st to Dec 31st 2008.
    Date Values should be assigned for past month. Value of Cycle_dt in target table should be end date of past month like 30-nov-2008, 31-dec-2008.
    2. Weekly Report
    In the SQL Query, I have where clause condition—
    Where Record_dt >=’01-dec-08’ and record_dt<=’07-dec-08’
    Here week start day is Monday and end day is Sunday.
    If I run the report between Dec 08th to Dec 14th , it should pull records of dates from Dec 01st to Dec 07th 2008.
    On Dec 15th, it should pick from Dec 08th to Dec 14th.
    Value of Cycle_dt in target table should be end date of past week like 07-Dec-2008, 14-Dec-2008.
    Please help me with the logics for both Monthly and Weekly reports.
    Thanks

    Hi,
    For the monthly report, instead of
    Where Record_dt >=’01-nov-08’ and record_dt<=’30-nov-08’say:
    Where   Record_dt >= TRUNC (ADD_MONTHS (SYSDATE, -1), 'MM')
    and     record_dt <  TRUNC (SYSDATE, 'MM')SYSDATE is the current DATE.
    TRUNC (SYSDATE, 'MM') is the beginning of the current month. (Notice the condition above is less than this date, not equal to it.)
    ADD_MONTHS (STSDATE, -1) is a date exactly one month ago, therefore it is in the previous month.
    For the weekly report, instead of:
    Where Record_dt >=’01-dec-08’ and record_dt<=’07-dec-08’say
    Where   Record_dt >= TRUNC (SYSDATE - 7, 'IW')
    and     record_dt <  TRUNC (SYSDATE, 'IW')TRUNC (dt, 'IW') is the beginning of the ISO week (Monday-Sunday) that contains dt. Again, notice the end condition is strictly less than the beginning of the current week.

  • Sort+logical database using field group and extract

    Hi Folks,
    I have a program which is using Logical database concept and creating a file on application server as below.
    SORT BY
        reguh-zbukr                        "Zahlender Buchungskreis
        reguh-rzawe                        "Payment method
        reguh-ubnks                        "Bankland unserer Bank
        reguh-ubnky                        "Bankkey zur Übersortierung
        reguh-ubnkl                        "Bankleitzahl unserer Bank
        reguh-ubknt                        "Kontonummer bei unserer Bank
        payment_form                       "Brazil: CC, DOC or OP
        regud-xeinz                        "X - Lastschrift
        reguh-zbnks                        "Bankland Zahlungsempfänger
        reguh-zbnky                        "Bankkey zur Übersortierung
        reguh-zbnkl                        "Bankleitzahl Zahlungsempfänger
        reguh-zbnkn                        "Bank-Ktonummer Zahlungsempfänger
        reguh-lifnr                        "Kreditorennummer
        reguh-kunnr                        "Debitorennummer
        reguh-empfg                        "Zahlungsempfänger CPD
        reguh-vblnr                        "Zahlungsbelegnummer
        regup-belnr.  
    LOOP.
    AT NEW reguh-rzawe
    PERFORM store_on_file USING j_1bh1.
    ENDAT
    AT NEW reguh-ubnkl
    PERFORM store_on_file USING j_1bh2.
    ENDAT
    AT NEW reguh-ubnkt
    PERFORM store_on_file USING j_1bh2.
    ENDAT
    AT NEW VBLNR
    PERFORM store_on_file USING j_1bh3.
    AT DATEN
    PERFORM store_on_file USING j_1bh4.
    ENDAT.
    ENDLOOP.
    FORM store_on_file USING daten.
      IF hlp_temse CA par_dtyp.            "Temse
        PERFORM temse_schreiben USING daten.
      ELSE.
        TRANSFER daten TO g_name.
      ENDIF.
    ENDFORM.
    Is Sorting concept different when it comes to logical databases and field groups ?
    I had added a new field in the sort reguh-rzawe.I think due to that it is getting into AT NEW UBNKL and AT NEW UBKNT even though those details are same for the payment methods in the payment run.Even though the house bank number and account number is same for all the payment methods it is getting into AT NEW UBNKL and AT NEW UBKNT for every new payment method in the iteration.
    vblnr-1
    rzawe- A
    ubnkl-12345
    ubnkt-45678
    vblnr-2
    rzawe- A
    ubnkl-12345
    ubnkt-45678
    vblnr-3
    rzawe- B
    ubnkl-12345
    ubnkt-45678
    vblnr-4
    rzawe- B
    ubnkl-12345
    ubnkt-45678
    Can anyone here throw some light on this.
    Thanks,
    K.Kiran.

    Read the documentation for the at-new process.  As I recall the at-new considers the field named, and all the fields to the left of that in the table.  With that in mind, look at how your logic will work.  This could result in more, or fewer, breaks than intended(fewer if, for instance, a field to the left was deleted).

  • Logic Required in HR ABAP Program

    Hi,
    First i have to check the Change Date on Infotype 0000 Actions infotype (P0000-AEDTM).  If the change date falls within the Period Selection date specified then i have to include the employee in the report.
    the included fields are:
    P0000-AEDTM,P0001-BUKRS,PERNR,ENAME,P0000-MASSN,P0000-MASSG,P0000-BEGDA,P0001-ORGEH,P0001-PLANS,P0001-STELLP0001-ABKRS,P0001-WERKS,P0001-BTRTL,Q0001-MSTBR,Q0001-ENAME(supervisor name)
    If the change date (P0000-AEDTM) does not fall within the Period Selection Date, i have to check the Change Date in Infotype 0001 Organization Assignment infotype (P0001-AEDTM). If the change date falls within the Period Selection date specified then i have to include the employee in the report. Include in report only that information which has been changed from the previous Infotype 0001 record, except for Change Date, Company Code, Personnel Number and Name, which must always be included in the report.
    For this requirement i have written the below code:
    LOOP AT p0000 WHERE aedtm >= pn-begda AND
                          aedtm <= pn-endda.
       wa_final-massn = p0000-massn.
        wa_final-pernr = p0000-pernr.
        wa_final-aedtm = p0000-aedtm.
        wa_final-massg = p0000-massg.
        wa_final-begda = p0000-begda.
        wa_final-begda = p0000-begda.
        rp-provide-from-last p0001 space  p0000-begda p0000-endda.
        wa_final-bukrs = p0001-bukrs.
        wa_final-kostl = p0001-kostl.
        wa_final-mstbr = p0001-mstbr.
        wa_final-ename = p0001-ename.
        APPEND wa_final TO it_final.
        CLEAR wa_final.
    ENDLOOP.
    if sy-subrc ne 0.
    LOOP AT p0001 WHERE aedtm >= pn-begda AND
                            aedtm <= pn-endda.
          lv_endda = p0001-begda - 1.
          READ TABLE p0001 WITH KEY pernr = p0001-pernr endda = lv_endda INTO w0001.
          IF sy-subrc = 0.
          if p0001-kostl ne w0001-kostl.
            wa_final-kostl = p0001-kostl.
          endif.
         if p0001-mstbr ne w0001-mstbr.
            wa_final-mstbr = p0001-mstbr.
         endif.
          wa_final-pernr = p0001-pernr.
          wa_final-aedtm = p0001-aedtm.
          wa_final-bukrs = p0001-bukrs.
          wa_final-ename = p0001-ename.
           APPEND wa_final TO it_final.
           CLEAR wa_final.
          Endif.
    Endif..
    is this code correct? or do i have to do any modifications?

    This is like retro payroll run see the payroll program.
    RPCUCALC00 and you will find the logic over there how it will run retroactive payroll
    Best Regards

  • Reg logic required for selection-screen.

    Hi,
    i have one requirement
    on selection screen 2 radio button
    1 for service
    2 for account
    Parameter      FILE     LOCALFILE     Filename
    If the radiobutton ACCOUNT is selected the default name for file will be:
         ‘Rev_acc_com_&system_time_stamp&.dat’
    Elseif the radiobutton SERVICE is selected the default name for file will be:
         ‘Rev_srv_com_&system_time_stamp&.dat’
    some body can give the logic for this.

    take the following solution
    data: tstamp type TZNTSTMPS.
    data: filename type string.
    call function 'CONVERT_INTO_TIMESTAMP'
    exporting
       I_DATLO  = sy-datum
       I_TIMLO   = sy-uzeit
    importing
       E_TIMESTAMP = tstamp.
    if ACCOUNT is selected then
    concatenate 'Rev_srv_com_' tstamp '.dat' into filename.
    else if SERVICE is selected then
    concatenate 'Rev_srv_com_' tstamp '.dat' into filename.
    the filename variable will be containing ur required file name..
    reward points if useful....

Maybe you are looking for

  • Arrange Window Editing Questions

    I've been working on a recording for a few months now and I'm at the point of doing the vocal recording and comps. This means I'm at a point that involves a lot of editing, copying, pasting and moving. There are a few problems I've run up against tha

  • WIll not Display portal30.home

    I just installed Oracle 9i AS and it all seemed to work the I got a message that seemed to point to a problem with init.ora and require me to drop the portal30x users etc and run the config tool again. I did that and now get the following error: Plea

  • Using eMac keyboard with iMac help needed.

    I have an iMac from around 2009, at the weekend the keyboard stopped working and until I can afford a replacement a friend has given me an old eMac keyboard he had spare to use in the meantime (which could be a while). Just this morning I've realised

  • Frozen iPad screen; non responsive. MSG:  carrier settings update....choose not now or update.... Neither respond and iPad will not totally shut down...date

    MY husbands iPad screen is frozen. Will not shut down. Non responsive. Message:  Carrier settings update....choose Not Now or Update.... Completely frozen & non responsive.

  • BB8100 Error

    I have a BB 8100 and it has Device Software v4.2.0.73. On several applications ie: emobile today, Pub Checkers, Spider Solitare, Aces Majhong, Soduku, Tele Maps, Help, Medivial Kings Chess 2, Yahoo, Texas Hold'em King 2) I get an Error Starting $2dMo