BaaN ERP中字符转换string.scan用法举例

首先,我有一些疑问,BaaN开发中有Str$的函数,用来把其他类型的Data转换成字符型,到底有没有什么专用的函数把其他类型转成数字型?

我暂时没有找到,只能用string.scan()函数来完成一个客户的要求.
大家知道PO Line里面有一个Text的纪录:Tdpur401.txta,客户的要求就是从一个reference中取出PO Number以及PO Position Number,然后取出PO Line’s Text.

我们从reference中取出的PO Number和PO Position Number 都是字符型,而实际上tdpur401 table中,PO number是字符型,而PO Position Number是Int类型!

只有转换:
long pono.g | PO Position Number
extern domain tcmcs.str4 pono | PO Position Number

string.scan(pono,”%d”,pono.g) | Convert to Long Type

select tdpur401.txta
from tdpur401
where
tdpur401.orno = :Orno.g and
tdpur401.pono = :pono.g
As set with 1 rows
Selectdo
Endselect

String.Scan()标准用法

Syntax

long string.scan( str_expr, string format(.) [, variable, …] )

Description

This scans an input string (str_expr) for one or more fields and stores each individual field found in the first available variable argument. The format argument contains conversion symbols that the function uses to interpret the input string and retrieve the individual field values. The conversion symbols indicate the types of values expected:

%s expects a single-byte or multibyte string

%f expects a double

%d expects a long

An input field is defined as all characters up to the next separator character or up to the next character that does not match the type of the corresponding conversion symbol.

A separator character is a single character used to separate individual values in the input string. It can be a space character, or any other character that is not used within individual fields in the input string. You cannot use multibyte characters as separators.

The string.scan() function scans the input string using each conversion symbol in the format argument in turn. For each conversion symbol, it scans the input string for characters that match the specified format. It stops scanning when it meets a separator character or a character that does match the expected type.

For example, consider the following function call:

string.scan( input_string, “%d|%f”,long,double )

In this case, the function expects input_string to contain two separate numeric values. It reads the input string until it meets a pipe [|] character (this is the separator specified in the format argument). It then converts the characters read (excluding the separator) to a long value and stores that value in the long variable. The function then continues scanning the input string using the next conversion symbol in the format argument.

Note that if two conversion symbols are separated by more than one separator character, the function ignores those characters unless they match the input.

Return values

The function returns the number of scanned fields.

Context

Bshell function.

Example

double D

long L

string S(80)

long ret

ret = string.scan(“string 123 456.78″,”%s %d %f”,S,L,D)

| S contains “string”, L contains 123, D contains 456.78

ret = string.scan(“string|123|456.78″,”%s|%d|%f”,S,L,D)

| S contains “string”, L contains 123, D contains 456.78

本文首发于中国最大的BaaN ERP论坛西山之家:[URL=http://www.xihome.com]http://www.xihome.com[/URL]

Loading

《BaaN ERP中字符转换string.scan用法举例》上有1条评论

  1. ERP Application Supervisor
    Requirements:
    • University degree in IT, Computer Science or related majors.
    • Min. 2-3 years experience in ERP and MRP systems, experience with full cycle ERP implementation projects (especially BAAN ERP) would be added advantage.
    • The applicant should be well versed with the application of ERP modules such as sales, purchasing and manufacturing.
    • Good command of both written and spoken English.
    Major Responsibilities:
    • Support and training of the key-user during the implementation process of BAAN ERP.
    • Ongoing support of the end-user after completion of the implementation project.
    • Analysis and improvement of business processes with the help of BAAN ERP.
    • Troubleshooting of BAAN ERP configuration deficiencies.

    Tel:+86-22-6046-4966
    E-mail:echosi@3ctc.com
    MSN:echo_si2008@hotmail.com

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据