showstuff11
13th March 2015, 07:22
Hi all!

i want to extract tcmcs050.seri in tdsls400.orno so that i can get the first and
last used series with date.

is this possible?

i think this is the easiest way to extract the first and last usage with date in any table that uses a specific number group/s


example:
Series |Description | First free numbers (or last used just -1)

MBD1 |BangS FG Bin Invoice |316
MBE1 |BangS FG Pil Invoice |3
MBG1 |BangS FG Pam Invoice |10



| FIRST USED
select TOP 1 tdsls400.odat , tdsls400.orno
from tdsls400
where tdsls400.orno(MBD100001) = "MBD1"
ASC
selectdo
First used= tdsls400.orno
First used date= tdsls400.odat
endselect


| LAST USED
select TOP 1 tdsls400.odat , tdsls400.orno
from tdsls400
where tdsls400.orno(MBD100316) = "MBD1"
DESC
selectdo
First used= tdsls400.orno
First used date= tdsls400.odat
endselect

the above report script is just an imagination of mine

i hope you understand what im saying... its been a week since i thought of this..

Thank all!

soumya093
13th March 2015, 08:02
To get the first record
Set Order by tdpur400.orno ascending
as set with 1 rows
To get the last record
Set Order by tdpur400.orno descending
as set with 1 rows

bhushanchanda
13th March 2015, 08:12
domain tcorno first.used
domain tcorno last.used
domain tcdate first.used.date
domain tcdate last.used.date

| FIRST USED
select tdsls400.odat , tdsls400.orno
from tdsls400
where tdsls400.orno(1;4) = "MBD1"
order by tdsls400._index1 asc
as set with 1 rows
selectdo
first.used= tdsls400.orno
first.used.date= tdsls400.odat
endselect


| LAST USED
select tdsls400.odat , tdsls400.orno
from tdsls400
where tdsls400.orno(1;4) = "MBD1"
order by tdsls400._index1 desc
as set with 1 rows
selectdo
last.used= tdsls400.orno
last.used.date= tdsls400.odat
endselect

showstuff11
14th March 2015, 05:50
Hi bhushanchanda,

what does " tdsls400.orno(1;4) " means?
what does (1;4) do?
i already search for this but i got no clear reference on this subject

Thank you for your help!!

bhushanchanda
14th March 2015, 06:00
It will compare first 4 charachters of tdsls400.orno

If you do not use that you need to do something like that

where tdsls400.orno = "MBD1 "

Or

where tdsla400._index1 = "MBD1 "

bdittmar
14th March 2015, 10:59
Hello,

it looks like there are missing 4GL basics.

field(x;y)

read string from character x with y characters

... tcibd001.item(10;12)
takes 12 characters starting at character 10 from field tcibd001.item

for variable length of substrings or different startpositions for a substring use POS

pos(), rpos()
Syntax:

function long pos ()function long rpos ()

Description


These return the start position of a specified substring ( pattern ) in a specified string ( source ). source and pattern can be either strings or string expressions.

pos() starts searching for the substring at the first position in the source string. rpos() starts searching at the last position in the source string. Both return the start position relative to the beginning of the source string.


Return values

The start position of the substring in the string. Or 0 if the substring is not found.

Context

This function can be used in all script types.

Example

long posno
posno = pos("abcdabcd", "bcd") | posno contains 2
posno = rpos("abcdabcd", "bcd") | posno contains 6

Regards