Siebel provides tens of ways to accomplish one task. Creating files is a good example to explore the myriad ways to create a text file and populate it with content.
I will filter out all the other ways, and tell you the fastest, most simple way of creating a file. Use the CLIB functions. The C libraries are called by the Siebel OOB business services, workflows too, and when used properly provide the fastest way to achieve a given task.
Create File in Siebel – the fastest way
>> Although I have used this method of creating files using CLIB functions, it is not recommended (or turned on by default) by Oracle post Siebel version 22.214.171.124. See comments below. <<
Without much ado, here’s the script to create the file.
function CreateFile(sFile, sContent)
Author: Prashanth K
Description: Create file with a given name and content.
No implied warranties. Use at your own risk.
Date Author Description
var fPtr = Clib.fopen(sFile,"w");
fPtr = null;
What the script does is self-evident (you can use the crmcog utility to debug scripts faster) .
- Accept the file name as sFile
- Accept the text content that needs to in a file – sContent
- Create the file using the CLIB function fputs
- Close the file, finish the job, and let you enjoy your life
If you are stuck in a Siebel application that uses a LOT of file transfers, you may even want to include this as an application function.
Compare to other ways of creating files in Siebel
There were always two camps that use Siebel scripting. One that advocates the use of CLIB functions, and the other is a fan of using Siebel provided functions.
Siebel functions and services abstract the CLIB functions, and have their advantages. They provide easier, better error handled ways of accomplishing a given task.
I will take one such example for creating files.
EAI File Transport is a business service that can do all the file handling for you.
The Send method in EAI File Transport service accepts the following arguments:
It is fairly obvious that this service can do a lot more than what was demonstrated earlier in this post. You can:
- Create new file, or append to file
- Use a connection subsystem named parameter – this implies that the file name is separated from the code. You can configure this parameter value outside the core system (typically in the CFG file, or Enterprise Parameters)
- Handle various code pages
- Ask Siebel to use a transformation service to handle outgoing data
All these are invaluable, no doubt. But at the end of the day Siebel services sit on top of C library functions, and will have their overhead. This may be in milliseconds, but overhead nonetheless.
My typical rule of thumb is to use Siebel services in case of any medium or high complexity tasks. You are better prepared to scale the complexity as it happens, you do lesser coding, and error handling is better. However, for simpler tasks you are better off using CLIB functions. They are simpler, have lesser overhead, and are faster.