Dear all,
This message is already posted on the forum.
Thanks for your precious help!
I've several files with duplicate ID and i would like to know if there's a way to write a batch program for re-assign ID number, so avoid duplicate.
I know it's not so easy but Cspro developer team, mainly Josh and Gregory always have solution for any sophisticated request.
@ Joshua, my first and simplest idea is to use the same logic you send to me last day within a batch function, something like this after concatenating whole files.
// Start at first case in the data file
locate(MYEXTERNALDICT_DICT, >=, "");
// Loop through all cases
// until loadcase returns zero when it hits end of file.
while loadcase(MYEXTERNALDICT_DICT) <> 0 do
// Increment ID
if ID_MYEXTERNALDICT_DIC >1 then //1 because we don't need to increment the first ID
ID_MYEXTERNALDICT_DIC = visualvalue(ID_MYEXTERNALDICT_DIC) + 1;// Whatever the ID number, increment ID using previous number
endif;
enddo;
I know it's not possible within Csentry, does my idea is realistic using a batch?
Thanks in advance!
Batch to fix and correct duplicate ID
Batch to fix and correct duplicate ID
G.VOLNY, a CSProuser from Haiti, since 2004
Re: Batch to fix and correct duplicate ID
I'm not sure why you need would need to use that logic to iterate through the cases in an external file. In a batch application the index file is not used for the main data file so it is possible to open a file with duplicate case ids. If you use an external file and loadcase you will get errors because the index file is used.
Usually we use a batch application to fix duplicates on the main data file. You just need to have some logic to map the duplicate ids to the correct ids. For example if you want to add one to the id MYID if it is the same as the id from the previous case then you would do something like:
PROC GLOBAL
numeric lastId = -1;
PROC MYID
if MYID = lastId then
MYID = MYID + 1;
endif;
lastId = MYID;
Usually we use a batch application to fix duplicates on the main data file. You just need to have some logic to map the duplicate ids to the correct ids. For example if you want to add one to the id MYID if it is the same as the id from the previous case then you would do something like:
PROC GLOBAL
numeric lastId = -1;
PROC MYID
if MYID = lastId then
MYID = MYID + 1;
endif;
lastId = MYID;