>>> Is this doable in DFSORT?  If so, can help point me to some examples / 
>>> suggested reading / command statements?

Steve,

Yes DFSORT can do it quite easily.   Since you haven't provided any details 
about LRECL/RECFM here is sample that I came up on the fly.  Run this job and 
check the output.

//***************************************************************
//* Input file has the following layout                         *
//*                                                             *
//* Fieldname  Position Length                                  *
//* ---------  -------- -------                                 *
//* firstname      01        30                                 *
//* lastname       31        30                                 *
//* company        61        20                                 *
//***************************************************************
//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN   DD *
FIRST NAME                    LAST NAME                     COMPANY
STEVE JR                      ESTLE                         IBM-MAIN
DFSORT                        IBM                           IBM
ABC                           DEF                           XYZ
IJKLMNOPQRSTUVWXYZ            1234567890                    SOME COMPANY
//SORTOUT  DD SYSOUT=*
//SYSIN    DD *
  OPTION COPY
** Right justify the fields so that the trailing spaces are gone
  INREC IFTHEN=(WHEN=INIT,
               BUILD=(01,30,JFY=(SHIFT=RIGHT),       # firstname
                      C'|',                          # stopper
                      31,30,JFY=(SHIFT=RIGHT),       # last name
                      C'|',                          # stopper
                      61,20,JFY=(SHIFT=RIGHT),       # company
                      C'|')),                        # stopper

** Parse the right justified content and pick values from nonblank
** pay attention to fixlen parm as it is incremented by 3
** fixlen = original length  +   30 bytes
**          opening quotes   +   01 byte
**          closing quote    +   01 byte
**          csv separator        01 byte
**                           =   33 bytes

        IFTHEN=(WHEN=INIT,
               PARSE=(%01=(STARTAT=NONBLANK,
                           ENDBEFR=C'|',
                            FIXLEN=33),

                      %02=(STARTAT=NONBLANK,
                           ENDBEFR=C'|',
                            FIXLEN=33),

                      %03=(STARTAT=NONBLANK,
                           ENDBEFR=C'|',
                            FIXLEN=23)),

               BUILD=(%01,JFY=(SHIFT=LEFT,
                                LEAD=C'"',
                               TRAIL=C'"'),

                      %02,JFY=(SHIFT=LEFT,
                                LEAD=C'"',
                               TRAIL=C'"'),

                      %03,JFY=(SHIFT=LEFT,
                                LEAD=C'"',
                               TRAIL=C'"'))),

** Squeeze out the additional spaces while retaining the embedded
** Blanks

        IFTHEN=(WHEN=INIT,
               BUILD=(01,89,SQZ=(SHIFT=LEFT,
                                  PAIR=QUOTE,
                                   MID=C','))),

** Remove the double quotes that we added to retain the embedded
** Blanks
        IFTHEN=(WHEN=INIT,
               FINDREP=(INOUT=(C'"',C'')))

/*


The output from the above job looks like this.

FIRST NAME,LAST NAME,COMPANY
STEVE JR,ESTLE,IBM-MAIN
DFSORT,IBM,IBM
ABC,DEF,XYZ
IJKLMNOPQRSTUVWXYZ,1234567890,SOME COMPANY


Further if you have any questions, please let me know.

Thanks,
Kolusu
DFSORT Development
IBM Corporation



----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to