Page 1 of 1

update colums, if match found in file1 and file2.

Posted: Wed Jan 04, 2023 8:46 pm
by Puja Motwani
Hi all, how to update colums, if match found in file1 and file2.

Can anyone help

Re: update colums, if match found in file1 and file2.

Posted: Wed Jan 04, 2023 8:58 pm
by Robert Sample
What "colums" (sic)? You posted in the thought of the day, general talk & jokes forum so you're obviously NOT talking about DB2 columns (which is the correct spelling). Furthermore, you did not provide any context for "file1" and "file2" -- are these input data sets? Are they driving a matching process? Are they merely random files?

In other words, based upon what you've posted so far there is no way anyone could possibly help you as it is not clear what your problem is, what your environment is, nor what you have already tried.

Re: update colums, if match found in file1 and file2.

Posted: Thu Jan 05, 2023 8:11 am
by Anuj Dhawan
This definitely needs more explanation as Robert has said too. What kind of solution are you looking for COBOL or SORT or anything else?

Re: update colums, if match found in file1 and file2.

Posted: Fri Jan 06, 2023 10:08 pm
by Puja Motwani
Hey, sorry for not being clear.

There are two files and need to do it using sort.

Re: update colums, if match found in file1 and file2.

Posted: Sat Jan 07, 2023 11:16 am
by Anuj Dhawan
This is a classic case of JOINKEYs in SORT, unless there is more to what meets the eyes. See below exmaple:

Code: Select all

//JKE1  EXEC  PGM=SORT
//SYSOUT    DD  SYSOUT=*
//SORTJNF1 DD *
Roses          03  Red
Daisies        06  Orange
Roses          04  Pink
Daisies        02  Yellow
Roses          06  Yellow
Daisies        12  Lilac
Roses          09  Blue
/*
//SORTJNF2 DD *
Red      Lilies          InStock
Red      Roses           InStock
Orange   Daisies         SoldOut
Pink     Roses           SoldOut
Yellow   Daisies         InStock
Yellow   Roses           Ordered
Lilac    Daisies         SoldOut
White    Daisies         InStock
/*
//SORTOUT DD SYSOUT=*
//SYSIN    DD    *
* Control statements for JOINKEYS application
  JOINKEYS FILE=F1,FIELDS=(1,15,A,20,8,A)
  JOINKEYS FILE=F2,FIELDS=(10,15,A,1,8,A)
  REFORMAT FIELDS=(F1:20,8,1,15,F2:26,10,F1:16,2)
* Control statements for main task (joined records)
  OPTION COPY
  OUTFIL REMOVECC,
    HEADER2=(1:'Color',11:'Flower',26:'Status',36:'Per Pot',/,
             1:7'-',11:14'-',26:7'-',36:7'-'),
    BUILD=(1:1,8,11:9,15,26:24,10,
      36:34,2,ZD,M10,LENGTH=7)
/*
The output file will have RECFM=FB and LRECL=42. It will contain the paired records from the two files reformatted as follows:

Code: Select all

Color     Flower         Status    Per Pot
-------   -------------- -------   -------
Lilac     Daisies        SoldOut        12
Orange    Daisies        SoldOut         6
Yellow    Daisies        InStock         2
Pink      Roses          SoldOut         4
Red       Roses          InStock         3
Yellow    Roses          Ordered         6
If there are more to it - post specific examples.