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] (FOC36355) INVALID TYPE OF ARGUMENT #2 FOR USER FUNCTION TRIMV

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] (FOC36355) INVALID TYPE OF ARGUMENT #2 FOR USER FUNCTION TRIMV
 Login/Join
 
Guru
posted
Hi all,

When running the procedure below and setting &FIELDNAME to UNITS (or any other non-alpha format field from GGSALES) it works just fine.

When setting &FIELDNAME to PRODUCT (or any alpha format field from GGSALES) I get an error
(FOC36355) INVALID TYPE OF ARGUMENT #2 FOR USER FUNCTION TRIMV

My assumption here is that when FLDINIT does equal 'A' that the statement would skip the 'THEN' portion and go straight to the 'ELSE' portion. Apparently that is not happening and it is trying to use the alpha field in the EDIT function which is where the error is created.

How can I get around this? Confused

-SET &ECHO = ALL;

-DEFAULT &DATASOURCE=GGSALES;
-DEFAULT &FIELDNAME=UNITS;
-DEFAULT &BLOCKSIZE=100;
-DEFAULT &BLOCK=0;


TABLE FILE &DATASOURCE
  WRITE
    COMPUTE ROWNUM/I7 = LAST ROWNUM-(-1);
    COMPUTE BLOCK /I5 = 1-(-(INT((ROWNUM-1)/&BLOCKSIZE)));
  BY &FIELDNAME
ON TABLE HOLD AS FOCCACHE/HOLDKEYS
END
-RUN

CHECK FILE &DATASOURCE HOLD AS DS_HLD
TABLE FILE DS_HLD
SUM FST.FORMAT
WHERE FIELDNAME EQ '&FIELDNAME';
ON TABLE SAVE
END
-RUN

-READ SAVE &FLDTYPE.A8.


DEFINE FILE FOCCACHE/HOLDKEYS
FLDINIT/A1 = SUBSTR(8, '&FLDTYPE', 1, 1, 1, 'A1');

-*  The next line is where I get tripped up.  If &FIELDNAME is a non-alpha it works, if &FIELDNAME is alpha it breaks
FLDNAM/A99V = IF (FLDINIT NE 'A') THEN (TRIMV('L', EDIT(&FIELDNAME), 99, '0', 98, 'A99V')) ELSE ('&FIELDNAME');
-*  *****************************************************************************************************************

END

TABLEF FILE FOCCACHE/HOLDKEYS
 WRITE
 FST.ROWNUM AS LOROW
 LST.ROWNUM AS HIROW
 FST.&FIELDNAME   AS LOKEY
 LST.&FIELDNAME   AS HIKEY
 FST.FLDNAM
 LST.FLDNAM
 FLDINIT
COMPUTE RANGE/A99V =
   IF (LST.ROWNUM GT FST.ROWNUM)
   THEN FST.FLDNAM || ' ~ ' | LST.FLDNAM
   		ELSE FST.FLDNAM;
 BY BLOCK
ON TABLE SET HOLDLIST PRINTONLY AND ASNAMES ON
ON TABLE PCHOLD FORMAT HTML
END


Thanks!

Dan

This message has been edited. Last edited by: Dan Pinault,


7.7.05M/7.7.03 HF6 on Windows Server 2003 SP2 output to whatever is required.
 
Posts: 393 | Location: St. Paul, MN | Registered: November 06, 2007Report This Post
Expert
posted Hide Post
Dan, the problem is caused by the EDIT(XXX) code - if the field is an alpha field, the EDIT tries to convert it to integer, but because the value (e.g. Atlanta) is not convertible to integer you get an error. The solution is to prepare for the TRIMV function in Dialogue Manager.

-SET &ECHO = ALL;

-DEFAULT &DATASOURCE=GGSALES;
-DEFAULT &FIELDNAME=CITY;
-DEFAULT &BLOCKSIZE=100;
-DEFAULT &BLOCK=0;

TABLE FILE &DATASOURCE
  WRITE
    COMPUTE ROWNUM/I7 = LAST ROWNUM-(-1);
    COMPUTE BLOCK /I5 = 1-(-(INT((ROWNUM-1)/&BLOCKSIZE)));
  BY &FIELDNAME
ON TABLE HOLD AS FOCCACHE/HOLDKEYS
END
-RUN

CHECK FILE &DATASOURCE HOLD AS DS_HLD
TABLE FILE DS_HLD
SUM FST.FORMAT
WHERE FIELDNAME EQ '&FIELDNAME';
ON TABLE SAVE
END
-RUN

-READ SAVE &FLDTYPE.A8.

-SET &FLDINIT = EDIT(&FLDTYPE,'9$');

-SET &XFIELD = IF (&FLDINIT NE 'A') THEN 'EDIT(&FIELDNAME.EVAL)' ELSE '&FIELDNAME.EVAL';

DEFINE FILE FOCCACHE/HOLDKEYS
FLDINIT/A1 = SUBSTR(8, '&FLDTYPE', 1, 1, 1, 'A1');
FLDNAM/A99V = (TRIMV('L', &XFIELD, 99, '0', 98, 'A99V'));
END

TABLEF FILE FOCCACHE/HOLDKEYS
 WRITE
 FST.ROWNUM AS LOROW
 LST.ROWNUM AS HIROW
 FST.&FIELDNAME   AS LOKEY
 LST.&FIELDNAME   AS HIKEY
FST.FLDNAM
LST.FLDNAM
 FLDINIT
COMPUTE RANGE/A99V =
  IF (LST.ROWNUM GT FST.ROWNUM)
  THEN FST.FLDNAM || ' ~ ' | LST.FLDNAM
  ELSE FST.FLDNAM;
BY BLOCK
ON TABLE SET HOLDLIST PRINTONLY AND ASNAMES ON
ON TABLE PCHOLD FORMAT HTML
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
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Virtuoso
posted Hide Post
quote:
My assumption here is that when FLDINIT does equal 'A' that the statement would skip the 'THEN' portion and go straight to the 'ELSE' portion. Apparently that is not happening and it is trying to use the alpha field in the EDIT function which is where the error is created.


The problem is that BEFORE ANY evaluation of fields takes place, the &vars are evaluated and then the syntax of the statement is checked before placing it on the FOCSTACK for execution. When &FIELDNAME is alpha, that makes the syntax invalid and throws your error before it even starts reading records to to see what the value of FLDINIT is.

Francis' suggestion is one way around it. His way makes sure that the statement that is sent for execution always contains valid syntax, regardless of what the format of the field value is.


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat
 
Posts: 2298 | Location: Salt Lake City, Utah | Registered: February 02, 2007Report This Post
Guru
posted Hide Post
Francis - Thanks for the solution!

Darin - Thanks for the explanation!

Cheers,

Dan


7.7.05M/7.7.03 HF6 on Windows Server 2003 SP2 output to whatever is required.
 
Posts: 393 | Location: St. Paul, MN | Registered: November 06, 2007Report 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] (FOC36355) INVALID TYPE OF ARGUMENT #2 FOR USER FUNCTION TRIMV

Copyright © 1996-2020 Information Builders