cancel
Showing results for 
Search instead for 
Did you mean: 

Change configuration data in VA01/VA02

Former Member
0 Kudos

Hello, everyone.

I have a task to alter position configuration data (the one that's shown in Extras - Configuration) when order is saved in VA01/VA02.

What I do is the following:

  1. Make use of USEREXIT_SAVE_DOCUMENT_PREPARE;
  2. Fetch current position configuration using  CUCB_GET_CONFIGURATION FM and passing VBAP-CUOBJ for the INSTANCE parameter;
  3. Make necessary changes in the configuration;
  4. Make sure the OWNER field of the configuration is filled correctly: OBJECT_TYPE = 'VBPS', OBJECT_KEY = VBAP-VBELN && VBAP-POSNR;
  5. Save changes using  CUCB_SET_CONFIGURATION.

The code seems to work fine for the existing positions. However, when a position is added, the configuration changes are not saved after saving the order. My guess is that CUCB_SET_CONFIGURATION needs position to exist already in the database.

So, the question is: are there any workaounds or other solutions?

I know, I can move all my code to a custom RFC-enabled FM and call it with a STARTING NEW TASK addition. The FM body will then wait until order is saved and update the configuration data. But RFC-call causes an implicit commit, which is apparently undesired inside a user-exit.

Thank you in advance.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member

Just in case anyone cares, the solution seems to be found: config can be changed using cl_cbase class. The call sequence is the following:

cl_cbase=>get_current_cbase_by_instance( iv_instance = vbap-cuobj iv_check_only_buffer = 'X' ).

cl_cbase->get_configuration

change config as needed

cl_cbase->set_configuration

cl_cbase->set_mark_for_saving


Methods are called inside USEREXIT_SAVE_DOCUMENT_PREPARE.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Alex,

Why don't you go for V2 Update module as V1 is where the order will be updated and you don't have to be concerned about explicit commit as SAP will take care of it.

R

Former Member
0 Kudos

I've tried running my FM (that does all described above) via CALL FUNCTION ... IN UPDATE TASK setting it up as V1 or V2 module - no luck. It looks like this way updates do not happend at all, even for the existing positions.