How to process a collection of objects of a derived class?

I'm trying to clean up some duplicated code.
I have several classes that have a common parent class. I have in my application several searching and sorting functions that operate on these child classes. But I realized that this is code duplication, as these functions only need data members of the common parent class. So I figured I could make these functions operate on collections of the parent class.
But during refactoring, I ran into a compiler error that surprised me. This is the SSCCE:
import java.util.*;
public class Tinker {
  static class ParentClass {}
  static class ChildClass extends ParentClass {}
  static void processClassCollection( Collection< ParentClass > c ) {}
  public static void main( String[] args ) {
    Collection< ParentClass > parentClassCollection = new Vector< ParentClass >();
    Collection< ChildClass > childClassCollection = new Vector< ChildClass >();
    processClassCollection( parentClassCollection );
    processClassCollection( childClassCollection ); // Why won't this compile?
}Every object of type ChildClass is also of type ParentClass, right? Every function that requires a ParentClass object, can be passed a ChildClass, right?
Then, if a function requires a Collection< ParentClass >, why can't I pass it a Collection< ChildClass >?
Apparently there is a gap of my understanding, either of inheritance, or of Collections. I would very much appreciate clarification, and any suggestion how to deal with such a case.
-Ron.

ejp wrote:
Why can't a Collection< ChildClass > be used where a Collection< ParentClass > is expected?Because Collection< ChildClass > doesn't extend Collection< ParentClass >. They are separate unrelated types.And I think part of the reason this is not allowed. i.e. you can pass ChildClass to a method which expects a ParentClass. is that java doesn't know if you are just looking at the Collection or modifying it. If you could add anything which extends ParentClass to the collection, the collection of ChildClass would not be valid any more.
The difference is that in the first case, you are passing the reference by value and changing it in the method has no impact on the caller. However, in the case of the Collection, you could corrupt it if you can add objects which the caller does not expect to be in it.

Similar Messages

  • How to create an collection/array/object/thingy from a bunch of objects for eventual export to CSV.

