‎2020 Dec 04 1:19 PM
For example, I have 3 pushbuttons and one input field.
Pushbuttons, 1,2,+
And now I want to click 1 then + then 2.
After that I want to have on my input text: "1+2".
How Can I do that?
‎2020 Dec 04 1:29 PM
Hello tkasperski
Something like this?
AT USER-COMMAND.
CASE sy-ucomm.
WHEN 'BTN_1'.
gv_expression = |{ gv_expression }1|.
WHEN 'BTN_2'.
gv_expression = |{ gv_expression }2|.
WHEN 'BTN_+'.
gv_expression = |{ gv_expression }+|.
WHEN 'BTN_CLR'.
CLEAR gv_expression.
ENDCASE.You could also make it like this.
AT USER-COMMAND.
CASE sy-ucomm.
WHEN 'BTN_CLR'.
CLEAR gv_expression.
WHEN OTHERS.
gv_expression = |{ gv_expression }{ sy-ucomm+4(1) }|.
ENDCASE.Kind regards,
Mateusz
‎2020 Dec 04 1:29 PM
Hello tkasperski
Something like this?
AT USER-COMMAND.
CASE sy-ucomm.
WHEN 'BTN_1'.
gv_expression = |{ gv_expression }1|.
WHEN 'BTN_2'.
gv_expression = |{ gv_expression }2|.
WHEN 'BTN_+'.
gv_expression = |{ gv_expression }+|.
WHEN 'BTN_CLR'.
CLEAR gv_expression.
ENDCASE.You could also make it like this.
AT USER-COMMAND.
CASE sy-ucomm.
WHEN 'BTN_CLR'.
CLEAR gv_expression.
WHEN OTHERS.
gv_expression = |{ gv_expression }{ sy-ucomm+4(1) }|.
ENDCASE.Kind regards,
Mateusz
‎2020 Dec 04 1:52 PM
Hi, thanks for your answer. I don't understand how to use it. I mean to use the user selection screen. Add 3 buttons and input on the user selection screen for example
DATA: input TYPE i.
SELECTION-SCREEN:
BEGIN OF SCREEN 500 AS WINDOW TITLE title,
PUSHBUTTON 2(10) text-001 USER-COMMAND cli1,
PUSHBUTTON 12(30) text-002 USER-COMMAND cli2,
PUSHBUTTON 12(30) text-003 USER-COMMAND cli3
VISIBLE LENGTH 10,
END OF SCREEN 500.
For example
text-001 = 1
text-002 = 2
text-003 = +
I click cli1(button) then cli3(button) then cli2(button) and as a result I have 1 + 2 on my input.
‎2020 Dec 04 2:03 PM
You need to use AT SELECTION-SCREEN event in this case.
DATA:
gv_expression TYPE string.
" create push buttons
SELECTION-SCREEN PUSHBUTTON /2(40) text-001 USER-COMMAND btn_1,
SELECTION-SCREEN PUSHBUTTON /2(40) text-002 USER-COMMAND btn_2.
SELECTION-SCREEN PUSHBUTTON /2(40) text-003 USER-COMMAND btn_+.
SELECTION-SCREEN PUSHBUTTON /2(40) text-004 USER-COMMAND btn_clr.
" handle a button being pushed
AT SELECTION-SCREEN.
CASE sscrfields.
WHEN 'BTN_CLR'.
CLEAR gv_expression. " clear the expression
WHEN OTHERS.
gv_expression = |{ gv_expression } { sscrfields+4(1) }|. " add next character to the expression
ENDCASE.
WRITE gv_expression.
Not tested in the system, though. Might have some typos.
‎2020 Dec 04 2:11 PM
Ok, now I understand but how to put values from text-001 etc. into input field?
‎2020 Dec 04 2:17 PM
If you want to do it that way.
CASE sscrfields.
WHEN 'BTN_CLR'.
CLEAR gv_expression. " clear the expression
WHEN 'BTN_+'.
gv_expression = |{ gv_expression } { text-003 }|.
WHEN 'BTN_1'.
gv_expression = |{ gv_expression } { text-001 }|.
WHEN 'BTN_2'.
gv_expression = |{ gv_expression } { text-002 }|.
ENDCASE.
Kind regards,‎2020 Dec 04 2:30 PM
Ok, thanks a lot now I understand how it works and how to do but the last thing I want to know Is how "in real time" put those values into input field because now I am clicking buttons and when I click execute button I see result.
‎2020 Dec 04 2:32 PM
Add the input field to the screen.
PARAMETER: p_input TYPE char20.
After the expression is updated, update the field.
p_input = gv_expression.You could also concatenate the expression to the input field directly.
Kind regards,
Mateusz‎2020 Dec 04 3:47 PM
Hello Tomasz Kasperski
Make sure to upvote and accept Mateusz Adamus answer as a token of appreciation. He's not only answer, he is providing a crash ABAP course here too ;))
BR, Dominik Tylczynski
‎2020 Dec 04 5:21 PM
Hello, 3a9e4ce873a94034b33dc62b0ce600eeI upvoted, accepted, and liked every comment. Thank you Mateusz Adamus for outstanding help and patience 🙂
‎2020 Dec 04 5:25 PM