Compute totals and subtotals with model clause

Please help,
I am using the model clause for the first time and need something like this, but no rule definition for every deptno:
SQL> select deptno, empno, ename, sal
  2    from emp
  3  model
  4    dimension by (deptno, empno, ename)
  5    measures(sal)
  6    rules (
  7       sal[10, null, 'ZZ-Sum'] = sum(sal)[10, any, any]
  8      ,sal[20, null, 'ZZ-Sum'] = sum(sal)[20, any, any]
  9      ,sal[30, null, 'ZZ-Sum'] = sum(sal)[30, any, any]
10      ,sal[null, null, 'ZZ-All'] = sum(sal)[any, any, 'ZZ-Sum']
11       )
12   order by deptno, empno, ename
13  /
    DEPTNO      EMPNO ENAME             SAL
        10       7782 CLARK            2450
        10       7839 KING             5000
        10       7934 MILLER           1300
        10            ZZ-Sum           8750
        20       7369 SMITH             800
        20       7566 JONES            2975
        20       7788 SCOTT            3000
        20       7876 ADAMS            1100
        20       7902 FORD             3000
        20            ZZ-Sum          10875
        30       7499 ALLEN            1600
        30       7521 WARD             1250
        30       7654 MARTIN           1250
        30       7698 BLAKE            2850
        30       7844 TURNER           1500
        30       7900 JAMES             950
        30            ZZ-Sum           9400
                      ZZ-All          29025
18 rows selected.Regards
eri

Many thanks to you! Your hint shows me, that in this case the model clause is not the right way to go.
The statement below fits exactly my requirements:
SQL> select
  2     g.deptno,
  3     e.empno,
  4     decode(g.grouping_empno,
  5        1, decode(g.deptno, null, 'All-Total:', 'Dept-Total:'),
  6           e.ename) emp_name,
  7     e.job, g.sum_sal salary
  8    from (select deptno, empno, grouping(empno) grouping_empno, sum(sal) sum_sal
  9            from emp
10           group by rollup(deptno, empno)
11           order by deptno, grouping(empno), empno) g, emp e
12   where g.empno = e.empno (+)
13  /
    DEPTNO      EMPNO EMP_NAME        JOB           SALARY
        10       7782 CLARK           MANAGER         2450
        10       7839 KING            PRESIDENT       5000
        10       7934 MILLER          CLERK           1300
        10            Dept-Total:                     8750
        20       7369 SMITH           CLERK            800
        20       7566 JONES           MANAGER         2975
        20       7788 SCOTT           ANALYST         3000
        20       7876 ADAMS           CLERK           1100
        20       7902 FORD            ANALYST         3000
        20            Dept-Total:                    10875
        30       7499 ALLEN           SALESMAN        1600
        30       7521 WARD            SALESMAN        1250
        30       7654 MARTIN          SALESMAN        1250
        30       7698 BLAKE           MANAGER         2850
        30       7844 TURNER          SALESMAN        1500
        30       7900 JAMES           CLERK            950
        30            Dept-Total:                     9400
                      All-Total:                     29025
18 rows selected.Regards
eri

