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     [CLOSED ]Increment Alpha Value

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[CLOSED ]Increment Alpha Value
 Login/Join
 
Virtuoso
posted
I have a manufacturing scenario where I have an alpha serial number and a part count. The serial number indicates the starting serial number, and the part count indicates the number of parts produced starting from that known serial. The intention is to create a single record for each serial number so that they can be flagged when defective for future clustering and yield analysis. I can use the MacGyver technique to generate a line per unique part produced, however, what I really need is an easy way to increment the serial numbers for each part.

There are 2 types of serial numbers:

AANANAN - e.g. MN7A9B6 an increment would be then MN7A9B7, and an increment for MN7A9B9 would be MN7A9C0
ANNNNNNNN - e.g. A00012340 an increment would be A00012341

Any thoughts on an easy way to do this?

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


"There is no limit to what you can achieve ... if you don’t care who gets the credit." Roger Abbott
 
Posts: 1102 | Location: Toronto, Ontario | Registered: May 26, 2004Report This Post
Virtuoso
posted Hide Post
Wow ... crickets!

Screw this ... I'm writing a Fuse routine.


"There is no limit to what you can achieve ... if you don’t care who gets the credit." Roger Abbott
 
Posts: 1102 | Location: Toronto, Ontario | Registered: May 26, 2004Report This Post
Expert
posted Hide Post
Darryl,

Perhaps a DEFINE function would do the job, it might take me as long as it would take you to write it!

But I can try, if you like.


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
Expert
posted Hide Post
What would the increment for MZZZZZZ be?


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
Expert
posted Hide Post
Is the alphanumeric sequence 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ?


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
Don't bother. I couldn't imagine doing a define function that didn't contain a mountain of code ... hence the posting. I just finished testing the FUSE routine on my local system. I'm happy with the results, and it took < 1 hour to do, so that was a lot less time than I initially expected. All I need to do now is compile and deploy on the customer site.

Thanks anyway.


"There is no limit to what you can achieve ... if you don’t care who gets the credit." Roger Abbott
 
Posts: 1102 | Location: Toronto, Ontario | Registered: May 26, 2004Report This Post
Expert
posted Hide Post
quote:
Wow ... crickets!

What's a "FUSE routine"? Written in C and compiled?


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
Expert
posted Hide Post
This just does my head in.



Can you post the source code, just in case someone needs to do something similar ?

I'm also interested in how you did it.


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
Virtuoso
posted Hide Post
Yes. Stands for Focus User Written Subroutine. Write it in C, then compile it to a .dll, then copy it to the server /user directory and then you can use it like any subroutine.

 COMPUTE NEW_SERIAL/A10 = GETNEXTSNBR(SERIALNBR,'A10');  


Keeps the WF coding down to a minimum.


"There is no limit to what you can achieve ... if you don’t care who gets the credit." Roger Abbott
 
Posts: 1102 | Location: Toronto, Ontario | Registered: May 26, 2004Report This Post
Virtuoso
posted Hide Post
quote:
Can you post the source code, just in case someone needs to do something similar ?

I'm also interested in how you did it.


Here you go:

/*
 * GETNEXTSNBR.C - Fuse routine to increment Polycon serial numbers by 1.  Serial numbers can be of
 *    multiple formats, and are always a combination of letters and numbers.
 *
 *    Known formats are:  AA9A9A9 - e.g. MN1A8C9
 *                        A99999999 - e.g. A00213456
 *
 *  Created on: 2011-11-08
 *      Author: d hagen
 */

#include <string.h>

