Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with Simple Transformation

former_member186145
Participant
0 Kudos

Hi to all

I am working with ST, and have the following issue:

I have a highly nested xml structure, and, when I execute a abap program with a myself ST, only the last one data is passed to internal tables.

I want to know: how can I do to get that all the information from xml file to store to internal tables but not only the latest information structure?

For example I have the following xml file, and only the last occurence of <PSMService> is update in internal tables.

Thank you very much for your help.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<InvoicingInformation>
<Services>
<PSMServices>
        <PSMService ContractCode="STF0996" InvoicePeriod="2011-01-31T00:00:00-06:00" ReceiptPointCode="347">
          <Transactions>
            <Transaction ReceiptPointCode="347" DeliveryPointCode="167" ExitTramoCode="15" SectorCode="SECTP_GNV">
            </Transaction>
          </Transactions>
          <DailyCharges>
            <DailyCharge ChargeCode="CHRGS_FIJO" Date="2011-01-01T00:00:00-06:00" Quantity="93" QuantityUnit="KPC">
            </DailyCharge>
            <DailyCharge ChargeCode="CHRGS_FIJO_COP" Date="2011-01-01T00:00:00-06:00" Quantity="93" QuantityUnit="KPC">
            </DailyCharge>
          </DailyCharges>
          <AggregateCharges>
            <AggregateCharge ChargeCode="CHRGS_DESVIO" IsTiered="false" Quantity="0" QuantityUnit="KPC" CurrencyCode="COP">
            </AggregateCharge>
            <AggregateCharge ChargeCode="CHRGS_DESVIO_US$" IsTiered="false" Quantity="0" QuantityUnit="KPC" CurrencyCode="USD">
            </AggregateCharge>
         </AggregateCharges>
        </PSMService>
        <PSMService ContractCode="STF0996" InvoicePeriod="2011-01-31T00:00:00-06:00" ReceiptPointCode="347">
          <Transactions>
            <Transaction ReceiptPointCode="347" DeliveryPointCode="192A" ExitTramoCode="16" SectorCode="SECTP_GNV">
            </Transaction>
          </Transactions>
          <DailyCharges>
            <DailyCharge ChargeCode="CHRGS_FIJO" Date="2011-01-01T00:00:00-06:00" Quantity="112" QuantityUnit="KPC">
            </DailyCharge>
            <DailyCharge ChargeCode="CHRGS_FIJO_COP" Date="2011-01-01T00:00:00-06:00" Quantity="112" QuantityUnit="KPC">
            </DailyCharge>
          </DailyCharges>
          <AggregateCharges>
            <AggregateCharge ChargeCode="CHRGS_FIJO" IsTiered="false" Quantity="560" QuantityUnit="KPC" CurrencyCode="USD">
            </AggregateCharge>
            <AggregateCharge ChargeCode="CHRGS_FIJO_COP" IsTiered="false" Quantity="560" QuantityUnit="KPC" CurrencyCode="COP">
            </AggregateCharge>
          </AggregateCharges>
        </PSMService>
        <PSMService ContractCode="STF0996" InvoicePeriod="2011-01-31T00:00:00-06:00" ReceiptPointCode="360">
          <Transactions>
            <Transaction ReceiptPointCode="260A" DeliveryPointCode="167" ExitTramoCode="15" SectorCode="SECTP_GNV">
            </Transaction>
            <Transaction ReceiptPointCode="260B" DeliveryPointCode="168" ExitTramoCode="15" SectorCode="SECTP_GNV"> 
            </Transaction>
          </Transactions>
          <DailyCharges>
            <DailyCharge ChargeCode="CHRGS_DESVIO" Date="2011-01-01T00:00:00-06:00" Quantity="0" QuantityUnit="KPC">
            </DailyCharge>
            <DailyCharge ChargeCode="CHRGS_DESVIO_US$" Date="2011-01-01T00:00:00-06:00" Quantity="0" QuantityUnit="KPC">
            </DailyCharge>
          </DailyCharges>
          <AggregateCharges>
            <AggregateCharge ChargeCode="CHRGS_DESVIO" IsTiered="false" Quantity="0" QuantityUnit="KPC" CurrencyCode="COP">
            </AggregateCharge>
            <AggregateCharge ChargeCode="CHRGS_DESVIO_US$" IsTiered="false" Quantity="0" QuantityUnit="KPC" CurrencyCode="USD">
            </AggregateCharge>
          </AggregateCharges>
        </PSMService>
 </PSMServices>
 </Services>
</InvoicingInformation>

Edited by: Thomas Zloch on May 10, 2011 12:46 PM - code tags added

9 REPLIES 9

Former Member
0 Kudos

Hi Hernan,

Show us the transformation code to help us help you.

