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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Alignment issue while Concatenating two Strings

(0) ShareShare
ReportReport
Posted on by

Hi 

In purchase order report i have to print "type and description" in a line called "Spec".I am concatenating two strings in X++ DP class but while printing i am facing alignment issues in SSRS

Below is my Code :

Spec =  Spec + "/n" + type +"      "+ Description ;

I am getting value in SSRS Report like,

Spec:

test  file

testing   Drawing

But what i need is like properly aligned table format.How to achieve the below table format in X++ code

test        file

testing   Image

*This post is locked for comments

I have the same question (0)
  • Mea_ Profile Picture
    60,284 on at

    Hi Anna Mu,

    What about using table in SSRS and put Spec  in the first column and type  in the second?

  • Martin Dráb Profile Picture
    237,976 Most Valuable Professional on at

    If you want a properly aligned table, why don't you use the Table control? It's there exactly for this purpose.

  • Community Member Profile Picture
    on at

    Hi ievgen,

    I cannot do that because of the table structure.So i have no other option other than choosing this option

  • Martin Dráb Profile Picture
    237,976 Most Valuable Professional on at

    That's sounds weird; I would like to hear why exactly you say it's impossible. If it's a table, the table control should be able to handle it.

    Also, the solution you've chosen won't ever work well with proportional fonts.

  • Community Member Profile Picture
    on at

    Hi Martin,

    I said , i cannot print those two fields separately in two columns of the ssrs report because  

    there is already a datasource for the purchase order lines.My requirement is , i have to print the Document Type and Description for all the items in the purchase order lines.Recently i have tried the following code,

    public static Notes concatDocuRefNotes(DocuRefSearch _search,RecId _purchLineRecId)

       {

           DocuRef     docuRef;

           Notes       result;

           #xppTexts

           while select TypeId,Name from docuRef order by TypeId  where docuRef.RefTableId

           == tableNum(PurchLine) && docuRef.RefRecId == _purchLineRecId

                   && docuRef.Restriction == DocuRestriction::External

           {

               result += "\n" + docuRef.Name +"           "+ docuRef.TypeId ;

           }

         return result;

       }

    }

    Please suggest me a solution do to proper alignment between two strings for all the lines printed respectively.

    Kind Regards,

    AnnaaMu

  • Mea_ Profile Picture
    60,284 on at

    Hi Anna Mu,

    Its very hard because characters has different width for different fonts and theoretically you can do this calculations but amount of efforts and complexity of this solution do not worth it. You need to do it in a proper way, that is a table control in SSRS report and it is possible as well. For example, you can add 2 new fields to a data source and if one line  has 2 documents then all the fields except doc type and description would be repeated, then you will handle duplicated data it in the report.

  • Community Member Profile Picture
    on at

    Thanks for the reply,

    Before going to tablix control i have tried the following in Code level

    public static Notes concatDocuRefNotes(DocuRefSearch _search,RecId _purchLineRecId)

       {

           DocuRef     docuRef;

           Notes       result;

           #xppTexts

           while select TypeId,Name from docuRef order by TypeId  where docuRef.RefTableId == tableNum(PurchLine) && docuRef.RefRecId == _purchLineRecId

                   && docuRef.Restriction == DocuRestriction::External

           {

               if (!result)

               {

                   result = "<table>";

               }

               result += "<tr><td style='width:auto;'>"+  docuRef.Name + "</td><td>" + docuRef.TypeId + "</td></tr>";

           }

           if(result)

           {

               result += "</table>";

           }

           return result;

       }

    But when i print the report it shows value like

    <table><tr><td style='width:auto;'>"TESTFIRST "</td><td>" FILE "</td></tr>

    Please help me whether there is a fix for the above code,or else i ll go with tablix control.

    Regards,

    AnnaaMU

  • Martin Dráb Profile Picture
    237,976 Most Valuable Professional on at

    Even if it worked with the HTML renderer, what would you expect to happen with renderers that don't use HTML? Use the SSRS table control instead; all SSRS renders know how to work with it.

  • Verified answer
    Chaitanya Golla Profile Picture
    17,225 on at

    Hi,

    You can try the approach to calculate the string length of Description and append the spaces(to the right) of the first part of field type to match the length. Please use the following code in your DP class.

    static void alignment(Args _args)
    {
        str type = "test file";
        str description = "testing drawing";
        int pst, pst1, i;
        str typeStr, spec;
        #file
        
        pst = strFind(description, #delimiterSpace, 1, strLen(description));
        pst1 = strFind(type, #delimiterSpace, 1, strLen(type));
        i = pst1;
        typeStr = subStr(type, 1, pst1-1);
        
        while (pst1 <= pst)
        {
            typeStr = typeStr + #delimiterSpace;        
            pst1++;
        }
        
        type = typeStr + #delimiterSpace + #delimiterSpace + subStr(type, i+1, strLen(type));
        
        spec = Spec + '\n' + type + '\n' + Description;
        
        info(strFmt(spec));
    }


    Output:

    Alignment.jpg

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans