on 11-02-2014 8:51 AM
Dear Experts,
I am having a requirement to read images from Oracle Database (Sender) to SAP ECC (Receiver).
My design would involve:
Sender JDBC adapter ( Images stored in Oracle Database) -> SAP PI 7.4 -> Inbound ABAP Proxy
To read the BLOB field from the JDBC table, I would be using a Stored Procedure with Select statement.
I also refered the blog written by Praveen Gujjeti in the blog
http://scn.sap.com/community/pi-and-soa-middleware/blog/2010/03/28/sap-xipi-storing-binaries-images-... but its a scenario which is just the reverse.
1.Once I call the Stored Procedure, can I store the BLOB field containing Hexadecimal String directly to ABAP table?
2.If not, should I create a Message Mapping UDF for the the BLOB field with the below code to convert HexadecimalString to Binary Array?
public static byte[] hexStringToByteArray(String s) {
int len = s.length();
byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2) {
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4)
+ Character.digit(s.charAt(i+1), 16));
}
return data;
}
3. If the above scenario populates the ABAP table , would an ABAP inbound proxy would be able to work? If not , please suggest the best solution?
Quick guidance would be appreciated.
Regards..
Hi Rebecca,
I would recommend to create attachment in mapping using UDF with above method public static byte[] hexStringToByteArray(String s) output binary data.
Handle the image attachment in abap proxy according to your requirement
Best Regards,
Praveen Gujjeti
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear Praveen,
Thanks for you response.
I have selected the option Read Attachment in Operation Mapping.
I don't have experience in JAVA programs. I copied the method of the JAVA public static byte[] hexStringToByteArray(String s) into my UDF and this UDF I will place in between the Sender and Receiver BLOB field.
I have selected Execution Type as Single Value while creating the UDF.
While executing I am receiving the following error which you can observe in the screenshot.
Please correct me.
Regards..
Hi Rebecca,
Try with below UDF code and use UDF for target root node (or) BLOB field on target. Once you receive the proxy data (payload + image attachment), handle attachment accordingly. Payload has no significance as per your snap shot and I hope you are interested only with image data in ECC R/3
int len = s.length();
byte[] data = new byte[len / 2];
for (int i = 0; i < len; i += 2)
{
data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4) + Character.digit(s.charAt(i+1), 16));
}
try
{
GlobalContainer globalContainer = container.getGlobalContainer();
OutputAttachments outputAttachments = globalContainer.getOutputAttachments();
Attachment newopAttachment = outputAttachments.create("ImageFileName.jpg", data);
outputAttachments.setAttachment(newopAttachment);
}
catch (Exception e)
{
e.printStackTrace();
//throw new StreamTransformationException(e.toString());
}
return "";
//BR,
Praveen Gujjeti
Message was edited by: Praveen Gujjeti
Hi Rebecca,
Just now i have a similar scenario i've read the blob in the ORACLE system and i send it to a server abap proxy. You only need to define the file in the XML payload like string and in the ECC like rawstring and later read it in the ECC with:
I pass to form the paramater: p_blfichero TYPE fpcontent
DATA: ft_pdf_bin TYPE STANDARD TABLE OF bapiconten INITIAL SIZE 0 WITH HEADER LINE,
f_tamano TYPE i.
* Se pasa el contenido hexadecimal a binario
CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
buffer = p_blfichero
append_to_table = 'X'
IMPORTING
output_length = f_tamano
TABLES
binary_tab = ft_pdf_bin.
Now in binary mode i can write it to filesystem, document reposotory, and so on.
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.