"You cannot set key column "ItemCode$" while in edit state" getting this error when sending item code as "/newitem" of charge type miscellaneous item

SOLVED

I am getting this error when trying to add miscellaneous item of charge type for sales order in sage100c 2021

int TaskID = (int)oSS.InvokeMethod("nLookupTask", "CI_ItemCode_UI");
oSS.InvokeMethod("nSetProgram", TaskID);
using (DispatchObject oCIItemCode = new DispatchObject(pvx.InvokeMethod("NewObject", "CI_ItemCode_bus", oSS.GetObject())))
{

   retVal = oCIItemCode.InvokeMethod("nSetKey", "/naato");

 retVal = oCIItemCode.InvokeMethodByRef("nSetValue", new object[] { "ItemCode$", "/cream" });   // here i am getting the error "You cannot set key column ItemCode$ while in edit state."
if (retVal.ToString() == "0")
{
object errorMsg = oCIItemCode.GetProperty("sLastErrorMsg");
Service1.WriteToLogFile(errorMsg.ToString());
}
retVal = oCIItemCode.InvokeMethodByRef("nSetValue", new object[] { "ItemCodeDesc$", /cream });   //if i'll put the same value here then it is creating successfully
if (retVal.ToString() == "0") 
{
object errorMsg = oCIItemCode.GetProperty("sLastErrorMsg");
Service1.WriteToLogFile(errorMsg.ToString());
isInvalidItem = true;
}
retVal = oCIItemCode.InvokeMethodByRef("nSetValue", new object[] { "ItemType$", "3" });              //creating charge item type
retVal = oCIItemCode.InvokeMethodByRef("nSetValue", new object[] { "SalesAcctKey$", incomeAccount, "kACCOUNT" });
if (retVal.ToString() == "0")
{
object errorMsg = oCIItemCode.GetProperty("sLastErrorMsg");
Service1.WriteToLogFile("Error :- Wrong account mapped for sales income " + incomeAccount + " " + errorMsg.ToString());
}


retVal = oCIItemCode.InvokeMethod("nWrite");
if (retVal.ToString() == "0")
{
object errorMsg = oCIItemCode.GetProperty("sLastErrorMsg");
Service1.WriteToLogFile("Error while creating item :- " + errorMsg.ToString());
Console.Read();
}

Service1.WriteToLogFile("Item Created successfully ");

but when i am putting the same value "/naato" in  "ItemCodeDesc$" field then it is working fine
can anyone help me out what is the reason of this and how i can fix this ?

Thank You