How to test an RFC module that exists only in remote system? - abap

I'm debugging a solution where a program in one SAP system (A) calls a remote-enabled function module in a different SAP system (B) via RFC connection.
Is there a way to 'test-run' the RFC from A, like we normally do with SE37 for local function modules? The remote function module does not exist in A, so SE37 just gives an error message that the function module does not exist.
I can run the function module in B using SE37, but I need to test it over an RFC connection.

Two options in the calling system:
Create a shell ABAP program to call the FM, run in SE38;
Create a shell of the FM with just the parameters, run in SE37.
I do not believe there is a way to do this without any programming in the calling system. To generate the test environment in SE37 the transaction needs to know the interface of the FM.

Related

Whats the relation between a module and a process in Erlang

I am new to Erlang trying to understand what's the relation of a module and a process in Erlang.
Dose each module spun up a new process in BEAM ?
When we call a function from another module is there message passing been done between two process ?
I tried to search go through Erlang docs, while working on a existing Erlang code
Functions execute inside processes, whether they are defined in a module or not.
Dose each module spun up a new process in BEAM ?
Nope. You can define 50 modules and the functions therein can all execute in a single process. Modules are more like namespaces.
When we call a function from another module is there message passing
been done between two process ?
There aren't two processes unless you start two processes.
Message passing between processes is done by calling send/2 or using the operator !. Messages are read inside a process using a receive clause.

Copy code and data types of namespace /FOO/ to second SAP system

During the last weeks I developed some code with the namespace/prefix /FOO/. The namespace is official. It is registered at SAP.
If a second customer wants to use our code how one can transfer all code and data from this namespace from one sap system to a different sap system?
Under this namespace there are some data types and some abap code, some old SAP only (netweaver 7.4), no HANA.
This question is not about the usual transport (dev -> qual -> prod). This works.
Related: https://github.com/guettli/why-i-like-django-and-sap/blob/master/README.md#packaging
Here is how you could do that without the access to the operating and file system.
Release your workbench transport containing your code (either in SE01 or SE10).
Each time you release a transport two files are written in data and cofiles directories which can be found in the DIR_TRANS directory (see AL11). Those files are named exactly like your transport with R and K prefix and the extension which is named after the SAP system name, let it be XYZ for the sake of this example.
Start the command line in SAP GUI with the report RSBDCOS0 (transaction SE38).
Set the working directory to a directory of your choice and create there a folder named transport containing two subfolders data and cofiles.
Copy transport files into the transport directory in your working directory. On Windows system it could look like that.
copy %DIR_TRANS%\data\R<your_transport_number>.XYZ .\transport\data
copy %DIR_TRANS%\cofiles\K<your_transport_number>.XYZ .\transport\cofiles
Pack the contents of the transport directory in your working directory using SAP Archiver (sapcar) application. On a Windows system it could look like that.
cd transport
sapcar -cvf XYZK<your_transport_number>.SAR data\R<your_transport_number>.XYZ cofiles\K<your_transport_number>.XYZ
Download the file from the application server to your local client for example with SE37 and function module ARCHIVFILE_SERVER_TO_CLIENT.
Upload the file to the target SAP application server with function module ARCHIVFILE_CLIENT_TO_SERVER.
Start operating system command line in the target server like you did in the point no. 3.
Unpack the SAR file.
sapcar -xvf XYZK<your_transport_number>.SAR
copy cofiles\K<your_transport_number>.XYZ %DIR_TRANS%\cofiles
copy data\R<your_transport_number>.XYZ %DIR_TRANS%\data
Go to transaction STMS and refresh your transport import queue. The transport you wanted to import in the first place should now be visible in the queue.
%DIR_TRANS% has to be replaced with the directory you can see in the AL11 of source and target system.
You can try new SAP transport system that is promoted actively for new environments like S4HANA and is recommended as a replacement to CTS+, it is called abapGit.
Objects with namespaces /FOOBAR/REPORT are serialized with abapGit to #foobar#report.prog.abap
To move objects in customer namespace you need to create this namespace in the target system:
Create namespace in SE03, namespace role = C, and add the repair license
Open namespace for modifications in SE03
Create namespaced package
Change package original system to current in SE03 -> Change Object Directory Entries
Clone/pull like normal
then pull them in a regular way via Git, they should appear in the customer namespace.
If all the namespaced objects are stored in the same package, the task is much simpler for you, read here about moving whole packages.

Make SAP Report available via RFC

