cancel
Showing results for 
Search instead for 
Did you mean: 

URGENT: Illegal Argument Exception

Former Member
0 Kudos

I am getting this error in the following scenario.

I want to save the text fields from an interactive form to SAP through RFC enabled function module. The type in the model and controller is byte[]. I have converted the string attribute from view to save to the model. But the model dictionary in Web Dynpro projec (model) has this type as Binary. I am going nuts since 3 days due to this.

The type in SAP is RAW.

The initial exception that caused the request to fail, was:

java.lang.IllegalArgumentException

at com.sap.dictionary.runtime.DdTypeBinary.format(DdTypeBinary.java:60)

at com.sap.dictionary.runtime.DdTypeBinary.toString(DdTypeBinary.java:64)

at com.sap.tc.webdynpro.clientserver.data.DataContainer.doFormat(DataContainer.java:1405)

at com.sap.tc.webdynpro.clientserver.data.DataContainer.getAndFormat(DataContainer.java:1098)

at com.sap.tc.webdynpro.clientimpl.xdp.renderer.data.XfdRenderer.renderAttributes(XfdRenderer.java:370)

... 41 more

Accepted Solutions (0)

Answers (1)

Answers (1)

raja_thangamani
Active Contributor
0 Kudos

You can convert the bytes into Binary..refer the below sample code:

		byte[] lineContents = new byte[1022];

	        int numBytesRead = 0;

		do {
    		numBytesRead = fileStream.read(lineContents);
		if (numBytesRead > 0) {
			fileSize += numBytesRead;
			Bapiconten bin = new Bapiconten();
	         	bin.setLine(lineContents);
		        bapi_Input.addI_File_Content(bin);
			Arrays.fill(lineContents, (byte) 0);
		}
	} while (numBytesRead > 0);

Hope this will help you..

Let me know if you need any help.

Raja T

Message was edited by:

Armin Reichert

Former Member
0 Kudos

Hi Raja,

Thanks for the quick response.

The Problem I have here is I need <b>binary stream in byte array</b> for setting the attribute as the the type taken by that attribute is byte array and the type in dictionary is binary. I think your code is for filestream. Also Bapi_input, filestream in your code are not recognised. Request you to help me out.

byte[] lineContents = new byte[1022];

int numBytesRead = 0;

do {

numBytesRead = fileStream.read(lineContents);

if (numBytesRead > 0) {

fileSize += numBytesRead;

Bapiconten bin = new Bapiconten();

bin.setLine(lineContents);

bapi_Input.addI_File_Content(bin);

Arrays.fill(lineContents, (byte) 0);

}

} while (numBytesRead > 0);

former_member751941
Active Contributor
0 Kudos

Hi BW,

Check this.

dataSrc attribute is of type binary.

try {

FileInputStream FileIn =

new FileInputStream("C:
Temp
data.txt");

byte Bytes[] = new byte[FileIn.available()];

FileIn.read(Bytes, 0, Bytes.length);

FileIn.close();

wdContext.currentContextElement().setDataSrc(Bytes);

Arrays.fill(Bytes,(new Byte("0")).byteValue());

} catch (FileNotFoundException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Byte.html

Regards,

Mithu

Former Member
0 Kudos

Issue with the RAW data types is resolved now. I have changed the data type of the field into String in the dictionary (web dynpro).. I have changed the corresponding getters and setter functions from byte[] to string. And everything working fine now. I got the Illegal Argument exception initially because I was trying to display the binary data type fields on the adobe form or view which I am not supposed to do.

Also it is better to create separate view attributes in the context to get the values rather than mapping the model attributes directly in the form or view.

Thank you one and all.

Regards

Vasu