cancel
Showing results for 
Search instead for 
Did you mean: 

Conditional Dynamic configuration : Reg

former_member593220
Participant
0 Kudos

Hi,

Am using below code for Dynamic file name.

try{

String filename    = "";

DynamicConfiguration conf1 = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key1 = DynamicConfigurationKey.create( "http:/"+"/sap.com/xi/XI/System/File","FileName");

filename = BUKRS+"GSBER"+Filename+".CSV";

conf1.put(key1,filename);

return filename;

}

catch(Exception e)

{

  String exception = e.toString();

  return exception;

}

Here, my requirement is GSBER value will have three combinations 9999,0201,1450. SO these 4 digit value should be converted to 1 digit and need ot send to filename in place of GSBER.

So with Fix values am trying to convert it to 1 digit in the following way..

9999 = A

0201 = B

0203 = C

So can any body help me with the piece of Java code which is needed to convert this 4 digit to 1 digit.

Thanks in Advance..!

--

Regards

Raj

Accepted Solutions (1)

Accepted Solutions (1)

engswee
Active Contributor
0 Kudos

  if(GSBER.equals("9999")) {

   GSBER = "A";

  } else if(GSBER.equals("0201")) {

   GSBER = "B";

  } else if(GSBER.equals("0203")) {

   GSBER = "C";

  }

former_member593220
Participant
0 Kudos

Hi Swee Yeoh,

Thanks for your reply. I have added this condition in UDF but still the file name is printing as "LBGVPFVPFPARGSBER000220150128-073954-850"

Below is the code which I am using in the UDF..

try{

String filename    = "";

DynamicConfiguration conf1 = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key1 = DynamicConfigurationKey.create( "http:/"+"/sap.com/xi/XI/System/File","FileName");

filename = BUKRS+"GSBER"+Filename+".CSV";

if(GSBER.equals("9999")) { 

    GSBER = "A";

} else if(GSBER.equals("0201")) {

    GSBER = "B";

} else if(GSBER.equals("0203")) {

    GSBER = "C";

}

conf1.put(key1,filename);

return filename;

}

catch(Exception e)

{

  String exception = e.toString();

  return exception;

}

Can you please tell me where I need to correct.?

thanks in advance.!

--

Regards

Raj

engswee
Active Contributor
0 Kudos

You are hardcoding your GSBER in your following line of code


filename = BUKRS+"GSBER"+Filename+".CSV";

GSBER need to be a String input into your UDF.

From your mapping flow, there is three inputs to the UDF. Can you please show the screenshot of the parameter/argument definition of your UDF?

Former Member
0 Kudos

Hi Raj,

Modify your code as below :

try{

String filename    = "";

DynamicConfiguration conf1 = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

DynamicConfigurationKey key1 = DynamicConfigurationKey.create( "http:/"+"/sap.com/xi/XI/System/File","FileName");

if(GSBER.equals("9999")) { 

    GSBER = "A";

} else if(GSBER.equals("0201")) {

    GSBER = "B";

} else if(GSBER.equals("0203")) {

    GSBER = "C";

}

filename = BUKRS+GSBER+Filename+".csv";

conf1.put(key1,filename);

return filename;

}

catch(Exception e)

{

  String exception = e.toString();

  return exception;

}

former_member593220
Participant
0 Kudos

Hi,

Below are the arguments which am taking as inputs.. Please have a look.

--

Regards

Raj

engswee
Active Contributor
0 Kudos

Ok, just need to change your code from


filename = BUKRS+"GSBER"+Filename+".CSV";

to


filename = BUKRS+GSBER+Filename+".CSV";

Basically, just remove the double quote surrounding GSBER.

Former Member
0 Kudos

Hi Raj,

Remove the FixValues function and code it(Set_FileName) as mentioned above.

Regards,

Soumyadip

former_member593220
Participant
0 Kudos

Hi Soumyadip,

It is working fine with this code. Thanks a lot for timely help..

--

Regards

Raj

Answers (0)