Dear All I write some syntax for sql
After that I go to a code and convert to x++;
==================================================
My code:
display String20 ppvno()
{
HSTHPaymAdviceTable PaymAdviceTable;
HSTHPaymAdviceLine paymAdviceLine;
VendTrans VendTrans;
str ppvVoucher = "";
;
while select PaymAdviceTable
join paymAdviceLine
where paymAdviceLine.PAYMADVICEID == PaymAdviceTable.PAYMADVICEID
join VendTrans
where VendTrans.LASTSETTLEVOUCHER == paymAdviceLine.DOCUMENT
&& VendTrans.VOUCHER like '%PPV%' // when I put this code output will show blank but if not it's sound work by logical but not match my requirement
&& PaymAdviceTable.PAYMADVICEID == 'PAV0026123' //this.PaymAdviceId //
{
ppvVoucher = VendTrans.VOUCHER;
break; // Only need the first PPV voucher, so exit the loop after the first result
}
return ppvVoucher;
}
==================================================
Can some one guide me how to solve?
Thanks Girish.
Thanks Mohit
Hi Thanakorn Kanjiropas,
If it's a display method no need of while select. Single select statement will be enough which will run for all the lines.
For like operator use like below.
display String20 ppvno() { HSTHPaymAdviceTable PaymAdviceTable; HSTHPaymAdviceLine paymAdviceLine; VendTrans VendTrans; str ppvVoucher = ""; ; select PaymAdviceTable join paymAdviceLine where paymAdviceLine.PAYMADVICEID == PaymAdviceTable.PAYMADVICEID join VendTrans where VendTrans.LASTSETTLEVOUCHER == paymAdviceLine.DOCUMENT && VendTrans.VOUCHER like "*" PPV "*" when I put this code output will show blank but if not it's sound work by logical but not match my requirement && PaymAdviceTable.PAYMADVICEID == 'PAV0026123' //this.PaymAdviceId // { ppvVoucher = VendTrans.VOUCHER; break; // Only need the first PPV voucher, so exit the loop after the first result } return ppvVoucher; }
Thanks,
Girish S.
Hi, If you want only first record then while select loop is not required. I haven't tested the code but tried to re-factor your code, please check and see if it works
select firstonly Voucher from VendTrans join paymAdviceLine where paymAdviceLine.DOCUMENT == VendTrans.LASTSETTLEVOUCHER && VendTrans.VOUCHER like '%PPV%' join PaymAdviceTable where PaymAdviceTable.PAYMADVICEID == paymAdviceLine.PAYMADVICEID && PaymAdviceTable.PAYMADVICEID == 'PAV0026123'; return VendTrans.Voucher;
André Arnaud de Cal...
291,979
Super User 2025 Season 1
Martin Dráb
230,848
Most Valuable Professional
nmaenpaa
101,156