Looping through several employee numbers

My program calculates salary  for a given period for an employer and prints the result in a word doc using the function MS_WORD_OLE_FORMLETTER. This works fine when I have only one employer. When I enter several employee numbers the information is collected correctly in a table but only the first record is printed. I have an impression that the program executes as many times as there are employee numbers instead of executing once by looping through the employee numbers before printing the result. How can I print all the information for several employers?

The shorter version of the code is as foolows:
Loop at i_result into w_rt "loop through payroll results for given period
  case w_rt-lgart
  "do some calulations for this employee for
   FIELD-SYMBOLS: <fsd>, <fsl>   type any.
             CONCATENATE 'MF' w_rt-lgart INTO keyA_Merge.
             assign component keya_merge of structure T_MergeData to <fsd>.
             if sy-subrc = 0.
                <fsd> = <fsd> + w_rt-betrg.
             endif.
end case
endloop
append t_mergedata to Fdata
"Now create mail merge for all employees using Fdata
call function 'MS_WORD_OLE_FORMLETTER'
      exporting
        WORD_DOCUMENT             = FILEFORM
        HIDDEN                    = 0
        WORD_PASSWORD             =
        PASSWORD_OPTION           = 1
        FILE_NAME                 = FILEDATA
        NEW_DOCUMENT              =
        DOWNLOAD_PATH             = FILEPATH
       PRINT                     = PFPRINT
      tables
        DATA_TAB                  = FDATA
        FIELDNAMES                = pFIELDS
My problem is that the loop executes for one Employee and then goes on to the end of the program to do the mail merge. the program then "restarts" for the necxt employee. However through each program run/cylce the table t_mergedata is appended with the correct information. I would like to first collect all this info before executing the FM for all the records in t_mergedata.

