Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
Molle
Advisor
Advisor

Introduction


In this blog post, I will present the background processing framework (named bgPF in the rest of this post). Namely, I will talk about the basic idea behind it, list possible use-cases as well as the currently available features and show integration possibilities for monitoring purpose together with the available unit test environment. Of course, I will also demonstrate a simple coding example on how to use the bgPF.

The scope of this post is to present the main functionality of the bgPF without diving too deep into some more complex areas. Therefore, some of the more advanced features will only be named but not explained in detail.


Preconditions



  • The bgPF is available available in the cloud (ABAP Environment for SAP BTP and SAP S/4HANA) and on premise starting with releases 2023

  • To work with the bgPF, you need an inbound bgRFC destination. For cloud, no further action is needed, since this configuration has been performed by SAP for you.
    For on-premise, you must create the default destination BGPF. Follow the steps below:

    • Go to transaction SBGRFCCONF.

    • Click on the tab Define Inbound Dest.

    • Press the button with the tooltip Create.
      On the Configure Inbound Destination dialog box, do the following.


      • Enter the Inb. Dest. Name BGPF.
        Do not enter information for Logon/Server Group or Add Queue Prefix.

      • Choose Save.






Use case


The bgPF is a framework that offers functionality and convenience for applications, which need to run processing steps in the background, in a reliable way. It is a simple and easy-to-use feature to execute time-consuming ABAP methods asynchronously and reliably.

 

Consider, for example, a train booking application that has a screen for calculating the best and cheapest route to a destination. If you choose an offer, the application searches for activities you can do at the destination. Often, these applications redirect you to an activities screen where you still have to wait for the results. But what if you want to search for another destination instead of waiting?

 

That's exactly where the bgPF comes in place. You can realize a workflow, which searches for activities in the background while you're on to your next journey: The bgPF offers you the functionality to execute time-consuming methods asynchronously, if you do not need the result immediately. Instead, you can continue processing and come back to the result(s) later. Realization of such a scenario is massively eased by the bgPF.

Furthermore, the usage of the bgPF does also come in handy if you need to trigger functionality in a different session than your current one – e.g., because the functionality you want to call does a database commit while you are still in the interaction phase. This makes the bgPF a powerful tool in the ABAP RESTful Application Programming Model (RAP) and its transactional control.

 

Technical background (in a nutshell)


Just like you can use a car without having to know the laws of thermodynamics, you don’t need to know the technical background behind the bgPF to use it – promised!

So, if you are not interested and directly want to get your hands dirty, you can simply skip this part and go to the next one.

But let’s be honest: It’s much more fun if you know how things work 😊

 

The bgPF is built upon the background remote function call (bgRFC) but provides easy-to-use APIs that are completely abstracted from the bgRFC.

Furthermore, the bgPF offers RAP/ABAP cloud qualities like e.g., supportability, testability, typed APIs, ADT integration, debugging, extensibility, transactional consistency, … for usage in SAP BTP, ABAP Environment or SAP S/4HANA ABAP Environment.

 

Let’s look at below diagram for a general overview: The bgPF is used by an application to asynchronously call an application layer in a different ABAP application session via bgRFC:


 

In the synchronous session, the application creates an instance of the bgPF background process, which serializes the provided background operation. The serialized operation is used as input for the corresponding function method call, which in turn is written onto the bgRFC queue and saved for execution after a COMMIT WORK statement.

Therefore any referenced object must implement the IF_SERIALIZABLE_OBJECT interface, because otherwise it is not passed from the synchronous session to the asynchronous session when being serialized.

Once the asynchronous session is triggered via the bgRFC queue, the bgPF application process is deserialized and processed.

This process is also described in the following sequence diagram:


 

 

Available Features


Currently, you can use the following features:

  • Transactional background processing

    • Service Quality: Exactly once (i.e., the operations of a background process are executed exactly once without a specific order)

    • A default inbound destination is part of the bgPF

    • Support of Transactional Control in RAP



  • Process for single Operation

    • Exactly one operation can and must be added to this process




 

