Logic code for capturing duplicate entries on crop commodity code on a roster

Discussions about CSEntry
Forum rules
New release: CSPro 8.0
Post Reply
pollyp20
Posts: 4
Joined: June 21st, 2020, 9:08 am

Logic code for capturing duplicate entries on crop commodity code on a roster

Post 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
khurshid.arshad
Posts: 572
Joined: July 9th, 2012, 11:32 am
Location: Islamabad, Pakistan

Re: Logic code for capturing duplicate entries on crop commodity code on a roster

Post 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;

pollyp20
Posts: 4
Joined: June 21st, 2020, 9:08 am

Re: Logic code for capturing duplicate entries on crop commodity code on a roster

Post by pollyp20 »

Thanks for the reply. Will it work if may list of commodity codes are store in valueset?
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Logic code for capturing duplicate entries on crop commodity code on a roster

Post 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
khurshid.arshad
Posts: 572
Joined: July 9th, 2012, 11:32 am
Location: Islamabad, Pakistan

Re: Logic code for capturing duplicate entries on crop commodity code on a roster

Post 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;
Post Reply