Archive for the ‘ERP’ Category

How To #8 – Can I bypass DAL in my program ? #baanhowto #LNHowto

February 17, 2017 Leave a comment

Please be careful when you are doing this, I assume you already know what you are doing.

But yes off course, you can bypass DAL in your program. The below piece of code will do it all for you, this will prevent all the DAL checks on the main table for the session.


I wouldn’t recommend bypassing DAL at all, its good to have it on. But if you have some customization where you can’t avoid it, you can’t avoid it.

Quick Submit

Categories: BaaN, ERP, HowTo, Infor Tags: , ,

What’s your choice, while upgrading your ERP System ?

January 17, 2012 Leave a comment

Categories: BaaN, ERP, Infor Tags: , ,

How To #1 – Call a Report Layout Programmatically #baanhowto

October 8, 2011 Leave a comment

Tweeted a month back, to start a howto section for Baan ERP on my blog.Well starting it from today.I Would like to make this section totally interactive, you can submit your #howtos using the quick submit form below in the post or from submit howto page, and you can also correct me, or add your inputs to the howtos answered by me, in the comment section below. Howtos are mainly for those who are new to Baan, bringing more awareness of wide capabilities, Baan Tools can provide. Love the way Baan Tools is designed. While tweeting any howto post, please use #baanhowto, to make the information available under a single hash tag. Starting with the first howto.

Quick Submit

How to call a Report Layout Programmatically ?

Many a times, there is a requirement to call a particular report layout, conditionally after another layout. For example, you need After.Field layout to get printed, after every 5 records in Detail layout are printed. How will you do that ? In normal scenario, After.Field will get executed after all the records in Detail layout are printed.But in this scenario, we need to call the After.Field layout before all the records are printed and execution of Details layout is complete.

This can be achieved simply as shown in code snippet below

cnt = cnt + 1
if cnt > 5 then
cnt = 0

You can notice the function r.5.s.after.tdXXXXXX.YYYY() called in the before.layout of Detail.1. This function is a auto-generated function. When you compile your Report, Report Generator internally generates a script, defining the Report structure and Report flow based on the what you have maintained in the UI (Layouts maintained, Fields maintained in the Report Editor etc.). If you have two detail layouts say “detail.1” & “detail.2”, the auto-generated script will have the two layouts defined in functions “r.1.s.detail()” & “r.2.s.detail()” respectively. Similarly every layout maintained by you will have a respective function defined in the auto-generated script, which you can call in your Report script.

The image below provides the visual representation of the function’s naming convention.

stay tuned for more howtos, submit your howtos

Categories: BaaN, ERP, How to, Infor Tags: , , ,

Excel data upload to BaaN System (OLE Automation)

July 11, 2011 3 comments

Most of the times, Infor BaaN users have a requirement of uploading data from excel to BaaN database.This blog post will explain everything about the above topic. Some of the common questions asked are answered below.

Q.1 Is it possible to upload/download data directly from Excel ?
Ans: It is absolutely possible to upload or download data, right from your excel file.

Q.2 Can I use the BaaN business logic, while uploading data ?
Ans : Answer is yes, absolutely yes.

Q.3 Do I need a third party tool for this ?
Ans : No, apart from MS Excel no other third party tool.

Q.4 How will I connect to BaaN ? Dont want to hit the DB at backend.
Ans : You can use OLE to connect to BaaN System and call a BaaN DLL to perform database transactions, database is not directly hit.

Q.5 What is this OLE ?
Ans : Object Linking and Embedding (OLE) is a technology developed by Microsoft that allows embedding and linking to documents and other objects.

Q.6. How exactly this works ?
Ans : You will need to write a VBA code inside excel, the belows points explains the same

To start with, you will have to write a VBA macro in excel, Assuming you know the about macros, I won’t go deep into how to write a macro code, it can all together be a different post. I will jump directly into the macro code and concentrate more on BaaN connectivity.

The first step is create an object for setting a connection to BaaN legacy system. The following code snippets, shows the same.

Dim BaanObj As Variant
Dim value As String

Set BaanObj = CreateObject(value)

The CreateObject method creates the actual underlying IDL object. The argc, argv, and argpal parameters are used to supply parameters to the underlying IDL object’s Init method. If the Init method does not have any parameters, the caller sets argc, argv, and argpal to 0, NULL, and NULL, respectively.

The OLE Automation object, i.e BaanObj in this case have methods and properties. Methods are nothing but functions and properties are attribute that has a value. Property values can be set and/or retrieved.

The methods available for BaaN Application Objects are

  • ParseExecFunction “<DLL_NAME>”,”<FUNCTION_CALL>”
  • Quit

Properties available for BaaN Application objects are

  • Timeout
  • FunctionCall
  • Error
  • ReturnValue

You can see the variable “value” used as a argument for CreateObject, now to connect to BaaN Sytem, we will be making use of the BW configuration file. Assign the classname defined under the automation tab in BaaN BW configuration dialog box to the variable “value”. This will establish connection with the BaaN legacy sytem using the user id defined in the configuration. If username/password is not saved in the configuration, then it will prompt for the same.

Now the next step is to define the BaaN DLL and call the function defined in the DLL. Below code snippet demonstrate the same.

Dim B_function As String
B_function = <FUNCTION_NAME> (<arg-1>,<arg-2> ,..,<arg-n>)

BaanObj.ParseExecFunction “otdpurdllxxxxxx”, B_function

This will call the Baan DLL, where in the Baan Business logic is written, all db transactions are performed using this DLL.

Last but not the least,  for ending the automation you will need to use the “Quit” method as in the below code snippet.

Set BaanObj = Nothing

Quit method will end the lifecycle of the object. The second line in the code will initialise it to “Nothing”, to free the memory allocation.

There are some limitations though in this method

  •  Array Arguments not supported
  • Variable number or Optional  arguments not supported
  • 4K Limit on the max size of function call (bshell limit)
  • 4K Limit on the max size of ReturnValue (bshell limit)

Example Code (BaaN DLL)

function extern string upload.currency.rates(     ref string ccur,
ref string srate,
ref string prate)
code for updating the currency rates


Example Code ( Excel VBA )

      Dim RetVal As String
      Dim BaanObj As Object

      Sub Function_XYZ ()
          On Error GoTo ConnectionError

          Set BaanObj = CreateObject("Baan.Application")

          On Error GoTo AutomationError

          BaanObj.ParseExecFunction "<BaaN_DLL>", "<BaaN_FUNCTION>"
          If (BaanObj.Error <> 0) Then GoTo AutomationError
          	RetVal = Baan4Object.ReturnValue

          Row = 1
          Column = 1 

	  While (RetVal <> "") 

                Worksheets("Main_Sheet").Cells(Row, Column) = RetVal
                Row = Row + 1 

                If Row > 15 Then
		   Row = 1
		   Column = Column + 2
              	End If

             	BaanObj.ParseExecFunction "<BaaN_DLL>", "<BaaN_FUNCTION>" 

            	If (BaanObj.Error <> 0) Then GoTo AutomationError
             	   RetVal = BaanObj.ReturnValue

          Set BaanObj = Nothing
          Exit Sub

          MsgBox "Connection Error"
          Exit Sub

          MsgBox "Automation error"
          Set BaanObj = Nothing
          Exit Sub

      End Sub
Categories: BaaN, ERP, Infor Tags: , ,
%d bloggers like this: