Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Fixed size fields with apostrophes and quotes

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
Bruno Oliveira

New User


Joined: 28 Jan 2010
Posts: 16
Location: Portugal

PostPosted: Tue Jan 18, 2011 10:22 pm    Post subject: Fixed size fields with apostrophes and quotes
Reply with quote

Hi there!

Is there a way of reformat this type of file (fixed size fields) into a variable position/length fields (like a CSV)?

Rules:
- Squeze to left the numeric fields
- delimiter -> ;

File Format
Code:
 01 MYFILE.                     
    05 VALUE01    PIC S9(5)V9(2).
    05 MYSTRING1  PIC X(20).     
    05 VALUE02    PIC S9(5)V9(2).
    05 MYSTRING2  PIC X(20).     



Input:
Code:
005001}LCD 24' BEST        009999RORNITORRINCO
001000{PLASMA PHILIPS 42"  005002CPROGRAMADOR


Output:
Code:
-500.10;LCD 24' BEST;-999.99;ORNITORRINCO
100.00;PLASMA PHILIPS 42";500.23;PROGRAMADOR


I have tried to use PAIR=QUOTE and PAIR=APOST but if I have in field MYSTRING1 apostrophes and quotes how can I reformat this file?

I know that DFSORT can read variable position/length fields but I'm not seeing the solution to read fixed sized fields and reformat them if I have apostrophes and quotes in one field.

Thank you,
Bruno Oliveira
Back to top
View user's profile Send private message

Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Wed Jan 19, 2011 2:41 am    Post subject:
Reply with quote

Quote:
I have tried to use PAIR=QUOTE and PAIR=APOST but if I have in field MYSTRING1 apostrophes and quotes how can I reformat this file?


With both apostrophes and quotes in MYSTRING1, it is quite tricky, but I believe this DFSORT job will do what you want. I allowed MYSTRING2 to have both apostrophes and quotes too just for completeness. I also assumed you didn't have X'FF' in your strings.

Code:

//S1 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD DSN=...  input file (FB/54)
//SORTOUT DD DSN=...  output file (FB/57)
//SYSIN DD *
  OPTION COPY
  INREC IFOUTLEN=57,
   IFTHEN=(WHEN=INIT,
    FINDREP=(STARTPOS=8,ENDPOS=27,IN=X'7F',OUT=X'FF')),
   IFTHEN=(WHEN=INIT,
    FINDREP=(STARTPOS=35,ENDPOS=54,IN=X'7F',OUT=X'FF')),
   IFTHEN=(WHEN=INIT,
     BUILD=(1,7,ZD,EDIT=(SIIIIT.TT),SIGNS=(,-),
     8,20,JFY=(SHIFT=LEFT,LEAD=C';"',TRAIL=C'";',LENGTH=22),
     28,7,ZD,EDIT=(SIIIIT.TT),SIGNS=(,-),
     35,20,JFY=(SHIFT=LEFT,LEAD=C';"',TRAIL=C'"',LENGTH=22))),
   IFTHEN=(WHEN=INIT,
     BUILD=(1,64,SQZ=(SHIFT=LEFT,PAIR=QUOTE))),
   IFTHEN=(WHEN=INIT,
     FINDREP=(INOUT=(X'7F',C'',X'FF',X'7F')))
/*
Back to top
View user's profile Send private message
Bruno Oliveira

New User


Joined: 28 Jan 2010
Posts: 16
Location: Portugal

PostPosted: Wed Jan 19, 2011 4:09 pm    Post subject:
Reply with quote

Hi, Frank.

It works very well.
Very nice thinking (replacing X'7F' by X'FF' and then X'FF' by X'7F').

Thank you,
Bruno Oliveira
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 -> DFSORT/ICETOOL All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts JES2 job size field matching Windows ... SRICOBSAS All Other Mainframe Topics 4 Tue Sep 05, 2017 5:49 pm
No new posts Split file based on comparsion to 2 f... Div Grad DFSORT/ICETOOL 3 Thu Jul 27, 2017 9:16 pm
No new posts How to write Specific Fields from Mul... Padhu SYNCSORT 6 Thu Jul 06, 2017 10:26 am
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Validate date and numeric fields and ... Rick Silvers DFSORT/ICETOOL 6 Thu May 11, 2017 6:51 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us