Earn Points & Redeem with attractive offers!
You can earn points, by asking, answering, voting questions and redeem with
attractive offers
. To view various available redemption schemes, please visit
"My Profile".
New User? Sign Up  |  Sign In  |  Help
Barcode support and tutorials from IDAutomation and the community. Click for the BBB Business Review of this Computers Hardware, Software & Services in Tampa FL
Ask
Ask a question. Make sure you select the correct category for the question.
Answer
Like to help others? Then browse through the open questions to answer their questions.
Find
Find answer by browsing the resolved questions.
     
Search for Questions:
My Profile

FulanoNadie

Resolved Questions Bookmark and Share

Mod10 and Mod43 Crystal Report Custom Function

We need to add a Mod10 or a Mod43 custom function to an IDAutomation product for Crystal Reports.

Can you provide a general guide for it?



Operating System: Windows

Application: Crystal Reports, Business Objects

12-08-16     348 day(s) ago     Views: 496

    Report Abuse

 

James

Best Answer

I. Create Function (choose #1 or #2):

1. Mod 43:
• Open the Formula Workshop: In the top bar, choose Report > Formula Workshop
• In the Formula Workshop, choose the ‘white paper icon’ image > Custom Function > enter in the name mod43calc and choose the Use Editor button.

When the window pops up:
1. Select Basic Syntax: image
2. Select everything in the lower section and paste the following:

Function mod43calc (dataIn As String) As String
dim intSum As Number
dim intRemainder as Number
dim stringOfCharacters as String
dim i as Number

'set characters in a string (array of characters) whose index matches values of respective character
stringOfCharacters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%"

'Declare variables
intSum = 0
intRemainder = 0

For i = 1 To Len(dataIn)
'sum up all the individual characters' values by index (which corresponds to set character values)
intSum = intSum + (InStr(stringOfCharacters, Mid(dataIn, i, 1)) - 1)
Next i

'get remainder by dividing by 43
intRemainder = intSum Mod 43

'get/return character for the value of the remainder - this is the mod43 check digit
mod43calc = Mid(stringOfCharacters, (intRemainder + 1), 1)
End Function

3. Press Save

II. View Function:
You will now see the function in both the Functions Tree and the Report Custom Functions:
image

III. Use Function:
Now the function is a Custom Function (also known as a Report Custom Function). It is now available in the report itself and able to be concatenated with other data/functions in a formula field:

dim fieldText as string
fieldText = "ABC123"
formula = cstr (fieldText + mod43calc (fieldText))



2. Mod 10:
• Open the Formula Workshop: In the top bar, choose Report > Formula Workshop
• In the Formula Workshop, choose the ‘white paper icon’ image > Custom Function > enter in the name mod10calc and choose the Use Editor button.

When the window pops up:
1. Select Basic Syntax: image
2. Select everything in the lower section and paste the following:

Function mod10calc (DataToEncode as string) as string
dim Factor as number
dim WeightedTotal as number
dim I as number
dim CurrentCharNum as number
Factor = 3
WeightedTotal = 0
For I = Len(DataToEncode) To 1 Step -1
CurrentCharNum = tonumber(Mid(DataToEncode, I, 1))
WeightedTotal = WeightedTotal + ((CurrentCharNum) * Factor)
Factor = 4 - Factor
Next I
I = (WeightedTotal Mod 10)
If I <> 0 Then
mod10calc = totext(10 - I,0,"")
Else
mod10calc = totext(0,0,"")
End If
end function


3. Press Save

II. View Function:
You will now see the function in both the Functions Tree and the Report Custom Functions:
image
III. Use Function:
Now the function is a Custom Function (also known as a Report Custom Function). It is now available in the report itself and able to be concatenated with other data/functions in a formula field:

dim fieldText as string
fieldText = "00811410010000010"
formula = cstr (fieldText + mod10calc (fieldText))


OR


Dim DataToEncode As String
Dim tempString as String
tempString = "00811410010000010"
DataToEncode = "Ê" & "00" & tempString & mod10calc(tempString)



Support Note: There is an example report available showing the implementation.



Posted 348 day(s) ago

()
()
  Report Abuse
 
   Find Interesting  
   Email to Others  
   Bookmark  
   Subscribe to Answer Alert  
No comments yet.     Be the first to comment.

Email this question link to friends
You must enter an email address, if name is entered or vice-versa for each friend.
Friend #1 -
Friend #2 -
Friend #3 -
Friend #4 -
Friend #5 -
  Your comment on this question
  |         |  
bold  italic  underline  strike       big  small       superscript  subscript 
  Allows to add a link. Added links would only be converted to actual clickable link, when the domain of the link is white-listed by administrator.
Caption :
Link URL :
(Must starts with "http://")
Add  |   Cancel
  Allow to insert an image. Must be among the following file types - *.jpg, *.gif, *.png & *.bmp.
Image Url :   Upload New
(Image url must always starts with " http:// ")
Width : pixels
(Must not be greater than 450px. Enter 0px for no resize)
Add  |   Cancel
  Allow to insert YouTube video. Insert the video embed code.
Embed Code :
Add  |   Cancel
Up to 5000 Characters are allowed. Current Count: 0
  Your comment on this answer
  |         |  
bold  italic  underline  strike       big  small       superscript  subscript 
  Allow you to add a link. Added links would only be converted to actual clickable link, when the domain of the link is white-listed by administrator.
Caption :
Link URL :
(Must start with "http://")
Add  |   Cancel
  Allow to insert an image. Must be among the following file types - *.jpg, *.gif, *.png & *.bmp.
Image Url :   Upload New
(Image url must always start with " http:// ")
Width : pixels
(Must not be greater than 450px. Enter 0px for no resize)
Add  |   Cancel
  Allow to insert YouTube video. Insert the video embed code.
Embed Code :
Add  |   Cancel
Up to 5000 characters are allowed. Current Count: 0

You may answer and comment on any thread according to the Terms and Conditions.

 © Copyright 2017 IDAutomation.com, Inc., All Rights Reserved. Legal Notices.

 Barcode Fonts | Components | Scanners | Support | Contact Us
Training Videos on YouTube Join us on Google Plus Join us on LinkedIn Follow us on Twitter Like us on Facebook