Sample Program to display a Stored Data

Sample Program to display a Stored Data

This session describes how to define a variable as particular Data type and display their contents.

First up all we will see the assigning a text to a 'text' variable and display there contents in a message box.

  • For doing this you have to first define the variable as text variable for that goto the Tools -> Object Designer 
  • Open the object you want to do coding. (for how to open a C/AL Editor see the C/AL Editor page) 
  • After open the C/AL editor goto the View -> C/AL Globals
  • Go to the Variables tab and enter the Name as your text name let us say "sampletext"
  • Go to the Datatype column, here you can specify the datatype of the variable 
  • Got to the Length column type 30. ie, is the space where specifies the length of the text.

Variables defining area looks like follows


After defining this press Esc and goto the normal C/AL Editor window and type the following text in the OnRun()

------------------------------------------------------------------------------------

sampletext := 'My Sample Text';
MESSAGE('The Value of %1 Is %2', 'sample text',sampletext);

------------------------------------------------------------------------------------

Then you will get a output like the following when you run the program.

Related Posts with Thumbnails