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: 

okcode and subscreen

former_member182371
Active Contributor
0 Kudos

Hi,

- in transaction miro i´ve implemented a badi.

- in this badi there is a subscreen.

- within this subscreen i´ve created a button.

my problem is that once i´ve clicked the pushbutton, the value of sy-ucomm is the correct one (let´say DOSOMETHING).

but if i do just INTRO (not clicking the pushbutton), in pai of the subscreen the value of sy-ucomm keeps the former value of the pushbutton (that is DOSOMETHING).

If i try clear sy-ucomm or something similar it does not work because the value is not cleared.

How can i solve this?

Best regards

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Pablo,

System fields should never be changed/altered manually, e.g. where you are trying to CLEAR SY-UCOMM. It could result in inconsistencies and hence SAP does not allow it in some cases.

To overcome this disadvantage, it is recommended to save the processing code (OKCODE) in another variable saved in element list of main screen (type OK). When any operation is performed (e.g. clicking a button), SAP transfers the SY-UCOMM to OKCODE and this is used for further processing.

Once you enter the processing in CASE OKCODE. WHEN DOSOMETHING, then you CLEAR OKCODE. In this way, the old sy-ucomm does not remain in the process code.

Hence instead of using SY-UCOMM for your processing, please identify the "OKCODE" from the main screen from which the BAdi is called and "work on" the OKCODE rather than SY-UCOMM.

I hope I am clear on the subject.

Please revert in case of doubt.

Regards,

Aditya

16 REPLIES 16

Former Member
0 Kudos

Hi Pablo,

System fields should never be changed/altered manually, e.g. where you are trying to CLEAR SY-UCOMM. It could result in inconsistencies and hence SAP does not allow it in some cases.

To overcome this disadvantage, it is recommended to save the processing code (OKCODE) in another variable saved in element list of main screen (type OK). When any operation is performed (e.g. clicking a button), SAP transfers the SY-UCOMM to OKCODE and this is used for further processing.

Once you enter the processing in CASE OKCODE. WHEN DOSOMETHING, then you CLEAR OKCODE. In this way, the old sy-ucomm does not remain in the process code.

Hence instead of using SY-UCOMM for your processing, please identify the "OKCODE" from the main screen from which the BAdi is called and "work on" the OKCODE rather than SY-UCOMM.

I hope I am clear on the subject.

Please revert in case of doubt.

Regards,

Aditya

former_member182371
Active Contributor
0 Kudos

Hi,

the question is that for a subscreen the okcode does not work as in a dynpro.

in a dynpro you define your own okcode as an element of the screen.

but for a subscreen there is not that possibility.

in this way i cant´ do:

case okcode.

when 'DOSOMETHING'.

endcase.

because the only value that i have acces to is sy-ucomm.

Best regards.

0 Kudos

Hi Pablo,

You are right that OKCODE is not possible with a subscreen. But whenever a pushbutton is pressed on the subscreen, the function code is passed to the OKCODE field of the main screen and from the PAI of the main screen it can be copied to a variable of your own like SAVE_OKCODE or something like that. Then doing CASE SAVE_OKCODE will be possible.

I think this is what Aditya is trying to suggest in the previous message on the subject.

Hope this helps.

Thanks

Sanjeev

former_member182371
Active Contributor
0 Kudos

Hi,

- when you say:

"But whenever a pushbutton is pressed on the subscreen,

the function code is passed to the OKCODE field of the main screen"

bear in mind that my subscreen is within a badi of transaction MIRO.

- what i´d like to do is something like:

l_okcode = ok

case l_okcode.

when 'DOSOMETHING'.

clear ok.

endcase.

where ok is the okcode of the subscreen

is there a solution for this?.

Best regards.

0 Kudos

Hi,

When you say:

"but if i do just INTRO (not clicking the pushbutton), in pai of the subscreen the value of sy-ucomm keeps the former value of the pushbutton (that is DOSOMETHING)."

What do you mean by INTRO?

Are you refreshing the main screen? If not, then the value of sy-ucomm will remain same until another button is pressed on the screen either on the main screen or the subscreen.

If you are refreshing the screen may be by entering the transaction afresh then system will set the sy-ucomm to appropriate value.

Please explain a bit more as to what you are doing on the subcreen.

Thanks

Sanjeev

former_member182371
Active Contributor
0 Kudos

Hi Sanjeev,

- fist i tried with something like:

IF SY-UCOMM = 'DOSOMETHING'.

perform do_something.

ENDIF.

but if the user refreshed the screen the subroutine would be called again.

- then i tried with:

DATA: L_OKCODE(4) TYPE C.

CLEAR L_OKCODE.

L_OKCODE = SY-UCOMM.

CASE L_OKCODE.

WHEN 'DOSOMETHING'.

perform do_something.

WHEN OTHERS.

ENDCASE.

same problem again.

the question is that instead of using sy-ucomm i should use the okcode of the pushbutton

but i´m not able to get this value (due to the subscreen i guess).

should i try to get this value (the okcode of the main screen) via field-symbols?

is there something in the standard that does something similar?

Best regards.

former_member182371
Active Contributor
0 Kudos

Hi,

i´ve just found this:

http://sap.ittoolbox.com/groups/technical-functional/sap-dev/ok-code-value-in-subscreen-578102?cv=ex...

the problem discussed here is the same as mine.

the solution proposed is a routine in the main program that clears the ok-code.

So next monday i´ll try to find a routine that does this. Hope to find it.

Best regards.

former_member182371
Active Contributor
0 Kudos

