Finding the occurrence of string within another string through X++

X++ offers a lot of string functions to be used on the strings. Here, we will be using the “strscan” function. The “strscan” searches for a string within another string

————————————————————————————————————-

The strscan function takes the following arguments

Strscan (str text, str characters, int position, int number);

Text: The target string

Characters: The string to be found

Position: The first position in the target string to perform the search

Number: Number of times search will be performed. Normally, it is the length of the original string. If a negative sign is used in this argument, the search operation is performed in the reverse order

————————————————————————————————————-

Below is the code to find any character in a string.

int position;

str targetstring = “ABCD”

position = strscan( targetstring, “CD”,3,strlen(targetstring);

if (position)

{

info(“Found”);

}

else

{

info(“Not Found”);

}

 

 

Developing Query Based Reports

For production and operational reports that are crucial to an organization, a developer can use SSRS reports. There are three types of data sources available to be used for the development of the SSRS Reports

  • Query
  • RDP
  • Business Logic

Here, we will be discussing about developing query based SSRS Reports. Before you can start developing query based reports, you need to create an AOT query on which your report will be based. Once you have created a query and added the required data sources, open a new project in Visual Studio. From the Project dialog, select “Microsoft Dynamics AX’ from project types and “Report Model” from templates. Create the Project and open the solution explorer. Right click on your project and add a new report. Double click on the newly created report. You can see a number of items in your report now. Right click on the node “Datasets” and add a new Dataset. In the properties of the newly created dataset, name your Dataset, set data source type to “query” and select the query you made earlier in AX by clicking on the ellipse button appearing in the Query Property. You can select all fields or only the desired fields of the AX query for reporting purposes.

After you have configured the dataset, add a report design. There are two types of report designs; Auto design and precision design. Always prefer auto design unless you need to customize your report. For the sake of simplicity, we select the Autodesign here.

Right click on the design node and add “Autodesign”. It is recommended to set the name of the report to either to “Report” or “Design”. Drag your data set on the newly created design node. The report is now ready to be executed. You can open your report through three options.

  • Preview in Visual Studio
  • Open from Dynamics AX using output action menu
  • From browser by opening the URL : http://localhost/reports

I hope this post helped you. I will be writing about RDP and business logic based reports in my next posts. I will also be writing about precision design based reports which allow you to customize the design of your reports.

Troubleshooting Data Import Export Framework Dynamics AX 2012 Error: 0 records have been inserted in Staging Tables

This is one of the errors you get when you are trying to import your Data in AX 2012 through the Data Import Export Framework.

Error in DMF

It is very frustrating to trace that one record, from a large set of data that is the cause of this error. This error usually arises when your primary key is duplicated in the import data file.

Always make sure to perform the following steps before importing your Data in AX 2012 through the Data Import Export Framework. Open your file in excel and select the primary key column. Go to Condition Formatting in the Home tab and select Highlight Cell Rules-> Duplicate Values. This function will highlight the duplicated primary key records. Fix the records before importing your data in AX in order to avoid such errors.

5 ways to import your Data in Microsoft Dynamics AX 2012

A critical phase in any ERP implementation, including Dynamics AX 2012 is the migration of master data. User Acceptance testing is smooth when customer sees their own data and obviously, the system isn’t classified as “functional” unless data is successfully entered as per the desired designs.

For beginners and new entrants into ERP, the database model in Dynamics AX 2012 can seem to be very complex and may give a tough time to the integrators and developers, who are migrating data from old systems to Dynamics AX 2012.

When the developers or system integrators have to import data in Dynamics AX 2012, they must know how to classify data. Data can be classified into 4 types.

System Configuration Data: The data which is used to set up the environment of Microsoft Dynamics AX 2012

Parameter Data: The Specific Data for a module which is migrated from a staging environment to the production environment.

Master Data: The data which describes an entity, such as Vendor and Customer etc., including the parties, locations, products and activities referenced by the entity.

Transactional Data: The data which describes an entity that document business events and record their economic value.

Microsoft Dynamics offers a wide range of options for importing Data. Each of the type is efficient and optimum in its’ own way.  The 5 ways to import data in Microsoft Dynamics AX are mentioned and discussed in detail below:

Microsoft Dynamics AX Import:

Dynamics AX Import:

The primary mechanism for transferring Data between the different instances of Dynamics AX is the standard Import method. The utility is available in System Administration->Common->Data Export/Import->Import.

In order to use the functionality of this feature, Definition groups have to be created which include the tables involved in importing of Data. This utility cannot be used for migrating data from one ERP system to another or to import data into the older versions of Dynamics AX 2012.

Microsoft Excel Add-in for Microsoft Dynamics AX:

Another powerful option to import Data in Dynamics AX is the Excel Add-in. Data has to be organized in a specific pattern and some basic requirements are need to be met in order to import data successfully. Only the Excel documents which meet the below mentioned requirements can be used to create or update Data in AX tables.

  • Replacement Keys: Parent Data source must have unique indexes other than RecId.
  • Related Replacement Keys: Each RecId-based foreign key must be related to a table that specifies a replacement key
  • Relationship Direction: Relationships pointing towards parent from child element should be used only
  • Query and Service Consistency: Query and service must be synchronized in order to ensure consistency
  • View Support: Services using views must be properly implemented using the specified methods only

RapidStart Services:

RapidStart services are used to populate basic configuration data along with some master data. The services cannot be used to import transactional data. These services can, however, be used to manage data.

AIF:

AIF has the ability to exchange external data in the form of XML with Microsoft Dynamics AX. To call an AIF service, System administration > Setup > Services and Application Integration Framework > Inbound ports, and then click New. Enter a Port name and description. Select service operations under Service Operations. Click on Activate and use the system generated WSDL URI to import Data externally.

Microsoft Import Export Framework:

The Microsoft Import Export Framework is a very powerful tool for importing and exporting Data. It has predefined entities which map the data to the desired fields and validates the data. The data is at first migrated to a staging environment where it can be validated once again. After that, it is finally transferred to the AX tables and new records are created or existing records are updated. There are 5 main steps to import Data using the Framework:

  1. Prepare Data Source
  2. Select an AX entity
  3. Map and Validate Data
  4. Transfer to Staging Tables
  5. Transfer from Staging Tables to final AX destinations.

The framework also allows creating customized entities. I will be writing in detail much more about data migration scenarios in Dynamics AX 2012 so visit us frequently if this is something of your interest!