Results 1 to 7 of 7

Thread: Isolate Multiple Occurance of Same Records - BSFN

  1. #1
    New Member
    Join Date
    Dec 2017
    Posts
    20

    Exclamation Isolate Multiple Occurance of Same Records - BSFN

    Hello,

    I need to read through an array in a C++ BSFN and either write to another array or file the multiple occurances,.....below is an example of the data.....

    Thank you for any help....

    Array1: What I need in Array 2:
    1111111 1111111
    1111111 1111111
    1111111 1111111

    2222222 4444444
    3333333 4444444
    4444444 5555555
    4444444 5555555
    5555555
    5555555
    6666666
    7777777
    8888888
    9999999
    Last edited by FrankCLT; 09-29-2018 at 08:05 PM.

  2. #2
    Senior Member
    Join Date
    Mar 2004
    Location
    Fort Worth, Texas
    Posts
    1,492
    Easiest way would be to use jdeCache since you can create a unique index on the field(s) in the struct that will help you find the duplicates.
    Brian Oster
    Application Development Manager
    E1: 9.0 (TR9.1.5.1) / 9.2 (TR9.2.2.2)
    JAS/BSSV: Weblogic 12.1.2 / Weblogic 12.2
    ES: Win2008 / Win2016
    DB: MSSQL 2014 / 2016
    WebDev Client: Win7Pro / Win10Pro

  3. #3
    New Member
    Join Date
    Dec 2017
    Posts
    20
    Below is actual sample data.......the end goal is to take data from array aBoxTrkA and populate aBoxTrkD with only the multiple occurrences. The red highlight in aBoxTrkA is the only record that would NOT be written to aBoxTrkD because it occurs just once. I will add the code shortly....and a Visual Studio Debug....


    Thanks again,
    FrankCLT




    aBoxTrkA
    0 085085000303985330 1Z8R9A510346043690
    1 085085000303985330 1Z8R9A510347631301
    2 085085000303985330 1Z8R9A510347814159
    3 085085000303985330 1Z8R9A510347957540
    4 085085000303985507 1Z8R9A510346913571
    5 085085000303985507 1Z8R9A510347894671
    6 085085000303985521 1Z8R9A510346303480
    7 085085000303985521 1Z8R9A510347934163
    8 085085000303985620 1Z8R9A510346043690

    9 085085000303985637 1Z8R9A510346408331
    10 085085000303985637 1Z8R9A510348212726
    11 085085000303985729 1Z8R9A510347053436
    12 085085000303985729 1Z8R9A510347622311




    aBoxTrkD
    0 085085000303985330 1Z8R9A510346043690
    1 085085000303985330 1Z8R9A510347631301
    2 085085000303985330 1Z8R9A510347814159
    3 085085000303985330 1Z8R9A510347957540
    4 085085000303985507 1Z8R9A510346913571
    5 085085000303985507 1Z8R9A510347894671
    6 085085000303985521 1Z8R9A510346303480
    7 085085000303985521 1Z8R9A510347934163
    8 085085000303985637 1Z8R9A510346408331
    9 085085000303985637 1Z8R9A510348212726
    10 085085000303985729 1Z8R9A510347053436
    11 085085000303985729 1Z8R9A510347622311
    Attached Images Attached Images
    Last edited by FrankCLT; 10-01-2018 at 01:01 PM.

  4. #4
    New Member
    Join Date
    Dec 2017
    Posts
    20
    Here is the snippet of code:

    Code.JPG
















    Results from above loop
    DebugStep.JPG




















    This is what the above debug should look like......index from 0 - 11, no missing entries.

    aBoxTrkD
    0 085085000303985330 1Z8R9A510346043690
    1 085085000303985330 1Z8R9A510347631301
    2 085085000303985330 1Z8R9A510347814159
    3 085085000303985330 1Z8R9A510347957540
    4 085085000303985507 1Z8R9A510346913571
    5 085085000303985507 1Z8R9A510347894671
    6 085085000303985521 1Z8R9A510346303480
    7 085085000303985521 1Z8R9A510347934163
    8 085085000303985637 1Z8R9A510346408331
    9 085085000303985637 1Z8R9A510348212726
    10 085085000303985729 1Z8R9A510347053436
    11 085085000303985729 1Z8R9A510347622311

















    Last edited by FrankCLT; 10-01-2018 at 01:05 PM.

  5. #5
    New Member
    Join Date
    Dec 2017
    Posts
    20
    Maybe I'm complicating things.....how would i find distinct items in the array....the red would be the distinct record.


    aBoxTrkA
    0 085085000303985330
    1 085085000303985330
    2 085085000303985330
    3 085085000303985330
    4 085085000303985507
    5 085085000303985507
    6 085085000303985521
    7 085085000303985521
    8 085085000303985620
    9 085085000303985637
    10 085085000303985637
    11 085085000303985729
    12 085085000303985729

  6. #6
    Member
    Join Date
    Mar 2002
    Location
    Minneapolis, MN
    Posts
    774
    To avoid the "missing" indexes, use a separate counter variable that only increments when you get inside your 'if' statement. use that variable instead of j when you are assigning to your D array: aBoxTrkD[newvar].
    Jeremy
    E1 Consultant
    Minneapolis, MN

  7. #7
    You can do this in two loops. Create a struct that has a key and a counter. The key will contain the first part of the string. In the first loop, you create an array of this struct that should look like this:

    [0] => {key: "085085000303985330", count: 4 }
    [1] => {key: "085085000303985507 ", count: 2 }
    ..
    ..

    Then, you loop through this array to pick the ones from the original array. You skip the ones that have count < 2.


    I know this is not relevant to your question, but you can do this in one line in C#:

    List<string> list = new List<string>() {
    "085085000303985330 1Z8R9A510346043690",
    "085085000303985330 1Z8R9A510347631301",
    "085085000303985330 1Z8R9A510347814159",
    "085085000303985330 1Z8R9A510347957540",
    "085085000303985507 1Z8R9A510346913571",
    "085085000303985507 1Z8R9A510347894671",
    "085085000303985521 1Z8R9A510346303480",
    "085085000303985521 1Z8R9A510347934163",
    "085085000303985620 1Z8R9A510346043690",
    "085085000303985637 1Z8R9A510346408331",
    "085085000303985637 1Z8R9A510348212726",
    "085085000303985729 1Z8R9A510347053436",
    "085085000303985729 1Z8R9A510347622311"
    };

    var result = list.GroupBy(x => x.Substring(0, x.IndexOf(" "))).Where(y => y.Count() > 1).SelectMany(x => x).ToList();

    That's it. :-)
    Regards,

    Hari Sharma
    Aellius
    EnterpriseOne: Integration (.Net, Web Services) | Output Management | Monitoring

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
The legal restrictions and terms of use applicable to this site are available here.
Use of this site signifies your agreement to the terms of use.
JDELIST is NOT affiliated with JD Edwards® & Company, Oracle or Peoplesoft. Contents of this site are neither endorsed nor approved by JD Edwards® & Company and, or Oracle.