function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sathya82sathya82 

Compile Error: unexpected token: 'Class' at line 9 column 13

global class MainClass
{
global class RequestClass
{
webservice String errorMessage;

//Account Releated Fields

global Class AccountWrapper // Line9
{
webservice String accName;
webservice Integer accNumber;
webservice Id AccountId;
webservice List<AccountWrapper> accounts;
webservice List<ContactWrapper>;
webservice List<OpportunityWrapper>;
}

//Contact Releated Fields
//webservice String contactName;
global class ContactWrapper
{
webservice String clName;
webservice String cfName;

}

// Opportunity Releated Fields
global class OpportunityWrapper
{
webservice String oName;
webservice String ocDate;
webservice String oStage;
webservice List<ProductWrapper>;
}
// Quote Realeted Fields
webservice String qName;




// Product fields
global class ProductWrapper
{
webservice String productcode;
webservice String productName;
// boolean active;
webservice Integer quantity;
webservice Integer unitprice;
}
// QuoteItem Fields

webservice String qitemName;


}

webservice static ResponseClass behaviourOfWebService(RequestClass req)
{

List<Account> accountList = new List<Account>();
Account a;
for(AccountWrapper wrapper: req.accounts){
a = new Account();
a.Name = wrapper.accName;
a.AccountNumber =String.valueOf(wrapper.accNumber);
accountList.add(a);
}
insert AccountList;

ResponseClass res = new ResponseClass();
res.resId = a.Id;
res.resName = a.Name;
res.cresName = c.FirstName;
// res.respId = p.Id;
return res;
return res;

}

wt35wt35

It look like the closing square bracket of MainClass is missing.

Have you tried putting an additional  closing square bracket at the very end?

sathya82sathya82

@Wt35

 

 Hi,

 

     i put Square bracket and tried but agin it showing an error.same error,

wt35wt35

Check this link, inner classes are only allowed one-level deep:

http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_classes_defining.htm

 

It looks like your class at line 9 is two-level deep hence generating the error

RockzRockz

Hi..

 

Try below code...u missed ( } --last line)

 

global class MainClass
{
global class RequestClass
{
webservice String errorMessage;

//Account Releated Fields

global Class AccountWrapper // Line9
{
webservice String accName;
webservice Integer accNumber;
webservice Id AccountId;
webservice List<AccountWrapper> accounts;
webservice List<ContactWrapper>;
webservice List<OpportunityWrapper>;
}

//Contact Releated Fields
//webservice String contactName;
global class ContactWrapper
{
webservice String clName;
webservice String cfName;

}

// Opportunity Releated Fields
global class OpportunityWrapper
{
webservice String oName;
webservice String ocDate;
webservice String oStage;
webservice List<ProductWrapper>;
}
// Quote Realeted Fields
webservice String qName;




// Product fields
global class ProductWrapper
{
webservice String productcode;
webservice String productName;
// boolean active;
webservice Integer quantity;
webservice Integer unitprice;
}
// QuoteItem Fields

webservice String qitemName;


}

webservice static ResponseClass behaviourOfWebService(RequestClass req)
{

List<Account> accountList = new List<Account>();
Account a;
for(AccountWrapper wrapper: req.accounts){
a = new Account();
a.Name = wrapper.accName;
a.AccountNumber =String.valueOf(wrapper.accNumber);
accountList.add(a);
}
insert AccountList;

ResponseClass res = new ResponseClass();
res.resId = a.Id;
res.resName = a.Name;
res.cresName = c.FirstName;
// res.respId = p.Id;
return res;
return res;

}
}

 

Please accept my answer as a solution if my solution was helpful. This will make it available to others as a proper answer. If you felt that I went above and beyond please give me Kudos by clicking on on the star icon.

 

Thanks,

Cool Sfdc

sathya82sathya82

@Rockz

 

  

global class MainClass
{
global class RequestClass
{
webservice String errorMessage;

//Account Releated Fields

global Class AccountWrapper //  Error occuring point
{
webservice String accName;
webservice Integer accNumber;
webservice Id AccountId;
webservice List<AccountWrapper> accounts;
webservice List<ContactWrapper>;
webservice List<OpportunityWrapper>;
}

}

global class ResponseClass
{
webservice String resName;

}

webservice static ResponseClass behaviourOfWebService(RequestClass req)
{

List<Account> accountList = new List<Account>();
Account a;
for(AccountWrapper wrapper: req.accounts){
a = new Account();
a.Name = wrapper.accName;
a.AccountNumber =String.valueOf(wrapper.accNumber);
accountList.add(a);
}
insert AccountList;

ResponseClass res = new ResponseClass();
res.resId = a.Id;
res.resName = a.Name;
return res;
return res;

}
}

 

when i use this code also i am getting same error

Satyendra RawatSatyendra Rawat

Hi,

Update class keyword is small letter.

 

global Class AccountWrapper

                  to

global class AccountWrapper

 

sathya82sathya82

@Sathya_007

 

 

       HI i do that also but same error is came .

RockzRockz

@Satya....

 

 Hope this will help : 

 

change class name...

       

              global Class AccountWrapper

                            to

              global Class AccWrp

 

Please accept my answer as a solution if my solution was helpful. This will make it available to others as a proper answer. If you felt that I went above and beyond please give me Kudos by clicking on on the star icon.

 

Thanks,

Cool Sfdc

sathya82sathya82

@Rockz

 

        I tried latest one also but no use same error at same line.

wt35wt35

Again, did you ensure that your class is not two-level deep?

 

You are only allowed to have one-level deep classes...

Please double-check that.