cancel
Showing results for 
Search instead for 
Did you mean: 

How to wrap a SAP Report/Transaction to a RFC or BAPi

Former Member
0 Kudos
344

Hi

I was trying to figure out if there is a way to wrap SAP Report or Transaction into an RFC/BAPI, so that it can be called from a JCo.I guess if it is possible it would save a lot of time in writing BAPIs( which provide the same functionality as the std report/transaction).

Please help me figure it out.

Accepted Solutions (0)

Answers (1)

Answers (1)

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

Yep, you can, I just did one that updates delivery schedules. I did it using BDC. Just create a remote enabled function module, define the import parameters and put the code inside. That's it.

Regards,

Rich Heilman

Former Member
0 Kudos

HI

What you said is true if i want to populate data or update data in SAP.

My requirement here is to send the parameters from JCo and execute the SAP report and send the results back to the Calling java program.

Former Member
0 Kudos

Sure you can do that too. Look at all those 'Get Detail' BAPIs. That is what they do. They pass, let us say a customer number and it returns you with the details of the customer.

Now you must remember though that you cannot have a dialogue using a RFC. By that I mean there cannot be any pop-ups or screens in that module that are not handled by the code. Next thing to remember is that if you are planning on executing a report using a RFC, you can export the spool back but not the data. When you execute a report in SAP, it gives you a formatted output either onto the screen or to a printer. So this even you read this output, it will not be like returning an internal table to you.

Let us take an example of a report that writes out the material number and the material description, by taking a range of materials from the selection screen. The output may be formatted as below.


|-------------------------|-------------------------|
|      Material           |      Description        |
|-------------------------|-------------------------|
|       1234              |  material 1234          |
|       5678              |  material 5678          |
|-------------------------|-------------------------|

Now, once this is output, it is just plain text as a series of lines. So even if you read this output into an internal table, it will be one record for each line having the content of each line, including vertical and horizontal line characters.

You may have used an internal table of two fields(MATNR, MAKTX) to write this output, but that internal table is no longer available to you, once you wrap the execution of the report in a RFC. You have to make some changes to your report such that, if it is called from an RFC, it gives back the internal table and if it is called from within SAP, then it gives the output as above. The other tedious option is that you take the output containing the lines from the report and then parse through it for identifying your data. In which case you have to exactly know the line, position and length of each output field. If there are some changes made to the output the you have redo all your parsing logic.

Hope this helps, and please don't forget to reward the ones that help you.

Srinivas