Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Dump in Program

d4xtian
Participant
0 Likes
2,962

Hi i create a program that count the number of vowels in a input of a user...

When i run it dump when i put a word that has a lenght more than 6 characters.

My Parameterv"p_char" as a lenght of 20 and it is the max of the length...

Here is the code...

Thanks in advance..

**** Déclaration des variables ****

DATA: vlength_p   TYPE i, " Variable pour stocker la longueur d'input
      v_vowels(6) TYPE c, " Liste des voyelles
      index       TYPE i,
      occurences  TYPE i, " Variable de décompte
      v_vbyv      TYPE c. " Variable de chaque voyelle


**** Création Paramètres pour input User ****

PARAMETERS : p_char(20) TYPE c.


vlength_p = strlen( p_char ). " On obtien la longueur de l'input user
v_vowels = 'AEIOUY'. " Assignation des voyelles dans la variable

index = sy-index.  " Variable système utilisée pour la boucle

WHILE index < vlength_p. " Effectue bloucle tant que cette condition est vraie

  v_vbyv = v_vowels+index. " On change

*** On compte les occurences en fonction de la voyelle sur laquelle on est
  FIND ALL OCCURRENCES OF v_vbyv IN p_char MATCH COUNT occurences.
  ADD 1 TO index.

  IF occurences = 0.

  ELSE. " Ce qu'on fait si on trouve des occurences
    WRITE : / v_vbyv, TEXT-000, occurences, TEXT-001. " On affiche le resultat si occurences

  ENDIF.

ENDWHILE.
16 REPLIES 16
Read only

Jeansy
Active Contributor
0 Likes
2,825

Hi,

I checked your coding.

The reason why a dumps comes up when the length of your variable is longer that 6 characters is because you set the variable V_VOWELS to 'AEIOUY' (length of 6 characters).

In the while-loop you iterate based on the length of the char you entered as parameter. If this is longer than 6 chars you get an issue with this command:

v_vbyv = v_vowels+index. " On change

As mentioned, the variable V_VOWELS has a length of 6. So in case index gets the value of 7, it is not possible anymore to access this 7th char in this variable using this offset. That's why it is dumping with DATA_OFFSET_TOO_LARGE.

To be honest, I did not really understand what your are trying to achieve with this coding, that's why I cannot propose another possible solution. But I hope this helps you to understand the reason of the dump.

Kind regards
Jens

Read only

0 Likes
2,825

Thanks you, Yes it help

My program is to count the numbers of vowels of a word enter in a parameter...

I guess this isn't the right code to do...

Hum..

If you have a solution can you just don't give it , just give me Hich to help find the solution by my self.

if i use an internal table to store the vowels instead in a variable, would it be a way ?

Thanks

Read only

Jeansy
Active Contributor
0 Likes
2,825

Okay, now I got your requirement for this coding.

One possible solution could be:

  • Process each letter of the word entered in the parameter using e.g. the WHILE you already implemented
  • Using comparing operators, e.g. CO (contains only) to check if the single letter is part of the vowels-variable
  • If YES: counter+1
  • If NO: next single letter of the word

I hope this helps you to solve the issue by your own 🙂

Kind regards
Jens

Read only

0 Likes
2,825

So i ll processing the check the 6 vowels... with a If statement instead of FIND

Read only

Juwin
Active Contributor
0 Likes
2,825

Hi fotso

Have a look at this Regex and you will be able to achieve your requirement in just one statement. No looping, no counters, no indexing, no internal tables needed.

Thanks

Read only

0 Likes
2,825

I couldn't find the solution, can you help thanks

Read only

Juwin
Active Contributor
2,825

My answer was the same as what Nitish provided later below.

Read only

0 Likes
2,825

i know it was the same, but it fit partial of my solution

Read only

Juwin
Active Contributor
0 Likes
2,825

This worked well for me:

parameters: p_string type text40 obligatory.
find all occurrences of regex '[AEIOU]' in to_upper( p_string ) match count data(occur).
message |Number of vowels:{ occur }| type 'S'.
Read only

Sandra_Rossi
Active Contributor
2,825

Please attach the text file of the short dump when you have a question about a short dump, and indicate an example of "a word that has a lenght more than 6 characters", because maybe people will try other words which won't fail.

Read only

Nitish2027
Participant
0 Likes
2,825

Hi fotso,

I think this is what you need.

    DATA: p_char TYPE string VALUE 'Hello Christian Fotso, nice to meet you!'.

    FIND ALL OCCURRENCES OF PCRE '[AEIOUY]' IN p_char IGNORING CASE MATCH COUNT DATA(lv_vowels_count).
    WRITE:/ lv_vowels_count.

I'd recommend you to check out this blog: Regular Expressions (RegEx) in Modern ABAP. Also read about the PCRE library which I have used here, you will find details about it the mentioned blog.

RegEx is very powerful and can be very helpful scenarios such as your requirement.

Thanks.

Read only

0 Likes
2,825

As explained by jzaehringer, I hope you are clear with why you are getting the dump. I wanted to provide you with alternative solution and more importantly let you know about RegEx, which you can use in such scenarios.

Read only

0 Likes
2,825

Thanks you, but here you count in your variable lv_vowels_counts all the vowels in the p_char,

I want to make a count by vowels in p_char,

Read only

0 Likes
2,825

Sorry, I don't understand what you are looking for, can you please try and explain again?

What I understand is, you are trying to count the number of vowels present in your input parameter p_char, and then store that result in a variable right? The vowels in your case [AEIOUY] are going to be fixed right?

Please try to explain your requirement if its not what I have mentioned.

Read only

RaymondGiuseppi
Active Contributor
0 Likes
2,825

Your WHILE loop must be executed once per vowel, not once per character of the string.

(Also insure you check for uppercase/lowercase characters,)

Read only

d4xtian
Participant
0 Likes
2,825

For the Loop that what jeansy told me to do.

For the Uppercas/Lowercase i use 'Ignoring Case'

Thanks