/
Configuration of input XML transformations.

Configuration of input XML transformations.

Transaction /EDGE/FC_SPRO -> Configuration Folder "Transformations".

Through this option, it is possible to perform the mapping of XML to ABAP structures.

It is assumed that the XSD of the XML to be transformed has been previously imported into a WSDL and then into the ABAP instance as an ABAP proxy. The procedure is as follows:

  • Import the XML definition, i.e. the XSD, as a WSDL to the SAP system, so that the necessary proxies are created as if a service were being published. This activity is only performed once and must be transported to each environment. The idea is that the ABAP Framework generates a class and an interface with a method, where the only parameter to the method is the XML definition itself. In this way standard tools would be used to deserialise the XML and put it into a simpler ABAP structure.

The proxy created generates an ABAP input structure for the method; this structure is used to traverse the XML and to configure the mapping.

For clarity, the proxy created for electronic invoicing in Costa Rica is shown below, where several operations were created in the WSDL, each with an XML that would be used in the process of both issuing and receiving:

For the reception case where the XML transformation is used, the following structure was generated:

Therefore, based on the above structure, the functional mapping is done from the configuration tool that is being described.

The mapping to be described is based on the fact that the XML information is left at the end in two ABAP structures. A header structure and a detail structure.

In the following, the first part of the configuration is described, which is related to the creation of the basic data for the transformation. Columns:

  • Transform.
    Transformation code.

  • Name of transform.
    Description or name of the transformation..

  • Root node of the XML document
    XML usually starts from a root or parent node. If this is the case for the transformation that needs to be built, the name of the root node must be indicated here. For example, for Colombia the root node was INVOICE, however for Costa Rica there is no root node, since the most external element of the XML is the message itself; therefore, no root node was indicated..

  • Nodo item
    Corresponds to the node with occurrence of 0..n or 1..n and that in ABAp is represented by an internal table, which contains the lines, details or items of the invoice.
    If to reach the item node it is necessary to navigate between other structures; these must be separated with a hyphen.

An example of this configuration is shown below:

The second configuration to be performed is the actual mapping of the fields. In order to understand the mapping process, it is necessary to take into account the following premises

  • The result of the mapping is two structures. One for headers and one for items..

  • The header structure has the following layout and type:
    Type: /EDGE/FC_ST_PROPERTY
    Disposición:


    When a node that is a list is being mapped at header level, there are two options:
    1. Indicate which record of the list is going to be obtained, this is done with the symbols [n]; where n is equal to the position or record you want to obtain.
    2. If the previous symbols are not indicated, then the transformation engine repeats the same node in the structure as many times as records are found in the list.

  • La estructura de cabecera tiene la siguiente disposición y tipo:
    Tipo: /EDGE/FC_ST_PROPERTY_ITEM
    Disposition:


    When a node that is a list is being mapped at header level, there are two options::
    1. Indicate which record of the list is going to be obtained, this is done with the symbols [n]; where n is equal to the position or record you want to obtain.
    2. The previous symbols are not indicated, then the transformation engine repeats the same node in the structure as many times as records it finds in the list. However, the same ITEM (consecutive) is maintained so that it is clear to which position the mapped nodes belong.

