web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics SL (Archived)

SL SDK SGroupFetch Example

(0) ShareShare
ReportReport
Posted on by

I am wondering if anyone who does development using the SL toolkit might have an example for using SGroupFetch to return a string value?  I need to return the AdjgRefNbr field from ARAdjust based on a query that utilizes Group By).  I have followed the limited example in the documentation but that example is returning a count value, not a text value.  When I try to execute the SGroupFetch1 call the module immediately shuts down with no error message whatsoever.  If I try a test SGroupFetch on a query that returns a numeric value, the call completes and moves to the next code line so I am wondering if this even works with text values.

I am currently doing this change under version 6.5 and have not tried it under SL 2011.

If someone has figured out the proper code to make this work and is willing to share, it would be greatly appreciated.

 

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at

    Hi

    The below code will help you out towards your needs

    In the below example, I have retrieved the maximum of AdjdRefNbr from ApAdjust Table.  You can apply your scenario as you wish.

    Dim SqlStr as String

    Dim StrAdjdRefNbr as String

    Dim Csr_Temp as Integer

    SqlStr = "SELECT  ISNULL(Max(AdjdRefNbr),'') FROM ApAdjust WHERE VENDID Like" & Sparm(XXXX) &" Group by VENDID"

    Call sql(Csr_Temp, SqlStr)

    Serr1 = SGroupFetch1(Csr_Temp, StrAdjdRefNbr , LenB(StrAdjdRefNbr ))

    Call SqlFree(Csr_Temp)

    Note: XXXX represents VendID buffer (the Filter value)

    Hope this Helps

    Thanks & Regards

  • Community Member Profile Picture
    on at

    Santhosh,

    Thanks for the example.  I am curious if this represents actual functional code or just how you think it should be coded.  I am asking that because this is basically what I did (with the exception of the fact that I was using the ARAdjust table and I have the issue that when I execute the SGroupFetch1 call the program shuts down (with no error message).  My constructed query string executes just fine in SQL Management Studio.

    I will continue to play around with this to see if I can get any variation to work.  Meanwhile, I actually found a way to do what I needed to do without having to use a query that requires the use of SGroupFetch.  However, there is going to be a time where I need to use SGroupFetch so I would like to figure it out.  As we all know, SWIM is rather picky and the documentation on some of the SWIM calls is not the greatest.  If you do not get things just right, it is sometimes hard to determine what is not quite correct.

  • Community Member Profile Picture
    on at

    A bit more info.

    If I simply Dim the results variable as a String then I get an error message indicating that there is a length issue.  If you use the immediate window to execute ?LenB(stradjrefnbr) the result is 0.  I suspect this is because the variable has no length prior to being loaded with a value and this is probably causing the error I am getting.

    If I Dim the results variable as String * 10 (the actual max width of an AR reference number), that is when I get no error message and the program aborts during the SGroupFetch1 call.

    This is what is prompting me to wonder if the group fetch works with results that are a string item.  The documentation talks about the width of numeric results but not about a string result.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics SL (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans