22 Flares Twitter 0 Facebook 22 Google+ 0 LinkedIn 0 Email -- Pin It Share 0 22 Flares ×

Requirement:

Create a selection screen with 2 Select-options (Material Number, Sales Order Number) and 2 radio buttons (Material Data, Sales Data) as shown.

Case 1:  If I select Material Data radio button then Sales Order Number input filed will be disable as shown below.

Dynamic Selection Screen in SAP ABAPCase 2:  If I select Sales Data radio button then I Material Number input filed will be disable as shown below.

Dynamic Selection Screen in SAP ABAP1Note: By default select the material radio button and keep Sales order number selection screen in disable mode.

Step 1: Go to SE38 create a program (Program name starts must with Z or Y).

Step 2: Copy and paste the below code in your program.

*&———————————————————————*
*& Report  ZREPORT_01
*&
*&———————————————————————*
*&
*&
*&———————————————————————*

REPORT  ZREPORT_01 no standard page heading.

*//Tables declaration
tables : mara,vbak.

*//Types declaration for MARA
types : begin of ty_mara,
matnr type matnr,
ERSDA  TYPE ERSDA,
ERNAM  TYPE ERNAM,
LAEDA  TYPE LAEDA,
AENAM  TYPE AENAM,
end of ty_mara.

*//Types declaration for VBAK
types : begin of ty_vbak,
VBELN  TYPE VBELN_VA,
ERDAT  TYPE ERDAT,
ERZET  TYPE ERZET,
end of ty_vbak.

*//Internal table declaration
data : lt_mara type table of ty_mara,
lt_vbak type table of ty_vbak.

*//Work area declaration
data : wa_mara type ty_mara,
wa_vbak type ty_vbak.

*//Selection screen design
SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME TITLE text-s02.
select-options:s_matnr for mara-matnr modif id SC1,
s_vbeln for vbak-vbeln modif id SC2.
SELECTION-SCREEN END OF BLOCK blk1.
**//Check Boxes Design
* SELECTION-SCREEN BEGIN OF LINE.
*  SELECTION-SCREEN POSITION 10.
*  PARAMETERS: p_chk1 AS CHECKBOX.
*  SELECTION-SCREEN COMMENT 13(15) text-cb1.
*  PARAMETERS: p_chk2 AS CHECKBOX.
*  SELECTION-SCREEN COMMENT 32(15) text-cb2.
* SELECTION-SCREEN End of LINE.

*//Radio button design
SELECTION-SCREEN BEGIN OF BLOCK blk2 WITH FRAME TITLE text-s01.
*//Radio buttons design
selection-screen begin of line.
parameters: p_rad1 radiobutton group grp1 user-command test.
selection-screen comment 15(15) text-010 for field p_rad1.
parameters: p_rad2 radiobutton group grp1.
selection-screen comment 35(15) text-011 for field p_rad2.
selection-screen end of line.
SELECTION-SCREEN END OF BLOCK blk2.

*//validating selection screen
AT SELECTION-SCREEN OUTPUT .
LOOP AT SCREEN.
IF screen-group1 = ‘SC2’.
screen-input = 0.
ENDIF.
MODIFY SCREEN.
ENDLOOP.
if p_rad2 = ‘X’.
loop at screen.
if screen-group1 = ‘SC1’.
screen-input = ‘0’.
modify screen.
elseif screen-group1 = ‘SC2’.
screen-input = ‘1’.
modify screen.
endif.
endloop.
endif.

start-of-selection.
*//Retriving data from MARA
if p_rad1 eq ‘X’.
if s_matnr is not initial.
select matnr ersda ernam laeda aenam
from mara
into table lt_mara
where matnr in s_matnr.
else.
message ‘Enter material number’ type ‘I’.
endif.
if lt_mara is not initial.
*//Displaying output
loop at lt_mara into wa_mara.
write :/ wa_mara-matnr, wa_mara-ersda,wa_mara-ernam, wa_mara-laeda,wa_mara-aenam.
endloop.
else.
message ‘NO DATA’ type ‘I’.
endif.
elseif p_rad2 eq ‘X’.
if s_vbeln is not initial.
select vbeln erdat erzet
from vbak
into table lt_vbak
where vbeln in s_vbeln.
else.
message ‘Enter sales order number’ type ‘I’.
endif.
if lt_vbak is not initial.
*//Displaying output
loop at lt_vbak into wa_vbak.
write :/ wa_vbak-vbeln, wa_vbak-erdat,wa_vbak-erzet.
endloop.
else.
message ‘NO DATA’ type ‘I’.
endif.
endif.

OUTPUT:

Save your and active your program and press F8 button to execute.

By default material radio button is selected and Sales order number selection screen is in disable mode.

Case 1: If you want to retrieve the sales data then select Sales Radio button. If you select the sales radio button then automatically Material number field gets disable.

Enter the Sales order number and click on execute button (F8) to retrieve sales data.

Dynamic Selection Screen in SAP ABAP1Case 2: If you want to retrieve the material data then select the Material data radio button. If you select the Material radio button then automatically Sales number field gets disable.

Enter the Material number and click on execute Button(F8) to retrieve the material data.

Dynamic Selection Screen in SAP ABAP2Also Read:

Table Maintenance without using SE11 and SE30 Transaction Codes.

Creating Pushbuttons on Selection Screen.

Control Break Statements in SAP ABAP.

22 Flares Twitter 0 Facebook 22 Google+ 0 LinkedIn 0 Email -- Pin It Share 0 22 Flares ×