One customer wants to access a SAP report via RFC.
Steps:
Third party application connects to SAP via RFC
RFC call gets transmitted
SAP runs the report
SAP returns the report.
How can this be implement the part inside SAP?
I am using PyRFC as client library. But AFAIK this does not matter at all for this question. This question is only about the server part inside SAP.
In this case it is the report RM07MLBS which should be made available via RFC.
You need an ABAPer to make a function to you, I think there's no way without it.
If you have a ABAPer just do something like this:
SUBMIT <REPORT_NAME> ... EXPORTING LIST TO MEMORY AND RETURN.
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = t_listobj.
CALL FUNCTION 'LIST_TO_ASCI'
TABLES
listasci = t_ascilist
listobject = t_listobj.
Now you have the list in ASCII format, you can convert it to what you want.
Another way is send the report result to spool, get the spool and convert it to HTML/PDF.
To convert Spool you can use this functions:
RSPO_RETURN_ABAP_SPOOLJOB
RSPO_RETURN_SPOOLJOB_DAT
RSPO_RETURN_SPOOLJOB_HTML
In a perfect world, you'd have the report logic encapsulated in an abap class or a dedicated function module and use that as the basis for both your report and the RFC calls. But if this is a standard SAP report and SAP themselves weren't nice enough to provide said function module, you may not have this option.
I don't think this is the best solution for your request, but just to add another option to the ones already mentioned in other answers: the commercial product Theobald Xtract Universal can execute reports and return the results using several available destination types. Xtract is a windows service that offers connectivity to several target database types as well as a http based result stream. It isn't cheap though, and it essentially only can connect to SAP Netweaver based systems as its data source (at least S/4 is already supported). Target destinations have to be purchased extra, but at least not per system, only per destination type (Oracle, MySQL, MSSQL...).
https://theobald-software.com/en/xtract-universal/
Xtract Universal uses a number of customer function modules to execute the report in the target system, catch the output and return it, essentially as a wall of text. You'll have to parse that result yourself, you won't get a nice pre-parsed table with data in it.
Just to make sure there's no misunderstanding about a possible conflict of interest: I don't work for Theobald, but we are a paying customer and use Xtract for our own data extractions. It is very simple to use, can be executed in scripts, but as said, just does that one job.
As far as I know there is a limited possibility to trigger a report via a rfc-enabled function module. Otherwise try triggering a transaction (based on your report) via function module.
Also check: https://archive.sap.com/discussions/thread/811196
I dont think that you are able to respond the report result to your third party system.
From consulting perspective I would recommend running the report periodically, write results in a table, fetch data from table (from third party system) via RFC-enabled function module.
The best way to do this would be to wrap your report in a bespoke Function Module that is RFC Enabled, then give them access to run that RFC Function Module.

FM to Download ABAP report output to PC as text

Is there any function module aside from GUI_DOWNLOAD to download the ABAP report output?
When you say "ABAP report output", I am guessing you mean the list output.
You can use function module DOWNLOAD_LIST from within an ABAP report program to download the list, or any of the current lists in the stack.
Alternatively, use function module LIST_TO_ASCI to get the list into an internal table, then download it with CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD (GUI_DOWNLOAD will work, but it is recommended you use CL_GUI_FRONTEND_SERVICES instead). (Look at function group SLST for some other interesting list processing functions).
If you didn't mean the list output, then in general use CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD for downloading internal tables.
That is of course, if you are looking to download to the client PC. If you want to create a file on the application server, look at the keyword help for OPEN DATASET and related commands.

Why is KOFAX SAP Function Module Z_DICOM_STORE_USING_FB60_FB65 not being Populated when Run?

We have upgraded our development SAP system from ECC6 SPS3 to ECC6 SPS5.
An application external to SAP (KOFAX - a SAP certified product) passes an invoice image and invoice data to the SAP system. It then calls the Function Module Z_DICOM_STORE_USING_FB60_FB65 (supplied by KOFAX) in order to store the image on the SAP Content Server and trigger a workflow.
Before the upgrade of the SAP system, this worked, now it does not. An exception is raised within form check_and_add_delimiter (subroutine pool SCMS) which is effectively called from function module SCMS_ARCHIVE_INFO_GET.
The exception is raised because when class method CL_GUI_OBJECT->CLASS_INIT is called, the flags:
GUI_IS_RUNNING
ACTIVEX
JAVABEAN
WWW_ACTIVE
are set to blank values.
This happens when the process is kicked off from the KOFAX GUI. If I run Z_DICOM_STORE_USING_FB60_FB65 from transaction SE37 and populate the structures with the same data, the image is stored and the workflow is triggered.
Please can you suggest why the flags are not being populated when the program runs?
Thanks.
This is a "technical duplicate" of you other posting. Again, the issue is clear - the "KOFAX GUI" appears to use a RFC connection to call the function module, but the function module then uses some other stuff that requires not a RFC connection, but a full-blown SAP GUI at the other end because it tries to access SAP GUI attributes. I'm not into CMS, so I can't help you to figure out why this was changed during the upgrade...
For most scenarios a normal RFC connection is sufficient, SAP GUI is only required if you try to execute BDC within the function module (e.g. for "direct posting"). Since you say that it worked before I can only assume that this is not the case.
Could it not be that the error happens during the upload of the image? Maybe the upgrade did something to the content server configuration? There is a test program for the content server that you can run.
This was resolved by one of our develpers. The answer he gave me was:
We modified check_and_add_delimiter
(subroutine pool SCMS) in order to
overcome this problem (we effectively
stopped the bit of offending code from
being called)