0
public with sharing class APTS_UsageInput_InsertTempRecordsBatch implements Database.Batchable<APTS_UsageInputWrapper>
{

    public List <APTS_UsageInputWrapper> inputList = new List<APTS_UsageInputWrapper>();
    public List<EQ_TempSSP1Data__c> tempData = new List<EQ_TempSSP1Data__c>();
    list<APTS_UsageInputWrapperData> inputlistData= new list<APTS_UsageInputWrapperData>();

    public APTS_UsageInput_InsertTempRecordsBatch(List<APTS_UsageInputWrapper> uirecordsfromloadfile)
    {
        inputList = uirecordsfromloadfile;

    }


    public Iterable<APTS_UsageInputWrapper> start(Database.BatchableContext BC) {
        return inputList;
    }

    public void execute(Database.BatchableContext info,List<APTS_UsageInputWrapperData> inputlistData) 
    {
        // insert tempssp1 records
        integer counter = 1;

        for (APTS_UsageInputWrapperData record : inputlistData) {
            tempData.add(new EQ_TempSSP1Data__c(EQ_WorkId__c =
                    inputList.EQ_WorkId,
                    EQ_SourceSystem__c = record.EQ_SourceSystem,
                    EQ_IssueNumber__c = record.EQ_IssueNumber,
                    EQ_ServiceCode__c = record.EQ_ServiceCode,
                    EQ_Quantity__c = record.EQ_Quantity,
                    EQ_QuantityID__c = record.EQ_QuantityID,
                    EQ_RecordKey__c = record.EQ_RecordKey,
                    EQ_LoadMonth__c = system.today()));

            counter++;
        }
        insert tempData;
    }

    public void finish(Database.BatchableContext info) { }
}

Error: Class APTS_UsageInput_InsertTempRecordsBatch must implement the method: void Database.Batchable.execute(Database.BatchableContext, List)

I am trying to pass APTS_UsageInputWrapper wrapper from class to batch.

       global class APTS_UsageInputWrapper {

global String EQ_WorkId { get; set; }
global Integer EQ_Count { get; set; }
global Boolean ValidateOnly { get; set; }
global List<APTS_UsageInputWrapperData> data { get; set; }

}

public class APTS_UsageInputWrapperData {
//RefCode
public string EQ_IssueNumber { get; set; }

//FeeCode
public string EQ_ServiceCode { get; set; }

public decimal EQ_Quantity { get; set; }

public string EQ_QuantityID { get; set; }

public string EQ_SourceSystem { get; set; }

public string EQ_LoadMonth { get; set; }

public string EQ_RecordKey { get; set; }

}

3

Change the class signature:

public with sharing class APTS_UsageInput_InsertTempRecordsBatch 
implements Database.Batchable<APTS_UsageInputWrapper> 

Make sure you consistently apply "generics" in your Batchable implementation, as covered in the documentation:

public Iterable<APTS_UsageInputWrapper> start(Database.BatchableContext context)

and:

public void execute(Database.BatchableContext context, List<APTS_UsageInputWrapper> scope)

and:

public void finish(Database.BatchableContext context)

Any other signatures will cause you compilation issues. Any other errors revealed after that are not related to the incorrect generics usage you currently have.

You have used APTS_UsageInputWrapperData instead of APTS_UsageInputWrapper in the signature for execute.

It is the execute method that needs updating; you need to iterate the wrappers and from the wrappers get the wrapper data. You then use a combination of the wrapper-level data and the wrapper data's data to create the EQ_TempSSP1Data__c instances.

Perhaps something like:

    List<EQ_TempSSP1Data__c> data = new List<EQ_TempSSP1Data__c>();

    for (APTS_UsageInputWrapper wrapper : scope) {
        for (APTS_UsageInputWrapperData record : wrapper.data) {
            tempData.add(new EQ_TempSSP1Data__c(EQ_WorkId__c =
                wrapper.EQ_WorkId,
                EQ_SourceSystem__c = record.EQ_SourceSystem,
                EQ_IssueNumber__c = record.EQ_IssueNumber,
                EQ_ServiceCode__c = record.EQ_ServiceCode,
                EQ_Quantity__c = record.EQ_Quantity,
                EQ_QuantityID__c = record.EQ_QuantityID,
                EQ_RecordKey__c = record.EQ_RecordKey,
                EQ_LoadMonth__c = System.today()));
        }
    }

    insert data;

As an aside, since you are using an Iterable-based batch please note that:

  1. this restricts you to a maximum of 50000 underlying database objects for your processing (e.g. if you use a query to populate the "inputList" you can only use up to 50000 objects to do this).
  2. you should use generics against the iterable's type as well; note that List<APTS_UsageInputWrapper> can be returned as an Iterable<APTS_UsageInputWrapper> from your start method
| improve this answer | |
  • i tried with same but now getting again error: Class APTS_UsageInput_InsertTempRecordsBatch must implement the method: void Database.Batchable<APTS_UsageInputWrapper>.execute(Database.BatchableContext, List<APTS_UsageInputWrapper>) .. I have updated my wrapper in code. – Suren Jan 27 at 9:56
  • It is hard to be exact as to your problem because you have not included what the relationship is between APTS_UsageInputWrapper and APTS_UsageInputWrapperData. – Phil W Jan 27 at 10:09
  • Fundamentally you need to make sure the code uses APTS_UsageInputWrapper, extracting the APTS_UsageInputWrapperData from the wrapper when the data is needed. – Phil W Jan 27 at 10:11
  • I have added inner wrapper also. Could you please have a look and let me know what changes can i do. – Suren Jan 27 at 10:15
  • Thanks Phil, it worked. :) – Suren Jan 27 at 11:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.