Copy DTOs to aggregate (as defined by Eric Evans)

Hello,
I have the following situation: Hand is an aggregate which consists of several fingers. Each finger can only belong to one hand. So hand is the aggregate root.
One could write:
package org.hand;
class Hand {
  private long id; //generated by hibernate when saving the entity to the db
  private List<Finger> fingers = new ArrayList<Finger>();
  public void addFinger() {
   this.fingers.add(new Finger());
  public List getFingers() {
   return Collections.unmodifiableList(this.fingers);
  public Finger getFinger(long fingerId) {
   // Code to find a Finger by its Id.
class Finger {
  private Long id;  //generated by hibernate when saving the entity to the db
  private Long someProperty;
  protected Finger() {super()};
  public void setProperty(long val) {...}
  public long getProperty()
  public Long getId() {...}
  public void setId(Long id) {...}
}Hand has the method addFinger() to avoid that one Finger is added to another hand. It also prevents that a Finger exits without a Hand.
Furthermore the client sends a list of FingerDTOs to the server in order to modify the fingers of a Hand.
class FingerDTO {
  private Long id;
  private Long someProperty;
  public void setProperty(long val) {...}
  public long getProperty()
  public Long getId() {...}
  public void setId(Long id) {...}
}The client can modify an existing finger by sending a FingerDTO with an existing ID and add new Fingers by sending a FingerDTO without Id.
All Fingers which are not included in that list will be deleted from the hand.
The code to handle the adding and modifyng could look like this:
     for (final FingerDTO dto : dtoList) {
          Finger finger
          if (dto.getId() != null) {
               finger = theHand.getFinger(dto.getId());
          } else {
               finger = theHand.addNewFinger();
          finger.setProperty(dto.getProperty());
     }How would you include the deleting of no longer existing Fingers, on order to have a meaningfull model? Would you build a list of all Finger which where send from the client and remove the others from the hand or is there a more meaningfull way to implement this?

ODCI is just like regular PL/SQL. So use whatever approach you would used when diagnosing problems in your other programs - DBMS_OUTPUT,PUT_LINE (aka the Devil's Debugger), stepping through in SQL Developer (or A.N.Other PL/SQL IDE) or using some other form of trace.
Cheers, APC
blog: http://radiofreetooting.blogspot.com

Similar Messages

  • Include the COPY TO Option in User Define form

    Hi Experts
    How can we include the COPY TO Option in User Define form
    Thanks In Advance
    A S VAMSI KRISHNA

    Hi,
    In SAP B1 i think there is no default functionality  for copy to in user defined form. As Parminder said you can use the control button combo and write your own method for populating  data.
    Regards
    Arun

  • KE31 - Copying a report with newly defined form

    Hi ,
    While creating a new profitability report(Report A)  by copying an existing report (Report B with Form B) with the newly defined FORM(Form A) , the system is creating the new report(Report A) with  the form (Form B) from the copied report.
    How to create the report by copying another report (to get Report A with Form A)?
    Thanks,
    Prabha

    Hi ,
    Thanks for your reply.
    I created form A and used KE31 for creating report A by copying report B.
    While doing so, the report A got the form B not the form A. Though I assigned the form A while creating the report A (with copying report B), the report A got Form B.
    How to create the report A with form A by copying report B?
    Thanks,
    Prabha

  • Error in Aggregate activation

    Hi Experts
    I am trying to create Aggregates on a Info Cube.
    Go to t.code: RSDDV
    select the IFC
    In the Aggregation screen, select the characteristic that will be based on your aggregate (drag and drop)
    When i try to Activate the Aggregates it showing me error
    No aggregates selected for activation
    Please help

    .      You are in the Modeling function area of the Administrator Workbench.In the navigation window, choose InfoProvider.
           2.      In the InfoProvider tree, navigate to the InfoCube whose queries you want to optimize.
           3.      In the context menu for the InfoCube, choose Maintain Aggregate.This will bring you to the Maintain Aggregates screen.
    If an aggregate was already created for the selected InfoCube, you can also go to the maintenance screen by double-clicking on .
    If you create the first aggregate for an InfoCube, you will first go to the Proposals for Aggregates dialog box. You can define whether the system should propose aggregates or whether you want to create them manually.
           4.      The left side of the screen shows the dimensions, characteristics and navigation attributes of the selected InfoCube in a tree structure as Selection Options for Aggregates.
    Select one or more objects to be copied to the aggregate.
    Define the granularity you need for the data in the aggregate. Add all the characteristics derived from these characteristics.
    For example if you define an aggregate for the month, you should also include the quarter and year in the aggregate.
    This enhancement does not increase the data set, but permits
    ·         a year aggregate to be built from this aggregate,
    ·         those who need the annual values can also use queries of this aggregate.
    You can only include a characteristic and one of its attributes in an aggregate in expert mode (Extras  ®  Switch expert mode on/off). Such an aggregate has the same granularity and size as an aggregate that was only built with the characteristic, but is affected by the hierarchy/attribute change run. Compared with the aggregate for the characteristic in which the attribute information is defined by a join with the master data table, the aggregate for the characteristic and the attribute only saves the database join.
    We therefore recommend that you either build an aggregate using with the characteristic or you build a much smaller aggregate using the attribute.
           5.      You have different options for creating an aggregate:
    ·         Transfer the selected object(s) to the Aggregates column on the right side of the screen using Drag&Drop.
    ·         Select  Create New Aggregate.
    The Enter Description for Aggregate dialog box appears.
           6.      Enter:
    Short Description
    Long Description
    To change the text at a later time, select Change Description Text from the context menu of the aggregate.
           7.      Choose  Continue. You get to the Maintain Aggregates screen.
    The system displays the aggregate at the upper right of the screen. The log is displayed in the lower part of the screen. 
    For more information see Displaying an Aggregate and its Components.
           8.      If an aggregate contains a time-dependent component, you must assign a key date to the aggregate.
    When you fill the aggregate, the key date behaves like the key date of a query: The time-dependent attributes and hierarchies are evaluated on this key date. For this reason aggregates with a time-dependent component can only be used in a query if the key date of the query is the same as the key date of the aggregate.
    In the Select Variable or Fixed Date dialog box select the following as key date:
    ·         a variable that is also used in queries for the key date and can be automatically calculated in the SAP Exit or Customer Exit processing types (see Using Variables),
    0CWD Current workday
    0DAT Current calendar day
    0P_KEYDT Key date of due date
    0P_KEYD2 Key date of posting (from key date of due date)
    0P_KEYD3 Key date of clearing (from key date of due date)
    0P_KEYD4 Key date of posting (posting date)
    0P_KEYD5 Key date of clearing (from key date of posting)
    Aggregates with a variable key date must be updated regularly. This process must be included in a Process Chain (Further BW processes -> Adjust Time-Dependent Aggregates).
    ·         A certain calendar day
    To enter a calendar day, select object CALENDAR in the Select Variable or Fixed Date dialog box (). Choose  Transfer selection. This takes you to the Calendar dialog box. You can copy this date to the aggregate definition by double-clicking.
    The system displays the technical name of the variable you chose or of the fixed calendar date in the aggregate tree under  Properties for node  Variables for Key Date.
    Once the aggregate has been activated and filled, the system copies the key date computed from the variable when the aggregate should be filled into the line  Key Date.
           9.      You can change the structure of the aggregate by adding further components or deleting existing ones. You can also change the key date.
    Inserting components into the aggregate
    i.         Select one or more objects in Selection Options for Aggregates.
    ii.       Transfer them to the aggregate to be changed at the right of the screen with Drag&Drop.
    iii.      As needed, change the Aggregation Level with the associated entry in the context menu:
    All Characteristic Values
    Hierarchy Level
    Fixed Value
    Aggregates containing fewer than 14 components are stored on the database in optimized form (see Efficiently Loading Data into Aggregates).
    Note that the characteristics that are defined in the InfoCube are also included in the aggregate and thus increase the number of components even though they are not visible on the surface.
    Deleting components from the aggregate
    i.         In the aggregate tree navigate to the characteristic(s) or navigation attributes you want to delete.
    ii.       Select these components.
    iii.      To delete the components from the aggregate you can:
    -         Choose Remove Components in the context menu.
    -         Copy the components to the left part of the screen with Drag&Drop.
    To delete a dimension from an aggregate, you have to delete all the characteristics and navigation attributes of this dimension.
    Changing the key date
    i.         In the aggregate tree under  Properties, select node  Variable for Key Date and choose Change from the context menu. You get to dialog box Select Variable or Fixed Date.
    ii.       Select and transfer the required variable or calendar date.
    The key date computed from a changed variable is only copied to line  Key Date when the Adjust Time-Dependent Aggregates process has been executed.
       10.      To check the aggregate definition for inconsistencies choose  Check Definition.
       11.      Save the new or changed aggregate.
    Edited by: Rama on Sep 24, 2008 12:03 PM

  • Define Warhouse number or Copy standard warehouse number?

    Hi
    I am in situation where we are in a client replication project ( two different clients move in to one already existing client ).
    Client 1 - has no WM settings ( 3 different plants for different company codes ) - US
    Client 2 - has WM settings ( plant 221 for  company code 221 ) - US
    I am reconfiguring the whole setup in the Client 1 for plant 221 for WM settings.
    I am planning to define  the warehouse number and assigning the plant/storage location (221/009) for the same.
    If i copy from standard warehouse number 001 ( Germany ) it will copy the region.
    I dont see any option of removing region Germany for my ware house if i do so...
    I know this is very trivial question but i donot want to proceed with out procedure.....
    ( Usually in case of Plant copy in MM we remove all standard settings of DE for the created one, but in case of ware house no i do not see any thing )
    Since 001 Central warehouse is not connected to any plant i can copy that so that all tables get copied but how to remove the region?
    Please suggest
    Regards
    Rudresh K
    Edited by: Ravi Rudresh on Aug 18, 2009 10:06 PM
    Edited by: Ravi Rudresh on Aug 18, 2009 10:08 PM
    Edited by: Ravi Rudresh on Aug 18, 2009 10:09 PM

    Hi Anna Durai
    It works and it removes the Region Code. Thanks for your suggestion on this...
    I have one more  question ,
    Do you copy 001Central warehouse  or we can define our own ware house number?
    We have two options in Enterprise structure - LE-Define, copy, delete, check warehouse number
    Define warehouse number
    Copy/delete/check warehouse number
    Is the Region code required only hazardous materials or it has any impact on structure ....
    As my understanding the Central Warehouse 001 is not assigned to any plant.
    Regards
    Rudresh K

  • Aggregate copy -- variable or fixed date

    Hi Gurus:
    When I try to copy an existing aggregate a pop up screen comes up saying 'select variable or fixed date' -- and lists
    some dates.
    My question is what exactly this means & if I cancel it says, this aggr may not be used because I did not select value from that screen..
    pls suggest. I will be happy to assign the points.
    Thanks & have a nice day ahead.

    I got it...

  • Aggregate not hitting

    Hello Friends,
    I am trying to create an aggregate for Income Statement Query. 
    On the filter I have Fiscal Year Variant, Currency type and Chart of Accounts
    On the Free Characteristics I have Profit center, company code and Fiscal year period.
    I tried different ways on the Characteristics with fixed values and hierarchy(account no) but the aggregate is never used when executed the query. Can anybody give some input
    thanks

    Hi
    If your aggregate are not hitting
    Please ask the User to send me Book mark how he is drill down the query
    Check with rsrt tcode how you aggregate is defined
    copy the aggregate which is hitting ur aggregate and
    apply Fixed for Company code value type ,version,Hierarchy level set and
    chech
    rsddstat,rsddstataggrdef and RSDDAGGRDIR tables
    rgrds
    Reddy

  • Follow-up transaction copy control for opportunities

    Our CRM system is currently configured to permit follow-up opportunity creation.  When follow-up transactions are created all product categories are copied to the new opportunity.  We would like to stop this.  All header and business partner data should be copied as present, however product information should not be copied.  (i.e. follow-up transactions currently work, we only want to switch off product data copying)
    I am not familiar with follow-up transaction customization, and not sure exactly where to start.  Should I be modifying the current BAdI or is there a standard customizing option to switch off copying of product categories?

    Hi Derek,
    Just try this:-
    Go to SPRO->IMG->CRM->Transactions->Basic Settings->Copying Control for Business Transactions->Define Copying Control for Transaction Types.
    Search for entry Source=oppt and target=oppt.In this entry, uncheck the check box-Copy Item Number and see if it resolves your issue or not?
    Thanks and Regards,
    Rohit

  • How to Use Sequence Object Inside User-defined Function In SQL Server

    I'm trying to call sequence object inside SQL Server user-defined function. I used 
    Next Value for dbo.mySequence  to call the next value for my sequence created. But I'm getting an error like below.
    "NEXT VALUE FOR function is not allowed in check constraints, default objects, computed columns, views, user-defined functions, user-defined aggregates, user-defined table types, sub-queries, common table expressions, or derived tables."
    Is there any standard way to call sequence inside a function?
    I would really appreciate your response.
    Thanks!

    The NEXT
    VALUE FOR function cannot be used for User Defined function. It's one of the limitation.
    https://msdn.microsoft.com/en-us/library/ff878370.aspx
    What are you trying to do? Can you give us an example and required output?
    --Prashanth

  • Copying the value of customized fields from one order to other in CRM

    Hi ALL,
    We have added new customized fields in web ui for Sales Order.
    Now when we are using the standard COPY functionality to copy one particular sales order, then all the fields are getting copied into new order except the customized fields which we have added.
    We have created new data elements for our fields and added it by EEWB transaction.
    Please let me know if there is any badi or any other way which we can implement so that our customized fields are also copied.
    Thanks,

    Hi!
    BADI "CRM_COPY_BADI" is the one you are looking for.
    Create badi implementation and assign copy routine to the copy management parameter.
    The parameter can be configured via IMG->CRM->Transactions->Basic settings->Copying Control for Business Transactions->Define Copying Control for Transaction Types.
    I hope it helps you.
    Regards,
    Fukuhara Yohei

  • Copy control for activity

    Hi CRM gurus,
    Can anyone advice where can setup the copy control for activities in the IMG. Since the system defaulted lots of transactions in the activity followup, we need to disable some of them from the list.
    Thanks in advance.
    Rgs. Michelle

    As I wrote it in different thread...
    1. Activate Copying Control of Activities
    CRM - Transactions - Settings for Activities - Activate Copying Control of Activities
    This will cause that only transactions defined in your Business Transaction Profile (which is assigned to your Business Role and defined in CRM - Interaction Center Webclient - Business Transaction - Define Business Transaction Profiles) are visible in dropdown list.
    2. Define Copying Control of Transaction Types
    CRM - Transactions - Basic Settings - Copying Control of Transaction Types - Define Copying Control of Transaction Types
    Here select Source Transaction and choose Target Transaction.
    Always follow CRM Best Practices documentation as all of the customizing steps are described there...
    Link - http://help.sap.com/bp_crmv12007/CRM_DE/HTML/index.htm
    Edited by: drabas on Apr 13, 2010 6:40 PM

  • Copy header text from Purchage Requisition to Purchage order

    hi,
    My scenario is
    i was created Purchage Requisition 10000534 and i was maintained Header Text (any thing).
    Then i was created Purchase Order with reference to  purchase Requisition. But in Purchase Order Header Text not copied. Purchase Requisition.( I want to copy the Header Text From Purchase Requisition to Purchase Order).
    I am Using this Badi (ME-REQ-HEADER-TEXT).
    Thanks
    Munna

    Hi,
    Have you done the required configuration for this issue.
    SPRO --> Materials Management --> Purchasing --> Purchase Order --> Texts for Purchase Orders
    Define Copying Rules for Header Texts
    Define Copying Rules for Item Texts
    Regards,
    MT

  • Copy of Business Transaction (CRM Service Request)

    Hi Forum,
    I created a transaction that uses the CRM Service Request as leading Transaction Category. I configured the IMG step "Copying Control for Business Transacation" in order to copy the transaction as a follow-up.
    The problem is that the transaction does not appear in the list when we choose the link  "create follow-up".
    Any idea ?
    Thanks a lot !!!

    1. Activate Copying Control of Activities
    CRM - Transactions - Settings for Activities - Activate Copying Control of Activities
    This will cause that only transactions defined in your Business Transaction Profile (which is assigned to your Business Role and defined in CRM - Interaction Center Webclient - Business Transaction - Define Business Transaction Profiles) are visible in dropdown list.
    2. Define Copying Control of Transaction Types
    CRM - Transactions - Basic Settings - Copying Control of Transaction Types - Define Copying Control of Transaction Types
    Here select Source Transaction and choose Target Transaction.
    Always follow CRM Best Practices documentation as all of the customizing steps are described there...
    Link - http://help.sap.com/bp_crmv12007/CRM_DE/HTML/index.htm

  • Redetermine the VAT rate after item copy

    Hello everyone,
    [Background]
    I am in a project which is for VAT rate change.
    We implement a new condition BADI to reset Price_date in the communication structure to change the tax date.
    In the BADI we mapped varies date types(Such as Sales date) to PRICE_DATE.
    so when some date type was changed the BADI will be run for new tax determination.
    [Issue]
    The problem is when we follow-up from a contract to a new contract or sales order, the PRICE_DATE are not changed in some cases.(Just as copy source's PRICE_DATE)
    [Approach and question]
    After made a investigation, we found that the issue maybe resolved in item copying control customize.
    [CRM->Transactions->Copying Control for Business Transactions->Define Copying Control for Item Categories]
    There is a filed that we can define condition copy rule.
    - Do not copy conditions
    - C: Only copy manual conditions
    - D: Copy all conditions
    - G: Copy conditions and redetermine Tax
    By default all item category copy rule were set to C and D.
    What would be the risk of setting D to G?
    Is there any impact when changing D to G?
    -----------------------------------------For testing purpose you can implement the BADI as below----------
    [BADI Implementation detail]
    1. Enable Performance-Optimized Condition Processing and Pricing
    2.Define Customer-Specific Mapping of Condition Fiedls
         Add a record for PRICE_DATE, we copy it from standard and add a filter for Condtion FILLING BADI like Z00001
         The standard settings is mapping to PRICING-PRICE_DATE
         #Before using the filter you have to define it in "Implement BAdis to influence Mapping of Condition Fields"   
    3.Implement a Condtion Filling badi(BADI:Filling of Condition Fields)   CRM_CND_FLD_FILL
         after determining the new Price_date, add the value to the return value  RT_ATTR_VALUE.(You shouldn't leave it as blank or condition will be lost )
         For testing purpose, you can set a constant value in it.
    4.If you want to trigger your BADI when some filed changed, you have to implement a new BADI (CRM_CND_OBJ_REG)

    Hi Hui Sun,
    Your aprroch regarding copying control is right. You can keep the option D or G to copy the Pricing conditions.
    And after changing the coopying control for the item categories and keep a break point in CRM_COPY_BADI in the particular Copying routine implementation and in that keep a break point  PRICING and PRICING_I methods.
    The pricing will be automatically copied. if not copied then you have to maintain the Pricing using the FM in the methods of above mentioned implementation.
    Please check the importing parameters and export parameters of the Methods.
    Regards,
    Rajya lakshmi CH

  • Copy opportunity from previous expired organization

    Hi,
    Our salesperson have requirement to create opportunity from previous created ones, so we use opportunity copy function, but I found there has some problems when the oppts created previously contain expired organization data. For example, if the salesperson was in sales office A and he created oppt 1, now he was assigned to sales office B and he want to copy from oppt 1. As sales area A is invalid now, he will not able to save that, in our scenario, salesperson have no auth to change their org data, so how can we let salesperson copy opportunity with latest organization data? Is it required enhancement? If so, could you please tell me which component to enhance and how to do that? Thank you very much!
    Best Regards,
    Jeff

    Hi Ganesh,
    Thank you very much! It works. I firstly register the copying routine thru IMG: CRM->Transactions->Basic Settings->Copying control for Bus Trans->Define copying control for transaction types. Then implement the BADI you mentioned with the registered copying routine.
    Jeff

Maybe you are looking for

  • Collapsible Panels - Links to open one, and close others

    Hi, I am new to Dreamweaver and have been creating my site by learning as I go along. I have already read through all the other related topics associated with Collapsible Panels on this blog and have still not found an answer. I have been able to ope

  • PL/SQL Cursor Help

    I am trying to figure out how to get the following code to work. I am using a cursor to run a SELECT statement with a group function. How do I get the information from the group function to print out with a dbms_output.put_line statement? Just for my

  • Shared Object data not saving?

    I tried adding a "save progress" function to my latest project using the shared object class, yet it's not working. All of the information that should be saved, traces as undefined. I looked through some older projects, and the save functions in thos

  • Backup Function in XI?

    Hi, Is there a backup function in XI? Or should I use such a tool as "true image"? Can I make a backup when the XI-Systeme is running or is it better to stop xi in the sap mmc before the backup? Thanks. Regards Stefan

  • Siemens TC65 and Linux

    Hi, I'm trying to work with the Siemens TC65 on Linux. So far I've installed the J2ME Wireless Toolkit and the EclipseME plugin for eclipse. Now the tutorial I have tells me that I need to install the Siemens TC65 SMTK Enviroment, but i have only a W