cancel
Showing results for 
Search instead for 
Did you mean: 

getting the Form ID in UI API

Former Member
0 Kudos

Hi everyone,

I will appreciate if you can help me with the following:

1)

What is the correct way of getting the Form ID in UI API? Every time I open new Item Master Data Form the event monitor shows new ID number (i.e. F_42, F_44, etc..). How to catch event which occurs when a new <b>Item Master Data Form is open in “Add” mode</b>.

2)

Does anyone knows how to implement “auto increment” for Item Number field (Item Master Data Form), in other words, every time user enters a new record we perform max(Code) and increment it by 1. I don’t want my users to enter this manually.

thanks a lot for your help,

Regards,

Alex

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

For 2), a simple formatted search is enough. Try to search the forum or the SAP community and you will find the answer.

Basically what you should do:

DECLARE @MAX AS INTEGER

SET @MAX=(SELECT MAX(CardCode)+1 FROM OCRD WHERE CardType='C')

SELECT @MAX

I did not try this auery but I think it will help you to understand the concept.

Cheers,

Vincent

Former Member
0 Kudos

<b>a simple formatted search is enough.</b>

I am not sure whether formatted search is going to be good for that as the idea is to generate new ID once form is open in ADD mode.

<b>

Instead of the Form UID, have you looked at form-type property (Use TypeEx in version 2004/6.7)</b>

Unfortunately our current version is 6.5 and the only choices I have are Form ID (changes every time I open a new instance of the form), Item Num,Row,Col, Menu UID (not relevant for form)

<b> Dim objForm As SAPbouiCOM.Form

/* 6.5, Deprecated in 6.7 */

If pVal.FormType = 150 Then

If pVal.EventType = et_FORM_LOAD And Not pVal.BeforeAction Then

/* Here's your Item Master Data Form, opened in ADD-Mode */

Set objForm = SBO_Application.Forms(pVal.FormUID)

End If

End If</b>

Thanks I will try this one.

Does anyone uses C#? I find a lot of information for VB but not C#.

thanks to all

rasmuswulff_jensen
Active Contributor
0 Kudos

I use C#.... Its a hard world among all these VB programmers

The code-structure given to you of cause also work in C#

if(pVal.FormType = 150 && pVal.Eventtype=BoItemEventTypes.et_FORM_LOAD && pVal.before_action) {

//Do something

}

I recomend you make some helper-methods on the fly so development time in time can be reduced

rasmuswulff_jensen
Active Contributor
0 Kudos

Btw..If you will make an autogenerated number do remember to consider mulituser-systems...

I'm in the process of making the same as you need to do(Idea stage), but I will post something if I manage to do it

Former Member
0 Kudos

> I use C#.... Its a hard world among all these VB

> programmers

I'd be glad not to work with VB6. But I'm an employee, VB6 is the decision (probably because there are a lot of samples for it;) for developing SBO-SDK-stuff.

And after all: Sometimes I wonder how good the VB6-Debugger actually is, regardless of his age...

Former Member
0 Kudos

<b>I use C#.... Its a hard world among all these VB programmers :-)</b>

I'll stick with you than

<b>I'm in the process of making the same as you need to do(Idea stage), but I will post something if I manage to do it</b>

My vision is to create a new-empty item master form whenever user hits ADD Menu button (or Ctr+A) using DI API and than open it in EDIT mode. This how we eliminate errors of using same ID in mulituser enviroment. If user decides to abandon without entering any data by using Cancel button, we just delete this record via DI API. In my situation it’s more convenient to generate ID’s automatically.

What do you think?

rasmuswulff_jensen
Active Contributor
0 Kudos

What I have planned to do works in the same way as SAP does.

When you switch to add mode I will read the largest code and display code++ (In mulituser system all persons in the the process of adding an item will get this number).

When add is pressed I will start a transaction, make the check for largest code once more. if the code from this result I will use this, and inform the user that his item was added, but with a different number that was displayed (Like SAP do it with documents)...

Answers (2)

Answers (2)

Former Member
0 Kudos

    Dim objForm As SAPbouiCOM.Form
    
    /* 6.5, Deprecated in 6.7 */
    If pVal.FormType = 150 Then
        If pVal.EventType = et_FORM_LOAD And Not pVal.BeforeAction Then
            /* Here's your Item Master Data Form, opened in ADD-Mode */
            Set objForm = SBO_Application.Forms(pVal.FormUID)
        End If
    End If
    
    /* 6.7 */
    If pVal.FormTypeEx = "150" Then
        If pVal.EventType = et_FORM_LOAD And Not pVal.BeforeAction Then
            /* Here's your Item Master Data Form, opened in ADD-Mode */
            Set objForm = SBO_Application.Forms(pVal.FormUID)
        End If
    End If
rasmuswulff_jensen
Active Contributor
0 Kudos

1) Instead of the Form UID, have you looked at form-type property (Use TypeEx in version 2004/6.7). Use this if you need to catch an event on every form of the same type. ... The add-mode can be checked for by the forms Mode property