cancel
Showing results for 
Search instead for 
Did you mean: 

auto increment in BP code

Former Member
0 Kudos

Hello,

The requirement is ,

when I add New business partner master data, Business partner code should come automatically, suppose the last customer code was C0024, and if now i add new customer C0025 should come automatically,

How I can achieve this? can I do this with FMS?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Try:

If $[OCRD.CardType] in ('C' ,'L')

Select'C'+right(str(isnull(max(substring(T0.CardCode,2,5))+100001),5),'00001')

From OCRD T0

WHERE T0.CardCode LIKE 'C[0-9][0-9][0-9][0-9][0-9]'

else if $[OCRD.CardType] = 'S'

Select'V'+right(str(isnull(max(substring(T0.CardCode,2,5))+100001),5),'00001')

From OCRD T0

WHERE T0.CardCode LIKE 'V[0-9][0-9][0-9][0-9][0-9]'

Thanks,

Gordon

Answers (5)

Answers (5)

0 Kudos

Hey Punam,

Are you running 8.82? If you are you can set a BP Series that will auto increment from the document series window.

Best regards,

Former Member
0 Kudos

My last customer is with BP Code C04863 and last vendor is with bp code V00710.

When I will create new customer it should auto generate customer code C04864 and when i will create new vendor it should auto generate code V00711 and so on , for every new customer and vendor there should be auto increment of Business partner code

KennedyT21
Active Contributor
0 Kudos

Try This

declare @n nvarchar(15)

set @n=$[OCRD.CardCode]

If $[OCRD.CardType] in ('C' ,'L')

Select'C'+isnull(right(str(max(substring(c.CardCode,2,5))+1000000001),5),'00001')

  From OCRD c

  Where c.CardCode like 'C[0-9][0-9][0-9][0-9][0-9]'

else if

Select'V'+isnull(right(str(max(substring(c.CardCode,2,5))+1000000001),5),'00001')

  From OCRD c

  Where c.CardCode like 'V[0-9][0-9][0-9][0-9][0-9]'

else

select @n

Regards

Kennedy

Former Member
0 Kudos

Hi Punam.........

Try this.......

declare @temp as char(15)

IF ($[OCRD.CardType]) = 'C' 

    BEGIN

        set @temp=(select max(right(cardcode,5)) + 1 from ocrd where (cardtype='C') and (len(cardcode)=6) and (left(cardcode,1)='C'))

        set @temp='C'+isnull(replicate(0,5-len(@temp)),'')+@temp

        select isnull(cast(@temp as char(15)),'C04864')

       

    END

IF ($[OCRD.CardType]) = 'S' 

    BEGIN

        set @temp=(select max(right(cardcode,5)) + 1 from ocrd where (cardtype='C') and (len(cardcode)=6) and (left(cardcode,1)='V'))

        set @temp='V'+isnull(replicate(0,5-len(@temp)),'')+@temp

        select isnull(cast(@temp as char(15)),'V00711')

Regards,

Rahul

KennedyT21
Active Contributor
0 Kudos

Try this for Customer Vendor and lead.

declare @n nvarchar(15)

set @n=$[OCRD.CardCode]

If $[OCRD.CardType] in ('C' ,'L')

Select'C'+isnull(right(str(max(substring(c.CardCode,2,5))+1000000001),4),'0001')

  From OCRD c

  Where c.CardCode like 'C[0-9][0-9][0-9][0-9]'

else if

Select'V'+isnull(right(str(max(substring(c.CardCode,2,5))+1000000001),4),'0001')

  From OCRD c

  Where c.CardCode like 'V[0-9][0-9][0-9][0-9]'

else

select @n

Regards

Kennedy

Former Member
0 Kudos

Hi Punam..........

Please check this thread..

http://scn.sap.com/thread/1508623

Regards,

Rahul

KennedyT21
Active Contributor
0 Kudos

HI Puman Gandhi,

Try this in Fms

You can use this, setting auto refresh when BP name changes:

declare @n nvarchar(15)

set @n=$[OCRD.CardCode]

If $[OCRD.CardType]='C'

Select'C'+isnull(right(str(max(substring(c.CardCode,2,5))+1000000001),4),'0001')

  From OCRD c

  Where c.CardCode like 'C[0-9][0-9][0-9][0-9]'

else select @n

Regards

Kennedy