01-21-2008 3:21 PM
Hi!
I need to check in ABAP, if a given profit center (char 10) starts with P172. It could be filled with zeros -> 0000P17255. So I need to perform 2 actions:
1)
Lefttrim the 0 -> Result: P17255.
2)
Check, if the string starts with P172.
How can I do this in ABAP?
Thanks,
Konrad
01-21-2008 3:26 PM
data : var(10) type c.
move profit_center to var.
call conversion_exit_alpha_output
exporting
var
importing
var
condense var no-gaps.
if var+0(4) = 'P172'.
*--condition satisfied...
endif.
************************(or)****************
data : var(10) type c.
move profit_center to var.
shift var left deleting leading '0'.
if var+0(4) = 'P172'.
endif.
01-21-2008 3:26 PM
data : var(10) type c.
move profit_center to var.
call conversion_exit_alpha_output
exporting
var
importing
var
condense var no-gaps.
if var+0(4) = 'P172'.
*--condition satisfied...
endif.
************************(or)****************
data : var(10) type c.
move profit_center to var.
shift var left deleting leading '0'.
if var+0(4) = 'P172'.
endif.
01-21-2008 3:26 PM
01-21-2008 3:28 PM
Hi,
You can do as below :
1st scenario :
loop at itab.
"Below code will delete leading zero.
SHIFT itab-prctr LEFT DELETING LEADING '0'.
"Second scenario
if itab-prctr(4) = 'P1972'.
"Do necessary coding as per your requirment.
endif.
"If you wnat chnage tje contensts of the itab you can use modify else you append to append to another internal table.
endloop.
Thanks,
Sriram POnna
01-21-2008 3:33 PM
Hi
DATA: PROFIT(10) VALUE '0000P17255'.
WHILE PROFIT(1) = '0'.
SHIFT PROFIT.
ENDWHILE.
WRITE PROFIT.
IF PROFIT(4) = 'P172'.
WRITE 'P172'.
ENDIF.
Max