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

Do I need to declare parameters before using them?

Former Member
0 Likes
1,046

Hello,

Say I have a piece of code like below:


FORM UPLOAD_PC_FILE USING P_PATH
                           P_INTERNAL_TABLE.
   P_PCPATH_TOSTRING = P_PATH.
   CALL FUNCTION 'GUI_UPLOAD'
     EXPORTING
       FILENAME                      = P_PCPATH_TOSTRING
*   FILETYPE                      = 'ASC'
*   HAS_FIELD_SEPARATOR           = ' '
*   HEADER_LENGTH                 = 0
*   READ_BY_LINE                  = 'X'
*   DAT_MODE                      = ' '
*   CODEPAGE                      = ' '
*   IGNORE_CERR                   = ABAP_TRUE
*   REPLACEMENT                   = '#'
*   CHECK_BOM                     = ' '
*   VIRUS_SCAN_PROFILE            =
*   NO_AUTH_CHECK                 = ' '
 IMPORTING
*   FILELENGTH                    =
  HEADER                        =  WA_INBOUND
     TABLES
       DATA_TAB                      = P_INTERNAL_TABLE
EXCEPTIONS
FILE_OPEN_ERROR               = 1
FILE_READ_ERROR               = 2
NO_BATCH                      = 3
GUI_REFUSE_FILETRANSFER       = 4
INVALID_TYPE                  = 5
NO_AUTHORITY                  = 6
UNKNOWN_ERROR                 = 7
BAD_DATA_FORMAT               = 8
HEADER_NOT_ALLOWED            = 9
SEPARATOR_NOT_ALLOWED         = 10
HEADER_TOO_LONG               = 11
UNKNOWN_DP_ERROR              = 12
ACCESS_DENIED                 = 13
DP_OUT_OF_MEMORY              = 14
DISK_FULL                     = 15
DP_TIMEOUT                    = 16
OTHERS                        = 17

Do I have to declare the P_INTERNAL_TABLE as an internal table or ABAP will automatically know that this is an internal table (I will always pass in internal tables when I call this form in the main program)?

Thanks a lot!

Regards,

Anyi

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,007

Hi,

Data_itab --> takes any internal table which u pass.

since Data_itab is not a type specific

u declare P_INTERNAL_TABLE as internal table of any type; as per ur requirement it will except.

exam.

data :P_INTERNAL_TABLE type table of z_struc

or

data :P_INTERNAL_TABLE type table of standard_structure

it will except any table; but u have to declare internal table of particular type

Message was edited by: Manoj Gupta

Hi,

Data_itab --> takes any internal table which u pass.

since Data_itab is not a type specific

u declare P_INTERNAL_TABLE as internal table of any type; as per ur requirement it will except.

exam.

data :P_INTERNAL_TABLE type table of z_struc

or

data :P_INTERNAL_TABLE type table of standard_structure

it will except any table; but u have to declare internal table of particular type

Message was edited by: Manoj Gupta

8 REPLIES 8
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,007

You must declare it before you use it. In this case, you are declaring it in the signature of the FORM. So here it is declared. But when calling the form you must pass a valid internal table name that has been declared before hand.

For example.

report zrich_0001.

data: <b>itab</b> type table of string.



perform upload tables <b>itab</b>.


*---------------------------------------------------------------------*
*       FORM upload                                                   *
*---------------------------------------------------------------------*
*       ........                                                      *
*---------------------------------------------------------------------*
*  -->  L_ITAB                                                        *
*---------------------------------------------------------------------*
form upload tables <b>l_itab</b>.


  call function 'GUI_UPLOAD'
       exporting
            filename = 'C:test.txt'
       tables
            data_tab = <b>l_itab</b>.


endform.

Regards,

Rich Heilman

Read only

Former Member
0 Likes
1,008

Hi,

Data_itab --> takes any internal table which u pass.

since Data_itab is not a type specific

u declare P_INTERNAL_TABLE as internal table of any type; as per ur requirement it will except.

exam.

data :P_INTERNAL_TABLE type table of z_struc

or

data :P_INTERNAL_TABLE type table of standard_structure

it will except any table; but u have to declare internal table of particular type

Message was edited by: Manoj Gupta

Read only

Former Member
0 Likes
1,007

Of course yes.

They must be declared as the same type as in the function module.

Regards,

Ravi

Read only

Former Member
0 Likes
1,007

Hi you need to declare the p_path as the type of the variable that you are passing in the Perform of the FORM UPLOAD_PC

Similarily you also need to define the p_internal_table as the type of table that you are passing to the Perform.

Read only

Former Member
0 Likes
1,007
data: path type string.
data itab like mara occurs 0 with header line.
perform upload_pc_file using path tables itab.

FORM upload_pc_file  USING    P_PATH type string
                     TABLES   P_ITAB STRUCTURE ITAB .
"now use gui_upload here...                                
ENDFORM.                    " upload_pc_file

Regards

vijay

Read only

Former Member
0 Likes
1,007

Hi,

U jus have to declare it once before u pass them in ur perform...

The formal parameters need not to be declared again and it can have any name.

Hope this helps u.

Seema.

Read only

Former Member
0 Likes
1,007

hi

good

I DONT THINK YOU HAVE TO DECLARE THE SEPARATE INTERALABLE FOR THIS.

THANKS

MRUTYUN

Read only

Former Member
0 Likes
1,007

hi

good

I DONT THINK YOU HAVE TO DECLARE THE SEPARATE INTERALABLE FOR THIS.

THANKS

MRUTYUN