Doubt in makePersistentAll(Collection pcs) method

When a collection is given to a Persistence Manager to persistent, what
is the order in which the objects from this collection are picked up for
persistence. I have 2 objects to be persisted - A warehouse and a district
objects. There is a 1-M relationship between Warehouse and District. The
warehouse shld be added first and then the district as the district
account has a reference to the warehouse. When i add both the objects to
the collection, it always gives me a error sayin no warehouse record
found. Ive tried with both keepin the warehouse as the first or the last
record in the collection.
Can this problem be occuring becuz the warehouse record has not been
committed to the database yet. I cannot make makePersistent() call for
each objects as i have hundreds of objects to be persisteted.
Please advise.
Amol.

[email protected] (Amol) writes:
When a collection is given to a Persistence Manager to persistent, what
is the order in which the objects from this collection are picked up for
persistence. I have 2 objects to be persisted - A warehouse and a district
objects. There is a 1-M relationship between Warehouse and District. The
warehouse shld be added first and then the district as the district
account has a reference to the warehouse. When i add both the objects to
the collection, it always gives me a error sayin no warehouse record
found. Ive tried with both keepin the warehouse as the first or the last
record in the collection.Amol,
Could you please post the exception that you are seeing? Also, what
version of Kodo JDO are you using?
As of version 2.2.3, the behavior is as follows: makePersistentAll()
obtains an iterator from the collection passed into the method call, and
loops over that collection in order invoking makePersistent() on each.
The objects are queued for flushing to the data store in the order in
which they were first added to the current transaction. During commit,
PersistenceCapable objects reachable from the objects in the list of
objects made persistent will be made persistent themselves if they are
not already persistent.
Note that we may change this behavior slightly once the final
specification is released, if doing so will facilitate our compliance
with the final spec. In particular, our 1.0-compliant version may add a
reachable object to the transaction when its owning object is made
persistent. This would preserve the ordering as defined in the list
passed to makePersistentAll(), with two exceptions:
     - an object that appears late in the list but is reachable from
     an object early in the list may end up being persisted just
     after the object from which it is reachable, rather than in its
     position in the list (current behavior).
     - an object that is not in the list passed to makePersistentAll()
     but is reachable from an object in the list may be persistent just
     after the object from which it is reachable, rather than at the
     end of the list (current behavior).
Finally, what is the underlying implementation of the collection that
you are passing to makePersistentAll()? If the collection implementation
that you are using is not ordered, then all bets are off.
-Patrick
Patrick Linskey [email protected]
SolarMetric Inc. http://www.solarmetric.com

