Enterprise Resource Planning Blogs by SAP
Get insights and updates about cloud ERP and RISE with SAP, SAP S/4HANA and SAP S/4HANA Cloud, and more enterprise management capabilities with SAP blog posts.
cancel
Showing results for 
Search instead for 
Did you mean: 
Joselito
Advisor
Advisor
Introduction:

The SAP Business One Add-on Electronic File Manager Format Definition (EFM) can import the structure (Target) for the Electronic Format for electronic documents type xml from one schema file (xsd)or from an existing xml file.

In this blog I want to share with you a handy use of the SAP Business One add-on EFM to include additional user defined validations on a pre-existing electronic format, type XML  that has already embedded validations coming from its schema xsd.



EFM import target


You cannot edit or delete the validations that come from the schema using the EFM add-on, which makes sense to keep the validations that had an external origin. For that you need to create a new schema xsd and import it again.

But what If the validations imported are too generic for my needs?

Can I add additional Validations?

You can create additional validations with the EFM add-on.

The additional validations can be edited or removed in the add-on, saving you the time an effort of creating a new schema xsd.

In this example:

The original schema (xsd) file has brought to my electronic format the Target element CustomerName: with a definition type= xs:string.


xsd validation


Using EFM I have done a direct mapping, linking the Target node CustomerName to the Source field CardName, which is the Business Partner Name shown in the Invoice.


CustomerName->CardName (direct mapping).


 

If I wanted to have an additional validation to accept up to 50 characters when processing the xml I can add and additional validation using the Add-on EFM, I don’t need to change or create the xsd file and import it again, by following these steps:

STEPS:

1- In the Validation tab of the target field Mapping Settings where I want my validation, I press the ‘add’ button to unfold the type of validation desired. In my example I will use ‘Length’.


Validation: Add. Select: Length.


2-Then I enter the parameters for my validation.


Validation parameters


In my example I aim to avoid more than 50 characters in the string or leaving it empty.

I enter my Length Range From 1 To 50.

I mark as ‘Error’, to stop the xml file being generated. You can set it as a 'Warning', but that will defeat the purpose.

Finally, I define the message that I want to see in SAP Business One as an Error System Messages when the validation fails.

See the syntax in the example:

format('"CustomerName" - Value "{0}" exceeds 50 characters', .)

Syntax:

format

( [open parenthesis]

‘  [single quotation mark]

“ [Double quotation mark] + your free text+ [Double quotation mark]

value "{0}"   the variable content inserted in the text of your message.

more free text to be shown after the variable.

‘ [single quotation mark] the end of your text

, [comma]

.  [dot] stands the content for the variable value "{0}", to be captured in the node

)[close parenthesis] to finish your message.

NOTE:

You can create more sophisticated validations using a Customize validation using expressions and functions (see more in the EFM Help File to find functions).

Your expression should be set in a positive or true manner, meaning that you need to define the pattern that meets the validation as true for the error or warning to happen when the pattern is not met/false.

The same example as above, avoiding longer that 50 could be set with this expression:

Expression Function string-length(.) Less than or equal Constant Value 50


Customized

7 Comments
0 Kudos
How can I convert dollars to cents?
Joselito
Advisor
Advisor
0 Kudos
Hi Blessing

 

Your question relates more to mapping settings, not to validations.

I recommend to check the part related to Functions in the online help,  for example you will find a function called multiply in Functions Number

 

Here I quote the online help (F1) when running the add-on EFM





multiply(number, number, number?)

Description: Returns the product of the arguments


Sample:


multiply(1, 2, 3) = 6







so you may set if you use 'direct' mapping a function like

multiply(.,100)

And combine it with function round to get rid of the decimals, because you don't want decimals of cents.

round((muliply(.,100))

 

0 Kudos
Apparently I have a function that I have made, it works on bottom lines but on transactional lines it doesnt work. Not sure why. If you have some demo BPP file please send me.

 

Regards
0 Kudos
Apparently I have a function that I have made, it works on bottom lines but on transactional lines it doesnt work. Not sure why. If you have some demo BPP file please send me.
0 Kudos
Hi Jose Antonio 
If I have to do a validation that only takes the field defined by the user,
how could I generate this validation,
I am checking the length function if it works for me in my case.

but if I have that doubt for example I have a defined field called U_disc
that takes the distance traveled and which I want to map in
my input or original string is for a sat complement in Mexico
pqadmin
Explorer
0 Kudos

How is can we add custom fields to our EFM definitions?
E.g.
- UserText from the OITM table
- Custom FromDate and ToDate for Line Items

I tried the following but it doesn't work..


Custom Fields

Joselito
Advisor
Advisor
0 Kudos

Can you override the validations set on the imported schema in  a SAP Business One Electronic File Format?: Yes, but not advisable

Hi all, on my original post I said that you can't remove the validations. 

However, and even is not advisable, because it may defeat the whole porpoise of the validation, it is still possible to change the behavior of SAP Business One when the validation in the format fails to still generate the file.

This is controlled by a Property in the Target : Always Generated, which by default has the value 'False' .

Changing it to 'True' can be useful during the analysis and development of the Electronic File Format.  Trying that in production will risk any postprocessing of the file by Business One Integration and Services, or any third party recipients of the file. 

Joselito_0-1708511598736.png