I'm having a problem trying to duplicate an invoice. I found some code written by Dr. Wayne, but it doesn't work properly for me. I've tried changing it with my limited knowledge, but with no success.
The problem is that when the code copies the "Msquawk table" records, it copies them at the "Minv_hdr set" level instead of at the "Msquawk" table level.
What I'm trying to say is that if you look at the "Msquawk table" records that belong to that invoice number, there are 6 records. However, when viewing the "Msquawk table records at the "Minv_hdr" set level, there are 26 records.
I've tried changing the code to many different variants with no success. The following code copies only 6 records, but at the set level. Because the set level has 26 records, the first 6 records are all the same.
Does anyone have any suggestions as to how I can make it copy only the linked records at the "Msquawk" table level.
The goal is to copy the entire invoice, but for now, I'm just trying to copy the first child and I can't make it work.
'Duplicate the current invoice
dim hdr as p
dim squawk as p
dim old_hdr as b 'a blob variable to hold the old header record
dim count_squawks as n 'array of blobs to hold squawk Records; start with a size of 1 record
dim i as n
hdr = table.get("minv_hdr")
swk = table.get("msquawk")
'The folowing line counts the proper amount of records
count_squawks = count(msquawk->transno,GRP->minv_hdr)
if count_squawks > 0 then
dim squawkrecs[count_squawks] as b
i = 0
swk.fetch_first()
while i 0
parent.resynch()
end
The problem is that when the code copies the "Msquawk table" records, it copies them at the "Minv_hdr set" level instead of at the "Msquawk" table level.
What I'm trying to say is that if you look at the "Msquawk table" records that belong to that invoice number, there are 6 records. However, when viewing the "Msquawk table records at the "Minv_hdr" set level, there are 26 records.
I've tried changing the code to many different variants with no success. The following code copies only 6 records, but at the set level. Because the set level has 26 records, the first 6 records are all the same.
Does anyone have any suggestions as to how I can make it copy only the linked records at the "Msquawk" table level.
The goal is to copy the entire invoice, but for now, I'm just trying to copy the first child and I can't make it work.
'Duplicate the current invoice
dim hdr as p
dim squawk as p
dim old_hdr as b 'a blob variable to hold the old header record
dim count_squawks as n 'array of blobs to hold squawk Records; start with a size of 1 record
dim i as n
hdr = table.get("minv_hdr")
swk = table.get("msquawk")
'The folowing line counts the proper amount of records
count_squawks = count(msquawk->transno,GRP->minv_hdr)
if count_squawks > 0 then
dim squawkrecs[count_squawks] as b
i = 0
swk.fetch_first()
while i 0
parent.resynch()
end
Comment