johnmark
5th April 2013, 17:17
Hi All,

I want to split string in report script, by giving position number of characters. So, How can I do that?

Plz Help

mark_h
5th April 2013, 17:28
Not sure what you are saying but you can use tiitm001.dsca(1;15) to just get the first 15 characters of a string.

johnmark
5th April 2013, 17:38
function get.tax.rate()
{
select tcmcs032.pvat:perc4,tcmcs032.edat
from tcmcs032
where tcmcs032._index1 = {:tcmcs036.ccty,:tcmcs036.cvat}
and tcmcs032.edat < :cur.date
order by tcmcs032.edat desc
as set with 1 rows
selectdo

endselect
if not isspace(tax.code) then
tax.code = tax.code & " amount"
endif


}



Above tcmcs032.pvat gives only substring i.e. last 5 characters. So how can I resolve that?

Thanks

johnmark
5th April 2013, 17:43
Thanks for quick reply. I want to display tax code in report. But in report it will display half tax code. So I want to resolve that.

Plz Help

BaanInOhio
5th April 2013, 18:06
tcmcs032.pvat is a number = tax rate, not a string. The tax code is nine characters in tcmcs032.cvat. Tax codes (description) are stored in tcmcs037, which you could use tcmcs032.cvat in a refers to clause to get description:


select tcmcs032.pvat:perc4,tcmcs032.edat,tcmcs037.dsca
from tcmcs032, tcmcs037
where tcmcs032._index1 = {:tcmcs036.ccty,:tcmcs036.cvat}
and tcmcs032.edat < :cur.date
and tcmcs032.cvat refers to tcmcs037 unref clear
order by tcmcs032.edat desc
as set with 1 rows
selectdo
endselect


If you want the full description of the tax code:

if not isspace(tsmcs037.dsca) then
tax.code = trim$(tsmsc037.dsca) & " amount"
endif


If you want the tax code only:

if not isspace(tsmcs036.cvat) then
tax.code = trim$(tsmsc036.cvat) & " amount"
endif

mark_h
5th April 2013, 18:34
Either that or find where tax.code is defined and increase the size of it so it can store everything needed.

johnmark
6th April 2013, 09:08
extern domain tcperc perc4
extern domain tcmcs.str10 tax.code

function domain tcbool export.order()
{
select tdsls400.orno, tdsls400.rats
from tdsls400
where tdsls400._index1 = {:r.order.nr}
and tdsls400.expo.l = tcyesno.yes
selectdo
| exch.cur.rate = tdsls400.rats(1)
get.rate()
exch.cur.rate = cisli205.rate(1)
return(true)
endselect
return(false)
}

function get.rate()
{
cisli205.rate(1) = 0.0
select cisli205.rate
from cisli205
where cisli205._index1 = {:r.ih.fin.comp,:r.ih.trns.typ,:r.ih.doc.nr}
selectdo
endselect
}


function get.tax.code()
{
select tdsls401.cvat, tdsls401.bptc
from tdsls401
where tdsls401._index1 = {:r.order.nr, :r.order.line}
as set with 1 rows
selectdo
select tctax941.cvat,tctax941.ccty
from tctax941
where tctax941._index1 = {:tdsls401.bptc,:tdsls401.cvat}
selectdo

select tcmcs036.indt.l,tcmcs036.ccty,tcmcs036.cvat
from tcmcs036
where tcmcs036._index1 = {:tctax941.ccty,:tctax941.cvat}
and tcmcs036.smpl = tcyesno.yes
selectdo
if tcmcs036.indt.l = tctax.indt.l.cst then
tax.code = "CST"
get.tax.rate()
else
if tcmcs036.indt.l = tctax.indt.l.vat or tcmcs036.indt.l = tctax.indt.l.n.a then
tax.code = "VAT"
get.tax.rate()
endif
endif
endselect
endselect

endselect
}

function get.tax.rate()
{
select tcmcs032.pvat:perc4,tcmcs032.edat
from tcmcs032
where tcmcs032._index1 = {:tcmcs036.ccty,:tcmcs036.cvat}
and tcmcs032.edat < :cur.date
order by tcmcs032.edat desc
as set with 1 rows
selectdo



endselect
if not isspace(tax.code) then
tax.code = tax.code & " amount"
endif



}



function get.discount.and.netamount()
{
select cisli205.*
from cisli205
where cisli205.sfcp = :compnmbr
and cisli205.ityp = :r.ih.trns.typ
and cisli205.idoc = :r.ih.doc.nr
selectdo

endselect
}



This is code for that tax code.
When I print perc4 in layout it displays percentage of tax code but when there are aggregate tax in sales order it displays only first tax code percentage. So what is the solution to get full tax code in report?

mark_h
6th April 2013, 23:57
Is this in a special layout? If so the first thing you have to do is remove the "as set with 1 rows" from the right query. Not sure which one is limiting since we do not use these tables. Then search for "layout again" on this forum. There are examples showing you how to print a layout multiple times in a report to extract information from another table.