2010 Jan 13 11:39 AM
Hi ,
My internal table having the below data.
2340-8901
4566-8902
5672-8901
4567-8903
3435-8904
2345-8903
Only 8901 or 8902, or 8903 or 8904 will there in end of string I want to replace with space like below
2340
4566
5672
4567
3435
2345
Instead of writing 4 times of replace statement in the Loop . I wrote like below. But it is not working . Correct me where I am going wrong
loop at lit_tab.
lw_tabix1 = sy-tabix.
CLEAR : lw_len.
if lit_tab-xblnr CS '-8901' AND
lit_tab-xblnr CS '-8902' AND
lit_tab-xblnr CS '-8903' AND
lit_tab-xblnr CS '-8904'.
lw_len = sy-fdpos.
lit_tab-xblnr = lit_tab+0(lw_len).
MODIFY lit_tab INDEX lw_tabix1 TRANSPORTING xblnr.
clear lit_tab.
endif.
ENDLOOP.
Regards,
Ajay
Edited by: Ajay reddy on Jan 13, 2010 12:39 PM
2010 Jan 13 11:41 AM
Hi Ajay,
The condition should be OR , not AND.
regards,
amit m.
2010 Jan 13 11:41 AM
Hi Ajay,
The condition should be OR , not AND.
regards,
amit m.
2010 Jan 13 11:41 AM
Hello,
Well if the number of characters is fixed, you can try this
loop at itab.
itab-field1 = itab-field1+0(4).
modify itab.
endloop.
Vikranth
2010 Jan 13 11:43 AM
Hi Vikranth
Only 8901 or 8902, or 8903 or 8904
May be you missed to read this.
2010 Jan 13 11:43 AM
Hi Vikki,
Sorry !! the number of chars not same . it migh be 34567999-8902 or
like char also ...... RTYUHU-8901
i need to display 34567999
RTYUHU
regards
Aj
2010 Jan 13 12:00 PM
check
loop at lit_tab.
lw_tabix1 = sy-tabix.
if lit_tab-xblnr CS '-8901' or lit_tab-xblnr CS '-8902' or lit_tab-xblnr CS '-8903' or lit_tab-xblnr CS '-8904'.
split lit_tab-xblnr at '-' into lv1 lv2.
lit_tab-xblnr = lv1.
clear lv1.
MODIFY lit_tab INDEX lw_tabix1 TRANSPORTING xblnr.
clear lit_tab.
endif.
ENDLOOP.
or
check if this works
loop at lit_tab.
lw_tabix1 = sy-tabix.
if lit_tab-xblnr CS '-8901' or lit_tab-xblnr CS '-8902' or lit_tab-xblnr CS '-8903' or lit_tab-xblnr CS '-8904'.
lit_tab-xblnr = lit_tab-xblnr+sy-fdpos(*) = space.
MODIFY lit_tab INDEX lw_tabix1 TRANSPORTING xblnr.
clear lit_tab.
endif.
ENDLOOP.
Edited by: Keshav.T on Jan 13, 2010 5:31 PM
2010 Jan 13 11:42 AM
2010 Jan 13 11:43 AM
Hi Ajay,
Please check out below modification in your code. Use 'OR' insted of 'AND'.
if lit_tab-xblnr CS '-8901' OR
lit_tab-xblnr CS '-8902' OR
lit_tab-xblnr CS '-8903' OR
lit_tab-xblnr CS '-8904'.
lw_len = sy-fdpos.
lit_tab-xblnr = lit_tab+0(lw_len).
MODIFY lit_tab INDEX lw_tabix1 TRANSPORTING xblnr.
Thanks,
Archana
2010 Jan 13 11:45 AM
>if lit_tab-xblnr CS '-8901' AND
>lit_tab-xblnr CS '-8902' AND
>lit_tab-xblnr CS '-8903' AND
>lit_tab-xblnr CS '-8904'.
ajay,
is it possible that all 4 condition be true at the same time
so its not AND its OR..
2010 Jan 13 11:46 AM
Hi
Why don't you try splitting the string at '-' then you've got youre first
part sepperated.
Split wa at '-' into var1 var2.
2010 Jan 13 11:49 AM
Well am still not sure if i understood your question properly seeing Keshu's reply
If the number is not fixed try with split
loop at itab.
Split itab-field at '-' into var1 var2.
itab-field = var1.
modify itab.
endloop.
Vikranth
2010 Jan 13 11:49 AM
Hi ajay,
we can also use this simple logic. Just extend it to your variables and values.
report abc.
data : abc(15) type c.
abc = '2340-8901'.
write :/ abc.
if abc cs '-8901' or abc cs '-8902'.
abc = abc(sy-fdpos).
endif.
write :/ abc.
regards,
amit m.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |