IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Convert text in Line to Column.


IBM Mainframe Forums -> CLIST & REXX
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Ghellar

New User


Joined: 01 Sep 2005
Posts: 22

PostPosted: Mon Jun 25, 2007 1:42 pm
Reply with quote

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
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10872
Location: italy

PostPosted: Mon Jun 25, 2007 4:10 pm
Reply with quote

what environment?? what language??

It is not difficult to reformat such file with a REXX script

regards

e.s
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Mon Jun 25, 2007 6:53 pm
Reply with quote

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
View user's profile Send private message
amitava
Warnings : 1

Active User


Joined: 30 Oct 2005
Posts: 186
Location: India

PostPosted: Mon Jun 25, 2007 7:10 pm
Reply with quote

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!

icon_cool.gif Correct me if I am wrong icon_biggrin.gif
Back to top
View user's profile Send private message
Ghellar

New User


Joined: 01 Sep 2005
Posts: 22

PostPosted: Mon Jun 25, 2007 8:05 pm
Reply with quote

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
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Tue Jun 26, 2007 1:07 am
Reply with quote

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
View user's profile Send private message
Ghellar

New User


Joined: 01 Sep 2005
Posts: 22

PostPosted: Tue Jun 26, 2007 8:51 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> CLIST & REXX

 


Similar Topics
Topic Forum Replies
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts How to load to DB2 with column level ... DB2 6
No new posts RC query -Time column CA Products 3
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts Keep leading zero(s) after convert fl... SYNCSORT 7
Search our Forums:

Back to Top