cancel
Showing results for 
Search instead for 
Did you mean: 

Delete leading zeros

pekka_pottonen
Participant
0 Kudos

Hi,

I need to drop out leading zeros of data in javascript.

I am combining several fields of data into one output textfield. One of these data elements is salesman number (0000012345) with leading zeros and we do not want to display those.

Any way of achieving this with javascript?

Regs

Pekka

Accepted Solutions (0)

Answers (2)

Answers (2)

OttoGold
Active Contributor
0 Kudos

You can, of course, add some ABAP code into your interface. Well, I don´t recommend people to do that, but this can be the case to solve a problem quickly. And... If I remember well, you could solve this by setting some field attributes in your LCD, not sure if in any version, but should be possible in LCD 8.1.

In this one: http://help.adobe.com/en_US/livecycle/es/FormCalc.pdf there are string operations from page 91. You can copy the value of the field into the variable and then cut off the leading zeros one by one.

Or maybe somebody else could suggest some cleaner solution:))

Regards Otto

pekka_pottonen
Participant
0 Kudos

Hi,

Field that displays data has to contain salesman name also, so it cannot be set as numeric field.

Rest of the scripting is done with JavaScript, can I also use Formcalc among JavaSript?

Looping through salesman number sounds little bit "old fashioned", is it really that there is no function/method that can handle the job?

Regards,

Pekka

OttoGold
Active Contributor
0 Kudos

Cool. It is not a numeric field, so you can do all the string tricks. example: you can parse the string into the array (split by SPACE for example). I believe you can use FC and JS in one form but that is NOT recommended, because it would be confusing to maintain all the scripts. I don´t understand the old fashioned part, what function do you need? I don´t understand how do you create the "real value" of the field. You have two hidden: a) for number and b) for name and concatenate these two into a third one? If you don´t provide enough details, it is really difficult to help. Otto

pekka_pottonen
Participant
0 Kudos

Hello,

In "old fashioned" i mean that looping feels mainly stupid solution, since there are nice functions to do that, well, seems that some other programming languages do.

I found a solution. One could say that KISS-principle works here and the last S is for me.

If I have datavalue 0000012345 and I need just 12345, script is like this

TEST2.rawValue = 1 * List1.item(i).PARTNER_PERNR.value;

the I just add name of salesman and voilá, I have what I need.

-Pekka-

OttoGold
Active Contributor
0 Kudos

By the way, do you know you can do this in backend, right? Of course you can do this with javascript (or formcalc). Find the examples yourself here:

http://www.adobe.com/devnet/livecycle/articles/lc_designer_scripting_basics/lc_designer_scripting_ba...

http://help.adobe.com/en_US/livecycle/es/FormCalc.pdf

Regards Otto

pekka_pottonen
Participant
0 Kudos

Hi Otto,

In backend it is hard, since we have data collection organized by framework. I only have datastructure to use from interface on. Unless it can be done in interface?

I have downloaded all scripting pdf:s, but yet I have not found a solution. I could put data to hidden numeric field and use it from there, but this is not a good solution.

Regs,

Pekka