cancel
Showing results for 
Search instead for 
Did you mean: 

Reg:UDF

Former Member
0 Kudos

Hi...

I need one help in writing UDF...

Source Structure:

Root --- o to unbounded

Server Name

Product name

Corporate Name

Filetype

SerialNum

My requirement is like,

If the Server name = "A" and Product Name = "X", then

filename = concatenate{ConstantXCorporateNamecurrentDate(DDMMYYYY)currenttime(HH:mm:ss)SerialNum+filetype]

else

filename=concatenate{ConstantYCorporateNamecurrentDate(DDMMYYYY)currenttime(HH:mm:ss)SerialNum+filetype]

Can you please help in writing UDF for the above requirement.

Accepted Solutions (0)

Answers (3)

Answers (3)

jyothi_anagani
Active Contributor
0 Kudos

Hi,

Take these inputs for that UDF

Server Name , Product name , Corporate Name , Filetype ,SerialNum

and select context while creating the UDF and import this import java.text.;* in UDF


 String fileneme = "";
  DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
  java.util.Date date = new java.util.Date();

  for( int i=0; i<ServerName.length ; i++)
  {
      If (ServerName<i> .equals("A")&& ProductName.equals("X"))
      { 
          filename = "X"+CorporateName<i>+dateFormat.format(date)+SerialNum<i>+filetype<i>;
           result.addValue(filename);
     }
    else
    {
        filename = "Y"+CorporateName<i>+dateFormat.format(date)+SerialNum<i>+filetype<i>;
           result.addValue(filename);
    }
}

Map like this.


Server Name----\
Product name--\
Corporate Name-----UDF------filename
Filetype----------------/
SerialNum-----------/

This code is without Dynamic configuration and it just give the logic to construct the file name and You do your necessary Dynamic config Part

Thanks

jyothi_anagani
Active Contributor
0 Kudos

Hi,

If the condition is satisfied more than 1 time Do you want multiple files to be generated.

Will you please state your requirement clearly.

Thanks.

Former Member
0 Kudos

Hi..

Multiples files should be generated. For that splitting, i have done the mapping. For UDF, i got stuck up with it.

Thanks,

Leela

santhosh_kumarv
Active Contributor
0 Kudos

Hi,

Is your requirement is to set the filename dynamically...? If your root has occurrence unbounded are you splitting the file....? In the UDF do you require to validate all the occurrence of server name and product name and which element occurrence would to set in the filename.... explain you requirement more clearly...

Thanks,

SaNv...

Former Member
0 Kudos

Hi..

I need to set the file name dynamically. And i need to validate all the occurances of server name and product name. Based on the productname and server name i need to check the condition and write the file name dynamically.

Thanks,

Leela

Shabarish_Nair
Active Contributor
0 Kudos

/people/shabarish.vijayakumar/blog/2009/03/26/dynamic-configuration-vs-variable-substitution--the-ultimate-battle-for-the-file-name

look at my blog. You will have to enhance a bit to put in your logic to accommodate the requirement

Former Member
0 Kudos

Hi Shabarish,

I have seen your blog. It is really a nice blog.In that you were using Dynamic configuration. Without Dynamic Configuration, i need UDF.

Thanks,

Leela