Application Development and Automation 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: 
Read only

Selection screen logic

Former Member
0 Likes
1,846

Hi all,

I have 2 radio button for report output control.

o Purchase Order

o Sales Order

I am displaying 5 fields for the Purchase order radio button and 3 fields for Sales order button in selection screen dynamically.

Like if first radio button is selected then only 5 fields will be displayed and only 3 fields for second radio button.

Now my problem is i dont want users to execute the report without entering atleast one value in the selection screen for any of the radio buttons.

Suppose i select Sales order radio button and 3 fields are displayed. and user has to enter atleast one value here to execute.how to validate here.

Thanks

Khan

8 REPLIES 8
Read only

Former Member
0 Likes
1,084

Hi

you can put key word OBLIGATORY if put this it won't allow user to execute directly

he has to enter some value in it

other wise you can also write logic for this under AT SELECTION-SCREEN event to validate the screen fields after entring the values to check they are correct or wrong

same req like you

&----


*& Report ZNNR_REPORT

*&

&----


*&

*&

&----


REPORT ZNNR_REPORT NO STANDARD PAGE HEADING MESSAGE-ID ZNNR LINE-SIZE 100 LINE-COUNT 65(4).

******DATA DECLARATIONS**********

DATA : BEGIN OF IT_PLANT OCCURS 0,

MATNR LIKE MARA-MATNR,

WERKS LIKE MARC-WERKS,

PSTAT LIKE MARC-PSTAT,

EKGRP LIKE MARC-EKGRP,

END OF IT_PLANT.

DATA : BEGIN OF IT_PONO OCCURS 0,

EBELN LIKE EKKO-EBELN,

EBELP LIKE EKPO-EBELP,

MATNR LIKE EKPO-MATNR,

WERKS LIKE EKPO-WERKS,

LGORT LIKE EKPO-LGORT,

END OF IT_PONO.

TABLES EKKO.

********END OF DATA DECLARATIONS*********

********SELECTION SCREEN DESIGN ***********

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

PARAMETER : P_WERKS LIKE MARC-WERKS MODIF ID S1.

SELECT-OPTIONS : S_EBELN FOR EKKO-EBELN NO INTERVALS MODIF ID S2.

SELECTION-SCREEN END OF BLOCK B1.

SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-004.

SELECTION-SCREEN BEGIN OF LINE.

PARAMETERS : R1 RADIOBUTTON GROUP G1 DEFAULT 'X'.

SELECTION-SCREEN COMMENT 5(20) TEXT-002 FOR FIELD R1.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

PARAMETERS : R2 RADIOBUTTON GROUP G1.

SELECTION-SCREEN COMMENT 5(20) TEXT-003 FOR FIELD R2.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN END OF BLOCK B2.

******END OF SELECTION SCREEN DESIGN****************

*********INITIALIZATION OF SELECTION SCREEN ELEMENTS.*****

INITIALIZATION.

P_WERKS = '1000'.

S_EBELN-LOW = '4500016926'.

S_EBELN-OPTION = 'EQ'.

S_EBELN-SIGN = 'I'.

APPEND S_EBELN.

CLEAR S_EBELN.

************END OF INITIALIZATION***********************

***********SCREEN MODIFICATIONS*******************

AT SELECTION-SCREEN OUTPUT.

LOOP AT SCREEN.

IF R1 EQ 'X' AND SCREEN-GROUP1 EQ 'S2'.

SCREEN-INPUT = 0.

MODIFY SCREEN.

ENDIF.

IF R2 EQ 'X' AND SCREEN-GROUP1 EQ 'S1'.

SCREEN-INPUT = 0.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

********END OF SCREEN MODIFICATIONS*****************

***************SCREEN VALIDATIONS *****************

at selection-screen.

SELECT SINGLE *

FROM EKKO

INTO EKKO

WHERE EBELN IN S_EBELN.

IF SY-SUBRC <> 0.

SET CURSOR FIELD 'S_EBELN-LOW'.

MESSAGE E999 WITH TEXT-005.

ENDIF.

********end of screen validation*****************

START-OF-SELECTION.

*set pf-status '100'.

IF R1 EQ 'X'.

SELECT MATNR

WERKS

PSTAT

EKGRP

FROM MARC

INTO TABLE IT_PLANT

WHERE WERKS = P_WERKS.

LOOP AT IT_PLANT.

WRITE : SY-VLINE , 2 IT_PLANT-MATNR COLOR COL_KEY,

21 SY-VLINE , 22 IT_PLANT-WERKS COLOR COL_KEY,

27 SY-VLINE ,28 IT_PLANT-PSTAT COLOR COL_NORMAL,

43 SY-VLINE ,44 IT_PLANT-EKGRP COLOR COL_NORMAL.

ENDLOOP.

ENDIF.

IF R2 EQ 'X'.

SELECT EBELN EBELP MATNR WERKS LGORT

FROM EKPO

INTO TABLE IT_PONO

WHERE EBELN IN S_EBELN.

LOOP AT IT_PONO.

WRITE : SY-VLINE , 2 IT_PONO-EBELN COLOR COL_KEY,

12 SY-VLINE , 13 IT_PONO-EBELP COLOR COL_KEY,

18 SY-VLINE , 19 IT_PONO-MATNR COLOR COL_NORMAL,

37 SY-VLINE , 38 IT_PONO-WERKS COLOR COL_NORMAL,

44 SY-VLINE , 45 IT_PONO-LGORT COLOR COL_NORMAL, 49 SY-VLINE..

ENDLOOP.

ENDIF.

TOP-OF-PAGE.

IF R1 EQ 'X'.

*ULINE AT /1(48).

WRITE : SY-VLINE ,2 'MATERIAL NUMBER',

21 SY-VLINE , 22 'PLANT',

27 SY-VLINE , 28 'STATUS',

43 SY-VLINE , 44 'GRUP', 48 SY-VLINE.

ULINE AT /1(48).

ENDIF.

IF R2 EQ 'X'.

WRITE : SY-VLINE , 2 'PO NUMBER',

12 SY-VLINE, 13 'ITEM',

18 SY-VLINE,19 'MATERIAL NUMBER',

37 SY-VLINE, 38 'PLANT',

44 SY-VLINE, 45 'GRUP',

49 SY-VLINE.

ULINE AT /1(50).

ENDIF.

END-OF-PAGE.

ULINE AT /1(50).

WRITE :/10 'PAGE NUMBER', SY-PAGNO.

Read only

Former Member
0 Likes
1,084

Hi Khan,

Whenever a radio button is selected , Make any one of the field mandatory .( may be the key field like matnr )

So when a user doesnt enter the value , he will not be able to execute, but will get a message asking the user to enter the value .

Regards,

Chitra

Read only

Former Member
0 Likes
1,084

Hi khan,

In at selection-screen check like this.

if P_r2( radio button sales order ) eq 'X' and p_f1 is ininitail and P-f2 is inintial and p_f3 is ininitail.

raise message here.

endif.

i am assuming p_f1 , p_f2 ,P-f3 are the fields corresponding to the p_r2

thanx,

ananth

Read only

0 Likes
1,084

Hi Ananth,

It works fine for the first radio button but when u select the second radio button it directly gives a message .

IF NOT p_pur IS INITIAL.

*---Purchase data requested

IF so_a IS INITIAL AND

so_b IS INITIAL AND

so_c IS INITIAL AND

so_d IS INITIAL AND

so_e IS INITIAL AND

MESSAGE e205(zsrm). "Error: No selection made

ENDIF.

ELSE.

IF so_f IS INITIAL AND

so_g IS INITIAL AND

so_h IS INITIAL AND

MESSAGE e205(zsrm). "Error: No selection made

ENDIF.

This is wat i have tried for the logic at selection screen.

And the problem is i cant put a field to be obligatory.

Thanks

Read only

Former Member
0 Likes
1,084

You have to hide the two fields when the purchase order radio button is selected.

ie,

AT SELECTION-SCREEN ON RADIOBUTTON GROUP rad.

if <rad2> = 'X'. " sales order

loop at screen.

if screen-name = 'FIELD1' or screen-name = 'FIELD2' .

screen-active = 0.

modify screen.

endif.

endloop.

at selection-screen.

if field1 eq ' ' and field2 eq ' ' and field3 eq ' ' and field4 eq ' ' and field5 eq ' '.

message <message> type 'E'.

endif.

Read only

Former Member
0 Likes
1,084

Hi,

You can check the sample code.

PARAMETERS: RAD1 TYPE C RADIOBUTTON GROUP 1,

RAD2 TYPE C RADIOBUTTON GROUP 1. PARAMETERS: SELE TYPE C MODIF ID ABC.

AT SELECTION-SCREEN OUTPUT .

IF RAD1 EQ 'X'.

LOOP AT SCREEN .

IF SCREEN-GROUP1 EQ 'ABC'.

SCREEN-INVISIBLE = 1.

SCREEN-ACTIVE = 0.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDIF.

IF RAD2 EQ 'X'.

LOOP AT SCREEN .

IF SCREEN-GROUP1 EQ 'ABC'.

SCREEN-INVISIBLE = 0.

SCREEN-REQUIRED = 1.

SCREEN-ACTIVE = 1.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDIF.

REWARD IF USEFUL

Read only

Former Member
0 Likes
1,084

Hi,Khan

I m assuming that u r creating module pool program and also following few things

r_pur (name of radio button for purchase order)

r_sal (name of radio button for sales order)

rpf_1 (field 1 to dislplay if r_pur selected)

rpf_2 (field 2 to dislplay if r_pur selected)

rpf_3 (field 3 to dislplay if r_pur selected)

rpf_4 (field 4 to dislplay if r_pur selected)

rpf_5 (field 5 to dislplay if r_pur selected)

rsf_1 (field 1 to dislplay if r_sal selected)

rsf_2 (field 2 to dislplay if r_sal selected)

rsf_2 (field 2 to dislplay if r_sal selected)

rad (function code of radio group)

rpt (function code of save button or show report

button or function code for what ever you

want to perform when everything is correct.)

" Define a flag variable in TOP include to check which

" radio is selected

Data: c_check(3) type c.

" Add one module (user command) in PAI with following code

case ok_code.

when 'rad'.

if r_pur = 'x'.

c_check = 'pur'.

elseif r_sal = 'x'.

c_check = 'sal'.

else.

c_check = ' '.

endif.

when 'rpt'.

if r_pur = 'x'.

if rpf_1 is initial and rpf_2 is initial and rpf_3 is initial and rpf_4 is initial and rpf_5 is initial.

" raise message to enter PO data

else.

" Perform your task u wanted

endif.

elseif r_sal = 'x'.

if rsf_1 is initial and rsf_2 is initial and rsf_3 is initial.

" raise message to enter SO data

else.

" Perform your task u wanted

endif.

else.

" raise message to select any radio

endif.

endcase.

" Add one module in PBO with following code.

loop at screen.

if c_check = 'pur'.

rpf_1-invisible = '0'.

rpf_1-active = '0'. " (if using input-output field)

rpf_2-invisible = '0'.

rpf_2-active = '0'.

rpf_3-invisible = '0'.

rpf_3-active = '0'.

rpf_4-invisible = '0'.

rpf_4-active = '0'.

rpf_5-invisible = '0'.

rpf_5-active = '0'.

elseif c_check = 'sal'.

rsf_1-invisible = '0'.

rsf_1-active = '0'.

rsf_2-invisible = '0'.

rsf_2-active = '0'.

rsf_3-invisible = '0'.

rsf_3-active = '0'.

else.

" this will hide all element for first time display

rpf_1-invisible = '0'.

rpf_1-active = '0'.

rpf_2-invisible = '0'.

rpf_2-active = '0'.

rpf_3-invisible = '0'.

rpf_3-active = '0'.

rpf_4-invisible = '0'.

rpf_4-active = '0'.

rpf_5-invisible = '0'.

rpf_5-active = '0'.

rsf_1-invisible = '0'.

rsf_1-active = '0'.

rsf_2-invisible = '0'.

rsf_2-active = '0'.

rsf_3-invisible = '0'.

rsf_3-active = '0'.

endif.

modify screen.

end loop.

===============

If helpful, reward this stuff.

Read only

Former Member
0 Likes
1,084

This code solves ur proble.

*____________________________________________ Selection Screen

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-b01.

PARAMETERS:

rb_cus RADIOBUTTON GROUP rbg1 DEFAULT 'X' USER-COMMAND sel,

rb_cmp RADIOBUTTON GROUP rbg1.

SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-b02.

SELECT-OPTIONS:

pcust FOR kna1-kunnr MODIF ID cus,

pcmpy FOR knvv-vkorg MODIF ID cmp.

SELECTION-SCREEN END OF BLOCK b2.

SELECTION-SCREEN END OF BLOCK b1.

*____________________________________________ Screen Actions

AT SELECTION-SCREEN OUTPUT.

IF rb_cus = 'X'.

PERFORM hide_cmpy_options.

ELSE.

PERFORM hide_cust_options.

ENDIF.

START-OF-SELECTION.

EXIT.

&----


*& Form hide_cmpy_options

&----


FORM hide_cmpy_options.

LOOP AT SCREEN.

IF screen-group1 EQ 'CMP'.

screen-active = 0.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDFORM. " hide_cmpy_options

&----


*& Form hide_cust_options

&----


FORM hide_cust_options.

LOOP AT SCREEN.

IF screen-group1 EQ 'CUS'.

screen-active = 0.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

ENDFORM. " hide_cust_options

Regards,

Angi