Examples


Using the bgPF with transactional control


If you are working with a RAP application and want to ensure transactional consistency by using the RAP transactional control (see https://help.sap.com/docs/ABAP_PLATFORM_NEW/fc4c71aa50014fd1b43721701471913d/ccda1094b0f845e28b88f9f..., this scenario is the way to go. In the following, you will get to know the necessary steps.

As a reminder, in case of transactional control, the SAP LUW has two phases:

  • Modify phase

    • A consumer calls business object operations to change data and read instances with or without transactional changes. The business object runtime keeps the changes in its internal transactional buffer, which represents the state of the instance data. A transactional buffer is always required for a business object.



  • Save phase

    • After all changes were performed, data can be persisted.




 

Operation class


The operation class contains all the coding that shall be executed in the background session – i.e., on the asynchronous side. Let’s look at the coding for the transactional controlled operation:

 
CLASS cl_demo_bgpf_operation_contr DEFINITION
PUBLIC
FINAL
CREATE PUBLIC.

PUBLIC SECTION.

INTERFACES if_bgmc_op_single.

METHODS constructor
IMPORTING
iv_data TYPE string.

PRIVATE SECTION.

DATA mv_data TYPE string.

METHODS modify
RAISING
cx_bgmc_operation.

METHODS save.

ENDCLASS.

CLASS cl_demo_bgpf_operation_contr IMPLEMENTATION.

METHOD constructor.
mv_data = iv_data.
ENDMETHOD.

METHOD if_bgmc_op_single~execute.
modify( ).

cl_abap_tx=>save( ).

save( ).
ENDMETHOD.

METHOD modify.
IF mv_data IS INITIAL.
RAISE EXCEPTION NEW cx_demo_bgpf( textid = cx_demo_bgpf=>initial_input ).
ENDIF.

CONDENSE mv_data.
ENDMETHOD.

METHOD save.
MODIFY demo_bgpf FROM @( VALUE #( data = mv_data
changed_by = sy-uname ) ).
ENDMETHOD.

ENDCLASS.

 

In case of transactional control, your class must implement the interface IF_BGMC_OP_SINGLE. Our sample operation has input data, which is here handed over in the constructor, and shall be stored in the database table DEMO_BGPF with the following structure:

 
@EndUserText.label : 'Database table for bgPF'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #ALLOWED
define table demo_bgpf {

key client : abap.clnt not null;
data : abap.string(256);
@AbapCatalog.anonymizedWhenDelivered : false
changed_by : user;

}

 

Implementing IF_BGMC_OP_SINGLE~EXECUTE, the internal method MODIFY is called first, which checks if the input is initial. If it is, a background operation error is raised. The implementation also condenses the actual input. These actions are part of the transactional phase modify.

 

Please note:

Be careful when using member or global variable references in your operation. If a referenced object does not implement the IF_SERIALIZABLE_OBJECT interface, it is not passed from the synchronous session to the asynchronous session. Additionally, the constructor method of the operation is not called again in the asynchronous session.

 

Next, actions take place within the transactional phase save. First, we switch to save sequence by calling CL_ABAP_TX=>SAVE. Afterwards, the internal method SAVE is called and creates or modifies an entry in the database.

 

Starter class


The operation needs to be instantiated and handed over to the bgPF – this is the job of our starter class. This is the coding that is executed synchronously in the “original” ABAP application session and which triggers the background process. Let’s take a closer look at it:

 
CLASS cl_demo_bgpf_starter_contr DEFINITION
PUBLIC
INHERITING FROM cl_demo_classrun
CREATE PUBLIC.

PUBLIC SECTION.

METHODS main REDEFINITION.

PROTECTED SECTION.
PRIVATE SECTION.

ENDCLASS.

CLASS cl_demo_bgpf_starter_contr IMPLEMENTATION.

