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

Ranges

Former Member
0 Likes
1,000

Hi experts,

I gave input in tcode range 'ks02,MM02,LT03'.

i want tcodes changes only which are in Tcode ranges as mentioned above.Remaining tcodes i want to delete.

For this i have used this statement.

DELETE icdhdr WHERE NOT TCODE in r_tcode.

But still i am getting all tcodes which are not in Tcode ranges.

How to remove the unwanted tcodes.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
944

Hi,

the problem may be with the ranges.

r_tcode-sign = 'I'.
r_tcode-option = <b>'EQ'.</b>
r_tcode-low = v_frm.
r_tcode-high = v_to.
append r_tcode.
clear r_tcode.

and check the r_tcode values in debug mode...

it should be EQ not BT.

it works very well for me,

just check it

REPORT  ZTEST_RANGE                             .

RANGES : R_TCODE FOR SY-TCODE.
DATA: BEGIN OF ITAB OCCURS 0,
       TCODE LIKE SY-TCODE,
      END OF ITAB.

R_TCODE-LOW = 'KS02'.
R_TCODE-SIGN = 'I'.
R_TCODE-OPTION = 'EQ'.
APPEND R_TCODE.
R_TCODE-LOW = 'MM02'.
R_TCODE-SIGN = 'I'.
R_TCODE-OPTION = 'EQ'.
APPEND R_TCODE.
R_TCODE-LOW = 'LT03'.
R_TCODE-SIGN = 'I'.
R_TCODE-OPTION = 'EQ'.
APPEND R_TCODE.
"9 reocrds are there
ITAB-TCODE = 'MM01'.
APPEND ITAB.
ITAB-TCODE = 'VA02'.
APPEND ITAB.
ITAB-TCODE = 'VA01'.
APPEND ITAB.
ITAB-TCODE = 'VL01'.
APPEND ITAB.
ITAB-TCODE = 'MM02'.
APPEND ITAB.
ITAB-TCODE = 'MM03'.
APPEND ITAB.
ITAB-TCODE = 'KS02'.
APPEND ITAB.
ITAB-TCODE = 'MM02'.
APPEND ITAB.
ITAB-TCODE = 'LT03'.
APPEND ITAB.
DELETE ITAB WHERE TCODE NOT IN R_TCODE.
break-point.
"now only 4 records are there

Vijay

7 REPLIES 7
Read only

Former Member
0 Likes
944

Hi silviya,

1. Use like this :

loop at icdhdr.

if icdhdr-tcode in r_tcode.

else.

delete icdhdr.

endif.

endloop.

regards,

amit m.

Read only

Former Member
0 Likes
944

Hi Silviya,

I had checked with ur delete statement , its working fine

How did u give the tcode ranges?did u click on the extension button of select options and give the 3 tcodes.

check if u had given spaces before tcodes while giving input.

check my code.

&----


*& Report YCHATEST *

*& *

&----


*& *

*& *

&----


REPORT YCHATEST .

tables : tstc.

data:begin of it_tcode occurs 0,

tcode like tstc-tcode,

end of it_tcode.

selection-screen begin of block b1.

select-options : s_tcode for tstc-tcode.

selection-screen end of block b1.

it_tcode-tcode = 'KS02'.

append it_tcode.

it_tcode-tcode = 'MM02'.

append it_tcode.

it_tcode-tcode = 'LT03'.

append it_tcode.

it_tcode-tcode = 'VA01'.

append it_tcode.

clear it_tcode.

delete it_tcode where not tcode in s_tcode.

write : / 'a'.

i had given Ks02 , mm02 and lt03 in the range and i got those 3 in my internal table at last , it had deleted va01.

Read only

Former Member
0 Likes
944

Hi ,

Try this ..

delete icdhdr where not ( TCODE in r_tcode).

Please reward if useful.

Regards,

Sriranjani.

Read only

Former Member
0 Likes
944

Hi,

ranges : r_tcode for sy-tcode.

r_tcode-low = 'KS02'.

r_tcode-sign = 'I'.

r_tcode-option = 'EQ'.

