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

select-options

Former Member
0 Likes
706

Hi SAP Gurus ,

in the following code i m not able 2 get range for the full year .plz help me .

SELECT-OPTIONS : MONTH2 FOR Ztable-month2 .

loop at month2.

IF MONTH2-low eq '1' .

PERFORM JAN_DATA .

ENDIF .

IF MONTH2-low eq '2'.

PERFORM FEB_DATA .

ENDIF .

endloop

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
693

Hi Ranjna,

You will get your answer when you debug the program and check how MONTH2 is populated. It depends on how you will the range.

You might be aware that a select option like a range has the following fields:

SIGN, OPTION, LOW and HIGH

Now, say you put from 1 to 12 in your select option on the selection screen, then only one record will be created in the MONTH2 range table as follows:

SIGN OPTION LOW HIGH

I BT 1 12.

Hence, when you loop through MONTH2, there will be only one value for LOW i.e. 1.

You need to instead do the following:


data: begin of itab occurs 0, month2 type ztable-month2, end of itab.
SELECT month2 FROM ztable INTO TABLE itab
WHERE month2 IN month2.
IF sy-subrc EQ 0.
 LOOP AT itab.
  CASE itab-month2.
  WHEN '1'. 
  PERFORM JAN_DATA .
  WHEN '2'.
  PERFORM FEB_DATA .
  ENDCASE.
 ENDLOOP.
ENDIF.

Cheers.

6 REPLIES 6
Read only

Former Member
0 Likes
693

Hi,

Can u explain ur requirement clearly.

Kavitha.

Read only

0 Likes
693

thanks .

in the selection screen i have to write each month individually , but i want to give range e.g zmonth 1 to 12.

than it should display for 12 month , but it is showing for jan month ie not takinh high value .

Read only

0 Likes
693

Hi, Pasting your code esp. in routines JAN_DATA & FEB_DATA can get you better solutions in handling your requirement. Maybe the select-option parameter can be used directly in data extraction instead of looping on SELECT-OPTION.

Read only

Former Member
0 Likes
693

Please provide ur requirement clear.

Read only

Former Member
0 Likes
694

Hi Ranjna,

You will get your answer when you debug the program and check how MONTH2 is populated. It depends on how you will the range.

You might be aware that a select option like a range has the following fields:

SIGN, OPTION, LOW and HIGH

Now, say you put from 1 to 12 in your select option on the selection screen, then only one record will be created in the MONTH2 range table as follows:

SIGN OPTION LOW HIGH

I BT 1 12.

Hence, when you loop through MONTH2, there will be only one value for LOW i.e. 1.

You need to instead do the following:


data: begin of itab occurs 0, month2 type ztable-month2, end of itab.
SELECT month2 FROM ztable INTO TABLE itab
WHERE month2 IN month2.
IF sy-subrc EQ 0.
 LOOP AT itab.
  CASE itab-month2.
  WHEN '1'. 
  PERFORM JAN_DATA .
  WHEN '2'.
  PERFORM FEB_DATA .
  ENDCASE.
 ENDLOOP.
ENDIF.

Cheers.

Read only

dhruv_shah3
Active Contributor
0 Likes
693

Hi Ranjna,

Is month2 your Internal Table. Here you have specified as the name of Select Options.

pls you have to loop it on internal table and then check tht month2-low is equal to your condition or not...

Thanks & regards,

Dhruv Shah