METHOD main.
DATA lo_operation TYPE REF TO if_bgmc_op_single.
DATA lo_process TYPE REF TO if_bgmc_process_single_op.
DATA lo_process_factory TYPE REF TO if_bgmc_process_factory.
DATA lo_process_monitor TYPE REF TO if_bgmc_process_monitor.
DATA lx_bgmc TYPE REF TO cx_bgmc.

lo_operation = NEW cl_demo_bgpf_operation_contr( 'Input data' ).

TRY.
lo_process_factory = cl_bgmc_process_factory=>get_default( ).

lo_process = lo_process_factory->create( ).

lo_process->set_name( 'Test process 1'
)->set_operation( lo_operation ).

lo_process_monitor = lo_process->save_for_execution( ).

COMMIT WORK.

CATCH cx_bgmc INTO lx_bgmc.
out->write( lx_bgmc->get_longtext( ) ).

ROLLBACK WORK.

ENDTRY.
ENDMETHOD.

ENDCLASS.

 

Please note:

If you are using the RAP runtime, COMMIT WORK or ROLLBACK WORK will be executed by the runtime. Do not initiate them with your own operation.

 

Starting off, an instance of the operation and an instance of the process factory for the default destination BGPF are created. The process factory is used to create an instance of a transactional background process for a single operation. After that the name of the process (here: Test process 1) is set and the operation is injected. The name of the process, for example, will be displayed in the ABAP Cross Trace – we will talk about this a little bit later. Finally, the process is saved for execution (returning an instance of the process monitor, which we will later have a closer look upon when talking about monitoring) and COMMIT WORK is executed. Without COMMIT WORK, the background process won't start. If an error occurs, an error text is displayed in the console and ROLLBACK WORK is executed to revert any changes done so far.

 

Tip

Inheriting from CL_DEMO_CLASSRUN you can simply execute your coding in the ABAP Development Tools via “Run As” > “ABAP Application (Console)” [Shortcut: F9].

 

Using the bgPF without transactional control


If you are not working with a RAP application (or do not need the strict transaction control), this scenario is the way to go. There are only some minor differences compared to our previous example:

  • In contrast to the transactional controlled behavior, there is no need to differentiate between different transactional phases. All steps can be done at once.

  • Instead of interface IF_BGMC_OP_SINGLE, your operation class must implement interface IF_BGMC_OP_SINGLE_TX_UNCONTR (and its EXECUTE method)

  • In order to add an operation to the transactional background, you must use method SET_OPERATION_TX_UNCONTROLLED (instead of SET_OPERATION)


 

The rest of the coding is identical to the previous example.

 

Monitoring your background processes


It’s crucial to know what is going on - Knowledge is power!

But who you gonna call when you want to know the status of your background processes? Monitoring, of course! Which brings us directly to the topic:

There are two principal possibilities to monitor your background processes:

  • Using the bgPF process monitor

  • By integration of other SAP functionality


 

The bgPF process monitor


This is the approach for all those of you who want to do things by themselves!

The method IF_BGMC_PROCESS->SAVE_FOR_EXECUTION returns a monitor instance for the current background process, which can be used for your own accounting and monitoring.

The underlying interface - IF_BGMC_PROCESS_MONITOR – can be used to fetch the current state of the background process:

  • If you are still in the same session that also saved the background process for execution, you can simply use method GET_STATE to fetch the current state of the background process – e.g., “New” or “Runnning” (compare to enum structure GCS_STATE in the interface)

  • If you want to save the process monitor for a different session, use method TO_STRING and store the serialized string

  • If you want to create an instance of the process monitor from a stored string, use method CL_BGMC_PROCESS_FACTORY=>CREATE_MONITOR_FROM_STRING together with the serialized string as input


 

Integration of other SAP functionality


Why invent the wheel again if there is already ready-to-use functionality?

It is possible to integrate the bgPF into other SAP functionality to monitor your background processes, namely:

  • The bgRFC monitor (no further integration steps needed)

  • The SAP Application Interface Framework (AIF) (only for OnPrem)

  • The ABAP Cross-Tracer

  • The ADT Performance Trace


 

