cancel
Showing results for 
Search instead for 
Did you mean: 

Conversion of string to BLOB format

Former Member
0 Kudos

Hi,

Scenario is proxy to JDBC:

I have a requirement where my PFD file name is maintained in one ABAP R3 table and I need to convert the PDF file name to BLOB format.

Is there any function module available in R3 for converting to BLOB data type. or java mapping is required in graphical mappping for this conversion.

My pdf file name is:

SHELL_INC_123456789012_851000000005290_DE_04_2008.pdf

Thnx

Chirag

Accepted Solutions (0)

Answers (2)

Answers (2)

aashish_sinha
Active Contributor
0 Kudos

Hi Chirag,

I don't think there is any FM in ABAP is written for this purpose. you should need to write an UDF. Also my concern is that "where is the PDF file located"? If the answer is "on a file system accessible to the Oracle database" Then you can use directory objects and the DBMS_LOB package. It would look something like this:

as SYS user do:

-- assume the PDF files are in /data/documents filesystem directory

create or replace directory pdfdir as '/data/documents';

grant read on directory pdfdir to <USER>;

as USER do:

create table mydocs (id integer primary key, doc blob);

declare

bf bfile;

b blob;

src_offset integer := 1;

dest_offset integer := 1;

begin

' insert a new blob and return it to local variable

insert into mydocs values(1, empty_blob()) returning doc into b;

' open the bfile for file "summary.pdf"

bf := bfilename('PDFDIR', 'summary.pdf');

dbms_lob.loadBlobFromFile(b, bf, dbms_lob.lobmaxsize, dest_offset, src_offset);

' done

commit;

end;

I assumed that you are working with 2 different machines, one client, one server.

If you are working on a single machine, there may be a simple bug in the code.

try adding the line

dbms_lob.open(bf, dbms_lob.file_readonly);

between the calls to bfilename() and loadBlobFromFile()

Also if you want to do this using java then please have a look in this link.

http://publib.boulder.ibm.com/infocenter/idshelp/v111/index.jsp?topic=/com.ibm.jccids.doc/com.ibm.db...

Hopefully this will help you.

Regards

Aashish Sinha

Former Member
0 Kudos

Hi,

Swarup:

ye we do ahve oracle data base at the receiver end. The data needs to bo in BLOB or hexadecimal format.

Aashish:

Proxy will send the PDF file name to XI we r not storing any file on R3.

The code which is provided by u n aashish has to be written on DB side but I need to send direct blog data through XI to DB.

Is there any way we can achieve this.

Thnx

Chirag

Former Member
0 Kudos

Hi,

Any other way to do it.

Aashish,

U mean to say if we write code on JDBC side then it will convert the data into BLOB and store it in DB. This is what u mean to me.

Swarup:

Writing only two statement convert the data to BLOB format?

Thnx

Chirag

aashish_sinha
Active Contributor
0 Kudos

Hi Chirag,

Exactly. That is what i want to convey. You can try to write it in JDBC side and check how it behaves. But in anycase if it fails, you can write the Advance UDF to solve your problem and you can use multipart or something i don't remeber now. i did this a long time back in my earlier company.

I guess, your requirement is to get file name from the SAP (which is stored somewhere in SAP and you know the place n how to fetch the file name), depending upon this filename, you will retrieve it from somewhere from SAP server if name matches, and then you will send the file which will be in PDF format to XI in some stream say bytes, and using XI you will convert it in BLOP datatypes n save it somewhere.

I guess you can use this code in JDBC side. but i'll prefer Advance UDF, coz java provides some flexibility in this context.

Regards

Aashish Sinha

Former Member
0 Kudos

HI,

In R/3 you could take the data type as XSTRING for byte strings.

A byte string is a hexadecimal type with variable length. It can contain any number of bytes. The length of a byte string is the same as the number of bytes.

ABAP contains statements that allow you to read and set the individual bits in a type X field. There are also special logical operators that you can use to compare bit sequences.

Here you have to use in ABAP code as

for e.g.

ASSIGN L_HEX TO L_Char CASTING .

The idea is to convert L_HEX (hexadecimal value ) to character .

Refer

http://help.sap.com/saphelp_nw04/helpdata/en/b6/e7d716f46711d195200000e8353423/content.htm

If you are able to send it to XSTRING type that will convert to hexadecimal format.

Hexadecimal format means the numbers only so you could pass it as characters to XI. from XI pass it to Blob fields in Oracle where these noumbers will be treated as hexadecimal value and the data will be passed successfully.

Thanks

