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

Error .

Former Member
0 Likes
962

Hi all.

Please look at this code am getting error .

REPORT zrepp LINE-SIZE 800 MESSAGE-ID aod.

----


  • CLASS employee DEFINITION

----


*

----


CLASS employee DEFINITION.

PUBLIC SECTION.

TYPES : BEGIN OF emp,

name TYPE string,

age(2) TYPE n,

city TYPE string,

END OF emp.

METHODS:

getdata

IMPORTING : em_age(2) type n

em_name TYPE string

em_city TYPE string,

display.

PRIVATE SECTION.

DATA : g_emp TYPE emp.

ENDCLASS. "employee DEFINITION

----


  • CLASS employee IMPLEMENATION

----


*

----


CLASS employee implemenation.

METHOD getdata.

g_emp = emp-name.

g_emp = emp-age.

g_emp = emp-city.

ENDMETHOD. "getdata

METHOD display.

WRITE 😕 g_emp-name,/g_emp-age,/g_emp-city.

ENDMETHOD. "display

ENDCLASS. "employee IMPLEMENATION

DATA : g_emp1 TYPE REF TO employee.

START-OF-SELECTION.

CREATE OBJECT g_emp1

EXPORTING em_name = 'prajwal'

em_age = '24'

em_city = 'Bangalore'.

CALL METHOD g_emp1->display.

am getting error message like this.

<b>The format of field specification "EM_AGE(2)" is not expected. </b>

what may be wrong in this program & how to overcome this.

Regards

Prajwal.k

1 ACCEPTED SOLUTION
Read only

Pawan_Kesari
Active Contributor
0 Likes
932

Copy paste following code..


REPORT zrepp LINE-SIZE 800 MESSAGE-ID aod..

*---------------------------------------------------------------------*
* CLASS employee DEFINITION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS employee DEFINITION.
  PUBLIC SECTION.
    TYPES : BEGIN OF emp,
              name TYPE string,
              age(2) TYPE n,
              city TYPE string,
            END OF emp.

    METHODS: getdata IMPORTING em_age  TYPE n
                               em_name TYPE string
                               em_city TYPE string,
             display.

  PRIVATE SECTION.
    DATA : g_emp TYPE emp.
ENDCLASS. "employee DEFINITION

*---------------------------------------------------------------------*
* CLASS employee IMPLEMENATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS employee IMPLEMENTATION.

  METHOD getdata.
    g_emp-name = em_name.
    g_emp-age = em_age.
    g_emp-city = em_city.
  ENDMETHOD. "getdata

  METHOD display.
    WRITE :/ g_emp-name,
           / g_emp-age ,
           / g_emp-city.
  ENDMETHOD. "display
ENDCLASS. "employee IMPLEMENATION

DATA : g_emp1 TYPE REF TO employee.

START-OF-SELECTION.

  CREATE OBJECT g_emp1 .

  CALL METHOD g_emp1->getdata EXPORTING em_name = 'prajwal'
  em_age = '24'
  em_city = 'Bangalore'.

  CALL METHOD g_emp1->display.

8 REPLIES 8
Read only

Former Member
0 Likes
932

----


  • CLASS employee DEFINITION

----


*

----


CLASS employee DEFINITION.

PUBLIC SECTION.

TYPES : BEGIN OF emp,

name TYPE string,

<b>age TYPE n,</b>

city TYPE string,

END OF emp.

remove 2 from age.

Read only

varma_narayana
Active Contributor
0 Likes
932

Hi Prajwal..

In the Method definitions we should not specify the Length for formal parameters :

So change like this..

METHODS:

getdata

<b>IMPORTING : em_age type n "instead of em_age(2)</b>

em_name TYPE string

em_city TYPE string,

display.

reward if Helpful.

Read only

Former Member
0 Likes
932

Hi

for type N you don't need to put size

reomove that and declare likethis

EM_AGE type n.

reward if usefull

Read only

Former Member
0 Likes
932

hi,

i think u cant give length of type n variable.

Read only

Former Member
0 Likes
932

DO <b>em_age = 24</b> INSTED OF em_age = '24'

REWARD IF USEFUL

AMIT SINGLA

Read only

hymavathi_oruganti
Active Contributor
0 Likes
932

there is no <b>, (comma) </b> after EM_AGE(2) declaration in the method.

Message was edited by:

Hymavathi Oruganti

Read only

Pawan_Kesari
Active Contributor
0 Likes
933

Copy paste following code..


REPORT zrepp LINE-SIZE 800 MESSAGE-ID aod..

*---------------------------------------------------------------------*
* CLASS employee DEFINITION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS employee DEFINITION.
  PUBLIC SECTION.
    TYPES : BEGIN OF emp,
              name TYPE string,
              age(2) TYPE n,
              city TYPE string,
            END OF emp.

    METHODS: getdata IMPORTING em_age  TYPE n
                               em_name TYPE string
                               em_city TYPE string,
             display.

  PRIVATE SECTION.
    DATA : g_emp TYPE emp.
ENDCLASS. "employee DEFINITION

*---------------------------------------------------------------------*
* CLASS employee IMPLEMENATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS employee IMPLEMENTATION.

  METHOD getdata.
    g_emp-name = em_name.
    g_emp-age = em_age.
    g_emp-city = em_city.
  ENDMETHOD. "getdata

  METHOD display.
    WRITE :/ g_emp-name,
           / g_emp-age ,
           / g_emp-city.
  ENDMETHOD. "display
ENDCLASS. "employee IMPLEMENATION

DATA : g_emp1 TYPE REF TO employee.

START-OF-SELECTION.

  CREATE OBJECT g_emp1 .

  CALL METHOD g_emp1->getdata EXPORTING em_name = 'prajwal'
  em_age = '24'
  em_city = 'Bangalore'.

  CALL METHOD g_emp1->display.

Read only

0 Likes
932

thanks to all