Hi ,
You will possibly need two changes in your program
SIM900.print("AT+CNMI=2,2,0,0,0\r");
move this command to the void setup() loop
and to find the "#ok" in the receivng sms you can use "indexof" command
try this
String inchar;
if(SIM900.available()>0)
{
inchar=SIM900.read();
if(inchar.indexOf("#ok") >=0) // this command will check if your messgae received has got #ok in it .
Hope this post is helpful
All the best
check this link also .. this wil help you receive sms and once you received you just use that indexof command..