Thursday 1 October 2015

Working with Siebel VBC, Extracting data from external file

Hi All,

Recently we were preparing some POC for our client, one of our team member suggested to present some functionality which enables us to show data from an excel file in Siebel Screen.
so we thought to give it a try .we used the below approach.

1. Since data sorce was not any siebel table but a external file, we had to use VBC to read the file.
2. Created New VBC ,Business Service, Applet  to show the data.

the exact steps were :

1. Create a new VBC based on class CSSBCVExtern.
2. Add field in the VBC.
3. In BC User Property create a new record
   Name : Service Name
   Value : Read From File Business Service (Name Of Business Service)







4. Create the Business Service ,the sample code looks like

function Service_PreInvokeMethod (MethodName, Inputs, Outputs)
{
switch (MethodName)
{
case "Init" :
Outputs.SetProperty ("NumberOfCard", "");
Outputs.SetProperty ("TypeOfCard", "");
return (CancelOperation);
break;
case "Query" :
readFile(Inputs, Outputs);
return (CancelOperation);
break;
}
return (ContinueOperation);
}

//function to read file
function readFile(Inputs, Outputs)
{
var str;
var usageAry = new Array();
var test:PropertySet = TheApplication().NewPropertySet();
var filePath = "C:\\Output.CSV";
var oFile = Clib.fopen(filePath,"r+");
var out;

try
{
if(oFile != null)
{
while(!Clib.feof(oFile))
{
str = Clib.fgets(4000,oFile);
usageAry = str.split(","); // Delimiter to separate data from the file
test.SetProperty ("NumberOfCard", usageAry[0]);
test.SetProperty ("TypeOfCard", usageAry[1]);
Outputs.AddChild(test.Copy());
test.Reset();
}
}
}//end of try
catch(e)
{
//handle the error
}
finally
{
test = null;
usageAry = null;
}
}

5. Create a new applet based on the created VBC and Add it to either existing view or create a new view.
6. Compile and test you changes.

Data from csv file shown in applet








csv file with data













Hope this was helpful...

Note : VBC are specialised type of BC which are not based on any tables but get the data from the business service on which they are based. Various operation like Update, Query, Insert can be performed on VBC based on the method defined in the Business service.

No comments:

Post a Comment

Siebel GoTo View - Handling Realtime cases

 Hello All,  We all must have used GoTo view functionality of siebel to navigate to a particular view from current view. What if the require...