|
View previous topic :: View next topic
|
| Author |
Message |
Chidane
New User
Joined: 25 Nov 2021 Posts: 34 Location: India
|
|
|
|
Hi All,
Could you please help me with a solution for my requirement.
I have the flat file of 39 LRECL with data as below
- 3 char Seq, 3 char Num, 8 char date (4 occurrences), 1 char ID
| Code: |
001ABC20210930 U
002DEF202107302021110520211203 U
003XYZ2020051020210410 U
004WRT U |
Output should be - Each record with multiple date occurrence should come one below another as shown below with the output LRECL as 16 byte. If the date is not there, the record should be displayed as it is.
Format is 3 char Seq, 3 char Num, 8 char Date, 1 char space, 1 char ID
| Code: |
001ABC20210930 U
002DEF20210730 U
002DEF20211105 U
002DEF20211203 U
003XYZ20200510 U
003XYZ20210410 U
004WRT U
|
Can you please let me know whether this requirement can be accomplished using SORT or should I need to go with COBOL program.
Thanks
Chib |
|
| Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1448 Location: Bamberg, Germany
|
|
|
|
| Code: |
OPTION COPY
OUTFIL FNAMES=(SORTOUT),
REMOVECC,
IFTHEN=(WHEN=(23,1,CSF,EQ,NUM),
BUILD=(1,14,X,39,1,/,1,6,15,8,X,39,1,/,1,6,23,8,X,39,1)),
IFTHEN=(WHEN=(15,1,CSF,EQ,NUM),
BUILD=(1,14,X,39,1,/,1,6,15,8,X,39,1)),
IFTHEN=(WHEN=(7,1,CSF,EQ,NUM),
BUILD=(1,14,X,39,1)),
IFTHEN=(WHEN=NONE,BUILD=(1,6,16:39,1))
END |
|
|
| Back to top |
|
 |
Chidane
New User
Joined: 25 Nov 2021 Posts: 34 Location: India
|
|
|
|
Thanks very much Joerg.
I just tried this logic with 4 date occurrences as I have mentioned in my requirement and it worked.
I was asked, whether date occurrences can be increased from 4 to 50. So whether in that case, should we need to have the
IFTHEN statement 50 times covering all the 50 positions where date will come. Or whether there is any other way.
Thanks
Chib |
|
| Back to top |
|
 |
sergeyken
Senior Member

Joined: 29 Apr 2008 Posts: 2290 Location: USA
|
|
|
|
The joke is: SORT card does not participate in the whole process, not a bit!  |
|
| Back to top |
|
 |
Chidane
New User
Joined: 25 Nov 2021 Posts: 34 Location: India
|
|
|
|
I was of the impression that it comes under SORT card.
Sorry for that.
Regards
Chib |
|
| Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1448 Location: Bamberg, Germany
|
|
|
|
| Chidane wrote: |
I was asked, whether date occurrences can be increased from 4 to 50. So whether in that case, should we need to have the
IFTHEN statement 50 times covering all the 50 positions where date will come. |
You can repeat the logic for more fields of course. If you use PARSE and symbols it will be easier to fulfill the requirement. See with four parsed fields:
| Code: |
//WHATEVER EXEC PGM=ICEMAN
//SYMNAMES DD *
POSITION,7
p_01,*,8
p_02,*,8
p_03,*,8
p_04,*,8
ident,*,1
/*
//SYMNOUT DD SYSOUT=*
//SORTIN DD *
001ABC20210930 U
002DEF202107302021110520211203 U
003XYZ2020051020210410 U
004WRT U
/*
//SYSOUT DD SYSOUT=*
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
OUTFIL FNAMES=(SORTOUT),
REMOVECC,
IFTHEN=(WHEN=INIT,
PARSE=(%=(ABSPOS=7),
%01=(FIXLEN=8,REPEAT=4))),
IFTHEN=(WHEN=(p_04,CSF,EQ,NUM),
BUILD=(1,6,%01,X,ident,/,
1,6,%02,X,ident,/,
1,6,%03,X,ident,/,
1,6,%04,X,ident)),
IFTHEN=(WHEN=(p_03,CSF,EQ,NUM),
BUILD=(1,6,%01,X,ident,/,
1,6,%02,X,ident,/,
1,6,%03,X,ident)),
IFTHEN=(WHEN=(p_02,CSF,EQ,NUM),
BUILD=(1,6,%01,X,ident,/,
1,6,%02,X,ident)),
IFTHEN=(WHEN=(p_01,CSF,EQ,NUM),
BUILD=(1,6,%01,X,ident)),
IFTHEN=(WHEN=NONE,BUILD=(1,6,16:ident))
END
/* |
|
|
| Back to top |
|
 |
Chidane
New User
Joined: 25 Nov 2021 Posts: 34 Location: India
|
|
|
|
Hi All,
If I have the date occurrences as 50 (coming in fixed positions), whether I need to have 50 BUILD statements or whether there is any other way to get this done.
Appreciate your help.
Thanks
Chib |
|
| Back to top |
|
 |
Joerg.Findeisen
Senior Member

Joined: 15 Aug 2015 Posts: 1448 Location: Bamberg, Germany
|
|
|
|
| Chidane wrote: |
| ..or whether there is any other way to get this done. |
Use a programming language of your choice that supports loops and iterations. In REXX it's less than twenty lines of code including your sample data. |
|
| Back to top |
|
 |
Chidane
New User
Joined: 25 Nov 2021 Posts: 34 Location: India
|
|
|
|
Thanks Joerg.
I have tried SYM and it seems to be non supporting.
I am trying COBOL program for the same.
The IFTHEN statement that you have mentioned at first does the job easily and perfectly, however since I have to expand it to 50 date occurrences, I have to code 50 IFTHEN combinations.
Thatz why was checking, to avoid COBOL programming way.
Thanks for the suggestion.
Thanks
Chib |
|
| Back to top |
|
 |
|
|
 |
All times are GMT + 6 Hours |
|