Baanboard.com

Go Back   Baanboard.com > Forum > Baan Quick Support: Functional & Technical > Tools Development

User login

Frontpage Sponsor

Main

Poll
For ERP LN feature pack upgrade, what method of install are you using?
Installation Wizard into existing VRC
37%
Installation Wizard into new VRC
39%
Manual into existing VRC
3%
Manual into new VRC
21%
Total votes: 38

Baanboard at LinkedIn


Reference Content

Reply
 
Thread Tools Display Modes
  #1  
Old 26th October 2015, 09:28
manish_patel's Avatar
manish_patel manish_patel is offline
Senior Member
 
Join Date: Apr 2007
Location: Surat-->Bangalore, INDIA
Posts: 183
manish_patel is on a distinguished road
Baan: Baan IVc4, Baan 5.0 b - DB: Oracle 11g R2 - OS: HP-UX 11.31
MB string comparison
Baan: Other/Unknown
C/S: None/Unknown

Why below code is working in env 1 and not working in another environment? Is it due to character sets?
Code:
domain	tcptyp array.ptyp(100) |***This domain is defined as Multi Byte String 
 
for i = 1 to 10
     if 	array.ptyp(1,i) = tdsls315.ptyp
     then
              |statements
     endif
endfor

Env 1:
TSS locale : ISO88591

domain tcptyp is defined as Multi Byte String Length 9

Env 2:
TSS locale
Chinese Simplified - GB2312-80
NLS Locale: zh_CN

domain tcptyp is defined as Multi Byte String Length 18


In env 2 array.ptyp(1,i) = tdsls315.ptyp condition is never become true, where as in env 1 it is working.
If I remove trailing space from array.ptyp it is workin in Env 2 also.
__________________
Thanks & Regards,
Manish
Reply With Quote
  #2  
Old 27th October 2015, 12:19
bhushanchanda's Avatar
bhushanchanda bhushanchanda is offline
Guru
 
Join Date: Sep 2012
Location: India
Posts: 2,320
bhushanchanda has a spectacular aura aboutbhushanchanda has a spectacular aura aboutbhushanchanda has a spectacular aura about
Baan: LN FP 1-9, 10.4, a little bit of Baan IV - DB: SQL Server 2008, Oracle - OS: Windows Server 2008 R2, Unix
Hi Manish,

I guess its possible. With GB2312-80 there are times when some additional spaces fall in between. Did you tried, trim comparing them?

e.g.

Code:
if 	trim$(array.ptyp(1,i)) = trim$(tdsls315.ptyp)
     then
              |statements
     endif

Or the other way you can try is using mb.export$() for both and convert them into a similar locale and then compare it.
__________________
Regards,

Bhushan

Unless you try to do something beyond what you have already mastered, you will never grow!
Reply With Quote
  #3  
Old 27th October 2015, 15:40
vamsi_gujjula's Avatar
vamsi_gujjula vamsi_gujjula is offline
Senior Member
 
Join Date: Nov 2011
Location: hyderabad ; india
Posts: 240
vamsi_gujjula is on a distinguished road
Baan: ERPLN fp3 and 10.4 - DB: oracle - OS: Aix , Redhat linux 6
how is array.ptyp being filled up ??
__________________
Regards,
Vamsi
Reply With Quote
Sponsored Links
  #4  
Old 27th October 2015, 22:12
NPRao's Avatar
NPRao NPRao is offline
Guru
 
Join Date: Aug 2001
Location: Pacific NW, USA
Posts: 3,032
NPRao will become famous soon enough
Baan: iBaanERP-5.2a(Reger),SSA-ERP-LN-6.1,Infor LN-10.x - DB: Oracle-10g,11g,12c,MS-SQL - OS: HP-UX, Linux, Windows
Yes, that is due to the Multi byte setup. I don't have much experience with the Baan-4 releases in the recent years.
I found some information from my old docs, you can check for some docs related to your version on the Infor Extreme site and also refer to some of the TSS docs, MB functions in the programmers manual.
Quote:
3.2 TSS Character Sets
There is a useful menu mtttss3000m0000 to manage TSS related information. You can goto those sessions described below via this menu.
TSS Character Sets
The "TSS Character Sets" defines the rule how to convert Native encoding from/to TSS encoding. This is maintained by the session "TSS Characters Sets"(tttss0101m000 - B50c). Please refer the help for the usage of each field.
Character Set Name
Note it is necessary to define the name of the "Character Set" before defining the Character Set by using the session "Character Set Names"(tttss0108m000 -- B50c). You also must set the font for each character set. Although BX is not supported, the "display width" is required.
Character Set Locale
The "Locale" information is defined by the session "Character Set Locales"(tttss0104m000).
In this session, "TSS Locale" means the name of the native character set in Baan and "NLS Locale" means the locale of OS to be associated to Baan's locale.
The "MB factor" is the ratio of the storage size and the display width(column).
eg. "MB factor" for Chinese is 2 because the storage size is 4(byte) and the display width is twice as large as ASCII characters. However, there is a problem for Japanese. In Japanese character, there are characters called "Half-Width-Katakana" which have the same display width as ASCII characters. "MB factor" for Japanese is set to 2 now.
Baan's locale name can be overridden by the environment variable BSE_LOCALE.
3.3 Language
The "Language" information is defined in the session "Language"(ttaad1110m000). The language information is used in the session "User Data".
Baan's language can be overridden by the environment variable BSE_LANG.
3.4 Locale on each DBMS
You must indicate below locale in $BSE/lib/tabledef<ver> and the session "Database Definition"(ttaad4110m000)
You may have to modify in $BSE/lib/tss_locale<ver> to correct imformation.
With Oracle, BaanERP(B5.0b--) saves the locale information into $BSE/lib/defaults/db_resource. The character set information for Oracle instance is saved is the table (view?) V$PAPAMETERS or V$NLS_PARAMETERS.

