Search code examples
mainframezossyncsort

Joining 2 datasets with SYNCSORT (JOINKEYS), is it possible to wildcard some of the values any way?


Joining 2 datasets with SYNCSORT, is it possible to wildcard some values of F1 in any way?

I want to search for the word BEER, but in F2, the values might be BEER or BEER-BLONDE, or etc..

Here is the code I have now. If F2 contains BEER-BLONDE, the record is not paired because the value is not BEER (with 16 spaces after), but I still need to set the code to 0000100002.

//STEP01   EXEC PGM=SORT,PARM='DYNALLOC=(SYSDA,255)'
//SORTMSGS DD SYSOUT=*
//SORTJNF1 DD *
0000100001WINE
0000100002BEER
0000100003OTHER
/*
//SORTJNF2 DD DSN=ZZ.MAINDATA,
//            DISP=SHR,DCB=BUFNO=255
//SORTOUT  DD DSN=ZZ.OUTPUT,
//            DISP=(NEW,CATLG,DELETE),
//            UNIT=(SYSDA,59),
//            SPACE=(CYL,(500,100),RLSE)
//SYSIN    DD *
JOINKEYS FILE=F1,FIELDS=(11,20,A)
JOINKEYS FILE=F2,FIELDS=(40,20,A)
JOIN UNPAIRED,F2
REFORMAT FIELDS=(F2:1,10,F1:1,10,F2:21,20)
OPTION COPY
//DFSPARM  DD *
MSGDDN=SORTMSGS

I don't/can't list all possibilities (example below) as they will change too frequently, it can be set to anything.

//SORTJNF1 DD *
0000100001WINE
0000100002BEER
0000100002BEER-BLONDE
0000100002BEER-BROWN
0000100002BEER-WHITE
0000100002BEER-DARK
0000100003OTHER
/*

Is there something I can do with SORT or ICETOOL to address that problem?

Thanks


Solution

  • Instead of using a JOIN to change a value based on another value (on the same row), I later learn that one can simply use IFTHEN with SYNCSORT

    //SYSIN    DD *
      OPTION COPY
      INREC IFTHEN=(WHEN=(40,11,CH,EQ,C'BEER-BLONDE'),OVERLAY=(11:C'0000100002')),
        IFTHEN=(WHEN=(40,10,CH,EQ,C'BEER-BROWN'),OVERLAY=(11:C'0000100002')),
        IFTHEN=(WHEN=(40,10,CH,EQ,C'BEER-WHITE'),OVERLAY=(11:C'0000100002')),
        IFTHEN=(WHEN=(40,9,CH,EQ,C'BEER-DARK'),OVERLAY=(11:C'0000100002')),
        IFTHEN=(WHEN=(40,4,CH,EQ,C'BEER'),OVERLAY=(11:C'0000100002')),
        IFTHEN=(WHEN=(40,4,CH,EQ,C'WINE'),OVERLAY=(11:C'0000100001')),
        IFTHEN=(WHEN=(40,5,CH,EQ,C'OTHER'),OVERLAY=(11:C'0000100003'))