Similar Messages

  • Looping through several records where some share a primary key.

    Can anyone help me write this code... (fix as is, or restructure). I'm trying to perform methods on various objects which share a primary key (as I iterate through them), then a final method when the last matching primary key is met (they are present in grouped order), however I'm stuck at the new primary key when I want to use the old grouping (grouping code not shown).
    Sring primaryKey = "P1";
    for (MyRecord x : myArrayList) {
        while (s.getPKey() == primaryKey)  {
           // perform operations  ...  add results to array list 'y'
        } else {
           primaryKey = s.getPKey();
           // Here's the kicker: PERFORM METHOD ON OBJECTS FROM PREVIOUS LOOP --
           performMethod(NOT ON THIS array list Y-- LAST array list Y)     
    }EXAMPLE:
    P1
    P1
    P1
    P1
    P2
    P2
    P3
    P3
    P3
    P3
    P4

    present in grouped order), however I'm stuck at the new primary key when I want to use the old grouping (grouping code not shown).1. Normally a primary key means just 1 object associated with that key
    2. See the line above. You have posted code, then you say "this code is a problem. Code I haven't shown you is my problem" How are we supposed to help you?

  • Simple Max date pull from several rows with the same employee numbers.

    Ok so I'm hoping this is flying over my head because it's almost 3am, but I haven't been able to figure this query out for the last 2hrs, but I like to figure stuff out on my own. I'm wondering why the following statement works fine:
    select emp_num, to_char(max(end_date)) as newestdate
    from bank_history
    where emp_num in ('22964', '21667', '20758', '12739', '12731', '20929', '22795', '20594', '23077', '12588', '21294', '20618', '21204', '22952', '19990', '20632', '03093', '19991', '22951', '07779', '20014', '11981', '06149', '20364', '21103')
    and bank_type = 'P' group by emp_num
    BUT! When I start to add more columns that I need to see it starts adding the multiple employee numbers again.
    select emp_num, bank_type, earn_hrs, used_paid_hrs, used_paid_hrs, to_char(max(end_date)) as newestdate
    from bank_history
    where emp_num in ('22964', '21667', '20758', '12739', '12731', '20929', '22795', '20594', '23077', '12588', '21294', '20618', '21204', '22952', '19990', '20632', '03093', '19991', '22951', '07779', '20014', '11981', '06149', '20364', '21103')
    and bank_type = 'P' group by emp_num, bank_type, earn_hrs, used_paid_hrs, used_unpaid_hrs
    The orginal table looks something like this:
    EMP_NUM BANK_TYPE EARN_HRS USED_PAID_HRS END_DATE
    60393 P 0.58 0 3-Aug-2004
    60394 P 7.48 1 28-Oct-2003
    60394 P 40 40 28-Oct-2004
    60394 P 40 12.4 28-Oct-2005
    60395 P 40 40 21-Oct-2004
    60395 P 0 0 21-Oct-2003
    60395 P 40 40 21-Oct-2005
    60397 P 40 39.85 21-Oct-2004
    60397 P 0.97 0.97 21-Oct-2003
    Much thanks for any direction you can give to help guide me on my way to a solution. If you can help it please don't give me the answer, but try to give me the reason it's not working. I'll never learn if you give it to me right up front lol. Thanks again.
    Luke
    Message was edited by: trying to fix the table formating sorry it's so unreadable
    Luke22

    I just give you a prompt:
    SQL> with t as (select 1 emp_num, 'A' bank, date '2007-08-01' dt from dual union all
      2             select 1 emp_num, 'B' bank, date '2007-08-02' dt from dual union all
      3             select 1 emp_num, 'C' bank, date '2007-08-03' dt from dual union all
      4             select 2 emp_num, 'A' bank, date '2007-08-05' dt from dual union all
      5             select 2 emp_num, 'B' bank, date '2007-08-04' dt from dual union all
      6             select 3 emp_num, 'A' bank, date '2007-08-07' dt from dual union all
      7             select 3 emp_num, 'C' bank, date '2007-08-08' dt from dual)
      8  --
      9             select emp_num, max(dt) from t
    10             group by emp_num
    11  /
       EMP_NUM MAX(DT)
             1 03.08.2007
             2 05.08.2007
             3 08.08.2007
    SQL>
    SQL> with t as (select 1 emp_num, 'A' bank, date '2007-08-01' dt from dual union all
      2             select 1 emp_num, 'B' bank, date '2007-08-02' dt from dual union all
      3             select 1 emp_num, 'C' bank, date '2007-08-03' dt from dual union all
      4             select 2 emp_num, 'A' bank, date '2007-08-05' dt from dual union all
      5             select 2 emp_num, 'B' bank, date '2007-08-04' dt from dual union all
      6             select 3 emp_num, 'A' bank, date '2007-08-07' dt from dual union all
      7             select 3 emp_num, 'C' bank, date '2007-08-08' dt from dual)
      8  --
      9             select emp_num, bank, max(dt) from t
    10             group by emp_num, bank
    11  /
       EMP_NUM BANK MAX(DT)
             1 A    01.08.2007
             1 B    02.08.2007
             1 C    03.08.2007
             3 A    07.08.2007
             2 A    05.08.2007
             2 B    04.08.2007
             3 C    08.08.2007
    7 rows selected
    SQL>
    SQL> with t as (select 1 emp_num, 'A' bank, date '2007-08-01' dt from dual union all
      2             select 1 emp_num, 'B' bank, date '2007-08-02' dt from dual union all
      3             select 1 emp_num, 'C' bank, date '2007-08-03' dt from dual union all
      4             select 2 emp_num, 'A' bank, date '2007-08-05' dt from dual union all
      5             select 2 emp_num, 'B' bank, date '2007-08-04' dt from dual union all
      6             select 3 emp_num, 'A' bank, date '2007-08-07' dt from dual union all
      7             select 3 emp_num, 'C' bank, date '2007-08-08' dt from dual)
      8  --
      9             select emp_num, max(bank) keep (dense_rank last order by dt) bank, max(dt) from t
    10             group by emp_num
    11  /
       EMP_NUM BANK MAX(DT)
             1 C    03.08.2007
             2 A    05.08.2007
             3 C    08.08.2007

  • Looping through letters instead of numbers

    I need to create an array of strings containing everything from A100 to X999.  I tried looping through letters but I don't think it can be done
    var arrayAct = new Array();
      for (i = "A"; i <= "X"; i++){
       for (i2 = 100; i2 <= 999; i2++){
        arrayAct.push(String(i+i2));

    excellent.  Final code is working:
    var arrayAct = new Array();
      for (i = "A".charCodeAt(0); i <= "X".charCodeAt(0); i++){
       for (i2 = 100; i2 <= 999; i2++){
        arrayAct.push(String.fromCharCode(i)+String(i2));

  • Nested Loops...looping through one month of data at a time year by year

    Hi all,
    I'm trying to create an insert statement that loops through a table that has 10 years of data (2001 to 2010) month by month to minimize impact on server and commits more frequently to avoid filling up the redo logs and rollback tablespaces. The table is large, has about 40 millions records per year. Lets say the structure of the table is the following:
    Customer_ID number(9),
    Order_Item_1 number(6),
    Order_Item_2 number(6),
    Order_Item_3 number(6),
    Order_date date
    The table is in flat format but I want to normalize it so that it looks like the following:
    Customer_ID Order_Seq Order_Item Order_date
    999999999 1 555555 01-jan-2001
    999999999 2 666666 01-jan-2001
    999999999 3 444444 01-jan-2001
    888888888 1 555555 03-jan-2001
    888888888 2 666666 03-jan-2001
    But because I want to loop through month by month....I need to set it up so that it loops through month by month, year by year (Using the Order Date Field) and Order_item by Order_item. Something like:
    so my insert statements would be something like if I hardcoded instead of put the insert statement into a loop:
    insert into orders_normalized
    (Customer_id,Order_seq,Order_item,Order_date) select customer_id,1,Order_item,Order_date where Order_item_1 is not null and to_char(order_date,'yyyy') = '2001' and to_char(order_date,'mm')='01';
    insert into orders_normalized
    (Customer_id,Order_seq,Order_item,Order_date) select customer_id,2,Order_item,Order_date where Order_item_2 is not null and to_char(order_date,'yyyy') = '2001' and to_char(order_date,'mm')='01';
    insert into orders_normalized
    (Customer_id,Order_seq,Order_item,Order_date) select customer_id,3,Order_item,Order_date where Order_item_3 is not null and to_char(order_date,'yyyy') = '2001' and to_char(order_date,'mm')='01';
    insert into orders_normalized
    (Customer_id,Order_seq,Order_item,Order_date) select customer_id,1,Order_item,Order_date where Order_item_1 is not null and to_char(order_date,'yyyy') = '2001' and to_char(order_date,'mm')='02';
    insert into orders_normalized
    (Customer_id,Order_seq,Order_item,Order_date) select customer_id,2,Order_item,Order_date where Order_item_2 is not null and to_char(order_date,'yyyy') = '2001' and to_char(order_date,'mm')='02';
    insert into orders_normalized
    (Customer_id,Order_seq,Order_item,Order_date) select customer_id,3,Order_item,Order_date where Order_item_3 is not null and to_char(order_date,'yyyy') = '2001' and to_char(order_date,'mm')='03';
    Hope this makes sense.
    Thanks

    Does the sequence of items in an order really matter? In other words, do we really need to preserve that an item was in position 2 versus position 1? I bet that the sequence or position of each item in an order is not meaningful. They were probably numbered 1, 2, and 3 just to make them uniquely named columns so there would be three slots to hold up to 3 items in the denormalized table.
    You only have about 400 million rows to insert, so it could feasibly be done in a single transaction (depending on your database environment).
    You can always do a create table as select (CTAS) to help with undo / redo issues and get better performance. You could run it in parallel, and spit it out to a new table partitioned by month. Single DDL statement running in parallel making your new table--sounds good to me.
    How about something like this:
    CREATE TABLE ORDERS_NORMALIZED
    (CUSTOMER_ID, ORDER_ITEM, ORDER_DATE)
    PARTITION BY RANGE(ORDER_DATE)
    PARTITION p200901 VALUES LESS THAN (TO_DATE('200902','YYYYMM')),
    PARTITION p200902 VALUES LESS THAN (TO_DATE('200903','YYYYMM')),
    PARTITION p201012 VALUES LESS THAN (TO_DATE('201101','YYYYMM'))
    as SELECT CUSTOMER_ID, ORDER_ITEM_1, ORDER_DATE
       FROM OTHER_TABLE
       WHERE ORDER_ITEM_1 IS NOT NULL
       UNION ALL
       SELECT CUSTOMER_ID, ORDER_ITEM_2, ORDER_DATE
       FROM OTHER_TABLE
       WHERE ORDER_ITEM_2 IS NOT NULL
       UNION ALL
       SELECT CUSTOMER_ID, ORDER_ITEM_3, ORDER_DATE
       FROM OTHER_TABLE
       WHERE ORDER_ITEM_3 IS NOT NULL.....................
    Out of curiosity, why not normalize it further? You could have used two tables instead of one.
    One (ORDER) with:
    ORDER_ID
    CUSTOMER_ID
    DATE
    Order_id would be a new surrogate key / primary key.
    Another table (ORDER_ITEM) with:
    ORDER_ID
    ORDER_ITEM
    It would be a table that links ORDERS to ITEMS. You get the idea.

  • How to loop through the "On My Mac" folders in mail?

    Hi there - i am new to applescript, but am slowly working out how to use it.
    I am stumped on how to write a rule that will move a message to a folder identified by a tag in a message (I am using MailTags).
    I have script that will take the first tag and move the message to a mail folder in a fixed location (e.g. Archive/<tag name>) however I wanted to make it more generic by looping over all of my mail folders and finding one that matched the tag name.
    However I am stumped on how to loop over all of my mail folder names - I have tried:
    repeat with aFolder in (every mailbox of (mailbox for "ON MY MAC"))
    and
    repeat with aFolder in every mailbox of inbox
    etc.
    but none of these seem to work.
    Is there some magic syntax to do this, so that I can do:
    if (name of aFolder = msgTag) then
    move oneMessage to mailbox (name of aFolder)
    end if
    Tim

    You don't necessarily need to assign a variable to the entire list in order to loop through them (unless you really want to) - for example:
    tell application "Mail" to repeat with aFolder in (get mailboxes)
            -- do stuff with aFolder
    end repeat
    There are several AppleScript resources, but the main ones I use are:
    AppleScript Language Guide
    AppleScript Tutorials at MacScripter.net

  • Looping through a table

    how do I loop through the following table and get it to insert records into another depending on the number that it finds in the value column. eg if there is 8 in the value column, 8 records should be inserted into another table with the same ID
    i forgot to paste an example table
    ID
    Name
    Value
    1
    john
    12
    2
    sarah
    20
    3
    Tom
    5
    I want it to look at the value column and if it is 12 it should add 12 rows with the same ID into another table. eg in the new table there will be 12 rows for John with an ID of 1. For Sarah there will be 20 rows with an ID of 2.
    sukai

    Sure!
    DECLARE @sourceTable TABLE (ID INT, Name VARCHAR(20), Value INT)
    INSERT INTO @sourceTable (ID, Name, Value) VALUES (1, 'john', 12),(2, 'sarah', 20),(3, 'Tom', 5)
    This mocks up your source table (where your data is coming from). We're simply creating a table variable, and populating it with your example data.
    DECLARE @numbers TABLE (value INT)
    WHILE (SELECT COUNT(*) FROM @numbers) < (SELECT MAX(Value) FROM @sourceTable)
    BEGIN
    INSERT INTO @numbers (value) VALUES ((SELECT COUNT(*) FROM @numbers)+1)
    END
    This creates an example numbers table. The while causes the code to loop until there are as many rows as the maximum value for the Value column in your example data. Each time the loop iterates it inserts a row, causing the COUNT(*) to be one more each time,
    we add one to that, and insert it into the numbers table.
    INSERT INTO destinationTable
    SELECT s.ID, s.Name, s.Value
    FROM @sourceTable s
    INNER JOIN @numbers n
    ON s.Value >= n.value
    ORDER BY s.ID
    This performs an insert select to a made up table. We join the rows from @sourceTable (your example data) to the @numbers table where the Value column from @sourceTable is less than or equal to the value column in the numbers table. If s.Value is 1
    we'll perform this join once. If it's 2, twice and so on. This works because of the way we set up the numbers table. If we had insert multiple 1's it would cause additional joins.
    A numbers table is a handy tool to have for things like this were you need iterations. Create a database (or schema) on your database and call it something like 'Toolbox'. In that database/schema you can put things like this that have little to do with your
    actual data, but come in handy. You can make your numbers table as long as you need. It totally wouldn't hurt at all to have a numbers table with hundreds of thousands of rows. They're just int's, they don't eat much :).
    Let me know if you'd like anything clarified more.

  • PA30, attaching documents through the employee personal master dat

    Dear freinds,
    We are attaching documents through the employee personal master data
    PA30, Our client wants to know where exactly these attachments are
    getting saved; Our SAP environment is ECC6.0 on AIX 5.3. so i exactly would like to know what is the exact path where these documents are getting saved on AIX machine.
    I would appreciate if you can tell us where exactly these documents are
    getting saved at OS level, any particular file system you think,
    because I probed in but couldnu2019t find where exactly there are on the
    OS..
    Regards
    ayush

    hello,
    SAP generally recommends that you store employee documents with a bar code. You can find the documentation to 'Storage Within Personnel Administration' using the following path:
    => Help => SAP Library => Human Resources => Personnel Management (PA)=> Personnel Administration (PA-PA) => Storage Within Personnel Administration (PA-PA)
    In the SAP Standard it is not possible to tie original documents to specific personnel numbers in the PA30 transaction. The only exceptions are two specific scenarios where you can tie original documents in the PA30 transaction:
    1. late storing with bar code
    2. late storing without bar code
    During both scenarios you start out in the Trx PA30. If the bar code entry is deactivated the actual key data will have to be transferred to the document in any case, otherwise you will be asked to enter a barcode again. Therefore the document would be transferred to the scanning location and then assigned to a specific business object.
    Unfortunately it is NOT possible to upload a document directly into archive in the PA30 any other way.
    Let me emphasize once more that PA30 can not be used for storing infotype specific documents. Via the special scenarios mentioned already by my colleague you are able to assign documents to the specific infotypes but the storing has to be completed outside of PA30.
    Using the option Extras -> Assign facsimile in PA30 will be interpreted by the system as start for late scanning with barcode thus the error message.
    Hope this help
    Sarah

  • Loop through all controls in view

    Hi Everyone,
    I need to cycle through all the controls on a view.
    I have set each of the controls of type UISegmentedControl with a unique tag number.
    I am using this tag number to perform a lookup in database for the value of the segmented control.
    So, my question is this.... how do i cycle through all the controls on a view?
    thank you
    take care
    tony

    alt-088 wrote:
    I think we are close - just one correction.
    The segmented controls are all at design time, there will be no new controls added.
    I'm not clear on what's been corrected. The sample code I gave you assumed all the controls were known at compile time. So I think the example code addressed the problem you're trying to solve. The last paragraph of that post was just an afterthought, to explain what to do in case you ever needed to add controls dynamically.
    -> loop through all controls on view
    -> if control is of type uisegmentdcontrol
    then do database lookup on tag
    Set segment value to value returned from database
    Once again, if I correctly understand the above, the code I gave you does exactly what you want. You haven't indicated you want to take any action when a control is not a segmented control, so I don't see why you'd want to include them in the loop. However, if you actually do need to enumerate non-segmented controls (or other subviews), my last response advised you to set the tag properties of all those other controls, making sure the range of those tags is different from the range of the seg control tags.
    The part that eludes me is the looping through all the controls on the view
    I guess the part that eludes me is why you're so interested in enumerating all the controls, when you only seem to be interested in the segmented controls. But even if you really do need to look at every control, I don't see why you're rejecting the solution I gave you. [viewWithTag:|http://developer.apple.com/iphone/library/documentation/UIKit/Ref erence/UIViewClass/UIView/UIView.html#//appleref/doc/uid/TP40006816-CH3-SW26] is a powerful method which recursively walks the entire view hierarchy to find whatever tag it's looking for. If you use it correctly (e.g. by assigning unique tag numbers that tell you what type of control you've found), it will save you lots of trouble.
    If, for some reason, you insist on doing this job without using viewWithTag, the next best might be something like this:
    - (void)doSomethingWithEachSegCtrlInView:(UIView *theView) {
    UIView *subView;
    for (subView in theView.subviews) {
    if ([subView respondsToSelector:@selector(selectedSegmentIndex)]) {
    // subView is a segmented control ...
    else {
    // subView is not a segmented control ...
    if ([subView.subviews count]) {
    // this subview has its own subviews
    [self doSomethingWithEachSegCtrlInView:subView];
    Note that the above is a more difficult, more error prone method than the sample in my first response. Firstly, it needs to recurse in case any controls are placed on subviews of the main view (or on subviews of those subviews, etc.), a capability already built into viewWithTag. Secondly it needs to identify the type of each subview object. [respondsToSelector:|http://developer.apple.com/iphone/library/documentation/Co coa/Reference/Foundation/Protocols/NSObjectProtocol/Reference/NSObject.html#//appleref/occ/intfm/NSObject/respondsToSelector:] is the preferred way of identifying the class of an object, especially when the selector argument represents one of the methods you intend to use. However there's no reason to get into the business of identifying the class of an object, when you could have given that object a unique tag number in the xib, where there was no question about its class.
    Hope the above communicates the solution better than my first response!
    - Ray

  • Looping through a cursor (newbie)

    I am trying to construct a dynamic insert statement. I am retrieving (using a select) the column names from one of my tables into a cursor. I would now like to loop through the cursor and extract the column names. Is there anyway to loop through the cursor like you can normally do as below:
    for i = 0 to cursor%rowcount
    tempstring = tempstring + ',' + cursor.i; (something along these lines)
    end for
    and then do 'insert into tablename (' || tempstring
    Am I making sense?

    There are several methods to process cursors and you can easily find them
    here.
    http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96624/01_oview.htm#740
    http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96624/06_ora.htm#36656
    And before trying to use dynamic sql it would be better to think would you really
    need it...
    Rgds.

  • Employee Numbering in Multiple Business Groups

    Hi All,
    We are having 2 business groups. The employee numbering is automatic and global sequence. The employee transfers between business groups is quite common and the client wants the same employee number when the employee transfers from one BG to another.
    Example: Employee ABC is hired is BG1 with employee number as 10001 and when employee is transfered to BG2 the client wants the employee to retail his old employee number in the new BG.
    Any help is higlhly appreciated.
    Thanks,
    Ramprasad.

    Hi,
    I have done this before. You need to set the numbering to Manual (with profile option) and then edit the fast formula associated with Numbering.
    You need the following logic inside PLSQL procedure (gets called through FF) for this requirement:
    - Check if the employee is a transfer case. Use (first name , last name , date of birth) combination on per_all_people_f to check this. Note person_id and business_group_id will be different for a transfer case
    - If the person is transfer case then derive the previous employee number (from per_all_people_f)
    - else derive the last used employee number from per_all_people( select max(employee_number) from per_all_people_f) and return this number by adding 1.
    - he employee number field might have characters in it so you need to replace characters while deriving latest employee nnumber (select MAX(translate(employee_number, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',' ')) from per_all_people_f)
    Please note the fast forumula needs to be edited and verified from SETUP BG for this case.
    When you initially install Oracle HR (and it does not matter whether shared install or full install)
    you get two options, Automatic or Manual, as a choice for Employee Number Generation.
    If you choose Employee Number Generation = Manual, and then later decide to change to Automatic,
    you can do this.
    But, if you started as Manual, and then changed to Automatic, and then once again want to change
    back to Manual,
    Employee Number Generation = Manual will no longer show up in your LOV for Employee Number
    Generation.
    You only get to do this once and cannot go back to Manual Employee Number Generation if you have
    been there before.
    ~Amol

  • Looping through array

    If I declare an array such as the one below.
    declare
    type array_type is table of varchar2(100) index by binary_integer;
    component_array array_type;
    begin
      component_array(12345) := 'One';
      component_array(12347) := 'Two';
      component_array(12349) := 'Three';
      for i in component_array.FIRST .. component_array.LAST
      loop
        dbms_output.put_line(component_array(i));
      end loop;
    end;Is there a way to loop through only the existing binary_integer indeces? For example, if you execute the block above, you'll get an error because the loop iteration is hitting 12346 which of course doesn't exist. Other than the workaround below, is there another way using any type of array method?
    declare
    type array_type is table of varchar2(100) index by binary_integer;
    component_array array_type;
    begin
      component_array(12345) := 'One';
      component_array(12347) := 'Two';
      component_array(12349) := 'Three';
      for i in component_array.FIRST .. component_array.LAST
      loop
        begin
          dbms_output.put_line(component_array(i));
        exception
          when NO_DATA_FOUND then
            null;
        end;
      end loop;
    end;
    Thanks.

    Hi,
    Not to hijack this thread, but, since this is related to my answering OP's question, I am posting here.
    How come this code is erroring out?
    DECLARE
      TYPE array_type IS TABLE OF VARCHAR2(100) INDEX BY VARCHAR2(1000);
      component_array array_type;
    BEGIN
      component_array(12345) := 'One';
      component_array(12347) := 'Two';
      component_array(12349) := 'Three';
      FOR i IN component_array.first .. component_array.last LOOP
        IF component_array.exists(12345) THEN
          dbms_output.put_line(component_array(i));
        END IF;
      END LOOP;
    END;errors out with no_data_found, but, this doesn't ?
    DECLARE
      TYPE array_type IS TABLE OF VARCHAR2(100) INDEX BY VARCHAR2(1000);
      component_array array_type;
    BEGIN
      component_array(12345) := 'One';
      component_array(12347) := 'Two';
      component_array(12349) := 'Three';
      FOR i IN component_array.first .. component_array.last LOOP
        IF component_array.exists(12344) THEN
          dbms_output.put_line(component_array(i));
        END IF;
      END LOOP;
    END;notice the static numbers in the .exists parameter....

  • Looping through an array, i dont want duplicates

    hello,
    I am wondering if anyone can help me please, I have an array
    containing numbers, these numbers are attached to movie clips to
    determine where they are on the stage, and they are generated
    randomly, so the movie clips are always in a new place when a
    certain button is pressed.
    My problem is that I dont know how to avoid duplicates. The
    way I have done it is I have put the values in an array, and I loop
    through this with a for loop, from here I take the values and link
    them to another array that contains the movie clips, this all works
    well but some of the movie clips are stacked on top of one another
    because the same array values are coming up :S I have attached the
    code, so any suggestions would be gratefully recieved, I just
    havent a clue on this one :S
    Many thanks any help is gratefully recieved :D

    Hi. You were wise to trace the value of n. Your problem seems
    to be that the tests succeed (almost always) in the very first
    iteration because they truly don't match (where n = 0) and
    execution breaks out. You need to adjust the logic. As one
    approach, while sticking with your code and not changing it too
    much (such as using more efficient int vs Number):
    at the very top, define a counter var ct:int = 0;
    before the testing loop, define a flag, such as var
    flag:boolean = false;
    you could then invert the logic in the loop and test for ==
    rather than for !=
    if you find a match, do--> flag = true;
    and break
    at the end of testing, use the flag to decide whether to
    store the new value
    if (!flag) {
    // add to array
    ct++;
    also, use a while loop for controlling the whole thing-->
    while(ct < max) { }
    to know when you're done
    You can also check out the Array functions indexOf() and
    some(), to make things more efficient and faster/easier
    when you're all done, you can also look into using if (a != b
    && c != d)
    for efficiency, instead of nesting them separately
    good luck :)

  • Looping through Objects

    Hi,
    I'm trying to design business entities with ABAP Objects. I have been able to create internal tables of custom object types.
    I stumbled into a very peculiar situation in which i have to loop through my custom object internal table. i couldn't use the WHERE specification since the line type is not a structure. READ TABLE doesnt work either. What i did to overcome the problem was to do a LOOP AT with an IF statement inside and an EXIT command to quit the search when found.
    Is there a better solution? And Is the whole idea of wrapping everything in classes and accessing the through an internal idea a good idea in the first place?
    Thanks.

    heres an example:
    * DEFINITIONS
    CLASS cl_drag_drop_picture DEFINITION INHERITING FROM cl_gui_picture.
      PUBLIC SECTION.
        DATA: row     TYPE I,
              col     TYPE I.
    DATA: g_wa_pic_ctrl TYPE REF TO cl_drag_drop_picture.
    DATA: g_it_pic_ctrl LIKE TABLE OF g_wa_pic_ctrl.
    * PROCESS
    * lets assume that g_it_pic_ctrl has several entries and
    * each entry is uniquely identified by the attributes
    * row AND col.
    PERFORM GetObjectByRowCol USING p_row
                                    p_col
                           CHANGING g_wa_pic_ctrl.
    * SUBROUTINES
    FORM GetObjectByRowCol USING p_row
                                 p_col
                        CHANGING r_pic_ctrl.
      DATA: l_wa_pic_ctrl LIKE g_wa_pic_ctrl.
    * Search for picture
      LOOP AT g_it_pic_ctrl INTO l_wa_pic_ctrl.
        IF l_wa_pic_ctrl->row EQ p_row AND
           l_wa_pic_ctrl->col EQ p_col.
          r_pic_ctrl = l_wa_pic_ctrl.
          EXIT.
        ENDIF.
      ENDLOOP.
    * Collect Garbage
      CLEAR l_wa_pic_ctrl.
    ENDFORM.
    What I couldn't do is access my internal table like:
    READ TABLE g_it_pic_ctrl
          INTO r_pic_ctrl
      WITH KEY row = p_row
               col = p_col.
    OR
    LOOP AT g_it_pic_ctrl INTO r_pic_ctrl
                         WHERE row EQ p_row
                               col EQ p_col.

  • URGENT:  Loop through files

    I have a package that will be run from an Oracle Job and I want to process files in a directory and load each of the files into the database. I can load one specifically, but I want to loop through all the files in the directory and load each one at a time. Any help would be greatly appreciated.
    Lisa

    I followed the instructions but when I try to create the java, I get the following error (removed the numbers in front of each line):
    and compile java source named "DirList"
    ERROR at line 2:
    ORA-29536: badly formed source: Encountered "<EOF>" at line 1, column 17.
    Was expecting:
    unknown command beginning "import jav..." - rest of line ignored.
    unknown command beginning "public cla..." - rest of line ignored.
    unknown command "{" - rest of line ignored.
    unknown command beginning "public sta..." - rest of line ignored.
    For a list of known commands enter HELP
    and to leave enter EXIT.
    unknown command beginning "throws SQL..." - rest of line ignored.
    unknown command "{" - rest of line ignored.
    unknown command beginning "File path ..." - rest of line ignored.
    unknown command beginning "String[] l..." - rest of line ignored.
    For a list of known commands enter HELP
    and to leave enter EXIT.
    unknown command beginning "String ele..." - rest of line ignored.
    unknown command beginning "for(int i ..." - rest of line ignored.
    unknown command "{" - rest of line ignored.
    unknown command beginning "element = ..." - rest of line ignored.
    For a list of known commands enter HELP
    and to leave enter EXIT.
    unknown command beginning "#sql { INS..." - rest of line ignored.
    unknown command beginning "VALUES (:e..." - rest of line ignored.
    unknown command "}" - rest of line ignored.
    unknown command "}" - rest of line ignored.
    For a list of known commands enter HELP
    and to leave enter EXIT.
    unknown command "}" - rest of line ignored.
    and compile java source named "DirList"
    ERROR at line 2:
    ORA-29536: badly formed source: Encountered "<EOF>" at line 1, column 17.
    Was expecting:
    I researched it on metalink with no luck. I'm running it on my local database (Oracle8i Release 8.1.7.0.0 - Production JServer Release 8.1.7.0.0 - Production) so this may be the problem.
    Help!
    Lisa

Maybe you are looking for