3.5 Locale, Character Set, and User/Device Data
The chart hereunder expresses the dependencies between locale, character set and user/device data. The sessions enclosed by parentheses are those to maintain each information.
"User data"(ttaad2100m000) refers Language, Baan's Locale
"Device data"(ttaad3100m000) refers Baan's Locale
"Language"(ttaad1110m000)
Baan's locale(tttss0104m000) refers Character Set, and OS's locale
Character set(tttss0101m000) refers OS's locale(defined by each vendor)

7. Handling MB string in Baan 3GL
This chapter describe how to handle multi-byte string in Baan-3GL programming language.
7.1 multi-byte system and single-byte system
As for BaanERP Unix version, during installing, you will be asked you want "multi-byte enablie" or not.
When you answer "Yes" for it, the system will be the "multi-byte" system.
If you answer "No", the system will be the "single-byte" system.
It is important point because the system act differently depending on whether the system is multi-byte or single-byte.
- mb.locale.info()
Sometime, you will need to know the running system is the MB-system or SB-system.
In such case, the usual way is to call mb.locale.info().

domain tc.bool is.mb

if lval(mb.locale.info(TSS_GET_IFACTOR)) > 1 then
is.mb = true
else
is.mb = false
endif
7.2 data type for Multi-Byte characters
There is only one data type for the string data in 3GL. That is STRING data type.
This can be qualified as "MB", and string variables for multibyte characters must use this qualifier. The compiler prepares 4 byte per character for this data type.
The string variables can either be declared as single-byte strings like as:
string st.str(10)
or multi-byte strings as like:
string mb.str(10) MB
The qulifier "MB" changes how to be treated by some MB-sensitive functions or run-time system.
Supporse following string variable to following discussion.

string sb.str(10)
string mb.str(10)
domain tcmcs.s10 sbsdom | domain of string(10)
domain tcmcs.s10m mbsdom | domain of string(10) MB
Following, We call the single-byte string as "SB-string" and the multi-byte string as "MB-string".
You can put MB-characters into the SB-string as well as MB-string. As in the programming language 'C', the string type is just a sequence of bytes that might contain anything.
But a MB-character in the SB-string are treated as 4 SB-characters. ( Maybe, Some function can treat it as a MB-character even if it is in SB-string. But, I did not sure it. )
The same applies to variables declared in terms of single-byte and multi-byte string domain.
On the MB system, byte size and max column count of those variables are following. Take care that the byte size of "string MB" is different from one of "string MB domain". I can not understand why there is such difference.
variable byte size max column count
sb.str 10 10
mb.str 20(=10*2) 10
sbsdom 10 10
mbsdom 40(=10*4) 10
7.3 Substring operator
Note that in the substring operator "str(m;n)", the argument m and n implies character count on MB-system.
Besides, note that the 2nd, 3rd and 4th bytes of a TSS's 4-byte character can have the same byte value of single byte characters. The 4-byte characters are distinguished by their leading byte. As result of it, when you find a byte equal to 0x3b(semicolon) in a string, it may be a semicolon (";") and it may also be a part of a 4-byte character. So the following sample doesn't work with multi-byte characters. Note that the following code is an example of how not to manipulate a multi-byte string.

long counter
string str(10)
string mbstr(10) MB
...

|*
|* Wrong programming
|*
for counter = 1 to len(str)
if str1(counter;1) = ";" then
| do something
endif
endfor