Similar Messages

  • Doubt about Bulk Collect with LIMIT

    Hi
    I have a Doubt about Bulk collect , When is done Commit
    I Get a example in PSOUG
    http://psoug.org/reference/array_processing.html
    CREATE TABLE servers2 AS
    SELECT *
    FROM servers
    WHERE 1=2;
    DECLARE
    CURSOR s_cur IS
    SELECT *
    FROM servers;
    TYPE fetch_array IS TABLE OF s_cur%ROWTYPE;
    s_array fetch_array;
    BEGIN
      OPEN s_cur;
      LOOP
        FETCH s_cur BULK COLLECT INTO s_array LIMIT 1000;
        FORALL i IN 1..s_array.COUNT
        INSERT INTO servers2 VALUES s_array(i);
        EXIT WHEN s_cur%NOTFOUND;
      END LOOP;
      CLOSE s_cur;
      COMMIT;
    END;If my table Servers have 3 000 000 records , when is done commit ? when insert all records ?
    could crash redo log ?
    using 9.2.08

    muttleychess wrote:
    If my table Servers have 3 000 000 records , when is done commit ? Commit point has nothing to do with how many rows you process. It is purely business driven. Your code implements some business transaction, right? So if you commit before whole trancaction (from business standpoint) is complete other sessions will already see changes that are (from business standpoint) incomplete. Also, what if rest of trancaction (from business standpoint) fails?
    SY.

  • Doubt Regarding Statistics Collection in 10g

    Hello,
    Me Jr Dba i have a doubt regarding statistics calculation in 10g.As we know that if we set
    the initilization parameter STATISTICS_LEVEL=Typical then AOS(Automatic Optimizer staistics) calculate the statistics for the tables, whose blocks are greater then 10% changed from the last calculation.Here my doubt is since already statistics are gathered,
    is there any necessity for us to gather the statistics manually by using
    DBMS_STATS.GATHER to see the tables or system statistics.
    Can u plz assist me on the above
    Regards,
    Vamsi

    Hi,
    Please see here,
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14211/stats.htm#i41448
    If the table/s are changing very frequently than its better to gather the stats manually.This would lead teh volatile table coming up into the stats job again and again.
    For the system stats and data dictionary stats,they are not collected by default.So there is no choice but to gather them manually.
    Aman....

  • Compiler warning with Collections.sort() method

    Hi,
    I am sorting a Vector that contains CardTiles objects. CardTiles is a class that extends JButton and implements Comparable. The code works fine but i get the following warning after compilation.
    Note: DeckOfCards.java uses unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    After compiling with -Xlint, i get the following warning;
    DeckOfCards.java:173: warning: [unchecked] unchecked method invocation: <T>sort(java.util.List<T>) in java.util.Collections is applied to (java.util.Vector<CardTiles>)
    Collections.sort(handTwo);
    ^
    What could be the problem? Is Collections.sort() only intended for Collections of type List?
    Many thanks!

    Hi Jverd, my handTwo Vector was declared as follows;
    Vector<CardTiles> handTwo = new Vector<CardTiles>();
    The CardTiles Source code is as follows;
    import javax.swing.*;
    import java.util.*;
    public class CardTiles extends JButton implements Comparable{
         static String typeOfSort = "face";
         public static final long serialVersionUID = 24362462L;
         int i=1;
         public ImageIcon myIcon;
         public Card myCard;
         public CardTiles(ImageIcon i, Card c){
              super(i);
              myIcon = i;
              myCard = c;
         public int compareTo(Object o){
              CardTiles compare = (CardTiles)o;
              if(typeOfSort.equals("face")){
                   Integer ref1 = new Integer(this.myCard.getFaceValue());
                   Integer ref2 = new Integer(compare.myCard.getFaceValue());
                   return ref1.compareTo(ref2);
              }else{
                   if(this.myCard.getFaceValue() > 9 || compare.myCard.getFaceValue() >9){
                        if(this.myCard.getFaceValue() > 9 && compare.myCard.getFaceValue() >9){
                             String ref1 = this.myCard.getSuit().substring(0,(this.myCard.getSuit().length()-1));
                             String ref2 = compare.myCard.getSuit().substring(0,(compare.myCard.getSuit().length()-1));
                             return ref1.compareTo(ref2);
                        }else{
                             if(this.myCard.getFaceValue() > 9 || compare.myCard.getFaceValue() >9){
                                  String ref1 = this.myCard.getSuit().substring(0,(this.myCard.getSuit().length()-1));
                                  String ref2 = compare.myCard.getSuit() + Integer.toString(compare.myCard.getFaceValue());
                                  return ref1.compareTo(ref2);
                             }else{
                                  String ref1 = this.myCard.getSuit() + Integer.toString(this.myCard.getFaceValue());
                                  String ref2 = compare.myCard.getSuit().substring(0,(compare.myCard.getSuit().length()-1));
                                  return ref1.compareTo(ref2);
                   }else{
                        String ref1 = this.myCard.getSuit() + Integer.toString(this.myCard.getFaceValue());
                        String ref2 = compare.myCard.getSuit() + Integer.toString(compare.myCard.getFaceValue());
                        return ref1.compareTo(ref2);
         public String toString(){
              return ( myCard.toString() + " with fileName " + myIcon.toString());
    }What could be wrong?
    Many thanks!

  • Problem with Collection API method LIMIT?

    Hi,
    I am trying to learn PL/SQL in my free time and I can't get collection_name.LIMIT to work correctly.
    declare
    type list is table of integer;
    set_a list := list(1,2,3,3);
    i pls_integer := 0;
    begin
    set_a.trim(2);
    i := set_a.limit;
    dbms_output.put_line('Trim(2) leaves ' || to_char(i) || ' spaces in list');
    end;
    The above code prints 'Trim(2) leaves spaces in list'. I first tried putting set_a.limit inside the to_char and got the same results. I tried using it in the expression for an IF statement as I have read in the book and online; something like if set_a.limit < 4 then... This returns true, while set_a.limit > 1 returns false.
    Am I doing something wrong?
    Oh, and I am using the win32_11gR2_database I got from the Oracle download page on Windows XP SP3.
    Thanks.
    Edited by: user13107973 on Aug 24, 2010 3:08 PM

    I figured it out, on closer inspection I see it is only used for varying arrays, and I was trying it on a nested table... Thanks for the advice.
    So, I am reading a horrible book full of typos called "Oracle Database 11g PL/SQL Programming" from the Oracle Press and McGraw Hill.
    BULK COLLECT INTO, page 123
    "The LIMIT statement lets you constrain the size of bulk selections, but you can only use it with explicit cursors." - NOT what I asked about.
    FORALL, page 127
    "The FORALL loop is designed to work with Oracle collections. It lets you insert, update, or delete bulk data." - NOT what I asked about.
    Collection API, page 253
    "The LIMIT method returns the highest possible subscript value in a collection. It can only return a PLS_INTEGER type and can only be used by a VARRAY datatype. It has the following prototype..."
    Edited by: user13107973 on Aug 25, 2010 12:09 PM
    Edited by: user13107973 on Aug 25, 2010 12:09 PM

  • Doubt on bulk collect

    Hi All,
    I have the below query for doing bulk update for a particular region. I am doing an update of description id for a particular region id. can you please let me know if the below query is fine ?
    Also, i want to make this as a generalized script for all region id's. Say for example for rgn_id 7 i am updating dscr_id as 166. i would like to pass the rgn_id in cursor select as a parameter to the update statement. for each rgn_id i may be updating a different dscr_id. can i selectively update in the update statement ? can i pull the complete data in cursor and then update based on conditions ? how to do this selective/condition based update ?
    Pls advise..
    DECLARE
    CURSOR s_cur IS
        SELECT /*+ ORDERED USE_NL(c,cv,cvd) */ cvd.chr_val_dscr_id
        FROM chr_t c
        INNER JOIN chr_val_t cv
        ON c.chr_id = cv.chr_id
        INNER JOIN chr_val_dscr_t cvd
        ON cvd.chr_val_id = cv.chr_val_id
        AND cvd.lang_id = 6
        AND cvd.dscr_id = 31
        WHERE c.rgn_id = 7
        AND cv.crtd_by = 'PNB_EIMDB_LOAD'
        AND cv.upd_by = 'PNB_EIMDB_LOAD'
    TYPE fetch_array IS TABLE OF chr_val_dscr_t.chr_val_dscr_id%TYPE;
    s_array fetch_array;
    BEGIN
      OPEN s_cur;
      LOOP
        FETCH s_cur BULK COLLECT INTO s_array LIMIT 2;
        FORALL i IN s_array.FIRST .. s_array.LAST
        UPDATE chr_val_dscr_t
        SET    dscr_id = 166
        WHERE  chr_val_dscr_id = s_array(i);
        COMMIT; 
        EXIT WHEN s_cur%NOTFOUND;
      END LOOP;
      CLOSE s_cur;
    END;

    Hi Herald,
    Thanks for your reply! Database version is 10G. The table is having huge records(110 million) and hence we are resorting to this BULK update method.
    I have tweaked my earlier code as below. i am doing a full select of the table in the cursor and i am doing conditional if update in the execution block. can you please verify if its right and suggest any correction ?
    DECLARE
    CURSOR s_cur IS
        SELECT /*+ ORDERED USE_NL(c,cv,cvd) */ *
        FROM chr_t c
        INNER JOIN chr_val_t cv
        ON c.chr_id = cv.chr_id
        INNER JOIN chr_val_dscr_t cvd
        ON cvd.chr_val_id = cv.chr_val_id
        AND cvd.lang_id = 6
        AND cvd.dscr_id = 31
        AND cv.crtd_by = 'PNB_EIMDB_LOAD'
        AND cv.upd_by = 'PNB_EIMDB_LOAD'
    TYPE fetch_array IS TABLE OF chr_val_dscr_t.chr_val_dscr_id%TYPE;
    s_array fetch_array;
    BEGIN
      OPEN s_cur;
      LOOP
        FETCH s_cur BULK COLLECT INTO s_array LIMIT 2;
        FORALL i IN s_array.FIRST .. s_array.LAST
        IF s_array.rgn_id = 9 THEN
        UPDATE chr_val_dscr_t
        SET    dscr_id = 166
        WHERE  chr_val_dscr_id = s_array(i);
        ELSIF s_array.rgn_id = 8 THEN
        UPDATE chr_val_dscr_t
        SET    dscr_id = 160
        WHERE  chr_val_dscr_id = s_array(i);
        COMMIT;
        END IF;
        EXIT WHEN s_cur%NOTFOUND;
      END LOOP;
      CLOSE s_cur;
    END;

  • An April fool subject - fooling around the collections add method

    Here is a situation of an application business logic:
    A user can only add one feedback to a comment. I try to define how a feedback can be added into a comment by redefining the equal and hashCode methods.
    public class Feedback implements Serializable {
         public enum VALUE {
              NEGATIVE, POSITIVE
         protected Integer id;
         private Comment comment; // refer to a comment
         private User user;     // who gives this feedback
         private VALUE value;
         @Override
         public int hashCode() {
              final int prime = 31;
              int result = 1;
              result = prime * result + ((comment.id == null) ? 0 : comment.id.hashCode());
              result = prime * result + ((user == null) ? 0 : user.hashCode());
              return result;
          * (non-Javadoc)
          * @see java.lang.Object#equals(java.lang.Object)
         @Override
         public boolean equals(Object obj) {
              if (this == obj)
                   return true;
              if (obj == null)
                   return false;
              if (getClass() != obj.getClass())
                   return false;
              CommentFeedback other = (CommentFeedback) obj;
              if (comment.id == null) {
                   if (other.comment.id != null)
                        return false;
              } else if (!comment.id.equals(other.comment.id))
                   return false;
              if (user == null) {
                   if (other.user != null)
                        return false;
              } else if (!user.equals(other.user))
                   return false;
              return true;
          public class Comment {
             private Set<CommentFeedback> feedbacks;
               private transient short totalFeedbacks;
             private transient short positiveNumber;
             private transient short negativeNumber;
         public boolean addFeedback(CommentFeedback fb){
              boolean added = this.getFeedbacks().add(fb);
              if(added){
                   this.totalFeedbacks++;
                   if(fb.getValue() == CommentFeedback.VALUE.POSITIVE)
                        this.positiveNumber++;
                   else
                        this.negativeNumber++;               
              return added;
         }I don't get the expected behavior. A feedback with the same comment and user of an existing one in the feedback collection of the comment classs can be added into the collection. Anything is missing here?

    BigDaddyLoveHandles wrote:
    For starters, you can clean up equals with a helper method:
    public boolean equals(Object obj) {
    if (this == obj)
    return true;
    if (obj == null)
    return false;
    if (getClass() != obj.getClass())
    return false;
    Feedback other = (Feedback) obj;
    return
    equals(id, other.id) &&
    equals(comment, other.comment) &&
    equals(user, other.user) &&
    equals(value, other.value);
    public static boolean equals(Object a, Object b) {
    return a==null ? b==null : a.equals(b);
    What is wrong the equal method, then?
    Second, should equality depend on id?
    Third, your equality depends on comment's id, not on comment's equality.
    Fourth, you don't consider field value.Why not? The comment entity id is unique. Any other fields don't need to be considered for the reason I mentioned in the question (the first poster).
    [Recommend and review web sites|http://homepage.kgbinternet.com] - a fresh approach of building an open source, useful, and dynamic web site directory
    Edited by: vwuvancouver on Apr 17, 2009 9:01 AM

  • Doubt in bdc program session method

    hi,
    I tried to execute this program..i am getting error in the bolded line..can you give suggestions..
    REPORT  ZPRABA1.
    TABLES:LFA1.
    DATA:BEGIN OF IT_ITAB OCCURS 0,
         LIFNR LIKE LFA1-LIFNR,
         LAND1 LIKE LFA1-LAND1,
         NAME1 LIKE LFA1-NAME1,
         END OF IT_ITAB.
    DATA:BEGIN OF IT_JTAB OCCURS 0,
    <b>* Error is showing in the below line..that means i have to create new structure or
    what?</b>
         <b>INCLUDE STRUCTURE BDCDATA.</b>
         END OF IT_JTAB.
    CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD
         FILENAME = 'C:/praba.txt'
         FILETYPE = 'ASC'
         HAS_FIELD_SEPARATOR = 'X'
         CHANGING
           DATA_TAB = IT_ITAB[].
         CALL FUNCTION 'BDC_OPEN_GROUP'
         EXPORTING
           CLIENT = SY-MANDT
           GROUP = 'USER01'
           USER = SY-UNAME.
    LOOP AT IT_ITAB[] INTO IT_ITAB.
       REFRESH IT_JTAB.
           PERFORM SUB USING 'YVTRANS' '0100'.
           PERFORM SUB1 USING 'LFA1-LIFNR' ITAB-LIFNR,
           PERFORM SUB1 USING 'LFA1-LAND1' ITAB-LAND1,
           PERFORM SUB1 USING 'LFA1-NAME1' ITAB-NAME.
           PERFORM SUB1 USING 'BDC_OKCODE' 'INSERT'.
           PERFORM SUB USING 'YSBDC1' '100'.
           PERFORM SUB1 USING 'BDC_OKCODE' 'EXIT'.
           CALL FUNCTION 'BDC_INSERT'
           EXPORTING
             TCODE = 'YSBDC1'
             TABLES
               DYNPROTAB = IT_JTAB.
           ENDLOOP.
           CALL FUNCTION 'BDC_CLOSE_GROUP'.
           SUBMIT RSBDCSUB VIA SELECTION-SCREEN.
           FORM SUB USING A B.
           CLEAR IT_JTAB.
           IT_JTAB-PROGRAM = A.
           IT_JTAB-DYNPRO = B.
           IT_JTAB-DYNBEGIN = 'X'.
           ENDFORM.

    hi Praba,
    DATA:BEGIN OF IT_JTAB OCCURS 0,
    Error is showing in the below line..that means i have to create new structure or
    what?
    INCLUDE STRUCTURE BDCDATA.
    END OF IT_JTAB.
    change your code as below:
    <b>data: IT_JTAB type table of BDCDATA with header line.</b>
    hope this helps,
    Sajan Joseph.

  • Doubt in BDC direct input method

    Hi experts
    I dont know how to upload data in SAP data base by using BDC direct input coding method. Can u people explain this with coding?
    Thanks in advance.
    Regards
    Antony

    Hi,
    DI is used when u r going upload large amount of data for single application.
    Better example where direct input method will be used is... uploading the data for material master.....it includes lot of views so its very much difficult to capture all the views and record the tcode and map the data in such conditions its better to go with DI methods
    advantages:
    in session method or CT method while uploading the data u do the validation by fallowing the screen sequence and field sequence where as in DI validations can be done set of code so this make the process very fast so its advantageous to upload large amout of data.
    you always use the standard sap provided program for this.
    Here in DI method very important thing is structure of flat file... so to know the structure first of all you have to download the data for one record into the internal table with the use of the same program then with the use of that structure u have to desing the flat file and upload the data.
    Re: re: direct input method
    Award points if useful.
    Thanks,
    Ravee...

  • How good is the Collections.shuffle() method?

    Hello
    I have an ArrayList which I want to bootstrap from. I did not find any method to randomly select an entry from the ArrayList, so I use the shuffle method first, and then get the first entry (which should be random after each shuffle). However, I do get some strange results from this. On average the numbers gotten when I sample small series is lower then the ones I get sampling longer series. There is no aspect with the data that should imply such behavoiur. Does anyone know how good my way of sampling is (using shuffle), and if the shuffle method really is a good way to randomize?
    Regards
    JT

    I think the API docs probably give the best answer to this question. Notice the word "approximately" In the shuffle(List) method. Also note that shuffle.(List, Random) depends on how "good" Random is.
    I guess you'd have to construct some form of test to see if either shuffle was good enough for your requirements.
    Cheers
    DB

  • Java Collection addAll method parameters too restrictive

    Can anyone tell me why Java Sun does not allowed to add elements to Collection using addAll(List<?>) instead of addAll(List<? extends E>)?

    TNT wrote:
    It meant to prove that Yes, we can and we should allow addAll(List<?> c) instead of addAll(List<? extends E>) because the reasons I tries to explain here.No, we should not. It is correct as it is, for the reasons I stated. List<?> and List<Object> are effectively the same as far as this issue goes, and both +break compile-time type-safety* as I already demonstrated.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Simple doubt in BDC  Call Transaction Method

    Hi Friends,
      When i try to call vk13 transaction and pass the screen field values for the second screen and execute it it is displaying properly.But when i try to pass the different value in the bcddata internal table it is changing properly but in the screen it not updating that value.Alawly the screen fields are taking the values passed the first time.But in the internal table which we are oassing to the calltransaction it is changing correctly but not in the corresponding screen fields. Why it is happening so. Can any one help me out of this problem.
    Thanks in Advance.

    I am not passing through the selection screen . It is like iteractive report. when i select the particular line in the list output then the screen fields should take the values from that selected line. First time when i select the line it is taking properly.
    But next time when i select the line the content of the i_bdc_tbl is changing correctly but when it enter in to the transaction it is not taking the values from the i_bdc_tbl. Simply it is displaying the screen fields with the old values. It is not updating the screen fields with the values from the i_bdc_tbl. Why the screen fields are not replaced with the value of i_bdc_tbl? Why it is not getting refreshed with the new values?
    Just i am posting the bdc portion of my code here. So you can help me out on this.
    AT LINE-SELECTION.
      SELECT SINGLE kozgf FROM t685 INTO v_kozgf
                          WHERE kschl = wa_report-kschl.
      SELECT kolnr kotabnr FROM t682i INTO TABLE i_t682i
                     WHERE kozgf = v_kozgf.
      SORT i_t682i BY kolnr.
      READ TABLE i_t682i WITH KEY kotabnr = wa_report-tabna+1(3)
           TRANSPORTING NO FIELDS.
      CHECK sy-subrc = 0.
      v_index = sy-tabix.
      REFRESH i_bdc_tbl.
      l_tabix = '01'.
      PERFORM f_vk13.
      CONCATENATE 'RV13' wa_report-tabna  INTO v_bdc_val_field.
      PERFORM bdc_dynpro      USING v_bdc_val_field '1000'.
      PERFORM bdc_field       USING 'BDC_CURSOR'
                                    'F004-LOW'.
      PERFORM bdc_field       USING 'BDC_OKCODE'
                                    '=ONLI'.
      CREATE DATA v_rec  TYPE (wa_report-tabna).
      ASSIGN v_rec->* TO <wa_table>.
      SELECT SINGLE *  FROM (wa_report-tabna) INTO <wa_table>
      WHERE kschl = wa_report-kschl AND matnr = wa_report-matnr AND knumh = wa_report-objectid.
      CALL FUNCTION 'DDIF_FIELDINFO_GET'
        EXPORTING
          tabname        = wa_report-tabna
        TABLES
          dfies_tab      = lwa_tabna
        EXCEPTIONS
          not_found      = 1
          internal_error = 2
          OTHERS         = 3.
      READ TABLE lwa_tabna WITH KEY fieldname = 'KSCHL'.
      p1 = sy-tabix + 1.
      READ TABLE lwa_tabna WITH KEY fieldname = 'MATNR'.
      p2 = sy-tabix.
      LOOP AT lwa_tabna.
        v_field = lwa_tabna-fieldname.
        IF lwa_tabna-position BETWEEN p1 AND p2.
          ASSIGN COMPONENT lwa_tabna-position OF STRUCTURE <wa_table> TO <fld>.
          PERFORM f_vk13_s2 USING lwa_tabna-fieldname <fld>.
        ENDIF.
      ENDLOOP.
      PERFORM bdc_field       USING 'RV130-DATAM'
                                       wa_report-fdate_value_new.
      PERFORM bdc_field       USING 'BDC_OKCODE'
                                    'ONLI'.
      PERFORM bdc_field       USING 'BDC_CURSOR'
                                    'F001'.
      CALL TRANSACTION 'VK13' USING i_bdc_tbl
                              MODE  'A'.
    FORM f_vk13.
      DATA: l_tabix(2) TYPE c.
    *Condition type
      PERFORM bdc_dynpro      USING 'SAPMV13A' '0100'.
      PERFORM bdc_field       USING 'BDC_CURSOR'
                                    'RV13A-KSCHL'.
      PERFORM bdc_field       USING 'BDC_OKCODE'
                                    '/00'.
      PERFORM bdc_field       USING 'RV13A-KSCHL'
                                     wa_report-kschl.
    *Key combination
      PERFORM bdc_dynpro      USING 'SAPLV14A' '0100'.
      PERFORM bdc_field       USING 'BDC_CURSOR'
                                    'RV130-SELKZ(01)'.
      PERFORM bdc_field       USING 'BDC_OKCODE'
                                    '=WEIT'.
      PERFORM bdc_field       USING 'RV130-SELKZ(01)'
      l_tabix = v_index.
      SHIFT l_tabix RIGHT.
      OVERLAY l_tabix WITH '00'.
      CONCATENATE 'RV130-SELKZ(' l_tabix ')' INTO v_bdc_field.
      PERFORM bdc_field       USING v_bdc_field
                                    'X'.
    ENDFORM.                                                    "f_vk13
          FORM BDC_DYNPRO
          This form accepts the program name and screen number
          and places the values into the I_BDC_TBL internal table.
    FORM bdc_dynpro USING program dynpro.
      CLEAR wa_bdc_tbl.
      wa_bdc_tbl-program  = program.
      wa_bdc_tbl-dynpro   = dynpro.
      wa_bdc_tbl-dynbegin = 'X'.
      APPEND wa_bdc_tbl TO i_bdc_tbl.
    ENDFORM.                    "BDC_DYNPRO
          FORM F_BDC_FIELD
        This form accepts the field name and the corresponding value
        for that field and places them into the I_BDC_TBL internal table.
    FORM bdc_field USING fnam fval.
      CLEAR wa_bdc_tbl.
      MOVE fnam TO wa_bdc_tbl-fnam.
      MOVE fval TO wa_bdc_tbl-fval.
      APPEND wa_bdc_tbl TO i_bdc_tbl.
    ENDFORM.                    "BDC_FIELD
    *&      Form  f_vk13_s2
          text
    -->  p1        text
    <--  p2        text
    FORM f_vk13_s2 USING p_fieldname p_fld.
      CONCATENATE wa_report-tabna '-' p_fieldname INTO v_bdc_val_field.
      CHECK NOT p_fld IS INITIAL.
      PERFORM bdc_field USING v_bdc_val_field p_fld.
    ENDFORM.                                                    " f_vk13_s2
    Thanks.

  • Collection toArray method problem

    everything ok
    assets = new Asset[alAsset.size()];
    alAsset.toArray(assets);
    null pointer exception
    assets = new Asset[alAsset.size()];
    assets = (Asset[])alAsset.toArray();
    why?
    Do any one explain this?

                Vector v = new Vector();
                String str1 = "abc";
                String str2 = "123";
                v.add(str1);
                v.add(str2);
                String strs[] = new String[v.size()];
                v.toArray(strs);                //It work
    //            strs = (String[])v.toArray(); //It doesn't work
                for(int i=0;i<strs.length;i++)
                    System.out.println((String)strs);
    Class case exception,sorry for the latest mistaken make you inconvenient

  • Static method and variables doubts

    i have a doubt
    i have the following method
    private static void checkActionType(String action) {
    if (action.startsWith(" a")) {
    ++totalAddedActions;
    } else if (action.startsWith(" c")) {
    ++totalChangedFolders;
    } else if (action.startsWith(" p")) {
    ++totalPersonalizedActions;
    } else if (action.startsWith(" r")) {
    ++totalRemovedActions;
    } else if (action.startsWith(" v")) {
    ++totalViewedActions;
    } else if (action.startsWith(" u")) {
    ++totalUpdateActions;
    to use it, i need to declare my int variables static, because im calling this method from another static method that is called by main method.
    but this can cause me problems ?
    if i have two instances of this class running, my statics int will show the right value?
    there is a better approach?

    Here is my class, i want some advices to know if i am doing right, because everything is a little new for me.
    My class, read a log file and based upon a regular expression, it can retrieve a general statistic or a personal statistic.
    package br.com.organox.aggregator;
    import java.io.BufferedReader;
    import java.io.FileReader;
    import java.io.IOException;
    import java.util.Vector;
    import org.apache.oro.text.regex.*;
    public class LogFileReader {
    private static Pattern regexpPattern;
    private static PatternMatcher patternMatcher;
    private static PatternCompiler patternCompiler;
    private static PatternMatcherInput patternInput;
    private static MatchResult matchResult;
    private static final String patternString = "^[^\']+User\\s+\'([^\']+)\'[^\']+session\\s+\'([^\']+)\'\\s+(\\S+)";
    // Integers used to store number of user, sessions and specific actions
    private static int totalUsers;
    private static int totalSessions;
    private static int totalAddedActions;
    private static int totalChangedFolders;
    private static int totalPersonalizedActions;
    private static int totalRemovedActions;
    private static int totalUpdateActions;
    private static int totalViewedActions;
    public static void main(String[] args) {
    if (args.length == 0) {
    System.out.println("No file name was specified");
    printClassUsage();
    } else if (args.length == 1) {
    printGeneralData(args[0]);
    } else if (args.length == 2) {
    System.out.println("You must set file name, data value and data type in order to " +
    "this class run properly");
    printClassUsage();
    } else {
    printSelectedData(args[0],args[1],args[2]);
    public static void printGeneralData(String fileName) {
    String data = "";
    //Users and the Session Vector are used to avoid count repeated values.
    Vector usersVector = new Vector();
    Vector sessionVector = new Vector();
    patternCompiler = new Perl5Compiler();
    patternMatcher = new Perl5Matcher();
    try {
    regexpPattern = patternCompiler.compile(patternString);
    } catch (MalformedPatternException mpe) {
    System.out.println("Error Compiling Pattern");
    System.out.println(mpe.getMessage());
    try {
    FileReader fileRead = new FileReader(fileName);
    BufferedReader buffRead = new BufferedReader(fileRead);
    while ((data = buffRead.readLine())!= null) {
    patternInput = new PatternMatcherInput(data);
    while(patternMatcher.contains(patternInput,regexpPattern)) {
    matchResult = patternMatcher.getMatch();
    // Avoid to insert repeated data in user and session Vectors
    if (usersVector.lastIndexOf(matchResult.group(1)) == -1) {
    usersVector.add(matchResult.group(1));
    if (sessionVector.lastIndexOf(matchResult.group(2)) == -1) {
    sessionVector.add(matchResult.group(2));
    increaseActionType(matchResult.group(3));
    for (int i=0;i<usersVector.size();i++) {
    totalUsers++;
    for (int i=0;i<sessionVector.size();i++) {
    totalSessions++;
    fileRead.close();
    buffRead.close();
    } catch (IOException ioe) {
    System.out.println("An I/O error occurred while getting log file data");
    ioe.printStackTrace();
    System.out.println("Users logged : " + totalUsers);
    System.out.println("Sessions opened : " + totalSessions);
    System.out.println("Added contents : " + totalAddedActions);
    System.out.println("Changed folders : " + totalChangedFolders);
    System.out.println("Personalized contents : " + totalPersonalizedActions);
    System.out.println("Removed contents : " + totalRemovedActions);
    System.out.println("Viewed Contents : " + totalViewedActions);
    System.out.println("Updated contents : " + totalUpdateActions);
    public static void printSelectedData(String fileName,String value,String valueType) {
    String data = "";
    String user = "";
    //Flag used to print the right result on screen
    String printFlag = "";
    Vector sessionVector = new Vector();
    Vector userVector = new Vector();
    Vector actionVector = new Vector();
    patternCompiler = new Perl5Compiler();
    patternMatcher = new Perl5Matcher();
    try {
    regexpPattern = patternCompiler.compile(patternString);
    } catch (MalformedPatternException mpe) {
    System.out.println("Error Compiling Pattern");
    System.out.println(mpe.getMessage());
    try {
    FileReader fileRead = new FileReader(fileName);
    BufferedReader buffRead = new BufferedReader(fileRead);
    while ((data = buffRead.readLine())!= null) {
    patternInput = new PatternMatcherInput(data);
    while(patternMatcher.contains(patternInput,regexpPattern)) {
    matchResult = patternMatcher.getMatch();
    if (valueType.equalsIgnoreCase("-user")) {
    printFlag = "userPrint";
    if ((matchResult.group(1).equalsIgnoreCase(value))) {
    userVector.add(matchResult.group(1));
    // avoid insert a repeated value inside session vector.
    if (sessionVector.lastIndexOf(matchResult.group(2)) == -1) {
    sessionVector.add(matchResult.group(2));
    increaseActionType(matchResult.group(3));
    if (userVector.size() == 0) {
    printFlag = "userPrintError";
    } else if (valueType.equalsIgnoreCase("-session")) {
    printFlag = "sessionPrint";
    if ((matchResult.group(2).equalsIgnoreCase(value))) {
    user = matchResult.group(1);
    sessionVector.add(matchResult.group(2));
    increaseActionType(matchResult.group(3));
    if (sessionVector.size() == 0) {
    printFlag = "sessionPrintError";
    } else if (valueType.equalsIgnoreCase("-action")) {
    printFlag = "actionPrint";
    if ((matchResult.group(3).equalsIgnoreCase(value))) {
    if (userVector.lastIndexOf(matchResult.group(1)) == -1) {
    userVector.add(matchResult.group(1));
    actionVector.add(matchResult.group(3));
    if (actionVector.size() == 0) {
    printFlag = "actionPrintError";
    fileRead.close();
    buffRead.close();
    } catch (IOException ioe) {
    System.out.println("An I/O error occurred while getting log file data");
    ioe.printStackTrace();
    if (printFlag.equals("userPrint")) {
    for (int i=0;i<sessionVector.size();i++) {
    totalSessions++;
    System.out.println("Sessions opened by user " + value + " : " + totalSessions);
    System.out.println("Added contents by user " + value + " : " + totalAddedActions);
    System.out.println("Changed folders by user " + value + " : " + totalChangedFolders);
    System.out.println("Personalized contents by user " + value + " : " + totalPersonalizedActions);
    System.out.println("Removed contents by user " + value + " : " + totalRemovedActions);
    System.out.println("Viewed contents by user " + value + " : " + totalViewedActions);
    System.out.println("Updated contents by user " + value + " : " + totalUpdateActions);
    } else if (printFlag.equals("userPrintError")) {
    System.out.println("This user " + value + " was not found on log file");
    } else if (printFlag.equals("sessionPrint")){
    System.out.println("Session " + value + " was opened by user " + user);
    System.out.println("Added contents by session " + value + " : " + totalAddedActions);
    System.out.println("Changed folders by session " + value + " : " + totalChangedFolders);
    System.out.println("Personalized contents by session " + value + " : " + totalPersonalizedActions);
    System.out.println("Removed contents by session " + value + " : " + totalRemovedActions);
    System.out.println("Viewed Contents by session " + value + " : " + totalViewedActions);
    System.out.println("Updated contents by session " + value + " : " + totalUpdateActions);
    } else if (printFlag.equals("sessionPrintError")){
    System.out.println("This session " + value + " was not found on log file");
    } else if (printFlag.equals("actionPrint")){
    System.out.println("Action " + value + " was performed " + actionVector.size() +
    " times for " + userVector.size() + " different user(s)");
    } else if (printFlag.equals("actionPrintError")){
    System.out.println("This action " + value + " was not found on log file");
    } else {
    System.out.println("Wrong search type!");
    System.out.println("Accepted types are: ");
    System.out.println("-user -> Search for a specified user");
    System.out.println("-session -> Search for a specified session");
    System.out.println("-action -> Search for a specified action");
    private static void increaseActionType(String action) {
    if (action.startsWith("a")) {
    ++totalAddedActions;
    } else if (action.startsWith("c")) {
    ++totalChangedFolders;
    } else if (action.startsWith("p")) {
    ++totalPersonalizedActions;
    } else if (action.startsWith("r")) {
    ++totalRemovedActions;
    } else if (action.startsWith("v")) {
    ++totalViewedActions;
    } else if (action.startsWith("u")) {
    ++totalUpdateActions;
    }

  • Doubt in a custom method in a custom BO

    Hi All,
               I have a doubt in one of the methods I am writing in a custom BO.In the meethod I have written certain select statements and after fetching some data and calculation I am also updating some custom tables too.
    No what I am confused about is whether this method will work as i am basically writing ABAP in it. Also i have 3 export parameters but am not sure what will be their use as I am just updating saome tables in the method. So what exactly is the o/p? At the time of declaration i declared them with a view that I might use the output of the method but am not sure now?
    Please guide me on my approach.
    Thanks in advance,
    Saket.

    Hi Saket,
       1) a method works like normal Funciton module with import & export parameters.
       2) Tasks will be created using theses methods which in turn will be used in the workflow as one of the step.
       3) The import parameters are passed from WF container to Task container and then to method container.
       4) Then the method will do whatever it is intended to do like wht u hav specified to update som tables. If required u can export some values from the method which again will follow the path to Task -> WF container.
       5) The values can be used as input for the next or other steps in the WF.
    So it is not necessary that u should always export some values from the method. If u feel that the export parameters are not needed u can delete themand adjust the code accordingly.
    Regards,
    Sivagami

Maybe you are looking for