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: 

Internal table in method of class (BADI)

Former Member
0 Kudos

Hello people !!

I need to use an internal table into method of class. I don´t know very well how to use it. I know that it hasn´t a header; but I don´t know how to defined and use it.

I need to use in a method of badi.-

I will be grateful by the help that your could offer to me.-

Thank you so much,

Esther.-

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi,

acc_data is an internal table and not a work area..

You have to declare another work area for accessing the intenrl table acc_data...

changes marked in bold..

types: es_accdata type standard table of Z_ES_ACCDATA.

data: acc_data type es_accdata.

DATA: wa type line of es_accdata.

loop at it_mseg into r_mseg.

  • si es Entrada de Mercancía

if r_mseg-bwart = '101'.

at first.

wa

-cuenta = r_mseg-sakto.

if not r_mseg-kostl is initial.

wa

-centro_coste = r_mseg-kostl.
else.

wa

-orden_inversion = r_mseg-aufnr.

endif.

endat.

monto = monto + r_mseg-dmbtr.

endif.

endloop.

Thanks,

Naren

5 REPLIES 5

Former Member
0 Kudos

Hi,

In the method you have to declare the internal table using type ..

Example

-


1)

TYPES: BEGIN OF TYPE_MATERIAL,

MATNR TYPE MATNR,

END OF TYPE_MATERIAL.

DATA: ITAB TYPE STANDARD TABLE OF TYPE_MATERIAL.

DATA: WA TYPE TYPE_MATERIAL.

READ TABLE ITAB INTO WA WITH KEY MATNR = 'ASDF'.

2)

DATA: ITAB TYPE STANDARD TABLE OF MARA.

DATA: WA TYPE MARA.

READ TABLE ITAB INTO WA WITH KEY MATNR = 'ASDF'.

Thanks,

Naren

0 Kudos

Thank you for your answer.

But, I had defined as de fist item, but I had defined with a structure of dictinary.

Now, in my code, I need to deposit information to the above mentioned table. Then, when I try to accede to the fields of the estructure, when I compile it gives me the following mistake:

"ACC_DATA" is a table without a header line and therefore has no

component called "CUENTA".

I attach departs from the code:

types: es_accdata type standard table of Z_ES_ACCDATA.

data: acc_data type es_accdata.

loop at it_mseg into r_mseg.

  • si es Entrada de Mercancía

if r_mseg-bwart = '101'.

at first.

acc_data-cuenta = r_mseg-sakto.

if not r_mseg-kostl is initial.

acc_data-centro_coste = r_mseg-kostl.

else.

acc_data-orden_inversion = r_mseg-aufnr.

endif.

endat.

monto = monto + r_mseg-dmbtr.

endif.

endloop.

Thank you againg, for a new answer !!!!

bye, Esther.-

0 Kudos
types: es_accdata type standard table of Z_ES_ACCDATA.

data: acc_data type es_accdata.
data: xacc_data like line of acc_data.

loop at it_mseg into r_mseg.

* si es Entrada de Mercancía
if r_mseg-bwart = '101'.

at first.
xacc_data-cuenta = r_mseg-sakto.

if not r_mseg-kostl is initial.
xacc_data-centro_coste = r_mseg-kostl.
else.
xacc_data-orden_inversion = r_mseg-aufnr.
endif.
endat.

monto = monto + r_mseg-dmbtr.
endif.
endloop.

You need to use a workarea for ACC_DATA as shown above.

Regards,

Rich Heilman

0 Kudos

Now it is continue compiling. Now, I will see how to wok it .

Thank you so much, again.

Regards, Esther.-

Former Member
0 Kudos

Hi,

acc_data is an internal table and not a work area..

You have to declare another work area for accessing the intenrl table acc_data...

changes marked in bold..

types: es_accdata type standard table of Z_ES_ACCDATA.

data: acc_data type es_accdata.

DATA: wa type line of es_accdata.

loop at it_mseg into r_mseg.

  • si es Entrada de Mercancía

if r_mseg-bwart = '101'.

at first.

wa

-cuenta = r_mseg-sakto.

if not r_mseg-kostl is initial.

wa

-centro_coste = r_mseg-kostl.
else.

wa

-orden_inversion = r_mseg-aufnr.

endif.

endat.

monto = monto + r_mseg-dmbtr.

endif.

endloop.

Thanks,

Naren