‎2007 Jun 20 4:13 PM
Hello,
I have an XML file and need to grab a couple of fields from that. Iam passing each record of the XML file into the internal table and below is what I see. I need to pull AUFNR, AUART, TIDNR and STTXT from the code.
Iam thinking of this logic:
1. search for <AUFNR> in the string.
2. Pick 12 characters from <AUFNR>
3. Pass that value into another internal table for further processing.
Similar with the other fields.
I need some help with the code. It would be really great if someone can help me with this.
Thanks much ~V
<?xml version="1.0" encoding="iso-8859-1"?>
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0"><asx:values><OUTPUT><item><AUFNR>000005000292</AUFNR><AUART>PM01</AUART><TIDNR/><STTXT>REL NMAT PRC SETC</STTXT></item></OUTPUT></asx:values></asx:abap>
‎2007 Jun 20 4:18 PM
search for aufnr field and check sy-subrc and then use offset concept and pass that value to itab.
‎2007 Jun 20 4:19 PM
Find the ending position of <AUFNR> and the start position of </AUFNR>. Use offsets to take everything between.
Be careful if this can cross line breaks.
Rob
‎2007 Jun 20 4:21 PM
‎2007 Jun 20 4:22 PM
‎2007 Jun 20 4:24 PM
‎2007 Jun 20 4:30 PM
Thankyou all for the replies. We are on SAP Enterprise..I looked at the links I tried using the cal transformation unsucessfully.
Also, Iam new to the concept of offset, can anyone provide me a sample code?
Thanks,
-V
‎2007 Jun 20 5:11 PM
You'll probably be better off pursuing the CALL TRANSFORMATION, but if you still decide to go the other way, you can try something like:
REPORT ztest MESSAGE-ID 00.
DATA: itab TYPE TABLE OF string WITH HEADER LINE,
wa TYPE string,
order(12).
CONCATENATE: '<?xml version="1.0" encoding="iso-8859-1"?>'
'<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">'
'<asx:values><OUTPUT><item><AUFNR>000005000292</AUFNR>'
'<AUART>PM01</AUART><TIDNR/>'
'<STTXT>REL NMAT PRC SETC</STTXT>'
'</item></OUTPUT></asx:values></asx:abap> '
INTO wa.
SPLIT wa AT 'AUFNR>' INTO TABLE itab.
IF sy-subrc = 0.
READ TABLE itab INDEX 2.
REPLACE '</' IN itab WITH space.
order = itab.
ENDIF.
I'm using the split instead of offsets to avoid problems with new lines. An I assume there is no more than one order.
It's not pretty but you can use it as a start.
Rob
‎2007 Jun 20 4:38 PM
HI check these examples:
DATA string7(30) TYPE c VALUE 'This is a little sentence.'.
WRITE: / 'Searched', 'SY-SUBRC', 'SY-FDPOS'.
SEARCH string7 FOR 'X'.
WRITE: / 'X', sy-subrc UNDER 'SY-SUBRC',
sy-fdpos UNDER 'SY-FDPOS'.
SEARCH string7 FOR 'itt '.
WRITE: / 'itt ', sy-subrc UNDER 'SY-SUBRC',
sy-fdpos UNDER 'SY-FDPOS'.
SEARCH string7 FOR '.e .'.
WRITE: / '.e .', sy-subrc UNDER 'SY-SUBRC',
sy-fdpos UNDER 'SY-FDPOS'.
SEARCH string7 FOR '*e'.
WRITE: / '*e ', sy-subrc UNDER 'SY-SUBRC',
sy-fdpos UNDER 'SY-FDPOS'.
Praveen