Focal Point Banner
Community Center Education Summit Technical Support User Groups
Let's Get Social!

Facebook Twitter LinkedIn YouTube
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Concatenate defines into a comma separated value.
Go
New
Search
Notify
Tools
Reply
  
[CLOSED] Concatenate defines into a comma separated value.
 Login/Join
 
Platinum Member
posted
Hi,

I have 10 define fields which is of A20 format.
Now i want to create a field which concatenate all 10 define fields.

The issue i have is when concatenating using the operand ||','|| i get continuous comma when a define field is empty.
I tried using TRIM with LEADING , TRAILING and BOTH options,but how can i remove the commas in between.

 TRIM_(BOTH, ',', DEF1 || ','|| DEF2 ||','|| DEF3 ||','|| DEF4 ||','|| DEF5 ||','|| DEF6 ||','|| DEF7 ||','|| DEF8 ||','|| DEF9 || ','||DEF11 ) 


Any suggestions.

This message has been edited. Last edited by: FP Mod Chuck,


WF8202M,Windows 7,8,10
HTM,PDF,EXCEL
 
Posts: 208 | Location: MI | Registered: September 13, 2017Reply With QuoteReport This Post
Virtuoso
posted Hide Post
Can you show us what you're seeing and what you expect? I'm not sure I understand what's happening when a define is empty.


WebFOCUS 8206, Unix, Windows
 
Posts: 1716 | Location: New York City | Registered: December 30, 2015Reply With QuoteReport This Post
Platinum Member
posted Hide Post
When i have DEF1, DEF2 and DEF6 as empty i get the output like.

  
,,DEF3,DEF4,DEF5,,,DEF7,DEF8,DEF9,DEF10


If i use TRIM_(LEADING, ',', DEF1 || ','|| DEF2 ||','|| DEF3 ||','|| DEF4 ||','|| DEF5 ||','|| DEF6 ||','|| DEF7 ||','|| DEF8 ||','|| DEF9 || ','||DEF11 ) ,i can get rid of the first two commas.

But when i have commas between define outputs,TRIM won't help.


WF8202M,Windows 7,8,10
HTM,PDF,EXCEL
 
Posts: 208 | Location: MI | Registered: September 13, 2017Reply With QuoteReport This Post
Virtuoso
posted Hide Post
Take a look at REPLACE function. That might be a better one to use.
https://webfocusinfocenter.inf...r/source/replace.htm


WebFOCUS 8206, Unix, Windows
 
Posts: 1716 | Location: New York City | Registered: December 30, 2015Reply With QuoteReport This Post
Platinum Member
posted Hide Post
I am working in 8105 currently(for this issue) and it seems like 8105 don't have REPLACE function.

Also it will replace all the commas i think.


WF8202M,Windows 7,8,10
HTM,PDF,EXCEL
 
Posts: 208 | Location: MI | Registered: September 13, 2017Reply With QuoteReport This Post
Expert
posted Hide Post
Check out the documentation on functions.

Look at STRREP for example.

The other option you have is to create an intermediate define field for each testing for blank, and either leaving as blank or adding the comma, then combine.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.06OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Know The Code

 
Posts: 6136 | Location: 33.8688° S, 151.2093° E | Registered: October 31, 2006Reply With QuoteReport This Post
Platinum Member
posted Hide Post
Okay @Waz.
I did use STRREP ,but it work similar to REPLACE.
I am thinking of moving forward with the other option you mentioned.


WF8202M,Windows 7,8,10
HTM,PDF,EXCEL
 
Posts: 208 | Location: MI | Registered: September 13, 2017Reply With QuoteReport This Post
Expert
posted Hide Post
Yes, its probably the more robust option.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.06OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Know The Code

 
Posts: 6136 | Location: 33.8688° S, 151.2093° E | Registered: October 31, 2006Reply With QuoteReport This Post
Master
posted Hide Post
quote:
The other option you have is to create an intermediate define field for each testing for blank, and either leaving as blank or adding the comma, then combine.


Agreed. And then use the TRIM_ function to remove the trailing comma. Something like this:
 

DEFINE FILE master
DEF1/A4 = IF Field1 EQ '' THEN '' ELSE Field1 || ',';
DEF2/A4 = IF Field2 EQ '' THEN '' ELSE Field2 || ',';
DEF3/A4 = IF Field3 EQ '' THEN '' ELSE Field3 || ',';
DEF4/A4 = IF Field4 EQ '' THEN '' ELSE Field4 || ',';
DEF5/A4 = IF Field5 EQ '' THEN '' ELSE Field5 || ',';
DEF6/A4 = IF Field6 EQ '' THEN '' ELSE Field6 || ',';
DEF7/A4 = IF Field7 EQ '' THEN '' ELSE Field7 || ',';
DEF8/A4 = IF Field8 EQ '' THEN '' ELSE Field8 || ',';
DEF9/A4 = IF Field9 EQ '' THEN '' ELSE Field9 || ',';
CONCAT/50V = TRIM_(TRAILING, ',', DEF1||DEF2||DEF3||DEF4||DEF5||DEF6||DEF7||DEF8||DEF9);
END
 


Hallway
WF(Prod):8202M
WF(Test):8202M
OS/Platform:Win 10
Outputs:All
 
Posts: 493 | Location: Salt Lake City, UT, USA | Registered: November 18, 2015Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Concatenate defines into a comma separated value.

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