Swarup

Former Member
0 Kudos

Hi,

thanks for the valuable information. Let me try this out both the options and will get back to u.

I m not getting the reward point option?I have no idea What wrong I have done.

Thnx

Chirag

Edited by: Chirag Gohil on Feb 27, 2008 1:56 PM

Former Member
0 Kudos

HI Chirag,

Rewarding points will not be imp thing.

I will be happy if your problem get resolved..

Have a nice day. Please update me about your trials.

Thanks

Swarup

Former Member
0 Kudos

HI Swarup & Aashish,

I have developed adapter module which first convert the string to byte and then byte to BLOB and it worked for me.

Thnx for ur valuable input.....

Chirag

Former Member
0 Kudos

Hi Chirag,

So at last you would have to go for Adapter Module only. Thats good to hear that now the problem is resolved.

It means you have tried with the conversion in R/3 also and that isn't worked. Its unexpected. But can you tell me the exact updates about the results of previous ways.

It will help to know few more things about these kind of conversions.

Because Its very rare to come acorss these kind of requirements.

Thanks

Swarup

Former Member
0 Kudos

Hi Swarup,

I forgot to specify one more requirement,we need to read the smartform from R3 application system which I forgot to mentioned in the thread.

There are function modules in ABAP side but it didnt worked out for me.

FM:

NLS_STRING_CONVERT_TO_SYS( Hex to char)

and NLS_STRING_CONVERT_FROM_SYS (char to hex).

Also we dont want to try to convert the data into BLOB format at DB side as we dont hav control on DB side.SO we have to try on XI side only.

As aashish suggested to go for advance java function. hence we tried to go for adapter module rather than advance java.

U will have questions why to convert the data into BLOB as blob consumes very large space.

client has existing functionality where one system reads the BLOB data from DB and shows the data into smart form format and we done want to change the existing functionality as well hence we have gone for converting the data into BLOB format.

Thnx

Chirag

Edited by: Chirag Gohil on Mar 1, 2008 7:21 PM

Former Member
0 Kudos

Hi Chirag,

WELL EXPLAINED.. Thanks for the calrification.

You was ready with answer for my next doubts of using the BLOB....GR8,....:-)))

Thanks

Swarup

Former Member
0 Kudos

Hi Chirag,

Can you please let me know how you have converted from byte to BLOB and also how you have developed the adapter module.

Thank you,

Sridhar.

Former Member
0 Kudos

Hi Chirag,

this is not a usual requirement since BLOB type is used for Binary Objects (pics, docs,..). However, I think there should be no problem to save a text in this column type. Are you getting any error from the system?

Peter

Former Member
0 Kudos

Hi,

Thnx for the reply.

I m thinking in respect to the Design Aspect.

if there is a std SAP ABAP function module then I will go with client proxy and use that FM to convert the format to BLOB format and if there is no standard FM available then I will go with javamappping with client proxy.

So I m looking for ABAP FM or javamapping.

Thnx

Chirag

Former Member
0 Kudos

Chirag,

I'm not sure if I understand you right. You have a source (abap client proxy) and need to write data to target DB, right? So you send file name and need to "save" it in target DB..

Well, I don't think there is any conversion needed. You have a file name as a text and need to save it as a text. What do you want to convert it to? I think, text data are the same in both text/binary format..

But I think the problem will be in the target database - working with LOBs (large database objects) is not the same as other standard types. So I think, it is not possible to use just standard INSERT statement. This won't work. You'll need to call a stored procedure in that DB.

However, I still don't understand, why you need to save a text in a BLOB (binary LO) type. Maybe this is not technically possible at all. (Try it w/o XI, just simply to store text there). I would understand CLOB (character large object).

Peter

Edited by: Peter Jarunek on Feb 26, 2008 11:13 AM

Former Member
0 Kudos

Hi Chirag,

There is no Function Module available in R/3 for such conversion. you could do this with write statement

I think you need to convert the name of file to BLOB format. Are you using the Oracle database because the BLOB is used with Oracle.

In R/3 its nothing but RAW type with length 255.

So probably you could use the Write statement for conversion to BLOB format. somthing like below

Data i_blob type blob.

Write i_fileName to i_blob.

Let me know if it works for you.

Normaly when we used the Blob in generic IDOCs while processing the fields are added to BLOB field with Write and concat statement.

I am not sure if you I clarified it. I kindly request you to rectify me if there is any another interpretation I did.

Thanks

Swarup

Edited by: Swarup Sawant on Feb 26, 2008 11:49 AM