Application Development 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: 

Predefined ABAP TYPES

Brice1
Explorer
0 Kudos

 Hi team. I have the following task to complete:

  1. Like in the first exercise of this course, create a new global class that implements interface IF_OO_ADT_CLASSRUN.
  2. Copy the following code snippet to the implementation part of method if_oo_adt_classrun~main( 😞
    Code snippet

    * Data Objects with Built-in Types ********************************************************************** " comment/uncomment the following declarations and check the output DATA variable TYPE string. * DATA variable TYPE i. * DATA variable TYPE d. * DATA variable TYPE c LENGTH 10. * DATA variable TYPE n LENGTH 10. * DATA variable TYPE p LENGTH 8 DECIMALS 2. * Output ********************************************************************** out->write( 'Result with Initial Value)' ). out->write( variable ). out->write( '---------' ). variable = '19891109'. out->write( 'Result with Value 19891109' ). out->write( variable ). out->write( '---------' ).

     

    I have the following error:

    Field "VARIABLE" is unknown. 

     

    Please assist. I am a beginner.

    Brice.

     

    Brice1_0-1707603627548.png

2 REPLIES 2

HunorCzaka
Explorer

You have to declare the variable first. I assume the exercise was to figure out which data declaration is the correct one.

Since the variable gets its value later on, variable = '19891109'.

You have to see which one from the following can be

DATA variable TYPE string.

DATA variable TYPE i.

DATA variable TYPE d.

DATA variable TYPE c LENGTH 10.

DATA variable TYPE n LENGTH 10.

DATA variable TYPE p LENGTH 8 DECIMALS 2.

You need only one of the declarations, i wont tell which one. Try it out and see which one works.

 

matt
Active Contributor
0 Kudos

Click on the three dots in the editor. 

Then click on the </> button.

Then post your code.

 

* Data Objects with Built-in Types ********************************************************************** " comment/uncomment the following declarations and check the output DATA variable TYPE string. * DATA variable TYPE i. * DATA variable TYPE d. * DATA variable TYPE c LENGTH 10. * DATA variable TYPE n LENGTH 10. * DATA variable TYPE p LENGTH 8 DECIMALS 2. * Output ********************************************************************** 
out->write( 'Result with Initial Value)' ). 
out->write( variable ). 
out->write( '---------' ). 
variable = '19891109'. 
out->write( 'Result with Value 19891109' ). 
out->write( variable ). 
out->write( '---------' )

 

so much nicer, don't you think?

In answer to your original question it would really help if you would follow the instructions:

 comment/uncomment the following declarations and check the output