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. Moving forward, myibi is our community platform to learn, share, and collaborate. We have the same Focal Point forum categories in myibi, so you can continue to have all new conversations there. If you need access to myibi, contact us at email@example.com and provide your corporate email address, company, and name.
I am doing a query to get data fields to put together as a message table. The data in the table would have message number, line number, and text. I am getting the data out of the table but then want to concatenate the text by message number and line number into 1 field. For example:
message number line number text 1 1 This is the 1 2 first paragraph 1 3 of information. 2 1 This is the 2 2 second paragraph.
What I want in the end is to be able to create a table that has 2 rows: This is the first paragraph of information. This is the second paragraph.
I could have multiple message numbers and multiple line numbers within what I'm getting back from db2. Can anyone help with how I can accomplish this?This message has been edited. Last edited by: <Kathryn Henning>,
I first create a data file to simulate your db2 table. Then I create a Master for the file. The first TABLE FILE.. HOLD ensures that the data rows are in the correct order. The DEFINE FILE concatenates the multiple occurrences, the TABLE FILE... SUM outputs the paragraphs.
FILEDEF MY_DB2_TABLE DISK my_db2_table.txt
-WRITE MY_DB2_TABLE 1 1 This is the
-WRITE MY_DB2_TABLE 1 2 first paragraph
-WRITE MY_DB2_TABLE 1 3 of information.
-WRITE MY_DB2_TABLE 2 1 This is the
-WRITE MY_DB2_TABLE 2 2 second paragraph.
FILEDEF MASTER DISK my_db2_table.mas
-WRITE MASTER FILENAME=MY_DB2_TABLE, SUFFIX=FIX, $
-WRITE MASTER SEGNAME=MY_DB2_TABLE, $
-WRITE MASTER FIELDNAME=MESSAGE_NUMBER, FORMAT=I1 , ACTUAL=A1 , $
-WRITE MASTER FIELDNAME=FILL1 , FORMAT=A1 , ACTUAL=A1 , $
-WRITE MASTER FIELDNAME=LINE_NUMBER , FORMAT=I1 , ACTUAL=A1 , $
-WRITE MASTER FIELDNAME=FILL2 , FORMAT=A1 , ACTUAL=A1 , $
-WRITE MASTER FIELDNAME=MESSAGE_TEXT , FORMAT=A20, ACTUAL=A20, $
TABLE FILE MY_DB2_TABLE
ON TABLE HOLD AS HOLD001
DEFINE FILE HOLD001
MESSAGE_TEXT_OUT/A500V = IF MESSAGE_NUMBER EQ LAST MESSAGE_NUMBER THEN MESSAGE_TEXT_OUT || (' ' | MESSAGE_TEXT) ELSE MESSAGE_TEXT;
TABLE FILE HOLD001
BY MESSAGE_NUMBER NOPRINT
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