Regards,

Chalres

0 Kudos

Hi Charles.

Thank you.

This is a piece of the simple transformation:

<Services>
<!--                 PSM Services  -->

 <PSMServices tt:extensible="deep-dynamic">
 <tt:loop name="PSMService" ref="TABLA_PSM_SERVICES">
     <PSMService tt:extensible="deep-dynamic">
        <tt:attribute name="ContractCode" value-ref="$PSMService.ContractCode"/>
        <tt:attribute name="InvoicePeriod" value-ref="$PSMService.InvoicePeriod"/>
        <tt:attribute name="ReceiptPointCode" value-ref="$PSMService.ReceiptPointCode"/>
        <tt:attribute name="DeliveryPointCode" value-ref="$PSMService.DeliveryPointCode"/>
        <tt:attribute name="ExitTramoCode" value-ref="$PSMService.ExitTramoCode"/>
        <tt:attribute name="SectorCode" value-ref="$PSMService.SectorCode"/>
        <tt:attribute name="MarketCode" value-ref="$PSMService.MarketCode"/>
        <tt:attribute name="TransportMarketCode" value-ref="$PSMService.TransportMarketCode"/>
        <tt:attribute name="InvoiceBy" value-ref="$PSMService.InvoiceBy"/>
        <tt:attribute name="MarketCapacity" value-ref="$PSMService.MarketCapacity"/>
        <tt:attribute name="MarketCapacityUnitCode" value-ref="$PSMService.MarketCapacityUnitCode"/>
        <tt:attribute name="SAPMaterialCode" value-ref="$PSMService.SAPMaterialCode"/>
        <Transactions tt:extensible="deep-dynamic">
           <tt:loop name="Transaction" ref=".TABLA_PSM_TRANSACTIONS">
             <Transaction tt:extensible="deep-dynamic">
                <tt:attribute name="ReceiptPointCode" value-ref="$Transaction.ReceiptPointCode"/>
                <tt:attribute name="DeliveryPointCode" value-ref="$Transaction.DeliveryPointCode"/>
                <tt:attribute name="ExitTramoCode" value-ref="$Transaction.ExitTramoCode"/>
                <tt:attribute name="SectorCode" value-ref="$Transaction.SectorCode"/>
                <tt:attribute name="MarketCode" value-ref="$Transaction.MarketCode"/>
                <tt:attribute name="MarketCapacity" value-ref="$Transaction.MarketCapacity"/>
                <tt:attribute name="Firm" value-ref="$Transaction.Firm"/>
                <tt:attribute name="Overrun " value-ref="$Transaction.Overrun "/>
                <tt:attribute name="UnitCode" value-ref="$Transaction.UnitCode"/>
                <tt:attribute name="SAPMaterialCode" value-ref="$Transaction.SAPMaterialCode"/>
             </Transaction>
           </tt:loop>
        </Transactions>
        <DailyCharges tt:extensible="deep-dynamic">
            <tt:loop name="DailyCharge" ref=".TABLA_PSM_DAILYCHARGES">
                <DailyCharge tt:extensible="deep-dynamic">
                    <tt:attribute name="ChargeCode" value-ref="$DailyCharge.ChargeCode"/>
                    <tt:attribute name="Date" value-ref="$DailyCharge.Date"/>
                    <tt:attribute name="Quantity" value-ref="$DailyCharge.Quantity"/>
                    <tt:attribute name="QuantityUnit" value-ref="$DailyCharge.QuantityUnit"/>
                </DailyCharge>
            </tt:loop>
        </DailyCharges>
        <AggregateCharges tt:extensible="deep-dynamic">
            <tt:loop name="AggregateCharge" ref=".TABLA_PSM_AGGREGATECHARGES">
                <AggregateCharge tt:extensible="deep-dynamic">
                    <tt:attribute name="ChargeCode" value-ref="$AggregateCharge.ChargeCode"/>
                    <tt:attribute name="IsTiered" value-ref="$AggregateCharge.IsTiered"/>
                    <tt:attribute name="Quantity" value-ref="$AggregateCharge.Quantity"/>
                    <tt:attribute name="QuantityUnit" value-ref="$AggregateCharge.QuantityUnit"/>
                    <tt:attribute name="CurrencyCode" value-ref="$AggregateCharge.CurrencyCode"/>
                    <tt:attribute name="TariffRate" value-ref="$AggregateCharge.TariffRate"/>
                    <tt:attribute name="TariffRateUnit" value-ref="$AggregateCharge.TariffRateUnit"/>
                </AggregateCharge>
            </tt:loop>
          </AggregateCharges>
        </PSMService>
       </tt:loop>
      </PSMServices>
  </Services>

Edited by: Thomas Zloch on May 10, 2011 12:47 PM - code tags added

