2016 Jun 13 9:00 PM
Hi All,
My Decimal notation profile is USR01-DCPFM = SPACE ( Blank value ) i.e. Thousand's separator is '.' and decimal is ','
In VA01, if I enter Condition value = 1.24,34 , I get error - ' Input must be in the format __.___.___.__~,__V'.
I want to replicate same standard behavior in my custom report where I will be getting this amounts in excel file.
I want to check if file has invalid entries such as 1.24,34 or not . If yes error message ' Input must be in the format __.___.___.__~,__V' is to be given.
I tried with FM 'HR99L00_CONV_FROM_EDIT_MASK_IN ' by passing input = 1.24,34 and P_EDIT_MASK = __.___.___.__~,__V.
It gives expected error but for correct value input = 1.234,45 also it gives error input must be in the format __.___.___.__~,__V.
Can anybody please let me know where I am doing mistake.
Thanks,
Jit
Hi All,
My Decimal notation profile is USR01-DCPFM = SPACE ( Blank value ) i.e. Thousand's separator is '.' and decimal is ','
In VA01, if I enter Condition value = 1.24,34 , I get error - ' Input must be in the format __.___.___.__~,__V'.
I want to replicate same standard behavior in my custom report where I will be getting this amounts in excel file.
I want to check if file has invalid entries such as 1.24,34 or not . If yes error message ' Input must be in the format __.___.___.__~,__V' is to be given.
I tried with FM 'HR99L00_CONV_FROM_EDIT_MASK_IN ' by passing input = 1.24,34 and P_EDIT_MASK = __.___.___.__~,__V.
It gives expected error but for correct value input = 1.234,45 also it gives error input must be in the format __.___.___.__~,__V.
Can anybody please let me know where I am doing mistake.
Thanks,
Jit
2016 Jun 13 9:54 PM
I don't think this function module will help you to check the number format. AFAIK, It expects the input to have the same length as the edit mask. I couldn't see a handling of sign in the function module. If you want to convert the input number into SAP format, you can just use this method. It uses user setting to convert input value into number.
Thanks,
Juwin
2016 Jun 14 7:43 AM
Hi Juwin,
I can convert Amount form external format to internal format. But problem is to detect invalid values and throw error for such records in input file.
Eg: if I pass invalid amount 1.24,56 for USR01-DCPFM = SPACE then I should throe error.
Otherwise this amount will be saved as 124. 56 in database as per the logic to convert values from ext. to internal format.
Is there any way by which I can detect such erroneous values.
Please let me know.
Thanks,
Jit
2016 Jun 14 1:54 PM
How long is your number field? Does it include signs?
Thanks,
Juwin
2016 Jun 14 7:50 AM
Use a TRY - CATCH - ENDTRY block with a cx_sy-conversion_no_number error.
Rich
2016 Jun 14 8:06 AM
Hi Rich,
Didn't get your solution. For what you want me to use TRY -CATCH block.
Please elaborate little more.
Thanks,
Jit
2016 Jun 14 11:12 AM
To perform the functionality that you wish to perform. ie. To catch invalid numeric values.
You TRY to move your value from the excel file to a numeric variable, you then CATCH the exception which is raised when the value does not conform to the definition or a number where by you then issue an appropriate error message.
In your editor type 'TRY', put the cursor on it and press the F1 key.
Rich
2016 Jun 14 12:45 PM
Hi Rich,
I want to check if values are invalid in terms of Thousand's separator.
I tried moving value 13.21,19 to variable declared with below type:
DATA lv_num(10) TYPE n.
Although it's invalid number in terms of thousand's separator, it did not raise any exception.
Output - lv_num = 0000132119.
Regards,
Jit
2016 Jun 14 2:15 PM
This is true even on SAP screens. SAP doesn't expect user to put in thousand separators while entering numbers on screens - it is purely optional.
Thanks,
Juwin
2016 Jun 14 3:52 PM
And that code will do just that.
Use a numeric field, NOT a string field that accepts only numbers. Something like a type of Menge_D. Then move your invalid number to it and see what happens.
A NUMC field strips out any invalid characters when you move stuff to it. It is also a string field, which is not what you were talking about above (ie a number field).
Rich
2016 Jun 14 4:58 PM
Hi Juwin,
I guess that's partially true.. If you put Condition Amt= 1.23,45 in VA02- Condition tab it also gives error input must be in the format __.___.___.__~,__V.
So SAP expects to put input in correct format if we are adding thousand separators manually.
So if input file is having invalid value as 1.23,45 then I should throw an error.
2016 Jun 14 5:00 PM
2016 Jun 14 5:10 PM
Yes, if you add it, then SAP expects them to be in correct format.
Why are you so concerned about the format only? Is your primary intention to read the input value or just validate the format?
Thanks,
Juwin
2016 Jun 14 10:31 PM
In what way ?
It will detect if the user enters a number that cannot be translated to a number and then you can issue an error message to suit.
In what way does that not suit your requirement ?
2016 Jun 15 8:37 AM
My requirement is to determine if Amount has correct thousand's separator or not and not whether Amount amount is alphanumeric.
I tried your solution of declaring variable of type 'N' and passing amount field to it but it is not working.
2016 Jun 15 12:33 PM
Read what I said - a numeric field something like Menge_d, and not a NUMC field. (ie a string field that only accepts numbers).
And THEN it will work.
Your requirement is so simple!
2016 Jun 16 6:47 AM
Rich.. I have already tried your solution..
If you move Amount 1.23,45 to variable declared with Data element NETWR_AP then it will give dump for the obvious reason that 1.23,45 contains comma and it's not in SAP's internal number format.
As I have mentioned my requirement is to determine if Amount has correct thousand's separator.
Moving amt to numeric field with Data element NETWR_AP will not help as it will give dump just because amount is not in internal number format.
2016 Jun 16 7:47 AM
You obviously have not tried what I suggested if you are getting short dumps.
I will spell it out for you:
Try.
l_Number_Field = '1.23456,78'.
Catch CX_SY_CONVERSION_NO_NUMBER.
Message 'That number is erroneous'.
EndTry.
Rich
2016 Jun 16 8:17 AM
Below is the code I tried again:
DATA : lv_amt TYPE netwr_ap.
TRY.
lv_amt = '1.234,78'.
CATCH cx_sy_conversion_no_number.
MESSAGE 'That number is erroneous' TYPE 'I'.
ENDTRY.
Here 1.234,78 is correct amount from thousand's separator perspective and still the exception is raised which is wrong...
2016 Jun 16 9:01 AM
Ok, prior to trying this you need to remove any group separators that are appropriate for the decimal notation being used. Group separators can either be ',', '.' or a space. You can determine the group separator by getting the position of the dot in the string and then the comma or space.
If the comma or space's position is less than the dot then the gs is a comma or space. If the dot is less than the comma or spaces position then the gs is a dot. You need to make a special case if these characters do not appear in the string.
At that point you have an answer as to whether the format is somewhat correct. You can then remove the gs's and use the TRY block to determine if it is an actual number or not.
Rich
2016 Jun 16 10:06 AM
Richard Harper wrote:
If the comma or space's position is less than the dot then the gs is a comma or space. If the dot is less than the comma or spaces position then the gs is a dot. You need to make a special case if these characters do not appear in the string.
Rich
This was my first query which i mentioned in original post.. Is there any standard method ot FM which checks thousand's separator correctness.
2016 Jun 16 12:34 PM
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |