Page 1 of 1
Logic code for capturing duplicate entries on crop commodity code on a roster
Posted: June 21st, 2020, 9:16 am
by pollyp20
Hello im a beginner in cspro logic. Say for instance i have list of commodity codes for crops
Example 124020, 124040, 124041, 124042 and so on.
I want to prevent the enumerator or keyer to enter the same commodity code which was already used..because its not usual to entry same crop on the same plot.
Thank you in advance
Re: Logic code for capturing duplicate entries on crop commodity code on a roster
Posted: June 21st, 2020, 12:26 pm
by khurshid.arshad
Try this.
Code: Select all
PROC CropName
string StoreString=strip($);
numeric index=count(CropID where strip(CropName)=strip(StoreString));
if index>1 then
errmsg (You can not enter %s twice ", strip(StoreString) );
$="";
reenter;
else
endif;
Re: Logic code for capturing duplicate entries on crop commodity code on a roster
Posted: June 21st, 2020, 5:52 pm
by pollyp20
Thanks for the reply. Will it work if may list of commodity codes are store in valueset?
Re: Logic code for capturing duplicate entries on crop commodity code on a roster
Posted: June 22nd, 2020, 6:12 am
by josh
The logic is a bit different for a value set. Search for the word "ranking" on this forum and you will find some examples:
search.php?keywords=ranking
Re: Logic code for capturing duplicate entries on crop commodity code on a roster
Posted: June 23rd, 2020, 6:41 am
by khurshid.arshad
PROC CropName
numeric index=count(CropID);
if index>1 then
errmsg (You can not enter %s twice ", getlabel(CropName_V1, CropName));
$=notappl;
reenter;
else
endif;