Left padding for strings in NAV


The C/AL function PADSTR will only work for padding strings to the right.

Example:
String AA needs to be 10 chatacters long with a padding of zeros.
If the zeros need to be added to the right of the string you could use the PADSTR function like this:

mystring := PADSTR(mystring, 10, ‘0’);

If you need padding to the left you can do the following:

Use an empty string and fill it with the number of zeros needed to fill the whole string.
In our example this would be 8 zeros. This is equal to 10 – STRLEN(‘AA’).

So using the PADSTR function this can be:

mystring := PADSTR(”, 10- STRLEN(‘AA’), ‘0’) + ‘AA’;

Which results in: 00000000AA.

Advertisements
Tagged with: ,
Posted in NAV
2 comments on “Left padding for strings in NAV
  1. Johng537 says:

    I gotta favorite this internet site it seems handy very useful fekadcdefgde

  2. Johnd989 says:

    I think you have remarked some very interesting points , appreciate it for the post. agddgeagdbeg

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: