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.
TABLE FILE XXX PRINT A B COMPUTE C/D18.2C = A - B ; ON TABLE SET PAGE NOLEAD ON TABLE NOTOTAL ON TABLE HOLD AS HOLDTBL4 FORMAT FOCUS END -RUN
DEFINE FILE HOLDTBL4 C_DISP/D18.2C = C ; END
SQL SQLMSS INSERT INTO XXX (KEY1 ,KEY2 ,AMOUNT) VALUES (1,114,C_DISP) END
But WF thinks C_DISP is a column name and gives me an error. If I put quotes around C_DISP then WF thinks it's a literal and can't insert into a numeric field.
The 2 pieces of this puzzle I worked on (seperately) pretty extensively last week. There may be more than one way to skin this cat, but here's my 2¢...
TABLE FILE XXX
PRINT
A
B
COMPUTE C/D18.2C = A - B ;
ON TABLE SET PAGE NOLEAD
ON TABLE NOTOTAL
-*ON TABLE HOLD AS HOLDTBL4 FORMAT FOCUS
ON TABLE HOLD AS HOLDTBL4 FORMAT ALPHA
END
-RUN
-READ HOLDTBL4 &C.D18.2C.
-RUN
-* Make it visible to Dialog Manager
-SET C_DISP = C;
SET EMGSRV=OFF
SET SQLENGINE = SQLMSS
SQL SET SERVER Your_data_connection_name
-RUN
SQL
INSERT INTO XXX
(KEY1
,KEY2
,AMOUNT)
VALUES (1,114,&C_DISP)
;
END
Maybe the Decimal data type (with it's decimal) is throwing things off. Can you make an edit so that its an alpha field just for error checking purposes? Also, I spotted a typo in the next section, it should read: -SET &C_DISP = &C;
Suggest:
DEFINE FILE XXX
COMPUTE C_1/D18.2C = A - B ;
C/A10 = EDIT(C_1);
END
TABLE FILE XXX
PRINT
A
B
-* COMPUTE C/D18.2C = A - B ;
C
ON TABLE SET PAGE NOLEAD
ON TABLE NOTOTAL
-*ON TABLE HOLD AS HOLDTBL4 FORMAT FOCUS
ON TABLE HOLD AS HOLDTBL4 FORMAT ALPHA
END
-RUN
-READ HOLDTBL4 &C.A10.
-RUN
-* Make it visible to Dialog Manager
-SET &C_DISP = &C;
SET EMGSRV=OFF
SET SQLENGINE = SQLMSS
SQL SET SERVER Your_data_connection_name
-RUN
SQL
SELECT '&C_DISP' AS 'My Output'
-- INSERT INTO XXX
-- (KEY1
-- ,KEY2
-- ,AMOUNT)
-- VALUES (1,114,&C_DISP)
;
END
The edit may need some work, but I think you get the idea. Note the 'Select' statement will just dump the variable value to the screen, better for error checking than running it through the INSERT routine.
It appears that the format in the read (D18.2C) is causing the problem. But, I have to insert this as a numeric in the database, so converting to alpha does me no good.
Here's a CAR example. Note, I have used Alpha examples as sanity checks. You can use these as a jumping off point. I didn't say it was pretty...
DEFINE FILE CAR
MARKUP/D8.2C = RETAIL_COST - DEALER_COST;
END
TABLE FILE CAR
PRINT
DEALER_COST
RETAIL_COST
MARKUP
WHERE RECORDLIMIT EQ 1;
ON TABLE HOLD AS MY_PROFIT_MARGIN_1 FORMAT ALPHA
END
-RUN
-* The HOLD file is Format Alpha, which is all the fields strung
-* together. You have to edit out the piece you want. In this
-* case the 2 'COST' fields are D7.
DEFINE FILE MY_PROFIT_MARGIN_1
MARKUP/A6 = EDIT(MARKUP_TEMP,'$$$$$$$$$$$$$$999999999999');
END
TABLE FILE MY_PROFIT_MARGIN_1
PRINT
MARKUP
ON TABLE HOLD AS MY_PROFIT_MARGIN FORMAT ALPHA
END
-RUN
-READ MY_PROFIT_MARGIN &MARKUP.A6.
-RUN
-SET &DM_MARKUP = &MARKUP;
-TYPE &DM_MARKUP
-* Make it visible to Dialog Manager
SET EMGSRV=OFF
SET SQLENGINE = SQLMSS
SQL SET SERVER Some_SQL_Server_Data_Connection
-RUN
SQL
SELECT '&DM_MARKUP' AS 'My Output'
;
END
Does the CAR example work? I found out in my case that since I had a variable length field, it 'helped me out' by prepending a numeric onto the data that said how long that variable length field was. It wasn't until I did a ?FF or a PRINT * on the hold file that I saw what was happening. Maybe this is your issue?
Unless you set DMPRECISION, Dialogue Manager will default to storing numeric data as integers without decimals. The code below should work, but you will only get the first MARKUP value from the CAR file inserted into your table, because there is only one read of the save file. If you want to process all of the markup values placed in the save file, then you must introduce a repeat loop to do so. The second code example shows how that might work.
SET DMPRECISION = 2
SET HOLDLIST = PRINTONLY
TABLE FILE CAR
PRINT
COMPUTE MARKUP/D18.2C = RETAIL_COST - DEALER_COST ;
ON TABLE SAVE AS SAVEFILE
END
-RUN
-READ SAVEFILE &C_DISP.18
-*TYPE &C_DISP
SET SQLENGINE = SQLMSS
SQL SET SERVER <your_data_connection_name>
SQL
INSERT INTO XXX
(KEY1
,KEY2
,AMOUNT)
VALUES (1,114,&C_DISP);
END
With repeat loop to process all data in the save file:
SET DMPRECISION = 2
SET HOLDLIST = PRINTONLY
TABLE FILE CAR
PRINT
COMPUTE MARKUP/D18.2C = RETAIL_COST - DEALER_COST ;
ON TABLE SAVE AS SAVEFILE
END
-RUN
-SET &RECCOUNT = &LINES ;
SET SQLENGINE = SQLMSS
SQL SET SERVER <your_data_connection_name>
-RUN
-REPEAT :ENDREPEAT1 &RECCOUNT TIMES
-READ SAVEFILE NOCLOSE &C_DISP.18
-*TYPE &C_DISP
SQL
INSERT INTO XXX
(KEY1
,KEY2
,AMOUNT)
VALUES (1,114,&C_DISP);
END
-RUN
-:ENDREPEAT1
WebFOCUS 7.7.05
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007
Dan, Thanks for bringing that up, my piece was in the middle of a loop too (setting environmental variables for all items in a table). I did fail to mention this.