Ignore if double... how is it?

julkifli33julkifli33 Member Posts: 1,087
i have data like this
200,201,202,203,200,201,204

200 and 201 is double
so the data is become 200,201,202,203,204
ignore if it's double

my code
    REPEAT
      ItemVar := ItemVar + "No." +'|';
    UNTIL NEXT = 0;
can someone add something?

Comments

  • kapamaroukapamarou Member Posts: 1,152
    I usually do the following: find a table with a primary key of integer or code (table integer for instance), declare it as temporary, loop through the data and do an if tmprec.INSERT THEN; This leaves a temp record variable with only unique values that I can use to loop.

    But I don't use it to build a text filter. When I need something similar I use either mark or (mainly) temporary records. But it's your choice from that point on.

    Hope it helps.
  • julkifli33julkifli33 Member Posts: 1,087
    this is not the key field
    i want to cacth "item no." from item ledger entry table
    but i want to do grouping...
    so it is not double...
  • kapamaroukapamarou Member Posts: 1,152
    What I suggested is a way to store the unique values. What you do with them is your choice. I don't understand grouping. If it is for a report you can select a key that starts with item no. and use group sections. If it is for a code part you can loop through the records and for each new record compare the field you want with the previous value. What are you trying to achieve exactly?
  • julkifli33julkifli33 Member Posts: 1,087
    because i never use temporary table
    so i create variable text = 1024
    and then i can filter the table using that variable
    but it is lack of length in my case...because there are double entry for filtering
    so i think... if it is not double... it can be okay
    it is like if you want to filter data using 200|201|202
    something like that
  • vijay_gvijay_g Member Posts: 884
    julkifli33 wrote:
    this is not the key field
    but i want to do grouping...

    crazy.....
    how can u grouping until key is not defined for that field?
  • julkifli33julkifli33 Member Posts: 1,087
    vijay_g wrote:
    julkifli33 wrote:
    this is not the key field
    but i want to do grouping...

    crazy.....
    how can u grouping until key is not defined for that field?

    it is only for the filtering.....
    item table = 200,201,202,203,204....
    item ledger entry table = 200,201,200,200,201,203,202,203,200....

    may be transaction like that
    so i want filtering by group from item ledger entry table to item table
  • vijay_gvijay_g Member Posts: 884
    then what's problem?
    either you can insert in temp table or in text var.
  • julkifli33julkifli33 Member Posts: 1,087
    vijay_g wrote:
    then what's problem?
    either you can insert in temp table or in text var.


    REPEAT
    ItemTemp."No." := "No.";
    ItemTemp.SETRANGE("No.");
    IF NOT FIND('-') THEN
    ItemVar := ItemVar + ItemTemp."No." +'|';
    UNTIL NEXT = 0;
    MESSAGE('%1',ItemVar);

    still double
    do you know what i mistaken?
  • SogSog Member Posts: 1,023
    because you don't insert your not found record into the temporary table
    REPEAT
    ItemTemp."No." := "No.";
    ItemTemp.SETRANGE("No.");
    IF itemtemp.isempty THEN begin
      ItemVar := ItemVar + ItemTemp."No." +'|';
      itemtemp.insert;
    end;
    UNTIL NEXT = 0;
    MESSAGE('%1',ItemVar);
    
    |Pressing F1 is so much faster than opening your browser|
    |To-Increase|
  • kapamaroukapamarou Member Posts: 1,152
    What I would do is:
    REPEAT
    ItemTemp."No." := "No.";
    ItemTemp.SETRANGE("No.");
    IF itemtemp.isempty THEN begin
      IF ItemVar = '' THEN 
        ItemVar := ItemTemp."No." ELSE
        ItemVar := ItemVar +'|' + ItemTemp."No.";
      itemtemp.insert;
    end;
    UNTIL NEXT = 0;
    MESSAGE('%1',ItemVar);
    

    To avoid having to trim the last '|' .

    But I strongly believe that building a filter like this should be avoided. It is very easy to get text overflow errors. If you investigate the usage of temporary tables I think you will find better solutions.
  • David_SingletonDavid_Singleton Member Posts: 5,479
    julkifli33 wrote:
    this is not the key field
    i want to cacth "item no." from item ledger entry table
    but i want to do grouping...
    so it is not double...


    I think the first step is to work out what you want. Your FIRST post should contain all the important information. If it doesn't then you just waste other peoples time when they try to help you. Try again and post EVERYTHING, if the information is confidential and top secret, then forums are not the place to ask for help.
    David Singleton
  • pduckpduck Member Posts: 147
    Hi, why not using the MARK(TRUE) feature on the item table for every found Item? After the loop you can filter on only the marked ones and do what ever you want with these marked Item Records (another loop, building a filter, modifying something).
  • David_SingletonDavid_Singleton Member Posts: 5,479
    The problem is that the OP is not really sure what the customer requirement is. Or at least if he does, he is not able to clearly express the requirement. Thus any replies can not really help.

    First step is to understand the need and clearly document it.

    THEN try and solve it. Here again we have a business requirement turning into a code issue.
    David Singleton
  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    The problem is that the OP is not really sure what the customer requirement is. Or at least if he does, he is not able to clearly express the requirement. Thus any replies can not really help.
    Yes David, you have made your point already. There is no need to repeat yourself.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • David_SingletonDavid_Singleton Member Posts: 5,479
    The problem is that the OP is not really sure what the customer requirement is. Or at least if he does, he is not able to clearly express the requirement. Thus any replies can not really help.
    Yes David, you have made your point already. There is no need to repeat yourself.

    I know. ](*,) ](*,) ](*,) ](*,) ](*,)

    Maybe 3 months was not a long enough break for me to learn.

    :-#
    David Singleton
Sign In or Register to comment.