‎2014 Sep 29 3:01 PM
Dear All,
I have below requirement can any one plz help me.
In this below string i want to remove GB it is country key and this key is dynamic .how to remove it ?
DATA : L_var1 TYPE string .
l_var1 = ' Ledger 0L VAT reg.no.: GB602372281 RFASLM00/SAPUSER Page 1'.
Thanks,
Raj.
‎2014 Sep 29 3:07 PM
‎2014 Sep 29 3:17 PM
Hi Raj,
How you populate the vat reg in the string. You may move the value from databse selection and move it to string by concatenation.
If so then while concatenating VAT REgNO & the value you can remove the Country key by checking if the VAT no CA 'ABCD.....Z' then do not concatenate that part to the string.
Hope it helps.
Regards,
K.S
‎2014 Sep 29 3:35 PM
‎2014 Sep 29 3:42 PM
check for VAT reg.no. using CS and then pick up offset using Sy-fdpos then sy-fdpos+lengthof (VAT reg.no.) and this would be teh position where your country key starts, you can now remove it.
‎2014 Sep 29 8:32 PM
Hi Raj,
As you say all are no's except GB or can be any other country.
Declare a variable of type numeric,
move the contents of the vat which contains GB123456.
then it will contai only nos without country, provided all nos will come after GB, i.e.,GB doesn't come in between no's.if the format is different please send the possible formats.
Hope this helps.
Regards,
K.S
‎2014 Sep 29 3:20 PM
1. Use SPLIT statement to split your string at ':'
Like SPLIT lv_var1 into l_split_1 l_split_2 at ':'.
2. In your second temporary variable you will have l_split_2 = GB1234567
3. l_var3 = l_split_2+2(10). " this will pass your digits of VAT no.
4. Concatenate l_split_1 l_var3 into l_final.
This is just an idea how you can achieve it.
‎2014 Sep 29 3:39 PM
Hi Raj,
Try this,
REPORT ztezt.
DATA text TYPE string VALUE 'I know you know GB602372281 RFA'.
DATA: text1 TYPE string,
text2 TYPE c LENGTH 48,
off TYPE i,
lv_len TYPE i,
len TYPE i.
lv_len = strlen( text ).
FIND 'GB' IN text MATCH OFFSET off
MATCH LENGTH len.
REPLACE SECTION OFFSET off LENGTH len OF:
text WITH ' '.
lv_len = lv_len - off.
lv_len = lv_len - 2.
SPLIT text+off(lv_len) at space into text1 text2.
WRITE: text.
‎2014 Sep 29 4:10 PM
GB is not constant it is dynamic...it may be IN or US or DE like that..
‎2014 Sep 29 4:17 PM
Hi Raj,
Try any of the 3 steps:
1. The offset of the Country code is it constant?. i.e., it always comes at 16th position for example. If so try to hard code offset directly.
2. check you might find his country code in local or global variables. Based on that you can change your Find syntax.
3. You have to find the company code from respective table based on key and write the syntax based on that.
With Regards,
Giriesh M
‎2014 Sep 29 9:14 PM
data: lv_vat type string value 'GB602372281'.
replace all occurance of sy-abcd in lv_vat by space.
condence lv_vat.
‎2014 Sep 30 9:08 AM
You need to first define how to recognize country key before trying to remove it.
I am assuming that it would be first 2 alphabets that appear right after string ' VAT reg.no.: ' and I am replacing only the first occurrence.
Have a look at this snippet.
/.
‎2014 Sep 30 10:15 AM