05-30-2013 2:41 PM
Hi experts,
In BW i have to compare 2 fields with a statement Read Table with key.
The issue is that the 2 fields that I have to compare even if they contain the same kind of information, they have different lenghts, both of them are char, but the difference will be like this example because of lenghts:
Field1 : 0001
Field2: 00000001
As you see, both of them contain information 1 but with different lenghts, how can i bypass this in a Read table with key statment?
Thanks for your support.
Amine
05-30-2013 2:47 PM
Hi Amine,
Not sure this is what you need, but try using conversion exit:
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = FIELD1
IMPORTING
OUTPUT = FIELD1_AUX.
Declare FIELD1_AUX same type as FIELD2.
Then use field1_aux to read table.
Hope this helps.
Cheers,
Custodio
05-30-2013 2:44 PM
Operator | Meaning |
CO | Contains Only: True, if operand1 only contains characters from operand2. Upper/lower case and trailing blanks are taken into account for both operands. If operand2 is of type string and is initial, then the logical expression is false, unless operand1 is also of type string and is initial, in which case the logical expression is always true. If the result of the comparison is negative, sy-fdpos contains the offset of the first character in operand1, that is not contained in operand2. If the result of the comparison is positive, sy-fdpos contains the length of operand1. |
CN | Contains Not Only; True if a logical expression with CO is false, that is, if operand1 contains not only characters from operand2. sy-fdpos is set in the same way as for CO. If the comparison is true, sy-fdpos contains the offset of the first character in operand1 that is not contained in operand2. If the comparison is false, sy-fdpos contains the length of operand1. |
CA | Contains Any: True, if operand1 contains at least one character from operand2. Upper/lower case and trailing blanks are taken into account for both operands. If operand1 or operand2 is of type string and initial, the logical expression is always false. If result of the comparison is positive, sy-fdpos contains the offset of the first character in operand1 that is also contained in operand2. If the result of the comparison is negative, sy-fdpos contains the length of operand1. |
NA | Contains Not Any: True if a logical expression with CA is false, that is if operand1 does not contain any characters from operand2. If the result of the comparison is negative, sy-fdpos contains the offset of the first character in operand1 that is also contained in operand2. If the result of the comparison is true, sy-fdpos contains the le of operand1. |
CS | Contains String: True if the content of operand2 is contained in operand1. Upper/lower case is not taken into account, trailing blanks of the left operand are taken into account. If operand1 is of type string and initial, or of type c and contains only blank characters, the logical expression is false, unless operand2 is also of type string and initial, or of type c and only contains blank characters. In this case the logical expression is always true. If the result of the comparison is true, sy-fdpos contains the offset of operand2 in operand1. If the result of the comparison is negative, sy-fdpos contains the length of operand1. |
NS | Contains No String: True, if a logical expression with CS is false, that is if operand1 does not contain the content of operand2. If the result of the comparison is negative, sy-fdpos contains the offset of operand2. If the comparison is true, sy-fdpos contains the length of operand1. |
CP | Covers Pattern: True, if the content of operand1 fits the pattern in operand2. Wildcard characters can be used for forming the operand2 pattern, where "*" represents any character string, and "+" represents any character. Upper/lower case is not taken into account. If the comparison is true, sy-fdpos contains the offset of operand2 in operand1, whereby leading wildcard characters "*" in operand2 are ignored if operand2 also contains other characters. If the comparison is false, sy-fdpos contains the length of operand1. You can select characters in operand2 for a direct comparison by adding the escape symbol "#" before the required characters. For these characters, upper/lower case is taken into account, wildcard characters and the escape symbol itself do not receive special treatment, and trailing blanks in operands of type c are not cut off. |
NP | No Pattern: True, if a logical expression with CP is false, that is, if operand1 does not fit the pattern operand2. If the comparison is false, sy-fdpos contains the offset of operand2 in operand1, whereby leading wildcard characters "*" in operand2 are ignored if operand2 also contains other characters. If the comparison is true, sy-fdpos contains the length of operand1. |
05-30-2013 2:47 PM
Hi Amine,
Not sure this is what you need, but try using conversion exit:
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = FIELD1
IMPORTING
OUTPUT = FIELD1_AUX.
Declare FIELD1_AUX same type as FIELD2.
Then use field1_aux to read table.
Hope this helps.
Cheers,
Custodio
05-30-2013 2:59 PM
Type conversion can be done before read table like this.
TYPES:
BEGIN OF ty,
field TYPE n LENGTH 4,
END OF ty,
tty TYPE TABLE OF ty.
DATA wa TYPE ty.
DATA it TYPE tty.
DATA value1 TYPE n LENGTH 8 VALUE 1.
DATA key1 TYPE n LENGTH 4.
APPEND '0002' TO it.
APPEND '0001' TO it.
APPEND '0005' TO it.
key1 = value1. "type conversion
WRITE:/ key1, value1.
READ TABLE it INTO wa WITH KEY field = key1.
IF sy-subrc EQ 0.
WRITE:/ wa-field, key1, value1.
ENDIF.
05-30-2013 3:21 PM
05-31-2013 1:23 AM
By the way, in ABAP 7.40 you will be able to read it directly. Keep one eye on 's blog for more information.
Horst Keller wrote:
I love these questions hitting the mark.
No, you didn't miss it, conversion routines are simply not supported in string tenplates. If there is a large demand for an important general routine, it might be covered by a special format option. E.g. with Release 7.40 is a new option ALPHA was introduced, that does the same as CONVERSION_EXIT_ALPHA_INPUT or CONVERSION_EXIT_ALPHA_OUTPUT.
horst.keller: ABAP News for Release 7.40 - Expr... | SCN
Cheers,
Custodio
05-31-2013 9:08 AM