Get next BusinessPartners Code/Key

Hi together,
I am looking for a way to get the next CardCode of a BusinessPartner to add a new one by DIApi.
I tried it by using some Code like this, but it does not work fine:
Dim oSeriesService As SAPbobsCOM.BusinessPartnersService = cmpService.GetBusinessService(SAPbobsCOM.ServiceTypes.BusinessPartnersService)
Dim oSeriesCollection As SAPbobsCOM.BusinessPartners = oSeriesService.GetDataInterface(SAPbobsCOM.BusinessPartnersServiceDataInterfaces.bpsdiBPCodes)
The Bold Text is not very fine, because there is no method like 'GetNextCardCode', otherwise its not tested, so i dont think this would work.
Is there a way like the SeriesService... eg. there are no problems to get the next DocNum of an invoice
Thank you!
Sebastian

I don't know if B1 has anything to generate a "next" cardcode value but I doubt it since the field is alphanumeric,
but I've written something to do this for myself.
On the before event when the user clicks on the add mode on the BP form, and if they leave the cardcode blank,
I use a sql statement to determine the next number to assign.  We always prefix our customer numbers with a "C"
and our Suppliers with a "V" so I look for the highest cardcode (max) out there where the first character is a c/v and
the rest of the card code is completely numeric (like 'C1001', but not 'Customer 1' since it contains alpha values). 
I just add one to the 1001 part and return 'C1002'.  If by chance two users end up assigning the same number,
I let B1 catch the duplicate.
Maybe this code will work for you:
Public Enum BP_Type
        Customer = 0
        Vendor = 1
    End Enum
                'in add mode, if user leaves cardcode empty, then assign it the next highest number from table
                If pVal.FormMode = SAPbouiCOM.BoFormMode.fm_ADD_MODE Then
                    If Not IsNothing(cmbx) AndAlso Not IsNothing(cmbx.Selected) Then
                        Dim type As BP_Type
                        Dim prefix As String
                        If cmbx.Selected.Value = "S" Then
                            type = BP_Type.Vendor
                            prefix = "V"
                        Else
                            type = BP_Type.Customer
                            prefix = "C"
                        End If
                        If CardCode.Value = Nothing Then
                            Try
                                CardCode.Value = GetNextCardCode(type, prefix)
                            Catch ex As Exception
                                B1App.MessageBox("Could not generate next Card Code. " & vbCrLf & ex.ToString)
                    Bubble = false
                            End Try
                        End If
                    End If
                End If
   Public Shared Function GetNextCardCode(Optional ByVal zCardType As BP_Type = BP_Type.Customer, Optional ByVal zCardCodePrefix As String = "C") As String
        Dim brwsr As Recordset
        Dim sql As String
        Dim cardtype As String
        'sql statement is looking for next number based on C or V in first character of existing cardcodes, via passed in
        'prefix field.
        Select Case zCardType
            Case BP_Type.Customer
                cardtype = "C"
            Case BP_Type.Vendor
                cardtype = "S"
        End Select
        'Get next highest customer number from table where customer number
        'starts with a C and the remainder of the value is numeric; then add one to the max value
        brwsr = oCompany.GetBusinessObject(BoObjectTypes.BoRecordset)
        sql = "select  COALESCE(cast(max(str(substring(cardcode,2,len(cardcode)-1))) as numeric) +1,1) " & _
        " as newcode from ocrd  where cardtype = '" & cardtype & "' and left(cardcode,1) = '" & zCardCodePrefix & "' AND isnumeric(substring(cardcode,2,len(cardcode)-1)) = '1'"
        brwsr.DoQuery(sql)
        Return zCardCodePrefix & brwsr.Fields.Item("newcode").Value
    End Function
HTH

