Extract missing number sequence list using Electronic Reporting in D365FO
What's the Problem:
Customers having a huge number of transactions. The General Journal Transfer (GJT) numbers are used in all voucher entries posted in the system. These numbers are getting exhausted in a very short duration let assume in 2 months. Customer having doubt that many number sequences are missing for General Journal Transfer. They want to extract some reports which can provide the missing number sequences for GJT and get surety about missing number sequences.
There is an option "Check voucher series" under Ledger setup in the General Ledger module.
A temporary solution can be to use the Table browser, extract data from table GeneralJournalEntry for a particular date range into an Excel sheet. Put the expected number sequences, compare the data and identify the missing number sequences. Considering the huge transactions and limitation of the excel sheet to keep up to 10 lakhs rows, this solution is not a good one to use on regular basis.
Here is the solution:
Create a report of missing number sequences using Electronic Reporting functionality.Logic for the report:
- Identify the lowest and highest number sequence used in a given date range for GJT.
- Extract the number part from the number sequence. e.g if the number sequence is INMF-000012, then the number part is 000012.
- Create a parallel list with expected numbers between the range of Highest and Lowest number sequences identified in step 1.
- Then identify the records which are expected but not in the used number sequence.
- This way, you will get the list of numbers that are missed in the given date range for GJT.
Step 1: Click on the "Create configuration" option and select Root to prepare a data model from scratch.
Step 2: Create the data model with a Root, Recordlist, and String.
Step 3: Click on "Map model to Datasource".
Step 4: Click on New, provide a description and click on the designer.
Step 5: Select "User Input Parameter" in Datasource type. Click on "add root".
The table containing the list of Calculated fields with formula and purpose.
Calculated Fields | Formula | Purpose |
100_$SortedTable | ORDERBY('015_GeneralJournalEntry', '015_GeneralJournalEntry'.JournalNumber) | Use Order-by formula to sort the General Journal Entry table according to GJT (JournalNumber). |
105_$ExtractedNumbers | INTVALUE(VALUE(MID(@.JournalNumber, '005_StartFrom', '010_NumOfCharacters'))) | Extract the numeric part from the number sequence using MID formula. For starting number and number of characters, user parameters are used that we defined in step 1. e.g extract "000012" from INMF-000012. Then Use VALUE formula to convert the string "000012" into real value "12.00000". Use INTVALUE to convert the real number into an integer from "12.00000" to 12. |
200_$CountofRecords | COUNT('100_$SortedTable') | Get the count of records in General Journal entry table. |
300_$MinExtractedNumber | FIRSTORNULL('100_$SortedTable').'105_$ExtractedNumbers | There is no formula of MIN or MAX, so we are using the sorting and reverse sorting option & Picking the first values using the FIRSTORNULL option. To identify the minimum value of the number sequence, get the first value from Extracted numbers (already sorted A to Z above). |
400_$MaxExtractedNumber | FIRSTORNULL(REVERSE('100_$SortedTable')).'105_$ExtractedNumbers' | To identify the maximum value of the number sequence, first, we will reverse the sorting from "A to Z" to "Z to A". Then pick the first value using the FIRSTORNULL option. |
500_$CountOfExpectedRecords | ('400_$MaxExtractedNumber'-'300_$MinExtractedNumber')+1 | Get the count of expected records for number sequence assuming that no number sequence is missing. So, deduct a minimum value from the maximum value and add 1. |
600_$ExpectedRecordList | SPLIT(PADLEFT("#", '200_$CountofRecords', "#"), 1) | Now we want to create a list where expected records will be there and from this list, we will compare and get the missing number sequences. To create a sequence of records equal to a number of expected records (we calculated in the previous step). First use PADLEFT formula, PADLEFT(string,length,padding_chars) Returns a string of a specified length in which the beginning of the current string is padded with specified characters. We took the string as "#" (any special characters you can use), length is equal to the number of expected records calculated in the previous step. Padding character is also taken as "#". It helps to create a value like "######################" here "#" will repeat up to the number of expected records. Then we will use the SPLIT function: SPLIT(string,numeric) Splits an input string into a list of substrings by length. A parameter specifies the maximum length of a substring. It creates a list with number of records equal to the number of expected records with value "#" in all records. We used numeric as 1, to split the above-mentioned character into the expected number of records. |
700_$Sequence | ENUMERATE('600_$ExpectedRecordList') | Use ENUMERATE function to get the sequence from 1 to n. |
705_$SequenceFromMinNumber | (INTVALUE(@.Number)+'300_$MinExtractedNumber')-1 | Then add one calculated field under the node "700_$Sequence". Here we are creating the number sequence starting from the Minimum extracted number sequence till Maximum extracted number sequence. Now we have a list where all the expected number sequences are there. To get the same, we added minimum extracted number to all values and deduct 1. then convert the value into an Integer using the INTVALUE function. |
710_$Filter | WHERE('100_$SortedTable', '100_$SortedTable'.'105_$ExtractedNumbers'=@.'705_$SequenceFromMinNumber') | Now, first, filter the records in Expected Number sequences that match the Extracted number sequence ($SortedTable). |
715_$CalculatedSequence | IF(ISEMPTY(@.'710_$Filter'), 0, @.'710_$Filter'.'105_$ExtractedNumbers')+0 | Add a calculated field under node "700_$Sequence" with logic "Put value as 0 where records are not available in $Sorted table in comparison to the expected number of records. For achieving the same, we used the IF and ISEMPTY function. |
800_$Final | WHERE('700_$Sequence', '700_$Sequence'.'715_$CalculatedSequence'=0) | Get the final list where all missing number sequences are stored. Using the WHERE function with condition '715_$CalculatedSequence'=0. |
After completing above steps, model mapping designer will look like the below image:
Comments
Post a Comment