How do i write this in sql ? (another headcracker challenging  report)

hi guys!,
I need to create / generate a report. I intend to do all this with pure SQL alone.
Been cracking my head for days but to no avail.
Hope you gurus here will straightened me out.
Here it goes. i Have a table
TABLE USAGE_REPORT
Date DATE -- everyday's date
BalanceCF NUMBER -- an initial start amount or ( balancebf)
Topup_amount NUMBER -- amount of topup that day
Usage1 NUMBER -- amount of $ use on certain prod
Usage2 NUMBER -- amount of $ use on certain prod
BalanceBF NUMBER -- BalanceCF + topup - usage1 -usage2 (which is also the next date BalanceCF)
Example1
please see this link
http://img9.imageshack.us/img9/708/88149028.gif
asumming my sql is
WITH dates AS
SELECT TRUNC(SYSDATE) + level dmy
FROM DUAL CONNECT BY level < 366
TopUP as
SELECT trunc(purchase_date) dated, sum(payment_amount)
FROM purchase
GROUP by trunc(purchase_date)
Usage1 as
SELECT trunc(connect_date) dated, sum(charged_amount)
FROM tab1
WHERE prod_id = 'xxx'
GROUP BY trunc(connect_date)
Usage2 as
SELECT trunc(connect_date) dated, sum(charged_amount)
FROM tab2
WHERE prod_id = 'yyy'
GROUP BY trunc(connect_date)
SELECT * FROM DATES D
LEFT OUTER JOIN TOPUP T
ON (D.DMY = T.DATED)
LEFT OUTER JOIN USAGE1 U1
ON (D.DMY = U1.DATED)
LEFT OUTER JOIN USAGE2 U2
ON (D.DMY = U2.DATED);
however
q1) how do i start 'initiate' the 1st row
BALANCECF so that i can do the calculation
of
BALANCECF + TOPUP - USAGE1 - USAGE2 = BALANCEBF
q2) how do i bring the value of BALANCEBF into the 2nd row of BALANCECF to do further calculation ?
q3) is it has something to do with connect by ? parent-child relationship
q4) in short how do i make it look like the attach pic above?
Please help!
Best Regards,
Noob

