Focal Point
[SOLVED] How to join data from one segment of a file to data from another

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/5841070713

February 06, 2009, 11:15 AM
webmeister
[SOLVED] How to join data from one segment of a file to data from another
Not sure if I'm asking this correctly, but....
Is it possible to join data from one segment of a file to data from another segment of the same file, provided of course that there is a field common to both segments? I need to put data form one segment, say, Employee, Earnings codes and so on from one segment and then hire date, job, title from another segment, and yes there is an employee id in the segments to join.

I'm just not sure how to go about this.

Thank you.

This message has been edited. Last edited by: webmeister,


Mainframe FOCUS 7.0
VM/CMS and MVS/TSO
February 06, 2009, 11:26 AM
Francis Mariani
What kind of "file" is this? VSAM? IMS? FOCUS?

If they're different segments in the same table and they both have Employee as a field, then they're most likely already related and you wouldn't have to do the JOIN, non?

If you need a join, the join syntax can include the segment name, something like this:

JOIN table-name1.segment-name1.EMPLOYEE IN table-name1 to table-name1.segment-name2.EMPLOYEE IN table-name1 AS J1



Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
February 06, 2009, 11:43 AM
webmeister
Hi, Francis, and thank you for replying.

Here is some abbreviated info from my MFD. These are the two segments whose data I want to join or to work with.

I just am not sure if I should do a join or try to work with the data without a join as such.

Incidentally, the file is VSAM

Looking forward to hearing back from you.


$***********************************************************************
SEGNAME=EB_300 , SEGTYPE=S0, PARENT=ROOT
FIELD=DELETE_300 , ,A01 ,A01 ,TITLE='Del,Byte'
GROUP=KEY_300 ,ALIAS=KEY ,A19 ,A19 ,TITLE='Segment Key'
GROUP=KEY_300B ,ALIAS=KEY8 ,A12 ,A12 ,TITLE='SEGMENT KEy'
FIELD=CORP_300 , ,A03 ,A03 ,TITLE='Corp'
FIELD=EMP_ID_300 , ,A09 ,A09 ,TITLE='Employee, ID'


===========================================================================
I WANT TO JOIN DATA IN THE ABOVE SEGMENT TO DATA IN THE BELOW SEGMENT
===========================================================================

$***********************************************************************
SEGNAME=EB_210 , SEGTYPE=S0, PARENT=ROOT
FIELD=DELETE_210 , ,A01 ,A01 ,TITLE='Del,Byte'
GROUP=KEY_210 ,ALIAS=KEY ,A19 ,A19 ,TITLE='Segment Key'
GROUP=KEY_210B ,ALIAS=KEY3 ,A12 ,A12 ,TITLE='SEGMENT KEy'
FIELD=CORP_210 , ,A03 ,A03 ,TITLE='Corp'
FIELD=EMP_ID_210 , ,A09 ,A09 ,TITLE='Employee, ID'



Mainframe FOCUS 7.0
VM/CMS and MVS/TSO
February 06, 2009, 11:49 AM
GinnyJakes
WM,

Look up recursive join. That should work for you. You will have to TAG the join so that you will be able to differentiate between the fields with the same names but on different levels.


Ginny
---------------------------------
Prod: WF 7.7.01 Dev: WF 7.6.9-11
Admin, MRE,self-service; adapters: Teradata, DB2, Oracle, SQL Server, Essbase, ESRI, FlexEnable, Google
February 06, 2009, 12:34 PM
webmeister
Hi, Ginny,

I was wondering about that....I'll look it up and see what it can do for me. I've never really understood recursive joions, so there's no time like the present to learn.

Thanks!


Mainframe FOCUS 7.0
VM/CMS and MVS/TSO
February 06, 2009, 12:39 PM
GinnyJakes
They make your eyes cross, Roll Eyes, and aren't a lot of fun.

Good luck!


Ginny
---------------------------------
Prod: WF 7.7.01 Dev: WF 7.6.9-11
Admin, MRE,self-service; adapters: Teradata, DB2, Oracle, SQL Server, Essbase, ESRI, FlexEnable, Google
February 12, 2009, 10:10 AM
Shrikant
Webmeinster,

From the MFD you have provided, it is clear the key filed of the two segment is same. There should be some identifier in each segment to identify the type of the record. For instance consider CORP, EMPLOYEE ID and TYPE (values 0000001 and 0000002) forms the key of the VSAM file. You can use the below approach to join the two segments of the data source:

  
DEFINE FILE filename
KEY_1/A12 = EDIT(KEY_300,'999999999999$$$$$$$');
END

TABLE FILE filename
PRINT EMPNAME
      EARNINGCODE
BY KEY_1
IF TYPE EQ '0000001'
ON TABLE HOLD AS TP1HLD
END

TABLE FILE filename
PRINT HIREDATE
      JOB
      TITILE
BY KEY_210
IF TYPE EQ '0000002'
ON TABLE HOLD AS TP2HLD
END

JOIN KEY_1 IN TP1HLD TO KEY_210 IN TP2HLD AS JOIN12

TABLE FILE TP1HLD
PRINT EMPNAME
      EARNINGCODE
      HIREDATE
      JOB
      TITLE
BY KEY_1
END


-Shrikant


FOCUS 7.2.3
Platform: IBM system Z9 Business class
O/P formats: Flat files, excel and CSV files