Similar Messages

  • HT2240 I purchased a QT Pro Reg. Code Key. When I install it in the QT Preferences Panel, I get an: "Invalid Registration" note at the bottom, next to the "Buy QuickTime Pro" button to the right. Both on a desk top and a laptop. Win 7, QT version 7.7.1. N

    I purchased a QT Pro Reg. Code Key. When I install it in the QT Preferences Panel, I get an: "Invalid Registration" note at the bottom, next to the "Buy QuickTime Pro" button to the right. Both on a desk top and a laptop. Win 7, QT version 7.7.1. No joy! I've been on the phone with Apple for a little more than an hour, so far. They have my money. anyone have any Ideas? Just kiss the thirty bucks goodbye?

    You,Sir, are "The Man"! I followed the instructions and - viola - Joy in Mudville. Thank you, keep up the great work. Even the "Apple" people don't seem to know this. I was on the phone with them, passed from one to another, for over an hour. While waiting I stumbled on your advise and I was made free! If they ask you, charge them a mint for the information. You Sir have gone where no Apple has gone before.

  • How to Create process of Type : Get Next or Previous Primary Key Value

    Hi,
    Can anybody give the steps how to create the page process for type Get Next or Previous Primary Key Value in oracle Express database
    Ramesh j c.

    Hi Justin,
    In oracle 10g XE , we have sample application v2.0
    1. Do you have any Document to create step by step the sample application v2.0 and Is it possible to create all the pages of this sample application v2.0 b by wizard. To recreate or create the demo app, start from the home area,
    next go to application builder,
    then click the create button,
    next choose "demonstration application"
    and then you can choose "Run | Edit | Re-install" the "Sample Application" along with a few other apps.
    2. When we install this sample application v2.0 , which is the sql script is executed or how it is installed. If you want the sample application you can export it after you create it if you want the SQL associated with it.
    3. Whenever the sample application v2.0 is installed, how the encrypted pass word is created for the user demo and admin. This is setup with the application install. I don't believe it is encrypted either. If your wanting SSL there are some threads on here that talk about encrypting content.
    Justin thanks for to create process Get Next or Previous Primary Key Value

  • I want to start using the creative cloud programs but it has forced me to "start a trial" and looks like I need a redemption code to "license" the products on my computer for the next year. Where do I find or get this redemption code?

    I want to start using the creative cloud programs but it has forced me to "start a trial" and looks like I need a redemption code to "license" the products on my computer for the next year. Where do I find or get this redemption code?

    If you bought your subscription direct from Adobe, you should not need any codes, only your Adobe ID and password
    -Cloud programs do not use serial numbers... you log in to your paid Cloud account to download & install & activate... you MAY need to log out of the Cloud and restart your computer and log back in to the Cloud for things to work
    -Sign in help http://helpx.adobe.com/x-productkb/policy-pricing/account-password-sign-faq.html
    -http://helpx.adobe.com/creative-cloud/kb/sign-in-out-creative-cloud-desktop-app.html
    -http://helpx.adobe.com/x-productkb/policy-pricing/activation-network-issues.html
    -http://helpx.adobe.com/creative-suite/kb/trial--1-launch.html
    -Cloud Getting Started https://helpx.adobe.com/creative-cloud.html
    -Install, update or UNinstall, and launch after installing
    If you bought your subscription from some other vendor, ask that vendor for help
    -Redemption Code http://helpx.adobe.com/x-productkb/global/redemption-code-help.html

  • I am getting error messages when keying entries into SAP in transaction cod

    I am getting error messages when keying entries into SAP in transaction code F-02.  It will tell me that an asset doesn't exist in the company code I am posting to when the asset does exist.  For example in the parked document 101079622 it tells me that asset WV0707711 doesnt' exist in CoCode .  But what is keyed in the document is WV07077 1 1. 
    And when i look in Transaction AS03 for this asset number it does indeed exist in Co Code.  Also if you take these assets out and park it and then go into Transaction FBV2 and add the asset back into the document it will add it and then post to it.  This happens often and is very time consuming.  I need to know how to fix this without all this additional effort

    Hi,
    it is urgent can any one help on this.
    Thanks,
    Sridhar Reddy.G

  • Sound Blaster Live Code Key Model CT4

    Have lost my code key for my Sound Blaster Li've. Would be helpful if someone else has the key if they could share it with me.

    Originally Posted by dogweed
    I lost my install disk for my sound blaster live 5.1 model SBO 100 for windows 98se. I cant seem to find drivers on creative's web site that will work with my card. Any one know where I can get them.
    Here:
    http://ccftp.creative.com/manualdn/D...BL51_W9xME.exe
    Creative Surround Mixer (Windows 95, 98, and Millennium)
    Creative AudioHQ (Windows 95, 98, and Millennium)
    Creative Installer 1.00.07 (Windows 95, 98, and Millennium)
    here:
    http://www.vogonsdrivers.com/index.php?catid=3
    or here:
    http://www.touslesdrivers.com/index....ge=12&v_code=4
    Next time please use 'uncle google'...

  • Registration Code Key Retrival

    I had difficulties registering my Dreamweaver on my second
    computer. Calling Adobe, they gave me a registration code key for
    the second computer that worked fine. Unfortunately, I typed it in
    as it was given to me and did not write it down. I am getting a new
    laptop and need to transfer the program to the new laptop. Before I
    "deactivate" the program from my old laptop, how do I go about
    retrieving this code so that it can be used on the new laptop? Will
    I have a chance to see it when I deactivate it? I havent click on
    the deactivate key yet as I dont want to take the chance, not
    knowing what happens next.
    Thanks,
    PyrateJim

    PyrateJIm wrote:
    > Before I "deactivate" the program from my old laptop,
    how do I go about
    > retrieving this code so that it can be used on the new
    laptop?
    Contact Adobe support. They are the only people who can help
    you. I'm
    sure they'll be impressed if you tell them your screen name.
    David Powers
    Adobe Community Expert, Dreamweaver
    http://foundationphp.com

  • I purchased and downloaded Adobe Photoshop Elements 13 from Amazon and when I try to open it, it's asking for a "Redemption Code".  Where do I get the that code?

    When I try to open the Adobe software, it asks from the Redemption Code when on an Adobe web site.  The instructions that came in the download say that this is a 24 digit code of numbers and letters.  The only thing I got from Amazon was an Order Key, which is also 24 digits, but only numbers and the software didn't like that code…  I walked through the steps on the Adobe web site to get my redemption code, but the final step before giving me my redemption code is to enter my redemption code…  I have to enter the code for them to give me the code…???  Am I missing something???  Do I get this "Redemption Code" from Amazon, or from Adobe?

    You would get the redemption code, or perhaps even the serial number, from whomever you purchased the software from, apparently Amazon, so talk to them.  This wouldn’t be the first time they’ve sold something that didn’t have all the numbers needed to license it.
    A redemption code is something that is usually on the inner disc packaging if you purchase the media in a box, and there is a barcode on the outside of the packaging that must be scanned at the checkout register to activate the hidden inner code so you can redeem it at home on that website.  This is what happens if you buy PSE from a brick-and-mortar store like Best Buy.  I don’t’ know what happens if you purchase the downloaded version as I have never done that.
    A redemption code is 24-digits of letters and numbers that you enter into a website to get a serial number, once and only once.  The serial number of only 24-digits, no letters, is what you enter into the software during the install or when you run it and it asks if you want to register or run in a trial mode—whatever the exact phrasing is.
    In any case it sounds like you don’t have either a redemption code or serial number—although perhaps something is listed on the purchase confirmation or your account online at Amazon or even in an e-mail from Amazon.

  • When I try to log on to Facebook, My iPad will not recognize my password, and I get an error code 190. What is it and why do I get it?

    When I try to log onto Facebook, my iPad will not recognize my password, and I get an error code 190, but I can log on on my HP desktop. What is code 190, and why do I get it?

    I was using the FB app that came with the iPad. What I eventually did was.
    1. Held down both home key and on-off button until iPad shut down, then rebooted.
    2. Uninstalled FB app.
    3. Went to App Store and re-installed FB app.
    The iPad had numerous problems. My son saw my plea on FB as I was accessing it through my HP computer, and he walked me through it. While he was at it, he taught me how to disconnect auto-correct. I am not certain that I want to keep that off, but everything is working the way it is supposed to  the way it was in the beginning. 
    I am curious, though, as to what ears to the problem in the first place. After checking various sites, it seems that a code 190 has to do with windows not Apple.
    But thank you for the response.

  • I'm trying to re-install itunes 10.7 on PC.  I'm getting an error code saying i need a 64 bit not a 32 bit. I'm stuck.  Need some help.

    I'm trying to re-install itunes 10.7 on my PC. I'm getting an error code saying I need a 64 bitn not a 32 bit.  I'm stuck.  Need some help

    Hi Jon,
    The "correct" name for an iTunes Library file is iTunes Library.itl. Nearly all updates to iTunes involve some upgrade the library file. The pre-upgrade file is moved into the Previous iTunes Libraries folder, stamped with the date of the upgrade, and then used to construct a new library incorporating any changes that have been made to the data structure for the new build. Should this upgrade go wrong you can usually copy the archived file back into the main iTunes folder, give it the correct name, start iTunes and iTunes will do the upgrade over again. Like this...
    Sometimes when iTunes isn't shut down properly the active library file gets corrupted. If you start iTunes in this state you may be prompted to locate a valid library file. It looks like you have connected to a much older library file at some point. What is less clear is if this is a recent event or an older one.
    I suggest you search the entire computer for all files of the form *.itl. Ideally we need to find the most recently modified one that isn't corrupt, place it in the main iTunes folder, rename it as iTunes Library.itl and connect to it. Having placed a suitable library file in the correct location and renamed it, click the icon to start iTunes and then immediately press and hold down the left shift key. Keep holding until asked to create or choose a library. Click choose and browse to the renamed/relocated library file. If that file won't work close iTunes, and try another in the fashion shown in the diagram until you find one that is satisfactory. No need to use the shift-start-iTunes trick again as this time each new file will be on the same path.
    Once you've found the best of the available libraries you can use a tool called iTunes Folder Watch to catch up with any changes since the backup file was created, i.e., add in the new files, or delete the entries for tracks that have been removed from the media folder.
    If for some reason the restored library contains broken links to the media I have a script called FindTracks that can repair them.
    When you get it all working make a backup!
    tt2

  • I just restored my Mac HD from a time machine back-up and PS 4 Will not open. I get an error code 150:30. Any Idea what I should do ?

    I just restored my Mac HD from a time machine back-up and PS 4 Will not open. I get an error code 150:30. Any Idea what I should do ?

    Photoshop's licensing information might have lost when you restored it to new HD. Re-install Photoshop CS4 and enter the same serial key for PS CS4 which you used before.
    In case you need the download link for PS CS4, you can get it from here. Download CS4 products
    Let me know in case you still get any issues.
    ~ Arpit

  • How can I get the PUK code for my SIM card?

    I had to do a factory reset this morning on my DROID RAZR. As I was going through this afternoon setting everything up again, I saw that I could set a password for my SIM card. I thought it was asking me to create a password, not enter a default one. So needless to say, I locked myself out of my phone, and I need the PUK code. I cannot call, this is my only phone, and I cannot go to a local store today or tomorrow. I also cannot go the next two days without my phone. I've tried doing a chat, but because it's only sales that communicate through the chat, they were less than helpful and told me I can only fix this by going to a store, which I can't do.
    So, can I chat with anyone to get my PUK code today via internet?

    Why is this working for everyone, but me? When I follow these instructions (and many others that I've found in this community -- which has been helpful with other matters thus far) There is no PUK or SIM information. I have an (ESN) and my phone number. that's it. Help! I'm in a rabbit hole!
    Many thanks for any support you can provide!

  • OIM - Task Assignment Adapter - How to get the object instance key?

    Hello experts,
    I'm trying to use a task assignment adapter to assign an approval task dynamically. Basically, the user can request a resource like "CustomApp Profiles" and we create an object form to let them choose the profile that he needs. Each profile has an owner, which is populate in a Lookup (Owner is the code and Profile is the decode).
    So, in the approval task, I need to get the profile selected by user in the object form and search into the lookup who is the owner of that profile. But I don't know how can I get the object instance key using the parameters that can be mapped to a task assignment adapter.
    Looking into the OIM documents, I believe that the easier way is using the request key, because the REQ_KEY is a foreign key in OBI table.
    Did anyone knows how can I get the object instance key using the request key? Can I use some API or should I execute a SQL statement directly in OIM database?
    Best Regards,
    Nitto

    To retry a task that is in a rejected state, you use the SCH_KEY which is the task key.  In OIM, all rejected tasks are listed in the OTI table.  It contains all the important information about a rejected or pending task.
    You can use the APIs found in the tcProvisioningOperationsIntf class to retrieve open tasks.
    -Kevin

  • HT4623 I keep on getting an error code 82e11e when I try to print. Why am I getting it with the os?

    When I try to print anything from my ipad I get a error code 82e11e. This started happening when I upgrade the operating system. Please fix this bug! I can not print

    This issue can be caused by an extension that isn't working properly.
    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    * Don't make any changes on the Safe mode start window.
    * https://support.mozilla.com/kb/Safe+Mode
    * [[Troubleshooting extensions and themes]]
    If it does work in Safe-mode then disable all extensions and then try to find which is causing it by enabling one at a time until the problem reappears.
    * Use "Disable all add-ons" on the [[Safe mode]] start window to disable all extensions.
    * Close and restart Firefox after each change via "File > Exit" (Mac: "Firefox > Quit"; Linux: "File > Quit")
    In Firefox 4 you can use one of these to start in <u>[[Safe mode]]</u>:
    * Help > Restart with Add-ons Disabled
    * Hold down the Shift key while double clicking the Firefox desktop shortcut (Windows)

  • When burning cd's I get an error code

    All of the songs I am attempting to burn are ripped from C.D.'s I own.  I have tried to burn different play lists.  when I attempt to burn a cd it starts to write the first song for a while, and then cancels the burn. I get an error code saying "the attempt to burn a disc failed, an unknown error occurrred (4000) burn". I have the same songs in Windows Media Player so I created the same playlist there and had no problems burning a CD.  This makes me think itunes has a problem.  Any ideas?

    Could you post your diagnostics for us please?
    In iTunes, go "Help > Run Diagnostics". Uncheck the boxes other than DVD/CD tests, as per the following screenshot:
    ... and click "Next".
    When you get through to the final screen:
    ... click the "Copy to Clipboard" button and paste the diagnostics into a reply here.

Maybe you are looking for

  • Macbook Pro Retina 15" charging slowly

    My macbook pro retina was bought in august 2012, and yesterday it just started having charging/battery problems. All of a sudden when I plugged my computer in to charge it got REAL slow and said my estimated time until my battery was full was over 20

  • Purchase Req Key Figure

    SAP Gurus, Is there any way to include purch req qty as key figure in flexible planning? Created new info structure and have requirement to capture purch req reqmt's although this doesn't appear to be captured in LIS. Thanks

  • Help on how to parse some xml

    Hi I have the following bit of XML set to a variable like so:- <cfset var = " <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note> <note2> <to>Tove</to> <from>Jani</from> <heading>Remin

  • FM for BOM Explosion at Production Order

    Hi all, I am using 'CS_BOM_EXPLOSION' to get the list of component of a material, for rework order we used to delete some component in that case this FM gives same list of component, so I need a FM which gives me list of component with respect to Pro

  • USB ports and SD reader not working

    For a few days my usb ports and SD reader stop working, I tried, Doing a  SMC Reset and a PRAM reset I also reinstall my operating system but non of then have worked any advice would be greatly appreciated.