Need help in using a Secondary Index of a GL Table

Hello ABAPers,
Good morning/afternoon!
I  was wondering if anyone could give me a hand on this issue.
To give you a brief background, I need to retrieve Open and Cleared items in the last 24 hours, that is, from 11 am yesterday till 10:59:59 today. The criteria is to pull the information using Entry Date (CPUDT) and Entry Time (CPUTM) from BKPF and using BELNR, retrieve the postings in BSIS and BSAS. as you can see in the piece of code. However, this process takes soooooo long to run.
Below is the code snippet.
We use 46C and MS SQL database.
The index fields of BKPF~ZB2 are: MANDT, CPUDT and BLART.
The index fields of BSIS~Z01are: BUKRS, GJAHr, HKONT, PRCTR, GSBER
TYPES: BEGIN OF i_bseg,
       bukrs LIKE bkpf-bukrs,
       hkont LIKE bsis-hkont,
       gjahr LIKE bkpf-gjahr,
       belnr LIKE bkpf-belnr,
       buzei LIKE bsis-buzei,
       bldat LIKE bsis-bldat,
       budat LIKE bsis-budat,
       waers LIKE bsis-waers,
       monat LIKE bsis-monat,
       shkzg LIKE bsis-shkzg,
       gsber LIKE bsis-gsber,
       dmbtr LIKE bsis-dmbtr,
       wrbtr LIKE bsis-wrbtr,
       cpudt LIKE bkpf-cpudt,
       cputm LIKE bkpf-cputm,
       END OF i_bseg.
*Internal Tables
DATA:
      i_bkpf TYPE TABLE OF bkpf,
      i_bseg TYPE STANDARD TABLE OF i_bseg.
Select records from yesterday's entry date.
    SELECT  bukrs belnr gjahr monat budat cpudt cputm waers
            FROM bkpf INTO  CORRESPONDING FIELDS OF TABLE i_bkpf
            WHERE ( cpudt = so_date2-low AND
                    cputm >= so_cputm-low AND
                    cputm <= so_cputm-high )
            OR    ( cpudt = so_date2-high AND
                    cputm >= so_time2-low AND
                    cputm <= so_time2-high )
            %_HINTS MSSQLNT 'INDEX("BKPF" "BKPF~ZB2")'.
    IF sy-subrc NE 0.
      MESSAGE e006 WITH 'BKPF'.
    ENDIF.
Select Open Items***
    SELECT bukrs hkont gjahr belnr buzei  budat bldat
           waers monat shkzg gsber  dmbtr wrbtr
           FROM bsis
           APPENDING CORRESPONDING FIELDS OF TABLE i_bseg
           FOR ALL ENTRIES IN i_bkpf
           WHERE bukrs = i_bkpf-bukrs
           AND gjahr = i_bkpf-gjahr
           AND hkont IN so_saknr
           AND belnr = i_bkpf-belnr
           %_HINTS MSSQLNT 'INDEX("BSIS" "BSIS~Z01")'.
Also get any cleared items ***
    SELECT bukrs hkont gjahr belnr buzei  budat bldat
           waers monat shkzg gsber  dmbtr wrbtr
           FROM bsas
           APPENDING CORRESPONDING FIELDS OF TABLE i_bseg
           FOR ALL ENTRIES IN i_bkpf
           WHERE bukrs IN so_bukrs
           AND   hkont IN so_saknr
           AND   gjahr = sp_gjahr
           AND   belnr = i_bkpf-belnr.
Many thanks,
Rosemarie

Thanks for your response.
The date and time fields are defined in my selection screen and the default values pre-set in the INITIALIZATION, so the dates and times are already stored as a range.
The problem is why is the process taking so long. Is the syntax for the INDEX correct?
PARAMETERS:p_not RADIOBUTTON GROUP pass.
SELECT-OPTIONS:
  so_date2 FOR bkpf-cpudt,         " Entry Date
  so_cputm FOR sy-uzeit,         " Entry Time
  so_time2 for sy-uzeit.        " Entry Time 2
INITIALIZATION.
RANGES: so_time2 FOR sy-uzeit.
  g_date = sy-datum - 1.
  g_year = sy-datum+0(4).
  sp_gjahr = g_year.
  CONCATENATE sp_gjahr '0101' INTO g_from_date.
  g_from_time = '110000'.
  g_24_hour   = '235959'.
  g_time_diff = g_24_hour - g_from_time.
  g_to_time = g_from_time + g_time_diff.
  g_to_time2 = g_from_time - 1.
  MOVE: 'I'      TO so_cpudt-sign,
        'BT'     TO so_cpudt-option,
        g_from_date   TO so_cpudt-low,
        sy-datum TO so_cpudt-high.
  APPEND so_cpudt.
  MOVE: 'I'      TO so_date2-sign,
        'BT'     TO so_date2-option,
        g_date   TO so_date2-low,
        sy-datum TO so_date2-high.
  APPEND so_date2.
  MOVE: 'I'         TO so_cputm-sign,
        'BT'        TO so_cputm-option,
        g_from_time TO so_cputm-low,
        g_to_time   TO so_cputm-high.
  APPEND so_cputm.
  MOVE: 'I'         TO so_time2-sign,
        'BT'        TO so_time2-option,
        '000000'    TO so_time2-low,
         g_to_time2 TO so_time2-high.
  APPEND so_time2.

Similar Messages

  • Need help in using FM BAPI_MATERIAL_SAVEDATA

    Gurus,
    I need help in using the FM BAPI_MATERIAL_SAVEDATA. The FM is returning a message that says "The field MARA-MEINS/BAPI_MARA-BASE_UOM(_ISO) is defined as a required field; it does not contain an entry".
    I have supplied the necessary details and yet the FM won't push through.
    If possible, please post sample codes.
    Below is my sample code:
    ===============================================
    REPORT  zmm_materialupload.
    eject
    $$******************************************************************************
    $$    TYPES
    $$******************************************************************************
    eject
    $$******************************************************************************
    $$    INTERNAL TABLES (custom structure
    $$******************************************************************************
    eject
    $$******************************************************************************
    $$    RANGES
    $$******************************************************************************
    eject
    $$******************************************************************************
    $$    FIELD-SYMBOLS
    $$******************************************************************************
    eject
    $$******************************************************************************
    $$    PARAMETERS & SELECT-OPTIONS
    $$******************************************************************************
    SELECTION-SCREEN BEGIN OF BLOCK 1 WITH FRAME TITLE text-001.
    *SELECT-OPTIONS: s_matnr FOR mara-matnr.
    SELECT-OPTIONS: s_mtart FOR mara-mtart.
    SELECT-OPTIONS: s_mbrsh FOR mara-mbrsh DEFAULT 'P'.
    SELECT-OPTIONS: s_werks FOR marc-werks DEFAULT '1000' OBLIGATORY.
    SELECT-OPTIONS: s_lgort FOR marc-lgpro DEFAULT 'OPSL' OBLIGATORY.
    PARAMETERS: p_path  LIKE rlgrap-filename DEFAULT 'C:\Documents and Settings\training_11\Desktop\Book4 (2ITEMS).txt' OBLIGATORY.
    SELECTION-SCREEN END OF BLOCK 1.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_path.
      CALL FUNCTION 'F4_FILENAME'
        EXPORTING
          field_name = 'P_FNAME'
        IMPORTING
          file_name  = p_path.
    eject
    $$******************************************************************************
    $$    START-OF-SELECTION
    $$******************************************************************************
    START-OF-SELECTION.
      PERFORM check_input.
      PERFORM get_file.
      PERFORM filter_input.
    PERFORM populate_tabs.
      PERFORM bapi_mat.
    eject
    $$******************************************************************************
    $$    FORMS
    $$******************************************************************************
    FORM bapi_mat.
      LOOP AT it_tab INTO wa_tab.
        CALL FUNCTION 'BAPI_MATERIAL_GETINTNUMBER'
          EXPORTING
            material_type    = wa_tab-mtart
            industry_sector  = wa_tab-mbrsh
            required_numbers = 1
          TABLES
            material_number  = it_matnr.
      ENDLOOP.
      LOOP AT it_matnr INTO wa_matnr.
        READ TABLE it_tab INTO wa_tab INDEX sy-tabix.
        wa_tab-matnr = wa_matnr-material.
        MODIFY it_tab FROM wa_tab INDEX sy-tabix.
      ENDLOOP.
      PERFORM populate_tabs.
      CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
        EXPORTING
         headdata                   = it_headdata
        clientdata                 = it_clientdata
        clientdatax                = it_clientdatax
        plantdata                  = it_plantdata
        plantdatax                 = it_plantdatax
        FORECASTPARAMETERS         =
        FORECASTPARAMETERSX        =
        PLANNINGDATA               =
        PLANNINGDATAX              =
        STORAGELOCATIONDATA        =
        STORAGELOCATIONDATAX       =
        valuationdata              = it_valuationdata
        valuationdatax             = it_valuationdatax
         WAREHOUSENUMBERDATA        =
        WAREHOUSENUMBERDATAX       =
        SALESDATA                  =
        SALESDATAX                 =
        STORAGETYPEDATA            =
        STORAGETYPEDATAX           =
        flag_online                = ' '
        flag_cad_call              = ' '
        NO_DEQUEUE                 = ' '
        NO_ROLLBACK_WORK           = ' '
       IMPORTING
         return                     = it_return
       TABLES
         materialdescription        = it_materialdescription
         unitsofmeasure             = it_unitsofmeasure
         unitsofmeasurex            = it_unitsofmeasurex
         internationalartnos        = it_internationalartnos
         materiallongtext           = it_materiallongtext
         taxclassifications         = it_taxclassifications
         returnmessages             = it_returnmessages
        PRTDATA                    =
        PRTDATAX                   =
        EXTENSIONIN                =
        EXTENSIONINX               =
      IF sy-subrc = 0.
      ENDIF.
      CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
        EXPORTING
          wait   = 'X'
        IMPORTING
          return = it_return.
    ENDFORM.                    "bapi_mat
    *&      Form  GET_FILE
          text
    FORM get_file.
      CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
        EXPORTING
          text = 'Getting data from file...'.
      MOVE: p_path TO gv_file.
      CALL FUNCTION 'GUI_UPLOAD'
        EXPORTING
          filename                = gv_file
          filetype                = 'ASC'
          has_field_separator     = 'X'
          read_by_line            = 'X'
        TABLES
          data_tab                = it_tab
        EXCEPTIONS
          file_open_error         = 1
          file_read_error         = 2
          no_batch                = 3
          gui_refuse_filetransfer = 4
          invalid_type            = 5
          no_authority            = 6
          unknown_error           = 7
          bad_data_format         = 8
          header_not_allowed      = 9
          separator_not_allowed   = 10
          header_too_long         = 11
          unknown_dp_error        = 12
          access_denied           = 13
          dp_out_of_memory        = 14
          disk_full               = 15
          dp_timeout              = 16
          OTHERS                  = 17.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    ENDFORM.                    "GET_FILE
    *&      Form  check_input
          text
    FORM check_input.
    Material Type
      IF s_mtart-low IS INITIAL AND s_mtart-high IS INITIAL.
       s_mtart = 'IEQ'.
       s_mtart-low = 'ABF'.        "Waste
       s_mtart-high = 'ZTRD'.      "Stock Items
       APPEND s_mtart.
      ENDIF.
      IF s_mtart-low IS NOT INITIAL AND s_mtart-high IS INITIAL.
        MOVE: s_mtart-low TO s_mtart-high.
      ENDIF.
    Industry Sector
      IF s_mbrsh-low IS INITIAL AND s_mbrsh-high IS INITIAL.
       s_mbrsh = 'IEQ'.
       SELECT mbrsh
       FROM mara
       INTO TABLE it_mbrsh.
       s_mbrsh-low = wa_mbrsh-mbrsh.
       LOOP AT it_mbrsh INTO wa_mbrsh.
         s_mbrsh-high = wa_mbrsh-mbrsh.
       ENDLOOP.
       APPEND s_mbrsh.
      ENDIF.
      IF s_mbrsh-low IS NOT INITIAL AND s_mbrsh-high IS INITIAL.
        MOVE: s_mbrsh-low TO s_mbrsh-high.
      ENDIF.
    Plant
      IF s_werks-low IS INITIAL AND s_werks-high IS INITIAL.
        s_werks = 'IEQ'.
        s_werks-low = '1000'.
        s_werks-high = '2000'.
      ENDIF.
      IF s_werks-low IS NOT INITIAL AND s_werks-high IS INITIAL.
        MOVE: s_werks-low TO s_werks-high.
      ENDIF.
    Storage Location
      IF s_lgort-low IS NOT INITIAL AND s_lgort-high IS INITIAL.
        MOVE: s_lgort-low TO s_lgort-high.
      ENDIF.
    ENDFORM.                    "check_input
    *&      Form  Filter_input
          text
    FORM filter_input.
      SORT it_tab BY matnr mtart mbrsh werks lgort.
      LOOP AT it_tab INTO wa_tab.
       IF wa_tab-mtart NOT IN s_mtart.
         DELETE it_tab WHERE mtart NOT IN s_mtart.
       ENDIF.
       IF wa_tab-mbrsh NOT IN s_mbrsh.
         DELETE it_tab WHERE mbrsh NOT IN s_mbrsh.
       ENDIF.
        IF wa_tab-werks NOT IN s_werks.
          DELETE it_tab WHERE werks NOT IN s_werks.
        ENDIF.
        IF wa_tab-lgort NOT IN s_lgort.
          DELETE it_tab WHERE lgort NOT IN s_lgort.
        ENDIF.
      ENDLOOP.
    ENDFORM.                    "Filter_input
    *&      Form  populate_tabs
          text
    FORM    populate_tabs.
      LOOP AT it_tab INTO wa_tab.
        MOVE: wa_tab-matnr TO wa_headdata-material,
              wa_tab-mbrsh TO wa_headdata-ind_sector,
              wa_tab-mtart TO wa_headdata-matl_type,
                       'X' TO wa_headdata-basic_view,
                       'X' TO wa_headdata-sales_view,
                       'X' TO wa_headdata-purchase_view,
                       'X' TO wa_headdata-mrp_view,
                       'X' TO wa_headdata-account_view.
             wa_tab-matkl TO wa_clientdata-matl_group,
             wa_tab-meins TO wa_clientdata-base_uom,
             wa_tab-groes TO wa_clientdata-size_dim,
             wa_tab-gewei TO wa_clientdata-unit_of_wt,
             wa_tab-ntgew TO wa_clientdata-net_weight,
                      'X' TO wa_clientdatax-matl_group,
                      'X' TO wa_clientdatax-base_uom,
                      'X' TO wa_clientdata-size_dim,
                      'X' TO wa_clientdatax-unit_of_wt,
                      'X' TO wa_clientdatax-net_weight,
             wa_tab-werks TO wa_plantdata-plant,
             wa_tab-ekgrp TO wa_plantdata-pur_group,
             wa_tab-prctr TO wa_plantdata-profit_ctr,
             wa_tab-werks TO wa_plantdatax-plant,
                      'X' TO wa_plantdatax-pur_group,
                      'X' TO wa_plantdatax-profit_ctr,
             wa_tab-werks TO wa_valuationdata-val_area,
             wa_tab-bklas TO wa_valuationdata-val_class,
             wa_tab-peinh TO wa_valuationdata-price_unit,
             wa_tab-verpr TO wa_valuationdata-moving_pr,
             wa_tab-stprs TO wa_valuationdata-std_price,
             wa_tab-xlifo TO wa_valuationdata-lifo_fifo,
             wa_tab-werks TO wa_valuationdatax-val_area,
                      'X' TO wa_valuationdatax-val_class,
                      'X' TO wa_valuationdatax-price_unit,
                      'X' TO wa_valuationdatax-moving_pr,
                      'X' TO wa_valuationdatax-std_price,
                      'X' TO wa_valuationdatax-lifo_fifo.
        APPEND wa_headdata TO it_headdata.
       APPEND wa_clientdata TO it_clientdata.
       APPEND wa_plantdata TO it_plantdata.
       APPEND wa_valuationdata TO it_valuationdata.
       MODIFY it_tab FROM wa_tab TRANSPORTING matnr.
      ENDLOOP.
    ENDFORM.                    "populate_tabs
    $$******************************************************************************

    Hai.
    check the below example.
    REPORT z34332_bdc_create_material .
    data: la_headdata type BAPIMATHEAD,
    la_clientdata type BAPI_MARA,
    la_CLIENTDATAX type BAPI_MARAX,
    la_return type BAPIRET2.
    data: i_materialdescription type table of BAPI_MAKT,
    wa_materialdescription like line of i_materialdescription.
    la_headdata-MATERIAL = '000000000000000004'.
    la_headdata-IND_SECTOR = 'M'.
    la_headdata-MATL_TYPE = 'FERT'.
    la_clientdata-BASE_UOM = 'FT3'.
    la_CLIENTDATAX-BASE_UOM = 'X'.
    la_clientdata-MATL_GROUP = '01'.
    la_CLIENTDATAX-MATL_GROUP = 'X'.
    wa_materialdescription = 'TEST'.
    append wa_materialdescription to i_materialdescription.
    clear: wa_materialdescription.
    CALL FUNCTION 'BAPI_MATERIAL_SAVEDATA'
    EXPORTING
    headdata = la_headdata
    CLIENTDATA = la_clientdata
    CLIENTDATAX = la_CLIENTDATAX
    PLANTDATA =
    PLANTDATAX =
    FORECASTPARAMETERS =
    FORECASTPARAMETERSX =
    PLANNINGDATA =
    PLANNINGDATAX =
    STORAGELOCATIONDATA =
    STORAGELOCATIONDATAX =
    VALUATIONDATA =
    VALUATIONDATAX =
    WAREHOUSENUMBERDATA =
    WAREHOUSENUMBERDATAX =
    SALESDATA =
    SALESDATAX =
    STORAGETYPEDATA =
    STORAGETYPEDATAX =
    FLAG_ONLINE = ' '
    FLAG_CAD_CALL = ' '
    IMPORTING
    RETURN = la_return
    TABLES
    MATERIALDESCRIPTION = i_materialdescription
    UNITSOFMEASURE =
    UNITSOFMEASUREX =
    INTERNATIONALARTNOS =
    MATERIALLONGTEXT =
    TAXCLASSIFICATIONS =
    RETURNMESSAGES =
    PRTDATA =
    PRTDATAX =
    EXTENSIONIN =
    EXTENSIONINX =
    write: la_return-TYPE, ',', la_return-MESSAGE.
    clear: la_headdata, la_return, la_clientdata, la_clientdatax.
    regards.
    sowjanya.b.

  • Use two secondary indexes in a select statement

    hi, i want to use two secondary indexes in a select statement.
    how can i do it?

    Hello,
    To do it use the WHERE stm in the same order as the secondary stm is on SE11....To check if the index is used go to tcode ST05.
    example
    select * from ztable
    WHERE BUKRS EQ 'BUK1' AND
                 ZFIELD EQ 'BOY'.
    on se11 on the ZTABLE indexes setion must have a secondary index with
    BUKRS and
    ZFIELD.
    BYE!!
    Hope this helps!!
    Gabriel

  • Need help in using ActiveX to retrieve a VARIANT

    Need help in using ActiveX to retrieve a VARIANT.
    Variant is shown as       var{VT_Ul1,1}  in debug
    Using the following
    hr = CA_VariantGetShort (&var, &value);
    I get 0 for my answer instead of 1.
    Solved!
    Go to Solution.

    Answered my own question.
    VT_Ul1 is an unsigned char and not a short.

  • Need help on Using Oracle Acces Manager 11g

    Hi
    I Need help on Using Oracle Acces Manager Admin console to configure for SSO.
    I am new to Identity Management
    I have installed OAM 11g and configured for OAM in new weblogic domain
    Please help to proceed forward.
    Thanks
    Swapnil

    Hi
    Thanks for your reply
    I am able to login to the console
    I am unable to login the the weblogic server from another machine but abl eto do so from the machine where all this is installed
    What i feel is there needs to be some configurataion maybe policy or Agent
    IDMDomainAgent is configured and so is the OAM server configured .
    Please advice some books or link how to do achieve logging into the weblogic em/console from a remote machine
    Thanks in Advance

  • I need help on using up Microsoft.

    i need help on using up microsoft
    Moderator's Note: Post was moved and changed the title into a subject-related title. This is to keep the forum organized and let other forum users easily see and respond to this post.

    Please, we need the error message word for word. If you do not get an error message, please, elaborate in greater detail …
    Furthermore, which phone model do you use?

  • Secondary Index on ODS Change Table

    Hi All,
    We have a process that does a lookup to the change table /bic/XXXX40 in the update rules while loading the ODS. We are having performance problems that can be resolved by putting a secondary index on the change table. We are able to create the index in the Dev env using SE11, but we can't put it in a package other than $TMP. Putting a secondary index on the ODS in the normal way didn't put the index on the change table so that doesn't help us.
    Any ideas on how we can get our new index into a package that we can transport?
    Thanks in advance!

    Just echoing Jorge's post - you'll need to open Prod and create it there, same is if you were creating secondary indices on master data tables or dimension tables, since the wkbench doesn't support creating indices on them either.
    PS.
    Put yourself on the SDN world map (http://sdn.idizaai.be/sdn_world/sdn_world.html) and earn 25 points.
    Spread the wor(l)d!

  • Transport of secondary index on /BIC/P table

    Hi All,
    I have created a secondary index on '/BIC/P table and it is not allowing me to assign a transport object as the table itself is temporary and it gets created automatically in the target system when we activate the info-object.
    Is there any way to transport the secondary index directly on the /BIC/P table ?
    Its urgent.
    Thanks
    Soumya

    Soumya,
    Sorry for not being clear enough: you can change the package of this index and transport it but since the P table could be regenerated automatically by the BW application when you change your IObj you may now get into troubles when importing a change.
    Indeed having now a local $TMP table with a non-local object underneath may not please your target system and even not your DEV system...
    One can always bypass SAP BW application; for instance creating indexes directly in the database; but this is at its own risk!
    hoping this will explain a bit further your issue
    Olivier.

  • Can we create secondary index for a cluster table

    hi
    can we create secondary index for a cluster table

    Jyothsna,
    There seems to be some kind of misunderstanding here. You <i>cannot</i> create a secondary index on a cluster table. A cluster table does not exist as a separate physical table in the database; it is part of a "physical cluster". In the case of BSEG for instance, the physical cluster is RFBLG. The only fields of the cluster table that also exist as fields of the physical cluster are the leading fields of the primary key. Taking again BSEG as the example, the primary key includes the fields MANDT, BUKRS, BELNR, GJAHR, BUZEI. If you look at the structure of the RFBLG table, you will see that it has primary key fields MANDT, BUKRS, BELNR, GJAHR, PAGENO. The first four fields are those that all cluster tables inside BSEG have in common. The fifth field, PAGENO, is a "technical" field giving the sequence number of the current record in the series of cluster records sharing the same primary key.
    All the "functional" fields of the cluster table (for BSEG this is field BUZEI and everything beyond that) exist only inside a raw binary object. The database does not know about these fields, it only sees the raw object (the field VARDATA of the physical cluster). Since the field does not exist in the database, it is impossible to create a secondary index on it. If you try to create a secondary index on a cluster table in transaction SE11, you will therefore rightly get the error "Index maintenance only possible for transparent tables".
    Theoretically you could get around this by converting the cluster table to a transparent table. You can do this in the SAP dictionary. However, in practice this is almost never a good solution. The table becomes much larger (clusters are compressed) and you lose the advantage that related records are stored close to each other (the main reason for having cluster tables in the first place). Apart from the performance and disk space hit, converting a big cluster table like BSEG to transparent would take extremely long.
    In cases where "indexing" of fields of a cluster table is worthwhile, SAP has constructed "indexing tables" around the cluster. For example, around BSEG there are transparent tables like BSIS, BSAS, etc. Other clusters normally do not have this, but that simply means there is no reason for having it. I have worked with the SAP dictionary for over 12 years and I have never met a single case where it was necessary to convert a cluster to transparent.
    If you try to select on specific values of a non-transparent field in a cluster without also specifying selections for the primary key, then the database will have to do a serial read of the whole physical cluster (and the ABAP DB interface will have to decompress every single record to extract the fields). The performance of that is monstrous -- maybe that was the reason of your question. However, the solution then is (in the case of BSEG) to query via one of the index tables (where you are free to create secondary indexes since those tables are transparent).
    Hope this clarifies things,
    Mark

  • Is it possible to use a secondary index in embedded persistent class

    Hi,
    I'm new to Berkely DB Java Edition and have just started playing with it.
    To express a relation between two entities Foo and Bar, I am trying with an assocation class FooBarAssociation that is not an entity but rather a @Persistent-annotated embedded class in Foo (Foo has a collection of FooBarAssociations). Now I'm looking for a way to find all Foos associated with a given Bar id by use of an index. Can this be done? Is the use of the SecondaryKey in the embedded class at all correct? If this is not the way to go, can it be done any other way (except from using three entities)?
    @Entity
    class Bar {
        @PrimaryKey
        private int id;
    @Persistent
    class FooBarAssocication {
        @SecondaryKey(relatedEntity=Bar.class, relate=Relationship.ONE_TO_ONE)
        private int barId;
    @Entity
    class Foo {
        @PrimaryKey
        private int id;
        private Set<FooBarAssocication> fooBarAssociations = new HashSet<FooBarAssocication>();
    }Any help much appreciated.
    /Martin Söderström

    Martin,
    So could this be done with the embedded persistent class like this, or should I give up and make the FooBarAssociation class an entity of its own?A separate relationship entity class will definitely work, as described in the SecondaryIndex javadoc.
    But SecondaryKey fields have to be at the top level of an entity class, so an embedded class that contains the secondary key (and other attributes) won't work.
    Logically, you have a one-to-many relationship from Foo-to-Bar, and the relationship has attributes.
    If you store the relationship in the Bar entity, then it's pretty easy because there is one Bar instance per relationship and other attributes can easily be stored there. I know you said you want to put it in the Foo class because it logically belongs there, but I'll show this alternative anyway for completeness:
    @Entity
    class Bar {
        @PrimaryKey
        private int id;
        @SecondaryKey(relatedEntity=Foo.class, relate=Relationship.MANY_TO_ONE)
        private int fooId;
        private Date createTime;
    @Entity
    class Foo {
        @PrimaryKey
        private int id;
    }If it's really important to put the relationship fields into the Foo class, then you can do something like the following. It's messy to attach relationship attributes, but it can be done with either a parallel list or map.
    Also, be sure to read the "Key Placement with Many-to-Many for Related Entities" section of the SecondaryIndex javadoc page.
    @Entity
    class Bar {
        @PrimaryKey
        private int id;
    @Entity
    class Foo {
        @PrimaryKey
        private int id;
        // Use one of the following, either this:
        @SecondaryKey(relatedEntity=Bar.class, relate=Relationship.ONE_TO_MANY)
        private List<Integer> barIds = new ArrayList<Integer>;
        private List<Date> barCreateTimes = new ArrayList<Date>;
        // Or this:
        @SecondaryKey(relatedEntity=Bar.class, relate=Relationship.ONE_TO_MANY)
        private Set<Integer> barIds = new HashSet<Integer>;
        private Map<Integer, Date> barCreateTimes = new HashMap<Integer, Date>;
    From reading the documentation I also get the feeling that I could use the Base API and set up a SecondaryDatabase to create a secondary index for a case like this (correct?).Yes, you could do that, but I would hate to see you move to the base API just for this issue. The DPL is much easier to use (and easier for us to support).
    Anyway, so far the BDBJE looks very promising to us. It may replace our current Hibernate solution.Great. We'd love to hear more about what you're doing, why JE works well for you, etc, either on the forum or privately if you prefer (mark.hayes at o.com). It helps us a lot to know what people are doing with JE.
    --mark                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Need help in using sleep function in pl/sql

    Hi,
    need help:
    I have a condition where i want to validate total_pass=total_fail and
    I want to use the sleep function in a pl/sql where i want to wait for 2 minutes ie.checking
    whether total_pass=total_fail based upon class_id .
    I have the data in the table as:
    CLASS_ID TOT_PASS TOT_FAIL
    1 10 10
    2 5 4
    3 6 6
    4 7 5
    Any help will be needful for me

    I'm not quite sure what you are lookg for here, but whatever it is, your code as posted won't do it. You will never break out of the WHILE r_Class.Tot_Pass = r_Class.Tot_Fail loop, since these values will never change because you never get the next record form the cursor.
    From your original data, it looks like your cursor will return multiple rows which implies to me that you want to fetch the first row from the cursor, check if tot_pass = tot_fail, if they are equal, sleep for two minutes then get the next row. This does not make sense to me. Once the select in the cursor is executed, the data it returns will not change due to Oracle's read consistency model, so there seems to me no point in the sleep.
    The other alternative I can see is that you want to check all the returned rows, and if tot_pass = tot_fail for one of the rows (or possibly for all of the rows), then you want to sleep and try again.
    If you can explain in words what it is you are trying to accomplish, someone will be able to point you to a solution.
    John

  • Need help to use 'When' clause in CTL file

    Hi,
    I have a requirement
    in ctl file while loading file names in to a table we need to ignore if the filename already exist in the table
    eg:
    load infile.txt
    into a
    when filename not in (select filename from a) append
    filename varchar(1000)
    is it possible?? any way to achieve this?? Pleas help..
    Thanks in advance..

    user3647602 wrote:
    Hi,
    I have a requirement
    in ctl file while loading file names in to a table we need to ignore if the filename already exist in the table
    eg:
    load infile.txt
    into a
    when filename not in (select filename from a) append
    filename varchar(1000)
    is it possible?? any way to achieve this?? Pleas help..
    Thanks in advance..Easiest method i can think of would be to use an EXTERNAL TABLE instead of SQL LOADER.
    Much more flexible.
    Cheers,

  • New User,need help, charging, using, everythi

    I recently bought a Zen V Plus and have no tech savy so need help. I've checked with support but don't get th answers I need so thought someone here could help. Here are my questions.
    1. Is there anything else that can be used as a charger besides a Zen product. I have several cell phone chargers both for house and can, can any of these be used? need to save money
    2. Can the Zen be used while charging? All I get is the docked message and nothing else?
    3. I use my player mainly for audio books and the battery doesn't hold for a whole book so I have to charge but when I do the book goes? back to the first part instead of holding my place. I do I hold my place?
    Anybody that can give me simple clear answers please help. Because of my age I have trouble reading and the player allows me to enjoy books but I have trouble understanding how to make it work. Don't laugh but my 3 year old grandson would probably have better luck with getting it to work.
    Thanks for any help provided

    Li'vewolf,
    First, no three year old will do better than you can with the player. That said, spend some time reading the tutorials listed under support at the top of this page, and use the search in this forum to find everything you can about the Zen V Plus.
    When I shut down my Zen V plus, while reading my current audiobook, I just hit the pause button and then pull down the slide button on the left for "shutting down". Some of my books seem to do better with just a shut down instead of pause first. I have found that the bookmark feature is more trouble than it is worth. I use audiobooks from NetLibrary and Overdri've and a few extra from a forum on audiobooks. It seems that they all work differently when shutting down and holding a place.
    Anyway, spend some time trying different methods of bookmarking. The Zen V Plus is fairly forgiving player.
    Best Wishes.
    luvmyrescuedogs
    One more thought for recharging your battery. Try Amazon or eBay for a recharger, if you can't afford the Creative charger, but remember that you can fry the player if you use the wrong one and the warranty doesn't cover that damage. The easiest and cheapest way to recharge is to use the computer.

  • I need help in using iphoto?

    i have the appleipdmini but need help with iphoto, also how to move the cursor forward to delete error

    There is some help for the iPhoto app on this page : http://help.apple.com/iphoto/ipad/2.0/
    In terms of moving the cursor, you can use your find on the screen to reposition the insertion point - press and hold on the screen and after a second or so you should get a amgnifying symbol allowing you to position the insertion point. You can then delete backwards (there isn't a forward delete).

  • Need help for use crm fields into EJB2

    hello i need help.
    i have one db table (table_1):
    id_1
    field_1
    nad the second table that depends from the tale 1:
    id_2
    fields
    id_1
    id_1 is the field that join the table 2 with the table 1.
    can anybody helps me to implemet this relationship into the xml files and into the java class?
    into the java class for the second table i have:
    public abstract long getId_1();
    public abstract void setId_1(long Id_1);
    public abstract long getId_2();
    public abstract void setId_2(long Id_2);
    public abstract String getField();
    public abstract void setField(String field);
    how must i reference the relation into the bean and into the confdiguration xml files (i use Weblogic 8 and EJB 2.1)
    Thanks

    SRM doesn't use kind of "cockpit" LO-like in ECC.
    Overall picture:
    http://help.sap.com/saphelp_srm40/helpdata/en/b3/cb7b401c976d1de10000000a1550b0/content.htm
    If you setup data flows accordign Business Content of SRM:
    http://help.sap.com/saphelp_nw2004s/helpdata/en/3a/7aeb3cad744026e10000000a11405a/frameset.htm
    Then just perform an init load and schedule the deltas.

Maybe you are looking for

  • Audio out pavillion 25bw

    I operate a Dell Inspiron laptop. I use the audio port to an external sound system. Yesterday I purchased a Pavillion 25BW monitor. My only connection choice is HDMI. When I connect the HDMI I loose all audio either from internal or external speakers

  • Post Handling Unit Physical Inventory Document

    Hi Experts, Is there a BAPI or a FM to post/clear the physical inventory document created for a handling unit? The manual transaction used in this is 'HUINV05'. If there is no BAPI or FM, kindly help in finding a way how to capture in recording the c

  • Update requests on Adobe Reader for Mac

    I have a Mac using Adobe Reader 10.1.3. I have an older version 9. something. I continue to get a message to update the older version of Adobe Reader. When I try to do so, it gives me an error. Is there any reason I would need both versions or is 10.

  • Excise tab not coming at MIGO

    hi all pleasde tell me why excise tab is not coming at the time of MIGO trasaction what are the probable reasons regards, sujit

  • Scenarios activation of Baseline Package (FR)

    Hi, When I want to activate the scenarios from Solution view, this error message is generated: "Transport numbers not fullfill the requirement.". Someone can help me? Thanks in advance Best regards