Below is my code for the expected output and am getting errors and I am stuck at this point as to how to solve the error.
Code -
<#if Records?has_content>
<#assign record=Records[0] />
<#assign firstRecord=record.Records[0] />
01, ${092100052?replace(",", "")},${firstRecord.cust_acc_name},${.now?string("yyMMdd,ss")},1,80,,2/
02,${firstRecord.cust_acc_name},${091000022?replace(",", "")},1,${firstRecord.creation_ts?datetime("yyyy-MM-dd HH:mm:ss")?string("yyMMdd,ss")},,2/
<#assign debitamoVar = 0>
<#assign creditamoVar = 0>
<#assign indcountd = 0>
<#assign indcountc = 0>
<#list firstRecord as x>
<#assign y = x.y>
<#if (x.txn_type)?upper_case = 'D' || (x.txn_type)?upper_case ='DEBIT'>
<#assign debitamoVar = debitamoVar + x.debit_amount?number!0>
<#assign indcountd = (x?index + 1)>
<#elseif (x.txn_type)?upper_case = 'C' || (x.txn_type)?upper_case ='CREDIT' >
<#assign creditamoVar = creditamoVar + x.outstanding_balance?number!0>
<#assign indcountc = (x?index + 1)>
</#if>
<#assign TotalVariable = firstRecord.cust_acc_no+",,010,"+firstRecord.opening_available_balance+",045,"+firstRecord.closing_available_balance+","+firstRecord.closing_ledger_balance+",100,creditamoVar,4,${debitamoVar},${indcountd},/" >
<#assign x = TotalVariable?length>
<#if (x > 80)>
<#assign iteration = x/80>
<#assign pos = 0>
<#list 1..iteration as i>
<#if i = iteration>
<#assign sub_str = TotalVariable?substring(pos,x)>
<#else>
<#assign sub_str = TotalVariable?substring(pos,pos+80)>
</#if>
<#assign pos = (i*80)>
<#if i = 1>
03,${sub_str}/
<#else>
88,${sub_str}
</#if>
</#list>
<#if (pos < x)>
88,${TotalVariable?substring(pos,x)}
</#if>
<#else>
03,${TotalVariable?substring(0,x)}
</#if>
<#assign TotalVariable1 = firstRecord.txn_code+","+firstRecord.txn_amount+","+firstRecord.txn_reference_no+","+firstRecord.customer_reference+",174,"+firstRecord.txn_description+"/">
<#assign x = TotalVariable1?length>
<#if (x > 80)>
<#assign iteration = x/80>
<#assign pos = 0>
<#list 1..iteration as i>
<#if i = iteration>
<#assign sub_str = TotalVariable1?substring(pos,x)>
<#else>
<#assign sub_str = TotalVariable1?substring(pos,pos+80)>
</#if>
<#assign pos = (i*80)>
<#if i = 1>
16,${sub_str}/
<#else>
88,${sub_str}
</#if>
</#list>
<#if (pos < x)>
88,${TotalVariable1?substring(pos,x)}
</#if>
<#else>
16,${TotalVariable1?substring(0,x)}
</#if>
</#list>
</#if>
Expected output - In the below-expected output I have tags 01,02,03,88 - show the continuation of the above tag. cuz every tag has a limit of 80 characters once it reaches 80 characters it should break. Tag 16 should iterate as per the number of records. Tag 49,98,99 shows the count of total no.of records including the 02, all 03, 16, 49 and 88 records.
01, 092100052,ACMEINC,230411,0506,1,80,,2/ 02,ACMEINC,091000022,1,230328,2359,,2/ 03,0323234127,,010,004799254,,,015,0000033294619,,,045,33295600,,,/ 88,100,976000,4,,400,503322,2,/ 16,045,00000005477708,,,072,Ref.no 2002134,,,074,00000000000000/ 88,174,Counter Sales Bi Weekly/ 16,025,000000087646.76,,,072,Ref,no 117789,,,074,00000000000000/ 88,Deposit-Misc Receivables 16,347,0000002500000,1,I-GEN107032800003445,Transfer to HO 16,351,0000000579298,S,00000173112920,00000000000000,00000000000000/ 88,015,Supplier Invoice Paid,/ 16,351,00000000578298,S,00000173112920,00000000000000,00000000000000/ 88,Supplier Invoice Paid Nike,/ 16,021,0000000487224,S,00000173112920,00000000000000,00000000000000/ 88,For Supplier Invoice Coleman/ 88,Inv no 2238900 trf=22445a33/ 88,For Product Supplies/ 88,And Monthly procurement/ 16,531,000010948,,Monthly Store Maintenance/ 88,3rd party store maintenance/ 16,531,00003455865,,Counter Sales/ 88,Ref.no=335000089/ 49,0000001596703345,000019/ 98,0000002513367488,00001,000021/ 99,0000002513367488,00001,000023/