You need to sign in to do that
Don't have an account?

Getting Null Pointer Error -
Where am i missing, please help ?
public static ReturnTypeClass prepareReqWrapper(ReturnTypeClass reqWrap){
ReturnTypeClass reqWrapperNew = new ReturnTypeClass();
system.debug('reqWrap'+reqWrap);
try{
ReturnTypeClass.AR_INV_INBND_STG_ROW objInputIns = reqWrap.DataArea.AR_INV_INBND_STG_ROW != null ? reqWrap.DataArea.AR_INV_INBND_STG_ROW : new ReturnTypeClass.AR_INV_INBND_STG_ROW();
reqWrapperNew.DataArea.AR_INV_INBND_STG_ROW.AMOUNT = objInputIns.AMOUNT != null ? objInputIns.AMOUNT : '0';
}
catch(Exception e){
}
return reqWrapperNew;
My 'ReturnTypeClass' is -
global class ReturnTypeClass {
public class DataArea {
public AR_INV_INBND_STG_ROW AR_INV_INBND_STG_ROW;
}
public class AR_INV_INBND_STG_ROW {
public String AMOUNT;
}
}
public static ReturnTypeClass prepareReqWrapper(ReturnTypeClass reqWrap){
ReturnTypeClass reqWrapperNew = new ReturnTypeClass();
system.debug('reqWrap'+reqWrap);
try{
ReturnTypeClass.AR_INV_INBND_STG_ROW objInputIns = reqWrap.DataArea.AR_INV_INBND_STG_ROW != null ? reqWrap.DataArea.AR_INV_INBND_STG_ROW : new ReturnTypeClass.AR_INV_INBND_STG_ROW();
reqWrapperNew.DataArea.AR_INV_INBND_STG_ROW.AMOUNT = objInputIns.AMOUNT != null ? objInputIns.AMOUNT : '0';
}
catch(Exception e){
}
return reqWrapperNew;
My 'ReturnTypeClass' is -
global class ReturnTypeClass {
public class DataArea {
public AR_INV_INBND_STG_ROW AR_INV_INBND_STG_ROW;
}
public class AR_INV_INBND_STG_ROW {
public String AMOUNT;
}
}
Here in the above code, I don't know how u are able to access this AR_INV_INBND_STG_ROW with the help of DataArea class because this variable is not the staitc so I think it should give u compile time error. for accessing this u have to make object first for DataArea then access I think it will work.
All Answers
**Forgot to mention -
gettting Exception Message>>>is ::Attempt to de-reference a null object
at ' reqWrapperNew.DataArea.AR_INV_INBND_STG_ROW.AMOUNT = objInputIns.AMOUNT != null ? objInputIns.AMOUNT : '0';' line----
Here in the above code, I don't know how u are able to access this AR_INV_INBND_STG_ROW with the help of DataArea class because this variable is not the staitc so I think it should give u compile time error. for accessing this u have to make object first for DataArea then access I think it will work.