Focal Point
Appending to an Alpha field over multiple records

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

April 20, 2006, 06:47 AM
mark66
Appending to an Alpha field over multiple records
Hi,

I need to read through some records which have been previously selected and reside in a hold file TEST. Where the DATE_TIME field is the same I need to append the field NOTES together to create a new field ALL_NOTES. I will then be able to select the last record created and use this in my report and it should contain the whole note.

Example of my file TEST:
REC_NUMBER(P10)
DATE_TIME(A12)
NOTES(A30)

REC_NUMBER DATE_TIME NOTES
1 01MAR061000 The Customer has requested tha
2 01MAR061000 t the goods be dispatched Tuesday.

So I need to concat the notes fields together so I can eventually report them on one line: "The Customer has requested that the goods be dispatched Tuesday"

I looked through the online help and found an example using LAST and have coded it as follows

TABLE FILE TEST
PRINT
REC_NUMBER
DATE_TIME
COMPUTE ALL_NOTES/A800 = IF DATE_TIME EQ LAST DATE_TIME THEN
(ALL_NOTES || NOTES) ELSE NOTES; AS 'All Notes'

END

However this gives me the error:

RESULT OF EXPRESSION IS NOT COMPATIBLE WITH THE FORMAT OF FIELD: ALL_NOTES

So it does not like me trying to concat the NOTES field to ALL_NOTES. If I change the expression to compute a Total REC_NUMBER using numerics and adding the REC_NUMBER together it works just fine.

Hope this is all clear and someone can help.

Many thanks

Mark.


WebFocus 765. iSeries v5r4
April 20, 2006, 08:05 AM
Pete
Hi Mark,

I think the problem lies in the fact A800 is not accepted , i'm not sure but i think it goes up to A256 , try using A800V -> goes up until A4096V

Hope it helps

P.

quote:
TABLE FILE TEST
PRINT
REC_NUMBER
DATE_TIME
COMPUTE ALL_NOTES/A800V = IF DATE_TIME EQ LAST DATE_TIME THEN
(ALL_NOTES || NOTES) ELSE NOTES; AS 'All Notes'

END



D: WF 7.6.2 P. : WF 7.6.2 on W2003
------------------------------------------------------------------
I see myself as an intelligent, sensitive human, with the soul of a clown which forces me to blow it at the most important moments.

-Jim Morrison-

April 20, 2006, 08:12 AM
Tony A
Hi Mark,

The reason you are getting the error is that you are trying to concatenate strings of length 800 plus the length of the field NOTES into a declared string of length 800. You will have to derive a method of reducing the ALL_NOTES field before appending it.

Try using something like SUBSTR combined with ARGLEN -

TABLE FILE GGSALES
SUM COMPUTE ST_STRING/A800 = IF ST NE LAST ST 
THEN SUBSTR(800, LAST ST_STRING, 1, ARGLEN(800, ST_STRING, 'I4'), 
ARGLEN(800, ST_STRING, 'I4'), 'A600') || ST ELSE LAST ST_STRING;
BY ST
END


Note that I have split the code line to fit on the screen, so you will have to adjust it.
Also note that the final argument for SUBSTR is less than the A800 of the parent string, this is to prevent the FOC282 error.

Alternatively, use the A800V format as suggested by Pete.

T

This message has been edited. Last edited by: Tony A,



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
April 20, 2006, 08:55 AM
mark66
Brilliant, thanks guys. Pete's suggestions of using 800V worked straight awat.

By the way, what type is 'V' ? Sorry I am very new to WebFocus!


WebFocus 765. iSeries v5r4
April 20, 2006, 09:02 AM
Pete
Mark,

I think its refers to varchar types

P.


D: WF 7.6.2 P. : WF 7.6.2 on W2003
------------------------------------------------------------------
I see myself as an intelligent, sensitive human, with the soul of a clown which forces me to blow it at the most important moments.

-Jim Morrison-

April 20, 2006, 06:29 PM
Francis Mariani
Forgot about the varchar data-type.

This old-fashioned way, using SUBSTR works as well:

TABLE FILE CAR
SUM CAR
BY COUNTRY
BY CAR NOPRINT
ON TABLE HOLD
END

TABLE FILE HOLD
PRINT
COMPUTE CARS/A1000 = IF COUNTRY EQ LAST COUNTRY THEN SUBSTR(1000, CARS, 1, 900, 900, 'A900') || (' / ' | CAR) ELSE CAR;
BY COUNTRY
ON TABLE SET PAGE NOLEAD
ON TABLE SET STYLESHEET *
TYPE=REPORT, GRID=OFF,
FONT='ARIAL', SIZE=8, $
ENDSTYLE
END


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