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] Repeat a part of code in a fex

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Repeat a part of code in a fex
 Login/Join
 
Member
posted
Hi, I am new on Web Focus. I have been creating a Fex with developer studio 7.6.1. In a part of the FEX I need to repeat in the same line (a COMPUTE FIELD) the reading of a Date and the operations between other fields.

ex. my fields has this information:

DATEX (may have the dates: 12/01/2011, 13/01/2011, 14/01/2011, 15/01/2011, 16/01/2011)
FIELD1 (may have the values: 25, 35, 18, 35, 25, each value corresponding to a each date)
FIELD2 (may have the values: 18, 30, 16, 10, 25, too, each value correponding to a each date)

I need to put in 1 line:

Description: 12/01/2011 25-18=7, 13/01/2011 35-30=5, 14/01/2011 18-16=2, 15/01/2011 35-10=25, 16/01/2011 25-25=0

This FEX will export to an Excel file and the results appear like this:

....
....
Type: In
Form: Credit
Name: Enterprise
Code: ELA2508203L8
Address: Matamoros 25
Sent Description: 12/01/2011 25-18=7, 13/01/2011 35-30=5, 14/01/2011 18-16=2, 15/01/2011 35-10=25, 16/01/2011 25-25=0
Total: $452
...
...
I hope that somebody can advise to me and guide to me. Thanks!
Antonio

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


WebFocus 7.6.10, windows 7, win server 2003-2008 PDF, TXT, XML, html, xls, doc
 
Posts: 22 | Registered: January 06, 2011Report This Post
Expert
posted Hide Post
What does the source data look like ?


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
Member
posted Hide Post
This is part of the Master, that receive Data from a DDBB of Oracle

FIELDNAME=FAC_FECHA, ALIAS=FAC_FECHA, USAGE=DMYY, ACTUAL=DATE, $
MISSING=ON, $
FIELDNAME=ENTREGA, ALIAS=ENTREGA, USAGE=D20, ACTUAL=D8,
MISSING=ON, $
FIELDNAME=DEVOLUCION, ALIAS=DEVOLUCION, USAGE=D20, ACTUAL=D8,
MISSING=ON, $


Where FAC_FECHA is the date that I´ll use
ENTREGA is the field1
DEVOLUCION is the field2

And the data is like I showed them above

FAC_FECHA (it can have this values 12/01/2011, 13/01/2011, 14/01/2011, 15/01/2011, 16/01/2011)
ENTREGA (it can have this values 25, 35, 18, 35, 25)
DEVOLUCION (it can have this values 18, 30, 16, 10, 25)

Thanks!


WebFocus 7.6.10, windows 7, win server 2003-2008 PDF, TXT, XML, html, xls, doc
 
Posts: 22 | Registered: January 06, 2011Report This Post
Expert
posted Hide Post
Seems you want to reduce the data to one line.

You will need to convertt he dates and numerics to alpha, then you can concatenate them together.

Simple example:
DEFINE FILE ggorder
 ORDER_CONCAT/A100V = IF ORDER_NUMBER EQ 1
                      THEN EDIT(DATECVT(ORDER_DATE,'MDY','A6MDY'),'99/99/99')
                      ELSE LAST ORDER_CONCAT || (', ' | EDIT(DATECVT(ORDER_DATE,'MDY','A6MDY'),'99/99/99')) ;
END
TABLE FILE ggorder
SUM   LST.ORDER_CONCAT
WHERE ORDER_NUMBER LE 5
END


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
Member
posted Hide Post
Hi, thanks,
I used your idea, and I tried to put it in my fex, but I got some incorrect results. I show you the results:

--------------------------------------------------------------------------------
2.0
ME
1933
0000030169
2009
Ingreso

GUIA
EL DEBATE
19.20
01:02-02=00
GUIA
EL DEBATE
19.20
01:02-02=00->02 :02-02=00
GUIA
EL DEBATE
19.20
01:02-02=00->02 :02-02=00->03 :02-02=00
GUIA
EL DEBATE
19.20
01:02-02=00->02 :02-02=00->03 :02-02=00->04 :02-02=00
---------------------------------------------------------------------
the reading of the data is correct, but it put them in different blocks (lines). I tried to do an "Count", but then the reading of the data was incorrect. Too, If I use the verb PRINT, doesn´t appear the data

I show you the Code that I use, I appreciate your suggestions:

