Report Issue: Previous Weeks, Current Week and Next Week Values

Hello Folks,
this is a typical requirement...at-least typical for me..
we have 20 weeks of data at weekly level. we have four Metrics out of which two are coming from Database and rest two are calculated metrics.
Metric0: On Hand Qty
Metric1: Past Qty
Metric2: sell Qty
Metric3: unsell qty
Metric4: Total Qty
the report will always be shown for 20 weeks, but depending on whats my current week, all the past weeks should be flagged as Past Week. (so i wrote a case statement for this). for Instance: I am in Week11, so my weeks in should be Past Week, Wk11, Wk12.........Wk20.
Metric 1 is always dependent on result of Metric4 (This is the Complexity) per week basis
Metric1 for Past weeks value in Week Column will be wk1 to wk10 On Hand Qty (fox ex: 80)
Metric4 for Pass Weeks Value in Week Column will be Metric1 for Pastweeks + Metric2 for Past Weeks (For Ex: 20) (Past weeks mean wk1 to wk10)
value of Metric4 is now 100
Metric1 for Week11 Now should 100 (From Past weeks Calculation)
Metric4 for Week11 will be Metric1 for Week11(100) + Metric2 for Week11(10) + Metric3 for Week11 (10)
Now...Metric1 for Week12 will be 120 which is wk11 total (100+10+10) and goes on Until Week 20
Any Ideas how to achieve this in obiee 10g
Thanks
Rake

Please try out in this way....
Database level --Create opaque view & procedure or function  to get the week total,week ago total, current week , Past week ,future week & do rpd modelling and use PIVOT VIEW.
At answers:
1.Here Previous week M4 is the current week M1 which means it is a cumulative value carried forward week by week.
2. M2 & M3 are direct database columns.
3. You have time hierarchy with WEEK Level.
M1 - ago(rsum(m2+m3),weeklevel)
M4- RSUM(M2+M3)
week -AGO(RSUM(M2+M3)- M2-M3-RSUM(M2+M3)
w1-0-10-20-30
w2-30-11-21-62
w3-62-12-22-96
Now you can PIVOT IT to get in
W1-W2-W3
M1 0 - 30-62
M2 10-11-12
M3 20 -21-22
M4 30 - 62-96
NOW PASTWEEK (W1-W10), CURRENT WEEK(W11)-W12
1.as you see cumulative here you need to use BINS.means ( case when week <= currentweek(maybe variable) then prior) else week)
2. UNION - combine similar request - First cirteria week <= w11 and second criteria week > week 11 --combine pivot it. Use sum agg in fx criteria1.
Hope this should solve your pblm at answers.
Edited by: MK on Oct 27, 2011 12:48 PM