Handling the bgRFC monitor and the integration into AIF is more complex and would go beyond the scope of this blog post, so we will focus on the ABAP Cross-Tracer and the ADT Performance Trace.

 

ABAP Cross-Tracer


To monitor your background projects via ABAP Cross-Tracer, we first need to create (via ADT view “ABAP Cross Trace” – section “Trace Configurations”) a new Trace Configuration and activate the Component Background Processing (with ID: SAP.BC.BGMC), as shown in the following figures:


 


 

Example results (in ADT view “ABAP Cross Trace” – section “Trace Results”) can be seen below – the first entry is the saving of the background processing (method SAVE_FOR_EXECUTION) – i.e., the synchronous preparation of the background process -, the second entry is the asynchronous execution of the background process:

The first entry therefore only contains the information that the background process has been saved for execution:

The second entry contains the information that the execution of the background process has started and was completed successfully:

If an error during execution of the background process occurred, we would be able to see this in the corresponding entry (together with the underlying error message – “Operation failed” in this example):

 

In short, with the ABAP Cross-Trace, we can easily check the execution status of our background processes and see – if the execution failed – the corresponding exception text.

 

ADT Performance Trace


High performer or low performer - if you are interested in the performance of your background process, you can use the ADT Performance Trace to monitor this.

In order to create to create a corresponding trace configuration, switch to the ABAP Profiling view in your ADT and select the “ABAP Trace Requests” ADT View. Right click on your corresponding project and select “Create Trace Request”. In the editor, select Remote Function Call (RFC) as type and filter for Function Module FM_BGMC_PROCESS:




 

Once your background process is finished, select ADT view “ABAP Traces” and check the second entry (the first call of the function module lies within method SAVE_FOR_EXECUTION of the background process instance – i.e., when the background process is prepared for execution - and is of no further interest here):


 

Within the resulting call sequence of the second entry, one can find the call of CL_BGMC_OPERATION_DECORATOR->IF_BGMC_OP_SINGLE~EXECUTE (or CL_BGMC_OPERATION_DECORATOR-> IF_BGMC_OP_SINGLE_TX_UNCONTR~EXECUTE for transactional uncontrolled operations) and the corresponding operations of the application, together with the corresponding performance data:


 

In short, the ADT Performance Trace can be utilized to examine the performance of your background process.

 

Writing Unit Tests for your bgPF implementation


It is always very neat to provide some unit tests for your coding – or even start with them when following the principles of test-driven development!

Therefore, the bgPF offers functionality which enables you to write unit tests for your synchronous bgPF coding: Using CL_BGMC_TEST_ENVIRONMENT=>CREATE_FOR_SPYING, you can create a test environment that offers functionality like asserting that the method SAVE_FOR_EXECUTION was called or that the number of created background processes is correct.

Let’s look at a simple example, where we will write a unit test for our bgPF-for-RAP example from the beginning:
CLASS test_demo_bgpf_starter_test DEFINITION FINAL FOR TESTING
DURATION SHORT
RISK LEVEL HARMLESS.

PRIVATE SECTION.

CLASS-DATA go_bgpf_test_env TYPE REF TO if_bgmc_test_envir_spy.

METHODS execute FOR TESTING RAISING cx_static_check.
METHODS teardown.

CLASS-METHODS class_setup.
CLASS-METHODS class_teardown.

ENDCLASS.

CLASS test_demo_bgpf_starter_test IMPLEMENTATION.

METHOD class_setup.
go_bgpf_test_env = cl_bgmc_test_environment=>create_for_spying( ).
ENDMETHOD.

METHOD class_teardown.
go_bgpf_test_env->destroy( ).
ENDMETHOD.

METHOD teardown.
go_bgpf_test_env->clear( ).
ENDMETHOD.

METHOD execute.
DATA lo_cut TYPE REF TO cl_demo_bgpf_starter_contr.
DATA lo_process_act TYPE REF TO if_bgmc_process_spy.

lo_cut = NEW cl_demo_bgpf_starter_contr ( ).

