Loop a table without SETRANGE

hungryandfoolhungryandfool Member Posts: 114
Dear Experts,

I have a requirement to loop an entire table ("User" table). For the same I just did a FIND('-') on the table record variable and put the record variable in the REPEAT - UNTIL NEXT = 0 structure. But the mentioned structure only accesses te first record of the table. May be since I am not using SETRANGE so the REPEAT - UNTIL NEXT = 0 is only accessing the first record.
Can you help me out with the issue?
Thanks a lot.

Answers

  • MBergerMBerger Member Posts: 413
    Can you post your code ? With just this description we can't tell you what is wrong ( although i SUSPECT you might have forgotten to add the tablename to your NEXT=0, which is something i see consultants who try to program do often )
  • hungryandfoolhungryandfool Member Posts: 114
    Hi MBerger,
    Thanks for replying.
    MBerger wrote:
    Can you post your code ? With just this description we can't tell you what is wrong ( although i SUSPECT you might have forgotten to add the tablename to your NEXT=0, which is something i see consultants who try to program do often )

    My code is as follows:


    User.RESET();
    IF User.FIND('-') THEN BEGIN
    REPEAT
    GenJouBtch.RESET();
    GenJouBtch.SETRANGE("Journal Template Name",'JOURNAL VO');
    GenJouBtch.SETRANGE(User,User."User ID");
    IF NOT GenJouBtch.FIND('-') THEN BEGIN
    GenJouBtch.INIT();
    GenJouBtch."Journal Template Name" := 'JOURNAL VO';
    GenJouBtch.Name := User."User ID";
    GenJouBtch.Description := FORMAT(User."User ID")+' '+FORMAT('Batch');
    GenJouBtch."Bal. Account Type" := GenJouBtch."Bal. Account Type"::"G/L Account";
    GenJouBtch."No. Series" := 'UJV/HO';
    GenJouBtch."Posting No. Series" := 'JV/HO';
    GenJouBtch."Copy VAT Setup to Jnl. Lines" := TRUE;
    GenJouBtch."Allow VAT Difference" := FALSE;
    GenJouBtch."Sub Type" := GenJouBtch."Sub Type"::"Journal Voucher";
    GenJouBtch.User := User."User ID";
    GenJouBtch."Template Type" := GenJouBtch."Template Type"::General;
    GenJouBtch.Recurring := FALSE;
    GenJouBtch.INSERT();
    END;
    UNTIL GenJouBtch.NEXT=0;
    END;
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    UNTIL GenJouBtch.NEXT=0;
    Should be
    UNTIL User.NEXT=0;
    
  • hungryandfoolhungryandfool Member Posts: 114
    UNTIL GenJouBtch.NEXT=0;
    Should be
    UNTIL User.NEXT=0;
    

    Thanks a lot mohana. =D>
    I don't know what should I call myself. :oops: ](*,)
  • MBergerMBerger Member Posts: 413
    and it seems i was right too :)
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    MBerger wrote:
    and it seems i was right too :)
    Thanks to you too MBerger.. :thumbsup:
  • hungryandfoolhungryandfool Member Posts: 114
    MBerger wrote:
    and it seems i was right too :)

    Sorry for replying late, but many many thanks to you too MBerger =D> \:D/
Sign In or Register to comment.