Hi,

i haven´t found a routine that fits my purpose but i finally solved the question thus:

in module user_command_0100 of PAI

Here i get the OK-CODE of the main screen

CONSTANTS: c_okcode(17) TYPE c VALUE '(SAPLMR1M)OK-CODE'.

DATA: wa_okcode TYPE sy-ucomm.

CLEAR wa_okcode.

FIELD-SYMBOLS: = l_okcode.

ENDIF.

Best regards.

0 Kudos

Hola Pablo, te escribo en español que me resulta más cómodo..

Tengo un problema parecido al que explicaste aquí hace ya tiempo.. En mi caso, he tenido que aañadir una nueva pestaña en la transacción IP01. Dentro de esta pestaña hay varios campos. Uno de ellos es un checkbox, cada vez que lo marco, tengo que marcar un radiobutton de esa misma pestaña y cuando lo desmarco, tengo que marcar otro radiobutton.

Tras volverme loca, encontré tu solución pero no me funciona,me sigue dando el error de "Funcion solicitada ULTI no prevista".

He asignado a mi checkbox un codigo de funcion ULTI y mi código del user command es como sigue:

CONSTANTS: c_okcode(18) TYPE c VALUE '(SAPLXPRM)SY-UCOMM'.

DATA: wa_okcode TYPE sy-ucomm.

CLEAR wa_okcode.

FIELD-SYMBOLS: .

IF l_okcode = 'ULTI'.

IF ci_mpos-zzultimo_dia IS NOT INITIAL.

ci_mpos-zz_no = 'X'.

CLEAR ci_mpos-zz_dia1.

CLEAR ci_mpos-zz_dia2.

CLEAR ci_mpos-zz_dia3.

CLEAR ci_mpos-zz_dia4.

CLEAR ci_mpos-zz_dia5.

CLEAR ci_mpos-zz_dia6.

CLEAR ci_mpos-zz_dia7.

CLEAR ci_mpos-zz_semana_fija.

LOOP AT SCREEN.

IF screen-name = 'CI_MPOS-ZZ_DIA1' OR

screen-name = 'CI_MPOS-ZZ_DIA2' OR

screen-name = 'CI_MPOS-ZZ_DIA3' OR

screen-name = 'CI_MPOS-ZZ_DIA4' OR

screen-name = 'CI_MPOS-ZZ_DIA5' OR

screen-name = 'CI_MPOS-ZZ_DIA6' OR

screen-name = 'CI_MPOS-ZZ_DIA7' OR

screen-name = 'CI_MPOS-ZZ_SEMANA_FIJA'.

screen-input = '0'.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ELSE.

LOOP AT SCREEN.

IF screen-name = 'CI_MPOS-ZZ_DIA1' OR

screen-name = 'CI_MPOS-ZZ_DIA2' OR

screen-name = 'CI_MPOS-ZZ_DIA3' OR

screen-name = 'CI_MPOS-ZZ_DIA4' OR

screen-name = 'CI_MPOS-ZZ_DIA5' OR

screen-name = 'CI_MPOS-ZZ_DIA6' OR

screen-name = 'CI_MPOS-ZZ_DIA7'." OR

  • screen-name = 'CI_MPOS-ZZ_SEMANA_FIJA'.

screen-input = '1'.

MODIFY SCREEN.

ELSEIF screen-name = 'CI_MPOS-ZZ_NO'.

screen-input = '0'.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDIF.

  • to initialize the ok-code of the main screen

CLEAR l_okcode.

= l_okcode.

ENDIF.

ME limpia el l_code pero no llega a limpiarme el sy-ucomm... Se te ocurre qué puedo estar haciendo mal ??

Mil gracias de antemano !!!

Marí

0 Kudos

Ya he visto mi fallo, he puesto en vez de el programa principal, el de la nueva dynpro.

genial haber encontrado tu post !!

0 Kudos

Hi,

as some characters to this thread seem to have been changed/lost here i add again the answer:


CONSTANTS: c_okcode(17) TYPE c VALUE '(SAPLMR1M)OK-CODE'.

DATA: wa_okcode TYPE sy-ucomm.

CLEAR wa_okcode.

FIELD-SYMBOLS: <fs_okcode> TYPE any.

ASSIGN (c_okcode) TO <fs_okcode>.

data: l_okcode like sy-ucomm.

clear l_okcode.

l_okcode = <fs_okcode>.

IF l_okcode = 'DOSOMETHING'.

perform do_something.

To initialize the OK-CODE of the main screen

clear l_okcode.

<fs_okcode> = l_okcode.

ENDIF.

Best regards.

former_member182371
Active Contributor
0 Kudos

So as you can see what i needed was to get/modify the ok-code of the main screen via field-symbols.

Best regards.

0 Kudos

Hi Pablo ,

I faced the same problem . Thanks a lot for your solution .It worked perfectly ! It was very useful ...

Regards,

Deepthi

0 Kudos

very nice indeed... congratz!

lorne_glazer2
Member
0 Kudos

Hi

There has been a lot written about this problem. All of the solutions seem to be struggling with, from a BAdI subscreen, how to clear sy-ucomm or a similar parent main screen OK variable in the PAI phase.

What has worked for me was to clear SY-UCOMM in the PBO phase of the subscreen.

regards

lorne

Former Member
0 Kudos

Thanks a lot for this solution !!!

Solveld my Problem to...:D

It is verry Interesting how it was able to get the OK code over the field symbol by assigning...this was new for me ....verry nice

Thanks a lot