Loop around a variable

Hi,     
I have a situation where i need to loop around a variable which holds the value of the loop count. Is Loop AT possible in this case?

Hi Peri,
You can definetly use Loop AT with sy-tabix ( system variable that has the loop count)
Example Code Snippet:
LOOP AT t_marm INTO p_mattab FROM sy-tabix.
IF p_mattab-matnr NE p_matnr.
CLEAR p_mattab.
EXIT.
ENDIF.
ENDLOOP.
Kindly Reward Points If You Find The Reply Helpful.
Cheers,
Chaitanya.

Similar Messages

  • Why can't I hear the first note until it loops around?

    Hello Everyone,
    I have a littlr problem. I have quantized a drum pattern so that the kick drum is on every fourth of a bar. The problem is....I can't hear the first kick until it loops around. Any ideas as to why this is?
    Many thanks,
    JV

    Look at the piano roll (or the event list) and make
    sure that the first hit is on or just inside the
    first beat of the measure. It might sound fine, but
    if it's even a single tick in front of the first beat
    of your sequence, then you won't hear it, since
    playback starts at measure 1, beat 1, tick 1.
    Most of the time when this problem occurs it is not because the note is behind the downbeat. And with note chase=on that shouldn't present a problem anyay.
    And moving the beat one tick later than intended? If the tempo was right up there, say, 170 or something, maybe you wouldn't perceive that. But at slower tempos, a tick is a huge amount of time, especially for drums, and personally I wouldn't recommend changing the intended timing of your notes to suit the sequencer's inability to play things correctly on the downbeat, whatever the cause may be.
    The easiest workaround for this (and it's not perfect, but still a workaround) is to start playback slightly before the downbeat.

  • Run-Time Check Failure #2 - Stack around the variable was corrupted.

     I had checked on net as well as on social msdn site for this kind of error. Usually error is due to writing out of index. I tried to figure out same mistake in below mentioned code but I failed to do so. I am using Visual Studio 2010 for compilation
    on Windows 7 (64 bit) machine. I am getting following error "Run-Time Check Failure #2 - Stack around the variable 'lcPacketPrefix' was corrupted."
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #define TRUE 1
    #define FALSE 0
    #define BYTE unsigned char
    typedef struct {
    int i;
    double e;
    long t;
    char ar[45];
    }Sample;
    bool getMCXBuffPrefix(char * lpSource,char* Destination, int piSourceLen)
    char lcPacketLen[10];
    char lcPacketPrefix[5];
    try
    memset(lcPacketLen,'0',sizeof(lcPacketLen));
    memset(lcPacketPrefix,'0',sizeof(lcPacketPrefix));
    _itoa(piSourceLen,lcPacketLen,10);
    strcpy_s(lcPacketPrefix+(sizeof(lcPacketPrefix)-strlen(lcPacketLen)),sizeof(lcPacketPrefix),lcPacketLen);
    //To Prefix Length in send Packet
    memcpy(Destination,lcPacketPrefix,5);
    memcpy(Destination+5,(char*)lpSource,piSourceLen);
    catch(...)
    printf("In Catch: While Prefixing MCX Buffer.\n");
    return FALSE;
    return TRUE;
    int main(int argc, char *argv[])
    BYTE* lcCompData = (BYTE*) malloc (1024);
    BYTE* gpcSendSource = (BYTE*) malloc (1024);
    Sample sample_t;
    memset((BYTE*)gpcSendSource,'0',1024);
    memset(&sample_t, '\0', sizeof(Sample));
    memcpy(gpcSendSource, &sample_t, sizeof(Sample));
    bool lbPrefixed = getMCXBuffPrefix((char*)gpcSendSource,(char*)lcCompData,sizeof(Sample));
    return 0;
    Little guidance will be helpful.

     I had checked on net as well as on social msdn site for this kind of error. Usually error is due to writing out of index.
    As it is in your code.
           strcpy_s(lcPacketPrefix+(sizeof(lcPacketPrefix)-strlen(lcPacketLen)),sizeof(lcPacketPrefix),lcPacketLen);
    You're saying that the size of the buffer is greater than it is
    because you're offsetting the start pointer.
    If you'd more correctly written the code like this:
      size_t offset = (sizeof(lcPacketPrefix) - strlen(lcPacketLen));
    strcpy_s(lcPacketPrefix+offset,sizeof(lcPacketPrefix)-offset,lcPacketLen);
    You'd have got a run-time error in the debug version of your code.
    However that's not what you want. Try something like this instead:
      size_t offset = (sizeof(lcPacketPrefix) - strlen(lcPacketLen));
      strncpy(lcPacketPrefix + offset, lcPacketLen, strlen(lcPacketLen) );
    But most importantly, understand what you'd done wrong and learn from
    it.
    Dave

  • Debugging: Run-Time Check Failure #2 - Stack around the variable 'LoggerThread' was corrupted.

    I am getting:
    Run-Time Check Failure #2 - Stack around the variable 'LoggerThread' was corrupted.
    I have searched as much as I can for a description of how to diagnose, but I have not found anything. I don't know how to determine the specific address that is being corrupted. If I knew that, then I could of course set a breakpoint on the condition of that changing.
    I have found many answers about other instances of this error, but nothing that descibes how to diagnose this problem. All other problems were simple enough that the problem could be determined by looking at the code. I have looked at my code extensively and I don't see a problem. One of the previous answers I have found is Error: Stack corruption around the variable 'tm' but the current version of the program uses only default alignment.
    This particular problem is a symptom of a problem that has had various other symptoms, most of which would be more difficult to diagnose. Therefore the problem is probably more subtle than most. I initially encountered the problem in a DLL project, but I wrote a console program to use and test the relevant code. It is the console version that I am debugging.

     Sam Hobbs wrote:
     Holger Grund wrote:
    Hey, these data breakpoints are really not that hard to use ;-)
    Actually they are useless for me when I use my own system, which is only 350 MHz. On that system, even very simple programs run noticeably slow and any meaningful debugging is impossible. The problem I am encountering I am developing and debugging using a fast system, so the performance is not likely to be a probem, but that has been a problem for me in the past.
    You probably haven't set the breakpoints in the correct way (again you should calculate the address yourself and leave the context empty so that the hardware debug breakpoint registers can be used).
     Sam Hobbs wrote:
    One of us does not understand. First, I must correct what I said before; the stack is used in reverse of what I was thinking. I knew that but I forgot. In other words, for each item local appearing in a function, the addresses decrease. The processor's stack pointer register is decreased for each item put into it, which makes sense, because then the processor knows there is a problem when the register gets to zero or less.
    Yes, I certainly understand that the error message is referring to memory before and after LoggerThread.
    There is an important difference between stack memory before a function's allocations and after.
    So for example if we have:
    Code Snippet
    void Level3(int a) {
     char Local[4];
    std::cout << "In Level3 Local is at " << &Local << '\n';
    void Level2(int a) {
     char Local[4];
    std::cout << "In Level2 Local is at " << &Local << '\n';
    Level3(3);
    void Level1(int a) {
     char Local[4];
    std::cout << "In Level1 Local is at " << &Local << '\n';
    Level2(2);
    int main(int argc, char* argv[]) {
     (void)argc, argv;
     char Local[4]="321";
     unsigned *pStack;
    _asm {mov pStack, esp}
    std::cout << "The stack is at " << pStack << '\n';
    std::cout << "In main Local is at " << &Local << '\n';
    Level1(1);
    return 0;
    Then the ouput I get is:
    The stack is at 0012FF1C
    In main Local is at 0012FF6C
    In Level1 Local is at 0012FF0C
    In Level2 Local is at 0012FEB0
    In Level3 Local is at 0012FE54
    Note that the addresses decrease. If I create a breakpoint using "{main,,} *(Local-256)" for 256 elements, then that breakpoint breaks constantly due to normal use of the stack. That makes debugging more difficult; are you aware of that problem?
    Unsurprisingly the debugger will watch for modifications of 256 bytes if you tell it to do so. But I don't see why you would want to do it? It is obvious that this extends into callee stack space. There are only two bytes that you should be interested in: the one before the clobbered local and the one after. Of course, during its lifetime its allocated address will never change. And in debug stack frames its memory location is never shared with any other code. Any modification to it indicates a programming error.
    Also, do note that scoped data breakpoints have had some performance problems. Again, if you care about performance calculate the address manually and set a data breakpoint without a C++ scope and make sure you don't exceed the number of available hardware watchpoint registers (IIRC there are 4 HW breakpoint registers which can watch 1,2 or 4 bytes at a given (aligned?) address). With HW watchpoints you shouldn't see any performance degradation.
    -hg

  • Trying to pass array to stored procedure in a loop using bind variable

    All,
    I'm having trouble figuring out if I can do the following:
    I have a stored procedure as follows:
    create procedure enque_f826_utility_q (inpayload IN f826_utility_payload, msgid out RAW) is
    enqopt dbms_aq.enqueue_options_t;
    mprop dbms_aq.message_properties_t;
    begin
    dbms_aq.enqueue(queue_name=>'f826_utility_queue',
    enqueue_options=>enqopt,
    message_properties=>mprop,
    payload=>inpayload,
    msgid=>msgid);
    end;
    The above compiles cleanly.
    The first parameter "inpayload" a database type something like the following:
    create or replace type f826_utility_payload as object
    2 (
    3 YEAR NUMBER(4,0),
    4 MONTH NUMBER(2,0),
    83 MUSTHAVE CHAR(1)
    84 );
    I'd like to call the stored procedure enque_f826_utility_q in a loop passing to it
    each time, new values in the inpayload parameter.
    My questions are:
    First, I'm not sure in php, how to construct the first parameter which is a database type.
    Can I just make an associative array variable with the keys of the array the same as the columns of the database type shown above and then pass that array to the stored procedure?
    Second, is it possible to parse a statement that calls the enque_f826_utility_q procedure using bind variables and then execute the call to the stored procedure in a loop passing new bind variables each time?
    I've tried something like the following but it's not working:
    $conn = oci_pconnect (....);
    $stmt = "select * from f826_utility";
    $stid = oci_parse($conn, $sqlstmt);
    $r = oci_execute($stid, OCI_DEFAULT);
    $row = array();
    $msgid = "";
    $enqstmt = "call enque_f826_utility_q(:RID,:MID)";
    $enqstid = oci_parse($conn, $sqlstmt);
    oci_bind_by_name($enqstid, ":RID", $row); /* line 57 */
    oci_bind_by_name($enqstid, ":MID", $msgid);
    while ($row = oci_fetch_array($stid, OCI_RETURN_NULLS+OCI_ASSOC))
    ++$rowcnt;
    if (! oci_execute($enqstid)) /* line 65 */
    echo "Error";
    exit;
    When I run this, I get the following:
    PHP Notice: Array to string conversion in C:\Temp\enqueue_f826_utility.php on l
    ine 57
    Entering loop to process records from F826_UTIITY table
    PHP Notice: Array to string conversion in C:\Temp\enqueue_f826_utility.php on l
    ine 65
    PHP Warning: oci_execute(): ORA-06553: PLS-306: wrong number or types of argume
    nts in call to 'ENQUE_F826_UTILITY_Q' in C:\Temp\enqueue_f826_utility.php on lin
    e 65
    PHP Notice: Undefined variable: msgnum in C:\Temp\enqueue_f826_utility.php on l
    ine 68
    Error during oci_execute of statement select * from F826_UTILITY
    Exiting!

    Thanks for the reply.
    I took a look at this article. What it appears to describe is
    a calling a stored procedure that takes a collection type which is an array.
    Does anyone from Oracle know if I can pass other database type definitions to a stored procedure from PHP?
    I have a type defined in my database similar to the following which is not
    an array but a record of various fields. This type corresponds to a payload
    of an advanced queue payload type. I have a stored procedure which will take as it's input, a payload type of this structure and then enqueue it to a queue.
    So I want to be able to pass a database type similar to the following type definition from within PHP. Can anyone from Oracle verify whether or not this is possible?
    create or replace type f826_utility_payload as object
    YEAR NUMBER(4,0),
    MONTH NUMBER(2,0),
    UTILITY_ID NUMBER(10,0),
    SUBMIT_FAIL_BY VARCHAR2(30),
    MUSTHAVE CHAR(1)
    );

  • ForEach Loop Container Mapping Variable From SSIS Package Not Working In SQL-Server StoredProcedure

    I have an SSIS package that uses a ForEach Loop Container to enumerate Excel Files in a dir. I also have a Task Flow that inserts data from those Excel files into SQL-Server.
    Im trying to insert the file names into a column into the same table in SQL-Server by using a mapping variable in my StoredProcedure.
    Im having trouble with my MappingVariable at the end of the script with red squigglies. The following is my StoredProcedure script.
    CREATE PROCEDURE [dbo].[Insert_F_STG_v2]
    -- Add the parameters for the stored procedure here
    @Hrs float,
    @Type nvarchar(100),
    @SN nvarchar(100),
    @Op nvarchar(100),
    @[USER::CurrentFileName]
    AS
    BEGIN
    SET NOCOUNT ON;
    INSERT INTO [CRM_RC].[dbo].[F_StgTbl]
    [Hrs],
    [Type],
    [SN],
    [Op],
    [Report_Date]
    VALUES
    @Hrs ,
    @Type,
    @SN,
    @Op,
    @[USER::CurrentFileName]
    END
    The last @[USER::CurrentFileName] in the Values block at the bottom of the script is the one giving me issues.
    The following is the error:
    Msg 102, Level 15, State 1, Procedure Insert_F_STG_v2, Line 95
    Incorrect syntax near 'USER::CurrentFileName'.

    This seems to be the solution, but get the following exception: 
    [Derived Column [2]] Error: The "Derived Column" failed because truncation occurred, and the truncation row disposition on "Derived Column.Outputs[Derived Column Output].Columns[Derived Column 1]" specifies failure on truncation. A truncation error occurred
    on the specified object of the specified component.
    AND:  [SSIS.Pipeline] Error: SSIS Error Code DTS_E_PROCESSINPUTFAILED.  The ProcessInput method on component "Derived Column" (2) failed with error code 0xC020902A while processing input "Derived Column Input" (3). The identified component returned
    an error from the ProcessInput method. The error is specific to the component, but the error is fatal and will cause the Data Flow task to stop running.  There may be error messages posted before this with more information about the failure.

  • Single quotes around a variable

    Hi,
    I have values that are being passed into a variable with single quotes around.
    for eg: 'test'. So the value in variable v_empname will hold the value 'test'
    But then below sql statement returns null:
    select empid
    into v_empid
    from emp where empname = v_empname
    When I checked the value of the variable it's 'test' and compared as '''test'''.
    How can I get around this?
    Thanks for the help.
    SK.

    Doh!
    SQL> create or replace procedure get_empno (i_name in varchar2)
      2  as
      3    v_empno number;
      4  begin
      5    select empno into v_empno
      6    from emp
      7    where ename = i_name;
      8    dbms_output.put_line('empno is '||v_empno);
      9  exception
    10    when no_data_found then
    11      dbms_output.put_line('No such person, or did you mean '||upper(i_name)||'?');
    12  end;
    13  /
    Procedure created.
    SQL>
    SQL> set serveroutput on
    SQL> exec get_empno('king');
    No such person, or did you mean KING?
    PL/SQL procedure successfully completed.
    SQL> exec get_empno('KING');
    empno is 7839
    PL/SQL procedure successfully completed.

  • Multiple loops in one loop for text variables

    Dear experts,
    Please find the code below.This is text variable customer exit.Can u ple help me to put these multiple loops into one loop.Do u suggest this code is ok?
    Appreciate your help.
    WHEN 'ZSTXTPE01AA'or 'ZSTXT0FISCPER305AA'or 'ZSTXT0FISCYEAR01AA'
    INCLUDE Z_VARIABLES_TEXT
    DATA: vtype i,
          fisper i,
          fisyear i
    IF I_STEP=2.
    LOOP AT I_T_VAR_RANGE INTO loc_var_range WHERE VNAM='ZS0VTYPE01AA'
    vtype=LOC_VAR_RANGE-LOW
    ENDLOOP.
    CLEAR L_S_RANGE.
    L_S_RANGE-LOW= vtype.
    L_S_RANGE-SIGN = 'I'.
    L_S_RANGE-OPT = 'EQ'.
    LOOP AT I_T_VAR_RANGE INTO loc_var_range WHERE VNAM='ZS0FISCPER305AA'
    fisper=LOC_VAR_RANGE-LOW
    ENDLOOP.
    CLEAR L_S_RANGE.
    L_S_RANGE-LOW= fisper.
    L_S_RANGE-SIGN = 'I'.
    L_S_RANGE-OPT = 'EQ'.
    LOOP AT I_T_VAR_RANGE INTO loc_var_range WHERE VNAM='ZS0FISCYEAR01AB'
    fisyear=LOC_VAR_RANGE-LOW
    ENDLOOP.
    CLEAR L_S_RANGE.
    L_S_RANGE-LOW= fisyear.
    L_S_RANGE-SIGN = 'I'.
    L_S_RANGE-OPT = 'EQ'.
    APPEND L_S_RANGE TO E_T_RANGE.
    ENDIF.
    Rgds
    ACE

    Hi ACE BW,
    You can try to use the SELECT statement and then include the LOOP inside it.
    Thanks,
    Daniel

  • Cursor for loop vs bind variable efficiency

    PL/SQL
    I am going to need to execute many sqls within a cursor for loop.
    Note: This is pseudo pl/sql code
    for csr_rec in cursor
    loop
    insert into tablea
    select [whateever] from tableb
    where column_name = csr_rec.field
    versus
    execute immediate
    'insert into table a select ... where column_name = :1' using csr_rec.field
    So the question is whether the first insert statement will be treated as a separate sql statement and need to be parsed each iteration? If so, then I'd likely be much better of using the bind variable approach. (2nd) insert statement.
    Thanks!

    The first statement (static) will be re-used - PL/SQL variables (csr_rec.field in this case) will be used as a bind variable.

  • How to make chart from multiple loops without local variables

    Hi,
    It is my first experience in LabView.
    I did a program that communicate with Power Supply Device via RS232, sets an output voltage and read Voltage and Current in some sort of a program: Voltage goes up, staying in some value and then goes down. So there are many FOR LOOPS that sequensed one after another.
    I need to make a 2 live Charts (one for current and second for voltage), and the only one solution that i could obtain is using local variables. BUT also I need to export my data to the file after the end of the program (with real elapsed time for collecting data points) and with the use of local variables I cannot do so. Maybe the Shift Register will work, but I could not make it work.
    Thank you for help.
    Attachments:
    test.vi ‏47 KB

    You have multiple, deeply stacked, sequential loops. Way too complicated.
    All you need is a simple state machine architecture using a single loop and a single instance of your charts. No local variables needed. Simplify!!! You could even graph both values on a single chart.
    Look at your code. It is basically repeating the same thing with slighly different inputs. You only need to change the inputs based on state, and re-use the same IO function instances. Only one instance each needed.
    (you also have some misguided autoindexing near the middle of your code. Bad!)
    LabVIEW Champion . Do more with less code and in less time .

  • Single row table with for-each group loop to set variable.

    Hi: There is probably a simple answer for this but I have not found it ...
    I have a single row table to loop through a group to set a variable holding a running amount. I am not displaying the amount within the table however when I preview the report I see that the table is expanding (adding rows) for each loop.
    The single row table has 3 columns.
    1st column
    <?for-each:AC_GROUP?>
    2nd column
    <?xdoxslt:set_variable($_XDOCTX,'xAmtVar',xdoxslt:get_variable($_XDOCTX,'xAmtVar')+CURRENT_AMOUNT)?>
    3rd column
    <?end for-each?>
    Should I be using <?for each-group?> or something else. My requirement is to set the value of the variable with the running total but because the loop is adding rows for each value it loops through (even though not displayed), it is moving other areas of the layout off the page.
    Hope this makes sense. Thanks in advance.

    you can do it many ways.
    No need to loop
    You can create a variable and put the sum amount directly in that.
    <?doxslt:get_variable($_XDOCTX,'xAmtVar',sum(/AC_GROUP/CURRENT_AMOUNT))?>or
    loop thru and add like you do.
    <?for-each@inlines:AC_GROUP?><?xdoxslt:set_variable($_XDOCTX,'xAmtVar',xdoxslt:get_variable($_XDOCTX,'xAmtVar')+CURRENT_AMOUNT)?><?end for-each?>do give any space or enter character in word between them, just put this in a single form-field will do
    But as i said, i would certainly go with first option.

  • Problem in looping data in variable window

    Hi All,
    I am using loop at and i am displaying data in VAR window. But every time it loops it over writing the data in VAR window and finally its printing only the last record in the loop. Can we loop all the data in the VAR window just like what we do in general for MAIN window.

    Just try to use Text element and give the values to be printed under text element, in print program in  pass the WRITE_FORM with text element in loop and Endloop.
    I think we can not use Variable window to print records from an internal table, suppose if the data in first page is full in variable window, and if u use same variable window in second page, it starts printing from 1st record in second page also.
    Regards
    Bala Krishna

  • Question on how to loop through a variable amount of objects

    I have a csv file which I am parsing with powershell and it works perfectly. I would like to speed it up. Currently, I call a line that is customized for each groups list of subnets.
    I have about 30 groups.
    Some groups have one subnet, some have 5 subnets.
    I want to set up some sort of loop to parse everything while executing a single Import-CSV. Currently I call Import-CSV once per group. It takes me about 2-4 minutes to parse the entire file depending on the speed of the machine.
    The csv file has about 30,000 rows. I am not concerned about running out of resources. This is as much a learning challenge as a desire to make better powershell scripts.
    Below is a portion of the one liner that would parse the entire csv file looking only for those items that match, and writing them out to that groups specific csv file.
    Example #1
    Import-Csv $HostList |  Where-Object {$_."IP Address" -Match "^192.1.*" -or $_."IP Address" -Match "^192.2.*" -or $_."IP Address" `-Match "^192.3.*"  .....}| do more stuff...
    Example #2
    Import-Csv $HostList |  Where-Object {$_."IP Address" -Match "^192.7.*" ....}| do more stuff...
    The example above is just a snippet from code that works perfectly.
    The problem I am asking for help with is, when I loop through the items I am matching against (subnets), if one group has 3 items to match against, another has 1, another has 7, how do I set up such a loop?
    Am I using some sort of 'while'  $_."IP Address" or...?
    Do I create a big 30,000 array (Does PS even use arrays?)
    I would love to know what this type of looping is called, and what I can read with examples on how to understand approaching this challenge..
    Thank you for any help.
    -= Bruce D. Meyer

    The reason for the parsing (I thought I explained it, must have been too vague) is I have about 30 agencies in a csv file.
    Each agency can be determined by their subnet(s) and domain(s)
    I need to put all lines in the csv relating to each agency in their own separate csv file to distribute to them so I am not sharing agency 'A' info with the other 29 agencies.
    I get the regex comment. Thank you. For some reason I am rather hesitant to use PCRE under windows. I'll see how it works.
    Your comment on "Reloading a large file repeatedly takes more time", is the exact reason why I asked the question. I want to get away from that.
    I appreciate your quick reply, I think your example will work nicely. 
    -= Bruce

  • How do I get one tick around a variable

    Problem assigned_to is a character field. I want 406702 to come out as '406702'
    How do I do this. I thought that if I put ''' three ticks around it that would translate to 1.
    IF :P_DEVELOPER_ID IS NOT NULL THEN
         :P_TYPE := ' where info.assigned_to = ''' || :P_DEVELOPER_ID || ''' ;
         END IF;
    Howard

    or may be like this ??
    dev>declare
      2  P_DEVELOPER_ID varchar2(10):='1234';
      3  p_type varchar2(35);
      4  begin
      5   dbms_output.put_line('value before   :'||P_DEVELOPER_ID);
      6 
      7    P_TYPE := ' where info.assigned_to = ''' || P_DEVELOPER_ID || '''' ;
      8   dbms_output.put_line('value after   :'||P_type);
      9  
    10  END ;
    11  /
    value before :1234
    value after : where info.assigned_to = '1234'Message was edited by:
    devmiral

  • Looping around an arraylist of strings to find matches(more complicated!)

    Total Posts: 1
    Help developing an algortim
    Posted: 03-05-2006 07:11 AM
    Hi,
    I have been bashing my head with this for a while, so any help is much appreciated!
    I bascially have ONE arraylist which contains filenames as strings (e.g. file.txt, file1.xml, file2.doc, file2.xml, file2.txt)
    The arraylist bascially contains a document name with there associated metadata document names. For example file1.doc (document file), file1.xml (metedata file).
    There will be siuations where for example file1.doc may not have an associated file1.xml file with it. And there may be situations where there are 2 documents and only one associated metadata file (e.g. file.doc, file1.txt, file1.xml)
    I basiclaly need to loop arond the arraylist identifying only files names that:
    - have an associated metadatafile (once identified put the document name in an arraylist of matches)
    -this arraylist cannot contain duplicate documents with an associated file name (e.g. file.doc, file1.txt, file1.xml), if this particualr situations occurs I want to put these filenames in an arraylist of errors.
    Please help! thanks in advance

    I'm a little lost as to how
    >(e.g. file.doc, file1.txt, file1.xml)
    contains duplicate documents with an associated filename. Either the .txt and .xml are both metadata files, and you are saying that there should never exist two metadata documents of the same name, or else you meant to say
    (e.g. file1.doc, file1.txt, file1.xml)in which case you meant that two data files (the .doc and the .txt) with the same name (file1) cannot exist together if there exists a metadata .xml of the same name.
    Assuming the latter is true, try something like this: (hot off the grill ;)
    import java.util.*;
    public class Blah {
       public static void main(String[] args) {
          List<String> fileNames = Arrays.asList( new String[] {
             "File1.txt", "File2.txt", "File1.xml", "File1.doc", "File1.blah", "File3.doc",
             "File4.xml", "File4.txt", "File5.doc", "File6.doc", "File6.xml", "File7.csv",
             "File7.xsl", "File7.xml", "File8.xml", "File9.doc", "File90.txt"
          String metadataExtension = "xml";
          Map<String, Set<String>> pendingFileNames = new TreeMap<String, Set<String>>();
          Set<String> metadataNamesFound = new TreeSet<String>();
          Map<String, String> verifiedMetadataFileNamePair = new TreeMap<String, String>();
          Map<String, Set<String>> verifiedBadFileNames = new TreeMap<String, Set<String>>();
          Set<String> verifiedFileNamesWithoutMetadata = new TreeSet<String>();
          Set<String> verifiedMetadataWithoutFileName = new TreeSet<String>();
          for (String fileName: fileNames) {
             String[] halves = fileName.split("\\.");
             System.out.println(halves[0]+" "+halves[1]);
             String nameOnly = halves[0];
             String extension = halves[1];
             Set<String> associatedExtensions = pendingFileNames.get(nameOnly);
             if (associatedExtensions == null) {
                associatedExtensions = new TreeSet<String>();
                pendingFileNames.put(nameOnly, associatedExtensions);
             if (extension.equals(metadataExtension)) {
                metadataNamesFound.add(nameOnly);
             } else {
                associatedExtensions.add(extension);
          for (String name: pendingFileNames.keySet()) {
               Set<String> fileExtensions = pendingFileNames.get(name);
               boolean metaNameWasFound = metadataNamesFound.contains(name);
               String fullMetaName = name+"."+metadataExtension;
               if (fileExtensions == null || fileExtensions.size() == 0) {
                 if (metaNameWasFound)
                     verifiedMetadataWithoutFileName.add( fullMetaName );
               } else if (fileExtensions.size() == 1) {
                  String fullFileName = name+"."+fileExtensions.iterator().next();
                  if (metaNameWasFound)
                     verifiedMetadataFileNamePair.put(fullFileName, fullMetaName);
                  else
                     verifiedFileNamesWithoutMetadata.add(fullFileName);
               } else {
                 if (metaNameWasFound)
                     verifiedBadFileNames.put( name, fileExtensions );
                  else {
                    for(String extName: fileExtensions) {
                        verifiedFileNamesWithoutMetadata.add(name+"."+extName);
          System.out.println();
          System.out.println();
          // System.out.println(pendingFileNames);
          System.out.println("Verified one-to-one file/metadata pairs: \n"+verifiedMetadataFileNamePair);
          System.out.println("\nVerified errors (more than one document to one metadata): \n"+verifiedBadFileNames);
          System.out.println("\nVerified metadataless files: \n"+verifiedFileNamesWithoutMetadata);
          System.out.println("\nVerified fileless metadata: \n"+verifiedMetadataWithoutFileName);
    }

Maybe you are looking for

  • Why does iTunes crash on start up after update to OSX 10.6.8?

    To install iOS 7 on my iPhone 4s, iTunes needed to be updated, but before OS needed to be updated to 10.6.8. This is the detailed crash report of iTunes. Any idea? Thanks in advance!! Process:     iTunes [915] Path:        /Applications/iTunes.app/Co

  • Sharing across different subnets

    I have successfully connected a remote PC to my WRV54G using QuickVPN.  That remote PC can ping computers across the VPN and those computers can likewise ping the remote PC.  I have even successfully connected with Remote Desktop from that remote PC

  • Error at debug PL/SQL with object types

    Hi, can someone help me. My context is: Database: Oracle 9.2.0.5. O.S. Solaris 9 SQL Developer: 1.2.1 build 3213 I am trying to debug a package and I am getting this error: Connecting to the database ADMINEW_SERVICIOS. Executing PL/SQL: ALTER SESSION

  • Reader 8.1.3 installer does not start on Windows 2003 x64

    Hello, i use Windows Server 2003 SP2 as 64 Bit edition on AMD and have installed Reader 8.1.2 successfully. Now i tried to install 8.1.3, which is the most recent of the 8th series i found, and fail because the installer simply does nothing! It start

  • Sending out forms

    I have a PDF file I need to send out periodically. I would like to have the recipients be able to fill out the form using their screen and keyboard. What do I need to do to activate trhat capabiity in the document?