-----------------------------------------------------------------------
-* File facxml-separado.fex
DEFINE FILE FACTURACIRCULACION
DIA/D2=HPART(HDTTM(FACTURACIRCULACION.FACTURACIRCULACION.LIN_FECHAPORTADA, 10, 'HYYMDS'), 'DAY', DIA);
MES/D2=HPART(HDTTM(FACTURACIRCULACION.FACTURACIRCULACION.LIN_FECHAPORTADA, 10, 'HYYMDS'), 'MONTH', MES);
DIAMES/A5=EDIT( MES)||':'||EDIT( DIA);
DIAA/A2=EDIT(DIA);
Dent/D2=FACTURACIRCULACION.FACTURACIRCULACION.ENTREGA;
Ddev/D2=FACTURACIRCULACION.FACTURACIRCULACION.DEVOLUCION;
END
TABLE FILE FACTURACIRCULACION
SUM
COMPUTE guia/A4 = 'GUIA'; AS '' OVER
'FACTURACIRCULACION.FACTURACIRCULACION.PRO_NOMBREEXTENDIDO' AS '' OVER
'FACTURACIRCULACION.FACTURACIRCULACION.LIN_BASEIMPONIBLE/D10.2' AS '' OVER
COMPUTE DTot/D2 = Dent - Ddev; AS '' NOPRINT
COMPUTE DDet/A8 = EDIT(Dent)||'-'||EDIT(Ddev)||'='||EDIT(DTot);AS '' NOPRINT
COMPUTE CONCATENADO/A250 = IF ( FACTURACIRCULACION.FACTURACIRCULACION.PRO_NOMBREEXTENDIDO EQ LAST FACTURACIRCULACION.FACTURACIRCULACION.PRO_NOMBREEXTENDIDO )
THEN ( IF ( MES EQ LAST MES )
THEN SUBSTR(250, CONCATENADO, 1, 220, 220, 'A220') || '->'|| DIAA || ' :'|| DDet
ELSE SUBSTR(250, CONCATENADO, 1, 220, 220, 'A220') || '->'|| DIAMES || ' :'|| DDet )
ELSE DIAA || ': '||DDet; AS '' OVER
COMPUTE CONTADOR/I5 = IF FACTURACIRCULACION.FACTURACIRCULACION.PRO_NOMBREEXTENDIDO EQ LAST FACTURACIRCULACION.FACTURACIRCULACION.PRO_NOMBREEXTENDIDO THEN CONTADOR + 1 ELSE 1; AS '' NOPRINT
BY 'FACTURACIRCULACION.FACTURACIRCULACION.FAC_NUMERO' NOPRINT
BY 'FACTURACIRCULACION.FACTURACIRCULACION.FAC_SUCURSAL' NOPRINT
BY 'FACTURACIRCULACION.FACTURACIRCULACION.PRO_NOMBREEXTENDIDO' NOPRINT
BY 'FACTURACIRCULACION.FACTURACIRCULACION.LIN_FECHAPORTADA' NOPRINT
HEADING
" "
"2.0"
"""0000030169"
"2009"
"Ingreso"

" "
" "
FOOTING
""
WHERE FACTURACIRCULACION.FACTURACIRCULACION.FAC_NUMERO EQ '&FAC_NUMERO'
WHERE FACTURACIRCULACION.FACTURACIRCULACION.FAC_SUCURSAL EQ '&FAC_SUCURSAL'
ON TABLE SET EMPTYCELLS ON
ON TABLE SET PAGE-NUM OFF
ON TABLE NOTOTAL
ON TABLE PCHOLD FORMAT EXL2K
END
------------------------------------------------------------------------

Thanks!!


WebFocus 7.6.10, windows 7, win server 2003-2008 PDF, TXT, XML, html, xls, doc
 
Posts: 22 | Registered: January 06, 2011Report This Post
Expert
posted Hide Post
You have sort fields in the request, this will produce multiple records, if there are multiple records from the input.

How many lines of output are you expecting, one ?


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
<FreSte>
posted
It's not quite clear how many lines you expect and if the number of records to concatenate
are always in groups-of-5.
Below you'll find an example of making the concatenated line, but the number of consecutive
records to combine into 1 line is (in this example) hardcoded to 5.

-Fred-



FILEDEF tempfile DISK THEFILE.mas
-RUN

-WRITE tempfile FILENAME=DATASOURCE ,SUFFIX=FIX ,$
-WRITE tempfile SEGMENT=HODATASOURCELD ,SEGTYPE=S1 ,$
-WRITE tempfile FIELDNAME=FAC_FECHA ,ALIAS=FAC_FECHA ,USAGE=DMYY ,ACTUAL=A8 ,$
-WRITE tempfile FIELDNAME=ENTREGA ,ALIAS=ENTREGA ,USAGE=P8 ,ACTUAL=A8 ,$
-WRITE tempfile FIELDNAME=DEVOLUCION ,ALIAS=DEVOLUCION ,USAGE=P8 ,ACTUAL=A8 ,$
-CLOSE tempfile


FILEDEF thefile DISK thefile.ftm
-RUN

-* Replace periods with spaces (spaces are trimmed to 1 in HTML after posting)
-WRITE thefile 12012011......25......18
-WRITE thefile 13012011......35......30
-WRITE thefile 14012011......18......16
-WRITE thefile 15012011......35......10
-WRITE thefile 16012011......25......25



DEFINE FILE thefile
DIFF/P8 = ENTREGA - DEVOLUCION;
X1_FAC_FECHA/A8DMYY = FAC_FECHA;
X2_FAC_FECHA/A8 = X1_FAC_FECHA;
X3_FAC_FECHA/A10 = EDIT(X2_FAC_FECHA ,'99/99/9999');
X1_ENTREGA/A8 = FPRINT(ENTREGA ,'P8' ,'A8');
X1_DEVOLUCION/A8 = FPRINT(DEVOLUCION ,'P8' ,'A8');
X1_DIFF/A8 = FPRINT(DIFF ,'P8' ,'A8');

TMP1/A200 = X3_FAC_FECHA | X1_ENTREGA || '-' | X1_DEVOLUCION | '=' | X1_DIFF;
LINE1/A200 = SQUEEZ(200, TMP1, LINE1);
LINE2/A200 = STRREP(200, LINE1, 2, '- ' , 1 , '-' ,99 ,LINE2);
LINE3/A200 = STRREP(200, LINE2, 2, '= ' , 1 , '=' ,99 ,LINE3);

END

TABLE FILE thefile
SUM
COMPUTE COUNTER/I2 = LAST COUNTER + 1; NOPRINT
COMPUTE THELINE/A1000V = IF LAST THELINE EQ '' THEN 'Sent Description: ' | LINE3 ELSE LAST THELINE || (', ' | LINE3);
BY LINE3 NOPRINT
WHERE TOTAL COUNTER EQ 5 ;
END
-RUN

This message has been edited. Last edited by: <FreSte>,
 
Report This Post
Virtuoso
posted Hide Post
quote:
spaces are trimmed to 1 in HTML after posting
Well, that's where the red icon displaying as < / > (visible when posting) comes into play. Try it.


GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
 
Posts: 1961 | Location: Netherlands | Registered: September 25, 2007Report This Post
Member
posted Hide Post
I´m expecting almost a month, i mean 30 or 31 days for example, (shown in 1 line).
This line is in the midle of other lines or fields.
Of course the dates and data will change.
I Show you the example that I want in the result:
I have 2 products (El Debate, and La Razón):

....
....
Guia
19.20
El Debate
01: 25-18=7, 02: 35-30=5, 03: 18-16=2, 04: 35-10=25, 05: 25-25=0 ... (n days in the invoice)
Guia
4.50
La Razón
01: 20-18=2, 02: 25-20=5, 03: 28-12=16, 04: 15-1=14, 05: 22-15=7 ... (n days in the invoice)
...
...


The line that I need and i have troubles to show is where dates appear. I only use the day of the date.
Thanks.

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


WebFocus 7.6.10, windows 7, win server 2003-2008 PDF, TXT, XML, html, xls, doc
 
Posts: 22 | Registered: January 06, 2011Report This Post
<FreSte>
posted
OK, things are more clear now.
I made a new flat file with all days in January and some in February.
The example below is only for generating the concattenated line.

Hope this will meet what you expect.

-Fred

FILEDEF tempfile DISK THEFILE.mas
-RUN

-WRITE tempfile FILENAME=DATASOURCE ,SUFFIX=FIX ,$
-WRITE tempfile SEGMENT=HODATASOURCELD ,SEGTYPE=S1 ,$
-WRITE tempfile FIELDNAME=FAC_FECHA ,ALIAS=FAC_FECHA ,USAGE=DMYY ,ACTUAL=A8 ,$
-WRITE tempfile FIELDNAME=ENTREGA ,ALIAS=ENTREGA ,USAGE=P8 ,ACTUAL=A3 ,$
-WRITE tempfile FIELDNAME=DEVOLUCION ,ALIAS=DEVOLUCION ,USAGE=P8 ,ACTUAL=A3 ,$
-CLOSE tempfile


FILEDEF thefile DISK thefile.ftm
-RUN

-WRITE thefile 01012011 01 01
-WRITE thefile 02012011 03 02
-WRITE thefile 03012011 05 03
-WRITE thefile 04012011 07 04
-WRITE thefile 05012011 09 05
-WRITE thefile 06012011 11 06
-WRITE thefile 07012011 13 07
-WRITE thefile 08012011 15 08
-WRITE thefile 09012011 17 09
-WRITE thefile 10012011 19 10
-WRITE thefile 11012011 21 11
-WRITE thefile 12012011 23 12
-WRITE thefile 13012011 25 13
-WRITE thefile 14012011 27 14
-WRITE thefile 15012011 29 15
-WRITE thefile 16012011 31 16
-WRITE thefile 17012011 33 17
-WRITE thefile 18012011 35 18
-WRITE thefile 19012011 37 19
-WRITE thefile 20012011 39 20
-WRITE thefile 21012011 41 21
-WRITE thefile 22012011 43 22
-WRITE thefile 23012011 45 23
-WRITE thefile 24012011 47 24
-WRITE thefile 25012011 49 25
-WRITE thefile 26012011 51 26
-WRITE thefile 27012011 53 27
-WRITE thefile 28012011 55 28
-WRITE thefile 29012011 57 29
-WRITE thefile 30012011 59 30
-WRITE thefile 31012011 61 31
-WRITE thefile 01022011 63 32
-WRITE thefile 02022011 65 33
-WRITE thefile 03022011 67 34
-WRITE thefile 04022011 69 35
-WRITE thefile 05022011 71 36
-WRITE thefile 06022011 73 37
-WRITE thefile 07022011 75 38
-WRITE thefile 08022011 77 39
-WRITE thefile 09022011 79 40
-WRITE thefile 10022011 81 41
-WRITE thefile 11022011 83 42
-WRITE thefile 12022011 85 43
-WRITE thefile 13022011 87 44
-WRITE thefile 14022011 89 45
-WRITE thefile 15022011 91 46
-WRITE thefile 16022011 93 47
-WRITE thefile 17022011 95 48
-WRITE thefile 18022011 97 49
-WRITE thefile 19022011 99 50


DEFINE FILE thefile
  YR_MONTH/YYM        = FAC_FECHA;
  X1_FAC_FECHA/A8DMYY = FAC_FECHA;
  X2_FAC_FECHA/A8     = X1_FAC_FECHA;
  X3_DAY/A2           = EDIT(X2_FAC_FECHA, '99');
  DIFF/P8             = ENTREGA - DEVOLUCION;

  X1_ENTREGA/A8       = FPRINT(ENTREGA ,'P8' ,'A8');
  X1_DEVOLUCION/A8    = FPRINT(DEVOLUCION ,'P8' ,'A8');
  X1_DIFF/A8          = FPRINT(DIFF ,'P8' ,'A8');

  LINE0/A32           = X3_DAY || ':' || X1_ENTREGA || '-' | X1_DEVOLUCION | '=' | X1_DIFF;
  LINE1/A32           = SQUEEZ(32, LINE0, LINE1);
  LINE2/A32           = STRREP(32, LINE1, 2, '- ' , 1 , '-' ,99 ,LINE2);
  LINE3/A32           = STRREP(32, LINE2, 2, '= ' , 1 , '=' ,99 ,LINE3);
END

TABLE FILE thefile
  PRINT
    COMPUTE COUNTER/I2     = IF YR_MONTH EQ LAST YR_MONTH THEN LAST COUNTER + 1 ELSE 1; NOPRINT
    COMPUTE THELINE/A1000V = IF COUNTER EQ 1 THEN LINE3 ELSE LAST THELINE || (', ' | LINE3);
  BY YR_MONTH NOPRINT
  BY HIGHEST 1 TOTAL COUNTER NOPRINT
END
-RUN


PS: GamP, the code tags work like charm, thanks

This message has been edited. Last edited by: <FreSte>,
 
Report This Post
Member
posted Hide Post
perfect!, exactly this is how I get the line, I thank you, was great help!
I am grateful to you.
Greetings from Mexico!


WebFocus 7.6.10, windows 7, win server 2003-2008 PDF, TXT, XML, html, xls, doc
 
Posts: 22 | Registered: January 06, 2011Report 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] Repeat a part of code in a fex

Copyright © 1996-2020 Information Builders