Some common functions of ABAP

Source: Internet
Author: User

1. ABS absolute value

2. ROUD:

In addition to calling functions, there is another usage:

Round (val = arg {dec = n} | {prec = n} [mode = m])

3. SUBSTRING:

SUBSTRING (VAL = GS_STRING OFF = GI_FLAG-1 LEN = 1)

1. substring (val = text [off = off] [len = len])...

 

2. substring_from (val = text {sub = substring} | {regex = regex}
[Case = case] [occ = occ] [len = len])...

 

3. substring_after (val = text {sub = substring} | {regex = regex}
[Case = case] [occ = occ] [len = len])...

 

4. substring_before (val = text {sub = substring} | {regex = regex}
[Case = case] [occ = occ] [len = len])...

 

5. substring_to (val = text {sub = substring} | {regex = regex}
[Case = case] [occ = occ] [len = len])...

Example

 

The return codes of the following function cballs are: "CD", "CDEFGH" .., "EFGH" .., "AB" .., and "ABCD ".

 

DATA result TYPE string.

Result = substring (val = 'abcdefgh' off = 2 len = 2 ).

Result = substring_from (val = 'abcdefgh' sub = 'CD ').

Result = substring_after (val = 'abcdefgh' sub = 'CD ').

Result = substring_before (val = 'abcdefgh' sub = 'CD ').

Result = substring_to (val = 'abcdefgh' sub = 'CD ').

 

 

 

ROUND details:

Effect

This function rounds a decimal floating point number declared as an argument for the parameter val. A data object specified for arg is converted to the data type decfloat34 before the function is executed, if necessary.

 

  •  

  • If the parameter dec is given a value, the value entered is rounded to the number of decimal places specified in n and returned. data objects of type I is expected for n. the value of these data objects cannot be less than-6144. if a negative value is given, the relevant whole number place is rounded.

 

  •  

  • If the parameter prec is given a value, the value entered is rounded to the specified in n and returned. data objects of type I are expected for n. the value of these data objects must be greater than 0.

 

A rounding can reduce and but cannot increase them. if dec is specified, the mantissa of the return code does not contain any zeros after the position where the rounding applies. if prec is specified, the input value is returned without being changed, if the specified precision is greater than or equal to the input value.

 

You can use the mode parameter (optional) to set the rounding type. for m it is only possible to specify values that exist as ROUND _... constants in class. the following table shows the possible rounding rules. if mode is not given a value, specified cial rounding is used.

 

SUBSTRING usage instructions:

 

In the argument, the substring functions determine a substring and return it.

 

The substring is determined as follows:

 

  •  

  • The function substring uses the offset and the length to return a certain subrange. At least one of the two arguments off or len must be specified.

 

  •  

  • The function substring_from scans text for the match (specified in) with the character string specified in or with the specified in and returns the subrange of the length from the offset of the found location. if len is not specified, the substring is returned to the end of the character string. if substring is empty, an exception from the class CX_SY_STRG_PAR_VAL is raised. the search is case-sensitive by default, but you can override this with the parameter case. if no substring is found, the return code is empty.

 

  •  

  • The function substring_after works in the same way as substring_from, but the subrange plus the length of the substring found is returned, from the offset of the found location.

 

  •  

  • The function substring_before works in the same way as substring_from, but the subrange of the length is returned, before the offset of the found location. if len is not specified, the subrange is formed from the start of the character string.

 

  •  

  • The function substring_to works in the same way as substring_before, but the subrange before the offset of the found location plus the length of the substring found is returned.

 

The return code has the type string accordingly.

 

Note

 

The performance of the substring functions is not as good as a direct. They do, however, allow you to use in all operand positions.

Some common functions of ABAP

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.