web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Adding space in a string in middle and end

(0) ShareShare
ReportReport
Posted on by 68

hi,

I have a requirement to show all the sites in one string. And there is a custom table which has a relation of 1: n sites . 

Eg. I have site1,site2,site3....site10.

A custom table "Sitelinkage" is having column linkageid L001 . This Linkage ID can be associated to N number of sites with custom value assigned to site assigned  in this case .

site2= 1 , site 4=5 ,site 6 = 9 ,site 7 =12.

The requirement is that a text file will be created as below.

Site1 Site2 Site3 Site4 Site5 Site6 Site7 Site8 Site9
0 1 0 5 0 9 12 0 0

The problem is that when I am keeping a Tab space in between sites and its values . The string just removes them and print as below

0105091200.

The site1...site 9 is printing properly.

I have taken the variable of str1260 siteValue. 

Thanks,

VK

I have the same question (0)
  • Komi Siabi Profile Picture
    13,190 Most Valuable Professional on at

    Hello Vicky,

    Can you show us the code used for printing the string value?

  • vicky1234 Profile Picture
    68 on at

    Hi Komi,

    you can consider the below code as the main section.

    str1260 siteStr;//variable declared

    while select from customtable

    {

    sitestr += customtable.sitevalue + #Tab;

    }

    Even if you give space like -> "   "  instead of tab.

    The output is shown without the spaces.

  • Suggested answer
    Komi Siabi Profile Picture
    13,190 Most Valuable Professional on at

    use

    \t for tab

  • Martin Dráb Profile Picture
    238,789 Most Valuable Professional on at

    vicky1234, please don't forget using Insert > Code to paste source code. Let me re-post your code in the right way. I also fix a bug there and corrected letter casing:

    str1260 siteStr; //variable declared
    
    while select SiteValue from customTable
    {
    	siteStr  = customTable.SiteValue   #Tab;
    }

    Unfortuntately this code doesn't look relevant to your problem. Your problem is about writing this string to a file.

    Also, it's not clear why you add the delimiters by yourself. The usual approach is using a column delimiter when writing to a file.

  • vicky1234 Profile Picture
    68 on at

    Hi Komi

    Thanks for the comment.

    I have created a macro and [tag:Tab] value is '\t' but it still prints the output without the spaces.

  • vicky1234 Profile Picture
    68 on at

    Thanks Martin,

    I will use the code editor.

    I need to add space in between the sitevalues and this values will sit in 1 single column , which is why I am considering str1260.

    The issues is that it if I try to give any spaces in between it just skips and in case of any other values let's say " -" then it prints correctly.

    So the problem is to fix the section where empty space in the string is skipped.

  • GirishS Profile Picture
    27,833 Moderator on at

    Try to insert the values into container with space.

    While printing use con2str function for conversion.

    str1260 siteStr;//variable declared
    container site;
    while select from customtable
    
    {
    
    site  = customtable.sitevalue   " ";
    
    }
    

    Thanks,

    Girish S.

  • vicky1234 Profile Picture
    68 on at

    Hi Girish,

    I have written the same code and printing it via info(strfmt()), not sure why do we need the con2str method.

    If you run this same job and see the info then it will remove the spaces in between. You can consider any std table to check

  • Komi Siabi Profile Picture
    13,190 Most Valuable Professional on at

    Hello Vicky,

    I tried your code. See below:

    As you can see, I used 

    tab , " " , x.

    public static void main(Args _args)
    {
        LoanRequestTable customTable;
        #define.Tab('\t');
    
    
        str1260 siteStrtab, siteStrspace,siteStrx; //variable declared
    
        while select LoanEDs from customTable
        {
            siteStrtab  = customTable.LoanEDs   #Tab;
            siteStrspace  = customTable.LoanEDs  "   ";
            siteStrx  = customTable.LoanEDs   "x";
        }
    
        Info(strFmt("%1",siteStrtab));
        Info(strFmt("%1",siteStrspace));
        Info(strFmt("%1",siteStrx));
    }

    tab.png

  • vicky1234 Profile Picture
    68 on at

    Hi Komi,

    Really appreciate your help and executing the job and sharing the results.

    I think my statements were not that clear but below screens will help more on the issue.

    pastedimage1665160648478v1.png

    The first ones i.e  lets say site1 ...site 10 will be header for the third party and the records after that will be the actual values...
    so in the above case consider 10 20 ...150 as the site header separated by space/tab and this is working fine,

    Now when I am sending the data for the next line it will be having data starting from 10 then 20 and so on till 150 .

    so in my case lets say value of site 30 is one and for 140 - > two.

    now these values are also properly assigned during the debug I can see as below there are spaces in between.

    pastedimage1665160887378v2.png

    The problem is that when you see this values in the output window it will just trim the empty spaces in between as shown below.

    pastedimage1665160966118v3.png

    This will be wrong as this data will go into a csv...
    This has to be sent in a single column only as there are some complex requirements.

    Not sure if this is std way that is shows but this is the issue which i am facing.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 512 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 386

#3
Adis Profile Picture

Adis 259 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans