Tech Doc Search Tech Support User Forums WebFOCUS Newsletter Summit Education

IB - Developer Center    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Question about DYNAM CONCAT on the mainframe
Go
New
Search
Notify
Tools
Reply
  
[SOLVED] Question about DYNAM CONCAT on the mainframe
 Login/Join
 
Member
posted
We are running mainframe FOCUS (not WebFOCUS) and I have a question about using DYNAM CONCAT. In a program we wrote, we can have up to 5 files, all identical, that we want to concatenate together. However, in some cases, there may not be all five files. When we are missing, say FILE1 and use the following, we get errors:



We don't want to write a lot of code to check for the existence of (in this example) FILE1. How can we have a check for the existence of FILE1?

Also, we can have any permutation of the files - one run might have FILE1, FILE2 and FILE3 and then the next run might have FILE2, FILE4 and FILE5 and so on. That's why we don't want to write a ton of code.

Any ideas and suggestions will be appreciated.

And again, this is Mainframe FOCUS, not WebFOCUS.

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


Mainframe FOCUS, Rel 7.1.1 running on MVS/TSO
Windows XP, Mainframe VM/CMS and MVS/TSO
outputs in Reports, Excel, Flat file
 
Posts: 15 | Location: Texas | Registered: September 01, 2009Reply With QuoteReport This Post
Expert
posted Hide Post
Please edit your posting and put the DYNAM command between code tags (for some weird reason, the DYNAM command was translated to HTML):

[CODE]
DYNAM CONCAT DDNAME FILE1 FILE2 FILE3 FILE4 FILE5
[/CODE]


If you have a separate Master for each of the five files, I would allocate the five files and then use the MORE statement (if they're already allocated, the the DYNAM ALLOC are not required):

DYNAM ALLOC FILE FILE1 DA ONE.TWO.THREE.DATA1 SHR REUSE
DYNAM ALLOC FILE FILE2 DA ONE.TWO.THREE.DATA2 SHR REUSE
DYNAM ALLOC FILE FILE3 DA ONE.TWO.THREE.DATA3 SHR REUSE
DYNAM ALLOC FILE FILE4 DA ONE.TWO.THREE.DATA4 SHR REUSE
DYNAM ALLOC FILE FILE5 DA ONE.TWO.THREE.DATA5 SHR REUSE

TABLE FILE FILE1
PRINT *
ON TABLE HOLD AS HCONCAT
MORE
FILE FILE2
MORE
FILE FILE3
MORE
FILE FILE4
MORE
FILE FILE5
END

I, luckily, don't have access to a mainframe to test this, but I think this will not give any errors for missing files.


Francis

I have been working with Information Builders products since 1991, so I believe I have enough experience to allow myself the opportunity to provide my opinion in the hope that it helps build a better product.

Production: WF 7.7.05M / Sandbox: WF 8.0.08, MRE, BI Dashboard, Self Service, Dev Studio, Apache Tomcat/6.0.20, MS IIS 7, Oracle, MS Windows 7, I.E. 9, Output formats: HTML, Excel 2000, PDF
An old coder will never let you down
 
Posts: 8636 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Reply With QuoteReport This Post
Expert
posted Hide Post
Without looking anything up, how about a Dialogue Manager loop that checks the existence of each file, maybe by doing a DYNAM ALLOC for each file individually and checking the return code before adding it to the CONCAT.


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
 
Posts: 2723 | Location: Ann Arbor, MI | Registered: April 05, 2006Reply With QuoteReport This Post
Expert
posted Hide Post
Good idea!


Francis

I have been working with Information Builders products since 1991, so I believe I have enough experience to allow myself the opportunity to provide my opinion in the hope that it helps build a better product.

Production: WF 7.7.05M / Sandbox: WF 8.0.08, MRE, BI Dashboard, Self Service, Dev Studio, Apache Tomcat/6.0.20, MS IIS 7, Oracle, MS Windows 7, I.E. 9, Output formats: HTML, Excel 2000, PDF
An old coder will never let you down
 
Posts: 8636 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Reply With QuoteReport This Post
Member
posted Hide Post
Francis,

Thanks for replying and apologies for messing up the code tags.

Question: If in running our program, only 3 files got processed, for example FILE2, FILE4 and FILE5, would some simple GOTO logic placed into your suggestion help with our plight? I used pseudocode below, not real actual code. We can have any permutation of file combinations. Almost forgot... these FILE1, FILE2, etc. files are created as HOLD files.... if I understand you, since the files are created, I would not need to use the DYNAM ALLOC code? How would I then check for file existence, in order to avoid having the DYNAM CONCAT code not bomb? I think I'm confused but hope I got my questions across.

-IF FILE1 doesn't exist GOTO CKFILE2
DYNAM ALLOC FILE FILE1 DA ONE.TWO.THREE.DATA1 SHR REUSE
-CKFILE2
-If FILE2 doesn't exist GOTO CKFILE3
DYNAM ALLOC FILE FILE2 DA ONE.TWO.THREE.DATA2 SHR REUSE
-CKFILE3
-IF FILE3 doesn't exist GOTO CKFILE4
DYNAM ALLOC FILE FILE3 DA ONE.TWO.THREE.DATA3 SHR REUSE
-CKFILE4
-IF FILE4 doesn't exist GOTO CKFILE5
DYNAM ALLOC FILE FILE4 DA ONE.TWO.THREE.DATA4 SHR REUSE
-CKFILE5
-IF FILE5 doesn't exist GOTO DONEALOC
DYNAM ALLOC FILE FILE5 DA ONE.TWO.THREE.DATA5 SHR REUSE

-DONEALOC

TABLE FILE FILE1
PRINT *
ON TABLE HOLD AS HCONCAT
MORE
FILE FILE2
MORE
FILE FILE3
MORE
FILE FILE4
MORE
FILE FILE5
END
 
 


Mainframe FOCUS, Rel 7.1.1 running on MVS/TSO
Windows XP, Mainframe VM/CMS and MVS/TSO
outputs in Reports, Excel, Flat file
 
Posts: 15 | Location: Texas | Registered: September 01, 2009Reply With QuoteReport This Post
Expert
posted Hide Post
If they're created as HOLD files within the same fex as the rest of the code, then you have Masters for them, so my suggestion using MORE might be the best bet, and you won't need DYNAM commands.


Francis

I have been working with Information Builders products since 1991, so I believe I have enough experience to allow myself the opportunity to provide my opinion in the hope that it helps build a better product.

Production: WF 7.7.05M / Sandbox: WF 8.0.08, MRE, BI Dashboard, Self Service, Dev Studio, Apache Tomcat/6.0.20, MS IIS 7, Oracle, MS Windows 7, I.E. 9, Output formats: HTML, Excel 2000, PDF
An old coder will never let you down
 
Posts: 8636 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Reply With QuoteReport This Post
Member
posted Hide Post
I'm not that familiar with the MORE instruction. If I used your suggested MORE snippet, can I use it as is, or would I have to check for each file's existence?

Thanks for your replies and ideas.


Mainframe FOCUS, Rel 7.1.1 running on MVS/TSO
Windows XP, Mainframe VM/CMS and MVS/TSO
outputs in Reports, Excel, Flat file
 
Posts: 15 | Location: Texas | Registered: September 01, 2009Reply With QuoteReport This Post
Expert
posted Hide Post
If the Masters for the four HOLD files all exist, then the MORE commands will work as is - whether there is data or not.

Read up on the MORE command - all the code goes before the first MORE command - after the first MORE command, the only valid statement other than the FILE statement are WHERE/IF statements for each MORE.


Francis

I have been working with Information Builders products since 1991, so I believe I have enough experience to allow myself the opportunity to provide my opinion in the hope that it helps build a better product.

Production: WF 7.7.05M / Sandbox: WF 8.0.08, MRE, BI Dashboard, Self Service, Dev Studio, Apache Tomcat/6.0.20, MS IIS 7, Oracle, MS Windows 7, I.E. 9, Output formats: HTML, Excel 2000, PDF
An old coder will never let you down
 
Posts: 8636 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Reply With QuoteReport This Post
Member
posted Hide Post
Thanks, Francis.... I'll do my reading. I appreciate your help.


Mainframe FOCUS, Rel 7.1.1 running on MVS/TSO
Windows XP, Mainframe VM/CMS and MVS/TSO
outputs in Reports, Excel, Flat file
 
Posts: 15 | Location: Texas | Registered: September 01, 2009Reply With QuoteReport This Post
Guru
posted Hide Post
If your HOLD files are in FOCUS FORMAT, or you can convert to using HOLD FORMAT FOCUS, you could consider USEing the USE command...

For example:
  
-*
DYNAM ALLOC DD CAR DS DMB3.FOCUS.CAR SHR REUSE
-SET &COUNT = 0;
-*
-REPEAT ENDLABEL 5 TIMES
-SET &COUNT = &COUNT + 1;
-SET &COUNTRY = DECODE &COUNT('1' 'CHINA'
-                             '2' 'FRANCE'
-                             '3' 'ENGLAND'
-                             '4' 'JAPAN'
-                             '5' 'USA');
-SET &HOLDNAME = 'HOLD' | &COUNT;
TABLE FILE CAR
PRINT COUNTRY
IF    COUNTRY EQ &COUNTRY
ON TABLE HOLD AS &HOLDNAME FORMAT FOCUS
END
-RUN
-ENDLABEL
-*
USE
HOLD1 AS HOLD1
HOLD2 AS HOLD1
HOLD3 AS HOLD1
HOLD4 AS HOLD1
HOLD5 AS HOLD1
END
-RUN
-*
TABLE FILE HOLD1
PRINT COUNTRY
END


Yields:
PAGE     1

COUNTRY
-------
FRANCE
ENGLAND
JAPAN




Test: WebFOCUS 8.0.07 Prod: WebFOCUS 8.0.07 Server: Windows Server 2012/Tomcat Standalone Workstation: Windows 7/IE 9 Database: Oracle 11g/Netezza 7.0 Output: AHTML/Excel/HTML/PDF/Visualizations
 
Posts: 341 | Registered: April 23, 2003Reply With QuoteReport This Post
Expert
posted Hide Post
Good solution David.

Using your code and my suggestion, here's an example with MORE:

-*DYNAM ALLOC DD CAR DS DMB3.FOCUS.CAR SHR REUSE
-SET &COUNT = 0;
-*
-REPEAT ENDLABEL1 5 TIMES
-SET &COUNT = &COUNT + 1;
-SET &COUNTRY = DECODE &COUNT('1' 'CHINA'
-                             '2' 'FRANCE'
-                             '3' 'ENGLAND'
-                             '4' 'JAPAN'
-                             '5' 'USA');
-SET &HOLDNAME = 'HOLD' | &COUNT;
TABLE FILE CAR
PRINT COUNTRY
IF    COUNTRY EQ &COUNTRY
ON TABLE HOLD AS &HOLDNAME
END
-RUN
-ENDLABEL1
-*
TABLE FILE HOLD1
PRINT COUNTRY
-REPEAT ENDLABEL2 FOR &COUNT FROM 2 TO 5
MORE
FILE HOLD&COUNT
-ENDLABEL2
END

David's suggestion is a bit better...


Francis

I have been working with Information Builders products since 1991, so I believe I have enough experience to allow myself the opportunity to provide my opinion in the hope that it helps build a better product.

Production: WF 7.7.05M / Sandbox: WF 8.0.08, MRE, BI Dashboard, Self Service, Dev Studio, Apache Tomcat/6.0.20, MS IIS 7, Oracle, MS Windows 7, I.E. 9, Output formats: HTML, Excel 2000, PDF
An old coder will never let you down
 
Posts: 8636 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Reply With QuoteReport This Post
Member
posted Hide Post
David and Francis,

Interesting! I will try your ideas as soon as possible. That looks like what I need. Thanks!


Mainframe FOCUS, Rel 7.1.1 running on MVS/TSO
Windows XP, Mainframe VM/CMS and MVS/TSO
outputs in Reports, Excel, Flat file
 
Posts: 15 | Location: Texas | Registered: September 01, 2009Reply With QuoteReport This Post
  Powered by Social Strata  
 

IB - Developer Center    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Question about DYNAM CONCAT on the mainframe

Copyright © 1996-2014 Information Builders, leaders in enterprise business intelligence.