WhatsApp Button




top of page

Take 10 Minutes to Get Started With STRINGS IN ABAP

Aug 14, 2021
2 min read

Updated: May 31, 2022



Strings are set of characters arranged in sequence. Strings also called as character strings. Character or string data type is used to declare the character strings in ABAP.

Character data type holds alphanumeric characters with minimum length of 1 character and maximum of 65535 characters. Character data type is left justified and spaces padded to right.

Character data type considered as default data type when no data type specified during the declaration. If character data type used in declaration, length of the string should be specified in the declaration itself.

CREATING STRINGS

In ABAP programming, string variables defined by declaring the data type as Character. The string variables can get initialized in the same declaration or the string can get passed to the variable anywhere in the program execution.

SYNTAX——>

DATA STRING_NAME(SIZE_OF_STRING) TYPE C VALUE ‘STRING_VALUE’ .






NOTE—> In almost every ABAP program the system field SUBRC is used, because it’s meaning is connected with the successful execution of a statement. It contains return value, set by ABAP statements. It is an integer value like 0, 4, 8 or other. This value is used to determine the status of the execution of an ABAP statement. If SY-SUBRC is 0, the ABAP statement has been executed successfully. If the value is different from 0, than the statement has raised an error or warning. Usually 4 means error and 8 means warning, but this is not obligatory. It depends on the statement.




STRING OPERATIONS

  1. CONCATENATE——> Used to join two or more strings to form a third string. Separated by Clause used to separate the strings by a specified delimiter. "sy-subrc" identifies whether the concatenate was successful or not. If "sy-subrc" is zero, then concatenate successful. Otherwise, concatenate not successful.


SYNTAX—>

CONCATENATE STR1 STR2 STR3 INTO FINAL_STRING_NAME.


CODING SCREEN—>



INPUT—>


OUTPUT—>




2. SPLIT——> Used to split the string content into two or more fields.

"sy-subrc" identifies whether the split was successful or not. If "sy-subrc" is zero, then split successful. Otherwise, split not successful.


SYNTAX—>

SPLIT MAIN_STRING AT POS INTO STR1 STR2 STR3… .


CODING SCREEN—>



OUTPUT—>




3. CONDENSE——> Used to delete the space characters. Leave only one-character space in between the characters. NO-GAPS is optional and used to remove all spaces in between the characters. "sy-subrc" identifies whether the condense was successful or not. If "sy-subrc" is zero, then condense successful. Otherwise, condense not successful.


SYNTAX—->

CONDENSE STR_NAME.


CODING SCREEN—>


OUTPUT—>



If you want to delete all spaces between characters the use NO-GAPS.


SYNTAX—>

CONDENSE STR_NAME NO-GAPS.


CODING SCREEN—>



OUTPUT—>



4. REPLACE——> Used to replace the characters. REPLACE replaces the matching first instances of string. "sy-subrc" identifies whether the replace was successful or not. If "sy-subrc" is zero, then replace successful. Otherwise, replace not successful.


SYNTAX—->

REPLACE FIRST OCCURRENCE OF ‘OLD_CHAR’ IN STRING_NAME WITH ‘NEW_CHAR’ .

REPLACE ALL OCCURRENCE OF ‘OLD_CHAR’ IN STRING_NAME WITH ‘NEW_CHAR’ .


CODING SCREEN—>



OUTPUT—>



5. LENGTH——-> Holds the length of the string returned by STRLEN.


SYNTAX —>

INTEGER_VALUE = STRLEN(STR_NAME) .


6. TRANSLATE—-> Used to convert uppercase to lowercase or vice versa.


SYNTAX——>

TRANSLATE STR_NAME TO UPPER CASE.

TRANSLATE STR_NAME TO LOWER CASE.


CODING SCREEN—>



OUTPUT—>






ISHNOOR SINGH SETHI

10 Comments


dwainnervi55
6 days ago

TN88 giúp tôi đánh giá sự nhất quán của bố cục khi chuyển qua nhiều chuyên mục. Tôi bắt đầu bằng việc quan sát trang chính rồi mở từng khu vực theo thứ tự khác nhau. Tôi chú ý cách tiêu đề và các nút điều hướng được sắp xếp để xem chúng có thay đổi quá nhiều hay không. Đến giữa quá trình, tôi kiểm tra casino, bắn cá, xổ số và slot game nhằm quan sát cách từng nhóm được trình bày. Sau đó, tôi quay lại những khu vực đã truy cập để kiểm tra khả năng ghi nhớ. Khi các thành phần chính vẫn giữ logic quen thuộc, tôi dễ dự đoán bước tiếp theo và không phải…

Like

FLY88 được tôi tiếp cận như một người mới chưa có thói quen sử dụng nền tảng. Tôi bắt đầu bằng việc xác định những chức năng cơ bản như đăng ký, đăng nhập, hỗ trợ và giao dịch trước khi khám phá các sảnh giải trí. Sau đó, tôi thử đi qua thể thao, casino, bắn cá và nổ hũ để xem những quy luật giao diện có dễ ghi nhớ không. Tôi cũng quan sát cách thông tin khuyến mãi và hỗ trợ 24/7 được đặt trong hành trình. Điều tôi đánh giá là khả năng giúp người mới hình thành cách sử dụng mà không cần ghi nhớ quá nhiều bước. Khi bố cục có quy luật, người…

Like

tài xỉu md5 cho tôi cơ hội quan sát cách thông tin kỹ thuật được chuyển thành trải nghiệm dễ hiểu. MD5 vốn là thuật ngữ quen thuộc trong lĩnh vực công nghệ nhưng không phải người dùng nào cũng biết cách đọc chuỗi mã hoặc hiểu ý nghĩa của việc đối chiếu. Tôi vì vậy chú ý nhiều đến phần giải thích hơn là chỉ nhìn thấy mã xuất hiện trên màn hình. Nếu hướng dẫn đưa ra đúng thời điểm và sử dụng cách diễn đạt đơn giản, người dùng sẽ dễ hình dung quy trình hơn. Tôi cũng xem xét khả năng tìm lại thông tin sau khi ván kết thúc để đối chiếu khi cần. Với tôi,…

Like

top88 là nơi tôi xem thể thao từ ngữ cảnh người dùng chỉ quan tâm một môn cụ thể nhưng phải đi qua nhiều nguồn nội dung. Bài gốc nhắc SBOBET, M8Bet và IM Sports với bóng đá, bóng rổ, quần vợt, đua ngựa và esports. Tôi chú ý bảng kèo cập nhật theo thời gian thực rồi mới xác định môn cần xem. Khi Liên Minh Huyền Thoại, CS2 và Dota 2 được đặt trong esports, phạm vi lựa chọn rõ hơn. Với tôi, khu thể thao hợp lý khi người dùng có thể đi từ môn đến sự kiện mà không phải rà lại nhóm không liên quan

Like

mark tan
Aug 02

I never knew the character data type is left justified and pads spaces to the right—that’s really helpful for formatting output. The tip about specifying the length during declaration makes sense too, especially for avoiding surprises. By the way, I keep a free transmission fluid reference guide I like to share: https://transmissionfluid.net/

Like
bottom of page