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: 

passing an internal table to a badi

Former Member
0 Kudos

Helo All,

I have declared a variable outside the badi say

data: phead like STRUCTURE_head occurs 0 with HEADER LINE.

suppose this phead contains say 4 rows .

      • calling the method of the badi .

.

CALL METHOD user_exit->method1

CHANGING

thead = phead .

Here the parameter thead is of the type structure , so only the header line is passed . How do i pass all the four rows to the badi ?

Thanks in advance

regards,

swetha

8 REPLIES 8

Former Member
0 Kudos

Use square brackets to indicate you are passing the contents of the table, i.e. itab[] instead of just itab.

0 Kudos

Hello Steve higton,

This doesn't seem to work , it displays an error thead is not an inetrnal table -"the occurs n" specification is missing .

Best Regards,

Swetha

Former Member
0 Kudos

Hi Shwetha,

As you are trying to pass in internal table to a structure in changing parameters, it would end up in error.

If the BADI that you are using has CHANGING parameter of TYPE STRUCTURE, you cannot pass an internal table to the same.

You can loop in the internal table and call the BADI inside the loop, passing the WORK AREA.

Best Regards,

Ram.

Former Member
0 Kudos

Hi Swetha,

call that method in a loop... endloop, and pass parameters.. like changing parameters with your structure and outside badi update it.

Regards,

Dhanunjaya Reddy.

0 Kudos

my question is , if I loop at say phead aand call the badi for every row ,

will thead take the just header line value ( which is intial )or will with take the value of each row ?

0 Kudos

Hi Swetha,

Let say, we have an internal table phead.

You will be declaring a work area, lets say whead.

now,

LOOP AT phead into whead.

BADI CALL.

changing

thead = whead.

ENDLOOP.

So, whead wil be passed as changing parameter to the badi...

to be precise, you will be passing the structure to the badi.

Best Regards,

Ram.

0 Kudos

Hi,

We can not pass internal table to a structure type parameter. If you wish to pass 4 rows of data, you may need to use loop at the intenal table and call the BADI for 4 times.

Hope this helps,

Pragya

stefansoyka
Explorer
0 Kudos

You can pass internal tables to a BADI. For the parameter type of the BADI interface, you have to declare a DDIC table type with the line type of the structure (or look for an existing table type with a fitting line type), if you are defining a new BADI interface.

Once it is all set up, you pass the entire internal table (i.e. the structure parameter) to the respective BADI parameter. Be sure not to forget the square brackets, or the compiler will assume that you are passing the work area only. Your code might look similar to this:

    CALL BADI lr_badi->exit_sapln2la_001
      EXPORTING
        ss_okcode             = ss_okcode
        ss_form               = ss_form
        ss_n2labor001_vorher  = ss_n2labor001_ai[]
        ss_n2labor001_nachher = ss_n2labor001_bi[].