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 without headerline

Former Member
0 Kudos

hi,

I just started learning ABAP. I was struck up with this problem.

DATA : BEGIN OF str_mara,

Matnr LIKE MARA-MATNR,

END OF str_mara.

DATA : i_tab TYPE TABLE OF str_mara.

i declared internal table without headerline like this. now how can i write select query to fetch data from mara table and how can i display it??

plz help me,

thanks,

5 REPLIES 5

Former Member
0 Kudos

Hello,

you can loop at the table.

DATA wa_tab type str_mara.

loop at i_tab into wa_tab where log expresion

write wa_typ-plz.

endloop.

read table i_tab.

more about loop or read you find at sap docu.

ssimsekler
Active Contributor
0 Kudos

Hi Ravindra

Firstly, I recommend a structural study like the standard SAP course <b>BC 400</b>, or from the book <a href="http://www.sap-press.com/product.cfm?account=&product=H958"><b>"The Official ABAP Reference Book"</b></a> by Horst Keller and Joachim Jacobitz.

About your question:

1. To retrieve data from the DB table mara, you can use the SELECT statement.

<u>e.g.</u>

SELECT matnr FROM mara
       INTO TABLE i_tab
       WHERE cdate GE sy-datum .

2. To iterate in <i>i_tab</i> you need a work area since you declared your internal table without a header line. You can use <i>str_mara</i> which you have already declared.

<u>e.g.</u>

LOOP AT i_tab INTO str_mara .
  WRITE:/ sy-tabix, str_mara-matnr .
ENDLOOP .

However, these examples may just demonstrate some primitive functionality. For more options, you can use the F1 help feature of the SAP system or the resources I mentioned above.

Regards

*--Serdar <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]</a>

Former Member
0 Kudos

Hi~

If you didn't declare headerline explicitly, the headerline is made with same name as internal table by system, implicitly.

look at your code

DATA : BEGIN OF str_mara,
       Matnr LIKE MARA-MATNR,
END OF str_mara.

DATA : i_tab TYPE TABLE OF str_mara.

you declared a structure, an internal table.

like this

structure : str_mara 
 
internal table : i_tab

   header line ++++++++++++++++++++++++
               i_tab     
   body        ++++++++++++++++++++++++
               ....
               ++++++++++++++++++++++++

if you want to select query to fetch data from mara table

and display it, refer next code snippet.

1) select 
   SELECT matnr FROM mara   
      INTO TABLE i_tab 
     WHERE log expression.
2) display
   loop at i_tab.
      WRITE:/ sy-tabix, i_tab-matnr.
   endloop.

Even though you didn't declare header line, The header line is declared implicitly.

I mean,

   loop at i_tab.
      WRITE:/ sy-tabix, i_tab-matnr.
   endloop.

equals.

   loop at i_tab (into i_tab).
      WRITE:/ sy-tabix, i_tab-matnr.
   endloop.

the first i_tab means <b>internal table</b>, and the second one means <b>headerline</b>.

But SAP recommend you define header line, internal table

explicitly.

I wish I could you help.

Regards

Kyung Woo

eyal_alsheikh
Active Participant
0 Kudos

Hi RAVINDRA,

Maybe this book will help you

http://cma.zdnet.com/book/abap/

Eyal.

athavanraja
Active Contributor
0 Kudos

data: wa_mara like line of i_tab .

select * from mara into table i_tab .

loop at i_tab into wa_mara .

write:/wa_mara .

endloop .

Regards

Raja