Add counter only when duplicate segments are present in mapping

Hi Gurus,
I have a FILE to FILE scenario, and the source file is as this:
aaa aaa aaa
bbb bbb bbb
ccc ccc ccc
ccc ccc ccc
ddd ddd ddd
and the structure will be as:
<Row>
field1> aaa
field2> aaa
field3> aaa
</Row>
<Row>
field1> bbb
field2> bbb
field3> bbb
</Row>
etc
In the target structure, I need to have the same elements, but there is one more field which is a counter field that need to be increased for each repetitive line and then reset back to 1 for a non-unique one.
So regarding the source structure, the target one should be as this:
<Row>
field1> aaa
field2> aaa
field3> aaa
counter> 1
</Row>
<Row>
field1> bbb
field2> bbb
field3> bbb
counter> 1
</Row>
<Row>
field1> ccc
field2> ccc
field3> ccc
counter> 1
</Row>
<Row>
field1> ccc
field2> ccc
field3> ccc
counter> 2
</Row>
<Row>
field1> ddd
field2> ddd
field3> ddd
counter> 1
</Row>
etc
I am asumming that I need to do this using UDF and local variables, but what I don't know is how can I compare the actual Row data with the previous one so I can increase the counter (or reset it).
Any idea on what can I do here?

Hi,
  You can try the below logic to get the counter incremented according to the row. For all fields its simple one to one mapping except counter.
   Row----Row
   field1---field1
   field2---field2 etc
