Versiones comparadas

Clave

  • Se ha añadido esta línea.
  • Se ha eliminado esta línea.
  • El formato se ha cambiado.

Transacción Transaction /EDGE/FC_SPRO → Carpeta de configuración "Transformaciones".

A través de esta opción es posible realizar el mapeo del XML a estructuras ABAP.

Parte de la base que previamente se importó el XSD, del XML que se quiere transformar, dentro de un WSDL a la instancia ABAP como un proxy ABAP. El procedimiento es el siguiente:

  • Importar la definición del XML, es decir, el XSD, como un WSDL al sistema SAP, de tal forma que se creen los proxies necesarios como si se estuviera publicando un servicio. Esta actividad solo se realiza una vez y debe ser transportada a cada ambiente. La idea es que el Framework ABAP genere una clase y una interfaz con un método, donde al método le entre como único parámetro la definición tal cual del XML. De esta forma se haría uso de herramientas estándar para deserializar el XML y colocarlo en una estructura más simple ABAP.

El proxy creado, genera una estructura ABAP de entrada al método; esa estructura es la que se utiliza para recorrer el XML y para configurar el mapeo.

Para tener más claridad al respecto, a continuación se muestra el proxy creado para la facturación electrónica de Costa Rica, donde se crearon varias operaciones en el WSDL, cada una con un XML que se utilizaría dentro del proceso tanto de emisión como de recepción:

Image Removed

Image Removed

Para el caso de recepción donde se utiliza la transformación XML, se generó la siguiente estructura:

Image Removed

Image Removed

Por lo tanto, con base en la estructura anterior, se hace el mapeo funcional desde la herramienta de configuración que se está describiendo.

El mapeo que se describirá se basa en el hecho de dejar al final en dos estructuras ABAP la información del XML. Una estructura de cabecera y otra de detalle.

A continuación, se describe la primera parte de la configuración, la cual está relacionada con la creación de los datos básicos para la transformación. Columnas:

...

A continuación, se muestra un ejemplo de esta configuración:

Image Removed

La segunda configuración que se debe realizar, es el mapeo como tal de los campos. Para entender el proceso de mapeo, es necesario tener en cuenta las siguientes premisas:

...

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:

Image Added

Image Added

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

Image Added

Image Added

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:

Image Added

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:
    Image Removed
    Cuando a nivel de cabecera se está mapeando un nodo que es una lista, se tienen dos opciones:
    1. Indicar cuál registro de la lista se va a obtener, esto se hace con los símbolos [n]; donde n es igual a la posición o registro que se quiere obtener.
    2. No se indican los símbolos anteriores, entonces el motor de transformación repite el mismo nodo en la estructura tantas veces como registros encuentra en la listaImage Added

    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
    DisposiciónDisposition:
    Image Removed
    Cuando a nivel de cabecera se está mapeando un nodo que es una lista, se tienen dos opciones:
    1. Indicar cuál registro de la lista se va a obtener, esto se hace con los símbolos [n]; donde n es igual a la posición o registro que se quiere obtener.
    2. No se indican los símbolos anteriores, entonces el motor de transformación repite el mismo nodo en la estructura tantas veces como registros encuentra en la lista. Sin embargo, se mantiene el mismo ITEM (consecutivo) para que se tenga claridad de a cuál posición pertenecen los nodos que se mapearon.

...

  • Image Added

    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.?
    Indicador de mapeo desde cabecera o posición.
    Si se indica cabecera, se comenzará la búsqueda en la estructura ABAP del XML a partir del nodo de cabecera.
    Si se indica ítem, entonces se buscara una a una las posiciones según la ruta de éstas definidas en la tabla maestra.
    Consec.
    Consecutivo de asignación que indica la secuencia de asignación de los campos. Se recomienda asignarlos de 10 en 10.
    Ruta del campo que se va a buscar
    Opcional.
    Indica la ruta del campo origen de la información que se va a extraer. Esta ruta está de acuerdo a la estructura ABAP que se generó por el proxy. Para navegar entre más de un nodo, cada nodo se separa con el otro por un guión. Ejemplo: RECEPTOR-IDENTIFICACION → en este ejemplo se comienza en el nodo RECEPTOR, luego se pasa al nodo IDENTIFICACION. 
    Cuando se está mapeando un nodo que es una lista, se tienen dos opciones:
    1. Indicar cuál registro de la lista se va a obtener, esto se hace con los símbolos [n]; donde n es igual a la posición o registro que se quiere obtener.
    2. No se indican los símbolos anteriores, entonces el motor de transformación repite el mismo nodo en la estructura destino tantas veces como registros encuentra en la lista. Sin embargo, cuando se mapeando a las posiciones, se mantiene el mismo ITEM (consecutivo) para que se tenga claridad de a cuál posición pertenecen los nodos que se mapearon.
    Si está mapeando información de la cabecera y ésta no contiene un nodo raíz, y la información que se requiere obtener está directamente en un campo sin nodo padre, entonces no es necesario indicar nada en esta columna.
    Nombre del campo que se va a obtener
    Opcional
    Corresponde al nombre del campo dentro de la ruta final que se indicó en la columna anterior, desde donde se va a obtener la información.
    Campo destino al cual se asignará el val
    Obligatorio.
    Nombre del campo que se va a crear en la estructura properties que se mencionó anteriormente.
    Si se quiere llevar el campo a la tabla de la factura para que pueda ser tenido en cuenta en el monitor o para utilizarlo en otros proceso o funcionalidades; se debe anteponer una arroba @. De esta forma el paso de guardar datos extras 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) podrá tomar estos campos y llevarlos a la tabla de la factura. Se recomienda verificar el capítulo "Configuración del monitor o reporte de cada proceso" para validar la forma de cómo agregar nuevos campos al 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?
    Indica si al realizar la búsqueda de la información en el nodo y campo fuente, ésta no se encuentra o está vacía. Si esto sucede y este campo está chequeado, entonces al campo destino se le asigna vacío; de lo contrario el campo destino no se creará.
    Constante
    Literal que se asignará al campo destino, siempre y cuando se haya seleccionado que el tipo de asignación es por constanteIndicates 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 de of SYST
    Campos ABAP de la estructura SYST, que se le asignará al campo destino, siempre y cuando se haya seleccionado que el tipo de asignación es por constante ABAP.
    Tipo Asig.
    Indica el tipo de asignación que se va a realizar al campo destino. Existen varios tipos de asignación:
    ' '→ Por defecto - no se tienen en cuenta las constantes
    C → Se asigna la constante en caso de estar vacío el campo o en caso de no indicar ni ruta ni campo origen.
    A → Se asigna la constante ABAP en caso de estar vacío el campo o en caso de no indicar ni ruta ni campo origen.
    Clase ABAP
    Si se llena este campo, no importa el tipo de asignación que se haya seleccionado, el motor de transformación realizará la invocación de la clase respectiva para realizar el mapeo o asignación correspondiente. Se utiliza cuando la transformación implica una lógica más compleja que una simple asignación desde el XML.
    Esta clase debe implementar la interfaz 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. El único método que debe implementar es EXECUTE_ASSIGNMENT, y éste tiene los siguientes parámetrosThe only method it should implement is EXECUTE_ASSIGNMENT, and it has the following parameters:
    PI_ASSIGN → /EDGE/FC_TB959 → datos de la asignación que se configuródata of the configured assignment.
    PI_CURRENTNODE → ANY → puntero a la estructura del XMLpointer to the XML structure.
    PC_CONTEXT → /EDGE/CL_FC_CONTEXT → contexto que se comparte por todos los pasos del intérpretecontext shared by all steps of the business unit.
    PR_VALUES → /EDGE/FC_TT_PROPERTIES → retorno delos valores asignados o mapeados
    Actualmente existen varias implementaciones para este tipo de asignaciones con clases ABAP. Estas implementaciones son genéricas y pueden ser utilizadas en cualquier cliente. A continuación se detallanPROPERTIES → 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 → Permite obtener la sociedad con base en la identificación del receptor de la factura electrónica. En la configuración se debe asignar de dónde se obtiene la identificación del receptor. Igualmente se debe configurar a nivel del intérprete el parámetro COMPANY_CODE_PARAM, el cual indica el parámetro a nivel de configuración estándar donde está relacionada la sociedad con su identificación fiscal (tabla estándar SAP T001Z). También se puede indicar a nivel de configuración la constante que se debería colocar en caso que no se encuentre el código de la sociedad.
    Ejemplo de la configuración para utilizar esta asignación ABAPAllows 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 → Permite obtener de un campo en formato Allows to get from a field in xsd:datetime solo la fecha en formato ABAPformat only the date in ABAP format.

    /EDGE/CL_FC_EXT_CA_DATETIME_TI → Permite obtener de un campo en formato xsd:datetime solo la hora en formato ABAP → Allows to get from a field in xsd:datetime format only the time in ABAP format.

    /EDGE/CL_FC_EXT_CA_VENDOR_CODE → Permite obtener el código SAP del proveedor con base en la identificación del emisor de la factura electrónica. En la configuración se debe asignar de dónde se obtiene la identificación del emisor. La consulta se hace la tabla LFA1 por el campo STCD1, bien sea igual o que al menos comience por la identificación que llega en el XML.
    Ejemplo de la configuración para utilizar esta asignación ABAPAllows 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 → Obtiene la fecha de entrada del XML de la factura electrónica en formato ABAP.Gets the date of entry of the XML of the electronic invoice in ABAP format..

    /EDGE/CL_FC_EXT_CA_XML_NAME → Obtiene el nombre del XML de la factura electrónica.

Adicional a lo descrito anteriormente, a continuación se describe un poco más en detalle la configuración de los mapeos:

Si el campo destino está vacío, no se realizará ningún mapeo o asignación.

Si la clase ABAP no está vacía, se ejecutará ésta sin realizar ninguna verificación previa. Ésta tendrá la responsabilidad de realizar la asignación o mapeo respectivo. Se podrán llenar los demás campos como ayuda para la clase que va a relaizar el mapeo. Pero únicamente el procesador de mapeos y asignaciones la ejecutará.

Si la ruta está vacía y el campo fuente está vacío se evalúa lo siguiente en el mismo orden indicado:
1. Si el indicador tomar vacío está activo, entonces se asigna vacío.
2. Si uno NO. Si el tipo de asignación igual a vacío (por defecto), entonces no se asigna nada.
3. Si dos NO. Si el tipo de asignación igual a C (por constante), entonces se le asigna constante indicada en la parametrización.
4. Si tres NO. Si el tipo de asignación igual a A (por constante ABAP), entonces se le asigna la constante ABAP indicada en la parametrización.

Si la ruta NO está vacía, entonces se busca dicha ruta en la estructura ABAP representada para el XML. En caso que en la ruta hayan listas, el usuario podrá definir cuál registro tomar de la lista con el símbolo [n], donde n es la línea que requiere obtener. Si no indica dicho símbolo, el sistema recolectará todos los datos de dicha lista con el mismo nombre del campo destino.

Si al encontrar el dato en la estructura ABAP, éste está vacío, entonces se verifica si el usuario marcó "tomar vacío", si es así, entonces se aplican las mismas reglas mencionadas para el caso en que "la ruta está vacía y el campo fuente está vacío".

...

  • 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.