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 based on select-options

Former Member
0 Likes
1,115

Hi! All,

Based on the period entered on selection screen those hsl'nn' fields must be selected from faglflext table. That is, if period is 01 to 05 I need to display hsl01 to hsl05 fields, if it is period 11 then display hsl11 field. How do i do that?

<REMOVED BY MODERATOR>

Thank you,

-Priyanka

Edited by: Alvaro Tejada Galindo on Feb 11, 2008 5:49 PM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,063

Yo can use DO ... VARYING.

Put your cursor on DO and press F1.

Rob

10 REPLIES 10
Read only

Former Member
0 Likes
1,064

Yo can use DO ... VARYING.

Put your cursor on DO and press F1.

Rob

Read only

0 Likes
1,063

Hi! Jay,

The period in FAGLFLEXT is always 16 in our case. So I have to get all the periods in internal table and then filter out based on selction-screen into another internal table and display. I cant use your solution but thank you for your suggestion.

Hi! Rob,

Thank You for your advise. I have tried do...varying.

If the s_rpmax-low is 06 and I want from hsl01 to hsl06 then I can use do...varying ...from hsl01 next hsl02.

In my case, if s_rpmax-low is 06 then I should display only hsl06, if it is 06 - 09, then I should display hsl06, hsl07, hsl08, hsl09.

Kindly suggest a solution.

Thank You,

-Priyanka

Read only

0 Likes
1,063

Start with this:

DO VARYING amt FROM faglflext-hsl01 NEXT faglflext-hsl02.
  IF sy-index > period_sel. EXIT. ENDIF.
  CHECK NOT amt IS INITIAL.
  total = total + amt.
ENDDO.

Rob

Read only

0 Likes
1,063

Rob,

If user selects 01 to 06 I dont have a problem, problem is when it is 03 to 12.

How do I move gt_tab1-hsl03 to gl_tab2-hsl03 and so on

...............

till gt_tab1-hsl12 to gl_tab2-hsl12 dynamically.

Meaning if i use do...varying... hsl01 next hsl02, I will move from hsl01 to whatever the end condition is. But how to i dynamically change the starting point hsl01 in the do statement.

Thank You,

-Priyanka

Read only

0 Likes
1,063

Just a minor change:

DO VARYING amt FROM faglflext-hsl01 NEXT faglflext-hsl02.
  IF sy-index < period_sel_low. CONTINUE. ENDIF.
  IF sy-index > period_sel_high. EXIT. ENDIF.
  CHECK NOT amt IS INITIAL.
  total = total + amt.
ENDDO.

Rob

Read only

0 Likes
1,063

Rob,

I understand this part I am asking how to move gt_tab1-hslnn to gt_tab2-hslnn. Maybe I am confusing myself.

I need to display not only the total but also the individual fields. So if user wants periods 03 - 06, at sy-index = 3, I should move the amonut to gt_tab2-hsl03.

I have two similar structures

TYPES : BEGIN OF tab1,

racct LIKE faglflext-racct,

rbukrs LIKE faglflext-rbukrs,

prctr LIKE faglflext-prctr,

hsl01 LIKE faglflext-hsl01,

hsl02 LIKE faglflext-hsl02,

hsl03 LIKE faglflext-hsl03,

hsl04 LIKE faglflext-hsl04,

hsl05 LIKE faglflext-hsl05,

hsl06 LIKE faglflext-hsl06,

hsl07 LIKE faglflext-hsl07,

hsl08 LIKE faglflext-hsl08,

hsl09 LIKE faglflext-hsl09,

hsl10 LIKE faglflext-hsl10,

hsl11 LIKE faglflext-hsl11,

hsl12 LIKE faglflext-hsl12,

hsl13 LIKE faglflext-hsl13,

hsl14 LIKE faglflext-hsl14,

hsl15 LIKE faglflext-hsl15,

hsl16 LIKE faglflext-hsl16,

rtcur LIKE faglflext-rtcur,

END OF tab1.

gt_tab1 has values for all the periods. I should only move the fields user wants (gt_tab1-hsl03 to gt_tab2-hsl03...) values to the the second table and display. meaning

if sy-index < s_rpmax-low. move blanks to?????????

if sy-index = s_rpmax-low. move gv_amount to ???????continue.

if sy-index > s_rpmax-high. exit.

I hope i made myself understandable.

Read only

0 Likes
1,063

Now it's probably better to use field symbols, but you might also try:

DATA: out_ndex TYPE sy-index,
      amt      TYPE hsl01,
      amt_n    TYPE hsl01.

DO VARYING amt FROM gt_tab1-hsl01 NEXT gt_tab1-hsl02.
  IF sy-index < period_sel_low. CONTINUE. ENDIF.
  IF sy-index > period_sel_high. EXIT. ENDIF.
  CHECK NOT amt IS INITIAL.
  out_ndex = sy-index.
  DO VARYING amt_n FROM tab1-hsl01 NEXT tab1-hsl02.
    CHECK sy-index = out_ndex.
    amt_n = amt.
  ENDDO.
ENDDO.

Rob

Read only

former_member156446
Active Contributor
0 Likes
1,063

select-options: so_hsl type table-field.

loop at so_hsl.

so_hsl-low you contain your lover limit..

so_hsl-high you contain the upper limit you entered in the select option.

endloop.

Read only

Former Member
0 Likes
1,063

Hi,

Try this


 data : v_period(2) type n.

  v_temp = s_period-low.

  v_period = s_period-high  -  s_period-low.
 v_period = v_period + 1.

   Loop at itab.
       
       DO  v_period times.
        concatenate  'ITAB-HSL'  v_temp into v_value.
         write : / (v_value).                 
        v_temp = v_temp + 1.
       ENDDO.

   Endloop.

The output will be the values from HSL03  to  HSL12

Read only

0 Likes
1,063

Thank You very much for your responses.

I used the following logic and it worked well.

DO 16 TIMES.

IF lv_count IN s_rpmax.

*Find the field we are interested in

CONCATENATE 'GL_EXTRACT-HSL' lv_count+1(2) INTO lv_name.

ASSIGN (lv_name) TO <rqfield>.

gl_out_entries-hsltot = gl_out_entries-hsltot + <rqfield>.

CONCATENATE 'HSL' lv_count+1(2) INTO gl_out_entries-fieldname.

gl_out_entries-fieldvalue = <rqfield>.

if lv_count = 16.

APPEND gl_entries TO gt_entries.

endif.

ENDIF.

lv_count = lv_count + 1.

ENDDO.