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

Using function parameters in subroutines

Former Member
0 Likes
766

Hello,

how can I use parameters of a function in subroutines?

I keep getting error saying the fields are 'unknown'.

Thank you.

8 REPLIES 8
Read only

Former Member
0 Likes
731

paste ur code.

Regards

Read only

andreas_mann3
Active Contributor
0 Likes
731

hi,

you must use them as using / tables - parameters

A.

Read only

0 Likes
731

you must use them as using / tables - parameters

hello,

yes I am doing that. I have different table parameters (P0000, P0001, P0002).

I have a subroutine where I use these tables, but then I get the error that the fields are unknown.

This subroutine is in an include in the same function group

Read only

0 Likes
731

this is the code:


FUNCTION Z_TEST. 
*"---------------------------------------------------------------------- 
*"*"Local interface: 
*"  IMPORTING 
*"     VALUE(DRUN) TYPE  DATS 
*"  TABLES 
*"      P0000 STRUCTURE  P0000 
*"      P0001 STRUCTURE  P0001 
*"      P0002 STRUCTURE  P0002 
*"      P0006 STRUCTURE  P0006 
*"      P0016 STRUCTURE  P0016 
*"      P0021 STRUCTURE  P0021 
*"      P0100 STRUCTURE  P0100 
*"      P0108 STRUCTURE  P0108 
*"      P0109 STRUCTURE  P0109 
*"      P0138 STRUCTURE  P0138 
*"---------------------------------------------------------------------- 

  PERFORM delete_future_and_sort_desc. 

ENDFUNCTION.


FORM delete_future_and_sort_desc. 
  DELETE: p0000 WHERE begda GT drun, 
          p0001 WHERE begda GT drun, 
          p0002 WHERE begda GT drun, 
          p0006 WHERE begda GT drun, 
          p0016 WHERE begda GT drun, 
          p0021 WHERE begda GT drun, 
          p0100 WHERE begda GT drun, 
          p0108 WHERE begda GT drun, 
          p0109 WHERE begda GT drun, 
          p0138 WHERE begda GT drun. 

  SORT: p0000 BY endda DESCENDING, 
        p0001 BY endda DESCENDING, 
        p0002 BY endda DESCENDING, 
        p0006 BY endda DESCENDING, 
        p0016 BY endda DESCENDING, 
        p0021 BY endda DESCENDING, 
        p0100 BY endda DESCENDING, 
        p0138 BY endda DESCENDING. 
ENDFORM.   

Read only

0 Likes
731

Dear Dave

Please make the highlighted changes.

> this is the code:

>


> FUNCTION Z_TEST. 
> *"----------------------------------------------------
> ------------------ 
> *"*"Local interface: 
> *"  IMPORTING 
> *"     VALUE(DRUN) TYPE  DATS 
> *"  TABLES 
> *"      P0000 STRUCTURE  P0000 
> *"      P0001 STRUCTURE  P0001 
> *"      P0002 STRUCTURE  P0002 
> *"      P0006 STRUCTURE  P0006 
> *"      P0016 STRUCTURE  P0016 
> *"      P0021 STRUCTURE  P0021 
> *"      P0100 STRUCTURE  P0100 
> *"      P0108 STRUCTURE  P0108 
> *"      P0109 STRUCTURE  P0109 
> *"      P0138 STRUCTURE  P0138 
> *"----------------------------------------------------
> ------------------ 
> 
>   PERFORM delete_future_and_sort_desc
            <b>using drun
            tables p0000 .... to p0138.</b> 
> 
> ENDFUNCTION.
> 
> 
> FORM delete_future_and_sort_desc
       <b>using drun
       tables p0000 ... p0138.</b> 
>   DELETE: p0000 WHERE begda GT drun, 
>           p0001 WHERE begda GT drun, 
>           p0002 WHERE begda GT drun, 
>           p0006 WHERE begda GT drun, 
>           p0016 WHERE begda GT drun, 
>           p0021 WHERE begda GT drun, 
>           p0100 WHERE begda GT drun, 
>           p0108 WHERE begda GT drun, 
>           p0109 WHERE begda GT drun, 
>           p0138 WHERE begda GT drun. 
> 
>   SORT: p0000 BY endda DESCENDING, 
>         p0001 BY endda DESCENDING, 
>         p0002 BY endda DESCENDING, 
>         p0006 BY endda DESCENDING, 
>         p0016 BY endda DESCENDING, 
>         p0021 BY endda DESCENDING, 
>         p0100 BY endda DESCENDING, 
>         p0138 BY endda DESCENDING. 
> ENDFORM.   
> 
> 

Hope that resolves your error.

Kind Regards

Eswar

Read only

0 Likes
731

hello,

now i'm getting an error saying 'In LOOP..WHERE.. the line of the table must be statically defined'.

Read only

0 Likes
731

Hi dave,

1. If we want to use the parameters

in some FORM routine, insdie the FM,

2. Then we need to GLOBALIZE like this

3. In se37

4. EDIT->INTERFACE-->GLOBALIZE PARAMETERS

5. After this, u will be able to use in subroutine.

regards,

amit m.

Read only

venkata_ramisetti
Active Contributor
0 Likes
731

Hi Dave,

Looks like the problem with the data that is passed to the function module, but not with the parameters of the function module. The subroutine is not able to recognize the data that is passed to the FM.

1.Pass data to subroutine using syntax

perform subroutine using <field1> <field2>....

(OR)2. Try to define the data globally that you want to pass to the function module.

Thanks,

Ramakrishna