{"id":958,"date":"2014-04-13T11:33:15","date_gmt":"2014-04-13T10:33:15","guid":{"rendered":"http:\/\/oprsteny.cz\/?p=958"},"modified":"2014-04-13T11:33:15","modified_gmt":"2014-04-13T10:33:15","slug":"abap-treating-different-number-formats","status":"publish","type":"post","link":"https:\/\/oprsteny.cz\/?p=958","title":{"rendered":"ABAP &#8211; Treating different number formats"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"358\" data-permalink=\"https:\/\/oprsteny.cz\/?attachment_id=358\" data-orig-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/SAP.jpg\" data-orig-size=\"44,50\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;Picasa&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1365690880&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"SAP\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/oprsteny.cz\/wp-content\/uploads\/SAP.jpg\" class=\"alignleft size-full wp-image-358\" alt=\"SAP\" src=\"http:\/\/oprsteny.cz\/wp-content\/uploads\/SAP.jpg\" width=\"44\" height=\"50\" \/>You might face a problem when users have number format set differently in their user profiles (TCode SU01, table USR01). By default there are 3 formats available and this can cause troubles when processing user entered data and converting it into internal SAP DB format. <!--more-->Therefore you can use the following piece of code to check which format is applied on the user&#8217;s PC and format the numbers accordingly.<\/p>\n<pre lang=\"abap\">DATA:\r\n  l_dcpfm    TYPE usr01-dcpfm,\r\n  l_db_value TYPE char30,\r\n  l_number   TYPE dec5_2 .\r\n\r\nSELECT SINGLE dcpfm\r\n  INTO l_dcpfm\r\n  FROM usr01\r\n  WHERE bname = sy-uname.\r\n\r\nCASE l_dcpfm.\r\n  WHEN ''.               \"Format: 1.234.567,89\r\n    REPLACE ALL OCCURRENCES OF '.' IN l_db_value WITH ''.\r\n    TRANSLATE l_db_value USING ',.'.\r\n  WHEN 'X'.              \"Format: 1,234,567.89\r\n    REPLACE ALL OCCURRENCES OF ',' IN l_db_value WITH ''.\r\n  WHEN 'Y'.              \"Format: 1 234 567,89\r\n    TRANSLATE l_db_value USING ',.'.\r\nENDCASE.\r\n\r\nTRY.\r\n    l_number = l_db_value.\r\n  CATCH cx_sy_conversion_no_number.\r\nENDTRY.<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>You might face a problem when users have number format set differently in their user profiles (TCode SU01, table USR01). By default there are 3 formats available and this can cause troubles when processing user entered data and converting it &hellip; <a href=\"https:\/\/oprsteny.cz\/?p=958\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"ABAP - How to treat different number formats","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[16,86,9],"tags":[279,35,277,278],"class_list":["post-958","post","type-post","status-publish","format-standard","hentry","category-abap","category-alv","category-development","tag-dcpfm","tag-format","tag-number","tag-usr01"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p3nYbe-fs","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts\/958","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=958"}],"version-history":[{"count":1,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts\/958\/revisions"}],"predecessor-version":[{"id":959,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=\/wp\/v2\/posts\/958\/revisions\/959"}],"wp:attachment":[{"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=958"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=958"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oprsteny.cz\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=958"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}