Skip to Content
-2

Dynamic change based on 3 radio buttons not working ? (Working only first 2)

Aug 06, 2017 at 06:54 PM

101

avatar image
Former Member

When i click on p_r_ord radio button its not showing contents of this radio buttons as p_r_sto and p_r_car showing need help for only highlighted part "IF....Else LOGIC"

*-----------------------------------*

* DECLARATIONS
TABLES:
zsa_ddic_store.

CONSTANTS:
gc_show_store TYPE i VALUE 1,
gc_hide_store TYPE i VALUE 0,
gc_show_car TYPE i VALUE 1,
gc_hide_car TYPE i VALUE 0,
gc_show_ord TYPE i VALUE 1,
gc_hide_ord TYPE i VALUE 0.

*-----------------------------------*
* SELECTION-SCREEN

" Dynamic Change based on Radio Button Selection
SELECTION-SCREEN BEGIN OF BLOCK b06 WITH FRAME TITLE text-b06.

" Store Information
SELECTION-SCREEN BEGIN OF BLOCK b02 WITH FRAME TITLE text-b02.
PARAMETERS:
p_sto_f1 TYPE zsa_ddic_store_id MODIF ID sto, " Show Only When p_r_sto selected
p_sto_f2 TYPE zsa_ddic_address MODIF ID sto,
p_sto_f3 TYPE zsa_ddic_city MODIF ID sto,
p_sto_f4 TYPE zsa_ddic_country MODIF ID sto,
p_sto_f5 TYPE zsa_ddic_opened_at MODIF ID sto,
p_sto_f6 TYPE zsa_ddic_closed_at MODIF ID sto.
SELECTION-SCREEN END OF BLOCK b02.

" Car Information
SELECTION-SCREEN BEGIN OF BLOCK b03 WITH FRAME TITLE text-b03.
PARAMETERS:
p_car_f1 TYPE zsa_ddic_icpn MODIF ID car, " Show Only When p_r_car selected
p_car_f2 TYPE zsa_ddic_model_id MODIF ID car, " p -parameter sto - store f1 for field 1
p_car_f3 TYPE zsa_ddic_store_id MODIF ID car,
p_car_f4 TYPE zsa_ddic_price MODIF ID car,
p_car_f5 TYPE zsa_ddic_currency MODIF ID car.
SELECTION-SCREEN END OF BLOCK b03.

" Order Information
SELECTION-SCREEN BEGIN OF BLOCK b04 WITH FRAME TITLE text-b04.
PARAMETERS:
p_ord_f1 TYPE zsa_ddic_order_id MODIF ID ord, " Show Only When p_r_ord selected
p_ord_f2 TYPE zsa_ddic_customer_id MODIF ID ord.
* p_ord_f3 TYPE zsa_ddic_price,
* p_ord_f4 TYPE zsa_ddic_currency,
* p_ord_f5 TYPE zsa_ddic_ordered_at.
SELECTION-SCREEN END OF BLOCK b04.

SELECTION-SCREEN END OF BLOCK b06.

*-----------------------------------*
* AT SELECTION-SCREEN OUTPUT

" Use this event to change properties on sel.screen elements

AT SELECTION-SCREEN OUTPUT.

 IF p_r_sto = abap_true.
 " Display only store related selection screen elements
 " Hide all car related selection screen elements
 PERFORM toggle_selscreen
 USING gc_show_store.
 ELSE.
 " Display only car related selection screen elements
 " Hide all store related selection screen elements
 PERFORM toggle_selscreen
 USING gc_hide_store.
 ENDIF.


*&---------------------------------------------------------------------*
*& Form toggle_selscreen
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->IB_SHOW_STO text
*----------------------------------------------------------------------*
FORM toggle_selscreen
USING ib_show_sto TYPE i.

DATA:
lb_disp_sto TYPE i,
lb_disp_car TYPE i,
lb_disp_ord TYPE i.

 IF ib_show_sto = gc_show_store.
 lb_disp_sto = gc_show_store.
 lb_disp_car = gc_hide_car.
 ELSE.
 lb_disp_sto = gc_hide_store.
 lb_disp_car = gc_show_car.
 ENDIF.
 

