![]() |
||||||||||||
Go ![]() | New ![]() | Search ![]() | Notify ![]() | Tools ![]() | Reply ![]() | ![]() |
Platinum Member |
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 | ||
|
Virtuoso |
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 | |||
|
Platinum Member |
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 | |||
|
Virtuoso |
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 | |||
|
Platinum Member |
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 | |||
|
Expert |
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...
| |||||||||||||||||||||||||||
|
Platinum Member |
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 | |||
|
Expert |
Yes, its probably the more robust option. Waz...
| |||||||||||||||||||||||||||
|
Master |
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
| ||||||||||||||
|
Powered by Social Strata |
![]() | Please Wait. Your request is being processed... |
|