cancel
Showing results for 
Search instead for 
Did you mean: 

How To Suppress Leading Zeroes

Former Member
0 Kudos

Can someone give a new modeler a tip on how to suppress the leading zeroes in a field? Order number, for example, is returned with many leading zeroes, and each dynamic expression I choose doesn't seem to work.

Thanks in advance!

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member206397
Contributor
0 Kudos

Hi Mark,

As per my knowledge in VC you can not set the length. If you use BAPI or Web Service then you need to do it from the source application.

Thanks

Chandan

Former Member
0 Kudos

From which system do you get the order number (Query or BAPI)?

Best Regards,

marcel

Former Member
0 Kudos

I get the field from a custom BAPI. I use the same BAPI in our e-Business web site, and have written a Java method to re-format the field, but I don't believe we can write custom Java code with VC, can we?

I was thinking that I could translate the text to an integer, then format that result using NSTR and a formatting mask of 'P'. But no matter what I try to use with the INT function, I get the check message that the function expects a text or string - even if I use a quoted value, like '99' or "99".

Former Member
0 Kudos

Hi Mark,

if you use a custom BAPI, then you can use the convert function modules (there are two function modules for converting: 1.) from external to internal format 2.) from internal to external) I think you have to use a alpha conversion to external format (this is a standard SAP function module).

Best Regards,

Marcel

Former Member
0 Kudos

Thanks, Marcel, but the problem is that I cannot institute a change in the BAPI as it is used in our e-Business system. I'm re-using it for the Portal, so I have to suppress the leading zeroes on the Portal side. So, again, can I use the expressions editor, somehow, to suppress leading zeroes?

Also, is there a document somewhere listing <u>all</u> of the available expressions and defining how they are used? I've seen the "Frequently-Used Dynamic Expressions" section of the Visual Composer Modeling Guide, but am looking for some kind of master list.

Former Member
0 Kudos

Hi Mark,

this doesn't matter that you use it in your e-Business System. Create a new function module, which calls your BAPI then add the coding for removing the leading zeros (convert function module) this is faster then in the portal and is done in a few minutes.

Best Regards,

Marcel

Former Member
0 Kudos

I don't want to sound combative, but the answer you've given me is not acceptable. Why create a new function module when Visual Composer (VC) allegedly has functions to be able to manipulate the data coming from the BAPI? Am I missing something?

After all, this is the <i>Visual Composer</i> forum. If the answer is "no, VC can't do that" I can accept it and move on. But the modeler's guide seems to infer that it can be done.

Former Member
0 Kudos

Hi Mark,

if you don't want to use the backend system then try it with a formula.

But as I told you, this needs more efforts and also the performance is not as good as using a function module.

If you know the length of your returned number then you can create a long formula like:

if(left(@value,1)==0,if(right(left(@value,2))==0,...

so that you can check every digit from the left to the right and if a digit is not null then you can replace the every 0. It's not easy, but you want do this in this way.

Best Regards,

Marcel

Former Member
0 Kudos

As I said before, the easiest way I know to do this is to take your data, order number string "0000000000001234567", translate it to an integer - 1234567 - then re-translate that to a formatted string.

I have actually come up with an answer, but am not sure that I like how it has to be done. First, I changed the Control Type for field VBELN (order number) to "None". Then I created two additional fields in the output table view. The first is named fmtOrdNum. Its Control Type is "None", meaning it won't be displayed, and its default value is INT(@VBELN). The second field is named fmtOrdNum2. This field is displayed, and has a default value of NSTR(@fmtOrdNum, 'P'). The resulting output is what I wanted to see - leading zeroes are suppressed.

The reason I'm not happy with this is that I'm not sure that two additional fields should have to be created. I'm looking for the place to tell VC to manipulate (format, in this case) the fields it's received from the BAPI before it places them on-screen. So additional questions remain:

1. How do you instruct VC to apply formatting to a field before placing it on-screen? Is this done on Control Properties, and where?

2. Can expressions be nested - e.g. NSTR( INT(@@), 'P') - and to what level?

former_member194198
Active Participant
0 Kudos

The expression NSTR(@MATNR,'B') where @MATNR is your field with leading zeros removes them for me.

Cheers

Richard

former_member203650
Participant
0 Kudos

It may be two years after this thread was posted, but I wanted to share what worked for me. I needed to suppress the leading zeroes on the Service Notification number coming from R/3. The following expression did the trick: =NSTR(INT(@NOTIF_NBR)). This thread gave me enough hints to find something that worked. Thanks!

Terry