In the following, the second part of the configuration is described, which is related to the mapping of the fields in the transformation. Columns (the meaning of each field is also documented in the ABAP screen with the F1 key):

  • Cab. o P.?
    Mapping indicator from header or item.
    If header is indicated, then the search in the ABAP XML structure shall start from the header node.
    If item is indicated, then the items will be searched one by one according to the path of the items defined in the master table.

  • Consec.
    Assignment sequential indicating the sequence in which the fields are assigned. It is recommended to assign them 10 by 10.

  • Route of the field to be searched
    Optional.
    Indicates the path to the source field of the information to be extracted. This path is according to the ABAP structure generated by the proxy. To navigate between more than one node, each node is separated from the other by a hyphen. Example: RECEIVER-IDENTIFICATION → in this example you start at the RECEIVER node, then move to the IDENTIFICATION node. 

    When you are mapping a node that is a list, you have two options:
    1. Indicate which record of the list is going to be obtained, this is done with the symbols [n]; where n is equal to the position or record that you want to obtain.
    2. If the above symbols are not indicated, then the transformation engine repeats the same node in the target structure as many times as it finds records in the list. However, when mapping to positions, the same ITEM (consecutive) is maintained so that it is clear to which position the mapped nodes belong.

    If you are mapping header information and the header does not contain a root node, and the information you need to obtain is directly in a field with no parent node, then you do not need to indicate anything in this column.

  • Name of the field to be obtained
    Optional
    Corresponds to the name of the field within the final path indicated in the previous column, from where the information is to be obtained.

  • Destination field to which the value will be assigned
    Mandatory.
    Name of the field to be created in the properties structure mentioned above.
    If you want to take the field to the invoice table so that it can be taken into account in the monitor or to use it in other processes or functionalities, you must prefix it with an at sign @. In this way the save extra data step (/EDGE/CL_FC_SAVE_EXT_DATA_STEP) will be able to take these fields and take them to the invoice table. It is recommended to check the chapter "Configuration of the monitor or report of each process" to validate how to add new fields to the monitor.

  • Tom.Vacío?
    Indicates if when searching for the information in the source node and field, the information is not found or is empty. If this happens and this field is checked, then the target field is assigned empty, otherwise the target field will not be created.

  • Constant
    Literal to be assigned to the target field, provided that the assignment type has been selected to be by constant.

  • Cons.ABAP of SYST
    ABAP fields of the SYST structure, to be mapped to the target field, provided that you have selected that the mapping type is by ABAP constant.

  • Asig. Type
    Indicates the type of mapping to be made to the target field. There are several types of mapping:
    ' ' → Default - constants are not taken into account.
    C → The constant is assigned if the field is empty or if neither the route nor the source field is indicated.
    A →The ABAP constant is assigned if the field is empty or if neither route nor source field is specified.

  • ABAP Class
    If this field is filled, regardless of the selected assignment type, the transformation engine will invoke the respective class to perform the corresponding mapping or assignment. This is used when the transformation involves more complex logic than a simple assignment from the XML.
    This class must implement the interface /EDGE/IF_FC_CUST_ASSIGNMENT. The only method it should implement is EXECUTE_ASSIGNMENT, and it has the following parameters:
    PI_ASSIGN → /EDGE/FC_TB959 → data of the configured assignment.
    PI_CURRENTNODE → ANY → pointer to the XML structure.
    PC_CONTEXT → /EDGE/CL_FC_CONTEXT → context shared by all steps of the business unit.
    PR_VALUES → /EDGE/FC_TT_PROPERTIES → return of the assigned or mapped values.

    Currently, there are several implementations for this type of assignment using ABAP classes. These implementations are generic and can be used in any client. The following are some examples:
    /EDGE/CL_FC_EXT_CA_COMP_CODE → Allows obtaining the company code based on the identification of the e-invoice recipient. In the configuration, you must assign where the recipient's identification is obtained. You must also configure the COMPANY_CODE_PARAM at the business unit level, which indicates the standard configuration parameter where the company code is related to its fiscal identification (standard SAP table T001Z). Additionally, you can specify a constant to be used in the configuration if the company code is not found.

    Example of the configuration to use this ABAP assignment:



    /EDGE/CL_FC_EXT_CA_DATETIME_DA → Allows to get from a field in xsd:datetime format only the date in ABAP format.

    /EDGE/CL_FC_EXT_CA_DATETIME_TI → Allows to get from a field in xsd:datetime format only the time in ABAP format.

    /EDGE/CL_FC_EXT_CA_VENDOR_CODE → Allows the SAP code of the supplier to be obtained based on the identification of the issuer of the electronic invoice. In the configuration, you must assign where the issuer identification is obtained from. The query is made in the LFA1 table by the STCD1 field, either the same or at least starting with the identification that arrives in the XML.
    Example of the configuration for using this ABAP mapping:
     

    /EDGE/CL_FC_EXT_CA_XML_IN_DATE → Gets the date of entry of the XML of the electronic invoice in ABAP format..

    /EDGE/CL_FC_EXT_CA_XML_NAME → Gets the name of the XML of the e-invoice.

In addition to the above, the configuration of the mappings is described in more detail below:

If the destination field is empty, no mapping or assignment will be performed.

If the ABAP class is not empty, it will be executed without any prior verification. The responsibility of the class will be to perform the respective assignment or mapping. Other fields can be filled in as helpful information for the class that will perform the mapping, but only the mapping and assignment processor will execute it.

If the path is empty and the source field is empty, the following is evaluated in the order indicated:

1. If the "take empty" indicator is active, then it will be assigned empty.
2. If one is NO. If the assignment type is equal to empty (default), then nothing will be assigned.
3. If two is NO. If the assignment type is C (for constant), then the constant specified in the parameterization will be assigned.
4. If three is NO. If the assignment type is A (for ABAP constant), then the ABAP constant specified in the parameterization will be assigned.

If the path is NOT empty, the system will look for that path in the ABAP structure represented for the XML. In the case of lists within the path, the user can define which record to take from the list using the symbol [n], where n is the line to be obtained. If this symbol is not indicated, the system will collect all the data from that list with the same name as the destination field.

If, when finding the data in the ABAP structure, it is empty, then the system checks if the user marked "take empty". If so, the same rules mentioned for the case where "the path is empty and the source field is empty" are applied.

As a general premise, it is understood that if you are searching for a field in an ABAP structure representing an XML, the corresponding structure and the field to be obtained must always exist within the structure that corresponds to the source field.

Avvale 2024