Clone record through 4GL

SOLVED

Hi,

I would like to clone an invoice after posting, but the "Child" record will have few changes. 

Would anyone have a piece of script that clones one record to share, as an example? Just to learn the best way to do it.

Thank you.

Best regards,

  • +1
    verified answer

    Hi Arthur,

    Depending on where in a process this done from, screen or task, the best way in my opinion would be to get the key for last record, read it from the table and writing to the table again.  Here is an extract to give you an idea, hope it helps.

    If clalev([F:PIH]) = 0 : Local File PINVOICE [PIH] : Endif
    If clalev([F:PIL]) = 0 : Local File BPSINVLIG [PIL] : Endif
    # Read Index PIH0
    Read [F:PIH]PIH0 = [M]YNUM
    Read [F:PIL]PIL0 = [F:PIH]NUM
    [F:PIH]NUM = "" #Add the lines you want
    [F:PIL]NUM = ""
    Write [F:PIH]
    Write [F:PIL]
    # Close Tables