Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Uploading File using a BAPI

former_member715991
Participant
0 Kudos

Hello,

I have created a BAPI which is exposed as a webservice and is called in JAVA program.

I need to upload a file from JAVA Client into SAP and attach it to the claim.

I am using FM BDS_BUSINESSDOCUMENT_CREA_TAB

but this Fm requires file content in XSTRING. HOw do i get the XSTRING of the file ..???

If anyone has a different view of uploading the file please suggest.

Thanks,

Swati

1 ACCEPTED SOLUTION

brad_bohn
Active Contributor
0 Kudos

Did you do a where-used on the function for examples? Or look at test program BDSTESTOO? Why do you think the data has to be in XSTRING format?

16 REPLIES 16

brad_bohn
Active Contributor
0 Kudos

Did you do a where-used on the function for examples? Or look at test program BDSTESTOO? Why do you think the data has to be in XSTRING format?

0 Kudos

FM BDS_BUSINESSDOCUMENT_CREA_TAB that i use, accepts file content in Binary format .

So if i get the XSTRING of the file i can convert it to binary and pass it to my FM.

Thanks.

Former Member
0 Kudos

Swati,

I have used some of these FMs in the past for similar needs:

SCMS_BINARY_TO_XSTRING

SCMS_FTEXT_TO_XSTRING

SCMS_STRING_TO_XSTRING

SCMS_TEXT_TO_XSTRING

SCMS_XSTRING_TO_BINARY

0 Kudos

These are not RFC ... i can not use them in my BAPI

Do you have another idea for uploading file in sap using BAPI ...

Former Member
0 Kudos

If you have a custom Web Service (which sounds like a Provider WS), then after the WS gets the file from the client - call the appropriate FM from my list (it does not need to be remote-enabled once inside of SAP) and convert the file into XSTRING format.

Former Member
0 Kudos

Sawti,

I guess I am unclear as to which application is in control of the transaction - is the Java client in control or SAP?

By default - SAP provides many methods to upload a file from any client.

brad_bohn
Active Contributor
0 Kudos

These are not RFC ... i can not use them in my BAPI

Of course you can...what makes you think that? But there are more up to date ways to convert if you'd peruse the ABAP syntax or search the forums. Your content, however, doesn't even need to be binary in format...

0 Kudos

Thanks for everyones input..

Java client is calling the WS. How do i upload file present in Java Client to SAP??

GUI_upload doesnt seem to work ..

Please help.. since i could not get it uploaded i thought getting file in binary format would help me ..

Please guide if i am heading to a wrong direction .

Thanks again

Swati.

brad_bohn
Active Contributor
0 Kudos

Java client is calling the WS. How do i upload file present in Java Client to SAP??

GUI_upload doesnt seem to work ..

GUI_UPLOAD will not work in an RFC. Either load the file in the Java app (binary or base64 encoded) and transfer it via your BAPI call or mount the location on your app server and load it using OPEN DATASET/READ DATASET/... as usual.

0 Kudos

Could you please elaborate on the methods that can upload file from any client.

Former Member
0 Kudos

Swati,

OK - so the Java Client is in control of the transaction.

On what hardware and OS is this Java Client running? Is the hardware "hard-wired" to the same network that holds SAP? Or you trying to upload from the BlackBerry or the like?

0 Kudos

No the JAVA system is not at all connected to our SAP system..

They have a JAVA application , this calls our BAPI..

File is in JAVA Client ... somewhere in their directory structure.. so SAP does not have access to file..

here is the problem of uploading the file..

Please guide.

Any help will be appreciated

0 Kudos

See Brad earlier reply. You have to mount the file system. Did you ever talk to BASIS people about this issue. If not, ask them if they can mount the file system that is in the structure (java file system or whatever it is). They should have answer for you. From ABAP side, it is either use GUI functions if accessing via GUI else use Read data set function to read from application server which i meant file system

0 Kudos

OK . I guess i have only 2 options left now..

Either connect to their file system and mount file in our application server

OR

get the file content in BInary format and then try attaching .

I will 1st try 2nd options if it works good.. other wise i have no option but 1st.

Thanks.

0 Kudos

Either way, Post your solution here. Helpful to others.

Former Member
0 Kudos

Hi Swathi,

This Function Modules may helpful to you.

NLS_STRING_CONVERT_FROM_SYS

NLS_STRING_CONVERT_TO_SYS

Thanks & Regards,

Bhargav.