Change datasource in existing report

Hi,
I have created a WebI report (SAP Business Objects BI Platform 4.0 Client Tools (version 14.0.2.364)), on top of a BEx query. The report has one crosstab table with additional variables created. I now want to change the original BEx query to a new BEx query. Is it possible to make that change without changing the entire report? Is it possible to change just the underlying query? Please help! Thanks!
-Janice

Hi,
the workflow you need to follow is:
Data -> Data Provider -> Tools -> Change Source -> Query -> Specify new source -> Select data Source -> BEx  etc..
This will bring up a wizard where it will make assumptions about object mappings. you need to confirm or modif these.
Providing that the master and meta data isn't too radically different in the new target BEx, you're report may survive
Regards,
H

Similar Messages

  • Attempt to assign data set as datasource for existing report

    There must be something stupid I am missing.
    1) Created a report with Crystal Reports 2011
    2) It queries a table in a SQL 2008 database
    3) The internal select statement is
    SELECT "CUSTOMER"."rname", "CUSTOMER"."radd", "CUSTOMER"."radd2", "CUSTOMER"."rcity", "CUSTOMER"."rprov", "CUSTOMER"."rpostal", "CUSTOMER"."rcountry"
    FROM   "Data"."dbo"."CUSTOMER" "CUSTOMER"
    ORDER BY "CUSTOMER"."rname"
    4) Now I am attempting to use the report in Visual Basic 2010 but using a data set as the source
    5) Following examples I have looked at this is the code
    Private Sub CustomerCrystalReport2frm_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
            ' Define connection information
            Dim ConnectionInfo As New ConnectionInfo
            ConnectionInfo.ServerName = "TEST7\TEST7"
            ConnectionInfo.DatabaseName = "Data"
            ConnectionInfo.UserID = "Master"
            ConnectionInfo.Password = "MasterPassword"
            ' Load the existing report
            Dim rd As ReportDocument = New ReportDocument
            rd.Load(Application.StartupPath & "\Crystal Reports\DGVCustomerListing.rpt")
            SetDBLogonForReport(ConnectionInfo, rd) ' Set the report table connections
            ' This shows the report has loaded the records using the internal select statement (18305 records)
            Debug.Print(" Report Document Records=" & rd.Rows.Count)
            ' Create the data set with the records I want the report to use
            Dim ReportInfo As DataSet = New DataSet()    ' To hold data to pass to the report
            Dim SQLSelect As String = "select * FROM Data.dbo.Customer where rname LIKE 'z%' order by rname"
            ReportInfo = FillDataSet(SQLSelect, "ReportData")   ' Fill the data set to pass to the report
            ' This shows the data set contains the expected records (57 records)
            Debug.Print(" Data Set Records=" & ReportInfo.Tables("ReportData").Rows.Count)
            ' Change the source of the report
            rd.SetDataSource(ReportInfo)
            ' This changing the source had no effect records still (18305 records)
            Debug.Print(" Report Document Records=" & rd.Rows.Count)
            CrystalReportViewer1.ReportSource = rd  ' Bind report document to crystal report viewer
        End Sub
        Private Sub SetDBLogonForReport(ByVal ConnectionInfo As ConnectionInfo, ByVal ReportDocument As ReportDocument)
            Dim Tables As Tables = ReportDocument.Database.Tables
            For Each table As CrystalDecisions.CrystalReports.Engine.Table In Tables
                Dim TableLogOnInfo As TableLogOnInfo = table.LogOnInfo
                TableLogOnInfo.ConnectionInfo = ConnectionInfo
                table.ApplyLogOnInfo(TableLogOnInfo)
            Next
        End Sub
    end Sub
    6) The report is appearing in the viewer with 18305 records
    Any help would be appreciated

    Setting the report table connections caused the report to fill with data.
    At this point I seemed unable to reset the datasource.
    Also the set data source needed further clearification.
    The simplified following code works:
    Dim rd As ReportDocument = New ReportDocument
    rd.Load(Application.StartupPath & "\Crystal Reports\DGVCustomerListing.rpt")
    ' Create the data set with the records I want the report to use
    Dim ReportInfo As DataSet = New DataSet()    ' To hold data to pass to the report
    Dim SQLSelect As String = "select * FROM Data.dbo.Customer where rname LIKE 'z%' order by rname"
    ReportInfo = FillDataSet(SQLSelect, "ReportData")   ' Fill the data set to pass to the report
    ' Change the source of the report
    rd.SetDataSource(ReportInfo.Tables("ReportData"))
    CrystalReportViewer1.ReportSource = rd  ' Bind report document to crystal report viewer

  • Change datasource of Crystal Report via code

    Hi all!
    I'm developing partner solution for SAP B1 8.8 in C# and prepared some nice crystal reports. But they are bound to my default database for now. I want to include them to my installation file and change saved datasource location (Server, Company Name, User name, User password) in my installation script as soon as I get this values, entered by user. But I don't know the way how to change datasource in rpt file. I've tried the following:
    using CrystalDecisions.CrystalReports.Engine;
    ReportDocument rDoc = new ReportDocument();
    rDoc.Load(@"C:\Temp\Report2.rpt");
    rDoc.DataSourceConnections[0].SetConnection("Server", "SBOTest", "manager", "manager");
    rDoc.SaveAs(@"C:\Temp\Report3.rpt");
    rDoc.Close();
    but it save no changes to rpt file.
    I think, this thread belongs mostly to Development/SDK thread, because here most of the people make programs and potentially met this problem in the past.

    public void SetCrystalLogin(string sUser, string sPassword, string sServer, string sCompanyDB, CrystalDecisions.CrystalReports.Engine.ReportDocument oRpt)
                CrystalDecisions.Shared.ConnectionInfo oConnectInfo = new CrystalDecisions.Shared.ConnectionInfo();
                oConnectInfo.DatabaseName = sCompanyDB;
                oConnectInfo.ServerName = sServer;
                oConnectInfo.UserID = sUser;
                oConnectInfo.Password = sPassword;
                // Set the logon credentials for all tables
                SetCrystalTablesLogin(oConnectInfo, oRpt.Database.Tables);
                // Check for subreports
                foreach (CrystalDecisions.CrystalReports.Engine.Section oSection in oRpt.ReportDefinition.Sections)
                    foreach (CrystalDecisions.CrystalReports.Engine.ReportObject oRptObj in oSection.ReportObjects)
                        if (oRptObj.Kind == CrystalDecisions.Shared.ReportObjectKind.SubreportObject)
                            // This is a subreport so set the logon credentials for this report's tables
                            CrystalDecisions.CrystalReports.Engine.SubreportObject oSubRptObj = oRptObj as CrystalDecisions.CrystalReports.Engine.SubreportObject;
                            // Open the subreport
                            CrystalDecisions.CrystalReports.Engine.ReportDocument oSubRpt = oSubRptObj.OpenSubreport(oSubRptObj.SubreportName);
                            SetCrystalTablesLogin(oConnectInfo, oSubRpt.Database.Tables);
                oRpt.Refresh();
                oRpt.SetDatabaseLogon(sUser, sPassword, sServer, sCompanyDB, false);
                oRpt.VerifyDatabase();
                oRpt.Refresh();
            private void SetCrystalTablesLogin(CrystalDecisions.Shared.ConnectionInfo oConnectInfo, Tables oTables)
                foreach (CrystalDecisions.CrystalReports.Engine.Table oTable in oTables)
                    CrystalDecisions.Shared.TableLogOnInfo oLogonInfo = oTable.LogOnInfo;
                    oLogonInfo.ConnectionInfo = oConnectInfo;
                    oTable.ApplyLogOnInfo(oLogonInfo);
    Edited by: Konstantin Rakhuba on May 6, 2010 11:44 AM
    Edited by: Konstantin Rakhuba on May 6, 2010 11:45 AM

  • Presentation Layer column name change effects on existing reports ?

    Hello Gurus,
    I have one requirement where user are not sure about the column names in Presentation Layer.
    so they want us to create the reports and once the reports are delivered they will give us the column name as per their requirement.
    now i read couple of blogs related to this, that does it affects the exiting reports?
    in couple of blogs they says that i won't. becaus BI server creates the alias for the old name and will reflects it wherever it's used in reports..
    So can anyone tell me where this alias name has been stored in OBIEE?
    and is there any precaution that needs to be done while doing this beacuse we are expecting to create around 40-50 reports and changing the column name after changing the presentation layer name change will increase lots of work..
    Thanking You..

    I've confirmed it on a 10g environment that when you rename the column in the RPD the existing reports reflect the change.
    What I was referring to in the statement you highlight is that a column name can be changed when being used as the definition of a report. If somebody specifies an abbreviation of the current name to fit it in a table or chart then it will not be updated from a name change in the RPD.
    So long as you build reports using the name provided by the RPD and none of the developers take the liberty of renaming it in the column properties of the request/analyses the single rename should take effect through all the reports you build.
    You can also manage the column name by renaming it in a report and using the save as system wide default. But the way you intend to do it would be the best method.
    Edited by: James - Projected on 25-May-2012 14:07

  • It's possible not change  structure of existing report by adding  group ?

    Hello Everybody,
    I have to create new group in a report already existed . But every time I do it in Graphical Data Model, when apply in Report Wizard, The report changes completely with the position of columns and even the style of the report is modified.
    How I can avoid this fact ?
    It's possible to don't have this changes when having new groups ?
    Thanks in advance.
    Regards.
    Edited by: 794982 on 25 sept. 2010 04:06

    Then the manner of creating the repeating frame is only to draw it manually in layout ?Yes
    Then my problem is it exceeds the limiit and it disrupts after.Which llimit you are talking about?
    And Why when I create repeating frame, the column which I draw it developp and the others remain fixed ?You mean the new column you created you can move outside the frame? And the column you had before you can not move?
    A hint while creating group repeating frame you will have to select all the objects and place it in the new created grouped repeating frame. Then create new fields inside that group repeating frame.
    -Ammad

  • Cannot change Datasource location in report

    Post Author: TomS
    CA Forum: Data Connectivity and SQL
    I have a CR report that I am working on (inherited from another developer). For the life of me, this report will NOT let me change the database location! I need to point it to another database (MS SQL Server) that is the same thing (same tables, etc) but a different name/data. I go to Database...Set Data Location; however, when I try to do the Update to update the data location, I get the message
    Database Connector Error: '42S02:[Microsoft][ODBC SQL Server Driver][SQL Server][Invalid object name 'Old_database_name_here.dbo.table_name', [Database Vendor Code: 208]
    It is as though the database name(s) is hard coded somewhere in the report. I have tried and tried to get this to point to another DB while developing in Crystal (using Print Preview) but it will not work. So I am stuck using my development database and not my production database.
    I feel as though I am going to have to rewrite this report entirely to allow me to test against different databases. Anyone got any idea as to why this will not let me change database sources? Any help appreciated. Thanks in advance.
    Tom

    Post Author: sharonmtowler
    CA Forum: Data Connectivity and SQL
    if it uses a stored procedure, it may be hardcoded in the dataset.
    you can export the report in crystal to a report definition select application and you can see where all your hidden items etc are.

  • Database structure changed. Mapping Crystal reports to new datasource

    There are several crystal reports that need to be remapped to a new database we have in place. The data structure has quite changed. I started using the 'Set datasource Location' option to map the new database fields to existing fields in the report. The problem shows up when trying to map fields from multiple tables to existing fields in the report from a single table. To elaborate, the old database structure has only one table used for a report and the new database structure has these same fileds coming from two different tables. The 'Set datasource Location'  option is leting me map the existing table used in the report to only one report. Is this how this functionality works or am I missing something. Please advise the best way to do this mapping.
    VJ

    hi VJ,
    when you're dealing with reports where the data source can change along with the number of tables or the table names or the field names etc. then this is a method that you can design with to avoid issues associated with datasource changes.
    you can also change existing reports to use this formula only method but of course there's a bit of work involved in changing reports vs. designing them like this from the ground up.
    -jamie

  • Changing Datasource and New Aliases in CRystal Reports 11

    <p>I am in the process of converting from Crystal 7 to Crystal 11. In existing reports that have been saved in 11, I need to point to new tables. After pointing to a new table I get error messages saying that it does not know the fields used in the report and prompts me to change all the aliases in all the formulas and fields used on the report. I checked the documentation and it looks like I have to do this manually. In older versions, you could change the alias and it would go through and make all the changes in the formulas and fields.</p><p>Could it be possible that a new version has removed a great feature?? Not only did I have to manually change the aliases - but doing so removed all the field names from the report - very annoying!! I have several reports where new tables are being used and will have to be changed and this task could be a disaster. </p><p> Has anyone encountered this or know of a way around it??</p><p><br />Thanks,</p><p>Anne</p>

    It took me a while, but I figured it out.  Click on Database - Database Expert.  The directions for changing the alias should be displayed (click the table name on the right and press F2).

  • Crystal Reports 2008 - ERROR when changing datasource

    Hi, I have a report that is connected to a test database that needs to have the datasource changed to the production database.
    The Crystal Report has 2 "on-demand" subreports that the datasource has been changed for as well.
    SQL 2000 Databases on 2 different servers (W2003) used the "Set Datasource Location" and followed steps listed previously in the forum.
    Databases have different names but all tables are same in both.
    Database Expert is showing all tables coming from new datasource BUT when report is run parameter prompt comes up, click ok
    Error message - "Failed to retrieve data from the database" - click OK
    Error message - "Invalid Argument provided"
    Does anyone have an ideas on how to track down the issues.
    Please let me know if you need any other information

    Ok answers below:-
    1. Crystal Reports 2008 Cersion 12.1.0.892
    2. Connecting via OLEDB
    3. Yes able to refresh newly created report without sub reports enclosed
    4. Didn't know that this could be done - this report was done for us by a consultant who doesn't know how to fix this issue and reckons there is a bug in Crystal
    5. Sub reports are accessed after main report is run (I think that means that they are linked)
    6. Not sure how to do this as am newbie to Crystal Reports and we are relying on the person that we contracted to write the reports to know what he is doing.
    Any help appreciated I will try to go into the sub report and unlink - think I have found out how to do this.
    Thanks for the help so far!!

  • MCRM_SETTINGS  report cant change the already existing consumer

    Hi Middleware gurus,
    I have a problem in setting up of  CRM middleware setup with ECC .  The scenario is ECC is connected to CRM already and data is transferred, so as a result of that for all the objects in CRM the default consumer is CRM.  And now due to some requirements , i want to connect this same CRM system to another ECC and so the requirement is to change this already existing default consumer to a new consumer as per the new ECC system.
    SO, I ran the report MCRM_SETTINGS to change the consumer but the result says- the object is already a consumer.
    So, now the question is - cant i over write the already existing consume  to a new consumer...
    Regards,
    Neni.

    Hello Neni,
    In case you want to connect 1 CRM to 2 ECC systems, you'd be following a MEP(Multiple Exchange Projects) scenario and not a MCRM setting so MCRM_SETTINGS won't be useful here.
    Or do you want to disconnect the first ECC and connect a new ECC to the same CRM?
    can you please clarify?
    BR,
    Rohit

  • Change subject area of existing reports......

    hi all
    Is it possible to change the subject area of the existing reports.
    in my case i had 3 reports on my dashboard having different subject areas.
    i went to the rpd level. and created a new subject area within the rpd which consists of all the 3 subject areas.
    is it possible, that i can use this new integrated subject area for my reports and dashboards that i creatd
    regards
    mahis

    go to the advanced tab of each request/report
    then you find Enter the name of the Subject Area field.. where you see your old subject area
    replace that with your new subject area name..
    Note: need not to click on Set SQL
    you also can do that in catalog manager.. open that report, right click properties > edit xml, replace old subject area name with new one...
    but, i prefer first one
    finally, why your all threads are opened?
    close them if they answered and respond back to them by assigning points..
    Edited by: Kishore Guggilla on Nov 26, 2010 5:55 PM

  • How to change existing reports of sap with CR

    Hello Professionals,
    I need your help on the following matter:
    We recently updated one of our costumers from 2007 to SAP B1 version 8.8
    So, now we are able to use the Crystal Reports-Viewer for most of existing standard-reports of SAP, such as the report for open invoices and so on.
    To the question:
    Our costumer wishes to change the report - instead of information like the installement no. (the costumer doesn't work with payment installements at all) he wishes to have other information, like card code and tel no. within the report.
    Now I tried to implement those informations. But I can't, because I don't know how to link the tables concernig primary keys and so on. And where can I find those "PLD-ITEMS"-tables??
    Can you help me please and hand over some further "how-to-information"?
    Thanks in advance,
    best regards,
    daniel

    Hi Juli,
    The procedure of how to link those table is pretty clear - so theoretically I know how I have to proceed within Crystal Reports in order to get some more - more or less useless - information into an existing report by linking some other tables perjoins into an query.
    The Problem is - to connect the ocrd or other tables concerning the business partners to the report I need the possibility of a correct and smart link. I can't think of any for a connection to the ritm-table. Gordon mentioned  that table in a comment before.
    Hi Gordon,
    meanwhile I got access to the help-information of the sdk. But how am I supposed to find the right information there? I've been into the section Customization Tools - Database Tables References.
    To tell the truth - I got problems understanding those infos and even more important: within the section reports I can't find further information to the open docs-report - is it a 'standard report'?
    Greetings and good start into the week tomorrow,
    daniel

  • Can we change the subject area of an existing report

    Hi,
    Is it possible to change the subject area of an existing anlaysis?
    Thanks,
    KK

    @842704 - Yes, you can change. Go to the Advanced Tab of the report, in the Request XML find and replace the name of your old SA name with the new name. Once done hit the Set XML button to apply your changes and save your report. We had done this for few reports and observed that mainly there are two instances found in the XML where the name of SA appears.
    <saw:criteria subjectArea="SAName">
    <saw:filter subjectArea="SAName">
    @Deepak - Had a query regarding changing the name of Subject Area with the option you provided. When we had tried to use that option (which is simpler than what I mentioned above), we observed that it used to work fine. However, in the request XML we found that for saw:criteria tag the value was updated but not for saw:filter (it still used to hold the name of old SA). Although the report worked fine. Any thoughts regarding this behaviour?
    Thanks

  • Change Selection criteria for existing report in Report painter

    Hi Experts,
    We are on 4.7, using report painter for getting reports for Cost center & Profit Center. For one of the report we have selection criteria as Cost center and cost center group, but now user want us to add new selection field as Cost element and cost element Group to same report. We have tried all the options from GR32 ->Edit-> General Selection, but we don't find cost element in Key figure listed there.
    Please let us know how can we add the new field to selection criteria. We also would like to know is this is possible with existing report  to add new fields or not? Is that we need to create new report for this?
    Thanks in advance..
    Shilpa

    Shilpa-
    In my opinion the best way to troubleshoot issues like this is to go to SAP delivered standard reports and see how they are setup. For example, in your case you want to add cost element and cost element group to your report. There is one standard report from SAP - Transaction :S_ALR_87013611 which has both cost center, cost center group and cost element, cost element group in the selection criteria. You can look how this report is set up, and maintain your report in a similar fashion. Atleast this way, it will give you an idea.
    Go to transaction code GRR3 and under library look for report "1SIP-001". By double clicking on the row, you will see how it is maintained.
    Hope this helps.
    Shail

  • Adding a new Field to an existing report

    Hi all,
    Can anybody tell me, how to add an extra field in existing
    report, without changing the basic calulation, which i made
    in the same report.
    Regards
    Hema

    okay... that is not a standard program.
    sombody developed it.following is my existing code, here in last column i want to add BOM(mast-stlnr) and Component(stpo-idnrk). remaining things are okay.
    REPORT ZPOTREND NO STANDARD PAGE HEADING
                      LINE-SIZE 195
                      LINE-COUNT 60(3)
                      MESSAGE-ID Z1.
    TABLES: EKBE,
            MARA,
            TCURR.
    SELECT-OPTIONS: S_GJAHR FOR EKBE-GJAHR,
                    S_BUDAT FOR EKBE-BUDAT DEFAULT SY-DATUM NO-EXTENSION,
                    S_MATNR FOR EKBE-MATNR,
                    S_WERKS FOR EKBE-WERKS DEFAULT 'CE',
                    S_MTART FOR MARA-MTART.
    PARAMETERS: X_APP_L TYPE P DECIMALS 2 NO-DISPLAY,
                X_APP_H TYPE P DECIMALS 2 NO-DISPLAY,
                X_DTL   AS CHECKBOX.
    DATA: BEGIN OF I_EKBE OCCURS 0,
          BUDAT LIKE EKBE-BUDAT,
          MENGE LIKE EKBE-MENGE,
          DMBTR LIKE EKBE-DMBTR,
          SHKZG LIKE EKBE-SHKZG,
          EBELN LIKE EKBE-EBELN,
          MATNR LIKE EKBE-MATNR,
          WERKS LIKE EKBE-WERKS,
          MTART LIKE MARA-MTART,
          MEINS LIKE MARA-MEINS,
    END OF I_EKBE.
    DATA: P_EBELN LIKE EKBE-EBELN,
          P_MATNR LIKE EKBE-MATNR,
          P_WERKS LIKE EKBE-WERKS,
          P_MTART LIKE MARA-MTART,
          P_MEINS LIKE MARA-MEINS.
    DATA: BEGIN OF YMTH OCCURS 10,
          YYMM(6),
          MTH(3),
          COL TYPE I,
          MENGE LIKE EKBE-MENGE,
          DMBTR LIKE EKBE-DMBTR,
    END OF YMTH.
    DATA: S_YMTH LIKE YMTH OCCURS 10 WITH HEADER LINE.
    DATA: W_YMTH LIKE YMTH OCCURS 10 WITH HEADER LINE.
    DATA: G_YMTH LIKE YMTH OCCURS 10 WITH HEADER LINE.
    DATA: S_FLAG.                                               "MTART FLAG
    DATA: BEGIN OF CDATE,
          YYMM(6),
          DD(2) VALUE '01',
    END OF CDATE.
    DATA: SDATE LIKE SY-DATUM.
    DATA: CMTH(6),
          PMTH(6),
          LMTH1(6),
          LMTH2(6),
          MTH(2).
    DATA: W_MENGE LIKE EKBE-MENGE,
          W_DMBTR LIKE EKBE-DMBTR,
          W_MENGE1 LIKE EKBE-MENGE,
          W_DMBTR1 LIKE EKBE-DMBTR,
          W_TOTAL TYPE P DECIMALS 2,
          W_COL TYPE I,
          WTEXT(18),
          APP TYPE P DECIMALS 4,
          APP1 TYPE P DECIMALS 4,
          APP2 TYPE P DECIMALS 4.
    PERFORM GET_YMTH.
    SELECT P~BUDAT P~MENGE P~DMBTR P~SHKZG P~EBELN P~MATNR P~WERKS
           Q~MTART Q~MEINS
           INTO TABLE I_EKBE
             FROM EKBE AS P INNER JOIN MARA AS Q
           ON P~MATNR = Q~MATNR
           WHERE P~GJAHR IN S_GJAHR
             AND P~BUDAT IN S_BUDAT
             AND P~MATNR IN S_MATNR
             AND P~WERKS IN S_WERKS
             AND P~BEWTP = 'E'
             AND Q~MTART IN S_MTART.
    FORMAT INTENSIFIED OFF.
    IF X_DTL <> 'X'.
       LOOP AT I_EKBE.
          I_EKBE-EBELN = SPACE.
          MODIFY I_EKBE.
       ENDLOOP.
    ENDIF.
    SORT I_EKBE BY WERKS MTART MATNR EBELN BUDAT.
    LOOP AT I_EKBE.
      CMTH = I_EKBE-BUDAT(6).
      IF P_WERKS IS INITIAL.
        P_WERKS = I_EKBE-WERKS.
        P_MTART = I_EKBE-MTART.
        P_MATNR = I_EKBE-MATNR.
        P_EBELN = I_EKBE-EBELN.
        P_MEINS = I_EKBE-MEINS.
        PMTH = CMTH.
      ENDIF.
      IF P_WERKS NE I_EKBE-WERKS.
        PERFORM CHG_MTH.
        PERFORM CHG_MATNR.
        PERFORM CHG_MTART.
        PERFORM CHG_WERKS.
      ENDIF.
      IF P_MTART NE I_EKBE-MTART.
        PERFORM CHG_MTH.
        PERFORM CHG_MATNR.
        PERFORM CHG_MTART.
      ENDIF.
      IF P_MATNR NE I_EKBE-MATNR.
        PERFORM CHG_MTH.
        PERFORM CHG_MATNR.
      ENDIF.
      IF P_EBELN NE I_EKBE-EBELN.
        PERFORM CHG_MTH.
        PERFORM CHG_MATNR.
      ENDIF.
      IF PMTH NE CMTH.
        PERFORM CHG_MTH.
      ENDIF.
      IF I_EKBE-SHKZG = 'H'.
        I_EKBE-MENGE = I_EKBE-MENGE * -1.
        I_EKBE-DMBTR = I_EKBE-DMBTR * -1.
      ENDIF.
      IF I_EKBE-DMBTR NE 0.
        W_MENGE = W_MENGE + I_EKBE-MENGE.
        W_DMBTR = W_DMBTR + I_EKBE-DMBTR.
      ENDIF.
    ENDLOOP.
    PERFORM CHG_MTH.
    PERFORM CHG_MATNR.
    PERFORM CHG_MTART.
    PERFORM CHG_WERKS.
    TOP-OF-PAGE.
      WRITE:/ SY-DATUM,SY-UZEIT,
              77 'A M T E K   E N G I N E E R I N G   L T D',
              180 'Page', (4) SY-PAGNO.
      WRITE: / SY-REPID,
              77 '     Purchase Price Trending Report      ',
              180 SY-UNAME.
      write: /78 'From Date', S_BUDAT-LOW, 'To Date', S_BUDAT-HIGH.
      SKIP.
      WRITE: / 'SBU :', I_EKBE-WERKS,
               '     Material Type :', I_EKBE-MTART.
      SKIP.
      READ TABLE YMTH WITH KEY YYMM = '999901'.
      IF SY-SUBRC EQ 0.
        WRITE AT YMTH-COL ' APP Change'.
      ENDIF.
      WRITE: /01 'Part No',
              19 'PO No',
              31 'Curr'.
      LOOP AT YMTH.
        YMTH-COL = YMTH-COL + 3.
        IF YMTH-YYMM NE '999901'.
          WRITE AT YMTH-COL YMTH-YYMM(4).
          WRITE YMTH-MTH.
        ELSE.
          WRITE AT YMTH-COL '       %'.
        ENDIF.
      ENDLOOP.
      ULINE.
    *&      Form  get_ymth
          text
    -->  p1        text
    <--  p2        text
    FORM GET_YMTH.
      CMTH = S_BUDAT-HIGH(6).
      PMTH = S_BUDAT-LOW(6).
      IF S_BUDAT-HIGH IS INITIAL.
        CMTH = PMTH.
      ELSEIF S_BUDAT-LOW IS INITIAL.
        PMTH = CMTH.
      ENDIF.
      LMTH1 = CMTH.
      CDATE-YYMM = CMTH.
      SDATE = CDATE.
      SDATE = SDATE - 1.
      LMTH2 = SDATE(6).
      WHILE PMTH <= CMTH.
        MTH = CMTH+4(2).
        CDATE-YYMM = CMTH.
        YMTH-YYMM = CMTH.
        PERFORM GET_MTH.
        APPEND YMTH.
        SDATE = CDATE.
        SDATE = SDATE - 1.
        CMTH = sdate(6).
      ENDWHILE.
      YMTH-YYMM = '999901'.
      YMTH-MTH = ' % '.
      APPEND YMTH.
      SORT YMTH BY YYMM.
      W_COL = 21.
      LOOP AT YMTH.
        W_COL = W_COL + 15.
        YMTH-COL = W_COL.
        MODIFY YMTH.
      ENDLOOP.
      APPEND LINES OF YMTH TO S_YMTH.
      APPEND LINES OF YMTH TO W_YMTH.
      APPEND LINES OF YMTH TO G_YMTH.
      REFRESH YMTH.
      APPEND LINES OF S_YMTH TO YMTH.
    ENDFORM.                                                    " get_ymth
    *&      Form  get_mth
          text
    -->  p1        text
    <--  p2        text
    FORM GET_MTH.
      CASE MTH.
        WHEN '01'.
          YMTH-MTH = 'Jan'.
        WHEN '02'.
          YMTH-MTH = 'Feb'.
        WHEN '03'.
          YMTH-MTH = 'Mar'.
        WHEN '04'.
          YMTH-MTH = 'Apr'.
        WHEN '05'.
          YMTH-MTH = 'May'.
        WHEN '06'.
          YMTH-MTH = 'Jun'.
        WHEN '07'.
          YMTH-MTH = 'Jul'.
        WHEN '08'.
          YMTH-MTH = 'Aug'.
        WHEN '09'.
          YMTH-MTH = 'Sep'.
        WHEN '10'.
          YMTH-MTH = 'Oct'.
        WHEN '11'.
          YMTH-MTH = 'Nov'.
        WHEN '12'.
          YMTH-MTH = 'Dec'.
      ENDCASE.
    ENDFORM.                                                    " get_mth
    *&      Form  chg_matnr
          text
    -->  p1        text
    <--  p2        text
    FORM CHG_MATNR.
      CLEAR W_TOTAL.
      LOOP AT YMTH.
        W_TOTAL = W_TOTAL + YMTH-DMBTR.
      ENDLOOP.
      IF W_TOTAL = 0.
        EXIT.
      ENDIF.
      CLEAR: W_DMBTR, W_MENGE, W_DMBTR1, W_MENGE1, APP, APP1, APP2.
      READ TABLE YMTH WITH KEY YYMM = LMTH2.
      IF SY-SUBRC EQ 0 AND
         YMTH-MENGE NE 0.
        W_DMBTR = YMTH-DMBTR.
        W_MENGE = YMTH-MENGE.
        READ TABLE YMTH WITH KEY YYMM = LMTH1.
        IF SY-SUBRC EQ 0.
          APP = W_DMBTR / W_MENGE.
          APP1 = YMTH-DMBTR / YMTH-MENGE.
          APP2 = ( APP1 - APP ) / APP * 100.
        ENDIF.
      ENDIF.
      IF X_APP_L IS INITIAL AND
         X_APP_H IS INITIAL.
      ELSE.
        IF APP2 < X_APP_L OR
           APP2 > X_APP_H.
          EXIT.
          CLEAR: W_DMBTR, W_MENGE, APP.
          P_MATNR = I_EKBE-MATNR.
          P_EBELN = I_EKBE-EBELN.
          PERFORM CLR_YMTH.
        ENDIF.
      ENDIF.
      SKIP.
    WRITE:/ P_MATNR, ' Amount  ',
             'USD'.
    LOOP AT YMTH.
       WRITE AT YMTH-COL(12) YMTH-DMBTR NO-ZERO.
    ENDLOOP.
    WRITE:/(18) ' ', ' Quantity',
            P_MEINS.
    LOOP AT YMTH.
       WRITE AT YMTH-COL(12) YMTH-MENGE NO-ZERO.
    ENDLOOP.
      WRITE:/ P_MATNR(18), P_EBELN, 'USD' UNDER 'Curr'.
      LOOP AT YMTH.
        IF YMTH-YYMM NE '999901'.
          CLEAR APP.
          IF Ymth-menge ne 0.
            APP = YMTH-DMBTR / YMTH-MENGE.
          ENDIF.
          WRITE AT YMTH-COL(12) APP.
          READ TABLE S_YMTH WITH KEY YYMM = YMTH-YYMM.
          IF SY-SUBRC EQ 0.
            S_YMTH-MENGE = S_YMTH-MENGE + YMTH-MENGE.
            S_YMTH-DMBTR = S_YMTH-DMBTR + YMTH-DMBTR.
            MODIFY S_YMTH INDEX SY-TABIX.
          ENDIF.
          READ TABLE W_YMTH WITH KEY YYMM = YMTH-YYMM.
          IF SY-SUBRC EQ 0.
            W_YMTH-MENGE = W_YMTH-MENGE + YMTH-MENGE.
            W_YMTH-DMBTR = W_YMTH-DMBTR + YMTH-DMBTR.
            MODIFY W_YMTH INDEX SY-TABIX.
          ENDIF.
        ELSE.
          WRITE AT YMTH-COL(12) APP2.
        ENDIF.
      ENDLOOP.
      CLEAR: W_DMBTR, W_MENGE, APP.
      P_MATNR = I_EKBE-MATNR.
      P_EBELN = I_EKBE-EBELN.
      PERFORM CLR_YMTH.
    ENDFORM.                                                    " chg_matnr
    *&      Form  chg_mtart
          text
    -->  p1        text
    <--  p2        text
    FORM CHG_MTART.
      SKIP.
      ULINE.
      CONCATENATE P_MTART 'Total' INTO WTEXT SEPARATED BY SPACE.
      PERFORM PRN_TOT TABLES S_YMTH.
      P_MTART = I_EKBE-MTART.
      LOOP AT S_YMTH.
        CLEAR: S_YMTH-DMBTR, S_YMTH-MENGE.
        MODIFY S_YMTH.
      ENDLOOP.
    ENDFORM.                                                    " chg_mtart
    *&      Form  chg_werks
          text
    -->  p1        text
    <--  p2        text
    FORM CHG_WERKS.
      CONCATENATE P_WERKS 'Total' INTO WTEXT SEPARATED BY SPACE.
      PERFORM PRN_TOT TABLES W_YMTH.
      CLEAR: W_DMBTR, W_MENGE, APP.
      P_WERKS = I_EKBE-WERKS.
      LOOP AT W_YMTH.
        CLEAR: W_YMTH-DMBTR, W_YMTH-MENGE.
        MODIFY W_YMTH.
      ENDLOOP.
      NEW-PAGE.
    ENDFORM.                                                    " chg_werks
    *&      Form  chg_mth
          text
    -->  p1        text
    <--  p2        text
    FORM CHG_MTH.
      READ TABLE YMTH WITH KEY YYMM = PMTH.
      IF SY-SUBRC EQ 0.
        YMTH-MENGE = W_MENGE.
        YMTH-DMBTR = W_DMBTR.
        MODIFY YMTH INDEX SY-TABIX.
      ENDIF.
      CLEAR: W_MENGE, W_DMBTR.
      PMTH = CMTH.
    ENDFORM.                                                    " chg_mth
    *&      Form  clr_ymth
          text
    -->  p1        text
    <--  p2        text
    FORM CLR_YMTH.
      LOOP AT YMTH.
        CLEAR: YMTH-DMBTR, YMTH-MENGE.
        MODIFY YMTH.
      ENDLOOP.
    ENDFORM.                                                    " clr_ymth
    *&      Form  prn_tot
          text
    -->  p1        text
    <--  p2        text
    FORM PRN_TOT TABLES I_YMTH STRUCTURE YMTH.
      CLEAR: W_DMBTR, W_MENGE, W_DMBTR1, W_MENGE1, APP, APP1, APP2.
      READ TABLE I_YMTH WITH KEY YYMM = LMTH2.
      IF SY-SUBRC EQ 0 AND
         I_YMTH-MENGE NE 0.
        W_DMBTR = I_YMTH-DMBTR.
        W_MENGE = I_YMTH-MENGE.
        READ TABLE I_YMTH WITH KEY YYMM = LMTH1.
        IF SY-SUBRC EQ 0.
          APP  = W_DMBTR / W_MENGE.
          APP1 = I_YMTH-DMBTR / I_YMTH-MENGE.
          APP2 = ( APP1 - APP ) / APP * 100.
        ENDIF.
      ENDIF.
    WRITE:/ WTEXT, ' Amount  ',
             'USD'.
      LOOP AT I_YMTH.
        SELECT SINGLE * FROM TCURR
          WHERE FCURR = 'SGD'
          AND   TCURR = 'USD'.
          I_YMTH-DMBTR = I_YMTH-DMBTR * TCURR-UKURS.
       WRITE AT I_YMTH-COL(12) I_YMTH-DMBTR NO-ZERO.
      ENDLOOP.
    WRITE:/(18) ' ', ' Quantity'.
    LOOP AT I_YMTH.
       WRITE AT I_YMTH-COL(12) I_YMTH-MENGE NO-ZERO.
    ENDLOOP.
      WRITE:/(18) ' ', ' APP     ', 'USD'.
      LOOP AT I_YMTH.
        IF I_YMTH-YYMM NE '999901'.
          CLEAR APP.
          IF I_YMTH-MENGE NE 0.
            APP = I_YMTH-DMBTR / I_YMTH-MENGE.
          ENDIF.
          WRITE AT I_YMTH-COL(12) APP.
        ELSE.
          WRITE AT I_YMTH-COL(12) APP2.
        ENDIF.
      ENDLOOP.
      ULINE.
      CLEAR: W_DMBTR, W_MENGE, APP.
    ENDFORM.                    " prn_tot

Maybe you are looking for

  • Pop Up Menu HELP!

    i am new in using Dreamweaver, but i know the basics. i've been working on this site for a few months, and am not trying to find the best way to create a pop-up/drop down menu for my site. i found out that Dreamweaver should be able to do this, and a

  • **To branch to a new page in Smart forms after main window**

    I have three pages where on second pages main window so my data many be carry on next 3, 4, pages and my requirement is to display  data(like notes ) on last page after all contain of main window .that last  third page is different formatting on basi

  • Businexsss content activation

    Hi Experts, Could you please ellaborate all steps(R/3 Side & BW Side) involved in Business Content Activation(interms of D,M,A Version) and Installation.Thank you venkat Edited by: VenkataSubrmanian Ganesan on Jan 2, 2008 9:56 AM

  • Decode and Ifthenelse

    Hi Experts,                 I would like to know the functioning of decode and ifthenelse functions. Which one is faster. Is there difference in the performance of these two. Thanks & Regards Alex Oommen

  • IPhoto won't delete photos from camera after importing. It used to....

    Hello...anybody have any thoughts on this issue? I always check the 'delete after importing' option when connecting camera and importing new photos. Recently, the photos have remained on the camera and I have to delete pictures from my camera manuall