Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

string function fill out field to avoid matching key

hi i have the following question.

i wish to avoid the following scenario by setting the length of my fields to 6 and 3 accordingly and filling the blank values with 0.

OrdernrRowNr
W100120
W100120

Desired result.

Ordernr (set to 6 character)RowNr (set to 3 characters)
00W1001020
W100120

is this possible?

Best

Brad

1 Solution

Accepted Solutions
maxgro
MVP
MVP

you say you want length of 6 and 3 but your desired result is diffferent

SCRIPT

Inline:

load OrderNo, text(RowNo) as RowNo;

LOAD * INLINE [

    OrderNo, RowNo

    W1001, 20

    W100, 120

];

Load

repeat('0', 6 - len(OrderNo)) & OrderNo as OrderNo,

repeat('0', 3 - len(RowNo)) & RowNo as RowNo,

autonumber(OrderNo & RowNo) as %Key

Resident Inline;

drop table Inline;

RESULT (lOrderNo ength 6, RowNo length 3)

OrderNoRowNo
0W1001020
00W100120

View solution in original post

1 Reply
maxgro
MVP
MVP

you say you want length of 6 and 3 but your desired result is diffferent

SCRIPT

Inline:

load OrderNo, text(RowNo) as RowNo;

LOAD * INLINE [

    OrderNo, RowNo

    W1001, 20

    W100, 120

];

Load

repeat('0', 6 - len(OrderNo)) & OrderNo as OrderNo,

repeat('0', 3 - len(RowNo)) & RowNo as RowNo,

autonumber(OrderNo & RowNo) as %Key

Resident Inline;

drop table Inline;

RESULT (lOrderNo ength 6, RowNo length 3)

OrderNoRowNo
0W1001020
00W100120