cancel
Showing results for 
Search instead for 
Did you mean: 

How to handle BLOB field in receiver JDBC adapter into ABAP table

Former Member
0 Kudos

Dear Experts,

I am working in a synchronous scenario with Sender ABAP Proxy to Oracle Database as receiver via SAP PO 7.4.I will be calling a stored procedure view with fields ID, NAME,Age,Sex and BLOB (Image binary).

1. The response from Oracle Database field BLOB is to be stored in ABAP table.Would I have to write any JAVA program to read the BLOB or the receiver JDBC adapter will handle it and store in a table by using ABAP proxy once it reaches ECC.

2. If yes, would the JAVA program have to deal with other 4 fields.

3. Can I use a UDF mapping to this BLOB field.

Regards

Rebecca...

Accepted Solutions (1)

Accepted Solutions (1)

former_member181985
Active Contributor
0 Kudos

Hi Rebecca,

Now I have a bit more clarity on your requirement. In addition to my reply to your comment in my blog:

In response graphical mapping from JDBC to ABAP proxy, use UDF code same as method "public static byte[] hexStringToByteArray(String s)" that I have mentioned in blog. Using the byte data, create binary attachment in mapping for abap proxy response

Handle attachment on SAP according to your requirement

Hope this helps

Best Regards,

Praveen Gujjeti

Former Member
0 Kudos

Dear Praveen,

Thanks for your response...

Please correct me if I am wrong.

1. For 1-1 response mapping for BLOB field, I will use just use the below UDF code.

  1. public static byte[] hexStringToByteArray(String s) { 
  2.             int len = s.length(); 
  3.             byte[] data = new byte[len / 2]; 
  4.             for (int i = 0; i < len; i += 2) { 
  5.                         data[i / 2] = (byte) ((Character.digit(s.charAt(i), 16) << 4
  6.                                                                                      + Character.digit(s.charAt(i+1), 16)); 
  7.             } 
  8.             return data; 

2. ===Using the byte data, create binary attachment in mapping for abap proxy response===

Could you please share how to create the binary attachment.. I am not clear

Regards...

former_member181985
Active Contributor
0 Kudos

Yes, your understanding is correct.

Steps,

  1. * Enable "Read Attachments" option in interface/operation mapping
  2. Create a UDF for response graphical mapping with input fields s, and then copy below code AS-IS.  Now, use this UDF between JDBC response structure blob input field and root node of target abap proxy response structure


//Map this UDF output to root node of target ABAP proxy response structure (preferably)

GlobalContainer globalContainer = container.getGlobalContainer(); 

OutputAttachments outputAttachments = globalContainer.getOutputAttachments(); 

AbstractTrace trace = container.getTrace(); 

int len = s.length();//s is UDF input: for JDBC response BLOB hexadecimal string

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 

{    

  trace.addInfo("Creating Binary image attachment in mapping... "); 

  Attachment binaryImageData = outputAttachments.create("YourImageName.jpg", data); 

  outputAttachments.setAttachment(binaryImageData);            

}catch (Exception e){ 

  trace.addInfo("Error while creating attachment... "); 

  throw new StreamTransformationException(e.toString()); 

return "";

BR,

Praveen Gujjeti

Answers (0)