" Update Screen Elements
LOOP AT SCREEN.

 CASE screen-group1.
 WHEN 'STO'.
 screen-active = lb_disp_sto.
 MODIFY SCREEN.
 WHEN 'CAR'.
 screen-active = lb_disp_car.
 MODIFY SCREEN.
 WHEN 'ORD'.
 screen-active = lb_disp_ord.
 MODIFY SCREEN.
 ENDCASE.
 ENDLOOP.
 


ENDFORM. " TOGGLE_SELSCREEN

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Domi Bigl Aug 06, 2017 at 09:22 PM
0

Sorry, but these are programming basics!

You need to something like this:

...
...

CONSTANTS:
  gc_show_store TYPE i VALUE 1,
  gc_show_car   TYPE i VALUE 2,
  gc_show_ord   TYPE i VALUE 3.
CONSTANTS:
  gc_show TYPE i VALUE 1,
  gc_hide TYPE i VALUE 0.

...
...

AT SELECTION-SCREEN OUTPUT.

  IF p_r_sto = abap_true.
    PERFORM toggle_selscreen USING gc_show_store.
  ELSEIF p_r_car = abap_true.
    PERFORM toggle_selscreen USING gc_show_car.
  ELSE.
    PERFORM toggle_selscreen USING gc_show_order.
  ENDIF.

  ...
  ...

*  CASE abap_true.
  CASE ib_show_sto.
    WHEN gc_show_store.
      lb_disp_sto = gc_show.
      lb_disp_car = gc_hide.
      lb_disp_ord = gc_hide.

    WHEN gc_show_car.
      lb_disp_sto = gc_hide.
      lb_disp_car = gc_show.
      lb_disp_ord = gc_hide.

    WHEN gc_show_order.
      lb_disp_sto = gc_hide.
      lb_disp_car = gc_hide.
      lb_disp_ord = gc_show.

  ENDCASE.
 
  ...
  ...

