Ciesiel
23rd February 2016, 10:16
I would like to write the query:
select dmcom010.srid (38, 4): o_emp_grp from dmcom010, tfacp100
^ Where dmcom010.fmid = 'FATT_DOC_REV'
^ And dmcom010.trid = '{' & tfacp100.ninv & '}'

where for example. tfacp100.ninv = 529 and dmcom010.trid = {529}
I got an error. When I use "{529}" instead of variable everything works

Concat $ also does not work

Can anyone help me?

bhushanchanda
24th February 2016, 07:57
Hi,

You need to use something like this in your 4GL script.-

domain dmcom.lnkd temp.trid

select tfacp200.ninv
from tfacp200
selectdo
temp.trid = "{" & str$(tfacp200.ninv) & "}"
select dmcom010.*
from dmcom010
where dmcom010._index1 = "FATT_DOC_REV"
and dmcom010.trid = :temp.trid
selectdo

|**** Print or process the record
endselect
endselect

It won't be possible to do it in a query directly. For that, you can select dmcom010 records and in your report script you can handle the printing.

e.g.

Main query -

select dmcom010.*
from dmcom010
where dmcom010._index1 = "FATT_DOC_REV"


And in your report script you can write this -



declaration:
table ttfacp200
domain tfgld.docn docn
detail.1:
before.layout:



lattr.print = false
string.scan(dmcom010.trid,"{%d}",docn)
select tfacp200.*
from tfacp200
where tfacp200.ninv = {:docn}
selectdo
lattr.print = false
endselect


Though its not a good idea to compare directly with the document number as it may repeat for different transaction types.

Ajesh
24th February 2016, 18:42
Where do you want or intend to write it? SQL Queries or in 4 GL script or Report Script?

Ciesiel
26th February 2016, 12:12
Thank you bhushanchanda.
Ajesh I write in 4GL.

I wrote:
select tglpl200.wdoc
from tglpl200,tglpl100,dmcom010
where tglpl200.wdoc=tglpl100.wdoc
and tglpl100.obid=dmcom010.trid
and tglpl200.ninv = tfacp100.ninv - in this table,Idont need to use to connect { with ninv.

Ajesh
29th February 2016, 09:11
If dmcom010.trid and tfacp100.ninv do not belong to same domain they cannot be compared,Looks like the domain of tfacp100.ninv is long and dmcom010.trid is string.

tfacp100.ninv needs to be converted to string and then compared.



string hold.ninv

select tfacp200.ninv
from tfacp200
where tfacp200._index1 = {:hold.val1,:hold.val2} |tfacp200 record is |selected first according to the selection criteria
selectdo
hold.ninv = '{' & strip$(str$(tfacp200.ninv)) & '}'
select dmcom010.srid(38,4):o_emp_grp
from dmcom010
where dmcom010.fmid = 'FATT_DOC_REV'
and dmcom010.trid = :hold.ninv
selectdo
|The actions which you need to do
endselect
endselect



In the second example, looks like both the fields belong to the same domain.