
Login
ChatGPT ABAP Hello World
ABAP OO Hello World
Hello World with NEW operator
ABAP Challenge
DATA: word_count TYPE i VALUE 0,
letter_count TYPE i VALUE 0.
SPLIT sentence AT ' ' INTO TABLE DATA(words).
word_count = LINES( words ).
LOOP AT words INTO DATA(word).
letter_count = 0.
LOOP AT word INTO DATA(letter) WHERE letter CS 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.
letter_count = letter_count + 1.
ENDLOOP.
WRITE:/ word, ' has ', letter_count, ' unique letters'.
ENDLOOP.
* Unit test
CLASS lcl_test_unique_letters DEFINITION.
PUBLIC SECTION.
CLASS-METHODS test_unique_letters_count.
ENDCLASS.
CLASS lcl_test_unique_letters IMPLEMENTATION.
METHOD test_unique_letters_count.
DATA: sentence TYPE string VALUE `ABАP is excellent `.
DATA: word_count TYPE i VALUE 0,
letter_count TYPE i VALUE 0.
SPLIT sentence AT ' ' INTO TABLE DATA(words).
word_count = LINES( words ).
cl_abap_unit_assert=>assert_equals( act = word_count exp = 3
msg = 'Number of words in sentence should be 3' ).
LOOP AT words INTO DATA(word).
letter_count = 0.
LOOP AT word INTO DATA(letter) WHERE letter CS 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.
letter_count = letter_count + 1.
ENDLOOP.
cl_abap_unit_assert=>assert_equals( act = letter_count exp = strlen( word )
msg = 'Number of unique letters in word should be equal to the number of characters in the word' ).
ENDLOOP.
ENDMETHOD.
ENDCLASS.
cl_abap_unit_test=>run( class_name = 'LCL_TEST_UNIQUE_LETTERS' ).
Write ABAP code that start with this line of code as the first line in your application.
DATA(sentence) = `ABАP is excellent `.
Using the value in the variable sentence, programmatically determine the number of words in this variable and then count the number of UNIQUE letters in each word. The code should run in the ABAP cloud environment. Also write an ABAP unit test for this logic.
*Code:
DATA(words) = SPLIT sentence AT space INTO TABLE DATA(words_tab).
DATA(unique_letters) = 0.
LOOP AT words_tab REFERENCE INTO DATA(word_ref).
DATA(word) = word_ref.
DATA(current_letters) = VALUE #( FOR letter IN word( ) ( INIT letter_count 0 ) ( letter_count = letter_count + 1 ) ( letter_count ) ).
DATA(unique_letter_count) = 0.
LOOP AT current_letters REFERENCE INTO DATA(letter_ref).
IF NOT letter_ref[] CS letter_ref-previous.
unique_letter_count = unique_letter_count + 1.
ENDIF.
ENDLOOP.
unique_letters = unique_letters + unique_letter_count.
ENDLOOP.
*ABAP Unit Test:
CLASS lcl_word_letter_count DEFINITION FOR TESTING
DURATION SHORT
RISK LEVEL HARMLESS.
PRIVATE SECTION.
METHODS get_unique_letters
IMPORTING
sentence TYPE string
RETURNING
VALUE(unique_letters) TYPE i.
ENDCLASS.
CLASS lcl_word_letter_count IMPLEMENTATION.
METHOD get_unique_letters.
DATA(words) = SPLIT sentence AT space INTO TABLE DATA(words_tab).
DATA(unique_letters) = 0.
LOOP AT words_tab REFERENCE INTO DATA(word_ref).
DATA(word) = word_ref.
DATA(current_letters) = VALUE #( FOR letter IN word( ) ( INIT letter_count 0 ) ( letter_count = letter_count + 1 ) ( letter_count ) ).
DATA(unique_letter_count) = 0.
LOOP AT current_letters REFERENCE INTO DATA(letter_ref).
IF NOT letter_ref[] CS letter_ref-previous.
unique_letter_count = unique_letter_count + 1.
ENDIF.
ENDLOOP.
unique_letters = unique_letters + unique_letter_count.
ENDLOOP.
ENDMETHOD.
ENDCLASS.
CLASS lcl_word_letter_count_test DEFINITION FOR TESTING
DURATION SHORT
RISK LEVEL HARMLESS.
PRIVATE SECTION.
DATA sentence TYPE string.
DATA unique_letters TYPE i.
ENDCLASS.
CLASS lcl_word_letter_count_test IMPLEMENTATION.
METHODS setup.
sentence = `ABАP is excellent`.
ENDMETHOD.
METHODS test_get_unique_letters.
unique_letters = cl_word_letter_count=>get_unique_letters( sentence ).
cl_abap_unit_assert=>assert_equals( expected = 11 act = unique_letters ).
ENDMETHOD.
ENDCLASS.
ChatGPT is a revolutionary new chatbot technology that has the potential to revolutionize the way ABAP programmers interact with their existing systems. ChatGPT is an open source, cloud-based chatbot platform that provides an intuitive and user-friendly interface for ABAP developers to manage their applications. With ChatGPT, developers can quickly and easily create interactive conversations with their users, automate tasks, and manage system operations more efficiently. The platform also provides an integrated development environment that allows users to create, deploy, and manage their own custom chatbot applications. This blog will discuss the benefits of using ChatGPT for ABAP developers and how it can help them to streamline their workflows and increase efficiency.
ChatGPT is a revolutionary new tool for ABAP programmers. Built using the latest AI and natural language processing technologies, ChatGPT provides a powerful and intuitive way to write quality pro-code. With ChatGPT, ABAP programmers can easily create and maintain complex pro-code with the help of natural language commands. This makes it easier to write quality code in a fraction of the time. In today's no-code, low-code environment, ChatGPT is a powerful tool for ABAP programmers to quickly develop and maintain their code with minimal effort.
ChatGPT is a revolutionary new technology that promises to automate conversations with unprecedented accuracy. However, it cannot replace an ABAP developer due to the risks associated with it. ChatGPT is still an AI-driven technology, which means it is not infallible and may not be able to make the same decisions that an experienced ABAP developer could. Moreover, ChatGPT is not as adept at debugging and troubleshooting as a human developer, as it can only operate within the parameters of its programming. Additionally, ChatGPT does not possess the same creative problem-solving skills that an ABAP developer does, so it may not be able to come up with novel solutions to complex issues. Finally, ChatGPT is not capable of understanding certain nuances of language, which could lead to confusion or misinterpretations when communicating with end-users. For these reasons, ChatGPT cannot replace an ABAP developer and their expertise should still be valued.
ChatGPT is an AI-powered platform that enables organizations to automate conversations with customers, employees, and partners. It can handle complex conversations, allowing businesses to provide more personalized interactions and better customer service. It can also automate mundane tasks and enable more efficient customer service operations. For an ABAP developer, ChatGPT will enable them to focus more on developing innovative features and solutions that respond to customer needs, thus improving customer experience and satisfaction.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
2 | |
2 | |
2 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 |