0 Kudos

Hi Hernan,

I didn't understood why you used the ref atribute in your loops. Can you explain?

<tt:loop name="PSMService" ref="TABLA_PSM_SERVICES">

Also tell me if only the PSMService loop is not working or all your loops are not working.

The SAP Help for ST Internal Tables is in the following addres:

http://help.sap.com/saphelp_nw04/helpdata/EN/48/c21940a65ec442e10000000a1550b0/frameset.htm

Regards,

Charles

0 Kudos

Just curious, Does your table have a header line? or is it standard table without header line?

Also post your ABAP statement (code) for call transformation

0 Kudos

Hi Charles

I used the ref atribute in loops, by pass the info to internal tables.

For the example showed, all the loops is not working. When the execution is finalized, all the internal tables appear only with the information of the last iteration.

I call the ST as follow:

CALL TRANSFORMATION zpltg_simple

SOURCE XML itab_xml

RESULT

tabla_psm_services = itab_psm_services

tabla_psm_transactions = itab_psm_transactions

tabla_psm_dailycharges = itab_psm_dailycharges

tabla_psm_aggregatecharges = itab_psm_aggregatecharges.

where:

itab_psm_services, itab_psm_transactions, itab_psm_dailycharges, and itab_psm_aggregatecharges are internal tables with out header.

and

tabla_psm_services, tabla_psm_transactions, tabla_psm_dailycharges and tabla_psm_aggregatecharges, are the reference table of the ST:

<!-- Transformacion Simple que sirve como Parser entre XML generado por PLTG y SAP ECC 6.0 -->

<?sap.transform simple?>

<tt:transform xmlns:tt="http://www.sap.com/transformation-templates" xmlns:ddic="http://www.sap.com/abapxml/types/dictionary"

xmlns:def="http://www.sap.com/abapxml/types/defined">

<tt:root name="TABLA_PSM_SERVICES" type="?"/>

<tt:root name="TABLA_PSM_TRANSACTIONS" type="?"/>

<tt:root name="TABLA_PSM_DAILYCHARGES" type="?"/>

<tt:root name="TABLA_PSM_AGGREGATECHARGES" type="?"/>

<tt:root name="TABLA_ODORANTS" type="?"/>

....

Thanks by your help

ragards

Dario

0 Kudos

Hi Kris

I answer the questions in this thread.

Thank you by your help

regards

Dario.

0 Kudos

Hi Dario,

I think you didn't define correctly your variables and your root(s).

Shouldn't you define only one root (PSM_SERVICES), and define one matching internal table with the 3 others nested internal tables (transaction, daily charges, aggregate charges) inside?

In fact, what happens is that each time a PSM service is processed, the 3 inner trees are emptied and refilled. (note that you probably get the correct entries in ITAB_PSM_SERVICES)

BR

Sandra

0 Kudos

Hi Sandra.

Thank you for your help.

OK, I understand your point, but, how can I do to reference a field, in a nested internal table between them ?

For example:

By nested table DailyCharges, the field ChargeCode, I have to reference like "$PSMServices/DailyCharge.ChargeCode" ?

<DailyCharges>

<tt:loop name="DailyCharge" ref=".TABLA_PSM_DAILYCHARGES">

<DailyCharge tt:extensible="deep-dynamic">

<tt:attribute name="ChargeCode" value-ref="$DailyCharge.ChargeCode"/>

<tt:attribute name="Date" value-ref="$DailyCharge.Date"/>

<tt:attribute name="Quantity" value-ref="$DailyCharge.Quantity"/>

<tt:attribute name="QuantityUnit" value-ref="$DailyCharge.QuantityUnit"/>

</DailyCharge>

</tt:loop>

</DailyCharges>

regards

Dario

0 Kudos

Hi Dario,

you should change ref=".TABLA_PSM_DAILYCHARGES" with the name of the nested internal table component (and remember to remove the dot which links to a root node)


<DailyCharges>
<tt:loop name="DailyCharge" ref="itab_daily_charges">
<DailyCharge tt:extensible="deep-dynamic">
<tt:attribute name="ChargeCode" value-ref="$DailyCharge.ChargeCode"/>

would work with :


types: begin of daily_charge,
    charge_code type string,
end of daily_charge.

data: begin of itab_psm_services occurs 0,
    contract_code type string,
    itab_daily_charges TYPE daily_charge occurs 0,
end of itab_psm_services.

(sorry for the obsolete coding (OCCURS, implicit header line))

You have an example in transformation SSTDEMO_BOOKINGS, that you can run from program SSTDEMO_FLIGHTS (choose "flight bookings", first run it with option to generate the XML file, then run it with option to transform from the XML file to ABAP nested internal tables)

BR

sandra