Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Splitting a single record into many

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Splitting a single record into many
 Login/Join
 
Platinum Member
posted
HI all, I have a conceptional question which may or may not be possible. (not sure if I worded it right for my initial search)

I have a file with multiple fields of the same data, i.e. color.

For simplicity, lets say it has 21 fields. A sku number, and 20 color fields.
SKUNUMBER
COLOR001
COLOR002
COLOR003
...
COLOR020

Is there any way, in a Master file, to seperate these into 20 records, each having the sku_number and a single color field?
i.e. sku color001
sku color002
....
sku color020

I could do this using SQL and multiple passes with a hold file, but I am looking for a master file solution if possible.

and, i'll state up front, I have very little experience with Master file creation.

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


Lloyd Prendergast
Michael Kors (USA), Inc.
Phone: 201-453-5076
Fax: 646-354-4776
Lloyd.Prendergast@Michaelkors.com


WebFOCUS 523
WebFOCUS 7.6
WebFOCUS 7.7

Windows Server 2005
Windows Server 2008

Iseries V5R3M0
Iseries V5R5M0
Iseries V6R1M0
 
Posts: 157 | Location: Secaucus, NJ | Registered: May 21, 2004Report This Post
Expert
posted Hide Post
I think you cannot do that with a database table, but you can with a HOLD file. First create a hold file with data extracted from your database table. Then create a Master "on the fly" in the report fex or as a stand alone master. Then use FILEDEF to reassign which master you want to use with the hold file.

Here's a working example:

SET ASNAMES=ON
SET HOLDLIST=PRINTONLY
SET HOLDFORMAT=ALPHA


-* create a test hold file of skus and colours 
FILEDEF SKUS DISK skus.ftm
-RUN

-WRITE SKUS 1234 RED       GREEN     YELLOW    BLUE      PINK      ORANGE    SILVER    GOLD      MAROON    BROWN
-WRITE SKUS 3456 PINK      STEEL     SILVER    BLACK     TAUPE     AZURE     YELLOW    MOSS      AQUA      LIGHT BLUE
-RUN

-* create a master for the test hold file 
FILEDEF DATAMAST DISK skus.mas
-RUN

-WRITE DATAMAST
-WRITE DATAMAST FILE=SKUS, SUFFIX=FIX, $
-WRITE DATAMAST SEGNAME=SEG1, SEGTYPE=S0, $
-WRITE DATAMAST   FIELD=SKU_NUMBER, ALIAS=SKU, USAGE=A5, ACTUAL=A5, $
-WRITE DATAMAST   FIELD=COLOR001, ALIAS=COL001 , USAGE=A10, ACTUAL=A10, $
-WRITE DATAMAST   FIELD=COLOR002, ALIAS=COL002 , USAGE=A10, ACTUAL=A10, $
-WRITE DATAMAST   FIELD=COLOR003, ALIAS=COL003 , USAGE=A10, ACTUAL=A10, $
-WRITE DATAMAST   FIELD=COLOR004, ALIAS=COL004 , USAGE=A10, ACTUAL=A10, $
-WRITE DATAMAST   FIELD=COLOR005, ALIAS=COL005 , USAGE=A10, ACTUAL=A10, $
-WRITE DATAMAST   FIELD=COLOR006, ALIAS=COL006 , USAGE=A10, ACTUAL=A10, $
-WRITE DATAMAST   FIELD=COLOR007, ALIAS=COL007 , USAGE=A10, ACTUAL=A10, $
-WRITE DATAMAST   FIELD=COLOR008, ALIAS=COL008 , USAGE=A10, ACTUAL=A10, $
-WRITE DATAMAST   FIELD=COLOR009, ALIAS=COL009 , USAGE=A10, ACTUAL=A10, $
-WRITE DATAMAST   FIELD=COLOR010, ALIAS=COL010 , USAGE=A10, ACTUAL=A10, $

-* create the report with sku and all colours in the same row
TABLE FILE SKUS
PRINT
*
HEADING
"REPORT 1"
END
-RUN

-* create a master for the hold file, with occurs
FILEDEF DATAMAST DISK SKUS_OCC.MAS
-RUN

-WRITE DATAMAST
-WRITE DATAMAST FILE=SKUS_OCC, SUFFIX=FIX, $

-WRITE DATAMAST SEGNAME=SEG1, SEGTYPE=S0, $
-WRITE DATAMAST   FIELD=SKU_NUMBER, ALIAS=SKU, USAGE=A5, ACTUAL=A5, $

-WRITE DATAMAST SEGNAME=SEG2, PARENT=SEG1, OCCURS=20, $
-WRITE DATAMAST   FIELD=COLOUR, ALIAS=COL , USAGE=A10, ACTUAL=A10, $

-* reassign the test hold file to the master with occurs
FILEDEF SKUS_OCC DISK skus.ftm
-RUN

-* create the report with sku and individual colours
TABLE FILE SKUS_OCC
PRINT
SKU_NUMBER
COLOUR
HEADING
"REPORT 2"
END
-RUN


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
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Expert
posted Hide Post
OCCURS is probably the best way.

You can also have the OCCURS as variable if you do not know the number of fields.

I would suggest checking out the documentation on the concepts.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
Platinum Member
posted Hide Post
Hi Francis,
Thanks very much for that, it definitely points me in the right direction. There is one issue I am having with your example, it only returns 19 records. For some reason it's dropping BROWN from the first record.

Now that I have an idea of how to do this, I should be OK.

Waz, yes, I definitely got some reading to do. Frankly, it's about time for me to learn about these master file thingy's.


Lloyd Prendergast
Michael Kors (USA), Inc.
Phone: 201-453-5076
Fax: 646-354-4776
Lloyd.Prendergast@Michaelkors.com


WebFOCUS 523
WebFOCUS 7.6
WebFOCUS 7.7

Windows Server 2005
Windows Server 2008

Iseries V5R3M0
Iseries V5R5M0
Iseries V6R1M0
 
Posts: 157 | Location: Secaucus, NJ | Registered: May 21, 2004Report This Post
Expert
posted Hide Post
Master Files can do some really amazing things.

Cool


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
Platinum Member
posted Hide Post
Francis, thanks so much for your help. Your solution worked perfectly for what I needed.

The reality of my need was I have four groups with repetitive fields, 3 occurs, 40 occurs, 20 occurs, and 25 occurs. If I had to rely on SQL for this I'd probably go nuts....but the occurs made it quite easy.


Lloyd Prendergast
Michael Kors (USA), Inc.
Phone: 201-453-5076
Fax: 646-354-4776
Lloyd.Prendergast@Michaelkors.com


WebFOCUS 523
WebFOCUS 7.6
WebFOCUS 7.7

Windows Server 2005
Windows Server 2008

Iseries V5R3M0
Iseries V5R5M0
Iseries V6R1M0
 
Posts: 157 | Location: Secaucus, NJ | Registered: May 21, 2004Report This Post
Expert
posted Hide Post
The problem in my original example is due to the fact that I was generating the demo HOLD file with WRITE statements and the length of the first row of data was less than what the master declares. I can probably fix that with a variable block file or column. It won't occur in the real world because you have a real HOLD file.

I'm glad the occurs works for you.


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
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Splitting a single record into many

Copyright © 1996-2020 Information Builders