0

I am Mapping my XML -> String xml; total characters stored into the above string.

enter image description here

which needs for iteration of 100's of related records,

now I am into a list string -> LIST<STRING> liststring When I iterate the same with 100 records only 10 records information is stored.

In developer console when there's the size exceeded the console will throw as (three dots)... at the end of the string, after iteration I get these dot's from which Integrating with other system is bit difficult. How do we fix this?

      Staticresource b =  fetchpoxml();
 list<PurchaseOrders__c> fetchpo = [
                                            select id,name,PONumber__c,POReleaseDate__c,TotalAmount__c,createddate,CreatedBy.name,
                                            lastmodifiedBy.name,ShippingMode__c,BOMNumber__r.name,Vendor__r.name,
                                            Vendor__r.Billingstreet,CurrencyIsoCode,Vendor__r.CurrencyIsoCode,
                                            Vendor__r.Billingcity,Vendor__r.Billingstate,Vendor__r.Description,
                                            Vendor__r.PortofLoading__c from PurchaseOrders__c  where id =: StringId
                                            limit 1
                                          ]; 

        //This is to Fetch all the PO LineItems for a PO 
        List<POLineItem__c> fetchpoli =[select id,name,Amount__c,PurchaseOrder__r.name,Rate__c,Quantity__c,ItemCode__r.name from POLineItem__c where PurchaseOrder__c  =: StringId];

String xmlbody=b.Body.toString().replace('#VendorBillingStreet',  fetchpo[0].Vendor__r.Billingstreet);
        xmlbody=xmlbody.replace('#VendorBillingCity',  string.valueof(fetchpo[0].Vendor__r.Billingcity));
        xmlbody=xmlbody.replace('#VendorBillingState',  string.valueof(fetchpo[0].Vendor__r.Billingstate));
        xmlbody=xmlbody.replace('#VendorName',  string.valueof(fetchpo[0].Vendor__r.Name));
        xmlbody=xmlbody.replace('#DeliveryDate', StringPOReleasedate);
        xmlbody=xmlbody.replace('#ShippingMode',  string.valueof(fetchpo[0].ShippingMode__c));
        xmlbody=xmlbody.replace('#PODate',  StringPOCreateddate);
        xmlbody=xmlbody.replace('#POFullNo',  string.valueof(fetchpo[0].PONumber__c));//string.valueof(fetchpo[0].PONumber__c));
        xmlbody=xmlbody.replace('#POExtractNo',  Str1);
        xmlbody=xmlbody.replace('#VendorPortofLoading',  string.valueof(fetchpo[0].Vendor__r.PortofLoading__c));
        xmlbody=xmlbody.replace('#VendorPaymentTerms',  string.valueof(fetchpo[0].Vendor__r.name));
        xmlbody=xmlbody.replace('#Createddate', StringPOCreateddate);
        xmlbody=xmlbody.replace('#Createdby',  string.valueof(fetchpo[0].Createdby.name));
        xmlbody=xmlbody.replace('#Lastmodifiedby',  string.valueof(fetchpo[0].Lastmodifiedby.name));
        xmlbody=xmlbody.replace('#Currencycode',  string.valueof(fetchpo[0].Currencyisocode));
        xmlbody=xmlbody.replace('#TotalAmount',  string.valueof(fetchpo[0].TotalAmount__c));
        xmlbody=xmlbody.replace('#POLIQuantity',  string.valueof(fetchpoli[0].Quantity__c));

