cancel
Showing results for 
Search instead for 
Did you mean: 

Converting RFCTYPE_BYTE to byte in C#

Former Member
0 Kudos

Hello,

can someone tell/explain me how to cast a .NET byte[] array to an RFCTYPE_BYTE[] array, because i get a marshalling error when filling a BAPICONTENT255Table.

Thanks for any help in advance,

CHM

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

My mistake! The .Net Connector handels any marshaling for you, i guess. It just throws an exeception (System exception thrown while marshaling .NET type System.Byte[] to RFCTYPE_BYTE) when you do not assign a value to a table row field.

Former Member
0 Kudos

Hello,

We have got same problem but we do not find any solution, and we think we are assigning all values correctly.

Thanks in advance,

e-mail: juan_medina_98@yahoo.com

Former Member
0 Kudos

as i posted before you should not experience problems when you properly assign a value to each field. maybe this code fragment can help you

for ( i = 0; count < fs.Length-254; i++ )

{

count += 255;

bincontent.Add((SAPRM.BAPICONTENT255)bincontent.CreateNewRow());

bincontent<i>.Line=r.ReadBytes(255);

}

bincontent.Add((SAPRM.BAPICONTENT255)bincontent.CreateNewRow());

byte [] fill= new byte[255];

r.ReadBytes(255).CopyTo( fill, 0);

bincontent<i>.Line = fill;

Former Member
0 Kudos

Finally we've solved it.

Firstly we tried to "cut" the last file since it doesn't need to be so long but that's where SAP Connector error raises up. For whatever reason, SAP structure needs to have all rows with the same length.

Filling up with empty bytes at the end works nice for us.

See ya!