cancel
Showing results for 
Search instead for 
Did you mean: 

Indirect Addressing

Former Member
0 Kudos

Hi Everyone,

First time here and relatively new to ABAP.

Is there way in ABAP to accomplish what in other languages is known as 'Indirect Addressing'. For example I have a few internal tables and I want to write one form which will do the same process on all these internal tables, e.g. transfer their contents to a flat file.

How can I call such a form with different internal tables?

Thanks.

Shahid

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hello Shahid,

Please find dummy code which u can use as per ur req...

tables: mara,ekpo.

data: begin of i_mara occurs 0,

matnr like mara-matnr,

end of i_mara.

data: begin of i_ekpo occurs 0,

ebeln like ekpo-ebeln,

end of i_ekpo.

field-symbols:<fs2> type any,

<fs3> type table.

select-options:s_matnr for mara-matnr,

s_ebeln for ekpo-ebeln.

assign i_mara to <fs2>.

select matnr into i_mara-matnr from mara

where matnr in s_matnr.

append i_mara.

append i_mara.

if sy-dbcnt = 10.

exit.

endif.

endselect.

assign i_mara[] to <fs3>.

loop at <fs3> into <fs2>.

write : <fs2>.

endloop.

clear <fs3>.

refresh <fs3>.

  • for ekpo

assign i_ekpo to <fs2>.

select ebeln into i_ekpo-ebeln from ekpo

where ebeln in s_ebeln.

append i_ekpo.

append i_ekpo.

if sy-dbcnt = 10.

exit.

endif.

endselect.

assign i_ekpo[] to <fs3>.

loop at <fs3> into <fs2>.

write : <fs2>.

endloop.

clear <fs3>.

refresh <fs3>.

Former Member
0 Kudos

Hi,

In ABAP 'Indirect Addressing' is done with Field symbols..

Read the SAP documentation Field-symbols at the following link..

http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3860358411d1829f0000e829fbfe/content.htm

Regards,

Nagaraju Chidurupalli

athavanraja
Active Contributor
0 Kudos

check out this sample code.

REPORT Y_TEST 
       NO STANDARD PAGE HEADING.

types: begin of s_type ,
       a(10) ,
       b(10) ,
       c(10) ,
       end of s_type .

data: itab1 type standard table of s_type .
data: itab2 type standard table of s_type .
data: itab3 type standard table of s_type .
data: wa type s_type .

move: '1a' to wa-a ,
       '1b' to wa-b ,
       '1c' to wa-c .
append wa to itab1 .

move: '2a' to wa-a ,
       '2b' to wa-b ,
       '2c' to wa-c .
append wa to itab2 .

move: '3a' to wa-a ,
       '3b' to wa-b ,
       '3c' to wa-c .
append wa to itab3 .

perform write_list tables itab1 .
perform write_list tables itab2 .
perform write_list tables itab3 .

*&---------------------------------------------------------------------*
*&      Form  write_list
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*      -->P_ITAB1  text
*----------------------------------------------------------------------*
form write_list  tables   p_itab1 .
field-symbols: <FS> type any .

loop at p_itab1 assigning <fs> .
write:/ <fs> .
endloop .
write:/ sy-uline .
endform.                    " write_list

Is this what you are looking for?

Regards

Raja

Former Member
0 Kudos

Hi Raja,

Thanks for your help.

My internel tables are not identical but I am doing a similar function on all of them - dumping their contents to a flat file.

Shahid

Former Member
0 Kudos

Thanks Nagaraju,

I tried the field symbols but could not get it work.

Following is my code snippet.

  • Itab declaration in an include file

DATA: BEGIN OF h_Hdr9999,

Field1(4) VALUE '0000',

Field2(5) VALUE '00000',

Field3(11) VALUE SPACE,

Field4(19) VALUE SPACE,

Field5(3) VALUE SPACE,

Field6(17) VALUE SPACE,

Field7(6) VALUE SPACE,

Field8(9) VALUE SPACE,

Field9(50) VALUE SPACE,

Field10(17) VALUE SPACE,

Field11(6) VALUE SPACE,

Field12(6) VALUE SPACE,

END OF h_Hdr9999.

DATA i_Hdr9999 LIKE TABLE OF h_Hdr9999 WITH HEADER LINE.

  • Declaration after a call to include

FIELD-SYMBOLS <i_Tab> TYPE TABLE.

  • Execution in START-OF-SELECTION

ASSIGN i_Hdr9999 TO <i_Tab>.

End of code snippet

The error message is as follows:

I_HDR9999 is not type-compatibe with field symbol "<I_TAB>".

I get this error message with 'TABLE' or 'ANY TABLE'.

Thanks for your help.

Shahid

Former Member
0 Kudos

Hi Shahid

I can't be sure but it might have something to do with declaring your table with a header line. If you use the syntax:

DATA i_Hdr9999 TYPE STANDARD TABLE OF h_Hdr9999.

it might work. Of course, that means that at toher points in your code you will need to use explicit work areas rather than the implicit work area in the header line. Also with the field-symbols declaration, I think it should be one of the following:

FIELD-SYMBOLS <i_Tab> TYPE ANY TABLE.

OR

FIELD-SYMBOLS <i_Tab> TYPE ANY.

I doubt the second one will work for a table but unfortunately cant try it out at the moment!

Hope that helps

Andy.

athavanraja
Active Contributor
0 Kudos

did you try the code by chaing the itab definition.

even if the itab definitions are different, this sample would work.

Regards

Raja