Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Convert text in Line to Column.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
Ghellar

New User


Joined: 01 Sep 2005
Posts: 12

PostPosted: Mon Jun 25, 2007 1:42 pm    Post subject: Convert text in Line to Column.
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10274
Location: italy

PostPosted: Mon Jun 25, 2007 4:10 pm    Post subject: Re: Convert text in Line to Column.
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    Post subject:
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    Post subject:
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: 12

PostPosted: Mon Jun 25, 2007 8:05 pm    Post subject:
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

Moderator Team Head


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

PostPosted: Tue Jun 26, 2007 1:07 am    Post subject: Re: Convert text in Line to Column.
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: 12

PostPosted: Tue Jun 26, 2007 8:51 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Loading data to table gives wrong for... Raghu navaikulam DB2 18 Thu Jul 13, 2017 2:11 pm
No new posts Convert CLIST to REXX cvnlynn CLIST & REXX 12 Tue Jun 27, 2017 2:06 am
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
No new posts Count the length of the record & ... sreekusr DFSORT/ICETOOL 4 Thu Mar 23, 2017 7:52 pm
No new posts TSO or command line utility to genera... kishpra JCL & VSAM 3 Thu Mar 09, 2017 1:11 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us