static const char CURR_CHAR[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
static const char NEXT_CHAR[] = "1234567890BCDEFGHIJKLMNOPQRSTUVWXYZA";
static const int CHAR_COUNT = 36;

/**
 * Check if character to be processed is actually a valid character.
 * 1 = Valid, 0 = Invalid
 */
int isValid ( char _in )
{
	int i, irtn = 0;
	for ( i = 0; i < CHAR_COUNT; i++ ) {
		if (_in == CURR_CHAR[i]) {
			irtn = 1;
			break;
		}
	}
	return irtn;
}

/**
 * Change the passed character.
 * The new value will be the same index position in the NEXT_CHAR array.
 */
char changeValue ( char _in )
{
	int i;
	char rtn = _in;
	for ( i = 0; i < CHAR_COUNT; i++ ) {
		if (_in == CURR_CHAR[i]) {
			rtn = NEXT_CHAR[i];
			break;
		}
	}
	return rtn;
}

/**
 * Function to increment the serial number one digit at a time.
 */
void getnextsnbr ( char *, char * );
void getnextsnbr ( char *inChar, char *outChar )
{
	int i, rollover = 1;
	unsigned char p[ strlen(inChar) ];

	/* copy the inbound */
	for( i = 0; i < strlen(inChar); i++ ){
		p[i] = inChar[i];
	}

	/* Loop in reverse to increment a value.  If the resulting value is either 0 or A, then
	 * tag the loop as a roll over and allowing the digit to the left to be incremented as well */
	for ( i = strlen(inChar)-1; i >= 0; i-- ) {
		if ( isValid( p[i] ) && rollover ) {
			p[i] = changeValue( p[i] );
			if ( p[i] == 'A' || p[i] == '0' )
				rollover = 1;
			else
				rollover = 0;
		}
	}

	/* Write the value to the output for WF or iDM to use */
	for( i = 0; i < strlen(p); i++ ){
		outChar[i] = p[i];
	}
}
  


"There is no limit to what you can achieve ... if you don’t care who gets the credit." Roger Abbott
 
Posts: 1102 | Location: Toronto, Ontario | Registered: May 26, 2004Report This Post
Expert
posted Hide Post
It seems so easy when you put it like that. Big Grin

I think User Written Subroutines are the forgotten fourth dimention of WebFOCUS.





FYI

At the end of the Functions manual, there is a section for creating your own functions.

They can be created from many different languages, as long as some rules are followed.

Creating a function


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
Virtuoso
posted Hide Post
quote:
I couldn't imagine doing a define function that didn't contain a mountain of code


You were sooo right about that. I had to use some Dialogue Manager to help with the dirty and repetitive work and came up with a function that attempts to do that serial # increment you needed.

I'm sure your C-based solution is much more efficient than the WebFOCUS-based one below but the challenge was too tempting to resist Smiler

-*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-* Set &CHARSYS to 'ASCII' or 'EBCDIC' as needed
-* EBCDIC support has not been tested !!!

-SET &CHARSYS = 'ASCII';

-SET &CHR_0 = IF &CHARSYS EQ 'ASCII' THEN 48 ELSE 240;
-SET &CHR_9 = IF &CHARSYS EQ 'ASCII' THEN 57 ELSE 249;
-SET &CHR_A = IF &CHARSYS EQ 'ASCII' THEN 65 ELSE 193;
-SET &CHR_Z = IF &CHARSYS EQ 'ASCII' THEN 90 ELSE 233;

-*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DEFINE FUNCTION SERINCR (SERIALNO/A20)
SERLEN/I4  = ARGLEN(20, SERIALNO, SERLEN);
RESULT/A20 = REVERSE(SERLEN, SERIALNO, RESULT);
INCRNX/A1  = 'Y';

-REPEAT :INCRSER FOR &I FROM 1 TO 20;
SERCHR/A1 = SUBSTR(20, RESULT, &I, &I, 1, SERCHR);
SERDEC/I3 = BYTVAL(SERCHR, SERDEC);
SERNXDEC/I3 = IF INCRNX NE 'Y' THEN SERDEC ELSE
              IF NOT (SERDEC FROM &CHR_0 TO &CHR_9 OR SERDEC FROM &CHR_A TO &CHR_Z) THEN SERDEC ELSE
              IF SERDEC EQ &CHR_9 THEN &CHR_0 ELSE 
              IF SERDEC EQ &CHR_Z THEN &CHR_A ELSE (SERDEC + 1);
SERNXCHR/A1 = CTRAN(1, SERCHR, SERDEC, SERNXDEC, SERNXCHR);
RESULT/A20  = OVRLAY(RESULT, 20, SERNXCHR, 1, &I, RESULT);
INCRNX/A1   = IF INCRNX EQ 'Y' AND (SERDEC EQ &CHR_9 OR &CHR_Z) THEN 'Y' ELSE 'N';
-:INCRSER

SERINCR/A20 = REVERSE(SERLEN, RESULT, SERINCR);
END

-*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TABLE FILE CAR
PRINT CAR
COMPUTE SERIAL/A20 = IF EDIT(CAR, '9') EQ 'J' THEN 'MN1A8C9'   ELSE
                     IF EDIT(CAR, '9') EQ 'A' THEN 'A00213456' ELSE 
                     IF EDIT(CAR, '9') EQ 'P' THEN 'MZZZZZZ'   ELSE
                     IF EDIT(CAR, '9') EQ 'T' THEN 'MN7A9B6'   ELSE
                     IF EDIT(CAR, '9') EQ 'D' THEN 'A00012340' ELSE 'A99999999';
COMPUTE NEXTSERIAL/A20 = SERINCR (SERIAL);
END



I cheated a bit as your C routine gave me a few ideas and this post from Francis gave me the expression I needed to make character conversions.

This was not fully tested (particularly EBCDIC support) but as I said, was just an interesting exercise.

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



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
 
Posts: 1533 | Registered: August 12, 2005Report This Post
Expert
posted Hide Post
Itas good to know that there are still adventurous people out there, trying things out just because its there.

Go njsden !


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
Virtuoso
posted Hide Post
Thanks Warren! (I hope the whip is not directed to ME Wink )



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
 
Posts: 1533 | Registered: August 12, 2005Report This Post
Expert
posted Hide Post
quote:
I hope the whip is not directed to ME


No, I was comparing you to Indiana Jones. Big Grin


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
Expert
posted Hide Post
Mr. dhagen, the crickets woke up!


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:
Indiana Jones

I shall get a nice hat then Wink



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
 
Posts: 1533 | Registered: August 12, 2005Report This Post
Virtuoso
posted Hide Post
This version looks closer to your C function and does not have to deal with ASCII/ECBDIC codes.

-*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DEFINE FUNCTION SERINCR (SERIALNO/A20)
CNCHAR/A36 = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
NXCHAR/A36 = '1234567890BCDEFGHIJKLMNOPQRSTUVWXYZA';
CHARCNT/I3 = 36;

SERLEN/I4  = ARGLEN(20, SERIALNO, SERLEN);
RESULT/A20 = REVERSE(SERLEN, SERIALNO, RESULT);
INCRNX/A1  = 'Y';

-REPEAT :INCRSER FOR &I FROM 1 TO 20
SERCNCHR/A1 = SUBSTR(20, RESULT, &I, &I, 1, SERCNCHR);
SERCHPOS/I3 = POSIT(CNCHAR, CHARCNT, SERCNCHR, 1, SERCHPOS);
SERNXCHR/A1 = IF INCRNX NE 'Y' OR SERCHPOS EQ 0 THEN SERCNCHR
              ELSE SUBSTR(CHARCNT, NXCHAR, SERCHPOS, SERCHPOS, 1, SERNXCHR);
RESULT/A20  = OVRLAY(RESULT, 20, SERNXCHR, 1, &I, RESULT);
INCRNX/A1   = IF INCRNX EQ 'Y' AND (SERCNCHR EQ '9' OR 'Z') THEN 'Y' ELSE 'N';
-:INCRSER

SERINCR/A20 = REVERSE(SERLEN, RESULT, SERINCR);
END

-*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
TABLE FILE CAR
PRINT CAR
COMPUTE SERIAL/A20 = IF EDIT(CAR, '9') EQ 'J' THEN 'MN1A8C9'   ELSE
                     IF EDIT(CAR, '9') EQ 'A' THEN 'A0023456'  ELSE 
                     IF EDIT(CAR, '9') EQ 'P' THEN 'MZZZZZZ'   ELSE
                     IF EDIT(CAR, '9') EQ 'T' THEN 'MN7A9B6'   ELSE
                     IF EDIT(CAR, '9') EQ 'D' THEN 'A00012340' ELSE 'A99999999';
COMPUTE NEXTSERIAL/A20 = SERINCR (SERIAL);
END



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
 
Posts: 1533 | Registered: August 12, 2005Report This Post
Expert
posted Hide Post
Less lines of code than that C program...


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:
Originally posted by Francis Mariani:
Mr. dhagen, the crickets woke up!


They certainly did.

Did anyone get any sleep?


"There is no limit to what you can achieve ... if you don’t care who gets the credit." Roger Abbott
 
Posts: 1102 | Location: Toronto, Ontario | Registered: May 26, 2004Report This Post
Expert
posted Hide Post
I did not!


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:
Less lines of code than that C program...


But sadly, not as nicely documented Red Face



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
 
Posts: 1533 | Registered: August 12, 2005Report This Post
Virtuoso
posted Hide Post
quote:
But sadly, not as nicely documented Red Face


And it doesn't have all that fancy indentation stuff that creates the illusion that you know what you are doing!


"There is no limit to what you can achieve ... if you don’t care who gets the credit." Roger Abbott
 
Posts: 1102 | Location: Toronto, Ontario | Registered: May 26, 2004Report This Post
Virtuoso
posted Hide Post
So true Frowner



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
 
Posts: 1533 | Registered: August 12, 2005Report 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     [CLOSED ]Increment Alpha Value

Copyright © 1996-2020 Information Builders