Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .abapgit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
<REQUIREMENTS>
<item>
<COMPONENT>SAP_BASIS</COMPONENT>
<MIN_RELEASE>740</MIN_RELEASE>
<MIN_RELEASE>754</MIN_RELEASE>
</item>
</REQUIREMENTS>
<VERSION_CONSTANT>ZCL_CONVERT=&gt;C_VERSION</VERSION_CONSTANT>
<VERSION_CONSTANT>/APMG/CL_CONVERT=&gt;C_VERSION</VERSION_CONSTANT>
</DATA>
</asx:values>
</asx:abap>
19 changes: 14 additions & 5 deletions .github/workflows/reuse.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
# SPDX-FileCopyrightText: 2022 Free Software Foundation Europe e.V. <https://fsfe.org>
#
# SPDX-License-Identifier: CC0-1.0

name: REUSE Compliance Check

on: [push, pull_request,workflow_dispatch]
on: [push, pull_request, workflow_dispatch]

permissions:
contents: read

jobs:
test:
Reuse-Compliance-Check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
steps:
- name: Checkout
uses: actions/checkout@v4

- name: REUSE Compliance Check
uses: fsfe/reuse-action@v1
uses: fsfe/reuse-action@694eabb15673ec601ea19d4cd949969141372512 # v5.0.0
8 changes: 0 additions & 8 deletions .reuse/dep5

This file was deleted.