for counter concat field1,field2,field3 with empty delimiter ...
concatinationof3fields--removecontext-sort-splitbyvaluechange-UDF-splitbyeachValue--counter
**execution type of UDF is Allvalues of a context.
public void UDF(String[] var1, ResultList result, Container container) throws StreamTransformationException{
          ArrayList aList =  new ArrayList();
     int counter = 1;
     int cnt = 1;
     for(int i=0; i<var1.length; i++){
              if(aList.contains(var1<i>)){
          cnt++;
          result.addValue(cnt);
                             else{
          aList.add(var1<i>);
          result.addValue(counter);
Regards
Priyanka

Similar Messages

  • Callback function may be NULL only when database handles are read-only

    Hi,
    I am getting some errors when trying to run my java code that will try to open a few cursors and join them to fetch the data.
    ath .:/usr/src/db-4.7.25.NC/java/src:/usr/local/BerkeleyDB.4.7/lib/db.jar bdbtest
    MyDbs: Callback function may be NULL only when database handles are read-only
    Error on inventory secondary cursor:
    java.lang.IllegalArgumentException: Invalid argument: Callback function may be NULL only when database handles are read-only
    What does that error mean? How can I resolve it? I am following the sample program and I can't find anything related.
    Here is my code.
    import com.sleepycat.db.DatabaseException;
    import com.sleepycat.db.Database;
    import com.sleepycat.db.SecondaryDatabase;
    import com.sleepycat.db.DatabaseConfig;
    import com.sleepycat.db.DatabaseType;
    import java.io.FileNotFoundException;
    import com.sleepycat.db.DatabaseEntry;
    import com.sleepycat.db.SecondaryCursor;
    import com.sleepycat.db.Cursor;
    import com.sleepycat.db.DatabaseException;
    import com.sleepycat.db.LockMode;
    import com.sleepycat.db.OperationStatus;
    import com.sleepycat.db.SecondaryCursor;
    import com.sleepycat.db.SecondaryConfig;
    import com.sleepycat.bind.EntryBinding;
    import com.sleepycat.bind.serial.SerialBinding;
    import com.sleepycat.bind.tuple.TupleBinding;
    import com.sleepycat.db.Cursor;
    import com.sleepycat.db.DatabaseEntry;
    import com.sleepycat.db.DatabaseException;
    import com.sleepycat.db.LockMode;
    import com.sleepycat.db.OperationStatus;
    import com.sleepycat.db.SecondaryCursor;
    public class bdbtest {
    public static void main(String args[]) {
    SecondaryDatabase myDatabase = null;
         Database primDB = null;
         Cursor cursor = null;
    try {
    // Open the database. Create it if it does not already exist.
    DatabaseConfig dbConfig = new DatabaseConfig();
         dbConfig.setErrorStream(System.err);
    dbConfig.setErrorPrefix("MyDbs");
         dbConfig.setType(DatabaseType.BTREE);
    dbConfig.setAllowCreate(true);
         SecondaryConfig mySecConfig = new SecondaryConfig();
         mySecConfig.setErrorStream(System.err);
    mySecConfig.setErrorPrefix("MyDbs");
         mySecConfig.setType(DatabaseType.BTREE);
    mySecConfig.setAllowCreate(true);
         primDB = new Database("/tmp/bdb_ca_db.db",
    "bdb_ca_db",
    dbConfig);
    dbConfig.setAllowCreate(true);
    myDatabase = new SecondaryDatabase("/tmp/bdb_ca_sdb.db",
    "ca_sdb_res_alias",
    primDB,
    mySecConfig);
         String res ="in-1";
         SecondaryCursor secCursor = null;
         DatabaseEntry searchKey =
    new DatabaseEntry(res.getBytes("UTF-8"));
         DatabaseEntry foundKey = new DatabaseEntry();
    DatabaseEntry foundData = new DatabaseEntry();
         secCursor =
    myDatabase.openSecondaryCursor(null, config);
    // Search for the secondary database entry.
    OperationStatus retVal =
    secCursor.getSearchKey(searchKey, foundKey,
    foundData, LockMode.DEFAULT);
         if (retVal == OperationStatus.SUCCESS){
              System.out.println("succ");
         }else {
              System.out.println("fail");
    while (retVal == OperationStatus.SUCCESS) {
    String keyString = new String(foundKey.getData(), "UTF-8");
    String dataString = new String(foundData.getData(), "UTF-8");
    System.out.println("Key | Data : " + keyString + " | " +
    dataString + "");
    secCursor.getNextDup(searchKey, foundKey,foundData, LockMode.DEFAULT);
         } catch (Exception e) {
    System.err.println("Error on inventory secondary cursor:");
    System.err.println(e.toString());
    e.printStackTrace();
         finally {
    // Make sure to close the cursor
              try {
              cursor.close();
              }catch (com.sleepycat.db.DatabaseException e) {
    System.out.println("All done.");
    }

    Hi,
    The error is because either the primary database or the secondary database is configured as read only and the callback to create the secondary keys is null. A quick glance of the code, it appears as if you did not set up the secondary database correctly. In the Getting Started Guide for JAVA API chap 10, we have detailed information on what needs to be done as well as a code example. Please refer to http://www.oracle.com/technology/documentation/berkeley-db/db/gsg/JAVA/index.html and look for Chap 10.
    regards,
    Mike Brey, Oracle Berkeley DB

  • Count only when a external TTL signal is high

    Hallo,
    I'm using LabView 6.1 on WinXP with a NI6014 DAQ Board...
    I have to count a some TTL pulses only when another TTL signal is high (start the count when the signal goes high and stop it when the signal goes low). Can I program the DAQ to do this (like a gate function) so that in the meanwhile my program can do other things, and only at the end I read the result of the count?
    Thank you,
    Pixo

    Hello Pixo,
    Thank you for your inquiry regarding counters on the PCI-6014. It sounds like you would like a gate function for the counter that you are using. There is a gate for each counter that enables the counter when the gate line is high and disables the counter when this line is low. The I/O connector pin assignment and signal descriptions can be found here . To use the counter you must first configure it and then use a Counter Start VI. Then when the gate is high the counter will increment and the value can be read at the end of the program like you had stated. I have attached a great example VI to get you started with counters. Other examples like this can be found in LabVIEW 6.1 under �Find Examp
    les from the LabVIEW startup screen.
    I hope these resources help. Let me know if I can further assist you.
    Shea C.
    Applications Engineering
    Attachments:
    Getting_Started_Counters.vi ‏64 KB

  • Email notification to end-user only when both resources are provisioned

    Hello Gurus,
    My client has a requirement where the end-user needs to be sent an email notification as soon as his account gets created in OID and EBS.
    So the next time when the user logs in; he should be able to access both his accounts. But the email should be sent only when the 2 accounts are succesfully created.
    How can we do that by means of process tasks and adapters?
    Can anybody give an idea about how can we provide this functionality in the best way OOTB or custom way (code snippet) ?
    Thanks,
    - JHB.

    Hi
    If you are using OOTB connectors for OID and EBS then this requirement can be achieved by using OIM API.
    On successful response of 'Create user' in OID or EBS call a custom adapter and check for the provisioned status of other RO i.e. on completion of Create User task of OID, check for prov status of EBS and send the mail accordingly.
    If the user is not provisioned to the other resource, then do not send the mail. Otherwise if the user is already provisioned to the other resource, send the mail to the user. This approach is based on the assumption that there is no link between the provisioning to OID and provisioning to EBS.
    Correct me if I missed something.
    Hope this helps.

  • Ghost clip appears in canvas only when other clips are placed in its place

    Gd afternoon, this may sound crazy but here we go. the space on the timeline is blank, and when the sequence is played the blank section shows nothing but black screen. however when i drop any clip in the empty space on the timeline an old clip I changed the speed of shows over whatever clip i just dropped in the empty spot. Again, when the spot is empty nothing shows, only when a different clip is placed in that spot does the "ghost" clip appear over the new clip and the space that the ghost clip holds shows a blue rendered line for the speed that was changed.
    How do I get rid of this ghost clip?

    +thanks, i tried to delete the rendered clip but no help+
    No, what is required when the problem reaches the stage you described is to delete ALL of the render files for that sequence. One way to do that is to go to Tools > Render Manager and navigate to the problem sequence and clicking in the Remove column for that sequence. Then click OK.
    That will delete all of the render files for the sequence. Then you re-render. This sometimes works, as I said.

  • Add value only when true

    hi I am making an array with the iteration values of for loop by chechking the conditions and i want it to be done only when my condition is true.
    But now what is hapenning is that if the condition is false 0 is over wirrting my values.
    And also i have put two for loops inside a for loop.
    the second for loop is running to the first loop iterations.
    thanks in advance
     I am adding the vi i have made .
    @nk
    Attachments:
    get excel data.vi ‏37 KB
    get excel data.vi ‏37 KB

    Hi @nk
    That's because you have set "Use default if unwired" on the output tunnel of the Case Structure.
    Hence if the condition is true, it will only output an array of only 1 iteration value at the output tunnel of the most inner For Loop
    And if the condition is false, it will output an array with default value of 0 at the output tunnel of the most inner For Loop.
    Also, it seems that 2nd For Loop does not have the auto-indexing feature enabled in the output tunnel, which only generate a 2D array, instead of 3D array in the Array 3 indicator. I wonder if generating 2D array output for the Array 3 indicator is what you want, but if you want to generate 3D array output, you should enable the auto-indexing feature for the 2nd For Loop.
    And what you also should do is using the auto-indexing with conditional tunnel in the inner For Loop to automatically generate an array of iteration values if the elements in array is greater than the max value you've set as shown in the screenshot below for simple illustration.
    Here is the link for more information about auto-indexing with conditional tunnel: http://zone.ni.com/reference/en-XX/help/371361K-01/lvhowto/condacc_valuesnloops/
    Ee Lim
    See that button on the left side of this post...
    If you feel my post is helpful, all you need is just (at most) 2 seconds to click that button, to show your appreciation. Thank you~~

  • DLL created with LV 7.1 Application Builder doesn,t work when analysis subVIs are present

    I'm looking for a solution of the following problem.
    The DLL created by the "sum1.vi" source works properly, while the DLL create by "sum2.vi" always gives a zero result.
    The "sum2.vi" source contains an additional "Hanning Window" VI (not wired), that seems to be the cause of the problem.
    If I delete the Hanning VI and re-build the DLL, the same works fine
    Is there a solution or is it not possible to make Labview DLLs when containing analysis VIs as filters, windows, FFTs, and so on?
    Thank you for your answers.
    N. Roberto
    Attachments:
    sum1.vi ‏12 KB
    sum2.vi ‏14 KB

    Roberto N. wrote:
    Thank you Jordan, I'm using Labview 7.1.
    Anyway I've resolved the problem by adding the "lvanlys.dll" file (present in "..\Labview 7.1\resource\lvanlys.dll" path) as support file in the building process. Now the DLL containing the analysis functions works correctly.
    Natalino Roberto
    Ok, you probably got lucky since the lvanlys.dll seems to implement that function directly. However most Advanced Analysis functions are just redirected by lvanlys.dll to the Intel Math Kerneal Library that gets installed with LabVIEW 7.1 and higher. The only way to get that properly installed with your LabVIEW executable or DLL is to create a LabVIEW installer in your Application Builder and make sure to select under "Installer Settings->Advanced" the "LabVIEW Run-Time Engine" and the "Analyze VIs Support". Then use that installer to install your DLL on another computer.
    Rolf Kalbermatter
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • How to add actions only when the stage playhead passes a label/certain time?

    I have an animation that is 2 seconds long. On the 1 sec mark there is sym.stop(); and a label called 'in'. At the 2 sec mark there is another sym.stop();
    So what I want to happen is for the animation to play up until 'in', then on mouseenter for the stage have sym.play();, and on mouseleave sym.playReverse();. This will make it so that only the second half of the animation will get played on mouseenter/leave.
    My problem is that the mouseenter/leave also gets applied to the first half of the animation, not allowing the second half to animate if the user mouses over during the first half. I know this requires an if statement but I don't know how to write it. So it would be something like this: if the playhead reaches 'in', apply mouseenter/leave actions.

    yes, I am. By the way I've found the solution. Someone might find this usefull.
    In design.xml having
    <component name="ExtendedTextInput" namespace="mynamespace" category="beta" displayName="ExtendedTextInput"/>
    use this
    <component name="ExtendedTextInput" namespace="mynamespace" category="beta" displayName="ExtendedTextInput">
            <defaultAttribute name="text" value="ExtendedTextInput"/>
        </component>
    so when adding this component to design view, it will have text setted to value ('ExtendedTextInput' in this case).

  • How to add missing playlist, when my tunes are in my hd

    I have done a data recovery of my tunes, and brought the recover files back to itunes, and somehow itunes transferred my tunes to the media folder, but said there was not enough space on my Hd, so I deleted some of the recovered files i thought were not needed to give space for the transfer to the media folder, then i find, yes the media folder saves space, and my tunes are in the library, but all my previous playlists are gone, I probably removed then, trying to create space, the recovered tunes are on a back up drive, but what particuliar files do i use to get my playlist back, without re instaling everything, and considering my tunes are in the media folder already, Any one got a answer that `i could understand, I would be grateful. thanks.......!!!!!!

    My server went offline at thursady 6.00 PM and became online at sunday 12.30 PM.
    Users still waiting for emails on that period. Does it take this much time normally ? or is it depending on the external mail server configuration?
    As noted - it can take up to 3 days to resend mail depending on how the servers are configured.  Usually all mail is delivered within 24 hours and no sooner.
    There is no script or way we can help you with this.  Call you ISP or your vendor for more help on how to administer Internet mail. 
    Your outage may guarantee that you will have lost at least a days mail.  Call the senders and ask them to send it again. 
    As Bill has pointed out - this is not a scripting question but is a question about how to manage a mail server.
    ¯\_(ツ)_/¯

  • Issue warning message when duplicate material are enter on a purchase order

    Hi All,
    Is there any possibility  to give a message in   me21n if we enter a material which in already maintained as one line item  to create PO. To issue messages in sales order there is an exit. I tried with the badi ME_PROCESS_PO_CUST. I was struck here. Please suggest me good idea how to do this.Thanks to all.
    In Sales order i resolved in this way.
    LOOP AT xvbap
       WHERE matnr EQ vbap-matnr
             AND posnr NE vbap-posnr
             AND kwmeng NE 0.
       MESSAGE  'Material is already on the order' type 'I'.
    ENDLOOP.
    ENDFORM.
    Regars,
    Madhu.

    closed.

  • Code compiles only when static methods are defined in a certain order

    CC: Sun C++ 5.9 SunOS_i386 Patch 124864-10 fails to compile the code below with
    "/tmp/notagain.cc", line 9: Error: static X::decode<X::T>() already had a body defined.
    "/tmp/notagain.cc", line 13: Error: Cannot use int* to initialize double*.
    struct X
        static int* decode(int Val);
        static int* decode();
        template<typename T> static T* decode() { return new T; }
    int* X::decode(int t) { return new int(t); }
    int* X::decode() { return new int; }
    int main() {
            int* pi = X::decode();
            double* pd = X::decode<double>();
            return 0;
    }It actually manages to compile it if the struct X is defined slightly differently:
    struct X
        static int* decode(int Val);
        template<typename T> static T* decode() { return new T; }
        static int* decode();
    int* X::decode(int t) { return new int(t); }
    int* X::decode() { return new int; }
    int main() {
            int* pi = X::decode();
            double* pd = X::decode<double>();
            return 0;
    }None of this happens with g++ or Intel C++.

    Thanks for filing the bug report. It has been assigned CR 6935439, and should be visible at [http://bugs.sun.com] in a day or two.

  • GetMicrophone when multiple mics are present

    I'm trying to stream a webcam with a built-in microphone. The
    code is:
    var camera:Camera = Camera.getCamera();
    var mic:Microphone = Microphone.getMicrophone();
    But the system has two mics, a built in one on the sound card
    and one in the camera. getMicrophone should return the default mic
    which is set in the security panel, but no matter what setting is
    in the security panel it always returns the first microphone as if
    I'd called Microphone.getMicrophone(0). If I pass the microphone
    index to getMicrophone it works.
    I've read various other reports of this behaviour. Does
    anyone know of a solution?
    Thanks

    In AS3 getMicrophone passes 0 as the default value. If you
    know the name of the microphone you want to capture, you can use
    the Microphone.names property to get an array of the available
    Microphones and then use that to set the index for
    getMicrophone.

  • Crystal Report Alerts not firing when no records are fetched from the DB

    Hello,
    The crystal report alert i have created in the report in the event of no records being fetched from the query is not firing.  The condition used is isnull ( count(DB Field ) ).
    Is there a limitation with alerts that they would be fired only when some records are fetched in the report.
    Appreciate any pointers
    -Jayakrishnan

    hi Jayakrishnan,
    as alerts require records to be returned here's what you will need to do:
    1) delete your current alert
    2) create a new formula with syntax like
                  isnull(DistinctCount ()) or DistinctCount () = 0
    3) create a new Subreport (which you will put in a report header)
    4) the subreport can be based off of any table
    5) have the subreport record selection always return only 1 record...for performance reasons
    6) change the subreport link to be based on the new formula
    7) the link will be a one way link in that you will not use the "Select data in subreport based on field" option
    8) now in the subreport, create the Alert based on the parameter created by the subreport link
    i have tested this and it works great.
    jamie

  • SCCM 2012 powershell only when no user is logged in

    Hi All,
    I think this is probably me, I am trying to run a powershell script which calls an MSI in the Application node, seems to work fine when the user is logged on, but I wanted to run this as, only when no user is logged on, and install for system. It seems to
    start and just exit straight away.
    Command line: that I use: powershell.exe -noprofile -executionpolicy bypass -file .\Install.ps1 is this correct to run as system?

    I'm also having a very similar issue. In my scenario, I have a PowerShell script that runs an software update tool with different parameters based on the value of a specific registry entry. I was testing the SCCM Application when logged on and just running
    for Software Center and it runs as expected, but when I changed the User Experience from "Run whether or not a user is logged on" to "Only when no users are logged on" and it fails.  In the AppEnforce.log the following lines are present:
    <![LOG[+++ Starting Install enforcement for App DT "Set New Servers - addiman" ApplicationDeliveryType - ScopeId_2E6C34BD-8633-43D8-B5B5-09A1C291D45B/DeploymentType_56ca55b4-ce9b-4dfd-a64f-db3da408013b, Revision - 5, ContentPath
    - C:\WINDOWS\ccmcache\3n, Execution Context - System]LOG]!><time="11:06:10.878+480" date="02-12-2015" component="AppEnforce" context="" type="1" thread="1628" file="appprovider.cpp:1702">
    <![LOG[The enforcement of this App DT requires all users to be logged off.  The deployment cannot specify a user collection when the deployment type requires that a user must be logged off.  Aborting enforcement.]LOG]!><time="11:06:10.879+480"
    date="02-12-2015" component="AppEnforce" context="" type="3" thread="1628" file="appprovider.cpp:1732">
    <![LOG[CommenceEnforcement failed with error 0x87d0031d.]LOG]!><time="11:06:10.880+480" date="02-12-2015" component="AppEnforce" context="" type="3" thread="1628" file="appprovider.cpp:1825">
    <![LOG[Method CommenceEnforcement failed with error code 87D0031D]LOG]!><time="11:06:10.880+480" date="02-12-2015" component="AppEnforce" context="" type="3" thread="1628" file="appprovider.cpp:2390">
    <![LOG[++++++ Failed to enforce app. Error 0x87d0031d. ++++++]LOG]!><time="11:06:10.885+480" date="02-12-2015" component="AppEnforce" context="" type="3"
    thread="1628" file="appprovider.cpp:2467">
    I've did confirm that the Deployment was not to a User Collection as is implied by the error message and I even went as far as deleting and recreating the Deployment.
    In addition, I have another Application (Java 7 Update 31) that I have set to "Only when no users to login" and it installs as expected. When run from Software Center the Status changes to "Waiting for users to log off" and it is installed
    after I log off.
    Is there some issue with this when trying to run a PowerShell script when logged off?
    Thank you in advance for any insight as to this in consistent behavior.
    Bill Hunt

  • Query all to display but count only certain criteria

    using the following sql statement i can get all the information i want. However since i am decoding the salary_wage how do i count only those items that are over a certain dollar amount?
    select lss.job_order_no,
         jo.business_no,
         bs.business_name,
         li.industry_name,
         lj.job_title,
         js.office_id,
         jo.salary,
         jo.salary_type,
    decode (JO.salary_type,'MONTHLY',JO.salary/173.34,
              'BIWEEKLY',JO.salary/80,
              'HOURLY',JO.salary,
         'ANNUAL',JO.salary/2080) as salary_wage
    from link_status_seeker lss,job_order jo,business bs,look_industry li,link_job_order ljo,look_job lj,job_seeker js
    where lss.status_date between '06-APR-04' and '20-APR-04'
    and jo.job_order_no = lss.job_order_no
    and jo.business_no = bs.business_no
    AND bs.INDUSTRY_ID = li.INDUSTRY_ID
    AND ljo.JOB_ORDER_NO = jo.JOB_ORDER_NO
    AND ljo.JOB_ID = lj.JOB_ID
    and js.seeker_id = lss.seeker_id
    -- and lss.status_id = 105 105 is hired

    I dont think your question is clear.
    Do you mean you want to put where clause that looks like:
    where decode (JO.salary_type,'MONTHLY',JO.salary/173.34,
    'BIWEEKLY',JO.salary/80,
    'HOURLY',JO.salary,
    'ANNUAL',JO.salary/2080) > <some amount>
    ? if yes, you can do it.
    -Bipin.

Maybe you are looking for

  • How to call a function from Java to JSP

    Hello, I have a question about using tags. I have a java file,which has a function. Now I want to call this function into my JSP page. I'm using JSP 1.2 and TOMCAT 4.1 with Java2 SDK. I search through the web and find a method to do this.Bu it requir

  • New problem in page setup; custom sizes

    Although previously working fine, while using Pages, custom page set up settings aren't taking effect. Trying to do a business card setting of 3.54 x 2.05 with no margins. It always comes back with a 8 1/2" x 11" page. I restarted pages, then reboote

  • Using checkbox

    Hi, I have quiet a few number of checkboxes in my form , and i need to get the values of the checked ones instead of writing code like the below , is there any option by which i can get the checked ones? like i want a string containing values of chec

  • Camera Raw won't find update in CS6

    I currently have Photoshop CS6 running on 32 bit Windows Vista.  My current Camera Raw version is 7.0.0.308.  I need version 7.4 (which is compatible with my camera) Obviously, everybody in previous posts have said to use the update tool.  Well for s

  • How to make cell editable in new alv

    hi experts: i'm use cl_salv_table=>factory to display data, but I can't make some cell or column editable,does any body can help me?thanks!