Open hub: internal format in output file (neg numbers, …)
[hub] [Open]
Symptom
You load data into a file using an InfoSpoke. The internal format is always used for this. This can have the following undesired effects
1. If there are negative numbers under the extracted data, the minus sign is positioned after the number in the output file. However, you want the minus sign to be positioned before the number.2. If there are currency key figures under the extracted data, these are always written to the output file with two decimal places.3. If the extracted data contains currency key figures that are in a currency that does not use decimal places (such as Japanese Yen), these figures are too small by the factor 100 in the output file.4. If, among those currency key figures, there are currency key figures that have more than two decimal places in the external format, all decimal places over two are truncated from the key figure before they are converted to the two-character format. For example, a currency key figure that has the value 20001.23 in the external format is transferred as 2000.12. Bear this conversion in mind for the evaluation of the key figure.Other terms
Open hub, Business Add-In, less than zero, comma separated values (CSV), number, negative, minus
Reason and Prerequisites
When the data is copied from the open hub interface, it is copied from the display in the internal format directly to the string that is finally written to the file. In the internal display of a negative number, the minus sign is displayed after the number.
Solution
To correct the effects listed under ‘Symptom’, proceed as follows:
1. Minus sign for negative numbers: Create a Business Add-In implementation that has a copy of the source structure as its target structure (copy using Transaction SE11, for example, /BIC/CYMYSPOKE to ZMYSPOKE). Replace the negative number field (for example, MYNUMBER) with a sufficiently long character field (for example, MYNUMBER_CHAR with the data element CHAR20). Use the Business Add-In to move the minus sign in front of the number when you copy the data.
Sample source code:
zmyspoke-mynumber_char = /bic/cymyspoke-mynumber.
if zmyspoke-mynumber_char ca ‘-’.
shift zmyspoke-mynumber_char right deleting trailing ‘-’.
shift zmyspoke-mynumber_char left deleting leading ‘ ‘.
concatenate ‘-’ zmyspoke-mynumber_char into zmyspoke-mynumber_char.
endif.2. Number of decimal places: Create a Business Add-In (BAdI) implementation that has a copy of the source structure as its target structure (copy using Transaction SE11, for example, /BIC/CYMYSPOKE to ZMYSPOKE). Replace the key figure field in Transaction SE11 by an appropriately long DEC field with the required number of decimal places, for example, by choosing ‘Built-in type’. In the BAdI implementation, replace the contents of the field by dividing the original value by the power of 10 or multiplying the figure by the power of 10.
In the sample source code, a currency key figure MYNUMBER is multiplied by the factor 100 to provide a key figure MYNUMBER_YEN, which is defined without decimal places. This is required for the key figure for the currency Yen, for example:
zmyspoke-mynumber_yen = /bic/cymyspoke-mynumber * 100.