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: 

Automatically filled out the parameter based on Select Option

former_member612750
Participant
0 Kudos

Hi,

I want my parameter to copy the value in the select option low. for example, I have a hidden parameter that will appear and replaced the select option if a certain radio button is ticked. If I input a single value in the select option before ticking the radio button, I want my parameter to have the same value as in the select option without re-entering it.

1 ACCEPTED SOLUTION

mateuszadamus
Active Contributor

Hi catienza11

Below is the code for your requirement:

DATA:
  gv_per TYPE i.

PARAMETERS: p_per TYPE i DEFAULT 5.
SELECT-OPTIONS: s_per FOR gv_per.
SELECTION-SCREEN SKIP.
PARAMETERS: p_chk TYPE flag USER-COMMAND chk.

AT SELECTION-SCREEN OUTPUT.
  LOOP AT SCREEN.
    IF screen-name CS 'P_PER'.
      screen-active = 0.
      MODIFY SCREEN.
    ENDIF.
  ENDLOOP.

AT SELECTION-SCREEN.
  CASE sy-ucomm.
    WHEN 'CHK'.
      CHECK p_chk = abap_true.
      IF s_per[] IS INITIAL.
        s_per-low = p_per.
        APPEND s_per.
      ELSE.
        p_per = s_per[ 1 ]-low.
      ENDIF.
    WHEN OTHERS.
      " do nothing.
  ENDCASE.

Your parameter's value will be update only if the user selects the checkbox.

Regards,

Mateusz

12 REPLIES 12

mateuszadamus
Active Contributor

Hi catienza11

Below is the code for your requirement:

DATA:
  gv_per TYPE i.

PARAMETERS: p_per TYPE i DEFAULT 5.
SELECT-OPTIONS: s_per FOR gv_per.
SELECTION-SCREEN SKIP.
PARAMETERS: p_chk TYPE flag USER-COMMAND chk.

AT SELECTION-SCREEN OUTPUT.
  LOOP AT SCREEN.
    IF screen-name CS 'P_PER'.
      screen-active = 0.
      MODIFY SCREEN.
    ENDIF.
  ENDLOOP.

AT SELECTION-SCREEN.
  CASE sy-ucomm.
    WHEN 'CHK'.
      CHECK p_chk = abap_true.
      IF s_per[] IS INITIAL.
        s_per-low = p_per.
        APPEND s_per.
      ELSE.
        p_per = s_per[ 1 ]-low.
      ENDIF.
    WHEN OTHERS.
      " do nothing.
  ENDCASE.

Your parameter's value will be update only if the user selects the checkbox.

Regards,

Mateusz

0 Kudos

Hi Sir,

Good Day!

My program is if I tick the radio button the select option field will be hidden and the parameter will appear which I already did. now will this help that if I input a value in the select option and I tick the radio button the parameter will copy the value in the select option low field?

Hi Gerard,

Yes, it should work, because there is an event after the user selects the checkbox.


Regards,
Mateusz

0 Kudos

hi!

as per my understanding, it is copying the value of the parameter into the select option field. Is there any way can I do it the other way around? I will be just needing the first value or one value that the user enters in the select option field and copy it into the parameter field.

Hi

This part of the code copies the SELECT-OPTIONS LOW value to the PARAMETER field.

p_per = s_per[ 1 ]-low.
Regards,
Mateusz

0 Kudos

Hi Mateusz,

Good Day!

I want to add a warning message that if the user enters multiple plants it will prompt, where do I insert this code? I am glad that you were able to help me, I am fairly new to ABAP.

Regards,
Gerard.

Hello Gerard

I don't know what is the Plant parameter. But have a look at this.

IF lines( s_plant[] ) > 1.
" show error message
ENDIF.
Kind regards,
Mateusz

0 Kudos

Hi Mateusz,

Good Day!

related to my last question, I want to know what logic should I add in the code above if the second select option field has values.

Thank you very much!

0 Kudos

Hello Gerard A

It depends on the logic you want to have there. Do you know how the report should behave if the second select option field has values?

Kind regards,
Mateusz

0 Kudos

Hi Mateusz,

Good Day!

Same as before, it will display a system message.

Thank you!

IF s_plant-high IS NOT INITIAL.
" show error message
ENDIF.

Kind regards,
Mateusz

former_member1716
Active Contributor

catienza11,

Am afraid that this functionality can cause several other issues in your program, there is no harm in requesting the user to enter the value again.

How would you expect the program to behave when there are multiple values entered or range of values entered?

Not sure why this is needed!

Regards!