Tips and Tricks
Converting Timestamp Formats
Timestamps that are generated and processed in ABAP do not have the timestamp format that is used in JAVA or other programming languages. The following ABAP expression can be used to convert the ABAP timestamp value to the ISO format yyyy-mm-dd-hh:mm:ss as of Basis Release 7.02:
ev_conv_tstmp = |{ iv_time_stamp TIMESTAMP = ISO TIMEZONE = 'UTC ' }|
Linking Individual Quotation Marks Using Text String
Use Case: When linking string variables, the string variables are to be put in single quotation marks.
Example: Output of text string 'Template'Text' Module'
CONCATENATE 'Vorlagen' 'text' '-Baustein' INTO lv_result.
Result: lv_result = 'Template Text Module'
Solution: Use double quotation marks to enclose a text string with simple quotation marks. See constant GC_TXT_QM of the class CL_PCO_QUERY:
CONCATENATE 'Vorlagen' cl_pco_query=>gc_txt_qm 'text' cl_pco_query=>gc_txt_qm '-Baustein' INTO lv_result.
Result: lv_result = 'Template'Text' Module'
Linking Spaces Using Text String
Use Case: The linking of text string variables that contain a space (SPACE) results in a text string in which there is no longer a space.
Example: Output of text string 'ABCD EFGH'
Result: lv_string_3 = 'ABCDEFGH'
Solution: Use simple quotation marks to disguise spaces.
See constant GC_TXT_SP of the class CL_PCO_QUERY:
CONCATENATE lv_string_1 cl_pco_query=>gc_txt_sp lv_string_2 INTO lv_string_3.
Result: lv_string_3 = 'ABCD EFGH'
Converting and Formatting Floating Point Numbers
Floating point numbers can have either a scientific format (1.2345E01) or a decimal format (12.345). If floating point numbers are to be displayed in the ABAP system, one of three decimal point formats is used. The system uses the user master record (table USR01, field DCPFM) to determine the formatting settings of the user that is logged on. The following format templates are available in the system:
-
Decimal format: 1,234,567.89 (USR01-DCPFM = 'X')
-
Decimal format: 1 234 567,89 (USR01-DCPFM = 'Y')
-
Decimal format: 1.234.567,89 (USR01-DCPFM = '')
Two cases need to be differentiated with regard to Business Suite integration:
-
Floating point numbers are converted to string variables and added to the CDATA segment of the PCo query. The Business Suite application then uses an RFC call to transfer the content of the PCo query to PCo.
-
The Business Suite receives floating point numbers as the result of PCo queries in the form of data references. The data references are converted to string variables and output in the results view of the test program.
When thousand separators are used, it is difficult to effect the correct formatting of the floating point numbers for the value display: There is no standard SAP solution for this problem. Approaches to this challenge, which are discussed on the Internet (for example, SDN thread 1449990 and SDN thread115017), do not provide a sufficient solution.
Transferring Floating Point Numbers from Business Suite to PCo:
To transfer floating point numbers from Business Suite applications to PCo it is necessary to convert the floating point number to a string value. The string value is then part of the query data string, which is then transferred to PCo using an RFC call. At the same time, the decimal separators are unified and the thousand separator is removed (see class CL_PCO_UTILITY, method CONVERT_STRVAL_TO_SDT_DREF). PCo can then process the string values formatted in this way directly without any further conversions.
Displaying Floating Point Numbers Transferred from PCo to the Business Suite:
In the test program RPCO_BS_INT_TEST, the floating point numbers are displayed in the decimal format. The system can use the instance method FORMAT_FLOAT_CHAR (class CL_PCO_UTILITY) to set the thousand and decimal separators according to the formatting settings in the user master record of the current user. In the method mentioned, a specific algorithm is defined that guarantees the correct placing of the thousand and decimal separators.