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
Umamageshwari PalanisamyUmamageshwari Palanisamy 

how to resolve "LIMIT_USAGE_FOR_NS" in Batch class ?

I have written apex class.Tge batch class is success but in the debug log there is no result.It shows 

"
03:50:14.4 (2862599069)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:44 03:50:14.4 (2862607983)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4 03:50:14.4 (2862635997)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:64 03:50:14.4 (2862640267)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:44 03:50:14.4 (2862649133)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4 03:50:14.4 (2862677248)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:68 03:50:14.4 (2862681548)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:44 03:50:14.4 (2862690612)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4 03:50:14.4 (2862719222)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:72 03:50:14.4 (2862727335)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:44 03:50:14.4 (2862736722)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4 03:50:14.4 (2862766378)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:76 03:50:14.4 (2862770764)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:44 03:50:14.4 (2862779853)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4 03:50:14.4 (2862808777)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:80 03:50:14.4 (2862813192)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:44 03:50:14.4 (2862822196)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4 03:50:14.882 (2882961812)|CUMULATIVE_LIMIT_USAGE 03:50:14.882 (2882961812)|LIMIT_USAGE_FOR_NS|(default)| Number of SOQL queries: 0 out of 200
"  like this.
How to overcome this issue.
public virtual class Rfleet_DZCallc2gMainProduct implements Database.Batchable<List<String>>, Database.AllowsCallouts { 

public string jsonStr {get;set;}
public string geturl;
public string getcountrycode;
public string getCurrency;
public string brand;
list<string> calOut=new list<string>();
Set<String> newPhase= new Set<String>(); // for adding all new phase strings
List<String> lsNewurl = new List<String>();
set<String> updatePhase= new set<String>(); // for update entries
List<product2> listProd = new List<product2>();
 
public Rfleet_DZCallc2gMainProduct(){

    Rfleet_CountryInfo__c cs = Rfleet_CountryInfo__c.getInstance('Algeria');
    geturl= cs.Rfleet_C2GURL__c;
    system.debug('c2gURL'+geturl);
    getcountrycode=cs.Rfleet_CountryCode__c;
    getCurrency=cs.Rfleet_Currency__c;
    system.debug('getCurrency<<<<<<<<<<<<'+getCurrency);
    }
private virtual List<String> getJSONFromREST() {

    system.debug('getcountrycode'+getcountrycode);
    Http h = new Http();
    HttpRequest req = new HttpRequest();
    req.setEndpoint(geturl);
    req.setHeader('Accept','application/JSON');
    req.setMethod('GET');
    HttpResponse res = h.send(req);
    jsonStr= res.getBody();

    JSONParser parser = JSON.createParser(jsonStr);
    while (parser.nextToken() != null) {
    if (parser.getCurrentToken() == JSONToken.FIELD_NAME){
    String fieldName = parser.getText();
    if(fieldName == 'doc'){
    parser.nextToken();
    calOut.add(parser.getText());
    system.debug('calOut===>'+calOut); 
    }   
    }    
    }
    return calOut;
}
public Iterable<List<String>> start(Database.BatchableContext BC) {
    list<string>callc2gurl=getJSONFromREST();
    system.debug('callc2gurl'+callc2gurl);
    Rfleet_GetValues_DzC2G prodData = new Rfleet_GetValues_DzC2G(); 
    List<List<String>> urlData = new List<List<String>>();
        for(String dataUrl:callc2gurl){
            List<String> data = prodData.getData(dataUrl);
            data.add(dataUrl);
            System.debug('Add all url data======>'+data);
            urlData.add(data );
        } 
    System.debug('ALL Prod data======>'+urlData );  
    return urlData;
}
public void execute(Database.BatchableContext BC, List<List<String>> records) {
    Rfleet_GetValues_DzC2G prodData = new Rfleet_GetValues_DzC2G();
    System.debug('ALL Prorecords======>'+records);  
     List<product2> lsVersionProd = new List<product2>();
     List<product2> lsModelProd = new List<product2>();
        for(List<String> d:records){ 
            System.debug('ALL Prorecords======>'+d); 
            Map<string,String> VersionIdScrCode=prodData.getVersionIdScrCode(d[9]);  
            System.debug('VersionIdScrCode======>'+VersionIdScrCode);  
            Map<string,String> versionlabel=prodData.getVersionLabel(d[8]); 
            System.debug('ALL versionlabel======>'+versionlabel);
            List<List<String>> versionlabelIdScrcode=prodData.getversionlabelIdScrcode(versionlabel,VersionIdScrCode);   
            System.debug('ALL versionlabelIdScrcode======>'+versionlabelIdScrcode);  
            System.debug('versionlabelIdScrcodesize======>'+versionlabelIdScrcode.size());
          List<String> lsScpmodel= prodData.getModelScpLabel(d[8]); 
      
              for(List<string> p:versionlabelIdScrcode){            
                    Product2 newProd=new product2(); 
                    brand=d[4];  
                    newProd.ProductCode=p[2];
                    newProd.name=getcountrycode+'-'+p[1]+'-'+'strmodel';
                    newProd.CurrencyIsoCode=getCurrency;
                    newProd.SCP_code__c=p[2];
                    newProd.SCP_Label__c=p[1]; 
                    newProd.Country_code__c=getcountrycode;
                    
                    if(brand=='APL03'){brand='Reanult';}
                    if(brand=='APL05'){System.debug('brand<<<<<<<<<<'+brand);brand='Dacia';}
                    newProd.Brand__c=brand;
                    newProd.Rfleet_VersionCombination__c=getcountrycode+brand+p[2];
                     newProd.Rfleet_C2G_version_code__c=p[0];
                    newProd.Market__c='None';
                    newProd.Description=getcountrycode+'-'+brand+'-'+p[2];  
                    newProd.IsActive=true;
                    lsVersionProd .add(newProd);  
                    
                    System.debug('lsVersionProd inside<<<<<<<<<<'+lsVersionProd);   
                }
           
        } 
System.debug('lsVersionProd<<<<<<<<<<'+lsVersionProd); 
System.debug('lsVersionProdsizeee<<<<<<<<<<'+lsVersionProd.size()); 

try {

 upsert  lsModelProd Rfleet_ModelCombination__c; }    //Rfleet_VersionCombination__c;
catch (DMLException e){
  System.debug('retry!'); 
 }



}

}

the above is my code.Please help me out