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

Fixed size fields with apostrophes and quotes


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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 Developer


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

PostPosted: Wed Jan 19, 2011 2:41 am
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Store the data for fixed length COBOL Programming 1
No new posts Pulling a fixed number of records fro... DB2 2
No new posts Using Java/C/C++ to retrieve dataset ... Java & MQSeries 6
No new posts Help in extracting data between doubl... DFSORT/ICETOOL 5
No new posts Find the size of a PS file before rea... COBOL Programming 13
Search our Forums:

Back to Top