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: 

For all entries table handled by Tables parameter of Subroutine!

naveen_inuganti2
Active Contributor
0 Kudos

Hi....

See my code...

Dont leave as it seems very big code... Actually its very small one...

In sourse code of function module...

data:itab1  type standard table of <local structure of top include> with header line,
                 itab2 type standrad table of knvp with header line.

perform routine_data tables  itab1
                      using    p_var

Subroutine code, saved in F include of that function group...

form routine_data  tables itab1 type standard table
                           using    p_var
  
  select * from <db table>
              into corresponding fields of table itab
              where <keyfield> = p_var.

 endform.

Back to source cod eof Function module..

if sy-subrc is = 0.
    select parvw kunn2 kunnr from knvp
                        into corresponding fields of table itab2 for all entries in itab1
                         where kunnr = itab1-kunnr
                         and ( parvw = 'WE' or parvw = 'RE' or parvw = 'RG').
endif.

This code is working fine......

==================Now coming to my problem==========================

In source code of function module...

data:itab1  type standard table of <local structure of top include> with header line,
                 itab2 type standrad table of knvp with header line.

perform routine_data tables  itab1
                               using    p_var

Subroutine code, saved in F include of that function group...

form routine_data  tables itab1 type standard table
                           using    p_var
  
  select * from <db table>
              into corresponding fields of table itab
              where <keyfield> = p_var.

 endform.

Function module source code...

perform routine2_data tables itab1
                                 itab2.

F include coding part for above subroutine....

form routine2_data  tables itab1 type standard table
                                      itab2 type standard table

    select parvw kunn2 kunnr from knvp
                        into corresponding fields of table itab2 for all entries in itab1
                         where kunnr = itab1-kunnr                                         <-----causing error
                         and ( parvw = 'WE' or parvw = 'RE' or parvw = 'RG').
                       
endform.

Giving error message....

>>> The specified type has no structure and therefore no component called 'KUNNR".....

So here the problem is there is a incorrect way to declare parameters....

Plz remind that SUBROUTINES OF FUNCTION MODULES SAVING IN INCLUDE PROGRAMS, because they making some deffenrce with normal external subroutines...

also...

Here for all entries is mandatory!

And Two sub routines are mandatory!

Thanks for your attention...

Naveen Inuganti.

1 ACCEPTED SOLUTION

Former Member
0 Kudos

form routine2_data tables itab1 type standard table

itab2 type standard table

select parvw kunn2 kunnr from knvp

into corresponding fields of table itab2 for all entries in itab1

where kunnr = itab1-kunnr <-----causing error

and ( parvw = 'WE' or parvw = 'RE' or parvw = 'RG').

endform.

try specifying the structure of itab in the subroutine....

form routine2_data tables itab1 type standard table structure <name of structure>

itab2 type standard table structure <name of structure>

select parvw kunn2 kunnr from knvp

into corresponding fields of table itab2 for all entries in itab1

where kunnr = itab1-kunnr <-----causing error

and ( parvw = 'WE' or parvw = 'RE' or parvw = 'RG').

endform.

7 REPLIES 7

Former Member
0 Kudos

form routine2_data tables itab1 type standard table

itab2 type standard table

select parvw kunn2 kunnr from knvp

into corresponding fields of table itab2 for all entries in itab1

where kunnr = itab1-kunnr <-----causing error

and ( parvw = 'WE' or parvw = 'RE' or parvw = 'RG').

endform.

try specifying the structure of itab in the subroutine....

form routine2_data tables itab1 type standard table structure <name of structure>

itab2 type standard table structure <name of structure>

select parvw kunn2 kunnr from knvp

into corresponding fields of table itab2 for all entries in itab1

where kunnr = itab1-kunnr <-----causing error

and ( parvw = 'WE' or parvw = 'RE' or parvw = 'RG').

endform.

0 Kudos

Hi....Priyank....

I made that... still showing the same error...

Thanks,

Naveen.I

0 Kudos

do it like this...

form routine2_data tables itab1 type standard table structure <name of structure>

itab2 type standard table structure <name of structure>

data itab3 type table of <name of structure>.

itab3 = itab1.

select parvw kunn2 kunnr from knvp

into corresponding fields of table itab2 for all entries in itab3

where kunnr = itab3-kunnr

and ( parvw = 'WE' or parvw = 'RE' or parvw = 'RG').

endform.

There may also not be a need to write "Type standard table" while specifying a table in a subroutine...

just ....form routine2_data tables itab1 structure <name of structure> may be enough

Edited by: Priyank Jain on Aug 21, 2008 7:03 AM

0 Kudos

Hi...Priyank....

form routine2_data  tables itab1 type standard table
                                      itab2 type standard table

data: itab3 type table of <structure name of itab1>  
itab3 = itab1[].
    select parvw kunn2 kunnr from knvp
                        into corresponding fields of table itab2 for all entries in itab3
                         where kunnr = itab3-kunnr                                   
                         and ( parvw = 'WE' or parvw = 'RE' or parvw = 'RG').
                       
endform.

Is giving correct result.Find a small change....

If we declare like...

form routine2_data  tables itab1 type standard table stucture <name of structure>
                                      itab2 type standard table

....giving error i.e. no.of actual parameters and formal parameters are not equal.

My problem solved.

Thanks,

Naveen Inuganti.

Former Member
0 Kudos

hi,

Try this.

Chk whether the table itab1 has the field kunnr.

Also in form routine give it as itab1 type standard table of <type-name>

Sharin.

matt
Active Contributor
0 Kudos

First, don't use header lines. It's BAD programming. You should use either a seperately defined work area, or use ASSIGNING to a field-symbol.

Second, don't use TABLES!

All you need to do is, rather than

data:itab1  type standard table of <local structure of top include> with header line,

Use

TYPES :itab1_ty type standard table of <local structure of top include>.
DATA: itab1 type itab1_ty,
      wa_1 TYPE <local structure of top include>.

perform routine_data using itab1  p_var.
...
form routine_data  using itab1 type itab1_ty
                         p_var.
...

So whenever you pass itab1, pass it USING and make the TYPE itab1_ty.

This uses much stronger typing than generic types like standard table. And so is better programming. The rule is to use as specific a type as possible, and only use generic types where you really have to.

matt

Former Member
0 Kudos

Hi ,

Use the below syntax to pass the tables as parameters

*The below perform is in the source code of the F.M

PERFORM goods_movement_post TABLES itab1

itab2

itab3

USING ls_goodsmvt_header

g_mov_code.

suppose u are using the itab1 & itab2 tables data to get the itab3 Data

And The below code is in the Frms include

FORM goods_movement_post

TABLES

pt_itab1 STRUCTURE vbak

pt_itab2 STRUCTURE vbap

pt_itab3 STRUCTURE bapiret2

USING

p_ls_goodsmvt_header STRUCTURE bapi2017_gm_head_01

p_g_mov_code.

-


-


ENDFORM

Thanks & Reagrds

Mallikharjuna Reddy