
[DISCLAIMER: Please Note: Any Image/data in this presentation/video is from SAP internal systems, sample data, or demo systems. Any resemblance to real data is purely coincidental]
Dear All,
In this blog, I would like to explain one way to add extension field of list type created with adaption mode in the UI to Excel Template.
Here, I would use corporate account as an example.
Step1: Download the Excel Template
To modify the Excel Template, the first thing is to download the template from the tenant. Here, there are two ways to achieve the template.
The Excel template is available in Application and User Management -> Microsoft Office® Template Maintenance. In this view, you can filter the template through advance filter. Choose the target language version and download it.
Or it is also possible to directly download the template from which the template is used to upload the data.
Step2: Extract and open the map XML
After download the Excel template, An Xlsx file will be stored in your local device. Change the filename extension form "xlsx" to "zip" or other extension name which is supported by you ZIP tool. Then, you can extract the file and ger the following four items.
The target item is in the folder xl. In this folder, you will find a file named "xmlMaps.xml".
Step3: Modify the map XML
After find the file "xmlMaps.xml", open the file with XML modification tool. And then you can add the extension field created in adaption mode.
The process of adding can be divided in to three steps.
a. Add the extension field
"xmlMaps.xml" involves many different schemes and we need to find the one which is for the webservice to which the extension field is extended to. In this case, it is Schema 31.
In this schema, you may note that there is may similar structure like following.
<xs:element minOccurs="0" maxOccurs="1" name=" " type=" "/>
Each xs:element represent to one filed which is available in this Excel template. Therefore, we need add another xs:element along with other xs:element. The new added one is for the created extension filed. "name" is identity of the extension field in the file. There is no restriction in the name except for space. You can input any name you like. It is recommended to use a name which can help you define the field in the UI. "type" is the type of the field. There are serval pre-defined types like "xs:string" or "tns:Indicator". But for list type, there is not a pre-defined type. Therefore, it is necessary to define a type by yourself. How to define a type of yourself will be introduced following.
b. Define the custom type for the extension field.
Since the elements of a list is unknow, there is no pre-defined type for an extension field of list type. To define one for yourself, first find where the definition of type is in the XML file. Under the schema, find the structure "xs:simpleType". Here, you can define your own type along with them.
For a List type, you can define it like following.
<xs:simpleType name=" ">
<xs:annotation>
<xs:documentation xml:lang="EN">
<ccts:RepresentationTerm xmlns:ccts="urn:un:unece:uncefact:documentation:standard:CoreComponentsTechnicalSpecification:3.0">Code</ccts:RepresentationTerm>
</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:token">
<xs:enumeration value=" "/>
<xs:enumeration value=" "/>
</xs:restriction>
</xs:simpleType>
There are following items to be modified. First, define the type name. And then define the elements in this type. Depending on how many elements in the List, there should be how many <xs:enumeration value=" "/> in this structure. The value should map to the code of the element of the list. You can find the element ID in the UI.
Start adaption mode and edit the extension field, and you will find the code. Please note that different language version of the element will be regarded as one element.
After completed the defining, you now can fill the type name in <xs:element minOccurs="0" maxOccurs="1" name=" " type=" "/> as "tns: XXX" where XXX represents the name you defined for this type.
c. Add the namespace of the field
The last step is to add the namespace of field. Locate the sentence <xsl:template match="*[contains(local-name(),'__')]"> and add the following structure above it.
<xsl:template match=" ">
<xsl:element namespace=" " name=" ">
<xsl:value-of select="."/>
</xsl:element>
</xsl:template>
For match and name, you should input the value of name which is defined in <xs:element minOccurs="0" maxOccurs="1" name=" " type=" "/>. For the namespace, it can also be found in the UI. Start adaption mode and choose the extension field. Then click show further usage and go to extension. Namespace is displayed here.
Up to now, the modification is completed and you can save the file.
Step4: Package the file and upload to the tenant
After modifying the "xmlMaps.xml", choose the four items which are extracted and package them into one ZIP package. Please guarantee that when you open this ZIP file, you can only see these four items. Then change the Filename Extension back to "xlsx."
Open the new XLSX file. Then create a new column for the extension field. Navigating to Developer -> Source, it will open a right panel of XML Source. Switch the workbook to SAP_BYD_MAIN. And then choose the new column and find the field which has been added to the "xmlMaps.xml" in the right panel. Right click the field and click map element. With this, the new column will be map to the added extension field.
Since the value of this field is code, it is recommended to add an Input Message in Data Validation to help the user to distinguish that the code represents to which value in the UI.
After doing all the above, you can save the Excel Template and upload the template to the tenant and replace the original one. In the next time when any user try to upload data through this Excel Template, the new version will be available.
Best Regards,
Cariford
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
11 | |
7 | |
5 | |
3 | |
3 | |
3 | |
3 | |
3 | |
2 | |
2 |