Similar Messages

  • Totals and subtotals in blocked alv

    hi
    totals and subtotals for data type (CURR) fields is not coming in blocked alv report... Plz can u help us in this regard.. urgent.
    thnx in advance

    have a look on this
    REPORT  YMS_ALVBLOCKLIST.
    TABLES:LFA1,EKKO.
    SELECT-OPTIONS:LIFNR FOR LFA1-LIFNR.
    DATA:BEGIN OF ITAB OCCURS 0,
    LIFNR LIKE LFA1-LIFNR,
    NAME1 LIKE LFA1-NAME1,
    LAND1 LIKE LFA1-LAND1,
    ORT01 LIKE LFA1-ORT01,
    REGIO LIKE LFA1-REGIO,
    END OF ITAB.
    DATA:BEGIN OF JTAB OCCURS 0,
    LIFNR LIKE EKKO-LIFNR,
    EBELN LIKE EKKO-EBELN,
    BUKRS LIKE EKKO-BUKRS,
    BSTYP LIKE EKKO-BSTYP,
    EKORG LIKE EKKO-EKORG,
    BSART LIKE EKKO-BSART,
    END OF JTAB.
    SELECT * FROM LFA1 INTO CORRESPONDING FIELDS OF TABLE ITAB WHERE LIFNR
    IN LIFNR.
    SELECT * FROM EKKO INTO CORRESPONDING FIELDS OF TABLE JTAB WHERE LIFNR
    IN LIFNR.
    TYPE-POOLS:SLIS.
    DATA:LAYOUT TYPE slis_layout_alv.
    DATA:EVE TYPE slis_t_event WITH HEADER LINE.
    DATA:EVE1 TYPE slis_t_event WITH HEADER LINE.
    DATA:HEAD TYPE slis_t_listheader WITH HEADER LINE.
    DATA:FCAT TYPE slis_t_fieldcat_alv.
    DATA:FCAT1 TYPE slis_t_fieldcat_alv.
    LAYOUT-ZEBRA = 'X'.
    LAYOUT-colwidth_optimize = 'X'.
    LAYOUT-WINDOW_TITLEBAR = 'VENDOR DETAILS SCREEN'.
    EVE1-NAME = 'TOP_OF_PAGE'.
    EVE1-FORM = 'TOP_OF_PAGE1'.
    APPEND EVE1.
    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
    EXPORTING
    I_LIST_TYPE = 0
    IMPORTING
    ET_EVENTS = EVE[]
    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.
    READ TABLE EVE WITH KEY NAME = 'TOP_OF_PAGE'.
    EVE-FORM = 'TOP_OF_PAGE'.
    MODIFY EVE TRANSPORTING FORM WHERE NAME = 'TOP_OF_PAGE'.
    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_INIT'
    EXPORTING
    I_CALLBACK_PROGRAM = SY-REPID
    * I_CALLBACK_PF_STATUS_SET = ' '
    * I_CALLBACK_USER_COMMAND = ' '
    * IT_EXCLUDING =
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
    I_PROGRAM_NAME = SY-REPID
    I_INTERNAL_TABNAME = 'ITAB'
    * I_STRUCTURE_NAME =
    * I_CLIENT_NEVER_DISPLAY = 'X'
    I_INCLNAME = SY-REPID
    * I_BYPASSING_BUFFER =
    * I_BUFFER_ACTIVE =
    CHANGING
    CT_FIELDCAT = FCAT
    * EXCEPTIONS
    * INCONSISTENT_INTERFACE = 1
    * PROGRAM_ERROR = 2
    * OTHERS = 3
    IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
    EXPORTING
    IS_LAYOUT = LAYOUT
    IT_FIELDCAT = FCAT
    I_TABNAME = 'ITAB'
    IT_EVENTS = EVE[]
    * IT_SORT =
    * I_TEXT = ' '
    TABLES
    T_OUTTAB = ITAB
    * EXCEPTIONS
    * PROGRAM_ERROR = 1
    * MAXIMUM_OF_APPENDS_REACHED = 2
    * OTHERS = 3
    IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
    EXPORTING
    I_PROGRAM_NAME = SY-REPID
    I_INTERNAL_TABNAME = 'JTAB'
    * I_STRUCTURE_NAME =
    * I_CLIENT_NEVER_DISPLAY = 'X'
    I_INCLNAME = SY-REPID
    * I_BYPASSING_BUFFER =
    * I_BUFFER_ACTIVE =
    CHANGING
    CT_FIELDCAT = FCAT1
    * EXCEPTIONS
    * INCONSISTENT_INTERFACE = 1
    * PROGRAM_ERROR = 2
    * OTHERS = 3
    IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_APPEND'
    EXPORTING
    IS_LAYOUT = LAYOUT
    IT_FIELDCAT = FCAT1
    I_TABNAME = 'JTAB'
    IT_EVENTS = EVE1[]
    * IT_SORT =
    * I_TEXT = ' '
    TABLES
    T_OUTTAB = JTAB
    * EXCEPTIONS
    * PROGRAM_ERROR = 1
    * MAXIMUM_OF_APPENDS_REACHED = 2
    * OTHERS = 3
    IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    CALL FUNCTION 'REUSE_ALV_BLOCK_LIST_DISPLAY'
    * EXPORTING
    * I_INTERFACE_CHECK = ' '
    * IS_PRINT =
    * I_SCREEN_START_COLUMN = 0
    * I_SCREEN_START_LINE = 0
    * I_SCREEN_END_COLUMN = 0
    * I_SCREEN_END_LINE = 0
    * IMPORTING
    * E_EXIT_CAUSED_BY_CALLER =
    * ES_EXIT_CAUSED_BY_USER =
    * EXCEPTIONS
    * PROGRAM_ERROR = 1
    * OTHERS = 2
    IF SY-SUBRC <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    FORM TOP_OF_PAGE.
    REFRESH HEAD.
    HEAD-TYP = 'H'.
    HEAD-INFO = 'VENDORS DETAILS'.
    APPEND HEAD.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
    IT_LIST_COMMENTARY = HEAD[]
    * I_LOGO =
    * I_END_OF_LIST_GRID =
    ENDFORM.
    FORM TOP_OF_PAGE1.
    REFRESH HEAD.
    HEAD-TYP = 'H'.
    HEAD-INFO = 'PURCHASE DOCCUMENTS DETAILS'.
    APPEND HEAD.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
    IT_LIST_COMMENTARY = HEAD[]
    * I_LOGO =
    * I_END_OF_LIST_GRID =
    ENDFORM.

  • IN ALV HOW WE CAN TOTALS AND SUBTOTALS?

    HI EXPERTS?
    IN ALV HOW WE CAN TOTALS AND SUBTOTALS?

    Hi
    FOR DISPLAYING TOTALA AND SUBTOTALS IN ALV USE THIS:
    data: wa_fieldcat type slis_fieldcat_alv,
          it_fieldcat type slis_t_fieldcat_alv.
    data: wa_sort type slis_sortinfo_alv,
          it_sort type slis_t_sortinfo_alv.
    wa_fieldcat-do_sum = 'X'.
    append wa_fieldcat to it_fieldcat.
    wa_sort-fieldname = 'KUNNR'.
    wa_sort-tabname = 'IT_FINAL'.
    wa_sort-subtot = 'X'.
    append wa_sort to it_sort.
    AN EXAMPLE RELATED TO IT:
    This ALV program have all the basic report requirements such as page heading, page no, sub-total and a grand total.
    This is a basic ALV with the followings:-
    - Page Heading
    - Page No
    - Sub-Total
    - Grand Total
    REPORT ZALV.
    TYPE-POOLS: SLIS.
    DATA: G_REPID LIKE SY-REPID,
    GS_PRINT            TYPE SLIS_PRINT_ALV,
    GT_LIST_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER,
    GT_EVENTS           TYPE SLIS_T_EVENT,
    GT_SORT             TYPE SLIS_T_SORTINFO_ALV,
    GS_LAYOUT           TYPE SLIS_LAYOUT_ALV,
    GT_FIELDCAT         TYPE SLIS_T_FIELDCAT_ALV,
    FIELDCAT_LN LIKE LINE OF GT_FIELDCAT,
    COL_POS TYPE I.
    DATA: BEGIN OF ITAB,
      FIELD1(5) TYPE C,
      FIELD2(5) TYPE C,
      FIELD3(5) TYPE P DECIMALS 2,
    END OF ITAB.
    DATA: BEGIN OF ITAB1 OCCURS 0.
      INCLUDE STRUCTURE ITAB.
    DATA: END OF ITAB1.
    DATA: BEGIN OF ITAB_FIELDCAT OCCURS 0.
      INCLUDE STRUCTURE ITAB.
    DATA: END OF ITAB_FIELDCAT.
    Print Parameters
    PARAMETERS:
                P_PRINT  AS CHECKBOX DEFAULT ' ', "PRINT IMMEDIATE
                P_NOSINF AS CHECKBOX DEFAULT 'X', "NO SELECTION INFO
                P_NOCOVE AS CHECKBOX DEFAULT ' ', "NO COVER PAGE
                P_NONEWP AS CHECKBOX DEFAULT ' ', "NO NEW PAGE
                P_NOLINF AS CHECKBOX DEFAULT 'X', "NO PRINT LIST INFO
                P_RESERV TYPE I.                  "NO OF FOOTER LINE
    INITIALIZATION.
    G_REPID = SY-REPID.
    PERFORM PRINT_BUILD    USING GS_PRINT.      "Print PARAMETERS
    START-OF-SELECTION.
    TEST DATA
    MOVE 'TEST1' TO ITAB1-FIELD1.
    MOVE 'TEST1' TO ITAB1-FIELD2.
    MOVE '10.00' TO ITAB1-FIELD3.
    APPEND ITAB1.
    MOVE 'TEST2' TO ITAB1-FIELD1.
    MOVE 'TEST2' TO ITAB1-FIELD2.
    MOVE '20.00' TO ITAB1-FIELD3.
    APPEND ITAB1.
    DO 50 TIMES.
      APPEND ITAB1.
    ENDDO.
    END-OF-SELECTION.
    PERFORM BUILD.
    PERFORM EVENTTAB_BUILD CHANGING GT_EVENTS.
    PERFORM COMMENT_BUILD  CHANGING GT_LIST_TOP_OF_PAGE.
    PERFORM CALL_ALV.
    FORM BUILD.
    DATA FIELD CATALOG
    Explain Field Description to ALV
    DATA: FIELDCAT_IN TYPE SLIS_FIELDCAT_ALV.
    CLEAR FIELDCAT_IN.
    FIELDCAT_LN-FIELDNAME = 'FIELD1'.
    FIELDCAT_LN-TABNAME   = 'ITAB1'.
    *FIELDCAT_LN-NO_OUT    = 'X'.  "FIELD NOT DISPLAY, CHOOSE FROM LAYOUT
    FIELDCAT_LN-KEY       = ' '.   "SUBTOTAL KEY
    FIELDCAT_LN-NO_OUT    = ' '.
    FIELDCAT_LN-SELTEXT_L = 'HEAD1'.
    APPEND FIELDCAT_LN TO GT_FIELDCAT.
    CLEAR FIELDCAT_IN.
    FIELDCAT_LN-FIELDNAME = 'FIELD2'.
    FIELDCAT_LN-TABNAME   = 'ITAB1'.
    FIELDCAT_LN-NO_OUT    = 'X'.
    FIELDCAT_LN-SELTEXT_L = 'HEAD2'.
    APPEND FIELDCAT_LN TO GT_FIELDCAT.
    CLEAR FIELDCAT_IN.
    FIELDCAT_LN-FIELDNAME     = 'FIELD3'.
    FIELDCAT_LN-TABNAME       = 'ITAB1'.
    FIELDCAT_LN-REF_FIELDNAME = 'MENGE'. "<- REF FIELD IN THE DICTIONNARY
    FIELDCAT_LN-REF_TABNAME   = 'MSEG'.  "<- REF TABLE IN THE DICTIONNARY
    FIELDCAT_LN-NO_OUT        = ' '.
    FIELDCAT_LN-DO_SUM        = 'X'.   "SUM UPON DISPLAY
    APPEND FIELDCAT_LN TO GT_FIELDCAT.
    DATA SORTING AND SUBTOTAL
    DATA: GS_SORT TYPE SLIS_SORTINFO_ALV.
    CLEAR GS_SORT.
    GS_SORT-FIELDNAME = 'FIELD1'.
    GS_SORT-SPOS      = 1.
    GS_SORT-UP        = 'X'.
    GS_SORT-SUBTOT    = 'X'.
    APPEND GS_SORT TO GT_SORT.
    CLEAR GS_SORT.
    GS_SORT-FIELDNAME = 'FIELD2'.
    GS_SORT-SPOS      = 2.
    GS_SORT-UP        = 'X'.
    *GS_SORT-SUBTOT    = 'X'.
    APPEND GS_SORT TO GT_SORT.
    ENDFORM.
    FORM CALL_ALV.
    ABAP List Viewer
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
    I_INTERFACE_CHECK = ' '
    I_BYPASSING_BUFFER =
    I_BUFFER_ACTIVE = ' '
    I_CALLBACK_PROGRAM = G_REPID
    I_CALLBACK_PF_STATUS_SET = ' '
    I_CALLBACK_USER_COMMAND = ' '
    I_STRUCTURE_NAME = 'ITAB1'
    IS_LAYOUT =  GS_LAYOUT
    IT_FIELDCAT = GT_FIELDCAT[]
    IT_EXCLUDING =
    IT_SPECIAL_GROUPS =
      IT_SORT = GT_SORT[]
    IT_FILTER =
    IS_SEL_HIDE =
    I_DEFAULT = 'X'
    I_SAVE = ' '
    IS_VARIANT =
      IT_EVENTS = GT_EVENTS[]
    IT_EVENT_EXIT =
      IS_PRINT = GS_PRINT
    IS_REPREP_ID =
    I_SCREEN_START_COLUMN = 0
    I_SCREEN_START_LINE = 0
    I_SCREEN_END_COLUMN = 0
    I_SCREEN_END_LINE = 0
    IMPORTING
    E_EXIT_CAUSED_BY_CALLER =
    ES_EXIT_CAUSED_BY_USER =
    TABLES
    T_OUTTAB = ITAB1
    EXCEPTIONS
    PROGRAM_ERROR = 1
    OTHERS = 2.
    ENDFORM.
    HEADER FORM
    FORM EVENTTAB_BUILD CHANGING LT_EVENTS TYPE SLIS_T_EVENT.
    CONSTANTS:
    GC_FORMNAME_TOP_OF_PAGE TYPE SLIS_FORMNAME VALUE 'TOP_OF_PAGE'.
    *GC_FORMNAME_END_OF_PAGE TYPE SLIS_FORMNAME VALUE 'END_OF_PAGE'.
      DATA: LS_EVENT TYPE SLIS_ALV_EVENT.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
           EXPORTING
                I_LIST_TYPE = 0
           IMPORTING
                ET_EVENTS   = LT_EVENTS.
      READ TABLE LT_EVENTS WITH KEY NAME =  SLIS_EV_TOP_OF_PAGE
                               INTO LS_EVENT.
      IF SY-SUBRC = 0.
        MOVE GC_FORMNAME_TOP_OF_PAGE TO LS_EVENT-FORM.
        APPEND LS_EVENT TO LT_EVENTS.
      ENDIF.
    define END_OF_PAGE event
    READ TABLE LT_EVENTS WITH KEY NAME =  SLIS_EV_END_OF_PAGE
                             INTO LS_EVENT.
    IF SY-SUBRC = 0.
      MOVE GC_FORMNAME_END_OF_PAGE TO LS_EVENT-FORM.
      APPEND LS_EVENT TO LT_EVENTS.
    ENDIF.
    ENDFORM.
    FORM COMMENT_BUILD CHANGING GT_TOP_OF_PAGE TYPE SLIS_T_LISTHEADER.
      DATA: GS_LINE TYPE SLIS_LISTHEADER.
      CLEAR GS_LINE.
      GS_LINE-TYP  = 'H'.
      GS_LINE-INFO = 'HEADER 1'.
      APPEND GS_LINE TO GT_TOP_OF_PAGE.
      CLEAR GS_LINE.
      GS_LINE-TYP  = 'S'.
      GS_LINE-KEY  = 'STATUS 1'.
      GS_LINE-INFO = 'INFO 1'.
      APPEND GS_LINE TO GT_TOP_OF_PAGE.
      GS_LINE-KEY  = 'STATUS 2'.
      GS_LINE-INFO = 'INFO 2'.
      APPEND GS_LINE TO GT_TOP_OF_PAGE.
    CLEAR GS_LINE.
    GS_LINE-TYP  = 'A'.
    GS_LINE-INFO = 'ACTION'.
    APPEND GS_LINE TO  GT_TOP_OF_PAGE.
    ENDFORM.
    FORM TOP_OF_PAGE.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
           EXPORTING
                IT_LIST_COMMENTARY = GT_LIST_TOP_OF_PAGE.
      WRITE: SY-DATUM, 'Page No', SY-PAGNO LEFT-JUSTIFIED.
    ENDFORM.
    FORM END_OF_PAGE.
      WRITE at (sy-linsz) sy-pagno CENTERED.
    ENDFORM.
    PRINT SETTINGS
    FORM PRINT_BUILD USING LS_PRINT TYPE SLIS_PRINT_ALV.
      LS_PRINT-PRINT              = P_PRINT.  "PRINT IMMEDIATE
      LS_PRINT-NO_PRINT_SELINFOS  = P_NOSINF. "NO SELECTION INFO
      LS_PRINT-NO_COVERPAGE       = P_NOCOVE. "NO COVER PAGE
      LS_PRINT-NO_NEW_PAGE        = P_NONEWP.
      LS_PRINT-NO_PRINT_LISTINFOS = P_NOLINF. "NO PRINT LIST INFO
      LS_PRINT-RESERVE_LINES      = P_RESERV.
    ENDFORM.
    thnx
    Sravani
    Plz reward if useful

  • ALV Totals and Subtotals line in the output

    Hi!
       I want to display an ALV report in which there should be totals and subtotals buttons are to be displayed without displaying the totals and subtotals line when the list is displayed. It should be displayed only when the user clicks the button. If i take do_sum in the fieldcat table it'll display the subtotal button and also the totlas line and that shouldn't happen. If i take no_totalline in the layout it'll not display the totals line even the user selects the totals button. So is there any possibility like this. Please help me.
    Thanks & Regards,
    Swathi

    Hi Swathi,
              Have a look at these good links-
    <b>Add subtotals</b>
    http://www.sapfans.com/forums/viewtopic.php?t=20386
    http://www.sapfans.com/forums/viewtopic.php?t=85191
    http://www.sapfans.com/forums/viewtopic.php?t=88401
    http://www.sapfans.com/forums/viewtopic.php?t=17335
    You can also search for the same in the below links-
    www.sap-img.com
    www.sapfans.com
    www.sapgenie.com
    Reward points if you find the links useful.
    Regards,
    Tanuja.

  • How to write code  for totals and subtotals in alv programing?

    how to write code  for totals and subtotals in alv programing?

    hi,
    1. <u><b>TOTAL.</b></u>
    http://www.sapdevelopment.co.uk/reporting/alv/alvgrid_basic.htm
    2. <u><b>How do I add subtotals</b></u>
    http://www.sapfans.com/forums/viewtopic.php?t=20386
    http://www.sapfans.com/forums/viewtopic.php?t=85191
    http://www.sapfans.com/forums/viewtopic.php?t=88401
    http://www.sapfans.com/forums/viewtopic.php?t=17335
    Regards
    Anver

  • My old computer crashed, and down with it went my itunes library. How do I get my old library into my new library (on my new mac) ?

    My old computer crashed, and down with it went my itunes library. How do I get my old library into my new library (on my new mac) ?

    did you back up your music to another hard drive? if not, the only music you can get back is purchased music from i tunes. 

  • Query help with Model clause

    Hi Gurus,
    Can someone please help me out.
    I've a below tables.
    1) tbl_link --> this table contains information at profile level
    2) tbl_summary --> this table contains summary at parent profile level derived from tbl_link table
    One parent profile contains multiple child profiles and each child profile links to a code (which is B, W, G or P) and the code is linked to a category (i.e. ONL and OFL). In this case code B is linked to category 'ONL' and codes W,G,P linked to OFL category.
    ONL category needs 100 points. If it don't have enough points then i need to borrow from OFL category which i'm doing and populating into tbl_summary table at parent profile level.
    Now i need to insert data into tbl_link table at profile level with howmany points used, expired based on tbl_summary table. Rule is at the end of month if we add points for each profile in tbl_link table it should come as 0.
    with
    tbl_SUMMARY as
    select 1 as ppid,'ONL' as catgcode, 53 as earned_points,47 BORROWED_POINTS,100 CERT_POINTS,0 DISCARD_POINTS,100 used from dual
    union
    select 1 as ppid,'OFL' as catgcode, 223 as earned_points,0 BORROWED_POINTS,176 CERT_POINTS,76 DISCARD_POINTS,100 used from dual
    union
    select 2 as ppid,'ONL' as catgcode, 39 as earned_points,61 BORROWED_POINTS,100 CERT_POINTS,0 DISCARD_POINTS,100 used from dual
    union
    select 2 as ppid,'OFL' as catgcode, 90 as earned_points,0 BORROWED_POINTS,29 CERT_POINTS,29 DISCARD_POINTS,100 used from dual
    union
    select 3 as ppid,'ONL' as catgcode, 109 as earned_points,0 BORROWED_POINTS,109 CERT_POINTS,9 DISCARD_POINTS,100 used from dual
    union
    select 3 as ppid,'OFL' as catgcode, 223 as earned_points,0 BORROWED_POINTS,223 CERT_POINTS,23 DISCARD_POINTS,200 used from dual
    union
    select 4 as ppid,'ONL' as catgcode, 109 as earned_points,0 BORROWED_POINTS,109 CERT_POINTS,9 DISCARD_POINTS,100 used from dual
    union
    select 4 as ppid,'OFL' as catgcode, 169 as earned_points,0 BORROWED_POINTS,169 CERT_POINTS,69 DISCARD_POINTS,100 used from dual
    tbl_link as
    select 1 as ppid,1 as pid, 'B' as code,'ONL' as catgcode, 53 as earned_points from dual
    union
    select 1 as ppid,12 as pid, 'W' as code,'OFL' as catgcode, 26 as earned_points from dual
    union
    select 1 as ppid,13 as pid, 'G' as code,'OFL' as catgcode, 87 as earned_points from dual
    union
    select 1 as ppid,14 as pid, 'P' as code,'OFL' as catgcode, 110 as earned_points from dual
    union
    select 2 as ppid,2 as pid, 'B' as code,'ONL' as catgcode, 39 as earned_points from dual
    union
    select 2 as ppid,22 as pid, 'W' ,'OFL' as catgcode, 30 as earned_points from dual
    union
    select 2 as ppid,23 as pid, 'G' ,'OFL' as catgcode, 29 as earned_points from dual
    union
    select 2 as ppid,24 as pid, 'P' ,'OFL' as catgcode, 31 as earned_points from dual
    union
    select 3 as ppid,3 as pid, 'B' as code,'ONL' as tier_catgcode, 109 as earned_points from dual
    union
    select 3 as ppid,32 as pid, 'W' ,'OFL' , 26 as earned_points from dual
    union
    select 3 as ppid,33 as pid, 'G' ,'OFL', 87 as earned_points from dual
    union
    select 3 as ppid,34 as pid, 'P' ,'OFL' , 110 as earned_points from dual
    union
    select 4 as ppid,4 as pid, 'B' as code,'ONL' as catgcode, 109 as earned_points from dual
    union
    select 4 as ppid,42 as pid, 'W' as code,'OFL' , 26 as earned_points from dual
    union
    select 4 as ppid,43 as pid, 'G' as code,'OFL' , 87 as earned_points from dual
    union
    select 4 as ppid,44 as pid, 'P' as code,'OFL' , 56 as earned_points from dual
    final (PARENT_PROFILE_ID,PROFILE_ID,catgcode,EARNED_POINTS,BORROWED_POINTS,CERT_POINTS,DISCARD_POINTS,USED)
    as (
    select A.PPID PARENT_PROFILE_ID,B.PID PROFILE_ID,A.catgcode,B.EARNED_POINTS,BORROWED_POINTS,CERT_POINTS,DISCARD_POINTS,USED
    from tbl_SUMMARY a,tbl_link b where a.ppid=b.ppid AND A.catgcode=B.catgcode
    ORDER BY PROFILE_ID
    select * from final order by 1;
    PARENT_PROFILE_ID  PROFILE_ID  CATGCODE  EARNED_POINTS  BORROWED_POINTS  CERT_POINTS  DISCARD_POINTS  USED
    1                  1           ONL       53             47               100          0               100
    1                  14          OFL       110            0                176          76              100
    1                  13          OFL       87             0                176          76              100
    1                  12          OFL       26             0                176          76              100
    2                  2           ONL       39             61               100          0               100
    2                  24          OFL       31             0                29           29              100
    2                  23          OFL       29             0                29           29              100
    2                  22          OFL       30             0                29           29              100
    3                  32          OFL       26             0                223          23              200
    3                  33          OFL       87             0                223          23              200
    3                  34          OFL       110            0                223          23              200
    3                  3           ONL       109            0                109          9               100
    4                  42          OFL       26             0                169          69              100
    4                  43          OFL       87             0                169          69              100
    4                  44          OFL       56             0                169          69              100
    4                  4           ONL       109            0                109          9               100
    Need Output as below :
    For parent profile 1, whatever i mentioned above is not correct. Borrowed 47 points from OFL to ONL to make ONL and also from OFL category has 176 points remaining after lending to ONL and using only 100 points, remaining 76 points are discarded. Need to deduct these 76 points also from child profiles. Output will be as below.
    PARENT_PROFILE_ID  PROFILE_ID  CATGCODE  EARNED_POINTS  BORROWED_POINTS  CERT_POINTS  DISCARD_POINTS  USED  BURN_PTS  EXPIRE_PTS
    1                  1           ONL       53             47               100          0               100   -53       0
    1                  12          OFL       26             0                176          76              100   -26       0
    1                  13          OFL       87             0                176          76              100   -74       -13
    1                  14          OFL       110            0                176          76              100   -47       -63
    For parent profile id 2 --> ONL category has 39 points, so borrowed 61 points from OFL category to make ONL points 100.
                                Now need to populate tbl_link table at child profile level (i.e. child profiles 22,23,24).
    Borrowed 61 points from OFL and need to deduct this points from the profile which has highest earned points, in this case deduct from profile 24 which has 31 points, from profile 22 which has 30 points. Need output like below
    PARENT_PROFILE_ID  PROFILE_ID  CATGCODE  EARNED_POINTS  BORROWED_POINTS  CERT_POINTS  DISCARD_POINTS  USED  BURN_PTS  EXPIRE_PTS
    2                  2           ONL       39             61               100          0               100   -39       0
    2                  22          OFL       30             0                29           29              100   -30       0
    2                  23          OFL       29             0                29           29              100   0         -29
    2                  24          OFL       31             0                29           29              100   -31       0
    For parent profile id 3 --> ONL category has 109 points, so no need to borrow points from OFL category
                                Now need to populate tbl_link table at child profile level (i.e. child profiles 32,33,34).
    in this case ONL has 100 points, so move the remaining 9 points will be expired. OFL category has 223 points total. need only 200 points (i.e. mutiple of 100) for our process, 23 points will be expired and has to deduct from the profile which has highest earned points, in this case from profile 34. Output :
    PARENT_PROFILE_ID  PROFILE_ID  CATGCODE  EARNED_POINTS  BORROWED_POINTS  CERT_POINTS  DISCARD_POINTS  USED  BURN_PTS  EXPIRE_PTS
    3                  3           ONL       109            0                109          9               100   -100      -9
    3                  32          OFL       26             0                223          23              200   -26       0
    3                  33          OFL       87             0                223          23              200   -87       0
    3                  34          OFL       110            0                223          23              200   -87       -23
    For parent profile id 4 --> ONL category has 109 points, so no need to borrow points from OFL category
                                Now need to populate tbl_link table at child profile level (i.e. child profiles 42,43,44).
    in this case ONL has 100 points, so move the remaining 9 points will be expired. OFL category has 169 points total. need only 100 points (i.e. mutiple of 100) for our process, 69 points will be expired and has to deduct from the profile which has highest earned points, in this case from profile 43. Output :
    PARENT_PROFILE_ID  PROFILE_ID  CATGCODE  EARNED_POINTS  BORROWED_POINTS  CERT_POINTS  DISCARD_POINTS  USED  BURN_PTS  EXPIRE_PTS
    4                  4           ONL       109            0                109          9               100   100       9
    4                  42          OFL       26             0                169          69              100   -26       0
    4                  43          OFL       87             0                169          69              100   -18       -69
    4                  44          OFL       56             0                169          69              100   -56       0
    Can someone help with the query. I googled about looping in sql and came to know that Oracle has a feature MODEL to loop in SQL, but i don't have idea on using MODEL clause.
    Appreciate your help!
    Thanks
    Sri

    Hi Gurus,
    Can someone please help me out.
    I've a below tables.
    1) tbl_link --> this table contains information at profile level
    2) tbl_summary --> this table contains summary at parent profile level derived from tbl_link table
    One parent profile contains multiple child profiles and each child profile links to a code (which is B, W, G or P) and the code is linked to a category (i.e. ONL and OFL). In this case code B is linked to category 'ONL' and codes W,G,P linked to OFL category.
    ONL category needs 100 points. If it don't have enough points then i need to borrow from OFL category which i'm doing and populating into tbl_summary table at parent profile level.
    Now i need to insert data into tbl_link table at profile level with howmany points used, expired based on tbl_summary table. Rule is at the end of month if we add points for each profile in tbl_link table it should come as 0.
    with
    tbl_SUMMARY as
    select 1 as ppid,'ONL' as catgcode, 53 as earned_points,47 BORROWED_POINTS,100 CERT_POINTS,0 DISCARD_POINTS,100 used from dual
    union
    select 1 as ppid,'OFL' as catgcode, 223 as earned_points,0 BORROWED_POINTS,176 CERT_POINTS,76 DISCARD_POINTS,100 used from dual
    union
    select 2 as ppid,'ONL' as catgcode, 39 as earned_points,61 BORROWED_POINTS,100 CERT_POINTS,0 DISCARD_POINTS,100 used from dual
    union
    select 2 as ppid,'OFL' as catgcode, 90 as earned_points,0 BORROWED_POINTS,29 CERT_POINTS,29 DISCARD_POINTS,100 used from dual
    union
    select 3 as ppid,'ONL' as catgcode, 109 as earned_points,0 BORROWED_POINTS,109 CERT_POINTS,9 DISCARD_POINTS,100 used from dual
    union
    select 3 as ppid,'OFL' as catgcode, 223 as earned_points,0 BORROWED_POINTS,223 CERT_POINTS,23 DISCARD_POINTS,200 used from dual
    union
    select 4 as ppid,'ONL' as catgcode, 109 as earned_points,0 BORROWED_POINTS,109 CERT_POINTS,9 DISCARD_POINTS,100 used from dual
    union
    select 4 as ppid,'OFL' as catgcode, 169 as earned_points,0 BORROWED_POINTS,169 CERT_POINTS,69 DISCARD_POINTS,100 used from dual
    tbl_link as
    select 1 as ppid,1 as pid, 'B' as code,'ONL' as catgcode, 53 as earned_points from dual
    union
    select 1 as ppid,12 as pid, 'W' as code,'OFL' as catgcode, 26 as earned_points from dual
    union
    select 1 as ppid,13 as pid, 'G' as code,'OFL' as catgcode, 87 as earned_points from dual
    union
    select 1 as ppid,14 as pid, 'P' as code,'OFL' as catgcode, 110 as earned_points from dual
    union
    select 2 as ppid,2 as pid, 'B' as code,'ONL' as catgcode, 39 as earned_points from dual
    union
    select 2 as ppid,22 as pid, 'W' ,'OFL' as catgcode, 30 as earned_points from dual
    union
    select 2 as ppid,23 as pid, 'G' ,'OFL' as catgcode, 29 as earned_points from dual
    union
    select 2 as ppid,24 as pid, 'P' ,'OFL' as catgcode, 31 as earned_points from dual
    union
    select 3 as ppid,3 as pid, 'B' as code,'ONL' as tier_catgcode, 109 as earned_points from dual
    union
    select 3 as ppid,32 as pid, 'W' ,'OFL' , 26 as earned_points from dual
    union
    select 3 as ppid,33 as pid, 'G' ,'OFL', 87 as earned_points from dual
    union
    select 3 as ppid,34 as pid, 'P' ,'OFL' , 110 as earned_points from dual
    union
    select 4 as ppid,4 as pid, 'B' as code,'ONL' as catgcode, 109 as earned_points from dual
    union
    select 4 as ppid,42 as pid, 'W' as code,'OFL' , 26 as earned_points from dual
    union
    select 4 as ppid,43 as pid, 'G' as code,'OFL' , 87 as earned_points from dual
    union
    select 4 as ppid,44 as pid, 'P' as code,'OFL' , 56 as earned_points from dual
    final (PARENT_PROFILE_ID,PROFILE_ID,catgcode,EARNED_POINTS,BORROWED_POINTS,CERT_POINTS,DISCARD_POINTS,USED)
    as (
    select A.PPID PARENT_PROFILE_ID,B.PID PROFILE_ID,A.catgcode,B.EARNED_POINTS,BORROWED_POINTS,CERT_POINTS,DISCARD_POINTS,USED
    from tbl_SUMMARY a,tbl_link b where a.ppid=b.ppid AND A.catgcode=B.catgcode
    ORDER BY PROFILE_ID
    select * from final order by 1;
    PARENT_PROFILE_ID  PROFILE_ID  CATGCODE  EARNED_POINTS  BORROWED_POINTS  CERT_POINTS  DISCARD_POINTS  USED
    1                  1           ONL       53             47               100          0               100
    1                  14          OFL       110            0                176          76              100
    1                  13          OFL       87             0                176          76              100
    1                  12          OFL       26             0                176          76              100
    2                  2           ONL       39             61               100          0               100
    2                  24          OFL       31             0                29           29              100
    2                  23          OFL       29             0                29           29              100
    2                  22          OFL       30             0                29           29              100
    3                  32          OFL       26             0                223          23              200
    3                  33          OFL       87             0                223          23              200
    3                  34          OFL       110            0                223          23              200
    3                  3           ONL       109            0                109          9               100
    4                  42          OFL       26             0                169          69              100
    4                  43          OFL       87             0                169          69              100
    4                  44          OFL       56             0                169          69              100
    4                  4           ONL       109            0                109          9               100
    Need Output as below :
    For parent profile 1, whatever i mentioned above is not correct. Borrowed 47 points from OFL to ONL to make ONL and also from OFL category has 176 points remaining after lending to ONL and using only 100 points, remaining 76 points are discarded. Need to deduct these 76 points also from child profiles. Output will be as below.
    PARENT_PROFILE_ID  PROFILE_ID  CATGCODE  EARNED_POINTS  BORROWED_POINTS  CERT_POINTS  DISCARD_POINTS  USED  BURN_PTS  EXPIRE_PTS
    1                  1           ONL       53             47               100          0               100   -53       0
    1                  12          OFL       26             0                176          76              100   -26       0
    1                  13          OFL       87             0                176          76              100   -74       -13
    1                  14          OFL       110            0                176          76              100   -47       -63
    For parent profile id 2 --> ONL category has 39 points, so borrowed 61 points from OFL category to make ONL points 100.
                                Now need to populate tbl_link table at child profile level (i.e. child profiles 22,23,24).
    Borrowed 61 points from OFL and need to deduct this points from the profile which has highest earned points, in this case deduct from profile 24 which has 31 points, from profile 22 which has 30 points. Need output like below
    PARENT_PROFILE_ID  PROFILE_ID  CATGCODE  EARNED_POINTS  BORROWED_POINTS  CERT_POINTS  DISCARD_POINTS  USED  BURN_PTS  EXPIRE_PTS
    2                  2           ONL       39             61               100          0               100   -39       0
    2                  22          OFL       30             0                29           29              100   -30       0
    2                  23          OFL       29             0                29           29              100   0         -29
    2                  24          OFL       31             0                29           29              100   -31       0
    For parent profile id 3 --> ONL category has 109 points, so no need to borrow points from OFL category
                                Now need to populate tbl_link table at child profile level (i.e. child profiles 32,33,34).
    in this case ONL has 100 points, so move the remaining 9 points will be expired. OFL category has 223 points total. need only 200 points (i.e. mutiple of 100) for our process, 23 points will be expired and has to deduct from the profile which has highest earned points, in this case from profile 34. Output :
    PARENT_PROFILE_ID  PROFILE_ID  CATGCODE  EARNED_POINTS  BORROWED_POINTS  CERT_POINTS  DISCARD_POINTS  USED  BURN_PTS  EXPIRE_PTS
    3                  3           ONL       109            0                109          9               100   -100      -9
    3                  32          OFL       26             0                223          23              200   -26       0
    3                  33          OFL       87             0                223          23              200   -87       0
    3                  34          OFL       110            0                223          23              200   -87       -23
    For parent profile id 4 --> ONL category has 109 points, so no need to borrow points from OFL category
                                Now need to populate tbl_link table at child profile level (i.e. child profiles 42,43,44).
    in this case ONL has 100 points, so move the remaining 9 points will be expired. OFL category has 169 points total. need only 100 points (i.e. mutiple of 100) for our process, 69 points will be expired and has to deduct from the profile which has highest earned points, in this case from profile 43. Output :
    PARENT_PROFILE_ID  PROFILE_ID  CATGCODE  EARNED_POINTS  BORROWED_POINTS  CERT_POINTS  DISCARD_POINTS  USED  BURN_PTS  EXPIRE_PTS
    4                  4           ONL       109            0                109          9               100   100       9
    4                  42          OFL       26             0                169          69              100   -26       0
    4                  43          OFL       87             0                169          69              100   -18       -69
    4                  44          OFL       56             0                169          69              100   -56       0
    Can someone help with the query. I googled about looping in sql and came to know that Oracle has a feature MODEL to loop in SQL, but i don't have idea on using MODEL clause.
    Appreciate your help!
    Thanks
    Sri

  • Using the Case clause with Model clause

    Hello PL SQL gurus
    I've used some scripts I've found on these forums to create a mortgage amortization statement. What I am trying to accomplish is getting the script to run a calculation or use a value within a table based upon the value in that table.
    Here are the two tables:
    CREATE TABLE mortgage_facts (customer VARCHAR2(20), fact VARCHAR2(20),
    amount NUMBER(10,3));
    INSERT INTO mortgage_facts VALUES ('Smith', 'Loan', 131828.81);
    INSERT INTO mortgage_facts VALUES ('Smith', 'Annual_Interest', 3.348);
    INSERT INTO mortgage_facts VALUES ('Smith', 'Payments', 72);
    INSERT INTO mortgage_facts VALUES ('Smith', 'PaymentAmt', 0);
    CREATE TABLE mortgage (customer VARCHAR2(20), pmt_num NUMBER(4), principalp NUMBER(10,3), interestp NUMBER(10,3), mort_balance NUMBER(10,3));
    INSERT INTO mortgage VALUES ('Smith',0, 0, 0, 131828.81);
    If the value within the table mortgage_facts is zero, I want the script to run a calculation to be used in a MODEL clause. If it is not zero, I would like to use that value instead of the calculation. Below is the script that I am getting an error on (I have bolded the portion in question):
    SELECT c, p, to_char(round(m,2),'fm$9999999.00') principal_balance,
    to_char(round(pp,2),'fm$9999999.00') towards_principal,
    to_char(round(ip,2),'fm$9999999.00') towards_interest,
    to_char(round(mp,2),'fm$9999999.00') monthly_payment
    FROM MORTGAGE
    MODEL --See 1
    IGNORE NAV
    REFERENCE R ON
    *(SELECT customer, fact, amt --See 2*
    FROM mortgage_facts
    *MODEL DIMENSION BY (customer, fact) MEASURES (amount amt)          --See 3*
    RULES SEQUENTIAL ORDER
    CASE WHEN mortgage_facts.fact = 'PaymentAmt' AND mortage_facts.amt = 0 THEN
    *amt[ANY, 'PaymentAmt'] = mortgage_facts.amt*
    ELSE
    *amt[any, 'PaymentAmt']= (amt[CV(),'Loan']**
    *Power(1+ (amt[CV(),'Annual_Interest']/100/12),*
    *amt[CV(),'Payments']) **
    *(amt[CV(),'Annual_Interest']/100/12)) /*
    *(Power(1+(amt[CV(),'Annual_Interest']/100/12),*
    *amt[CV(),'Payments']) - 1)*
    END
    DIMENSION BY (customer cust, fact) measures (amt)
    MAIN amortization
    PARTITION BY (customer c)
    DIMENSION BY (0 p)
    MEASURES (principalp pp, interestp ip, mort_balance m, customer mc, 0 mp )
    RULES SEQUENTIAL ORDER
    ITERATE(1000) UNTIL (ITERATION_NUMBER+1 =
    r.amt[mc[0],'Payments'])
    (ip[ITERATION_NUMBER+1] = m[CV()-1] *
    r.amt[mc[0], 'Annual_Interest']/1200,
    mp[ITERATION_NUMBER+1] = r.amt[mc[0], 'PaymentAmt'],
    pp[ITERATION_NUMBER+1] = r.amt[mc[0], 'PaymentAmt'] - ip[CV()],
    m[ITERATION_NUMBER+1] = m[CV()-1] - pp[CV()]
    ORDER BY c, p
    Any help is much appreciated. Thank you!!

    Ok, here we go, one way with iterative model:
    select *
    from mortgage_facts
    model
    partition by (Customer)
    dimension by (1 p)
    measures(loan, payments, INTEREST, PAYMENTAMT, INTERESTPMT, PRINCIPALPMT, balance)
    rules iterate(1e9) until (iteration_number+2 >= payments[1])
    (loan[iteration_number+2]=loan[1]
    ,payments[iteration_number+2]=cv(p)-1
    ,interest[iteration_number+2]=interest[1]
    ,paymentamt[iteration_number+2]=ROUND(
      (LOAN[1] * (INTEREST[1]/12/100)*Power((1+INTEREST[1]/12/100), PAYMENTS[1])/(Power((1+INTEREST[1]/12/100),PAYMENTS[1])-1)), 2)
    ,INTERESTPMT[iteration_number+2]=round(balance[cv(p)-1]*interest[1]/1200, 2)
    ,PRINCIPALPMT[iteration_number+2]=paymentamt[cv()]-INTERESTPMT[cv()]
    ,balance[iteration_number+2]=balance[cv()-1]-PRINCIPALPMT[cv()]
    CUSTOMER     P     LOAN     PAYMENTS     INTEREST     PAYMENTAMT     INTERESTPMT     PRINCIPALPMT     BALANCE
    Smith     1     131828.81     72     3.348     0     0     0     131828.81
    Smith     2     131828.81     1     3.348     2023.55     367.8     1655.75     130173.06
    Smith     3     131828.81     2     3.348     2023.55     363.18     1660.37     128512.69
    Smith     4     131828.81     3     3.348     2023.55     358.55     1665     126847.69
    Smith     5     131828.81     4     3.348     2023.55     353.91     1669.64     125178.05
    Smith     6     131828.81     5     3.348     2023.55     349.25     1674.3     123503.75
    Smith     7     131828.81     6     3.348     2023.55     344.58     1678.97     121824.78
    Smith     8     131828.81     7     3.348     2023.55     339.89     1683.66     120141.12
    Smith     9     131828.81     8     3.348     2023.55     335.19     1688.36     118452.76
    Smith     10     131828.81     9     3.348     2023.55     330.48     1693.07     116759.69
    Smith     11     131828.81     10     3.348     2023.55     325.76     1697.79     115061.9
    Smith     12     131828.81     11     3.348     2023.55     321.02     1702.53     113359.37
    Smith     13     131828.81     12     3.348     2023.55     316.27     1707.28     111652.09
    Smith     14     131828.81     13     3.348     2023.55     311.51     1712.04     109940.05
    ....

  • I want to wipe my computer clean and start with a new installation of Lion

    My MBP has been acting strange.  I want to wipe it completely clean and start with a brand new installation of Lion.  How do I do that?  I know I can access the recovery partition by pressing 'Command+r' during the boot process.  However, do I need to use the disk utility option first and erase my internal hard drive?  Then do I use the new lion instal option?
    Or if I choose the new lion isntallation from the recovery partition, does it erase my drive first?
    -jon

    What error?
    The sync is one way - computer to iphone.  The only exception is itunes purchases.  File>Transfer Purchases
    It has always been very basic to always maintain a backup copy of your computer.  Have you failed to do this?

  • How to display both total and subtotal with condition on

    Hi Experts,
    We had a special requirements from our "Powerful" user for a top sales ranking report:
    say user runs for top 10 customers, query/view (It has to be built as query/views because they are going be exported to Portal) need to show
    1. sub total 10 customers
    2. total for all customers
    3. for each customer to show their sales percentage out of the overall total sales
    any recommendation welcomes
    Regards,
    Feng

    Create a condition on the Sales Key Figure as Top N and value as 10.
    So when you run the report for the Customer in Rows and Sales Key Figure in Coulmns you will get the report output for 10 customers and their respective Sales Figure. But if you see the overall result, it will be for all customers and not for only 10 customers. To get the total of only 10 customers, right click on Sales Key Figure and select Calculate result as Summation.
    Now below Sales Key Figure, create a Formula Key Figure (FKF) that will give the Total Sales for All customers. Use the formula as below
    FKF = SUMGT (SALES)
    Now create another Formula Key Figure (FKF1) that will give the % Sales with respect to total Sales. use teh Formula as below
    FKF1 = Sales %A FKF

  • ALV OO: How can I set totals and subtotals in program

    Hello together,
    I have a report using cl_gui_alv_grid. I would like to have button that leads to a predefined total-/subtotal configuration.
    1. How can I switch on/off a sortation for a column dynamically?
    2. How can I switch on/of the criteria for subtotals dynamically?
    Thanks for your help!

    Hi,
    On click on the button
    1) change the field catalog adding DO_SUM e.g.fcat-DO_SUM = 'X'
    2) Change the sort and add subtotal e.g.wa_sort-SUBTOT = 'X'
    Reload the ALV.
    Regards,
    Jovito

  • Running Totals and Formulas with Cross Tabs

    Hi,
    I'm using Crystal Reports 2008 and am having two issues using Cross Tabs.
    The first is that I want to have two crosstabs. They both will have a common Y axis (Oppourtunity.Sales Rep), and on the Y Axis I want one to show all (Opportunity.Create Date) where (Opportunity.Staus = Won) and the other where (Opportunity.Staus = In Process), but I can't figure out how to contruct the formula to return this result.
    The other issue, is that in addition to summarizing based on Sum (Opportunity.Expected Revenue), I would also like to create a running total to show the cumulative (Expected Revenue) Week over Week.
    Any direction would be fantastic.
    Thank you,
    Michael

    Please go through the SAP Notes listed here which would help you how to create mannual running totals in crosstab
    [https://www.sdn.sap.com/irj/scn/advancedsearch?cat=sdn_ossnotes&query=runningtotalin+crosstab&adv=true&note_number=&component=&sdn_updated_on_comparator=GE&sdn_updated_on=&sortby=cm_rnd_rankvalue]
    Regards,
    Raghavendra

  • 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

  • ALV Grid Control -  Modifiy data in total and subtotal lines

    Hello all,
    I´am creating a report using ALV Grid Control. This report calculates (using delivered and returned materials) for each vendor/material-combination the return quote.
    Using the totals and subtotals function for different characteristics I want to calculate the return quote for the selected characteristic. Example:
    Material delivered returned quote
    ..4711 . . . 500 . . . 5 . . . . 1 (=returned*100/delivered)
    ..4711 . . . 400 . . . 10 . . . . 2,5
    . SUM . . . 900 . . . 15 . . . . 3,5 <-- 3,5 is the sum but I want display the calculated value 1,667
    Is there a possibility to modify data in the total and subtotal lines.
    Thank you for your answer
    Best regards
    Thomas

    you said instead of 3.5 you want to show 1,667 ..
    how is it possible...
    3,5 become 1,667
    i thought you are doing any conversions...
    vijay

  • 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>

Maybe you are looking for

  • Not all things are loading in Safari (for me)

    Ok, well I frequently check my friends myspace's and blogs. And they usually are updated aout every other day with comments and/or new pictures/new things they talk about. So on myspace one of my friends adds new things to it about every day. So I co

  • A few questions from a new tech...

    It is based on the conversion process of a Cisco 6500 Series switch (WS-Sup720-3B release) w/MSFC3 from a hybrid mode (CatOS/IOS) over to a native mode. I've found a few conversion processes online however, I do not know which process is the best to

  • Maximum RAM upgrade?

    What is the maximum RAM I can safely install in my 21.5 inch, Mid 2011, iMac 2.5 GHz Intel Core i5. I have the 2 x 2 GB that came factory installed.

  • HT4477 How do you get netflix to work...keeps saying plug in missing????

    How does one get to use netflix when it keeps saying plug in is missing?????????? Don't use the computer a lot but have a Mac 2009 thanks

  • Select-option of a  variable is acting wierd in web report

    Hi, I am getting the following error in web report when I click a select option button of variable. Has any of you come across this situation ? Error:  <b>"System error in program CL_RSR_WWW_RENDERER and form GET_VARDEF_FOR_F4:03 (see long text)"</b>