cancel
Showing results for 
Search instead for 
Did you mean: 

How to use LENGTH function In transformation file

Former Member
0 Kudos

Hi,

Currently we are working on NW BPC 10.0

I am trying to validate below transformation file, but I am getting error near length function.

Can anyone help me how to use length function or any other option.

Here ACCOUNT is coming from flatfile with value similarly like 123,it should be converted into AA_00000123 if length of ACCOUNT is equal to 3.

Thanks in Advance.

Regards

Anitha

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

It is working.

regards

Anitha

former_member186338
Active Contributor
0 Kudos

I still think that single line: js: "AA_"+("0000000"+%external%.toString()).slice(-8) is better then multiline: ?,??,???,?????...

Vadim

Former Member
0 Kudos

Thank you Vadim. it is working

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Anitha,


I don't know how to achieve this through Transformation file,  but  i know you can do this through end routine.


In end routine you will get the list of data in one internal table, you can put your validation on "Account Length" and can achieve whatever you want.


To Achieve this, you need to implement UJD_ROUTINE Badi.


Regards

Rohit

former_member186338
Active Contributor
0 Kudos

Hi Rohit,

It's absolutely strange to perform an easy job using ABAP badi...

Vadim

former_member186338
Active Contributor
0 Kudos

Hi Anitha,

Where have you read that you can use something like LEN in transformation file???

And yes, the test can be performed in conversion using JavaScript:

js: (%external%.toString().length=3) ? "AA_00000" + %external%.toString() : "SOMETHING??"

Vadim

Former Member
0 Kudos

Hi Vadim,

Thank you for your spontaneous reply.

I have tried the java script which you have given.

It is validated successfully.But every time the condition is taking true value, it is not going to false statement. please see the screen shot for more details.

Anitha.

former_member186338
Active Contributor
0 Kudos

After you posted the real requirements I have already answered with another JavaScript code:

js: "AA_"+("0000000"+%external%.toString()).slice(-8)

Vadim

Former Member
0 Kudos

Hi Anitha,

Do you wan to prefix AA_00000 to all your account? please supply more info what all accounts.

Use conversion file rather then in the transformation file.

have a look here for help:

Andy

Former Member
0 Kudos

Hi Andy,

ACCOUNT Id's coming from source are may be single digit or two digit or three digit  or four digit  number. But in destination it should be eight digit number padding with zeros and AA_.

(Ex: if source is 123 then destination should be AA_00000123,

       if source is 7654 then destination should be AA_00007654,

       if source is 567823 then destination should be AA_00567823).

With the help of Transformation and conversion files we have to achieve this.

I have tried using padding function in transformations, I can be able to add zeros but I couldn't be able to concatenate AA_.

May be we have to use start routine and end routine for this.

Anitha

former_member186338
Active Contributor
0 Kudos

"I have tried using padding function in transformations, I can be able to add zeros but I couldn't be able to concatenate AA_" - have you tested:

*Str(AA_) + *PAD(...)

Not sure that it will work... If not - go to JavaScript in conversion

Former Member
0 Kudos

Hi Anitha,

You need to look at internal format while loading data, then all the leading 0s will be retained, all you need to do is append prefix AA_ which is very easy to do in transformation file.

Andy

former_member186338
Active Contributor
0 Kudos

JavaScript with AA_ prefix and 8 characters padding:

"AA_"+("0000000"+%external%.toString()).slice(-8)

Vadim