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

How to move the first field of each record to the end...


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
tuxama

New User


Joined: 25 Jan 2007
Posts: 42
Location: france

PostPosted: Fri Mar 17, 2023 11:30 pm
Reply with quote

Hello,

Does anyone have a solution to propose: How to move the first field of each record to the end of the record in a CSV file ?

My input file contains multiple fields, each separated from the previous one by a semicolon

The problem seemed trivial to me, but I don't see a simple solution.
The problem also comes from the fact that we don't know the number of fields.
Of course, it is not impossible that SPACE characters are present in one or more fields.

I starded with :

Code:

OUTFIL VTOF,                                                   
      PARSE=(%01=((ABSPOS=1,ENDBEFR=C'";',FIXLEN=2),   
                   %02=( ? )),
      BUILD=(%02,C';',%01)


But I don't know how to reference the end of the record.

Thank you in advance for your help.

Best regards
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2018
Location: USA

PostPosted: Sat Mar 18, 2023 12:24 am
Reply with quote

First of all, while working with RECFM=VB, in SORT you need to take into account RDW field, in every record.

Code:
"1";22222;33333;44444;55555;66666                     
"2";AAAAA;BBBBB;CCCCC;DDDDD;EEEEE;FFFFF;GGGGG         
"3";999;888;777;666;555;444                           


Code:
 SORT FIELDS=COPY                                           
 OUTREC PARSE=(%01=(ABSPOS=5,ENDBEFR=C'";',FIXLEN=2),       
               %02=(FIXLEN=80)),                             
        BUILD=(1,4,%02,JFY=(SHIFT=RIGHT),C';',%01,C'"')     
 OUTFIL VTOF,                                               
        PARSE=(%03=(ABSPOS=5,STARTAFT=C' ',FIXLEN=100)),     
        BUILD=(%03,JFY=(SHIFT=LEFT))


Code:
22222;33333;44444;55555;66666;"1"                                 
AAAAA;BBBBB;CCCCC;DDDDD;EEEEE;FFFFF;GGGGG;"2"                     
999;888;777;666;555;444;"3"                                       
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1244
Location: Bamberg, Germany

PostPosted: Sat Mar 18, 2023 2:48 pm
Reply with quote

No need for a second parse operation.

Code:
OPTION COPY                                                     
INREC IFTHEN=(WHEN=INIT,                                         
  PARSE=(%01=(ABSPOS=5,ENDBEFR=C'";',FIXLEN=2),                 
         %02=(FIXLEN=80)),                                       
  BUILD=(1,4,%02,JFY=(SHIFT=RIGHT,TRAIL=C';'),%01,C'"')),       
  IFTHEN=(WHEN=INIT,BUILD=(1,4,5,83,JFY=(SHIFT=LEFT,LENGTH=80)))
END
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2018
Location: USA

PostPosted: Sat Mar 18, 2023 10:46 pm
Reply with quote

Joerg.Findeisen wrote:
No need for a second parse operation.

Code:
OPTION COPY                                                     
INREC IFTHEN=(WHEN=INIT,                                         
  PARSE=(%01=(ABSPOS=5,ENDBEFR=C'";',FIXLEN=2),                 
         %02=(FIXLEN=80)),                                       
  BUILD=(1,4,%02,JFY=(SHIFT=RIGHT,TRAIL=C';'),%01,C'"')),       
  IFTHEN=(WHEN=INIT,BUILD=(1,4,5,83,JFY=(SHIFT=LEFT,LENGTH=80)))
END


Anyway, OUTFIL VTOF is required...
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1244
Location: Bamberg, Germany

PostPosted: Sat Mar 18, 2023 11:17 pm
Reply with quote

This for sure.
Back to top
View user's profile Send private message
tuxama

New User


Joined: 25 Jan 2007
Posts: 42
Location: france

PostPosted: Sun Mar 19, 2023 9:38 pm
Reply with quote

Hello,

Thank you very much for your help, it perfectly solved my problem.

The issue with the RDW was due to a transcription error because I did not use the copy/paste function.

However, I am delighted to see that this error did not go unnoticed, as it is also a mistake of carelessness that I easily make.

Thank you again.
best regards
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 -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts FINDREP - Only first record from give... DFSORT/ICETOOL 3
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts To find whether record count are true... DFSORT/ICETOOL 6
Search our Forums:

Back to Top