|*
|* Right programming
|*
for counter = 1 to len(mbstr)
if mbstr(counter;1) = ";" then
| do something
endif
endfor
7.3.1 Example
Following is a example. Suppose that sb.str and mb.str contains following same multi-byte strings.
sb.str = "aあbカ"
mb.str = "aあbカ"
those byte values are 0x61, 0x9b, 0x21, 0x24, 0x22, 0x62, 0x9b, 0x21, 0x25, 0x2b
Expression Result Byte values
sb_str(1;1) "a" 0x61
mb_str(1;1) "a" 0x61
sb_str(4;1) "$" 0x24
mb_str(4;1) "カ" 0x9b, 0x21, 0x25, 0x2b
sb_str(1) "a^[!$"b^[!%+" 0x61, 0x9b, 0x21, 0x24, 0x22, 0x62, 0x9b, 0x21, 0x25, 0x2b
mb_str(1) "aあbカ" 0x61, 0x9b, 0x21, 0x24, 0x22, 0x62, 0x9b, 0x21, 0x25, 0x2b
sb_str(3) "!$"b^[!%+" 0x21, 0x24, 0x22, 0x6b, 0x9b, 0x21, 0x25, 0x2b
mb_str(3) "bカ" 0x62, 0x9b, 0x21, 0x25, 0x2b
7.4 Functions to get information for MB Character
As I explained before, as for latin language, 1 byte(8 bits) is enough to store each character code.
So, The character count is same as byte count to store them.
And as for old fixed font, we can consider all character has same display width.
As result:
1 character = 1 byte = 1 column on the display of character cell
As for Asian language, 1 byte(8 bits) is not enough to store each character code.
So, The character count is NOT same as byte count to store them.
And they need more display width. Usually, on the legacy system, the display width need to be double of one of latin language.
As for TSS encoding:
1 character needs 1 or 4 bytes to store it.
1 character needs 1 column or 2 columns on the display of character cell.
Baan provides useful functions to get such information from the string in question.
You have to understand below functions to handle string data. I mean, when you use below functions, you have to make clear which value you wants.
Function The meaning of Return value
len(string s) Returns character count. ( Not byte count, not display width. )
len.in.bytes(string s) Returns byte count.
mb.width(string s) Returns display width.
7.4.1 Example
Following is a example. Suppose that mb.str contains following multi-byte strings.( Two ASCII, one full-width HIRAGANA, and one half-width KATAKANA )
mb.str = "aあbア"
those byte values are 0x6a, 0x9b, 0x21, 0x24, 0x22, 0x6b, 0x9b, 0x21, 0x21, 0xb1
Expression Result
len(mb.str) 4
len.in.bytes(mb.str) 10
mb.display(mb.str) 5
7.5 Replace Substring operator
Baan 3GL provide replace substring functions by following syntax,

mb.str(pos;len) = mb.str2
But, we can not use it for MB-string.
When you try to replace substring, if multi-byte characters and single-byte characters are mixtured, (It is usually, ) the function will cause the unexpected result. TSS encoding will not be corruped, but the result will not what you want. )
During executing the expression,"str(pos;chcnt) = ins", as first, the storage space for the substring str(pos;chcnt) is filled by space characers(0x20). Then, ithe content of the string 'ins' is copied to the storage space.
For the example,
1. When 'str' is "あいうえおかきくけこ", and 'ins' is "abc",
The result of 'str( 2; 3 ) = ins'
is "あabc おかきくけこ"
2. When 'str' is "abcdefghijk", and 'ins' is "あいう",
The result of 'str( 2; 3 ) = ins'
is "a efghijk".
The result of 'str( 2; 4 ) = ins'
is "aあfghijk"
Actually, in most case, 'pos' and 'len' are intended to be <column position> and <column count>.
So, we have to following conversion.
1. pos = mb.strpos( str; pos ) -- We have to take care that this conversion must work even if pos overs the end of str.
2. lent has to be corrected by the content of str.
Below function is the function to be called as inseted of 'str(pos;len) = ins'.

|*---------------------------------------- |#150185-1.sn
|* Function mb.field.replace
|*Description:
|* Implement insertion into the middle of string specifying the column
|* position.
|*Comment-1:
|* For multi-byte string next line's code generates unexpected result.
|*
|* tmp.buffer$( start.pos, level; field.len) = edi.data
|*
|* For example:
|* str = "abcdefghijklmn"
|* ins =
|* str(2;1) = ins
|* |Now, str is "a cdefghijklmn". the character in "ins" was not copied.
|*
|*Comment-2:
|* For multi-byte string, column position and index in the string are
|* different, because one multi-byte character need 2 display-column-width.
|* For example
|* string str3(3) MB
|*
|* When it contain 3 multi-byte characters,
|* 6 == mb.width(str3)
|* 3 == len(str3)
|* 2 == mb.width(str3(1;1))
|* 2 == mb.strpos(str3, 5)
|* When it contain 3 ASCII characters,
|* 3 == mb,width(str3)
|* 3 == len(str3)
|* 1 == mb.width(str3(1;1))
|* -1 == mb.strpos(str3, 5)
|* 3 == mb.strpos(str3, 3)
|*
function string field.replace(
string str(MAX.REC.LENGTH) MB,
long clmpos,
long width,
string ins(MAX.REC.LENGTH) MB )
{
string tail.str(MAX.REC.LENGTH) MB
string ins.str(MAX.REC.LENGTH) MB
string result.str(MAX.REC.LENGTH) MB
long lclm.pos
long rclm.pos
long ix
long lack
long tail.padding_b
long padding_b
|*
|* Check argument
|* str(lclm.pos..rclm.pos) is replaced by ins.
|*
lclm.pos = clmpos
rclm.pos = clmpos + width -1
if ( width < 1 or clmpos < 1 ) then
return(str)
endif
|*
|* make tail-part.
|*
|*!! mb.strpos() return last index for exceeding screen position
|* with the porting-set 6.2a.03.02
|*
ix = mb.strpos( str, rclm.pos+1 )
if ix > 0 and mb.width( str ) >= rclm.pos then
if ( mb.strpos( str, rclm.pos ) = ix ) then
tail.padding_b = true
ix = ix+1
else
tail.padding_b = false
endif
tail.str = str(ix)
else
tail.str = ""
endif
|*
|* check word to be inserted.
|* make ins.str
|*
ix = mb.strpos( ins, width+1 )
if mb.width(ins) >= width+1 and ix > 0 then
if ( mb.strpos( ins, width ) = ix ) then
padding_b = true
else
padding_b = false
endif
ins.str = ins(1;ix-1)
if ( padding_b ) then
ins.str = ins.str & ">"
endif
else
ins.str = ins
lack = width - mb.width( ins )
while ( lack > 0 )
ins.str = ins.str & " "
lack = lack - 1
endwhile
endif
if ( tail.padding_b ) then
ins.str = ins.str & " "
endif
|*
|* check left part of inserted string
|*
ix = mb.strpos( str, lclm.pos )
if mb.width(str) >= lclm.pos and ix > 0 then
if ( lclm.pos > 1 and mb.strpos( str, lclm.pos-1) = ix ) then
padding_b = true
else
padding_b = false
endif
result.str = str(1;ix-1)
if ( padding_b ) then
result.str = result.str & ">"
endif
else
result.str = str
lack = lclm.pos - mb.width(str) -1
while ( lack > 0 )
result.str = result.str & " "
lack = lack - 1
endwhile
endif
result.str = result.str & ins.str & tail.str
return(result.str)
} |#150185-1.en
7.6 shiftr and shiftc for MB string
shiftr$() and shiftc$() function also don't work for multi-byte string. Because it works storage size based.
For example, When mb.sdom(10) is the variable of the domain which is string (10) MB, and the content is "abc", the result of shoftr$(mb.sdom) is
" abc".
Below functions are the substitutions of shiftr$() and shiftc$().

|* Start: DF17314-1: khiguchi
|* I don't know how to declare variable size string.
|* And I can not specify MB for retuen value. The compiler display error msg.
|+
function string mbstr.shiftr( string mbstr(132) MB, long clmcnt )
{
long spc_cnt

spc_cnt = clmcnt - mb.width( strip$(mbstr) )
if spc_cnt > 0 then
mbstr = string.set$( " ", spc_cnt ) & strip$(mbstr)
endif
return(mbstr)
}
|+
|* End: DF17314

|* I don't know how to declare variable size string.
|* And I can not specify MB for retuen value. The compiler display error msg.
|+
function string mbstr.shiftc( string mbstr(132) MB, long clm_cnt )
{
long spc_cnt

spc_cnt = clm_cnt - mb.width( strip$(mbstr) )
spc_cnt = spc_cnt / 2
if spc_cnt > 0 then
mbstr = string.set$( " ", spc_cnt ) & strip$(mbstr)
else
mbstr = strip$(mbstr)
endif
return( mbstr )
} |DF89411-1.en
__________________
The art of perfection does not lie in doing extraordinary things but, doing ordinary things extraordinarily well. [-N. Prashanth Rao]
How To Ask Questions The Smart Way,BaaNBoard,NPRao
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
DEV: Export any Baan table to (proper) Excel Francesco Code & Utilities 27 2nd September 2011 15:00
Writing Export Conditions ian_j_albert Tools Development 4 22nd July 2010 08:30
Help regarding tools session rahul.kolhe22 Tools Development 4 22nd January 2010 14:31
problems with stpapi.zoom.option Finnigan AFS/DDC/OLE: Function servers 5 3rd November 2009 15:04
File Browser Bogdan Tools Development 52 7th January 2004 09:17


All times are GMT +2. The time now is 04:35.


©2001-2017 - Baanboard.com - Baanforums.com