Similar Messages

  • Hi, I´m from Brazil and next week I´ll be in Usa, NY , where I bought my Iphone 4. I want to know if i could go to apple store in Ny and upgrade for iphone 4s unlocked? I know i have to pay more, but IS THERE that possibility?

      Hi I´m from Brazil and next week I´ll be In NY , where i Bought my iphone 4. I want to know if I could go to apple store to exchange to iphone 4s W
      I know I have to pay more for that , but is there that possibility?

    You can buy an  iphone 4s.
    There is no trade in.

  • Current objectives and next yearu2019s objectives in one appraisal document

    I keep coming across the requirement for an employee to be able to record comments and scores for his/her current objectives and at the same time to document his/her objectives for the next year in the same appraisal document. The SAP standard process being to record last yearu2019s objectives and next years objectives in two separate documents.
    Has anyone else come across this requirement and if so how did you meet it?
    Is there a BAdI which will pull the u2018Performance Objectives for the next 12 monthsu2019 from the 2010 appraisal document into the 2011 appraisal document?
    Any suggestions would be much appreciated.

    Hi,
    Please check the following discussion:
    Re: Performance Appraisal-Copy the "Completed" Appraisal for next year
    Credits: SDN members
    Hope this helps.
    Donnie

  • Business connector scheduler gets hanged and Next run value is large number

    Hi All,
    I see the scheduler in business connector gets hanged and the Next run value shows huge/large number like 9223370831700598.0 sec. Please can anyone suggest what can be done.
    Currently BC ver is 4.7. The problem gets resolved every time when i restart the server.

    Hi,
    Not aware of the reason though, I guess you must be using the simple scheduled tasks.
    Try using complex reapting tasks where you specify days , minutes etc.
    It should work fine.
    Hope it helps. Reward if useful.
    Regards,
    Siddhesh S.Tawate

  • Lots of folks on vacation this and next week

    If you're concerned that your questions and threads aren't receiving much attention, it's not intentional. Quite a bit of the team is out on holiday as this seems to be the peak of summer vacation time for us.
    We'll have another Early Adopter Release and more time to work through the bugs and usability issues with our new features.
    Thanks for the great feedback and keep it up!

    I have 2 mini iPods, in few cases (and not everytimes), while just after doing the Restore, it showed the same icon as yours. I plugged into an (USB) ac charger, it did not work, so I used the Firewire ac charger instead or even connected iPod with my iPod HiFi, which managed to complete the Restore process.
    It does not mean that I suggest you to buy a firewire ac charger, bring your mini to an apple shop to prove it.

  • Calendar is creating an extra event when the event spans the week view end of week to beginning of next week.

    When I create an event in Calendar that goes from Saturday to Sunday, like my work shift that starts at 5:30 pm and ends at 3:30 am the next day, the event gets duplicated onto the next day but is seen as a single event. So if I delete the one on Sunday it deletes the Saturday one as well. But visually there are two separate events. This happens when spanning work weeks. I first noticed it because my week view was set to start on Sundays. All of my Saturday shifts were duplicated onto the Sunday. It seemed to be okay only when I switched the week to start on Mondays. But then I just went to create an extra shift I picked up on Sunday and now it's there on Monday as well.

    Ive reset, restored and this is the second phone. Thought it maybe a wonky screen that would shift it while setting dates. THe only thing I can think of is that I am syncing with google calendar, but it only happens when setting events in ios not if i do it from google website on desktop PC.

  • Reporting on Previous Month/Current Year - Jan 09 fix

    I currently have about 10 reports that are being filtered to only show data on the repository variables for :
    PreviousMonth and Current Year.
    When Jan 1, 2009 comes around, these reports will be kicked off to show Decemeber of the Current Year, so December of 2009.
    What is the best/easiest way to fix this problem for the future?

    What Shiva meant was to let YEAR be a Presentation Variable that the user can select from, say a drop down list of "years."
    But consider this. Whenever the month of the "system date" is January, you want the year to be one less than the "current year." For all other months, you want the year of the "system date."
    PrevYear = CASE WHEN MONTH(Calendar."System Date")=1 THEN YEAR(TIMESTAMPADD(SQL_TSI_YEAR, -1,Calendar."System Date")) ELSE YEAR(Calendar."System Date") END
    And since you weren't sure about how to do the previous month...
    PrevMonth = MONTH(TIMESTAMPADD(SQL_TSI_MONTH,-1,Calendar."System Date"))

  • MDVP for next week Planned orders

    Hi,
    I keep in my system this week production orders and next week firm planned orders so that I can see the plan in my system and system can check the availabilty on planned order for next week missing parts. Now my qyestion is:
    Suppose there is matewrial X which is having planned orders from today to next 14 days. Now for this week I run the MDVP  for first 7 days for this material "X"and it gives 50% confirmation availabilty of components. But what is happening with me is when I run the MDVP for next 7 days for the same "X" it gives 100% . why? On which logic it is doing like this? If for first 7 days it is 50% then why for next 7 days it is 100%.
    Please explain me at what logic MDVP checks the material availabilty? is it checing the planned delivery time and GR time of components in material master ?
    Regards
    Deepak Sharma

    THe possiblility may be the arrival or availabilityof the raw materials on those dates...
    i.e there might be Pur reqs for the raw materials already raised in the system.. and they are expected to be available for the next 7 days.....
    please check..
    karthick

  • COPA Report current period and previous period issue

    Hi Gurus,
    I have defined COPA report (Tcode KE94) based on line items. Now I want all values to be displayed based on an entry parameter in terms of period. That is to say that  If I give input values of "010.2013" as a period entry , my report should display the values for the the period specified i.e. 010.2013 in the first column and in second column  values for the period 009.2013 should be displayed and in the third column values for the period 001.2013 till 010.2013 should be displayed cumulatively.
    For this, I choosed the character "period/year" in General data selection tab, clicked "Variable on/off" tab and gave values "From"  as well as "To" for the Global Variable "OFP"  which is Curr.fisc.per./year.
    For the 1st column (1st column which is suppose to display the values according to selection parameter), along with the character "company code" , I choosed the character "period" and clicked "Variable on/off" tab and gave value "From"  as well as "To" for the Global Variable "OFP"  which is Curr.fisc.per./year.
    For the 2nd column (2nd column which is suppose to display the values for the immediately preceeding period of the selection parameter), along with the character "company code" , I choosed the character "period" and clicked "Variable on/off" tab and gave value "From"  as well as "To" for the Global Variable "OFP"  which is Curr.fisc.per./year. While doing so, I selected operator as "-" and choosed offset as 1.
    For the 3rd column (3rd column which is suppose to display the cumulative values from the beginning of the fiscal year till the period mentioned in the selection parameter), along with the character "company code" , I choosed the character "period" and selected 001 in "From" and 016 in "To" tab.
    Company Code selected in all the three columns is same and I have selected actual values i.e. 0 for "plan/actual indicator" tab.
    When I run the report through Tcode KE30 , I give values as "010.2013" for the From and To selection tabs. System shows the values as per the selection parameter in the 1st column which is correct  but display values same as per coulmn 1st in the 3rd column which is wrong because it should be cumulative. 2nd column is blank. 
    How to display the values for the immediately preceeding period and for cumulative period?
    Regards,
    makrand

    Dear Ajay,
    Thanks for the reply. Here are the screen shots.
    For the general data selection tab
    For the first column "current month" i.e. for the month
    For the second column "Last Months"
    For the third column "Cumulative" i.e. year to date
    Following is the result of KE30
    Values for the period 010.2013
    You can see that values in the report for the period 011.2013 contains value for the previous period which is 59090.21
    This value is matching when the report is run for the period 010.2013.
    But in both the reports,the figures for Current month and YTD (year to date) are same.
    Please let me know what setting is required in the current month column.
    Regards,
    makrand

  • Siri does not interpret 'This Week' vs 'Next Week' correctly

    OK this seems really mixed up to me. I seems that Siri does not correctly interpret 'This Week' versus 'Next Week' correctly.
    Environment information:
    Phone = iPhone 4S
    Language setting = 'British English' as there is, unfortunately, no 'Australian English'
    Region Format = Ireland (because that is the only one which gives desired region formats € etc. bit of an issue with iOS in that it does not have customisable localisation settings like OS X)
    Voice Control = English (Australia)   (because that's the best English of course - my native English )
    Date the Siri tests were done = Saturday, 5th of November 2011
    I would consider that if one said a day (Mon, Tues, Wed etc.) this week that it would refer to the days in the current week which is Monday 31st Oct - Sunday 6th Nov. (and no, I'm not American so I don't have the unusual idea that Sunday is the first day of the week ).
    Regardless of the above, if I said to Siri on Saturday 5th November, "What's the weather like next Monday" I would expect to get back weather for Monday of the next week, that is Monday 7th of November. But this is what I get...
    Huh? Why does it want to go out to the next, next week?? Which is what the 14th November (14/11/2011) would be.
    So then I asked for the weather for this Monday - which I would expect to be the Monday of this week which would be Monday 31st October. But Siri gives me the result for next week (as I am still in this week and this Monday has passed).
    OK then Siri what if I ask you "What's the weather like Monday next week". Uhhhh you give me next week's Monday but you call it "this Monday".
    Finally, if I ask Siri what is the weather like this weekend it correctly gives me this weekend - Saturday & Sunday. So it knows I think Saturday & Sunday are the weekend. If I say "what's the weather like next weekend" it says "I can't check the weather out to 13/11/2011" which is the Sunday of the next weekend. So it seems to understand weekends, not weeks.
    I've been using 'this week' and 'next week' for many years, and I don't think I'm confused - so I am calling Siri confused.
    Any comments, anyone able to shed light on this?

    Hi Kevin, I will do the bug report.
    Hi Steve, that probably is true. The NeatVideo plug-in in AE and PPro is also the same - at least the technician in NeatVideo claims that. So, then it must be PremierePro itself reading or interpreting the .R3D files incorrectly.
    Remembering that NV plug-in asks the host application for adjacent frames, I made also an experiment (in PPro) with how much is cut from the beginning of the clip with the following results:
    - as told before, if the clip is not shortened from the beginning, NV gives good results
    - if I shorten the clip only one or two frames, the result is not much worse
    - if I shorten the clip ten frames, the results are getting worse
    - if I shorten the clip couple of seconds, the results are getting even worse
    - the more I shorten the clip from the beginning, the worse results I get...
    The clip I've tried has steady movement (the camera moves steadily in one direction). Therefore, I guess PPro gives different time references for the frame played and the adjacent frames NeatVideo plug-in is asking for. If the clip has been shortened on the timeline only a bit, then they still work quite well as references for NV to be used. And the more the clip has been shortened on the timeline, the less the "asked frames" work as a good comparison. It seems as if NV plug-in asks frames based on the length of the original clip, and PPro gives frames counted from the beginning of the edited clip on the timeline. Hence the bad quality.

  • Ical moving item in week view to next week view - can you drag it

    i like to drag items not completed from a week view to the next week view, but as with Office 2007 you cant just drag the event from the week view to the months calendar view on the side and drop it into a new date.
    I know if you use month view, it make is easy but month view is my least preferred display option, also in month view, to drag to the next month is no possible.
    I wonder what is a quickstep to do this, it must be annoying for others

    CaptainStarwars,
    Try using (⌘+C) and then (⌘+V). That action retains the event in the original, while also placing a duplicate in the new location.
    If you want to remove the event from the original time, use (⌘+X), then (⌘+V) in the new time frame.
    ;~)

  • Display Current Quarter and Previous Quarter???

    Hi Gurus,
    I Had a requirement to display only the current Quarter and previous quarter in the report level using single quarter column.
    and my quarter value type is Q1 2013.
    Please anyone help me out on this asap/
    Thanks.

    Hi,
    Using time serious function you can acheive this requirement.
    http://obieetutorialguide.blogspot.in/2012/02/modeling-time-series-function-in-obiee.html
    OBIEE 11g Time Series Function
    or,
    Using presentation variable you can achieve this.
    Re: OBIEE 10g LY YTD returns YTD for past years
    The above thread for year you can change to qtr.
    Hope this help's
    Thanks,
    Satya

  • Crystal Report issue : Error in file.. .rpt . Error in formula

    Hi ,
    I recently migrated a report from production to test environemnt and it throws me the following error:
    Error in File C:\DOCUME1\oe_user\LOCALS1\Temp\packing instructions {4058873B-9756-4052-B479-EBD2D0A08E7D}.rpt:Error in formula  <Object_Visibility>. '{Command.EXACT_WEIGHT_FLAG} = "Ne (No)"'
    This field name is not known.
    In production server is installed Oracle 9i database and in test server is installed Oracle 10g
    The report has 1 main report and 2 sub reports.
    1. The same report works fine in production server without any issues.
    2. I had executed the report in Crystal reports 2008 and it runs fine displaying all fields without any issues.
    3. I had also tried taking the query of both subreports and the main report and tried executing it in oracle and it runs fine without any issues.
    However during the runtime in the test server, it throws the following error.
    Can someone help me out with this issue..

    Hi Siva,
    What is the patch level of CR 2008?
    Is it a win or a web app?
    What is the server OS?
    First, try to simply view the report. Let  the report prompt for the database credentials and the parameter values if any.
    See if it reproduces the issue.
    ReportDocument rd = new ReportDocument();
            rd.Load(Server.MapPath("CrystalReport.rpt"));
            CrystalReportViewer1.ReportSource = rd;
    Take a look at the SAP Note :
    [1421867 - Error: This field name is not known|http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_bi/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes%7B6163636573733d36393736354636443646363436353344333933393338323636393736354637333631373036453646373436353733354636453735364436323635373233443330333033303331333433323331333833363337%7D.do]
    Hope it helps,
    Thanks,
    Bhushan.

  • Monitor database job-find out current statement and bind values

    Hi all,
    we have a job running on one of our databases which sometimes runs for a very long time.
    Sometimes it it is necessary to kill that job because it is blocking normal work.
    Therefore it is important to find out the current statements the job is processing in order to avoid too much trouble after killing.
    Job processing is a chain of several procedures that insert, update, delete from different tables dependant on initital user input.
    Database is 10203 on solaris 10. Job was created with dbms_job (no em job).
    Is there any way to find out the job's current statement and relevant bind values?
    FJH

    http://www.orafaq.com/wiki/SQL_Trace

  • OUTSTANDING PO QTY AND OUTSTANDING PO VALUE

    Hi
        I am in need of report to print outstanding po qty and outstanding po value.
    could any one please give me the source code..
    Its very urgent.....
                   Thanks in advance

    Please find this report for Outstanding PO's
    report zaprropo message-id zm no standard page heading line-size 212
                                                           line-count 65.
    **** TABLES------------------------------------------------------------*
    tables:
          ekko,                            " Purchasing Document Header
          ekpo,                            " Purchasing Document Item
          ekbe,                            " History of PurchasingDocument
          essr.                            " Service Entry Sheet HeaderData
    **** DATA--------------------------------------------------------------*
    data  : begin of it_ekko occurs 0,
             ebeln like ekko-ebeln,
             ernam like ekko-ernam,
             ekgrp like ekko-ekgrp,
             bedat like ekko-bedat,
           end of it_ekko.
    data  : begin of it_ekbe_gr occurs 0,
              ebeln like ekbe-ebeln,
              ebelp like ekbe-ebelp,
              bewtp like ekbe-bewtp,
              dmbtr like ekbe-dmbtr,
            end of it_ekbe_gr.
    data  : begin of it_ekbe_ir occurs 0,
              ebeln like ekbe-ebeln,
              ebelp like ekbe-ebelp,
    *          bewtp LIKE ekbe-bewtp,
              dmbtr like ekbe-dmbtr,
            end of it_ekbe_ir.
    data  : begin of it_output occurs 0,
              ekgrp like ekko-ekgrp,
              ebeln like ekko-ebeln,
              ebelp like ekpo-ebelp,
              ernam like ekko-ernam,
              afnam like ekpo-afnam,
              bedat like ekko-bedat,
              txz01 like ekpo-txz01,
    *          bewtp LIKE ekbe-bewtp,
              netwr like ekpo-netwr,
              dmbtr like ekbe-dmbtr,
              iramt like ekbe-dmbtr,
              outst like ekpo-netwr,
              eindt like eket-eindt,
    *          effwr LIKE ekpo-effwr,
            end of it_output.
    data  :  begin of it_title occurs 0,
               h11(5),
               h0(5),
               h1(13),
               h2(7),
               h3(15),
               h4(15),
               h5(10),
               h6(40),
               h7(20),
               h8(20),
               h9(20),
               h10(20),
               h12(10),
             end of it_title.
    data : flength.
    data : s_no type i value 1.
    * ---- Added by Gopi
    * Internal table for PO / WO Delivery Date
    data : begin of it_eket occurs 0,
             ebeln like eket-ebeln,
             ebelp like eket-ebelp,
             eindt like eket-eindt,
           end of it_eket.
    ***** selections
    selection-screen : skip.
    selection-screen : begin of block block1 with frame title text-001.
    parameters : s_bukrs like ekko-bukrs.
    select-options :  s_ebeln for ekko-ebeln,
                      s_bedat for ekko-bedat,
                      s_ekgrp for ekko-ekgrp.
    *                  s_hdg   for ekko-ekgrp.
    selection-screen : end of block block1.
    selection-screen begin of block btch with frame title text-003.
    parameters: excel as checkbox,
                file(128) type c.
    selection-screen end of block btch.
    selection-screen begin of block block2 with frame title text-002.
    parameters: asat as checkbox,
                p_date like sy-datum.
    selection-screen end of block block2.
    *---------AT SELECTION-SCREEN------------------------------------------*
    at selection-screen.
    at selection-screen on value-request for file.
      perform get_file_name using file.
    **** main program code**************************************************
    start-of-selection.
      it_title-h11 = 'S.No'.
      it_title-h0  = 'Group'.
      it_title-h1  = 'PO Number'.
      it_title-h2  = 'PO Item'.
      it_title-h3  = 'PO Creator'.
      it_title-h4  = 'Requisitor'.
      it_title-h5  = 'PO Date'.
      it_title-h6  = 'PO Short Text'.
      it_title-h7  = 'PO Amount'.
      it_title-h8  = 'GR/SE Amount'.
      it_title-h9  = 'IR Amount'.
      it_title-h10 = 'Outstanding'.
      it_title-h12 = 'Del. Date'.
      append it_title.
      perform extract_po_details_new.                           "20070814
      perform extract_po_history_new.                           "20070814
      perform calculate_outstanding_new.                        "20070814
    end-of-selection.
      perform display_report.
      if excel = 'X'.
        perform download.
      endif.
    * ---- Added by Gopi
    top-of-page.
      perform page_heading.
    *************************** display_report ****************************
    form display_report.
    *  it_title-h11 = 'S.No'.
    *  it_title-h0  = 'Group'.
    *  it_title-h1  = 'PO Number'.
    *  it_title-h2  = 'PO Item'.
    *  it_title-h3  = 'PO Creator'.
    *  it_title-h4  = 'Requisitor'.
    *  it_title-h5  = 'PO Date'.
    *  it_title-h6  = 'PO Short Text'.
    *  it_title-h7  = 'PO Amount'.
    *  it_title-h8  = 'GR/SE Amount'.
    *  it_title-h9  = 'IR Amount'.
    *  it_title-h10 = 'Outstanding'.
    *  it_title-h12 = 'Del Date'.
    *  APPEND it_title.
    *  WRITE : / 'Outstanding PO Listing Report'.
    *  ULINE.
    *  FORMAT COLOR COL_HEADING.
    *  WRITE : /1   it_title-h11,
    *           7   it_title-h0,
    *           14  it_title-h1,
    *           29  it_title-h2,
    *           38  it_title-h3,
    *           53  it_title-h4,
    *           68  it_title-h5,
    *           79  it_title-h6,
    *           122 it_title-h7,
    *           142 it_title-h8,
    *           162 it_title-h9,
    *           182 it_title-h10,
    *           202 it_title-h12.
    *  FORMAT COLOR OFF.
    *  ULINE.
    * If Output table is not empty
      if not it_output[] is initial.
        loop at it_output.
          on change of it_output-ebeln.
            uline.
            write : /1(5)  s_no, 6 sy-vline,
                     7  it_output-ekgrp,
                    14  it_output-ebeln,
                    29  it_output-ebelp,
                    38  it_output-ernam,
                    53  it_output-afnam,
                    68  it_output-bedat,
                    79  it_output-txz01,
                    122 it_output-netwr,
                    142 it_output-dmbtr,
                    162 it_output-iramt,
                    182 it_output-outst,
                    202 it_output-eindt.
            s_no = s_no + 1.
          else.
            write :/6 sy-vline,
                    29  it_output-ebelp,
                    38  it_output-ernam,
                    53  it_output-afnam,
                    68  it_output-bedat,
                    79  it_output-txz01,
                    122 it_output-netwr,
                    142 it_output-dmbtr,
                    162 it_output-iramt,
                    182 it_output-outst,
                    202 it_output-eindt.
          endon.
    *      WRITE :/6 sy-vline.
          clear : it_output.
        endloop.
      else.
    * If Output table is empty
        format color 5 intensified on.
       write : / 'No outstanding report generated for the purchasing group'
                  ,s_ekgrp-low, 'to', s_ekgrp-high,'for the period'
                  ,s_bedat-low, 'to', s_bedat-high.
        format color off.
      endif.
    endform.
    **************************** download*********************************
    form download.
      data: begin of it_download_header occurs 1,
               h0(5),
               h1(13),
               h2(7),
               h3(15),
               h4(15),
               h5(10),
               h6(40),
               h7(20),
               h8(20),
               h9(20),
               h10(20),
               h12(10).
      data: end of it_download_header.
      it_download_header-h0  = 'Group'.
      it_download_header-h1  = 'PO Number'.
      it_download_header-h2  = 'PO Item'.
      it_download_header-h3  = 'PO Creator'.
      it_download_header-h4  = 'Requisitor'.
      it_download_header-h5  = 'PO Date'.
      it_download_header-h6  = 'PO Short Text'.
      it_download_header-h7  = 'PO Amount'.
      it_download_header-h8  = 'GR/SE Amount'.
      it_download_header-h9  = 'IR Amount'.
      it_download_header-h10 = 'Outstanding'.
      it_download_header-h12 = 'Del. Date'.
      append it_download_header.
      call function 'WS_DOWNLOAD'
           exporting
                codepage            = 'IBM'
                filename            = file
                filetype            = 'DAT'
           importing
                filelength          = flength
           tables
                data_tab            = it_download_header
           exceptions
                file_open_error     = 1
                file_write_error    = 2
                invalid_filesize    = 3
                invalid_table_width = 4
                invalid_type        = 5.
      call function 'WS_DOWNLOAD'
           exporting
                codepage            = 'IBM'
                filename            = file
                filetype            = 'DAT'
                mode                = 'A'
           importing
                filelength          = flength
           tables
                data_tab            = it_output
           exceptions
                file_open_error     = 1
                file_write_error    = 2
                invalid_filesize    = 3
                invalid_table_width = 4
                invalid_type        = 5.
      if sy-subrc ne 0.
        message e999 with 'error downloading file :' file.
      endif.
    endform.
    *&      Form  get_file_name
    *       text
    *      -->P_P_FNAME  text
    form get_file_name using    p_fname.
      call function 'WS_FILENAME_GET'
           exporting
                def_filename     = p_fname
                mask             = ',*.*,*.*.'
                mode             = 'S'
           importing
                filename         = p_fname
           exceptions
                inv_winsys       = 1
                no_batch         = 2
                selection_cancel = 3
                selection_error  = 4
                others           = 5.
    endform.                    " get_file_name
    *&      Form  page_heading
    *       text
    *  -->  p1        text
    *  <--  p2        text
    form page_heading.
    *  it_title-h11 = 'S.No'.
    *  it_title-h0  = 'Group'.
    *  it_title-h1  = 'PO Number'.
    *  it_title-h2  = 'PO Item'.
    *  it_title-h3  = 'PO Creator'.
    *  it_title-h4  = 'Requisitor'.
    *  it_title-h5  = 'PO Date'.
    *  it_title-h6  = 'PO Short Text'.
    *  it_title-h7  = 'PO Amount'.
    *  it_title-h8  = 'GR/SE Amount'.
    *  it_title-h9  = 'IR Amount'.
    *  it_title-h10 = 'Outstanding'.
    *  it_title-h12 = 'Del. Date'.
    *  APPEND it_title.
      write : / 'Outstanding PO Listing Report'.
      uline.
      format color col_heading.
      write : /1   it_title-h11,
           7   it_title-h0,
           14  it_title-h1,
           29  it_title-h2,
           38  it_title-h3,
           53  it_title-h4,
           68  it_title-h5,
           79  it_title-h6,
           122 it_title-h7,
           142 it_title-h8,
           162 it_title-h9,
           182 it_title-h10,
           202 it_title-h12.
      format color off.
      uline.
    endform.                    " page_heading
    *&      Form  EXTRACT_PO_DETAILS_NEW
    *       text
    *  -->  p1        text
    *  <--  p2        text
    form extract_po_details_new.
      data: begin of it_po occurs 0,
        ebeln like ekko-ebeln,
        ebelp like ekpo-ebelp,
        ernam like ekko-ernam,
        ekgrp like ekko-ekgrp,
        bedat like ekko-bedat,
        txz01 like ekpo-txz01,
        netwr like ekpo-netwr,
        afnam like ekpo-afnam,
        effwr like ekpo-effwr.
      data: end of it_po.
      refresh it_output.
      if not p_date is initial.
        select a~ebeln b~ebelp a~ernam a~ekgrp a~bedat b~txz01 b~netwr
           b~afnam b~effwr
        into corresponding fields of table it_po
        from ekpo as b inner join ekko as a
        on b~ebeln = a~ebeln
        where a~bukrs = s_bukrs  and
            a~aedat le p_date  and
            a~ebeln in s_ebeln and
            a~bedat in s_bedat and
            a~ekgrp in s_ekgrp and
            a~frgke ne 'E'     and
            b~loekz not in ('L', 'S', 'X').
      else.
        select a~ebeln b~ebelp a~ernam a~ekgrp a~bedat b~txz01 b~netwr
           b~afnam b~effwr
        into corresponding fields of table it_po
        from ekpo as b inner join ekko as a
        on b~ebeln = a~ebeln
        where a~bukrs = s_bukrs  and
            a~ebeln in s_ebeln and
            a~bedat in s_bedat and
            a~ekgrp in s_ekgrp and
            a~frgke ne 'E'     and
            b~loekz not in ('L', 'S', 'X').
      endif.
      sort it_po by ebeln ebelp.
      delete adjacent duplicates from it_po.
      delete it_po where ekgrp eq 'HDB' and ebelp eq 10.    "20070814
      delete it_po where ebeln+0(1) eq '6'.
      loop at it_po.
        move-corresponding it_po to it_output.
        append it_output.
        clear it_output.
      endloop.
      refresh it_po.
      free it_po.
    endform.                    " EXTRACT_PO_DETAILS_NEW
    *&      Form  EXTRACT_PO_HISTORY_NEW
    *       text
    *  -->  p1        text
    *  <--  p2        text
    form extract_po_history_new.
      data: begin of it_ekbe occurs 2000,
              ebeln like ekbe-ebeln,
              ebelp like ekbe-ebelp,
              bewtp like ekbe-bewtp,
              shkzg like ekbe-shkzg,
              dmbtr like ekbe-dmbtr.
      data: end of it_ekbe.
      check not it_output[] is initial.
      select * into corresponding fields of table it_ekbe
        from ekbe for all entries in it_output
        where ebeln = it_output-ebeln and
              ebelp = it_output-ebelp and
              bewtp in ('E', 'N', 'Q', 'R', 'X').
      loop at it_ekbe.
        if it_ekbe-bewtp = 'E'.          "GET GR AMT
          move it_ekbe-ebeln to it_ekbe_gr-ebeln.
          move it_ekbe-ebelp to it_ekbe_gr-ebelp.
          move it_ekbe-bewtp to it_ekbe_gr-bewtp.
          if it_ekbe-shkzg = 'H'.
            it_ekbe_gr-dmbtr = it_ekbe-dmbtr * ( -1 ).
          else.
            it_ekbe_gr-dmbtr = it_ekbe-dmbtr.
          endif.
          collect it_ekbe_gr.
        else.                              "GET IR AMT
    *    ELSEIF IT_EKBE-BEWTP = 'N' OR     "GET IR AMT
    *           IT_EKBE-BEWTP = 'Q' OR
    *           IT_EKBE-BEWTP = 'R' OR
    *           IT_EKBE-BEWTP = 'X'.
          move it_ekbe-ebeln to it_ekbe_ir-ebeln.
          move it_ekbe-ebelp to it_ekbe_ir-ebelp.
          if it_ekbe-shkzg = 'H'.
            it_ekbe_ir-dmbtr = it_ekbe-dmbtr * ( -1 ).
          else.
            it_ekbe_ir-dmbtr = it_ekbe-dmbtr.
          endif.
          collect it_ekbe_ir.
        endif.
      endloop.
      refresh it_ekbe.
      free it_ekbe.
    endform.                    " EXTRACT_PO_HISTORY_NEW
    *&      Form  CALCULATE_OUTSTANDING_NEW
    *       text
    *  -->  p1        text
    *  <--  p2        text
    form calculate_outstanding_new.
    *  DATA: BEGIN OF IT_EKET OCCURS 10000,
    *          EBELN LIKE EKET-EBELN,
    *          EBELP LIKE EKET-EBELP,
    *          EINDT LIKE EKET-EINDT.
    *  DATA: END OF IT_EKET.
      sort: it_ekbe_gr, it_ekbe_ir.
      sort it_output by ebeln ebelp.
      loop at it_output.
        read table it_ekbe_gr with key ebeln = it_output-ebeln
                                       ebelp = it_output-ebelp.
        if sy-subrc = 0.
          move it_ekbe_gr-dmbtr to it_output-dmbtr.
        endif.
        read table it_ekbe_ir with key ebeln = it_output-ebeln
                                       ebelp = it_output-ebelp.
        if sy-subrc = 0.
          move it_ekbe_ir-dmbtr to it_output-iramt.
        endif.
        if it_output-iramt gt it_output-netwr.
          delete it_output. " where iramt gt it_output-netwr.
          clear : it_output.
          continue.
        endif.
        if it_output-ekgrp eq 'HDB'.
          if it_output-netwr = it_output-iramt.
            delete it_output.
            clear it_output.
          else.
            it_output-outst = it_output-netwr - it_output-iramt.
            modify it_output.
          endif.
        else.
          if it_output-netwr = it_output-dmbtr.
            if it_output-dmbtr = it_output-iramt.
              delete it_output.
              clear it_output.
            else.
              it_output-outst = it_output-netwr - it_output-iramt.
              modify it_output.
            endif.
          else.
            if it_output-netwr = it_output-iramt.
              delete it_output.
              clear it_output.
            else.
              it_output-outst = it_output-netwr - it_output-iramt.
              modify it_output.
            endif.
          endif.
        endif.
      endloop.
      sort it_output by ebeln ebelp.
      check not it_output[] is initial.
      select * into corresponding fields of table it_eket
        from eket for all entries in it_output
        where ebeln = it_output-ebeln and
              ebelp = it_output-ebelp.
      sort it_eket by ebeln ebelp.
      loop at it_output.
        read table it_eket with key ebeln = it_output-ebeln
                                    ebelp = it_output-ebelp.
        if sy-subrc = 0.
          it_output-eindt = it_eket-eindt.
        else.
          clear it_output-eindt.
        endif.
        modify it_output.
      endloop.
      sort it_output by ekgrp ebeln ebelp.
    endform.                    " CALCULATE_OUTSTANDING_NEW
    Regards
    Gopi

Maybe you are looking for