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: 

Specify lenght of a char in exporting addition.

FabioPagoti
Active Contributor
0 Kudos
92

Hello guys. I have a very simple question.

I am defining a class and i'm having some troubles to specify the formal parameter of one of its methods.



CLASS c_information DEFINITION.
  PUBLIC SECTION.
    METHODS:
          get_year 
            IMPORTING l_erdat TYPE vbak-erdat 
            EXPORTING l_year type c . " >>> i'd like to export a c of lenght = 4
  PRIVATE SECTION.
    DATA: 
          erdat TYPE vbak-erdat,
          total_netwr TYPE vbak-netwr.
  
ENDCLASS.                    "c_information DEFINITION

as you can see commented, i'd like to export a c type of lenght equal 4, but i got error if i do:


" ...
 EXPORTING l_year(4) type c .
" or
 EXPORTING l_year type c lenght 4.
" ...

Could you please help me with that?

1 ACCEPTED SOLUTION

MarcinPciak
Active Contributor
0 Kudos
62

In parameters you don't need to specify length of the field. It is enought to specify generic type ( i.e c ). You can pass any char variable then. You can also use clike instead of c but it is even more generic as embraces c,n,d,t,string

If you need parameter of exact type and length use data element for typing as suggested by Suhas.

Regards

Marcin

2 REPLIES 2

SuhaSaha
Advisor
Advisor
0 Kudos
62

How about using

EXPORTING l_year type CHAR04

BR,

Suhas

MarcinPciak
Active Contributor
0 Kudos
63

In parameters you don't need to specify length of the field. It is enought to specify generic type ( i.e c ). You can pass any char variable then. You can also use clike instead of c but it is even more generic as embraces c,n,d,t,string

If you need parameter of exact type and length use data element for typing as suggested by Suhas.

Regards

Marcin