lo_cut->main( ).

lo_process_act = go_bgpf_test_env->assert_number_of_processes( 1
)->get_process( 1 ).

lo_process_act->assert_number_of_operations( 1
)->assert_is_saved_for_processing( ).

ENDMETHOD.

ENDCLASS.

 

The code does the following:

 

  • CLASS_SETUP: An instance of the test environment for spying is created.

  • CLASS_TEARDOWN: The test environment is destroyed.

  • TEARDOWN: The test environment is cleared by removing all previously created processes from the test environment. Doing so, every unit test could be started with a new test environment.
    Note:
    Do not create several test environments at the same time. If you try to create a second test environment while there is another active environment an exception will be raised.

  • EXECUTE: The actual unit test. An instance of the underlying bgPF starter (code under test) is created and executed.

    • Assert that only one background process was created (IF_BGMC_PROCESS_FACTORY) and get an instance of the first (and only) process.

    • Assert that the background process only contained one operation and that the method SAVE_FOR_EXECUTION of IF_BGMC_PROCESS_SINGLE_OP was called.




Note:

When using the test environment, the process method SAVE_FOR_EXECUTION does nothing, and the operations are not called. Instead, you can validate that the operations are instantiated and added to a process correctly. Operations need to be tested independently.

 

With this simple unit test, we have completely covered the synchronous side of our bgPF application and validated that our bgPF coding

  • Created one background process

  • Injected one background operation into our background process

  • Successfully saved our background operation for execution


 

Summary


The background processing framework is a simple and easy-to-use feature to asynchronously and reliably execute ABAP methods. It is also a powerful tool in RAP (ABAP RESTful Application Programming Model) and its transactional control.

Monitoring possibilities using bgPF intrinsic as well as separate SAP solutions are available.

A unit test environment makes it simple to write unit tests for the (synchronous-side) bgPF coding.

 

Further reading



  • For other options to asynchronously execute code using ABAP Cloud, see e.g. the following blog post

  • The SAP Help Portal entry about the bgPF can be found here


 

 
22 Comments
larshp
Active Contributor
Hi, is bgPF released for ABAP Cloud programming model?
Molle
Advisor
Advisor
Hi Lars,

yes, all public bgPF classes and interfaces are C1 released and can be used in the ABAP Cloud.
david_joseph
Explorer
0 Kudos
Why has the framework been set to trigger exactly one operation?

Since it has not been given much focus here? 5 years down the line what if we have multiple possible operations possible or say just 2.

In addition to Modify demo_bgf, there's another operation trigger_mails_to_stakeowners written in a separate operation class.

Would we need two starter classes to handle this?

This is what I felt going through the example. Can you shed some light about this rule "exactly one operation"?

 

 
Jelena
Active Contributor
Thanks for sharing! I have to admit I just briefly scanned through the text but I didn't find an answer to the questions in my mind.

Since it has "background processing" in the name, obvious question: is this like SM37 for the Cloud? The example of a user starting a query and then waiting for an answer makes me think the answer is "not really" but that triggers many follow-up questions like "can we run background job equivalent (aka SM36/37) in the Cloud and if so, how?"

I'm also curious about the "one operation" and "exactly once". With on-premise systems, many times we have no choice but to trigger a background job to perform one or more operations that would be time-consuming or not technically feasible otherwise. Even with OData services, we have to resort to this tactic still. With background jobs, we are not limited to one operation. We do usually trigger just one job though. So, is this just a way of saying that if there are de facto multiple operations, they just need to be wrapped as one? Or are there some potential pitfalls?

As a side note, it would be really appreciated by the mature generations of ABAPers if these posts pointed either similarities or differences with the old/existing functionality. It would be very helpful to understand things much faster when we can relate them to what we already know.

Thank you.

 
maulikparekh
Participant
0 Kudos

Dear @molberg86

Thank you for nice blog.

I am having a question please. I need to create a pure custom solution in ABAP Cloud on BTP (steampunk) that behaves like an executable program, running periodically in the background.

 

