Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics SL forum
Suggested answer

How to declare Offset and Length in temporary table!

Posted on by 315

Hi all,

I developed a new screen and use the temporary table for filtering.I do the followings:

1.Declare table in Records Maintenance

2.Declare fields in Fields Maintenance

3.Use Generate Schema to generate SDO for this table

4.Add this SDO in SDK and declare fields for some controls with Offset address,Type, and Length.

But I found incorrect value in date control : it not display correct the date? (Note: I followed the help for declaring the table which is not exist in the database).

Thanks in advance,

Hien

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    Re: How to declare Offset and Length in temporary table!

    Create a module:

    Option Strict Off

    Option Explicit On

    Imports Solomon.Kernel

    Module Module1

       Public Class selectBUF

           Inherits SolomonDataObject

           < _

           DataBinding(PropertyIndex:=0) _

           > _

           Public Property b_DateTime() As Integer

               Get

                   Return Me.GetPropertyValue("b_DateTime")

               End Get

               Set(ByVal setval As Integer)

                   Me.SetPropertyValue("b_DateTime", setval)

               End Set

           End Property

    ...other fields in your unbound table....

    end class

       Public bselectbuf As selectBUF = New selectBUF, nselectbuf As selectBUF = New selectBUF

    End Module

    form1_load put these where they belong

           Call SetAddr(LEVEL0, "bselectbuf", bselectbuf, nselectbuf)

           Call SqlCursorEx(c1, LEVEL0, "c1", "selectbuf", "selectbuf")

           Call SetButton(1023 AllLevels, False)  'disable toolbar buttons

    SAFdate field fieldname="selectbuf.b_datetime"; 0; 3; 4

    I have this working so I hope this was clear enough for you to follow.

    Another option, which I also use, is what Barry suggested.  I use a xRptControl table.  In it I have username, reportNbr, dte1, dte2, dte3, str1, str2,str3, dbl1, dbl2......

    Then I can bind this table to the report launcher screen and allow users to save their defaults.

    good luck,

    Ayrin

  • Barry Flynn Profile Picture
    Barry Flynn 3,090 on at
    Re: How to declare Offset and Length in temporary table!

    Hien

    I'll offer two approaches.

    First - if you want to keep your three controls as Unbound.

    If there are three unbound controls, I think the simplest way in 7.x is to use a separate buffer (and therefore separate SetAddr call) for each.

    That way, you don't have to worry about the Offset value - it will always be zero.

    If there were a very large number, then having a separate buffer for each would be very unwieldy.

    For a Date, the Type is 3 and the Length is 4.

    As I noted earlier, be a little wary of Code Inspector.

    My experience with unbound date controls is that it suggests changing the Type to that of an Integer, rather than a Date.

    As I recall it, if that change is made, the date control does not work properly.

    ---

    But, there is a totally different approach, which is probably much easier.

    This is an approach which I think was suggested by Tom Malia a while ago.

    Create a table in the database which contains your three (or however many) columns.

    By that simple action, your controls are no longer Unbound, and you can enter zero for the Offset, Type and Length.

    You never need to write to, or read from your "table".

    It simple has to exist in the database.

    That may be the easiest fix for your problem.

    Barry

    .

  • Hien Nguyen Profile Picture
    Hien Nguyen 315 on at
    Re: How to declare Offset and Length in temporary table!

    Hi Barry,

    This table is not exist in the database,so I need to declare Offset,Type and Length for each unbound control.I use help file for this but it work incorrectly.I also use Inspector Tool for auto-repairing but it does not work.

    How can I declare the correct offset for this?Example : I have 3 unbound controls followed by the following orders:

    1.Date

    2.Text

    3.Date

    Thanks in advance

    Hien

  • Barry Flynn Profile Picture
    Barry Flynn 3,090 on at
    Re: How to declare Offset and Length in temporary table!

    Hien

    Provided the table exists in the database, you don't need to enter the Offset/Type/Length fields - leave them all as 0 (zero).

    At run time, the Dynamics SL kernel looks at the table definition in the database and calculates those entries itself.

    One quirk to that - after creating the table you must close & restart Dynanics SL.

    Otherwise, the kernal does not realize that the table exists, and it will give you an error at run time.

    It is only for so-called Unbound controls that you need to enter the Offset etc.

    Be a lottle wary of Code Inspector for "unbound controls".

    For unbound date controls, my experience is that it erroneously wants to set the "type" to that of an Integer, rather than the type for a Dater.

    As a sample, in one of my screens with an unbound date control, the Offset is 0, Type is 3 and Lenlength is 4.

    Obviously Offset" will vary, depending on whether the Date is the first field in the Buffer or not.

    I'm unclear on whether you are using Unbound controls or not.

    You say that "and use the temporary table for filtering" which tells me that there is a table.

    But you also say that "I followed the help for declaring the table which is not exist in the

    database)."

    And that suggests that it is an "unbound control".

    Ir is vital that we are clear on whether there is a table in the database or not.

    That directly affects what you enter in the "Offset" etc. fields.

    Barry

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,554 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,588 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans