Skip to Content
0
Former Member
Sep 30, 2005 at 10:43 AM

Automatic number generation

48 Views

Hi All,

How can I generate automatic number's in Business patner code? I tried to execute one query for this , but error came while executing this query.Error message is: 'Error (8180) encountered'. Please help me out from this

thanks in advance bbn

Query:

-- This Query generates a Business Partner Code automatically

-- depending on the Card Type i.e. C100001, S1000001, L1000001

-- Prerequisites:

-- 1. The first customer, supplier and lead number has to be entered manually

-- 2. The number must start directly behind the cardtype, no leading zeros (NOT C000100)

-- Edda, March 27, 2003

SELECT $[OCRD.CardType] +

CONVERT(char(7),MAX(CONVERT(int, SUBSTRING(CardCode, 2, 6)))+1)

FROM OCRD

where OCRD.CardType = $[OCRD.CARDTYPE]

FOR BROWSE

SELECT

CASE OCRD.CardType

WHEN 'C' Then MAX(OCRD.CardCode)+1

When 'S' Then MAX(OCRD.CardCode)+1

Else ''

END

FROM OCRD WHERE OCRD.CardCode <> '20001' and OCRD.CardType = $[OCRD.CARDTYPE] Group by OCRD.CardType

FOR BROWSE