W dniu 2017-07-17 o 17:33, Sri h Kolusu pisze:
I see the following room for improvement: 1. Do NOT limit domain field
to first dot. Just take it as whole string.
Example of sorted domains

R.S

My earlier job was just an untested sample that I wrote on the weekend to
meet Edward's requirement.  Here is a fully tested version and it takes
into consideration all the points raised here so far.  Thanks paul for
sending in some sample data. It also handles the lower case and upper
case. We only convert the parsed values to upper case and leave the
original record as is.

I did not code the OUTREC statement to remove the parsed fields as I
wanted to show how the values are parsed. If the job met all your
requirements then simply add OUTREC BUILD=(1,80)

//STEP0100 EXEC PGM=SORT
//SYSOUT   DD SYSOUT=*
//SORTIN   DD *
John Sr Doe <[email protected]>,
SORT EXPERT <[email protected]>,
[email protected],
<[email protected]>,
<"JOHNDOE"@US.IBM.COM>,
(MUST BE EQUIVALENT) <"JOHNDOE"@US.IBM.COM>,
(OPTIONALLY DISTINCT) <"JOHNDOE"@US.IBM.COM>,
(MAY BE REJECTED BY IBM) <"JOHNDOE+FOLDER"@US.IBM.COM>
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
//SORTOUT  DD SYSOUT=*
   INREC IFTHEN=(WHEN=INIT,
          PARSE=(%01=(ENDBEFR=C'@',FIXLEN=50),   $ GET FIELD BEFORE @
                 %02=(ENDBEFR=C'>',              $ GET FIELD BEFORE <
                      ENDBEFR=C',',              $ GET FIELD BEFORE ,
                      ENDBEFR=C' ',FIXLEN=50)),  $ GET FIELD BEFORE ' '
    OVERLAY=(081:%01,TRAN=LTOU,                  $ PUT NAME AT 81
             C'#$%&',                            $ ADD SPL CHAR #$%&
             135:%02,TRAN=LTOU)),                $ PUT DOMAIN AT 135
    IFTHEN=(WHEN=INIT,
           PARSE=(%03=(ABSPOS=81,STARTAFT=C'<',  $ REPARSE THE NAME
                      ENDBEFR=C'#$%&',           $ SPL CHAR AS STOPPER
                      FIXLEN=50)),
    OVERLAY=(185:%03)),                          $ PUT NAME AT 185
IFTHEN=(WHEN=INIT,
    FINDREP=(STARTPOS=181,INOUT=(C'"',C''))),    $ REPLACE THE "
IFTHEN=(WHEN=(185,50,CH,GT,C' '),
   BUILD=(001,80,                                $ ORIGINAL REC
          185,50,                                $ NAME
          135,50)),                              $ DOMAIN
IFTHEN=(WHEN=NONE,
   BUILD=(001,80,                                $ ORIGINAL REC
          081,50,                                $ NAME
          135,50))                               $ DOMAIN
SORT FIELDS=(081,50,CH,A, $ NAME
                131,50,CH,A),EQUALS              $ DOMAIN
/*
Thanks,
Kolusu
DFSORT Development
IBM Corporation

OK, I give up.
The job is obvoiusly working OK, however I can't fully understand its logic.

My understanding:
** first IFTHEN + OVERLAY put string before @ (with all the garbage like "John Sr Doe <") and string before end of domain (which can be space or ">" or comma). First string is placed in col 81, the second in col 135.
What is "#$%&" ? is kind of delimiter?

** the second IFTHEN parses "name" field again to remove "<". What about records without "<>" ?

** third IFTHEN simply removes " character, but why it starts from 181, while name was put on 185?

** fourth IFTHEN chooses records with non-empty field 185,50 and builds record using original record (1,80), name (185,50) and domain (135,50).

** fifth IFTHEN takes rest of records (means empty 185,50) and builds record using original record (1,80) "raw" name (81,50) and domain (131,50).

--
Radoslaw Skorupka
Lodz, Poland




======================================================================


       --
Treść tej wiadomości może zawierać informacje prawnie chronione Banku 
przeznaczone wyłącznie do użytku służbowego adresata. Odbiorcą może być jedynie 
jej adresat z wyłączeniem dostępu osób trzecich. Jeżeli nie jesteś adresatem 
niniejszej wiadomości lub pracownikiem upoważnionym do jej przekazania 
adresatowi, informujemy, że jej rozpowszechnianie, kopiowanie, rozprowadzanie 
lub inne działanie o podobnym charakterze jest prawnie zabronione i może być 
karalne. Jeżeli otrzymałeś tę wiadomość omyłkowo, prosimy niezwłocznie 
zawiadomić nadawcę wysyłając odpowiedź oraz trwale usunąć tę wiadomość 
włączając w to wszelkie jej kopie wydrukowane lub zapisane na dysku.

This e-mail may contain legally privileged information of the Bank and is 
intended solely for business use of the addressee. This e-mail may only be 
received by the addressee and may not be disclosed to any third parties. If you 
are not the intended addressee of this e-mail or the employee authorized to 
forward it to the addressee, be advised that any dissemination, copying, 
distribution or any other similar activity is legally prohibited and may be 
punishable. If you received this e-mail by mistake please advise the sender 
immediately by using the reply facility in your e-mail software and delete 
permanently this e-mail including any copies of it either printed or saved to 
hard drive.

mBank S.A. z siedzibą w Warszawie, ul. Senatorska 18, 00-950 Warszawa, 
www.mBank.pl, e-mail: [email protected]ąd Rejonowy dla m. st. Warszawy XII 
Wydział Gospodarczy Krajowego Rejestru Sądowego, nr rejestru przedsiębiorców 
KRS 0000025237, NIP: 526-021-50-88. Według stanu na dzień 01.01.2016 r. kapitał 
zakładowy mBanku S.A. (w całości wpłacony) wynosi 168.955.696 złotych.
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to