Canada
pawan.deep55@gmail.com

How to do string left or right padding in X++

401 unauthorised error

How to do string left or right padding in X++

This article will explain how you can do string padding with zeros or space with the specified length either left padded or right padded in X++. Often we have a requirement that the desired string should be of specific length (say 10) and if it is not of that length, it should be prefixed with 0. A practical example would be that we need to export bank or vendor txt file with the specific configuration at desired places for a string with a specific length from ERP.

To do left padding, strRFix function can be used and to do right padding, strLFix function can used

Syntax

str strRFix(str _str,int _length,char _char= ‘ ‘)

str strLFix(str _str,int _length,char _char= ‘ ‘)

I hope this article helped you learn how to do padding of string (x++) in the D365 Finance & operations AX. Don’t forget to share this article.
You may also want to see our article on Convert string into enum str2enum in x++. You can find us on facebook.


Author: Pawan Deep SinghI am a D365 Finance & Operations Technical Consultant. I have dedicated this blog to write about all D365FO , ax2012 x++ related tips and tricks I came across in my career. For any query feel free to contact me via the contact section.

 

Comments: 1

  1. Thank my friend! I work with Dynamics AX until version 4.0 and allways used working around function. as the saying goes “living and learning”

Add your comment