// **This is the LIST Where i was talking abt**
String Poliformat= ' <ALLINVENTORYENTRIES.LIST> '
+'         <BASICUSERDESCRIPTION.LIST TYPE="String"> '
+'        <BASICUSERDESCRIPTION> </BASICUSERDESCRIPTION> '
+'        <BASICUSERDESCRIPTION>Note : COC Need to Be Send</BASICUSERDESCRIPTION> '
+'        <BASICUSERDESCRIPTION>Along with Material</BASICUSERDESCRIPTION> '
+'        <BASICUSERDESCRIPTION>.</BASICUSERDESCRIPTION> '
+'        <BASICUSERDESCRIPTION>The Supplied Part Must Meet the</BASICUSERDESCRIPTION> '
+'        <BASICUSERDESCRIPTION>Required Specification. If There.</BASICUSERDESCRIPTION> '
+'        <BASICUSERDESCRIPTION>Is Non - Compliance to Spec,</BASICUSERDESCRIPTION> '
+'        <BASICUSERDESCRIPTION>Rejected Parts Will Be Shipped</BASICUSERDESCRIPTION> '
+'        <BASICUSERDESCRIPTION>Back &amp; Rejection Cost to Be</BASICUSERDESCRIPTION> '
+'        <BASICUSERDESCRIPTION>Refunded by Supplier Within 1 Month.</BASICUSERDESCRIPTION> '
+'       </BASICUSERDESCRIPTION.LIST> '
+'       <STOCKITEMNAME>#MasterItemDescription</STOCKITEMNAME> '
+'       <ISDEEMEDPOSITIVE>Yes</ISDEEMEDPOSITIVE> '
+'       <ISLASTDEEMEDPOSITIVE>Yes</ISLASTDEEMEDPOSITIVE> '
+'       <ISAUTONEGATE>No</ISAUTONEGATE> '
+'       <ISCUSTOMSCLEARANCE>No</ISCUSTOMSCLEARANCE> '
+'       <ISTRACKCOMPONENT>No</ISTRACKCOMPONENT> '
+'       <ISTRACKPRODUCTION>No</ISTRACKPRODUCTION> '
+'       <ISPRIMARYITEM>No</ISPRIMARYITEM> '
+'       <ISSCRAP>No</ISSCRAP> '
+'       <RATE>$ #VendorPrice = #VendorPrice / Pc </RATE> '
+'       <AMOUNT>- $ #POLIAmount @ 1/ $ = - #POLIAmount </AMOUNT> '
+'       <ACTUALQTY> #POLIQuantity Nos</ACTUALQTY> '
+'       <BILLEDQTY> #POLIQuantity Nos</BILLEDQTY> '
+'       <BATCHALLOCATIONS.LIST> '
+'        <BATCHNAME> Any</BATCHNAME> '
+'        <INDENTNO/> '
+'        <ORDERNO>#POExtractNo</ORDERNO> '
+'        <TRACKINGNUMBER/> '
+'        <DYNAMICCSTISCLEARED>No</DYNAMICCSTISCLEARED> '
+'        <AMOUNT>-$ #POLIAmount @ 1/ $ = - #POLIAmount </AMOUNT> '
+'        <ACTUALQTY> #POLIQuantity Nos</ACTUALQTY> '
+'        <BILLEDQTY> #POLIQuantity Nos</BILLEDQTY> '
+'        <ORDERDUEDATE JD="42657" P="01-Dec-2016">01-Dec-2016</ORDERDUEDATE> '
+'        <ADDITIONALDETAILS.LIST>        </ADDITIONALDETAILS.LIST> '
+'        <VOUCHERCOMPONENTLIST.LIST>        </VOUCHERCOMPONENTLIST.LIST> '
+'        <UDF:_UDF_721421523.LIST DESC="" ISLIST="YES" TYPE="Quantity" INDEX="1234"> '
+'         <UDF:_UDF_721421523 DESC=""> #POLIQuantity Pc</UDF:_UDF_721421523> '
+'        </UDF:_UDF_721421523.LIST> '
+'       </BATCHALLOCATIONS.LIST> '
+'       <ACCOUNTINGALLOCATIONS.LIST> '
+'        <OLDAUDITENTRYIDS.LIST TYPE="Number"> '
+'         <OLDAUDITENTRYIDS>-1</OLDAUDITENTRYIDS> '
+'        </OLDAUDITENTRYIDS.LIST> '
+'        <LEDGERNAME>IMPORT PURCHASE</LEDGERNAME> '
+'        <GSTCLASS/> '
+'        <ISDEEMEDPOSITIVE>Yes</ISDEEMEDPOSITIVE> '
+'        <LEDGERFROMITEM>No</LEDGERFROMITEM> '
+'        <REMOVEZEROENTRIES>No</REMOVEZEROENTRIES> '
+'        <ISPARTYLEDGER>No</ISPARTYLEDGER> '
+'        <ISLASTDEEMEDPOSITIVE>Yes</ISLASTDEEMEDPOSITIVE> '
+'        <AMOUNT>-$ #POLIAmount @ 1/ $ = - #POLIAmount </AMOUNT> '
+'        <SERVICETAXDETAILS.LIST>        </SERVICETAXDETAILS.LIST> '
+'        <CATEGORYALLOCATIONS.LIST> '
+'         <CATEGORY>Primary Cost Category</CATEGORY> '
+'         <ISDEEMEDPOSITIVE>Yes</ISDEEMEDPOSITIVE> '
+'         <COSTCENTREALLOCATIONS.LIST> '
+'          <NAME>U1-HD</NAME> '
+'          <AMOUNT>- #POLIAmount </AMOUNT> '
+'         </COSTCENTREALLOCATIONS.LIST> '
+'        </CATEGORYALLOCATIONS.LIST> '
+'       </ACCOUNTINGALLOCATIONS.LIST> ' 
+'      </ALLINVENTORYENTRIES.LIST> ';
list<string> Listofstring = new  list<string>();
             integer i=0;
        for(  POLineItem__c s :fetchpoli){
            i++;
                    Listofstring.add(Poliformat.replace('#MasterItemDescription', string.valueof(s.ItemCode__r.name))
                              .replace('#VendorPrice', string.valueof(S.Rate__c))
                              .replace('#POExtractNo', str1).replace('#POLIAmount', string.valueof(S.Amount__c))
                              .replace('#POLIQuantity',string.valueof(S.Quantity__c))
                   );


        }
        String finalchange = string.valueof(Listofstring);
        finalchange = finalchange.replace(',',' ').replace('(',' ').replace(')',' ');
        xmlbody=xmlbody.replace('#OverridePOLISTFormat', finalchange);

  system.debug('Listofstring'+Listofstring);
              System.debug('before send http xmlbody'+JSON.serialize(xmlbody));

        callhttp(xmlbody, StringId);

Because of this I get Attempt to de-reference a null object Error, where as if below 10 records this works fine.

Even this method works but I wonder why its not working which is written on top.

 list<string> Listofstring = new  list<string>();
        list<string> Listofstring1 = new  list<string>();
        list<string> Listofstring2 = new  list<string>();

 for(  POLineItem__c s :fetchpoli){
            i++;
           if(i>=1 && i<=10){
                system.debug('int i'+i);
                    Listofstring.add(Poliformat.replace('#MasterItemDescription', string.valueof(s.ItemCode__r.name))
                              .replace('#VendorPrice', string.valueof(S.Rate__c))
                              .replace('#POExtractNo', str1).replace('#POLIAmount', string.valueof(S.Amount__c))
                              .replace('#POLIQuantity',string.valueof(S.Quantity__c))
                   );
             }
            if(i>=11 && i<=20){
                system.debug('int i'+i);
                    Listofstring1.add(Poliformat.replace('#MasterItemDescription', string.valueof(s.ItemCode__r.name))
                              .replace('#VendorPrice', string.valueof(S.Rate__c))
                              .replace('#POExtractNo', str1).replace('#POLIAmount', string.valueof(S.Amount__c))
                              .replace('#POLIQuantity',string.valueof(S.Quantity__c))
                   );
             }
            if(i>=21 && i<=30){
                system.debug('int i'+i);
                    Listofstring2.add(Poliformat.replace('#MasterItemDescription', string.valueof(s.ItemCode__r.name))
                              .replace('#VendorPrice', string.valueof(S.Rate__c))
                              .replace('#POExtractNo', str1).replace('#POLIAmount', string.valueof(S.Amount__c))
                              .replace('#POLIQuantity',string.valueof(S.Quantity__c))
                   );
             }


 }
        String finalchange = string.valueof(Listofstring);
                String finalchange1 = string.valueof(Listofstring1);
                String finalchange2 = string.valueof(Listofstring2);
          String overalllist= string.valueof(Listofstring)+string.valueof(Listofstring1)+string.valueof(Listofstring2);
                   xmlbody=xmlbody.replace('#OverridePOLISTFormat', overalllist);
            callhttp(xmlbody, StringId);

Note: no data changes were made. The above solution is not feasible.

  • 1
    I don't think only 10 records information will be stored. It shows you only 10 and then dots, because developer console shows limited data. You can use system.debug statement for printing each record separately, and then you will find all 100s there. – Nitish Singhal Jun 6 '17 at 10:50
  • I thought the same, But because of these dots no info is hitting my tally server. – kishore Jun 6 '17 at 10:51
  • Can you please share some more details, as your screenshot is not descriptive enough. You can edit your question and add some more screenshots and code (if possible) – Nitish Singhal Jun 6 '17 at 10:52
  • Nitish, that integration is quite big. how can i reach you and moreover this works well for 10 records but whereas if this goes beyond 15 above then this fails. – kishore Jun 6 '17 at 12:47
  • The null pointer exception at record 15 is probably because one of the fields you are referencing is null on record 15. Track down the line number that the exception is thrown from to narrow your search for the problem. – Keith C Jun 6 '17 at 14:11
4

A list can store many thousands of items and the total space used by the items and list can be several megabytes.

But to convert a list into a string that represents all the items in the list, you should not use the convenience feature provided for debug logging that just presents the first 10 values (to help prevent the debug log being swamped by big lists):

List<String> x = new List<String>{
        'a',
        'b',
        'c',
        'd',
        'e',
        'f',
        'g',
        'h',
        'i',
        'j',
        'k',
        'l',
        'm'
        };
System.debug('' + x);
// Outputs (a, b, c, d, e, f, g, h, i, j, ...)

but instead use some deliberate code such as:

System.debug(String.join(x, ', '));
// Outputs a, b, c, d, e, f, g, h, i, j, k, l, m

or:

 System.debug(JSON.serialize(x));
 // Outputs ["a","b","c","d","e","f","g","h","i","j","k","l","m"]
  • What you mentioned did not work keith. I still get only 10 values – kishore Jun 6 '17 at 12:37
  • @kishore Then you are going to have to add the relevant code to your question so people can see exactly what is going on. – Keith C Jun 6 '17 at 12:43

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.