Thanks in advance.

Sandra_Rossi
Active Contributor
Thanks. Too bad that bgPF has objects named BGMC instead of BGPF, but well a quick search of bgPF in sap dot com will find example code with the BGMC objects 😉
mauriciolauffer
Contributor

This seems to be a new wrapping for our old bgRFC friend, it's the ABAP Cloud version. The concept is similar to regular SM36/37 jobs.

Regarding the "exactly once", it means you can add multiple transactions to the "job" and the framework guarantees they won't be executed multiple times. That's a common problem when working with queuing frameworks.

Molle
Advisor
Advisor

I agree, that's unfortunate.

We started developing the framework as "background method call" (bgmc), before it was decided that bgpf is a much better name. However, at this point, the objects were already transported through our internal systems and in use by other teams, so we could at this point not simply rename them.

Molle
Advisor
Advisor
0 Kudos

Fair question!

From developer side, there is no reason for only providing the single-operation process. However, it was decided to not provide multi-operation processes. 

Concerning your question: You would not need two starter classes.

Either you add the coding for triggering the mails into your existing operation class (which would first do the modify, then trigger the mails), or (in your existing starter class) you create another background process and add your mail operation into it.

However, with the second approach, it can not be guaranteed that the modify is done before triggering the mails.

 

"Exaclty one operation" means that you can only add one operation instance into your background process instance. How many steps your operation itself executes is not limited from bgPF side.

Molle
Advisor
Advisor
0 Kudos

I see how you connect this to SM37, but I would not say this is SM37 for Cloud.

 

With SM37, you can schedule a "complete" operation at a specific point in time and even do so periodically.

The aim of bgPF is that you are currently executing some operation and want to put certain long-running sub-tasks into the background. In the example, the booking application would still be running normally, only the part for finding the activities is executed in the background. That is not the classic usage of SM37.

You can also see the difference to SM37 when coming to your second question: "can we run background job equivalent (aka SM36/37) in the Cloud and if so, how?"

In principle, you could simulate something like this by writing a starter class that has a DO...ENDDO loop and several WAIT UP TO commands, but this would be very crude! Again, the aim of bgPF is not "SM37 for Cloud".

 

That's why I am also a little bit sceptical about your idea of using comparisons between old functionality and the new one: It does not always match and might lead to confusion.

 

Concerning your question about single/multi-operations, see my previous comment 

Molle
Advisor
Advisor
0 Kudos

Unfortunately, this is not the scope of the bgPF.

See also my previous comment.

WRoeckelein
Active Participant
Molle
Advisor
Advisor
0 Kudos
Ps: A colleague of mine just informed me about another blog post that might help you with this task.
glensimpson
Explorer

I think the successor to background jobs (SM36/SM37) is the "Application Job", isn't it?

 

This blog gives a useful comparison between the different ways to execute code asynchronously, including bgPF, application jobs and events:

https://blogs.sap.com/2023/10/11/asynchronous-code-execution-using-abap-cloud/

 

BTW, I agree with Jelena's idea that being able to relate new functionality to old functionality is very useful, even if it isn't a 1:1 (or "apples to apples") comparison.

ChristianGünter
Contributor

Hi Andreas,

nice blog, thanks for sharing.

I struggle a bit with the unit test example as cl_demo_bgpf_starter_contr doesn't have a method execute. Or does it and it's just missing in the listing above? Maybe I miss the obvious.

Regards

Christian

Molle
Advisor
Advisor
Hi Christian,

 

you are not missing something, I unfortunately did.

 

cl_demo_bgpf_starter_contr had originally an execute-method, but then I changed the class to inherit from cl_demo_classrun and renamed the execute-method to main in accordance with the super-class.

But I forgot to rename the method in the Unit Test example. Sorry for the confusion!  I will correct that.

 

Thanks for the hint!

 

Best regards,

