How to read serial data

How to store message content from serial moniter into string variable. Below is the code I got to work on. When user sends the
message from phone, it is received by GSM which is then given to Arduino to produce output. The
message is displayed in msg() function. I want to take that message in a variable and use for if else statement.
How to take that message in a variable?

#include <SoftwareSerial.h>

SoftwareSerial mySerial(9, 10);

void setup()
  mySerial.begin(9600);   // Setting the baud rate of GSM Module  
  Serial.begin(9600);    // Setting the baud rate of Serial Monitor (Arduino)

void loop()
  if (Serial.available()>0)
 if (mySerial.available()>0)

 void msg()
  mySerial.println("AT+CNMI=2,2,0,0,0"); // AT Command to receive a live SMS

This should give you the necessary information: