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

Can we execute WRITE before PARAMETER???

Former Member
0 Likes
2,130

Hi Experts,

I am new to SAP and I m trying to execute following code.

WRITE: '1.ABC',/,'2.XYZ',/. 

PARAMETERS p_a TYPE i OBLIGATORY. 

CASE p_a.  

WHEN 1. WRITE 'ABC'.  

WHEN 2. WRITE 'XYZ'.  

WHEN OTHERS. WRITE 'Wrong Selection'.

ENDCASE.


I want to display the Menu before the user give input. Is there any way to execute WRITE before the PARAMETER get executed.


Thanx in Advance..



6 REPLIES 6
Read only

Former Member
0 Likes
1,498

Hi,

To achive your requirement, you need to make use of SELECTION-SCREEN - COMMENT but not WRITE. And here the code to show your required output.

SELECTION-SCREEN COMMENT /1(50) comm1 MODIF ID mg1.
SELECTION-SCREEN SKIP.

SELECTION-SCREEN COMMENT /1(30) comm2.
SELECTION-SCREEN ULINE /1(50).


PARAMETERS p_a TYPE i OBLIGATORY.

DATA screen_wa TYPE screen.

AT SELECTION-SCREEN OUTPUT.
*  comm1 = '1.ABC,/,2.XYZ'.
  comm2 = '1.ABC,/,2.XYZ'.
  LOOP AT screen INTO screen_wa.
    IF screen_wa-group1 = 'MG1'.
      screen_wa-intensified = '1'.
      MODIFY screen FROM screen_wa.
    ENDIF.
  ENDLOOP.

Output

Hope this helps you.

Thanks

KH

Read only

Former Member
0 Likes
1,498

Hi Pankaj ,

                This is not possible since you want to get the write before selection screen.

Only those write statements will be executed which are written after selection parameters .

PARAMETERS p_a TYPE i OBLIGATORY.

CASE p_a. 

WRITE: '1.ABC',/,'2.XYZ',/.

WHEN 1. WRITE 'ABC'. 

WHEN 2. WRITE 'XYZ'. 

WHEN OTHERS. WRITE 'Wrong Selection'.

ENDCASE.



Regards ,

Rocky

Read only

Former Member
0 Likes
1,498

Hi Pankaj,

You cannot write on selection screen as Every Write statement gets accessed only after START-OF_SELECTION. So, the write statement will not be displayed anywhere on selection screen.

Instead of the same you can use SELECTION SCREEN - COMMENT.

Here the piece of code for your requirement.

SELECTION-SCREEN COMMENT /1(50) comment1 MODIF ID com1.

SELECTION-SCREEN SKIP.

SELECTION-SCREEN COMMENT /1(30) comm2.

SELECTION-SCREEN ULINE /1(50).

PARAMETERS: p_a TYPE i OBLIGATORY.

now , you can set the value of Comment1 and comment2 with the text you want.

for your program you can set value of comment 2 = '1.ABC,/,2.XYZ'.

Hope this will help you.

Regards,

Ashish

Read only

0 Likes
1,498

Thanks.... It helped a lot....

Read only

0 Likes
1,498

Hi,

If your issue resolved. Pls close the thread or else revert with your concerns.

Thanks

KH

Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,498

You could also try with list box

TYPE-POOLS: vrm.

PARAMETERS p_a TYPE i OBLIGATORY AS LISTBOX VISIBLE LENGTH 5
   USER-COMMAND dummy.

INITIALIZATION.
   DATA: id TYPE vrm_id,
         lt_values TYPE vrm_values,
         ls_value LIKE LINE OF lt_values.
   REFRESH lt_values.
   ls_value-key = '1'.
   ls_value-text = 'ABC'.
   APPEND ls_value TO lt_values.
   ls_value-key = '2'.
   ls_value-text = 'XYZ'.
   APPEND ls_value TO lt_values.
   id = 'P_A'.
   CALL FUNCTION 'VRM_SET_VALUES'
     EXPORTING
       id     = id
       values = lt_values.

AT SELECTION-SCREEN.

Regards,

Raymond