Andreas

 
Jelena
Active Contributor
0 Kudos
OK, that makes more sense now. Thank you!
Jelena
Active Contributor
0 Kudos
Thanks for the link! There is a comment in that other blog that someone is trying to use bgPF instead of FM "in background task" option and I guess that's the similar old option. Definitely a challenge there with the word "background" used in so many different contexts in SAP. 🙂
ajith_urimajalu
Participant
0 Kudos

@Molle - I tried using bgRFC (cl_bgmc_process_factory, if_bgmc_op_single) within a RAP behavior implementation, but its dumping with a weird error. It looks like system is just checking if the method name contains "save", which does not make much sense.  

Short Text Statement "CALL " is not allowed with this status.

Runtime Error BEHAVIOR_ILLEGAL_STATEMENT

Program ZCL_BGRFC_TEST================CP

 

What happened?

Error in the ABAP application program.

The current ABAP program "ZCL_BGRFC_TEST================CP" had to be terminated because it found a
statement that could not be executed.

Error analysis

Execution takes place in a transactional context: A BO implementation
is active for "ZTEST_R_RAP_TEST". Statement "CALL <save>" is therefore forbidden. In the case of
statement MESSAGE, the message text is as follows: "???" The actual error
is probably not located in the program where the termination occurs but
at a higher call level from which the program was called in an illegal
BEHAVIOR phase.

The reason for the runtime error (see the list below) is: (1)
Runtime errors in connection with contract violations can occur for the
following reasons: (0) This contract violation always causes an error
to occur. (1) It is required by the "strict” specification in the
current BO. (2) It is required by the "strict” specification in the BO
that is called. (3) The contract violation occurs in Restricted ABAP.
(4) The corresponding checkpoint group is set to "error". (5) The
violation occurs in a BO enhancement in Restricted ABAP.
The statements
- CALL FUNCTION IN UPDATE TASK
- CALL FUNCTION IN BACKGROUND TASK/UNIT
- PERFORM ON COMMIT/ROLLBACK
are not allowed outside of the "Save" method.
Operations that result in the commit of the primary DB connection (such
as RFC, HTTP, WAIT, and commit via EXEC SQL) are not permitted in the
"Late Save" phase (methods "Adjust_Numbers" and "Save").
&ABAPDOCU ABENDB_COMMIT
&ABAPDOCU ABAPRAP_IMPL_RULES
The following restrictions apply to (BAdI) methods and functions with
transactional classification:
It is not possible to call a method transactionally classified as
"Save" from within an interaction phase or from a method with a
contract other than “Save” or "Surface".
A method classified as "Read" can only be called if "READ ENTITIES" is
also allowed.

Information on where terminated

The termination occurred in ABAP program or include "ZCL_BGRFC_TEST================CP", in "PROCESS". The
main program was "SAPMHTTP".

In the source code, the termination point is in line 25 of include "ZCL_BGRFC_TEST================CM001".
include "ZCL_BGRFC_TEST================CM001".

Source Code Extract

15161718192021222324>> 26272829303132

iv_error_block = 'Test' ). TRY. lo_process_factory = cl_bgmc_process_factory=>get_default( ). lo_process = lo_process_factory->create( ). lo_process->set_name( 'Test process 1' )->set_operation( lo_operation ). lo_process_monitor = lo_process->save_for_execution( ).  CATCH cx_bgmc INTO lx_bgmc. ENDTRY. ENDMETHOD.

 

Molle
Advisor
Advisor
0 Kudos

@ajith_urimajalu Looks to me that you forgot to switch phases using 

	cl_abap_tx=>save( ).

You can check here for more information about RAP transactional model.

ajith_urimajalu
Participant
0 Kudos

@Molle - Thanks for the feedback. I tried this during the Interaction phase ( CL_ABAP_BEHAVIOR_HANDLER), but still get the same error. 

Molle
Advisor
Advisor
0 Kudos

@ajith_urimajalu Without knowing your whole coding and being able to reproduce this issue I can not tell you what is going wrong here.

Best would be to open a ticket on the component that owns the transactional behavior and let them check it: BC-ABA-LA