Focal Point
[SOLVED] Question about DYNAM CONCAT on the mainframe

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

October 06, 2009, 09:18 AM
Greaseman
[SOLVED] Question about DYNAM CONCAT on the mainframe
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
October 06, 2009, 10:27 AM
Francis Mariani
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


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
October 06, 2009, 10:35 AM
GinnyJakes
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
October 06, 2009, 10:36 AM
Francis Mariani
Good idea!


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
October 06, 2009, 10:45 AM
Greaseman
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
October 06, 2009, 10:52 AM
Francis Mariani
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


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
October 06, 2009, 11:07 AM
Greaseman
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
October 06, 2009, 12:03 PM
Francis Mariani
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


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
October 06, 2009, 01:55 PM
Greaseman
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
October 06, 2009, 04:51 PM
David Briars
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





Pilot: WebFOCUS 8.2.06 Test: WebFOCUS 8.1.05M Prod: WebFOCUS 8.1.05M Server: Windows Server 2016/Tomcat Standalone Workstation: Windows 10/IE11+Edge Database: Oracle 12c, Netezza, & MS SQL Server 2019 Output: AHTML/XLSX/HTML/PDF/JSCHART Tools: WFDS, Repository Content, BI Portal Designer & ReportCaster
October 06, 2009, 05:17 PM
Francis Mariani
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


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
October 07, 2009, 11:08 AM
Greaseman
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