append r_tcode.

r_tcode-low = 'MM02'.

r_tcode-sign = 'I'.

r_tcode-option = 'EQ'.

append r_tcode.

r_tcode-low = 'LT03'.

r_tcode-sign = 'I'.

r_tcode-option = 'EQ'.

append r_tcode.

<b>delete icdhdr where TCODE not in r_tcode.</b>

Regards

vijay

Read only

0 Likes
944

I agree with u all.but problem is..

This is range for TCODE.

ranges : r_tcode for struct-TCODE.

this is Hard coded value for TCODE

Transaction_code = 'KS02,LT03,XK02'

this hard coded value will pass through the following subroutines.

I want to delete Tcodes which are not in Tcode ranges.

*FOR Transcation Code

form ranges.

do.

split Transaction_code at '^' into v_range Transaction_code.

split v_range at ',' into v_frm v_to.

shift v_frm left deleting leading ' '.

shift v_to left deleting leading ' '.

if v_frm eq '' and v_to eq ''.

exit.

endif.

if v_frm ne '' and v_to ne ''.

r_tcode-sign = 'I'.

r_tcode-option = 'BT'.

r_tcode-low = v_frm.

r_tcode-high = v_to.

append r_tcode.

clear r_tcode.

elseif v_to ne '' and v_frm eq '' .

r_tcode-sign = 'I'.

r_tcode-option = 'EQ'.

r_tcode-low = v_to.

append r_tcode.

clear r_tcode.

elseif v_frm ne '' and v_to eq ''.

r_tcode-sign = 'I'.

r_tcode-option = 'EQ'.

r_tcode-low = v_frm.

append r_tcode.

endif.

enddo.

clear : v_range,v_frm,v_to.

Read only

Former Member
0 Likes
945

Hi,

the problem may be with the ranges.

r_tcode-sign = 'I'.
r_tcode-option = <b>'EQ'.</b>
r_tcode-low = v_frm.
r_tcode-high = v_to.
append r_tcode.
clear r_tcode.

and check the r_tcode values in debug mode...

it should be EQ not BT.

it works very well for me,

just check it

REPORT  ZTEST_RANGE                             .

RANGES : R_TCODE FOR SY-TCODE.
DATA: BEGIN OF ITAB OCCURS 0,
       TCODE LIKE SY-TCODE,
      END OF ITAB.

R_TCODE-LOW = 'KS02'.
R_TCODE-SIGN = 'I'.
R_TCODE-OPTION = 'EQ'.
APPEND R_TCODE.
R_TCODE-LOW = 'MM02'.
R_TCODE-SIGN = 'I'.
R_TCODE-OPTION = 'EQ'.
APPEND R_TCODE.
R_TCODE-LOW = 'LT03'.
R_TCODE-SIGN = 'I'.
R_TCODE-OPTION = 'EQ'.
APPEND R_TCODE.
"9 reocrds are there
ITAB-TCODE = 'MM01'.
APPEND ITAB.
ITAB-TCODE = 'VA02'.
APPEND ITAB.
ITAB-TCODE = 'VA01'.
APPEND ITAB.
ITAB-TCODE = 'VL01'.
APPEND ITAB.
ITAB-TCODE = 'MM02'.
APPEND ITAB.
ITAB-TCODE = 'MM03'.
APPEND ITAB.
ITAB-TCODE = 'KS02'.
APPEND ITAB.
ITAB-TCODE = 'MM02'.
APPEND ITAB.
ITAB-TCODE = 'LT03'.
APPEND ITAB.
DELETE ITAB WHERE TCODE NOT IN R_TCODE.
break-point.
"now only 4 records are there

Vijay

Read only

Former Member
0 Likes
944

Dear Silviya,

have you tried this:

r_tcode-low = 'KS02'.

r_tcode-sign = 'E'. -> excluded from selection

r_tcode-option = 'EQ'.

append r_tcode.

...

append the ranges table like this for every single tcode that you want to be excluded from the selection.

After that, the statement should work like this:

delete icdhdr where tcode in r_tcode.

Hope this helps, regards, Kathrin!