BTW: don`t use FORMs, use a local class instead

Show 7 Share
10 |10000 characters needed characters left characters exceeded
Former Member

I have done something like that after seeing your code and i am getting error now:

SPAN { font-family: "Courier New"; font-size: 10pt; color: #000000; background: #FFFFFF; } .L0S31 { font-style: italic; color: #808080; } .L0S32 { color: #3399FF; } .L0S33 { color: #4DA619; } .L0S52 { color: #0000FF; } .L0S55 { color: #800080; } .L0S70 { color: #808080; }

*-----------------------------------*
* DECLARATIONS
*TABLES:
* zsa_ddic_store.

CONSTANTS:
gc_show_store TYPE i VALUE 1,
gc_show_car TYPE i VALUE 2,
gc_show_ord TYPE i VALUE 3.
CONSTANTS:
gc_show TYPE i VALUE 1,
gc_hide TYPE i VALUE 0.

*-----------------------------------*
* SELECTION-SCREEN

" Choose Activity Select/Insert/Upload/Delete
SELECTION-SCREEN BEGIN OF BLOCK b01 WITH FRAME TITLE text-b01.
PARAMETERS:
p_r_sel RADIOBUTTON GROUP tst DEFAULT 'X'," Select
p_r_ins RADIOBUTTON GROUP tst, " Insert
p_r_upd RADIOBUTTON GROUP tst, " Update
p_r_del RADIOBUTTON GROUP tst. " Delete
SELECTION-SCREEN END OF BLOCK b01.

" Dynamic Change based on Radio Button Selection
SELECTION-SCREEN BEGIN OF BLOCK b06 WITH FRAME TITLE text-b06.

" Choose Activity Car/Order/Store
SELECTION-SCREEN BEGIN OF BLOCK b05 WITH FRAME TITLE text-b05.
PARAMETERS:
p_r_sto RADIOBUTTON GROUP act USER-COMMAND act DEFAULT 'X'," Store
p_r_car RADIOBUTTON GROUP act, " Car
p_r_ord RADIOBUTTON GROUP act. " Order
SELECTION-SCREEN END OF BLOCK b05.

" Store Information
SELECTION-SCREEN BEGIN OF BLOCK b02 WITH FRAME TITLE text-b02.
PARAMETERS:
p_sto_id TYPE zsa_ddic_store_id MODIF ID sto, " Show Only When p_r_sto selected
p_add TYPE zsa_ddic_address MODIF ID sto,
p_city TYPE zsa_ddic_city MODIF ID sto,
p_cntry TYPE zsa_ddic_country MODIF ID sto,
p_op_at TYPE zsa_ddic_opened_at MODIF ID sto,
p_cl_at TYPE zsa_ddic_closed_at MODIF ID sto.
SELECTION-SCREEN END OF BLOCK b02.

" Car Information
SELECTION-SCREEN BEGIN OF BLOCK b03 WITH FRAME TITLE text-b03.
PARAMETERS:
p_car_f1 TYPE zsa_ddic_icpn MODIF ID car, " Show Only When p_r_car selected
p_car_f2 TYPE zsa_ddic_model_id MODIF ID car, " p -parameter sto - store f1 for field 1
p_car_f3 TYPE zsa_ddic_store_id MODIF ID car,
p_car_f4 TYPE zsa_ddic_price MODIF ID car,
p_car_f5 TYPE zsa_ddic_currency MODIF ID car.
SELECTION-SCREEN END OF BLOCK b03.

" Order Information
SELECTION-SCREEN BEGIN OF BLOCK b04 WITH FRAME TITLE text-b04.
PARAMETERS:
p_ord_f1 TYPE zsa_ddic_order_id MODIF ID ord, " Show Only When p_r_ord selected
p_ord_f2 TYPE zsa_ddic_customer_id MODIF ID ord,
p_ord_f3 TYPE zsa_ddic_price,
p_ord_f4 TYPE zsa_ddic_currency,
p_ord_f5 TYPE zsa_ddic_ordered_at.
SELECTION-SCREEN END OF BLOCK b04.

SELECTION-SCREEN END OF BLOCK b06.

*-----------------------------------*
* AT SELECTION-SCREEN OUTPUT

" Use this event to change properties on sel.screen elements

AT SELECTION-SCREEN OUTPUT.

IF p_r_sto = abap_true.
PERFORM toggle_selscreen
USING gc_show_store.
ELSEIF p_r_car = abap_true.
PERFORM toggle_selscreen
USING gc_show_car.
else.
PERFORM toggle_selscreen
USING gc_show_ord.
ENDIF.

*&---------------------------------------------------------------------*
*& Form toggle_selscreen
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->IB_SHOW_STO text
*----------------------------------------------------------------------*
FORM toggle_selscreen
USING ib_show_sto TYPE i.

DATA:
lb_disp_sto TYPE i,
lb_disp_car TYPE i,
lb_disp_ord TYPE i.

" Update Screen Elements
LOOP AT SCREEN.

CASE abap_true.
WHEN gc_show_store.
lb_disp_sto = gc_show.
lb_disp_car = gc_hide.
lb_disp_ord = gc_hide.

WHEN gc_show_car.
lb_disp_sto = gc_hide.
lb_disp_car = gc_show.
lb_disp_ord = gc_hide.

WHEN gc_show_ord.
lb_disp_sto = gc_hide.
lb_disp_car = gc_hide.
lb_disp_ord = gc_show.

ENDCASE.

ENDLOOP.
ENDFORM. " TOGGLE_SELSCREEN

0

which error?

1
Former Member
Domi Bigl

run time error see attached screen shot :

http://prntscr.com/g66ig5

Its error in case abap_true X value

0

Sorry, wrong variable for the CASE -> CASE ib_show_sto.

0
Former Member

Program is not toggling the radio buttons : just copy and paste this code into your system and you will understand what is exactly happening....i think we are not considering MODIF ID and not declared MODIFY SCREEN

*-----------------------------------*
* DECLARATIONS
*TABLES:
* zsa_ddic_store.

CONSTANTS:
gc_show_store TYPE i VALUE 1,
gc_show_car TYPE i VALUE 2,
gc_show_ord TYPE i VALUE 3.
CONSTANTS:
gc_show TYPE i VALUE 1,
gc_hide TYPE i VALUE 0.

*-----------------------------------*
* SELECTION-SCREEN

" Dynamic Change based on Radio Button Selection
SELECTION-SCREEN BEGIN OF BLOCK b06 WITH FRAME TITLE text-b06.

" Choose Activity Car/Order/Store
SELECTION-SCREEN BEGIN OF BLOCK b05 WITH FRAME TITLE text-b05.
PARAMETERS:
p_r_sto RADIOBUTTON GROUP act USER-COMMAND act DEFAULT 'X'," Store
p_r_car RADIOBUTTON GROUP act, " Car
p_r_ord RADIOBUTTON GROUP act. " Order
SELECTION-SCREEN END OF BLOCK b05.

" Store Information
SELECTION-SCREEN BEGIN OF BLOCK b02 WITH FRAME TITLE text-b02.
PARAMETERS:
p_sto_id TYPE zsa_ddic_store_id MODIF ID sto, " Show Only When p_r_sto selected
p_add TYPE zsa_ddic_address MODIF ID sto,
p_city TYPE zsa_ddic_city MODIF ID sto,
p_cntry TYPE zsa_ddic_country MODIF ID sto,
p_op_at TYPE zsa_ddic_opened_at MODIF ID sto,
p_cl_at TYPE zsa_ddic_closed_at MODIF ID sto.
SELECTION-SCREEN END OF BLOCK b02.

" Car Information
SELECTION-SCREEN BEGIN OF BLOCK b03 WITH FRAME TITLE text-b03.
PARAMETERS:
p_car_f1 TYPE zsa_ddic_icpn MODIF ID car, " Show Only When p_r_car selected
p_car_f2 TYPE zsa_ddic_model_id MODIF ID car, " p -parameter sto - store f1 for field 1
p_car_f3 TYPE zsa_ddic_store_id MODIF ID car,
p_car_f4 TYPE zsa_ddic_price MODIF ID car,
p_car_f5 TYPE zsa_ddic_currency MODIF ID car.
SELECTION-SCREEN END OF BLOCK b03.

" Order Information
SELECTION-SCREEN BEGIN OF BLOCK b04 WITH FRAME TITLE text-b04.
PARAMETERS:
p_ord_f1 TYPE zsa_ddic_order_id MODIF ID ord, " Show Only When p_r_ord selected
p_ord_f2 TYPE zsa_ddic_customer_id MODIF ID ord,
p_ord_f3 TYPE zsa_ddic_price,
p_ord_f4 TYPE zsa_ddic_currency,
p_ord_f5 TYPE zsa_ddic_ordered_at.
SELECTION-SCREEN END OF BLOCK b04.

SELECTION-SCREEN END OF BLOCK b06.

*-----------------------------------*
* AT SELECTION-SCREEN OUTPUT

" Use this event to change properties on sel.screen elements

AT SELECTION-SCREEN OUTPUT.

IF p_r_sto = abap_true.
PERFORM toggle_selscreen
USING gc_show_store.
ELSEIF p_r_car = abap_true.
PERFORM toggle_selscreen
USING gc_show_car.
else.
PERFORM toggle_selscreen
USING gc_show_ord.
ENDIF.

*&---------------------------------------------------------------------*
*& Form toggle_selscreen
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->IB_SHOW_STO text
*----------------------------------------------------------------------*
FORM toggle_selscreen
USING ib_show_sto TYPE i.

DATA:
lb_disp_sto TYPE i,
lb_disp_car TYPE i,
lb_disp_ord TYPE i.

" Update Screen Elements
LOOP AT SCREEN.

CASE ib_show_sto.
WHEN gc_show_store.
lb_disp_sto = gc_show.
lb_disp_car = gc_hide.
lb_disp_ord = gc_hide.

WHEN gc_show_car.
lb_disp_sto = gc_hide.
lb_disp_car = gc_show.
lb_disp_ord = gc_hide.

WHEN gc_show_ord.
lb_disp_sto = gc_hide.
lb_disp_car = gc_hide.
lb_disp_ord = gc_show.

ENDCASE.

ENDLOOP.
ENDFORM. " TOGGLE_SELSCREEN

Output showing same on all radio bottons see this ->

https://ibb.co/n2S5hF

0

You got all coding - just adjust FORM toggle_selscreen!

"i think we are not considering MODIF ID and not declared MODIFY SCREEN"

That may be true - so do it!

0

Hello,

You had to leave your "LOOP AT SCREEN.[...]. ENDLOOP." part just like in your first post.

The "CASE ib_show_sto. [...]. ENDCASE." part is to replace your old "IF [...] ENDIF."

0
Richard Harper Aug 09, 2017 at 07:55 AM
0

Use the code tags!

Show 4 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Sorry but i didn't get you

0

When you paste your code, highlight the text and click the 'code' button in the editor. It makes it so much more easier to read and you will find that people will then look at your post rather than seeing reams and reams of code that is totally unintelligable.

Also, don't post the entire program - only post the portion that is not working.

0
Former Member
Richard Harper

highlighted the code ....now please help

0

There is plenty of help above.

0