anandbtech01
New User
Joined: 07 Feb 2022 Posts: 15 Location: INDIA
|
|
|
|
File 1 has Dept Code (1-3) and Emp ID (5-14)
Code: |
INPUT 1:
010 1111111111
010 2222222222
022 3333333333
022 4444444444
|
File 2 has Employee details with different record type , in that only record type 3 alone contains Dept code at position 44.
NOTE : Record type (14-15), Emp Id (16-25), Dept Code (44-46)
Code: |
INPUT 2:
*************011111111111
*************021111111111
*************031111111111 010
*************041111111111
*************012222222222
*************022222222222
*************032222222222 010
*************042222222222
*************033333333333
*************023333333333
*************033333333333 022
*************043333333333
*************014444444444
*************024444444444
*************034444444444 022
*************044444444444
|
Expected 2 output files , each file based on market.
Out File 1 for Dept Code : 010
Code: |
OUTPUT 1:
*************011111111111
*************021111111111
*************031111111111 010
*************041111111111
*************012222222222
*************022222222222
*************032222222222 010
*************042222222222
|
Out File 2 for Dept Code : 022
Code: |
OUTPUT 2:
*************033333333333
*************023333333333
*************033333333333 022
*************043333333333
*************014444444444
*************024444444444
*************034444444444 022
*************044444444444
|
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1348 Location: Bamberg, Germany
|
|
|
|
A simple JOINKEYS will do the task for the sample you have provided.
Code: |
OPTION COPY
JOINKEYS F1=F1,FIELDS=(5,10,A)
JOINKEYS F2=F2,FIELDS=(16,10,A)
REFORMAT FIELDS=(F2:1,63,F1:1,3)
OUTFIL FNAMES=(TEN),
INCLUDE=(64,3,CH,EQ,C'010'),
BUILD=(1,63)
OUTFIL FNAMES=(TWENTY),
INCLUDE=(64,3,CH,EQ,C'022'),
BUILD=(1,63)
END |
|
|