Exemplo de transformação de atributos

A importação de dados do sistema de origem gerou a seguinte entrada no arquivo de saída XML:

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE eventlist SYSTEM "event.dtd">

<eventlist>

<event>

<attribute type="VBAP-VBELN">3866</attribute>

<attribute type="VBAP-POSNR">20</attribute>

<attribute type="VBAP-ERNAM">SCHMIDT</attribute>

<attribute type="VBAP-MATNR-MAKTX">100038</attribute>

<attribute type="VBAP-KWMENG">3</attribute>

</event>

</eventlist>

Quer vincular o valor do tipo de atributo VBAP-ERNAMcom uma cadeia de caracteres de constante e gravá-la no novo tipo de atributo Order item recorded by. Além disso, quer criar o tipo de atributo Note on order recording, que extrai o primeiro nome e sobrenome do tipo de atributo VBAP-ERNAM e cria a cadeia de caracteres seguinte:


<First name>< ><Last name>< has recorded the item ><VBAP-POSNR>< of the order ><VBAP-VBELN>< .>


As informações em parênteses angulares representam valores de atributo que são extraídos ou transformados a partir de tipos de atributo ou constantes existentes. Pode especificar as informações necessárias no arquivo de transformação de atributos XML:

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE attributecalculation SYSTEM

"attributetransformation.dtd">

<attributecalculation>

<calculateattribute type="Order item recorded by">

<operation name="concat">

<constant>Walter, "A" </constant>

<valueof>VBAP-ERNAM</valueof>

</operation>

</calculateattribute>

<calculateattribute type="Note on order recording">

<operation name="concat">

<operation name="substring">

<valueof>Order item recorded by</valueof>

<constant>1</constant>

<constant>6</constant>

</operation>

<constant> </constant>

<operation name="substring">

<valueof>Order item recorded by</valueof>

<constant>-1</constant>

<constant>7</constant>

</operation>

<constant> recorded item</constant>

<valueof>VBAP-POSNR</valueof>

<constant> in order </constant>

<valueof>VBAP-VBELN</valueof>

<constant>.</constant>

</operation>

</calculateattribute>

</attributecalculation>

Quando voltar a chamar o programa de linha de comando relevante, desta vez com o parâmetro -calcconfig <XML attribute transformation file>, será gerada o seguinte arquivo de saída XML:

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE eventlist SYSTEM "event.dtd">

<eventlist>

<event>

<attribute type="VBAP-VBELN">3866</attribute>

<attribute type="VBAP-POSNR">20</attribute>

<attribute type="VBAP-ERNAM">SCHMIDT</attribute>

<attribute type="Order item recorded by">

Walter, "A" SCHMIDT

</attribute>

<attribute type="VBAP-MATNR-MAKTX">100038</attribute>

<attribute type="VBAP-KWMENG">3</attribute>

<attribute type="Note on order recording">

Walter SCHMIDT registrou o elemento 20 na encomenda 3866.

</attribute>

</event>

</eventlist>