01-25-2006 8:30 PM
i want a solution for the problem.
i want to print the nos in this pattern.
1 2 3 4 5
5 4 3 2
2 3 4
4 3
3
01-25-2006 8:33 PM
01-25-2006 8:37 PM
Report just_joking.
write: / '1 2 3 4 5'.
write: / '5 4 3 2'.
write: / '2 3 4'.
write: / '4 3'.
write: / '3'.
***
Really just joking
(but isn't it a solution?!?!?)
P.S.: O.k. Rich, again some seconds faster. Get the points.
P.S.2: Seems that we're thinking the same way...
Message was edited by: Jürgen Mayer
01-25-2006 8:38 PM
oh! nice answer rich but i want to do it using loops.
plz send answer using loop concept.
01-25-2006 8:40 PM
Hi Prashanth,
Try this..
DATA: V_TEST value '1'.
WRITE:/ V_TEST.
DO 4 TIMES.
V_TEST = V_TEST + 1.
WRITE: V_TEST.
ENDDO.
WRITE:/ V_TEST.
DO 3 TIMES.
V_TEST = V_TEST - 1.
WRITE: V_TEST.
ENDDO.
WRITE:/ V_TEST.
DO 2 TIMES.
V_TEST = V_TEST + 1.
WRITE: V_TEST.
ENDDO.
WRITE:/ V_TEST.
DO 1 TIMES.
V_TEST = V_TEST - 1.
WRITE: V_TEST.
ENDDO.
WRITE:/ V_TEST.
Message was edited by: Phani Kiran Nudurupati
01-25-2006 8:45 PM
Ok, I figured. Try something like this.
report zrich_0002.
data: s type string.
data: begin of itab occurs 0,
s(1) type c,
end of itab..
s = '1 2 3 4 5'.
split s at space into table itab.
perform write_list.
sort itab descending by s.
perform write_list.
sort itab ascending by s.
perform write_list.
sort itab descending by s.
perform write_list.
sort itab ascending by s.
perform write_list.
*&---------------------------------------------------------------------*
*& Form write_list
*&---------------------------------------------------------------------*
form write_list.
loop at itab.
if sy-tabix = 1.
write:/ itab-s.
else.
write: itab-s.
endif.
endloop.
delete itab index 1.
endform.
Here is a little cleaner sample. Roughly the same.
report zrich_0002.
data: s type string.
data: switch(1) type c value 'A'.
data: begin of itab occurs 0,
s(1) type c,
end of itab..
s = '1 2 3 4 5'.
split s at space into table itab.
while sy-subrc = 0.
case switch.
when 'A'.
sort itab ascending by s.
switch = 'D'.
when 'D'.
sort itab descending by s.
switch = 'A'.
endcase.
perform write_list.
if itab[] is initial.
exit.
endif.
endwhile.
*&---------------------------------------------------------------------*
*& Form write_list
*&---------------------------------------------------------------------*
form write_list.
loop at itab.
if sy-tabix = 1.
write:/ itab-s.
else.
write: itab-s.
endif.
endloop.
delete itab index 1.
endform.
Regards,
Rich Heilman
01-25-2006 8:50 PM
01-25-2006 11:58 PM
> Unoffical Challenge!!!!!!
>
> Let's see how many DIFFERENT ways we can do this
> using ABAP.
>
> No, there is no prize, just the knowledge.
>
> Regards,
> Rich Heilman
Did I meet your challenge Rich? It was really challenging to come up with a generic solution. I tried mine with a couple of numbers and it seems to work. Of course, I didn't take care of negative number input.
01-26-2006 1:00 AM
Hi Srinivas,
I am trying a demo program with tabstrips.I dragged a tabstrip control and I just want to name the subscreens.I have 3 tab controls. I am using sap gui pagin technique.How do I name The subscreens. I can just name tab buttons or whole table control. I want to name the subscreens and assign them to push buttons.
Please help me.Dont mind If it is really bothering you.
Srinivas I f u can help me please answer this quoestion.
Regards,
Vijay.
01-25-2006 9:18 PM
hi i got solution using loops what i want.
and thanks for ur answers. they are also nice.
here how i have done.
data: f1 type i value 1,
f2 type i,
f3 type i value 6.
while f1 < 4.
f2 = f1.
f3 = f3 - 1.
while f2 <= f3.
write: f2.
f2 = f2 + 1.
endwhile.
write: /.
f1 = f1 + 1.
f2 = f2 - 1.
while f2 >= f1.
write: f2.
f2 = f2 - 1.
endwhile.
write: /.
endwhile.
01-25-2006 9:29 PM
Hi Prashanth,
I used Do loop & you used While loop.
we can do this any no of types....
01-25-2006 11:55 PM
Here is your solution for any number. Please reward and close the post if answered.
PARAMETERS: p_number TYPE i.
DATA: toggle TYPE c,
row_numbers TYPE i,
start TYPE i.
DO p_number TIMES.
NEW-LINE.
row_numbers = p_number - sy-index + 1.
IF toggle = space.
DO row_numbers TIMES.
start = start + 1.
WRITE start.
ENDDO.
toggle = 'X'.
ELSE.
DO row_numbers TIMES.
WRITE start.
start = start - 1.
ENDDO.
CLEAR toggle.
ENDIF.
ENDDO.
01-26-2006 3:54 AM
hi prashnath ,
hope this works ...
report zcount.
data : n type i value 5 , count type i value 1 , incr type i.
while n ne 0.
perform looping using count n incr.
n = n - 1.
count = count - incr.
endwhile.
form looping using count n incr.
if count > 3.
incr = -1.
else .
incr = 1.
endif.
skip.
do n times.
write : count.
count = count + incr.
enddo.
end form.
ps : reward points if helpful
01-26-2006 12:49 PM