I am using 200 as initial balance_cf. You did not provide sample data, so code below is not tested:
WITH dates as (
               SELECT  TRUNC(SYSDATE) + level dmy,
                       200 balance_cf
                 FROM  DUAL
                 CONNECT BY level < 366
     topUP as (
               SELECT  trunc(purchase_date) dated,
                       sum(payment_amount) topup_amount
                 FROM  purchase
                 GROUP by trunc(purchase_date)
    Usage1 as (
               SELECT  trunc(connect_date) dated,
                       sum(charged_amount) usage_amount
                 FROM  tab1
                 WHERE prod_id = 'xxx'
                 GROUP BY trunc(connect_date)
    Usage2 as (
               SELECT  trunc(connect_date) dated,
                       sum(charged_amount) usage2_amount
                 FROM  tab2
                 WHERE prod_id = 'yyy'
                 GROUP BY trunc(connect_date)
SELECT  dmy,
        balance_cf + sum(topup_amount - usage1_amount - usage2_amount) over order by dmy rows between unbounded preceding and 1 preceding) balance_cf
        topup_amount,
        usage1_amount,
        usage2_amount,
        balance_cf + sum(topup_amount - usage1_amount - usage2_amount) over order by dmy) balance_bf
  FROM  DATES D LEFT OUTER JOIN TOPUP T ON (D.DMY = T.DATED)
                LEFT OUTER JOIN USAGE1 U1 ON (D.DMY = U1.DATED)
                LEFT OUTER JOIN USAGE2 U2 ON (D.DMY = U2.DATED)
  ORDER BY dmy
/SY.

Similar Messages

  • How do I write this SQL command in Oracle

    Hi all
    I wriote this SQ L statement in Ms SQL Server. How do I write this sql command in Oracle?
    ALTER VIEW dbo.ConsumptionAS SELECT TOP 100 PERCENT ID,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200710' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Oct2007,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200711' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Nov2007,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200712' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Dec2007,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200801' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Jan2008,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200802' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Feb2008,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200803' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Mar2008,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200804' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Apr2008,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200805' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS May2008,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200806' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Jun2008 ,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200807' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Jul2008 ,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200808' AND NbrDaysUsed != 0 THEN (QtyUsed/ NbrDaysUsed) * 748.05 ELSE 0 END)) AS Aug2008,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200809' AND NbrDaysUsed != 0 THEN (QtyUsed NbrDaysUsed) * 748.05 ELSE 0 END)) AS Sep2008
    FROM dbo.MasterConsumption WHERE YEAR_MONTH >= '200710' AND YEAR_MONTH <= '200809' GROUP BY ID ORDER BY ID
    I am very interested in this part:
    SUM(CASE WHEN YEAR_MONTH = '200710' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Oct2007
    thanks
    Edited by: user631364 on Oct 27, 2008 8:25 AM
    Edited by: user631364 on Oct 27, 2008 8:26 AM
    Edited by: user631364 on Oct 27, 2008 8:27 AM

    Thank you!!
    Now let me aslk the second part of my question.
    This sql command:
    ALTER VIEW dbo.ConsumptionAS SELECT TOP 100 PERCENT ID,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200710' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Oct2007,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200711' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Nov2007,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200712' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Dec2007,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200801' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Jan2008,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200802' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Feb2008,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200803' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Mar2008,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200804' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Apr2008,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200805' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS May2008,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200806' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Jun2008 ,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200807' AND NbrDaysUsed != 0 THEN (QtyUsed/ Days_Usage) * 748.05 ELSE 0 END)) AS Jul2008 ,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200808' AND NbrDaysUsed != 0 THEN (QtyUsed/ NbrDaysUsed) * 748.05 ELSE 0 END)) AS Aug2008,
    CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = '200809' AND NbrDaysUsed != 0 THEN (QtyUsed NbrDaysUsed) * 748.05 ELSE 0 END)) AS Sep2008
    FROM dbo.MasterConsumption WHERE YEAR_MONTH >= '200710' AND YEAR_MONTH <= '200809' GROUP BY ID ORDER BY ID
    was created with this query in SQL Server and then I saved it in a store procedure, that I scheduled to run montlhy
    SET ANSI_NULLS ON
    DECLARE @SQLString NVARCHAR(4000)
    /* Build the SQL string once.*/
    SET @SQLString = 'ALTER VIEW dbo.Consumption AS SELECT TOP 100 PERCENT ID, CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = ' +
    "'" + dbo.CONLastMonth_fn(getdate(), month(getdate()) - 12) +
    "'" +
    ' AND NbrDaysUsed != 0 THEN (QtyUsed/ NbrDaysUsed) * 748.05 ELSE 0 END)) AS ' +
    dbo.CONMonthInEnglish(getdate(), month(getdate()) - 12) +
    … (GOES FROM current month -12 to current month -1)
    , CONVERT(decimal(10, 2), SUM(CASE WHEN YEAR_MONTH = ' +
    "'" + dbo.CONLastMonth_fn(getdate(), month(getdate()) - 1) +"'" +
    ' AND NbrDaysUsed != 0 THEN (QtyUsed/ NbrDaysUsed) * 748.05 ELSE 0 END)) AS ' +
    dbo.CONMonthInEnglish(getdate(), month(getdate()) - 1) +
    ' FROM dbo.MasterConsumption WHERE YEAR_MONTH >= ' +
    "'" + dbo.CONLastMonth_fn (getdate(), month(getdate())-12 ) +"'" +
    ' AND YEAR_MONTH <= ' +
    "'" + dbo.CONLastMonth_fn (getdate(), month(getdate())-1 ) +"'" +
    ' GROUP BY ID ORDER BY ID '
    EXEC sp_executesql @SQLString
    Is that something that can be done in Oracle in the same way?
    Do you use another approach?
    please advice
    Edited by: user631364 on Oct 27, 2008 10:19 AM
    Edited by: user631364 on Oct 27, 2008 10:21 AM
    Edited by: user631364 on Oct 27, 2008 10:21 AM
    Edited by: user631364 on Oct 27, 2008 10:22 AM
    Edited by: user631364 on Oct 27, 2008 10:23 AM
    Edited by: user631364 on Oct 27, 2008 10:23 AM
    Edited by: user631364 on Oct 27, 2008 10:24 AM

  • How can i write this C-Code in G-Code

    hallo
    how can I write this C-Code in LabVIew ,
    for a=0; a=<10; a++
       for b=0; b=5 ; b+2
            X= 3+b;
      Y=1+a;
    please see the attachment and tell me where is the problem
    Attachments:
    Unbenannt 11.vi ‏43 KB

    Well, at least you tried and got some of it right.
    I think this should do what you want, but my C is rusty. Is the increment performed before or after the loop executes? If it's after, then I believe the loop should iterate 11 times, not 10.
    In any case, you should note that for a literal translation, you would need to add a sequence structure to guarantee that Y was written to only after the inner loop finished because of the way data-flow works.. Also, note that controls and indicators in LabVIEW are not equivalent to variables. They can be used as such, but they usually should not be.
    Another point about this is that you probably want to use the correct data type - the orange terminals are floating point indicators (of double precision, in this case) and you want integers.
    To learn more about LabVIEW, I suggest you try looking at some of these tutorials.
    Try to take over the world!
    Attachments:
    C.png ‏4 KB

  • I can not eliminate ASK engine from the list. It came back by itself. Please, tel me how I can eliminate this problem. Another problem, this browser is no longer compatible with some institutions. This new version might have some problems.

    '''I can not eliminate ASK engine from the list. It came back by itself. Please, tel me how I can eliminate this problem.
    Another problem, this browser is no longer compatible with some institutions. .'''

    Step by step, how did you arrive at seeing this agreement?

  • List v = new Vector() how can i write this ?

    List v = new Vector() how can i write this ?
    vector does not 'extends' List rather it 'implements' only ......so how can write this way ? ( polymorphism applies only for 'extends' ).

    my question in a simple way is :
    List some_list extends Vector
    No, List is an interface; Vector is a concrete class. Read the javadocs.
    Vector implements List
    >
    AND
    List some_list implements Vector
    are these two same in behaviour
    our  apart from theoretical differences ?thanks
    Interfaces don't have any implementation; they're pure method signatures. When a concrete class implements an interface, it makes a promise that says "I will provide implementations for exactly these methods. Any client can call a method from the interface and I will do something 'sensible' if I'm written correctly."
    From the point of view of static and dynamic types, there's no difference between interfaces and classes.
    C++ has interfaces, too - they're classes with all pure virtual methods. If you understand how C++ works, the concept shouldn't be hard.
    ArrayList is preferred precisely because it isn't synchronized by default. (You can always make it so using java.util.Collections if you wish later on.) If you don't need synchronization, why pay the performance penalty?

  • How do I write this as a loop?

    How do I write this code to function as follows.
    When btn1 is clicked, SenderLoad should be "clay" AND when btn2 is clicked, SenderLoad should be "iron", etc...
    var mgB:Array = [btn1, btn2, btn3, btn4];
    var mgBW:Array = ["clay", "iron", "cotton", "leather"];
    var SenderLoad:LoadVars = new LoadVars();
    var ReceLoad:LoadVars = new LoadVars();
    var mgNum:Number=0;
    for (i=0; i<mgBW.length ; i++){
    mgBW[i].onRelease = function () {
    mgNum++
    SenderLoad.word = mgB[mgNum];
    SenderLoad.sendAndLoad("http://www.web.com/my.php",ReceLoad,"POST");
    ReceLoad.onData = function(src) {
    var messageA:Array = src.split(",,,");
    ldrB2.html=true;
    for(var i:Number=0; i<messageA.length; i++){
               var a:Array=messageA[i].split(",,");
       ldrB1.htmlText +=a[0];
       ldrB2.htmlText +=a[1];

    if you want different words in different colors you can use:
    ldrB1.html=true;
    ldrB1.text = formatF("REJECT",0xff0000,ldrB1)
    ldrB1.text = formatF("ACCEPT",0x000000,ldrB1);
    ldrB1.text = "formatF("BANNED",0xc0c0c0,ldrB1);
    function formatF(s:String, col:Number, tf:TextField):Void {
    if(tf.text.indexOf(s)==-1){
    return;
        tfor.color = col;
        var startindex:Number = 0;
        while (startindex>-1 && startindex<tf.text.length-1) {
            var bindex:Number = tf.text.indexOf(s, startindex);
            var eindex:Number = bindex+s.length;
            tf.setTextFormat(bindex,eindex,tfor);
            startindex = eindex;
    var tfor:TextFormat = new TextFormat();

  • How can I get this thru SQL ?

    Hi,
    I am having following sample data
    NUMRUB FORMAT
    1 X(02)
    2 9(02)
    3 9(08)
    4 X(20)
    5 9(01)
    6 X(03)
    7 9(1)
    8 X(02)
    9 9(02)
    I want output in following way
    NUMRUB FORMAT NewFormat Start Position
    1 X(02) 2 1
    2 9(02) 2 3
    3 9(08) 8 5
    4 X(20) 20 13
    5 9(09) 9 33
    6 X(03) 3 41
    7 9(1) 1 44
    8 X(02) 2 45
    9 9(02) 2 47
    How can I get this thru SQL ?
    Pl guide me.
    thanks & regards
    PJP

    SQL> create table mytable (numrub,format)
      2  as
      3  select 1, 'X(02)' from dual union all
      4  select 2, '9(02)' from dual union all
      5  select 3, '9(08)' from dual union all
      6  select 4, 'X(20)' from dual union all
      7  select 5, '9(09)' from dual union all
      8  select 6, 'X(03)' from dual union all
      9  select 7, '9(1)' from dual union all
    10  select 8, 'X(02)' from dual union all
    11  select 9, '9(02)' from dual
    12  /
    Tabel is aangemaakt.
    SQL> select numrub
      2       , format
      3       , to_number(regexp_replace(format,'(X|9)\((.*)\)','\2')) "NewFormat"
      4       , nvl
      5         ( sum(to_number(regexp_replace(format,'(X|9)\((.*)\)','\2')))
      6           over (order by numrub rows between unbounded preceding and 1 preceding)
      7         , 0
      8         ) + 1 "Start Position"
      9    from mytable
    10   order by numrub
    11  /
        NUMRUB FORMA  NewFormat Start Position
             1 X(02)          2              1
             2 9(02)          2              3
             3 9(08)          8              5
             4 X(20)         20             13
             5 9(09)          9             33
             6 X(03)          3             42
             7 9(1)           1             45
             8 X(02)          2             46
             9 9(02)          2             48
    9 rijen zijn geselecteerd.Regards,
    Rob.

  • My iTunes library is constructed entirely of uploaded music cds. How can I transfer this music to another mac

    My iTunes library is constructed entirely of uploaded music cds. How can I transfer this music to another mac (I'm replacing current macbook)? Eventually, I will begin using itunes to download / purchase music. Do i need to transfer original library before updating itunes library on the cloud? What's order of operations?

    From your OLD computer...
    Copy your ENTIRE iTunes FOLDER to an External Drive... and then from the External Drive to your New Computer..
    Full Details Here  >  http://support.apple.com/kb/HT1751
    An Added Bonus is that you will have a Backup of iTunes.
    Also have a look at these 2 Videos...
    http://macmost.com/moving-your-itunes-library.html
    http://macmost.com/moving-your-itunes-media-to-an-external-drive.html

  • How to re-write this big SELECT Query with INNER JOINs?

    Hi Experts
    I have a performance killer SELECT query with an inner join of 3 tables u2013 VBAP, VBAK and VBEP together, which populates records to an internal table INT_COLL_ORD. Based on these records selected, in another SELECT query, records are fetched from VBUK table to the internal table INT_VBUK.
    SELECT A~VBELN A~POSNR A~MATNR A~KWMENG A~KBMENG A~ERDAT A~ERZET A~PSTYV D~AUART E~ETTYP E~EDATU
    INTO TABLE INT_TAB_RES
    FROM VBAP AS A INNER JOIN VBAK AS D
    ON D~VBELN EQ A~VBELN AND D~MANDT EQ A~MANDT
    INNER JOIN VBEP AS E
    ON E~VBELN EQ A~VBELN AND E~POSNR EQ A~POSNR AND E~MANDT EQ A~MANDT
    WHERE  A~VBELN IN s_VBELN AND
           D~auart in s_auart AND
           D~vkorg in s_vkorg AND
           D~vbtyp eq 'C'     AND
           ( ( matnr LIKE c_prefix_sp AND zz_msposnr NE 0 AND kbmeng EQ 0 )
           OR ( matnr LIKE c_prefix_fp AND kwmeng NE A~kbmeng ) ) AND
           A~ABGRU EQ SPACE AND
           A~MTVFP IN R_MTVFP AND
           A~PRCTR IN R_PRCT AND
           E~ETENR EQ '1'.
    SORT INT_COLL_ORD BY VBELN POSNR ETTYP.
    DELETE ADJACENT DUPLICATES FROM INT_TAB_RES COMPARING VBELN POSNR.
    CHECK NOT INT_TAB_RES [] IS INITIAL.
    SELECT VBELN UVALL CMGST INTO TABLE INT_VBUK
    FROM VBUK FOR ALL ENTRIES IN INT_TAB_RES
    WHERE VBELN = INT_TAB_RES-VBELN AND UVALL NE 'A'.
    Now, the requirement is:
    I want to split this query. Like, first join VBAK and VBUK first. With this selection, go to the inner join of VBAP and VBEP (on key VBELN) to get the results. How can I re-write this Query?
    Please help.
    Thx n Rgds

    Hi Nagraj
    As of your suggestion, I have re-written the query as below:
    * Declarations
    TYPES: BEGIN OF TYP_COLL_ORD,
            VBELN  LIKE VBAK-VBELN,
            POSNR  LIKE VBUP-POSNR,
            MATNR  LIKE VBAP-MATNR,
            KWMENG LIKE VBAP-KWMENG,
            KBMENG LIKE VBAP-KBMENG,
            ERDAT  LIKE VBAK-ERDAT,
            ERZET  LIKE VBAK-ERZET,
            PSTYV  LIKE VBAP-PSTYV,
            AUART  LIKE VBAK-AUART, u201Calready exists in type
            ETTYP  LIKE VBEP-ETTYP,
            EDATU  LIKE VBEP-EDATU.
    TYPES: END OF TYP_COLL_ORD.
    DATA: INT_COLL_ORD TYPE TABLE OF TYP_COLL_ORD WITH HEADER LINE.
    TYPES: BEGIN OF TYP_VBUK,
            AUART  LIKE VBAK-AUART, u201Chave added this field
            VBELN  LIKE VBUK-VBELN,
            UVALL  LIKE VBUK-UVALL,
            CMGST  LIKE VBUK-CMGST.
    TYPES: END OF TYP_VBUK.
    DATA: INT_VBUK TYPE TABLE OF TYP_VBUK WITH HEADER LINE.
    *QUERY#1 u2013 for VBAK & VBUK Join
    SELECT A~AUART B~VBELN B~UVALL B~CMGST
    INTO TABLE INT_VBUK
    FROM VBAK AS A INNER JOIN VBUK AS B
    ON A~VBELN EQ B~VBELN
    WHERE A~VBELN IN s_VBELN AND
    A~auart in s_auart AND
    A~vkorg in s_vkorg AND
    A~vbtyp eq 'C' AND
    B~UVALL NE 'A'.
    IF NOT INT_VBUK[] IS INITIAL.
    SORT INT_VBUK BY VBELN.
    DELETE ADJACENT DUPLICATES FROM INT_VBUK COMPARING VBELN.
    *QUERY#2 u2013 for VBAP & VBEP Join
    SELECT A~VBELN A~POSNR A~MATNR A~KWMENG A~KBMENG A~ERDAT A~ERZET A~PSTYV B~ETTYP B~EDATU
    INTO TABLE INT_COLL_ORD
    FROM VBAP AS A INNER JOIN VBEP AS B
    ON B~VBELN EQ A~VBELN AND B~POSNR EQ A~POSNR AND B~MANDT EQ A~MANDT
    FOR ALL ENTRIES IN INT_VBUK
    WHERE A~VBELN = INT_VBUK-VBELN AND
    ( ( matnr LIKE c_prefix_sp AND zz_msposnr NE 0 AND kbmeng EQ 0 )
    OR ( matnr LIKE c_prefix_fp AND kwmeng NE A~kbmeng ) ) AND
    A~ABGRU EQ SPACE AND
    A~MTVFP IN R_MTVFP AND
    A~PRCTR IN R_PRCT AND
    B~ETENR EQ '1'.
    ENDIF.
      SORT INT_COLL_ORD BY  VBELN POSNR ETTYP.
      DELETE ADJACENT DUPLICATES FROM INT_COLL_ORD
        COMPARING VBELN POSNR.
      CHECK NOT INT_COLL_ORD[] IS INITIAL.
      LOOP AT INT_COLL_ORD.
        CLEAR: L_MTART,L_ATPPR,L_ETTYP.
        IF L_PREVIOUS_ETTYP NE INT_COLL_ORD-ETTYP OR
          L_PREVIOUS_AUART NE INT_COLL_ORD-AUART.
          READ TABLE INT_OVRCTL WITH KEY AUART = INT_COLL_ORD-AUART ETTYP = INT_COLL_ORD-ETTYP.
          CHECK SY-SUBRC NE 0.
    Now, the issue is:
    Please note that declaration for INT_COLL_ORD has a field AUART, which is used in further parts of program (see the statement just above)
    But, since neither VBAP nor VBEP contains AUART field, it cannot be fetched through the QUERY#2. So this value is not populated into INT_COLL_ORD through SELECT Query.
    Since this field is used in later part of program & that the internal table has no value for this field, it dumps!!
    How to include this value into the INT_COLL_ORD?
    Plz suggest....

  • How do you reactivate this phone in another family member name after the original owner now deceased

    How do you reactivate this phone Verizon Droid Maxx in another family member name after the original owner now deceased

    To switch it to another number, you need to activate another phone on the number you no longer need (or have Verizon cancel it for the deceased member).  Once that line is no longer active, you can activate the phone on another number - have Verizon CS at a store help you, or follow the steps on verizonwireless.com from the account of the person you do want it to be activated for.

  • How could I write this in java

    I have to use a parameter in a statement. I am trying but its giving error. I am trying to write it like ....
    fw.write("Object     dir/my.dat\n");I substitute my.dat with a variable dat & write like
    fw.write("Object     dir/+"dat"+\n");dat is a String variable.

    Sam_Fin wrote:
    thanks,welcome
    How could I remove this error.
    Unreported exception java.io.IOException; must be caught or declared to be thrown fw.write("#the number of patterns to be recognized\n");
    Its for every fw.write statement.read the Sun (Oracle?) [tutorial on exceptions,|http://java.sun.com/docs/books/tutorial/essential/exceptions/index.html] and then either throw the exception or wrap in a try / catch block (the tutorial will explain how).

  • How can i write a Pl/sql Programme for a calender

    hi all,
    How can i write Pl/sql programme (may be function) for a calendar ,like after the programme is created if call the function at the prompt and give the year 2099 so on, it should display the result with all the 12 months (months and days.)
    Please email the answer to
    [email protected]
    or send the link for the answers.
    Thx

    Well, you can start off by reviewing the SYSDATE command and the TO_DATE and TO_CHAR functions. Also, review addmonths etc.
    http://www.unix.org.ua/orelly/oracle/prog2/ch14_01.htm
    Cheers

  • How would I write this query

    [USERNAME]
    [GROUP]
    User1
    New Member
    User2
    New Member
    User1
    All Members
    User1
    Gold Member
    How would I write a query so that I could select * from the above table where a user has more than 1 group (user1) and if one of the groups = 'All members' then ignore that row and just return the all the other rows for the user that has > 1 group. 
    Thanks in advance.  I can write the query for counting if a user has more than 1 group, but I stuck on the rest.
    Thanks again

    Try this
    declare @tab table(USERNAME varchar(10), Usergroup varchar(15));
    insert into @tab values
    ('User1','New Member'),
    ('User2','New Member'),
    ('User1','All Members'),
    ('User1','Gold Member');
    select * from
    (Select *,ROW_NUMBER() OVer(partition by username Order by case when Usergroup ='All members' then 0 else 1 end desc) RN From @tab ) t
    where t.usergroup= case when t.rn >1 and t.Usergroup='All members' then 'Do not return' else t.Usergroup end
    Satheesh
    My Blog |
    How to ask questions in technical forum

  • How could u write this application?

    write an application to read an unknown number of integer pairs representing binary numbers from a file redirected input from the command line. do not use sentinel value or prompt.
    1. Echo print in colums 1 and 2 the numbers that were read.
    2. Convert each number to decimal for columns 3 and 4.
    3. Count the number of 1's in the numbers for columns 5 and 6.
    4. Find the larger of the decimal versions of the first and second number of each integer pair, and print that number in column 7.
    5. Keep separate cumulative sum of the decimal versions of the first and second number of each integer pair, and print that number below the appropriate column after all numbers have been read.
    Sample output:
    10 11 101 1111 111 10000 101011 0
    thanks for your interest

    > hey young fella, its not a HW or something!! everyone
    talks alot here like they know everthing(which they
    aint gotta clue), i decided to put an easy
    application to c how many people are going to be able
    to write this application??
    That's a little tough to believe. It's far more likely that you need some help on figuring out how to go about writing such an application. There's nothing wrong with that; just know that most folks who volunteer to help here aren't particularly interested in "proving their skills" by way of programming "challenges". They typically get far more satisfaction by helping others learn Java.
    i guess u r one those fellas who dont have a clue about java!!! b/c if u
    were not, this would take ur 5-6 mins of time..
    So, do you have a specific question regarding those requirements? If you do, please ask. If, on the off chance you've got some special insight regarding an implementation, post your idea and get some feedback from the community.
    Also, please make the extra effort to write out words such as "see", "you", "are", "your", and "because". The extra keystrokes won't cost much in the way of time, and the enhanced clarity will be appreciated by those communicating on a forum with international readership. Also, it will give the appearance that you take your question seriously, which will in turn make your question look more interesting to answer.
    Thanks!
    ~

  • How can I write this string to a file as the ASCII representation in Hex format?

    I need to convert a number ( say 16000 ) to Hex string ( say 803E = 16,000) and send it using Visa Serial with the string control in Hex Mode. I have no problem with the conversion (see attached). My full command in the hex display must read AA00 2380 3E...
    I can easily get the string together when in Normal mode to read AA0023803E... but how can I get this to hex mode without converting? (i.e. 4141 3030 3233 3830 3345 3030 3030 3031 )
    Attachments:
    volt to HEX.vi ‏32 KB

    Sorry, The little endian option was probably introduced in 8.0 (?).
    In this special case it's simple, just reverse the string before concatenating with the rest.
    It should be in the string palette, probably under "additional string functions".
    (note that this only works in this special case flattening a single number as we do here. If the stat structure is more complex (array, cluster, etc.) you would need to do a bit more work.
    Actually, you might just use typecast as follows. Same difference.
    I only used the flatten operation because of the little endian option in my version.
    Message Edited by altenbach on 11-16-2007 11:53 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    littleendian71.png ‏4 KB
    littleEndiancast71.png ‏4 KB

Maybe you are looking for

  • Formating field on the Adobe form

    Hi All, I have a field matnr which is displayed on the adobe form with the leading zeros. Eg 000000000001003800, However I want this field to get displayed in the internal format such as 100-3800. How to get this resolved. Has anybody worked on the s

  • Save for web and devices - grayed out. Why?

    Hi. I just bought a new computer, new hard drives, etc. So, I had to reinstall Windows XP pro and all my software applications, which includes Adobe Creative Suite Design (standard edition). All loaded well and my computer is up and running nicely. o

  • Issues Downloading Photoshop

    You are running an operating system that Photoshop no longer supports. Refer to the system requirements for a full list of supported platforms. What do I need to do to be able to download this program?

  • Lightroom or Photoshop?

    I am a mother of two and like to take my own pictures of my children.  I'm not sure which product would be best for me.  Can you isolate colors in lightroom (meaning the photo is all black and white except maybe one color such as red?)  Also, do your

  • No input using USB Audio CODEX

    We have been using the USB Audio CODEX input for several weeks from an Allen & Heath ZED 436 sound board. Suddenly last Sunday no audio inputs. It still sends to the computer but GB Will not record and no input levels show in the System Prefs. Any he