View previous topic :: View next topic
|
Author |
Message |
Ghellar
New User
Joined: 01 Sep 2005 Posts: 22
|
|
|
|
I have this dataset.
Code: |
<RESULT>
<PACKAGE>CM77000010</PACKAGE>
<APPLNAME>CM77</APPLNAME>
<PACKAGEID>000010</PACKAGEID>
<PACKAGESTATUS>6</PACKAGESTATUS>
<REQUESTORNAME>PIPPO</REQUESTORNAME>
<REQUESTORPHONE>6605</REQUESTORPHONE>
</RESULT>
<RESULT>
<PACKAGE>CM78000055</PACKAGE>
<APPLNAME>CM78</APPLNAME>
<PACKAGEID>000055</PACKAGEID>
<PACKAGESTATUS>9</PACKAGESTATUS>
<REQUESTORNAME>PLUTO</REQUESTORNAME>
<REQUESTORPHONE>6608</REQUESTORPHONE>
</RESULT>
|
I want to obtain a result like this, is possible?
Code: |
| PACKAGE | APPLNAME | PACKAGEID | PACKAGESTATUS | REQUESTORNAME | REQUESTORPHONE |
| CM77000010 | CM77 | 000010 | 6 | PIPPO | 6605 |
| CM78000055 | CM78 | 000055 | 9 | PLUTO | 6608 |
|
Ghellar |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10872 Location: italy
|
|
|
|
what environment?? what language??
It is not difficult to reformat such file with a REXX script
regards
e.s |
|
Back to top |
|
|
stodolas
Active Member
Joined: 13 Jun 2007 Posts: 632 Location: Wisconsin
|
|
|
|
Sure looks like XML to me. You could use the XML PARSE command in COBOL. It knows how to handle all of the tages and data elements. |
|
Back to top |
|
|
amitava Warnings : 1 Active User
Joined: 30 Oct 2005 Posts: 186 Location: India
|
|
|
|
Hey Enrico,
Quote: |
It is not difficult to reformat such file with a REXX script |
Yop I agree with u that it is quite possible by REXX but doin this reformat will require lots of coding logic and a bit complex also!
Correct me if I am wrong |
|
Back to top |
|
|
Ghellar
New User
Joined: 01 Sep 2005 Posts: 22
|
|
|
|
Thanks to all for the different replies.
This is the REXX that I wrote:
Code: |
/* REXX */
"DELSTACK"
"FREE F(INP001)"
"FREE F(OUT001)"
"ALLOC DA('INP.SUN.XML') F(INP001) SHR"
"ALLOC DA('OUT.SUN.XML.SORT') F(OUT001) SHR"
"EXECIO * DISKR INP001 (STEM VAR. FINIS"
DO I = 1 TO VAR.0
RIGA = VAR.I
PARSE VAR RIGA '<' R1 '>' R2 '<' RESTO
PRIMO_RIGA:
DO
QUEUE '| '!!(R1)!!' |'
QUEUE '| '!!(R2)!!' |'
END
END
"EXECIO "QUEUED()" DISKW OUT001 (FINIS"
"FREE F(INP001)"
"FREE F(OUT001)"
|
The file of Input is formed from more pieces. Every piece is included between:
<RESULT>
...............
...............
...............
</RESULT>
I do not succeed to make it write CM77 to the right hand of CM77000010 and subsequently 000010 to the right hand of CM77 so thread to the end of the piece, then to distribute from the column PACKAGE with the data of the second piece.
| PACKAGE | APPLNAME | PACKAGEID | PACKAGESTATUS | REQUESTORNAME |
| CM77000010 | CM77 | 000010 | 6 | PIPPO |
| CM78000055 | CM78 | 000055 | 9 | PLUTO | |
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
My possible solution:
Code: |
rec = ''
Do i = 1 To var.0
Parse Var var.i '<' ident '>' value '<' .
If ident = 'RESULT' Then rec = '|'
Else If ident = '/RESULT' Then Queue rec
Else rec = rec||value||'|'
End
"EXECIO "Queued()" DISKW OUT001 (FINIS"
|
|
|
Back to top |
|
|
Ghellar
New User
Joined: 01 Sep 2005 Posts: 22
|
|
|
|
Many Thanks superk this rexx is fantastic, It is the rexx that I sought and
many thank for the time that you dedicated for my problem.
regards
ghellar |
|
Back to top |
|
|
|