    This is a follow-up to an earlier post (How
    to output a bunch of variables into a table.) Now that I can ouput data for a single computer I need to to do the same for a list of computers into a CSV. In more general terms how do I get a bunch of $Computer objects into a single collection/array/object/thingy
    with a clever name like $Computers?
    # http://ss64.com/ps/get-wmiobject-win32.html
    # http://social.technet.microsoft.com/Forums/en-US/da54b6ab-6941-4e45-8697-1d3236ba2154/powershell-number-of-cpu-sockets-wmi-query?forum=winserverpowershell
    # http://serverfault.com/questions/10328/determine-cpu-processors-vs-sockets-though-wmi
    # http://social.technet.microsoft.com/Forums/windowsserver/en-US/8443fcfd-5a0b-4c3d-bda7-26df83d2ee92/how-to-output-a-bunch-of-variables-into-a-table?forum=winserverpowershell
    Param(
    [Parameter(Mandatory=$false,ValueFromPipeline=$true)]
    [string]$ComputerName = $env:COMPUTERNAME,
    [Parameter(Mandatory=$false,ValueFromPipeline=$false)]
    [ValidateScript(
    If ( $_ -ne $null ) { Test-Path $_ }
    [String]$ComputerListFile
    Function Get-Computer
    Param(
    [string]$ComputerName
    $Win32_PingStatus = $null
    $Win32_PingStatus_Result = $null
    $Win32_OperatingSystem = $null
    $Win32_Processor = $null
    $Win32_PhysicalMemory = $null
    $Win32_ComputerSystem = $null
    $Win32_BIOS = $null
    $Computer = $null
    $Win32_PingStatus = "select * from Win32_PingStatus where address = '$ComputerName'"
    $Win32_PingStatus_Result = Get-WmiObject -query $Win32_PingStatus
    If ( $Win32_PingStatus_Result.protocoladdress )
    "$ComputerName ping succeeded."
    $Win32_OperatingSystem = Get-WmiObject Win32_OperatingSystem -computer $ComputerName -ErrorAction SilentlyContinue
    If ( $Win32_OperatingSystem -eq $null)
    "$ComputerName WMI failed."
    } Else {
    "$ComputerName WMI succeeded."
    $Win32_Processor = [object[]]$(Get-WmiObject Win32_Processor -computer $ComputerName)
    $Win32_PhysicalMemory = [object[]]$(Get-WmiObject Win32_PhysicalMemory -computer $ComputerName)
    $Win32_ComputerSystem = Get-WmiObject Win32_ComputerSystem -computer $ComputerName
    $Win32_BIOS = Get-WmiObject Win32_BIOS -computer $ComputerName
    $Computer = New-Object -Type PSObject -Property @{
    Name = $Win32_OperatingSystem.CSName
    Win32_BIOS_SerialNumber = [string]$Win32_BIOS.SerialNumber
    Win32_ComputerSystem_Manufacturer = [string]$Win32_ComputerSystem.Manufacturer
    Win32_ComputerSystem_Model = [string]$Win32_ComputerSystem.Model
    #Win32_ComputerSystem_NumberOfLogicalProcessors = [int32]$Win32_ComputerSystem.NumberOfLogicalProcessors
    #Win32_ComputerSystem_NumberOfProcessors = [int32]$Win32_ComputerSystem.NumberOfProcessors
    Win32_ComputerSystem_TotalPhysicalMemory = [long]$Win32_ComputerSystem.TotalPhysicalMemory
    Win32_ComputerSystem_TotalPhysicalMemory_GB = [float]($Win32_ComputerSystem.TotalPhysicalMemory / (1024*1024*1024))
    Win32_OperatingSystem_Caption = [string]$Win32_OperatingSystem.Caption
    Win32_OperatingSystem_CSName = [string]$Win32_OperatingSystem.CSName
    #Win32_OperatingSystem_OSArchitecture = [string]$Win32_OperatingSystem.OSArchitecture
    #Win32_OperatingSystem_SerialNumber = [string]$Win32_OperatingSystem.SerialNumber
    Win32_OperatingSystem_ServicePackVersion = [string]$Win32_OperatingSystem.ServicePackMajorVersion + "." + [string]$Win32_OperatingSystem.ServicePackMinorVersion
    Win32_PhysicalMemory_Capacity = ($Win32_PhysicalMemory | ForEach-Object { $_.Capacity } | Measure-Object -Sum).sum
    Win32_PhysicalMemory_Capacity_GB = (($Win32_PhysicalMemory | ForEach-Object { $_.Capacity } | Measure-Object -Sum).sum / (1024*1024*1024))
    Win32_Processor_Count = [int]$Win32_Processor.Count
    Win32_Processor_NumberOfCores = [string]$Win32_Processor[0].NumberOfCores
    Win32_Processor_NumberOfLogicalProcessors = [string]$Win32_Processor[0].NumberOfLogicalProcessors
    #Win32_Processor_Description = [string]$Win32_Processor[0].Description
    Win32_Processor_Manufacturer = [string]$Win32_Processor[0].Manufacturer
    Win32_Processor_Name = [string]$Win32_Processor[0].Name
    } ## end new-object
    $Computer
    } Else {
    "$ComputerName ping failed."
    $ComputerNameMgmt = $ComputerName + "-mgmt"
    $Win32_PingStatus = "select * from Win32_PingStatus where address = '$ComputerNameMgmt'"
    $Win32_PingStatus_Result = Get-WmiObject -query $Win32_PingStatus
    If ( $Win32_PingStatus_Result.protocoladdress )
    "$ComputerNameMgmt ping succeded."
    } Else {
    "$ComputerNameMgmt ping failed."
    "$(Get-Date -Format o) Starting script $($MyInvocation.MyCommand.Name)"
    If ( $ComputerListFile -eq $null -or $ComputerListFile.Length -eq 0 )
    "Processing computer $ComputerName"
    Get-Computer( $ComputerName )
    } Else {
    "Processing computer list $ComputerList"
    $ComputerList = Get-Content $ComputerListFile
    $Computers = @{}
    $Results = @()
    ForEach( $ComputerListMember in $ComputerList )
    "$(Get-Date -Format o) $ComputerListMember"
    # Get-Computer( $ComputerListMember ) | Add-Member -InputObject $Computers -MemberType NoteProperty -Name $_
    # http://social.technet.microsoft.com/Forums/windowsserver/en-US/e7d602a9-a808-4bbc-b6d6-dc78079aafc9/powershell-to-ping-computers
    # $Compuers += New-Object PSObject -Property $Props
    # $Computers += New-Object PSObject -Property Get-Computer( $ComputerListMember )
    Get-Computer( $ComputerListMember )
    "$(Get-Date -Format o) Ending script $($MyInvocation.MyCommand.Name)"
    If I try something like this:
    Get-Computer( $ComputerListMember ) | Add-Member -InputObject $Computers -MemberType NoteProperty -Name $_
    I get the following, even though $_.Name is not null.
    Add-Member : Cannot bind argument to parameter 'Name' because it is null.
    At <path to my script>Get-Hardware_Memory_OSVersion_CPU_Cores_ver04_sanitized.ps1:111 char:107
    + Get-Computer( $ComputerListMember ) | Add-Member -InputObject $Computers -MemberType NoteProperty -Name <<<< $_
    + CategoryInfo : InvalidData: (:) [Add-Member], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.AddMemberCommand
    Or if I try this:
    $Computers += New-Object PSObject -Property Get-Computer( $ComputerListMember )
    I get this:
    New-Object : Cannot bind parameter 'Property'. Cannot convert the "Get-Computer" value of type "System.String" to type "System.Collections.Hashtable".
    At <path to my script>Get-Hardware_Memory_OSVersion_CPU_Cores_ver04_sanitized.ps1:114 char:47
    + $Computers += New-Object PSObject -Property <<<< Get-Computer( $ComputerListMember )
    + CategoryInfo : InvalidArgument: (:) [New-Object], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.NewObjectCommand

    Hi Aenagy,
    If you want to combine all the computers' information to a single array, and add the property computername in the output, please also try the script below, which I make a little modification of the function Get-Computer, pleaese make sure the account running
    the script has the admin permission of the remote computers, or you need to privide cridentials in get-wmiobject, also note I haven't tested:
    $output = @()#to output information of the all the computers
    ForEach( $ComputerName in $ComputerList ){#loop all the computers
    $Win32_PingStatus = "select * from Win32_PingStatus where address = '$ComputerName'"
    $Win32_PingStatus_Result = Get-WmiObject -query $Win32_PingStatus
    If ( $Win32_PingStatus_Result.protocoladdress )
    "$ComputerName ping succeeded."
    $Win32_OperatingSystem = Get-WmiObject Win32_OperatingSystem -computer $ComputerName -ErrorAction SilentlyContinue
    If ( $Win32_OperatingSystem -eq $null)
    "$ComputerName WMI failed."
    Else {
    "$ComputerName WMI succeeded."
    $Win32_Processor = [object[]]$(Get-WmiObject Win32_Processor -computer $ComputerName)
    $Win32_PhysicalMemory = [object[]]$(Get-WmiObject Win32_PhysicalMemory -computer $ComputerName)
    $Win32_ComputerSystem = Get-WmiObject Win32_ComputerSystem -computer $ComputerName
    $Win32_BIOS = Get-WmiObject Win32_BIOS -computer $ComputerName
    $Computer = New-Object -Type PSObject -Property @{
    Computername = $ComputerName #add the property computername
    Name = $Win32_OperatingSystem.CSName
    Win32_BIOS_SerialNumber = [string]$Win32_BIOS.SerialNumber
    Win32_ComputerSystem_Manufacturer = [string]$Win32_ComputerSystem.Manufacturer
    Win32_ComputerSystem_Model = [string]$Win32_ComputerSystem.Model
    #Win32_ComputerSystem_NumberOfLogicalProcessors = [int32]$Win32_ComputerSystem.NumberOfLogicalProcessors
    #Win32_ComputerSystem_NumberOfProcessors = [int32]$Win32_ComputerSystem.NumberOfProcessors
    Win32_ComputerSystem_TotalPhysicalMemory = [long]$Win32_ComputerSystem.TotalPhysicalMemory
    Win32_ComputerSystem_TotalPhysicalMemory_GB = [float]($Win32_ComputerSystem.TotalPhysicalMemory / (1024*1024*1024))
    Win32_OperatingSystem_Caption = [string]$Win32_OperatingSystem.Caption
    Win32_OperatingSystem_CSName = [string]$Win32_OperatingSystem.CSName
    #Win32_OperatingSystem_OSArchitecture = [string]$Win32_OperatingSystem.OSArchitecture
    #Win32_OperatingSystem_SerialNumber = [string]$Win32_OperatingSystem.SerialNumber
    Win32_OperatingSystem_ServicePackVersion = [string]$Win32_OperatingSystem.ServicePackMajorVersion + "." + [string]$Win32_OperatingSystem.ServicePackMinorVersion
    Win32_PhysicalMemory_Capacity = ($Win32_PhysicalMemory | ForEach-Object { $_.Capacity } | Measure-Object -Sum).sum
    Win32_PhysicalMemory_Capacity_GB = (($Win32_PhysicalMemory | ForEach-Object { $_.Capacity } | Measure-Object -Sum).sum / (1024*1024*1024))
    Win32_Processor_Count = [int]$Win32_Processor.Count
    Win32_Processor_NumberOfCores = [string]$Win32_Processor[0].NumberOfCores
    Win32_Processor_NumberOfLogicalProcessors = [string]$Win32_Processor[0].NumberOfLogicalProcessors
    #Win32_Processor_Description = [string]$Win32_Processor[0].Description
    Win32_Processor_Manufacturer = [string]$Win32_Processor[0].Manufacturer
    Win32_Processor_Name = [string]$Win32_Processor[0].Name
    } ## end new-object
    $output+=$Computer #combine all the "$computer" to "$output"
    Else {
    "$ComputerName ping failed."
    $output
    If you have any feedback on our support, please click here.
    Best Regards,
    Anna
    TechNet Community Support

  • How to process a JCO.Table object line by line

    Hello all.
    I am new to development using JCo. How to process a JCO.Table line by line?! I want to print each line of the table using System.out.println ...
    Thx a lot
    Mike

    Hi Mike,
    here is a sample code for you,
    JCO.Table codes = function.getTableParameterList().getTable("INFO");
    for (int i = 0; i < codes.getNumRows(); i++) {
              codes.setRow(i);
              int tmp = new Integer(codes.getString("POSNN")).intValue();
              String tmpStr = new String(Integer.toString(tmp));
              ret = result.put(tmpStr, codes.getString("VBELN"));
    then using System.out.println(), you can print these values.
    regards,
    Abhijeet

  • How to map a collection of object in TopLink?

    For (simple) example, I've a XSD that defines:
    <xsd:complexType name="AttachmentType">
    <xsd:sequence>
    <xsd:element name="docID" nillable="false" type="xsd:string"/>
    </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="MyDocType">
    <xsd:sequence>
    <xsd:element name="attachment" nillable="true" minOccurs="0"
    maxOccurs="unbounded" type="tns:AttachmentType"/>     
    </xsd:sequence>
    </xsd:complexType>
    This XSD is referenced by a WSDL. Using JDeveloper to generate a Java Web Service using the WSDL and will get the following classes:
    public class AttachmentType implements java.io.Serializable
    protected java.lang.String docID;
    public AttachmentType() {    }
    public java.lang.String getDocID() {        return docID;    }
    public void setDocID(java.lang.String docID) {        this.docID = docID;    }
    public class MyDocType implements java.io.Serializable
    protected AttachmentType[] attachment;
    public MyDocType () {    }
    public AttachmentType[] getAttachment() {        return attachment;    }
    public void setAttachment(AttachmentType[] attachment)
    this.attachment = attachment;
    Now I want to generate a XML document from MyDocType. I use TopLink (JAXB) to do the mapping. However, how to map the 'attachment' of type AttachmentType[]? TopLink seems only allowing List/Set/Collection container options.
    Anyone can help?
    Note: I have to use the classes generated from WSDL.
    Thanks!!

    Thanks. I'm using TopLink Workbench for the mapping
    and have no idea on how to specify the XML
    transformation mapping for array attribute. Can you
    tell me more?I was putting together an example of the transformation mapping but came up with a better way. It turns out that a transformation mapping isn't ideal because you have to take over some of the responsibility for converting XML to objects. A better solution is to intercept the calls to the getter and setter for the AttachmentType[] and convert between an Array and List. Just map the Array as a composite collection in the workbench and customize the attachment attribute mapping in code.
    Each mapping in TopLink has Accessor object responsible for getting and setting values in objects. If you choose method or direct access the mapping will have a different Accessor class. So the solution is to use an Accessor that converts the List TopLink builds into an Array of the correct type on set. On get, the Accessor creates a List from the Array.
    You can introduce a custom Accessor using an After Load method. I've put a complete example up on my googlepages account[1]. The key code is listed below. Note that this code assumes you're using direct instance variable access. Also, this code works with TopLink 10.1.3.2 and the TopLink 11 preview. It won't work with previous versions.
    The After Load class that changes the mapping accessor:
    public class MyDocCustomizer {
         public static void customize(ClassDescriptor descriptor) {
              XMLCompositeCollectionMapping mapping = (XMLCompositeCollectionMapping)
                   descriptor.getMappingForAttributeName("attachment");
              InstanceVariableAttributeAccessor existingAccessor =
                   (InstanceVariableAttributeAccessor) mapping.getAttributeAccessor();
              ListArrayTransformationAccessor transformationAccessor =
                   new ListArrayTransformationAccessor(AttachmentType.class, "attachment");
              transformationAccessor.initializeAttributes(descriptor.getJavaClass());
              mapping.setAttributeAccessor(transformationAccessor);
    }The custom InstanceVariableAccessor subclass:
    public class ListArrayTransformationAccessor extends
              InstanceVariableAttributeAccessor {
         private Class arrayClass;
         public ListArrayTransformationAccessor(Class arrayClass, String attributeName) {
              super();
              this.arrayClass = arrayClass;
              this.setAttributeName(attributeName);
         public Object getAttributeValueFromObject(Object anObject)
                   throws DescriptorException {
              Object[] attributeValueFromObject =
                   (Object[]) super.getAttributeValueFromObject(anObject);
              return Arrays.asList(attributeValueFromObject);
         public void setAttributeValueInObject(Object anObject, Object value)
                   throws DescriptorException {
              List collection = (List)value;
              Object[] array = (Object[]) Array.newInstance(arrayClass, collection.size());
              for (int i = 0; i < collection.size(); i++) {
                   Object element = collection.get(i);
                   Array.set(array, i, element);
              super.setAttributeValueInObject(anObject, array);
    }--Shaun
    http://ontoplink.blogspot.com
    [1] http://shaunmsmith.googlepages.com/Forum-519205-OXM-Array.zip

  • How to compare a collection of objects?

    Basically I am checking answers to security questions.
    So I have an id, a question no and the answer_text stored in a table.
    What I intend to do is retrieve this into a collection and compare that to the collection passed in.
    If they match , I return true else I return false.
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
    PL/SQL Release 11.2.0.1.0 - Production
    CORE 11.2.0.1.0 Production
    TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    referencing this thread on collections
    Re: Compare Collections   - PL-00306
    I based my example on TUBBY's example.
    create or replace
    type answer_array_obj
    as
    object(id number,
              question_no number,
              answer_text varchar2(100)
    create or replace type answer_array as table of answer_array_obj;
    DECLARE
    first_list  answer_array_type := answer_array_type(answer_array_obj(1,1,'ONE'),
                                                                             answer_array_obj(1,2,'TWO'),
                                                                             answer_array_obj(1,3,'THREE')
    second_list  answer_array_type := answer_array_type(answer_array_obj(1,1,'ONE'),
                                                                             answer_array_obj(1,2,'TWO'),
                                                                             answer_array_obj(1,3,'THREE')
    compare_list answer_array_type := answer_array_type(NULL);
    BEGIN
    compare_list := first_list  MULTISET EXCEPT second_list;
    IF compare_list.COUNT = 0
    THEN
        compare_list := second_list MULTISET EXCEPT first_list;
    END IF;
    IF compare_list.COUNT = 0
    THEN
        DBMS_OUTPUT.PUT_LINE('EQUAL');
    ELSE
       DBMS_OUTPUT.PUT_LINE('THE ABSENCE OF EQUALITY');
    END IF;
    END;
    /When I looked at the example , by user 933207, he appeared to be using two different objects.
    18 BEGIN
    19 load1( nt_copy1);
    20 load2( nt_copy2);

    Hi,
    what is the question? I doesnt work? So you have to provide a map method
    CREATE OR REPLACE TYPE  "ANSWER_ARRAY_OBJ"
    as
    object(id number,
              question_no number,
              answer_text varchar2(100),
              MAP MEMBER FUNCTION match RETURN VARCHAR2);
    CREATE OR REPLACE TYPE BODY  "ANSWER_ARRAY_OBJ"
    as
              MAP MEMBER FUNCTION match RETURN VARCHAR2 is
              begin
                return to_char(id)||to_char(question_no)||answer_text;
              end;
    end;
    create or replace type answer_array_type as table of answer_array_obj;
    DECLARE
    first_list  answer_array_type := answer_array_type(answer_array_obj(1,1,'ONE'),
                                                                             answer_array_obj(1,2,'TWO'),
                                                                             answer_array_obj(1,3,'THREE')
    second_list  answer_array_type := answer_array_type(answer_array_obj(1,1,'ONE'),
                                                                             answer_array_obj(1,2,'TWO'),
                                                                             answer_array_obj(1,3,'FOUR')
    compare_list answer_array_type := answer_array_type(NULL);
    BEGIN
    compare_list := first_list  MULTISET EXCEPT second_list;
    IF compare_list.COUNT = 0
    THEN
        compare_list := second_list MULTISET EXCEPT first_list;
    END IF;
    IF compare_list.COUNT = 0
    THEN
        DBMS_OUTPUT.PUT_LINE('EQUAL');
    ELSE
       DBMS_OUTPUT.PUT_LINE('THE ABSENCE OF EQUALITY');
    END IF;
    END;
    THE ABSENCE OF EQUALITY
    Statement processed.
    0.02 secondsregards

  • How to process batch in ABAP Objects content

    Hi,
    my name is Wadim and i am sorry for my bad english
    I have a problem, maybe someone of you can help me.
    I need a class to pracess batch(bdc) oder a Call transaction which i had recorded with SHDB. I search for it but without success.
    The class should habe all function like the default BDC-Include "bdcrecx1".
    Is there a default class in SAP?
    Thanks for help.
    regards mark
    Edited by: Krapp Wadim on May 20, 2010 9:19 PM

    There is a class CL_HRTNM_QUOTA_BATCH_MANAGER which has a lot of batch functionality.
    I've never used it. My company has our own Z class for batch processing. A lot of similar code is in CL_HRTNM_QUOTA_BATCH_MANAGER in methods BDC_DYNPRO, BDC_FIELD, BDC_SESSION, CREATE_BATCH.
    In my quick look at that class, I don't see where they call BDC_CLOSE_GROUP but you should have a method with this also.

  • How to return Values from Oracle Object Type to Java Class Object

    Hello,
    i have created an Oracle Object Types in the Database. Then i created Java classes with "jpub" of these types. Here is an example of the type.
    CREATE OR REPLACE TYPE person_type AS OBJECT
    ID NUMBER,
    vorname VARCHAR2(30),
    nachname VARCHAR2(30),
    geburtstag DATE,
    CONSTRUCTOR FUNCTION person_type RETURN SELF AS RESULT,
    CONSTRUCTOR FUNCTION person_type(p_id NUMBER) RETURN SELF AS RESULT,
    CONSTRUCTOR FUNCTION person_type(p_vorname VARCHAR2,
    p_nachname VARCHAR2,
    p_geburtstag DATE) RETURN SELF AS RESULT,
    MEMBER FUNCTION object_exists(p_id NUMBER) RETURN BOOLEAN,
    MEMBER PROCEDURE load_object(p_id NUMBER),
    MEMBER PROCEDURE save_object,
    MEMBER PROCEDURE insert_object,
    MEMBER PROCEDURE update_object,
    MEMBER PROCEDURE delete_object
    MEMBER PROCEDURE load_object(p_id NUMBER) IS
    BEGIN
    SELECT p.id, p.vorname, p.nachname, p.geburtstag
    INTO SELF.ID, SELF.vorname, self.nachname, SELF.geburtstag
    FROM person p
    WHERE p.id = p_id;
    END;
    My problem is, that if i use the member function "load_object" from my java app it doesnt return the selected values to the java class and i dont know why. I use the java class like this:
    PersonObjectType p = new PersonObjectType();
    p.load_object(4);
    There is a reocrd in the database with id = 4 and the function will execute successful. But if i try to use "p.getVorname()" i always get "NULL". Can someone tell me how to do that?
    Thanks a lot.
    Edited by: NTbc on 13.07.2010 15:36
    Edited by: NTbc on 13.07.2010 15:36

    CallableStatement =
    "DECLARE
    a person_type;
    BEGIN
    a.load_object(4);
    ? := a;
    END;"
    And register as an out parameter.
    Edited by: michael76 on 14.07.2010 05:01

  • How to install business content Info Objects..

    Hello all.
    I am trying to do some BW extraction in our sandbox. Unfortunately I dont know how to install BC infoobjects. I have searched thru this forum but am still not fully sure. I have the source system client connected to BI. I replicated the datasources and see a ton of datasources under the UNASSIGNED NODES tree.
    Eg: How do I install the InfoObject 0Material. Can somone tell me steps..I think I can figure out the rest after that.
    Thanks in advance.

    Hi
    The Data Warehousing Workbench for installing BI Content has three navigation windows:
    In the left-hand window you determine the view of the objects in the middle area of the screen.
    In the middle window, you select the objects that you want to activate.
    In the right-hand window, you make the settings for installing the BI Content. The right-hand window also contains an overview of the objects you have selected, and it is here that you start installation of BI Content.
    In the Data Warehousing Workbench, you use the Navigation Window On/Off pushbutton in the toolbar to display or hide the left-hand navigation window. The rest of this section assumes that the left-hand navigation window is displayed.
    2. Assign Relevant Source Systems
    If you want to assign a source system, select the Source System Assignment function. The Choose Source System by Default? dialog box appears.
    Select one or more source systems by setting the corresponding indicators in the Default Assignment column.
    Only ever select the source systems that you really need, otherwise you may have to wait unnecessarily when objects are collected.
    The assignment of the source system is only relevant for source-system dependent objects (such as transfer rules, file DataSources, and InfoPackages). If more than one source system is available, only those objects assigned to the specified source system are collected ready for the transfer. Objects that have not been assigned to the specified source systems are ignored.
    For more information about the special features inherent in activating process chains that can reference source-system dependent objects, see the Customer Content documentation, under Process Chains and Process Variants.
    If you do not select a source system, all the source systems are assigned automatically. You can change your selection later using the Source System Assignment function.
    3. Group Objects To Be Included, Determine Mode of Collection for Objects
    Make the settings you require from the following selection lists on the right-hand side of the screen:
    Grouping
    Choose the objects that you want the system to include. The groupings combine the objects from a particular area. You have the following options:
    Only Necessary Objects (default setting)
    Data Flow Before
    Data Flow Afterwards
    Data Flow Before and Afterwards
    If you change the default setting (Only Necessary Objects), the new setting becomes the default setting for your user.
    The grouping selection has an impact on system performance during BI Content installation. For more information, see View of Objects and Object-Specific Recommendations.
    Collection Mode
    Select how you want to collect the objects:
    Collect Automatically (default setting): The data is collected when the objects are selected.
    Start Manual Collection: The data is only collected when you choose Collect Dependent Objects.
    Set the collection mode to Start Manual Collection. You can select all the objects without having to wait.
    4. Determine View of Objects
    In the left-hand navigation window, specify how you want the objects to be displayed. For more information, see View of Objects and Object-Specific Recommendations.
    5. Transfer the Objects to Collected Objects
    In the central area of the screen, select the objects that you want to install, and drag and drop them into the right-hand Collected Objects area of the screen.
    The Find Object function allows you to use strings of characters (for example, 0CUST) or wild card searches (for example, 0CUST_*B) to search for objects.
    Input help is available for every type of object: Double-click on the Select Objects icon in the tree structure of the corresponding object type to display the Input Help for Metadata screen. Select the required objects. Choose Transfer Selection.
    If you implement BI Service API Releases lower than 7.0 in the source system, you have to install the active version of the BI Content DataSources in the source system and replicate them in the BI system before you can use them for transferring data into BI. For more information, see Installing BI Content DataSources and Metadata Upload for SAP Systems.
    In the Collected Objects area of the screen, the system displays the selected objects and all dependent objects. Collected objects are stored by default in the repository cache. This reduces the time it takes to access these objects when you want to use them again.
    When you transfer objects into the Collected Objectsarea of the screen, these objects are also added to the tree structure of the corresponding object type in the central area of the screen and stored for your user. This personal object list can be called up each time the program is restarted.
    If you want to remove objects from your personal list, select the objects that you want to remove and choose the Remove Object from Display option from the context menu or click on the icon.
    Objects that are listed in several tree structures can only be changed in the place where they first appear. All additional instances of these objects are grayed out so you cannot modify them.
    6. Check Settings for Collected Objects
    Check the following columns in the Collected Objects area of the screen:
    Install
    The following BI Content objects are highlighted in this column by default:
    Objects that are being transferred for the first time. There is not an active version of these objects in the system.
    BI Content objects that have been redelivered in a new version. These objects can be identified by the Content time stamp in the corresponding object tables.
    When setting this indicator, check whether the checkbox refers to a folder of an individual object: If the checkbox refers to a folder, the indicator is set for all the objects that belong to this folder. If the checkbox refers to an individual object, the indicator is set for a single object and the indicators for the other objects in the folder are not changed. The same applies if you deselect this indicator.
    In the context menu, the following options are available for the installation:
    a. Install All Below
    The object in the selected hierarchy level and all objects in the lower levels of the hierarchy are selected as to Install.
    b. Do Not Install All Below
    The Install indicators are deselected for the object in the selected hierarchy level and all objects in the lower levels of the hierarchy.
    Match (X) or Copy
    If the SAP delivery version and the active version can be matched, a checkbox is displayed in this column.
    With the most important object types, the active version and the SAP delivery version can be matched.
    Note that the InfoSource TRCS supports the match, but the 3.x InfoSource ISTD does not.
    From a technical point of view, the SAP delivery version (D version) is matched against the M version. As in most cases the M version is identical to the active version (A version) in a customer system, this is referred to as a match between the D and A versions for reasons of simplification.
    When a match is performed, particular properties of the object are compared in the A version and the D version. First it has to be decided whether these properties can be matched automatically or whether this has to be done manually. If you are sure that the object will be used in the same way after you install BI Content, you can perform an automatic match for those properties. When performing matches manually you have to decide whether the characteristics of a property from the active version are to be retained, or whether the characteristics are to be copied from the delivery version.
    Assign points if useful.
    Thanks & Regards,
    Hari

  • How to release process model sequence file object?

    Calling engine's method GetStationModelSequenceFile we get the reference to the process model sequence file object. According to TestStand Help, you should "Release this reference when you are done using it." The question is: how do you release it? Call engine's method ReleaseSequenceFileEx passing the reference to the model sequence file gotten from GetStationModelSequenceFile won't work, it returns FALSE which means the sequence file can't be released. Similar problems exist with methods SequenceFile.GetModelSequenceFile, Execution.GetModelSequenceFile. My aplication is written in VB. Using the statement like
    Set modelSequenceFile = Nothing also does not solve the problem.  I want to get some information of process model, such as version number, so I call those API functions in my code, which was developed under TestStand 3.1. I post this question because when I ran my application with TestStand 3.5 or 4.0 beta, I got the warning dialog when loading a sequence file and then closing the application. The dialog listed all the unreleased objects which I figured out is due to that the process model file was not released. Because message in the dialog is as following:
    The following top-level objects were not released:
            Sequences [1 object(s) not released]
                Sequence #1:
                    Name: Test UUTs
            Type Definitions [43 object(s) not released]
                Type Definition #1:
                    Name: TimeDetails
                Type Definition #2:
                    Name: ReportOptions
    Of course there are more in the list, but the sequence file loaded into the application is released correctly by calling engine's method ReleaseSequenceFileEx, so it does not appear in the list.
    Any help will be greatly appreciated.

    Here are what I did after launch the operator interface:
    1) Call Engine.GetSequenceFileEx to get a reference to a sequence file.
    2) Display steps of MainSequence of the sequence file in GUI.
    3) Call Engine.GetStationModelSequenceFile to get a reference to the station process model sequence file. The variable used to save the reference of process model sequence file is modelSequenceFile.
    4) Loop through all the sequences in process model sequence file, get the references of entrypoint sequences in the process model and put them in a container (VB Collection).
    At this point,
    Calling modelSequenceFile.CanUnload returns TRUE
    Calling modelSequenceFile.IsExecuting returns FALSE
    Calling Engine.ReleaseSequenceFileEx(modelSequenceFile, ReleaseSeqFile_UnloadFile) returns FALSE
    There is no other loaded process model sequence file reference at this point.

  • How do you retrieve a Collection of objects using JDBC?

    How do you retrieve a Collection of objects using JDBC.
    MORE INFO:
    I have created a class i.e. Account class and I want to retrieve all the accounts previously created for accounts in my Mysql database..
    my method would retrieve an array of Account instances in the database i.e.
    public Vector retrieveAccounts();

    Connection con = null;
    ArrayList accounts = new ArrayList();
    try{
      con = DriverManager.getConnection(...);
      PreparedStatement ps = con.prepareStatement("select * from accounts");
      Resultset rs = ps.executeQuery();
      while (rs.next()) {
        Account account = new Account(rs.getString(1), rs.getString(2), ...);
        accounts.add(account);
      Account[] account_array = new Account[accounts.size()];
      accounts.toArray(account_array);
    catch (SQLException sqle) {
       sqle.printStackTrace();
    finally {
      if (con != null) {
        con.close();
    }should pretty much to what you want, you will obviously need to change it so that, a) the SQL query is correct and b) the Account class is correct and c) the correct values are taken from the result set to create an account.

  • Increase the number of portions in process for each conversion object

    I experts,
    I configured SAP TDMS 3.0 with SP 14 to transfer test data from QAS to DEV (both is ECC 6.0) for the first test with TDMS TIM (Time Based Reduction).
    The data transfer phase is still running (99% - 60hs running). We analyzed the Display Runtime Information report and see that objects of conversion with similar calc. records and calc. GBytes have very different the Net Runtime.
    TMDS currently is working with four objects of conversion, processing a portion of each.
    Conversion objects that are running are:
    - Z_LTBP_002
    - Z_TSEGE_002
    - Z_VEVW_002
    - Z_YST27_002
    We check in the receiver system, and we see that is use only one DIA process to update the each table.
    How can increase the performance of the update? Is correct that use only 1 DIA process for this??
    Can I increase the number of portions in process for each conversion object?
    Any help is greatly appreciated.
    Regards,
    Sergio

    Hi,
    Check SAP Note 916763 - TDMS performance composite SAP note
    Note 890797 - SAP TDMS - required and recommended system settings
    Thanks
    Sunny

  • Why and how to use events in abap objects

    Dear all,
      Please explain me why and how to use events in abap objects with real time example
    regards
    pankaj giri

    Hi Pankaj,
    I will try to explain why to use events... How to use is a different topic.. which others have already answered...
    This is same from your prev. post...
    Events :
    Technically speaking :
    " Events are notifications an object receives from, or transmits to, other objects or applications. Events allow objects to perform actions whenever a specific occurrence takes place. Microsoft Windows is an event-driven operating system, events can come from other objects, applications, or user input such as mouse clicks or key presses. "
    Lets say you have an ALV - An editable one ...
    Lats say - Once you press some button  you want some kind of validation to be done.
    How to do this ?
    Raise an Event - Which is handled by a method and write the validation code.
    Now you might argue, that I can do it in this way : Capture the function code - and call the validate method.
    Yes, in this case it can be done.. But lets say .. you change a field in the ALV and you want the validation to be done as soon as he is done with typing.
    Where is the function code here ? No function code... But there is an event here - The data changed event.
    So you can raise a data changed event that can be handled and will do the validation.
    It is not user friendly that you ask the user to press a button (to get the function code) for validation each time he enters a data.
    The events can be raised by a system, or by a program also. So in this case the data changed event is raised by a system that you can handle.
    Also, Lets say on a particular action you want some code to trigger. (You can take the same example of validation code). In this case the code to trigger is in a separate class. The object of which is not available here at this moment. (This case happens very frequently).
    Advantage with events : Event handlers can be in a separate class also.
    e.g : In the middle of some business logic .. you encounter a error. You want to send this information to the UI (to user - in form of a pop up) and then continue with some processing.
    In many cases - A direct method call to trigger the pop up is not done. Because (in ideal cases) the engine must not interact with UI directly - Because the UI could be some other application - like a windows UI but the error comes from some SAP program.
    So - A event is raised from the engine that is handled in the UI and a pop up is triggered.
    Here -- I would have different classes (lets say for different Operating Systems). And all these classes must register to the event ERROR raised in application.
    And these different classes for different Operation systems will have different code to raise a pop-up.
    Now you can imagine : If you coded a pop-up for Windows (in your application logic) .. it will not work for Mac or Linux. But of you raise a event.. that is handled separately by a different UI classes for Win, Linux or Mac  they will catch this event and process accordingly.
    May be I complicated this explanation .... but I couldn't think of a simpler and concrete example.
    Cheers.
    Varun.

  • How to process the PDF files at one time

    Hello,
    I'm using WebDynpro for ABAP and Adobe Interactive Forms as offline forms.
    I collect PDF files from received e-mails.
    I want them to be taken in at one time.
    (for example,
    system job read PDF files and create data in ERP,
    or I upload the files one time.)
    Please let me know
    - How to process the PDF files at one time.
    Best regards,
    Koji

    When you click the edit button in recents, try clicking the clear button in the upper left.

  • Client code cast error:EJB returning data in Collection of Objects

    Still trying to understand this EJB stuff.....
    My BMP EJB returns data to the client in a collection of objects;
      // Home interface (CountryHome) nothing unusual here
      public Collection findAllCountries()
      //Remote interface (Country) nothing unusual here
      public CountryModel getDetails()The data object is a serialised object;
      // data object - nothing strange here
      public class CountryModel implements Serializable {
        private int countryId;
        private String countryName;
        public CountryModel () {......etc etc
        public CountryModel getDetails()  {.......etc etc
        public String toString() { ...etcWhen I try and get at the data from the collection in the client code, calling getDetails() in CountryModel causes a cast exception. How can I get at the data?
      Collection a = home.findAllCountries();
      Iterator i = a.iterator();
      while (i.hasNext()) {
        Object obj = i.next();
        Country country = (Country)
             PortableRemoteObject.narrow(obj, Country.class);
        // this fails with class cast exception.....
        System.out.println(country.getDetails());And to add to the confusion, why does calling the remote interface's getPrimaryKey() method in the client code invoke the toString() method in the CountryModel class and work?
      while (i.hasNext()) {
        Object obj = i.next();
        Country country = (Country)
             PortableRemoteObject.narrow(obj, Country.class);
        // have no idea why this works.....but it does.....
        System.out.println(country.getPrimaryKey());Thanks, lebo

    hi,
    you are getting a collection of serializable objects and not remote objects. the narow method has to be applied only for remote objects (actually it is the stub that will be received on the client side).
    so you modify your code as,
    Collection a = home.findAllCountries(); Iterator i = a.iterator(); while (i.hasNext()) {    Object obj = i.next();    Country country = (Country)obj;
    this will definitely solve the problem.
    regards
    srini

  • How to Process a picture from a Camera to Labview

    I want to try and get a picture processed through Labview from a camera. For example I want to take a picture of a cup on a table and process it through Labview so that I can write a program for a robotic arm to pick up the cup from the table. I would like someone to advice me on how to process the picture from the camera and display it on Labview. Are there any examples in Labview, or the internet that can help put me in the right direction?  

    I would recommend starting small and have clear objectives in mind.  For example clearly define what you want your robot to do.  Do you want it to pick up "a" cup or anything that looks like a cup.   Things like learning algorithms, image processing, IMAQ, 3D motion control all come to mind.  These are subjects outside the scope of Labview but may be required in addition to understanding how to program your task in Labview.  There are dozens of examples in Labview on these subjects.  Take the task one step at a time and move from there.  It may also be helpful in the forum to give people an idea of your background.   If you are new to Labview this may be a very hard first program.  SS 

Maybe you are looking for