09-02-2008 10:30 AM
Dear All,
I tried to parse xml and failed to get the value. Would you mind tell me why. Here I paste the program:
ABAP Program:
REPORT z_elp_coba.
DATA: BEGIN OF line,
pernr(8) TYPE c,
begda(8) TYPE c,
endda(8) TYPE c,
wage(4) TYPE c,
amnt(15) TYPE c.
DATA: END OF line.
DATA itab LIKE TABLE OF line.
DATA: xmldata TYPE string.
CONCATENATE
' <DPG2010>'
' <PIN>12345678</PIN>'
' <BEGDA>20080828</BEGDA>'
' <ENDDA>20080829</ENDDA>'
' <WAGETYPE>1W06</WAGETYPE>'
' <AMOUNT>1500</AMOUNT>'
' <PIN>87654321</PIN>'
' <BEGDA>20080701</BEGDA>'
' <ENDDA>20080719</ENDDA>'
' <WAGETYPE>1W00</WAGETYPE>'
' <AMOUNT>34000</AMOUNT>'
' </DPG2010>' INTO xmldata.
CALL TRANSFORMATION z_dpg2010_transformation
SOURCE XML xmldata
RESULT DPG2010 = itab.
LOOP AT itab INTO line.
WRITE:/ 'PIN :', line-pernr.
WRITE:/ 'BEGDA:', line-begda.
WRITE:/ 'ENDDA:', line-endda.
WRITE:/ 'WTYPE:', line-wage.
WRITE:/ 'AMNT :', line-amnt.
ULINE.
ENDLOOP.
ST Program:
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="dpg2010"/>
<tt:template>
<DPG2010>
<tt:loop ref=".dpg2010">
<PIN>
<tt:value/>
</PIN>
<BEGDA>
<tt:value/>
</BEGDA>
<ENDDA>
<tt:value/>
</ENDDA>
<WAGETYPE>
<tt:value/>
</WAGETYPE>
<AMOUNT>
<tt:value/>
</AMOUNT>
</tt:loop>
</DPG2010>
</tt:template>
</tt:transform>
Click here for captured result:
[Simple transform result|http://picasaweb.google.com/erick.lawrence/UntitledAlbum/photo?authkey=w4M-CP6Ay8A#5241351437478431794]
Thank you all for answers.
Regards,
Erick L. Panjaitan
09-08-2008 3:18 AM
09-21-2008 7:00 AM
Finally I found the answer
For all of you need ST program to parse XML to ABAP, this might be usefull.
I modified this:
<tt:loop ref=".dpg2010">
<PIN>
<tt:value/>
</PIN>
...
Into this:
<tt:loop name="a" ref=".dpg2010">
<PIN>
<tt:value ref="$a.pernr"/>
</PIN>
...
For multi fields table, we have to put explicit reference.
09-21-2008 7:03 AM
In multi-fields table we need to explicitly assign the references.