22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
![Version](https://img.shields.io/endpoint?url=https://shield.abappm.com/github/abapPM/ABAP-Convert/src/zcl_convert.clas.abap/c_version&label=Version&color=blue)
![Version](https://img.shields.io/endpoint?url=https://shield.abappm.com/github/abapPM/ABAP-Convert/src/%2523apmg%2523cl_convert.clas.abap/c_version&label=Version&color=blue)

[![License](https://img.shields.io/github/license/abapPM/ABAP-Convert?label=License&color=success)](https://github.com/abapPM/ABAP-Convert/blob/main/LICENSE)
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg?color=success)](https://github.com/abapPM/.github/blob/main/CODE_OF_CONDUCT.md)
[![REUSE Status](https://api.reuse.software/badge/github.com/abapPM/ABAP-Convert)](https://api.reuse.software/info/github.com/abapPM/ABAP-Convert)

# Convert Any Data Type

The last class you will need to convert between data types. Well, that's the goal 😁
The last class you will ever need to convert between data types. Well, that's the goal 😁

Do you remember how to convert a string to an xstring? How about an ABAP timestamp to Unixtime? Or a string to a CHAR with overflow check? Don't recall the syntax for the right string template to convert a timestamp to an ISO date? 🤔
Do you remember how to convert a string to an xstring? How about converting an ABAP timestamp to Unix time? Or a string to a CHAR with overflow check? Do you recall the syntax for the correct string template to convert a timestamp to an ISO date? 🤔

Look no further and use this class 😄

NO WARRANTIES, [MIT License](https://github.com/abapPM/ABAP-Convert/blob/main/LICENSE)

> [!NOTE]
> It might make sense to move various date/time conversions into a separate "Temporal" object like in [JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal). Open an issue to discuss if you're interested!
> It might make sense to move various date/time conversions into a separate "Temporal" object, like in [JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Temporal). Open an issue to discuss if you're interested!

## Usage

Create an instance with the source value and use one of the methods to get the target value.

```abap
DATA(str) = NEW zcl_convert( value )->to_string( ).
DATA(str) = NEW /apmg/cl_convert( value )->to_string( ).
" or
DATA(str) = zcl_convert=>create( value )->to_string( ).
DATA(str) = /apmg/cl_convert=>create( value )->to_string( ).
" or
DATA(conv) = NEW zcl_convert( ).
DATA(conv) = NEW /apmg/cl_convert( ).
DATA(str) = conv->from( value )->to_string( ).
```

Expand Down Expand Up @@ -56,13 +56,13 @@ Method | Description

`^` All date/time conversions include `timezone` as an optional parameter (default `UTC`).

`*` String and xstring conversions include `encodinng` (default `UTF8`) and `ignore_errors` as optional parameters.
`*` String and xstring conversions include `encoding` (default `UTF8`) and `ignore_errors` as optional parameters.

Constructor options:

Option | Description
-------|------------
`trim_strings` | Remove trailing spaces when convertin to string (including intermediate conversions)
`trim_strings` | Remove trailing spaces when converting to string (including intermediate conversions)

## Prerequisites

Expand All @@ -82,12 +82,12 @@ All contributions are welcome! Read our [Contribution Guidelines](https://github

You can install the developer version of ABAP CONVERT using [abapGit](https://github.com/abapGit/abapGit) either by creating a new online repository for `https://github.com/abapPM/ABAP-Convert`.

Recommended SAP package: `$CONVERT`
Recommended SAP package: `/APMG/CONVERT`

## About

Made with ❤ in Canada

Copyright 2025 apm.to Inc. <https://apm.to>

Follow [@marcf.be](https://bsky.app/profile/marcf.be) on Blueksy and [@marcfbe](https://linkedin.com/in/marcfbe) or LinkedIn
Follow [@marcf.be](https://bsky.app/profile/marcf.be) on Bluesky and [@marcfbe](https://linkedin.com/in/marcfbe) or LinkedIn
11 changes: 6 additions & 5 deletions abaplint.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"CLAS",
"DEVC",
"INTF",
"NSPC",
"PROG"
]
},
Expand Down Expand Up @@ -148,7 +149,7 @@
"message_exists": true,
"method_implemented_twice": true,
"method_length": {
"exclude": ["zcl_convert.local_imp"]
"exclude": ["#apmg#cl_convert.local_imp.clas.abap"]
},
"method_overwrites_builtin": true,
"method_parameter_names": false,
Expand Down Expand Up @@ -182,7 +183,7 @@
"aqqu": "^Z",
"aqsg": "^Z",
"auth": "^Z",
"clas": "^ZC(L|X)\\_",
"clas": "^/APMG/C(L|X)_CONVERT",
"cmod": "^Z",
"doma": "^Z",
"dtel": "^Z",
Expand All @@ -194,7 +195,7 @@
"idoc": "^Z",
"ignoreNames": [],
"ignorePatterns": [],
"intf": "^ZIF\\_",
"intf": "^/APMG/IF_CONVERT",
"msag": "^Z",
"patternKind": "required",
"pinf": "^Z",
Expand Down Expand Up @@ -226,7 +227,7 @@
"prefer_inline": true,
"prefer_is_not": true,
"prefer_pragmas": true,
"prefer_raise_exception_new": true,
"prefer_raise_exception_new": false,
"prefer_returning_to_exporting": true,
"prefer_xsdbool": true,
"preferred_compare_operator": true,
Expand Down Expand Up @@ -281,7 +282,7 @@
"xml_consistency": true
},
"syntax": {
"errorNamespace": "^(Z|Y|LCL_|TY_|LIF_)",
"errorNamespace": "^(/APMG/|LCL_|TY_|LIF_)",
"globalConstants": [],
"globalMacros": [],
"version": "v754"
Expand Down
12 changes: 7 additions & 5 deletions package.abap.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
{
"name": "xxx",
"name": "convert",
"version": "1.0.0",
"description": "XXX",
"description": "Convert any data type",
"type": "module",
"keywords": [
"abap",
"apm",
"module"
"module",
"conversion",
"data types"
],
"homepage": "https://abappm.com",
"bugs": {
"url": "https://github.com/abapPM/ABAP-XXX"
"url": "https://github.com/abapPM/ABAP-Convert"
},
"license": "MIT",
"author": {
Expand All @@ -26,7 +28,7 @@
}
],
"repository": {
"url": "https://github.com/abapPM/ABAP-XXX"
"url": "https://github.com/abapPM/ABAP-Convert"
},
"funding": {
"type": "github",
Expand Down
16 changes: 16 additions & 0 deletions src/#apmg#.nspc.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<abapGit version="v1.0.0" serializer="LCL_OBJECT_NSPC" serializer_version="v1.0.0">
<asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
<asx:values>
<NSPC>
<NAMESPACE>/APMG/</NAMESPACE>
<REPLICENSE>41813564412598342476</REPLICENSE>
</NSPC>
<NSPC_TEXT>
<SPRAS>E</SPRAS>
<DESCRIPTN>apm</DESCRIPTN>
<OWNER>apm.to Inc.</OWNER>
</NSPC_TEXT>
</asx:values>
</asx:abap>
</abapGit>
Loading