Retrieving field from original records based on current related records transaction date

Post Author: Barbara W
CA Forum: Data Connectivity and SQL
I've been working with Crystal for awhile but am having trouble figuring out how to tell CR what I need to pull from a ledger table I am working with.
I need to identify fees and costs written off.  However, once they are written off, the code on the new transaction that identifies fees and costs changes to WOFF.  The write off transaction dates I need are in YTD 2007, however, the original transaction in my example is in 2006.
Therefore, I need to pull orginal record of fees, orginal record of costs, then write off record of each for a total of 4 records based on transaction date of the write off records
cust #
invoice #
trans date
   credit id
     index #
     amount
  code
1458
1195
7/11/06
458
250
  FEES
1458
1195
7/11/06
459
2.52
  COST
1458
1195
2/26/07
458
460
250
  WOFF
1458
1195
2/26/07
459
461
2.52
  WOFF
The credit id matches the index of the original transaction, however, it is on another record.  What I am trying to do is pull any record with a credit id, however, I also need to know the original code that goes with that record I.e. FEES/COST.
Any help would be greatly appreciated!!

Post Author: SKodidine
CA Forum: Data Connectivity and SQL
Have you tried a subreport?  Try creating a subreport and link it with index# to credit id (if you can).  This way, for every main record if there is a corresponding subreport record with a credit id, you can retrieve the required information.  Otherwise, if you cannot link it as mentioned above, then link it on Cust# but in the main report fetch those with a null credit id and in the subreport fetch those records where credit is not null.  You might have to play around with it a bit.  Hope it helps!

Similar Messages

  • Choose field from joined table based on another field?

    Good morning!
    Is it possible to select a field from a joined table row based on another field? Consider the following data in the CVALUES table:
    ID  C1   C2    C3    C4    C5    C6
    T1  9.6  10.3  12.4  19.6  19.6    0
    T7  9.6  10.4     0     0     0    0
    T3  8.2   9.9  11.4  19.6  19.6    0
    T8  8.3  10.7  13.5  20.7     0    0
    T5  9.4  10.3  12.7  22.9  19.6    0
    ...And the following data in the MDETAIL table:
    ID           MDATE        CNUM     ...
    T1  03/28/2012 18:00:00    4
    T1  03/28/2012 18:00:00    1
    T8  03/29/2012 06:00:00    6
    T8  03/29/2012 06:00:00    5
    ...I want to get the column from CVALUES corresponding to the CNUM field in the MDETAIL table. I'm currently doing this:
    SELECT m.t1, m.mdate,
           CASE WHEN m.cnum = 1 THEN c.c1
                WHEN m.cnum = 2 THEN c.c2
                WHEN m.cnum = 3 THEN c.c3
                WHEN m.cnum = 4 THEN c.c4
                WHEN m.cnum = 5 THEN c.c5
                WHEN m.cnum = 6 THEN c.c6 END AS cvalue
      FROM mdetail m
      JOIN cvalues c ON m.id = c.idThe records in the CVALUES table are unique; only one row per ID.
    This method works, and it's fast but it's messy code and I think there has to be a better way to do it. I use the cvalue value in several calculations so every calculation I use it in has this giant glob of CASE in it!

    Since you're comparing the same column against scalar values, the CASE statement could be simplified in a similar way :
    CASE m.cnum
      WHEN 1 THEN c.c1
      WHEN 2 THEN c.c2
      WHEN 3 THEN c.c3
      WHEN 4 THEN c.c4
      WHEN 5 THEN c.c5
      WHEN 6 THEN c.c6
    END AS cvalueSince performance is not the issue here, now it depends on what you consider "more readable".
    Using a one-liner piece of code certainly makes the query looks less bulky, but I won't be so sure about readability and immediate understanding.

  • SECATT, use output parameters from a recorded transaction

    Hi everybody,
    I'm testing the functionality of the SECATT transaction. I have a question about the folllowing case:
    someone has recorded mutliple transactions and wants them to be executed one after the other. But, 1 of these recorded transactions needs data that is generated by a previous transaction. Is this in some way possible (do these transactions generate some output parameters and can you capture them in your local parameters).
    thank you in advance,
    Tom

    Rajesh,
    please check if this following proposal could serve you.
    Define the Query with mode FixedQueryWithOutput. In the package define a ref cursor as IN OUT parameter. To get your 3 values back, open the cursor in your procedure like "Select val1, val2, val3 from dual". Then the values should get into your query.
    Here is an example how this could be defined.
    Package:
    type return_cur IS ref CURSOR;
    Procedure:
    PROCEDURE myProc(myReturnCur IN OUT return_cur) ...
    OPEN myReturnCur FOR SELECT val1, val2, val3  FROM dual;
    Query:
    DECLARE
      MYRETURNCUR myPackage.return_cur;
    BEGIN
      myPackage.myProc(
        MYRETURNCUR => ?
    END;
    Good luck.
    Michael

  • Concatinating a field from several records into a single string

    Using Crystal Reports 11
    I have a table of EMS/Fire runs, with a related table of fire trucks that respond on each run.  My report is grouped by EMS/Fire run, and then the details section shows each truck, something like this....
    Run #1 |  123 E Main St  |  Structure Fire
         E123
         E124
         E125
         L123
         L342
         R153
    Run #2  |  455 S High St  |  Fire Alarm
         E322
         E233
         L122
    What I would like to do is hide the details section, and instead in the footer section of each group, have a "text field" that combines all of the trucks into 1 line,  something like this...
    Run #1 | 123... | Stru... |  E123, E124, E125, L123...
    Run #2 | 455... | Fir... |  E322, E233, L122
    Basically the logic would be:
       For Each RecordInThisGroup
            If Maximum(TruckNumberField) = TruckNumber Field Then
                 TruckNumberField
            Else
                 TruckNumberField & ", "
       Next RecordInThisGroup
    Is there a way to loop through all the records in the group?
    Thanks for any insight!
    Jason

    Hi Jason,
    This can't be done in the Detail section but we can do it in the Group Footer.  Seeing as you already are grouping on the EMS/Filre run this is good.  We can use a running total to do this. 
    1)  Create a formula and drop it into the Group Header.  This will reinitialize the running total for each group:
    WhilePrintingRecords;
    StringVar Run := "";
    You can suppress this formula so you don't see it when you run the report
    2)  Now create another formula that will go into the Detail section.  This is the formula that will build the string: 
    WhilePrintingRecords;
    StringVar Run;
    Run := Run & & ", " & {table.TRUCK};
    You can hide the detail section or format this formula to be suppressed so you don't see it. 
    3)  The last formula goes into the GroupFooter section and will display the string:
    WhilePrintingRecords;
    StringVar Run;
    Good luck,
    Brian

  • Retrieving files from Sharepoint Online based on time stamp using SharePoint Online Management Shell

    Hello,
    I would like to create a Powershell script to download files based on timestamp (all files updated on a given date or later). I would really appreciate any guidance on which cmdlets/objects I should look at to accomplish this.  I am new to Sharepoint
    online and Powershell, though not to programming or scripting.
    Thank you for your help!

    Hi,
    You should start by reading this article : Windows PowerShell for SharePoint Online.
    Then have a look at the Windows PowerShell for SharePoint Command Builder, and select "SharePoint Online"
    in the dropdown list.
    My technical blog on SharePoint ||
    My contributions on the TechNet Gallery

  • CRS Editor - Retrieving Timestamp database field from SQL 2005

    Hello -
    For the life of me, I cannot retrieve a database timestamp field from SQL 2005.
    I have successfully used 'cast(Date as char(30)) as DateStr' to convert to string but the DBRead statement displays the original object only as java.lang.Timestamp.  Any posts regarding this topic usually require Java skill sets above my level (creating new java class for import,...).
    There has to be an easy way to do this without being a Java programmer, yes?
    Any help here would greatly be appreciated!
    Thanks
    Andy Backus
    941.587.7199

    Andy,
    I'm guessing you know that this isn't really a date/time value in MS SQL.  According to Microsoft: 
    The Transact-SQL timestamp data type is not the same as the timestamp data type defined in the SQL-92 standard. The SQL-92 timestamp data type is equivalent to the Transact-SQL datetime data type.
    But to your question how to get the timestamp value out in a string...You'll want to use the convert function:
    select convert(varchar(10),myTimestampField) from myTable
    That will return the hex value in the column in a string format.  Also, when you retrieve the data, are you looking at the original table (which specifies the column is a timestamp), or did you create a dummy table with the columns named and formatted the way the data will be returned that UCCX can look at for the schema?  If it doesn't have the correct schema to look at, you'll have problems.
    Cliff
    please rate helpful posts

  • Retrieving hierarchy fields from MDM to SAP R/3 using MDM ABAP API's

    Hi all,
    I have developed a code to retrieve fields from MDM to SAP R/3 using MDM ABAP API's, i could retrieve   all of the fields excluding the Lookup[Hierarchy] fields like-  FACILITY CODE  etc...
    please update me if anyone has any experience on this.
    Thanks and regards,
    Aastha Mehrotra

    Hi ,
    Any one worked in the MDM API to retrieve Hierarchy fields ???
    Regards,
    Arun.

  • How to merge key field from external source system with SAP R/3 master

    Hi,
    In SAP BW 7.0 system, our scenario is Master Data for 0GL_ACCOUNT is coming from SAP R/3 alongwith the Transactional data records for standard FI cubes. Then, one more set of transaction data is coming from external source system, a flat file, into another custom DSO(ZDSO_FI), which also has this GL Account field.
    This flat file's GL account, GL_file, has to be basically mapped/merged with the standard 0GL_ACCOUNT field so that at the time of loading the transactional data for custom DSO, ZDSO_FI (with transformation mapping GL_file > 0GL_ACCOUNT), system automatically refers to the 0GL_ACCOUNT master data to load these incoming transactional values, from the external flat file system. How can this be done?
    To illustrate the scenario, say I have 5 records in 0GL_ACCOUNT, loaded from SAP R/3 into SAP BW-
    0GL_ACCOUNT      Short Description     Source System
    100                                   D1                          R/3
    200                                   D2                          R/3
    300                                   D3                          R/3
    400                                   D4                          R/3
    500                                   D5                          R/3
    Now suppose if my flat file has following sample transactional data, to be uploaded in SAP BW  ZDSO_FI-
    GL_file      Key Figure1
    400          789
    200          567
    Then after uploading this transactional data in ZDSO_FI (with transformation mapping GL_file > 0GL_ACCOUNT), the 0GL_ACCOUNT data becomes as below-
    0GL_ACCOUNT      Short Description     Source System
    400
    200
    100                                   D1                          R/3
    200                                   D2                          R/3
    300                                   D3                          R/3
    400                                   D4                          R/3
    500                                   D5                          R/3
    So note that the system did not refer the incoming GL's from flat file, although the field is mapped to 0GL_ACCOUNT in transformation, to the already available master data. Rather created 2 new data rows for the GL accounts coming from external system. Because of this I am not able to perform the calculations common from standard FI cube and ZDSO_FI, with GL account as key field. I need to synchronise these data values based on GL Account to proceed with further calculation and am badly stuck.
    Request if anyone can please throw some light on how to achieve this seemingly simple requirement?
    Thanks in advance.
    Nirmit

    Better post this thread is in the [Enterprise Data Warehousing|Data Warehousing; forum.

  • AW Database: duplicating a field to every record.

    Is there a way that I can duplicate a field from every record to a new field so I can alter it?

    Field G (called 'Field 2' in this example) should be a calculation field as shown here:

  • Trouble maintaining original "date taken" info and metadata when exporting TIFFs from original CR2 files.

    When exporting TIFFs (from original RAW), I noticed my metadata said the "date created" was the day of export. I want to be able to access the date the original image was taken as opposed to the day I exported it. Is there a way to maintain original date of image taken in my info? I couldn't seem to find it after I exported my TIFFs...

    I just tested this with LR 5.5 Mac OS 10.9.3 and it works correctly for me.
    To troubleshoot your problem:
    1. Which version of LR and which platform (Mac, Windows)?
    2. Which tool or command are you using to examine Date Created of the exported TIFF?
    3. Upload a sample TIFF showing the problem to Dropbox or similar and post the URL here. This will allow us to take a look in detail.

  • I migrated all data from old PC to new and iTunes successfully transferred to new PC. When I click on a song it says it cannot locate the original. How does one map iTunes file to iMusic to enable play from original files ?

    Subject: Migration
    I migrated all data from old PC to new and iTunes successfully transferred to new PC. When I click on a song it says it cannot locate the original. How does one map iTunes file to iMusic to enable play from original files ?

    Subject: Migration
    I migrated all data from old PC to new and iTunes successfully transferred to new PC. When I click on a song it says it cannot locate the original. How does one map iTunes file to iMusic to enable play from original files ?

  • Problem in loading transactional data from to 0MKT_DSO1(ods) to 0MKTG_C01

    Hi,
    I am trying to load lead transaction data to the standard Crm lead management cube from ODS.There is a problem while loading transaction data from 0MKT_DSO1(ods) to the infocube 0MKTG_C01 as the field 0STATECSYS2(CRM STATUS)  is set to 10 in ods -meaning incorrect transaction. This feild is not there in the infocube.
    There is a routine in the cube that deletes data records with (0statecsys2) set to 10.
    THIS field is not coming in the transaction.
    so, where can i see the master data in crm source system? and why is that feild getting set to 10 ?
    thanks in advance!

    Thanks for the reply..
    I have checked the Fact table which shows
    1. packet Dimension
    2. Time dimension
    3. Unit dimension.
    I have kept the 0CALDAY as the time characteristics.
    Sample data i have loaded from ODS to Cube.
    Sample data in ODS.
    Sales order No_____0CALDAY_____AMOUNT
    800001___________12/02/2009____15
    I have loaded this data in Cube with Full Upload.
    Data in Cube.
    Sales order No_____0CALDAY_____AMOUNT
    800001___________12/02/2009____15
    Again i am loading the same data to cube
    Data in cube after loading.
    Sales order No_____0CALDAY_____AMOUNT
    800001___________12/02/2009____15
    800001___________12/02/2009____15
    The data is duplicated and it is not cumulating.
    Am i missing anything on this.
    Pls help..
    Thanks,
    Siva.

  • Trying to delete a record from an entity-based VO in ADF

    We are using J-Developer 9.0.5.2
    This is a web app using struts and ADF BC
    Click the link below to view part of the struts diagram that relates to this question
    http://home.earthlink.net/~katie1les/images/delete.gif
    1. We have a DataPage that displays a list of items (catalogItemLIsting.jsp). This is a view of all items in a particular category based on the ItemsVO. Each item has a delete icon beside it.
    2. The user clicks the delete icon which forwards to the bindDeleteItem DataAction that will bind that item number (through custom method in the AM) to an entity-based DeleteItemVO (the only record that will be in the DeleteItemVO is the item they selected to delete). This step corresponds to the deleteItem Data Page as seen in the image link above).
    We do this step (step 2) because we want to show the user a confirmation page with additional item information before they actually delete the item. Otherwise, we could just perform the delete from the original page.
    3. On the deleteItem data page there is a Delete (">Select</a>) link beside the single item in the view that when clicked should set the current row (the only row in the view object) and forward to the setDeleteItemDA Data Action.
    4. I dragged the setCurrentRowWithKey method from the DeleteItemVO onto the setDeleteItemDA data action.
    5. I forwarded that data action to the deleteItemDA data action where I dragged the Delete method from the DeleteItemVO.
    6. This action forwards to a deleteItemDP data page where I dropped a Commit action from the AM which owns the DeleteItemVO.
    The result of executing these steps brings it back to itself (deleteItem.do) and tries to rebind the single record view object producing a ORA-01008: not all variables bound error and not forwarding to the setDeleteItemDA data action.
    Are we using the right approach here?
    I tried following the example located at: http://otn.oracle.com/products/jdev/collateral/tutorials/9050/bizcomp_jsp_tut.html#delete, but there are some differences between the two. We are using data pages and a single view object, while the example is using regular jsp pages and a master detail view relationship.

    Thanks Steve for the reply. We dowloaded the following example (http://otn.oracle.com/products/jdev/tips/muench/DeleteEmpWithConfirm.zip) and tried to make it work for us. We set everything exactly the same (as far as we could tell). There is one difference though between what you have in this example and ours and that is that the VO that is dropped on the first data page is first bound by a custom method through a preceeding data action. When the page is rendered we see the item we choose (and that was bound in the data action) correctly on the page.
    The problem comes in when we click on the delete link on that page, it does not seem to be posting back properly - it appears to be ignoring the "confirmDelete" event, which is part of the url (and it's corresponding forward named the same) and instead ends up trying to rebind the VO on the same page which produces a "not all variables bound" error. Error listed below.
    Why is the Datapage seeking to rebind the VO again, when it was already bound previously? Shouldn't the setCurrentRowKey method simply set the current row on the VO without having to requery the VO again?
    *** error page ***
    You must correct the following error(s) before proceeding:
    JBO-29000: Unexpected exception caught: oracle.jbo.SQLStmtException, msg=JBO-27122: SQL error during statement preparation. Statement: SELECT DeleteItemInfoEntityObject.RETAILER_NUMBER, DeleteItemInfoEntityObject.AUTH_ITEM_CODE, DeleteItemInfoEntityObject.UPC, DeleteItemInfoEntityObject.ITEM_DESCRIPTION, DeleteItemInfoEntityObject.PACK, DeleteItemInfoEntityObject.RETAIL_SIZE, DeleteItemInfoEntityObject.UNIT_COST, DeleteItemInfoEntityObject.AWI_DEPT_NAME, DeleteItemInfoEntityObject.RETAILER_CATALOG_NAME, DeleteItemInfoEntityObject.RETAILER_CATEGORY_NAME, DeleteItemInfoEntityObject.RETAIL_PRICE, DeleteItemInfoEntityObject.QUANTITY_AT FROM DELETEITEMINFOVIEW DeleteItemInfoEntityObject WHERE AUTH_ITEM_CODE = :1 AND RETAILER_NUMBER = :2
    JBO-27122: SQL error during statement preparation. Statement: SELECT DeleteItemInfoEntityObject.RETAILER_NUMBER, DeleteItemInfoEntityObject.AUTH_ITEM_CODE, DeleteItemInfoEntityObject.UPC, DeleteItemInfoEntityObject.ITEM_DESCRIPTION, DeleteItemInfoEntityObject.PACK, DeleteItemInfoEntityObject.RETAIL_SIZE, DeleteItemInfoEntityObject.UNIT_COST, DeleteItemInfoEntityObject.AWI_DEPT_NAME, DeleteItemInfoEntityObject.RETAILER_CATALOG_NAME, DeleteItemInfoEntityObject.RETAILER_CATEGORY_NAME, DeleteItemInfoEntityObject.RETAIL_PRICE, DeleteItemInfoEntityObject.QUANTITY_AT FROM DELETEITEMINFOVIEW DeleteItemInfoEntityObject WHERE AUTH_ITEM_CODE = :1 AND RETAILER_NUMBER = :2
    ORA-01008: not all variables bound
    *** error ***
    Les, here's a minimal working sample:
    http://otn.oracle.com/products/jdev/tips/muench/Delete
    mpWithConfirm.zip
    It uses just two data pages and leverages the
    built-in event-handling features of ADF described in
    the ADF Data Binding Primer and ADF/Struts Overview.
    The pages use the post-back pattern to handle their
    own events before forwarding.
    http://otn.oracle.com/products/jdev/collateral/papers/
    0g/ADFBindingPrimer/index.html

  • Pulling a Record set and then using a field within that record to pull additional information from the table.

    I am pulling information based on the following "If" statement;
    If({JCT_CURRENT__TRANSACTION.Category} = "L"
        and "cost" in {JCT_CURRENT__TRANSACTION.Transaction_Type}
        and {JCT_CURRENT__TRANSACTION.Transaction_Date} > {@Prev Week}
        and {JCT_CURRENT__TRANSACTION.Transaction_Date} <= {@Week 1})
    then
    {JCT_CURRENT__TRANSACTION.Units}
    This works fine and I can print it on the report with other associated fields.  One of those fields is a "Cost Code" field associated with the above conditions and date set (I am pulling for one pay period week).  Of these transactions, each week different "cost codes" could be available.
    One item I need to figure out another formula is associated with the cost codes that are pulled, but, I need to compare them to a different date range.
    Here is how I get the cost codes that were used in a specific time frame;
    If({JCT_CURRENT__TRANSACTION.Category} = "L"
        and "cost" in {JCT_CURRENT__TRANSACTION.Transaction_Type}
        and {JCT_CURRENT__TRANSACTION.Transaction_Date} > {@Prev Week}
        and {JCT_CURRENT__TRANSACTION.Transaction_Date} <= {@Week 1})
    then
    left({JCM_MASTER__COST_CODE.Cost_Code},6) & "001"
    This gives me the cost codes used in that period but changes the last three digits to be "001" (xx-xx-001).
    Now, I need to take that cost code, the xx-xx-001 and compare it to a completely different date range to get an "estimate" number.
    My problem is that, because I need to use a date range in the original conditions, even after I truncate the cost code, for some reason, it stays associated with that date range.
    How can I use a field from a group of records based on date, but, associate it with a competely different date range.
    I hope this is clear, I am having a real hard time with this, I am fairly new, but have pretty normal working knowledge of basic formulas, etc...
    Thanks, Mike

    Please re-post if this is still an issue

  • How to retrieve more then one record from database

    I am doing a SELECT FROM WHERE SQL statement on a database which returns more then one record. I want to retrieve certain column values from the selected records. How do I do that? If only one record is returned, I know I can do a data operation with operation set to 'Get-Retrieve Values from Record' and Record to operate on set to 'Current-Use current record'. I need to find out how to configure to data operation window in the case more then one record is returned by the preceding SQL statement. Depending on the number of records returned, I can dynamically create array variables to store the 'to be retrieved' column values, just dont know how to retrieve them.
    Any help will be greatly appreciated.
    Thanks
    Anuj

    I apologize for not being clear in explaining my problem, perhaps I should have posted an example. Anyways, I was able to figure out the solution. I was doing an 'Open SQL' statement which was selecting multiple records (rows) from a table in the dB. I was storing the number of records returned in a local variable. Then, I wanted to retrieve certain columns of all the selected rows (records). In the "Data operation", I was choosing the 'Record to operate on' as 'Current-Use Current Record'. Changing this field to 'Next-Fetch next record' fixed the problem. I then retrieved the values of those columns into a dynamically created array variable whose dimensions came from the local variable which stored the number of records returned in the SELECT SQL statement. 
    Thanks
    Anuj

Maybe you are looking for