gmmisdt
30th December 2017, 06:22
Hi,
I use tcibd001.exin field as per my reuirement and when m going to compare this field with another table in which field's datatype is double and tcibd001.exin is string now while comparing its give error as attached.

FInd attached my query below.
|******************************************************************************
|* tdsls4401mc02 0 VRC B61O a live
|*
|* VJJI
|* 2017-12-28
|******************************************************************************
|* Main table tdsls401 Sales Order Lines, Form Type 4
|******************************************************************************

|****************************** declaration section ***************************
declaration:

table ttdsls401 | Sales Order Lines
table ttcibd001
table ttdtrg190
extern domain tcqsl1 back.qty

|****************************** program section ********************************


|****************************** group section **********************************

group.1:
init.group:
get.screen.defaults()

|****************************** choice section ********************************

choice.cont.process:
on.choice:
execute(print.data)

choice.print.data:
on.choice:
if rprt_open() then
read.main.table()
rprt_close()
else
choice.again()
endif


|****************************** field section *********************************

field.orno.f:




|****************************** function section ******************************

functions:

function read.main.table()
{


select tcibd001.exin,sum(tdsls401.qbbo):back.qty,tdtrg190.prmx
from tdsls401,tcibd001,tdtrg190
where tdsls401.item = tcibd001.item and tdsls401.qbbo > 0 and tcibd001.exin <> "" and val(tcibd001.exin) >= tdtrg190.cpfm and sval(tcibd001.exin) <= tdtrg190.cpto
group by tcibd001.exin,tdtrg190.prmx
selectdo
rprt_send()
endselect
}


Regards,
Vishal

JaapJD
2nd January 2018, 15:38
You should not use the val() function but the SQL CAST expression. See the Programmer's Manual.

pralash
3rd January 2018, 08:06
Hi,
You may be use the Lval function for converting string to long as per your requirement....

Syntax:
function long lval (string value)

Description

This function performs explicit string to long type conversion.

Regards,
Pralash

gmmisdt
4th January 2018, 05:29
Hi,
I try val() and lval() too but its not working.
I found on internet that this function not work in report script..?
is it true?
Need to find other way for this.


Regards,
Vishal

pralash
4th January 2018, 08:34
Hi,

1. Declare a double variable and assign the value of the string variable to it using val() function

e.g.
Code:
domain tcamnt amnt_val
string amnt_str

amnt_str = "182.22"
if not isspace(amnt_str) then
amnt_val = val(amnt_str)
else
amnt_val = 0
endif

2. On your report layout, use val(amnt_str) and use domain like tc amnt

JaapJD
4th January 2018, 12:15
val() and lval() do work in report script, but not in SQL queries. Try my suggestion with the CAST expression.

gmmisdt
8th January 2018, 05:43
Hi,
Its working using CAST.
Thnks guys.

Regards,
Vishal