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: 

ITAB LOOP

Former Member
0 Kudos

HI,

this is program i got and trying to execute..

REPORT sapbc400tss_itab_loop .

DATA: it_spfli TYPE sbc400_t_spfli.

DATA: wa_spfli TYPE spfli.

START-OF-SELECTION.

SELECT * FROM spfli INTO TABLE it_spfli.

IF sy-subrc = 0.

LOOP AT it_spfli INTO wa_spfli.

WRITE: / wa_spfli-carrid,

wa_spfli-connid,

wa_spfli-cityfrom,

wa_spfli-cityto,

wa_spfli-deptime,

wa_spfli-arrtime.

ENDLOOP.

ENDIF.

Its saying Type "sbc400_t_spfli" is unknown, i doubled click on that to check, but it does't exists. How to create that type sbc400_t_spfli, whats the syntax..

Thanks

1 ACCEPTED SOLUTION

Former Member
0 Kudos

You can also:

DATA: it_spfli TYPE spfli_tab.
DATA: wa_spfli TYPE spfli.

START-OF-SELECTION.
  SELECT * FROM spfli INTO TABLE it_spfli.

  IF sy-subrc = 0.
    LOOP AT it_spfli INTO wa_spfli.
      WRITE: / wa_spfli-carrid,
      wa_spfli-connid,
      wa_spfli-cityfrom,
      wa_spfli-cityto,
      wa_spfli-deptime,
      wa_spfli-arrtime.
    ENDLOOP.
  ENDIF.

Rob

PS - If you change your thread to a question, you might get more responses.

Message was edited by: Rob Burbank

6 REPLIES 6

Former Member
0 Kudos

types: sbc400_t_spfli type standard table of spfli.

add this statement right after report statement.

Otherwise declare it_spfli as an internal table.

data: it_spfli like spfli occurs 0.

declare

thanks,

Rajesh.

Message was edited by: Rajesh Mandalapu

Manohar2u
Active Contributor
0 Kudos

Can you try like below

DATA: it_spfli <b>LIKE</b> sbc400_t_spfli

or

DATA: it_spfli like spfli

Regds

Manohar

Message was edited by: Manohar Reddy

Former Member
0 Kudos

Hello Sir,

You need a book ---> Learn abap here

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

REPORT sapbc400tss_itab_loop .

DATA: it_spfli LIKE spfli occurs 0 with header line.

DATA: wa_spfli LIKE spfli.

START-OF-SELECTION.

SELECT * FROM spfli INTO TABLE it_spfli.

IF sy-subrc = 0.

LOOP AT it_spfli INTO wa_spfli.

WRITE: / wa_spfli-carrid,

wa_spfli-connid,

wa_spfli-cityfrom,

wa_spfli-cityto,

wa_spfli-deptime,

wa_spfli-arrtime.

ENDLOOP.

ENDIF.

Former Member
0 Kudos

You can also:

DATA: it_spfli TYPE spfli_tab.
DATA: wa_spfli TYPE spfli.

START-OF-SELECTION.
  SELECT * FROM spfli INTO TABLE it_spfli.

  IF sy-subrc = 0.
    LOOP AT it_spfli INTO wa_spfli.
      WRITE: / wa_spfli-carrid,
      wa_spfli-connid,
      wa_spfli-cityfrom,
      wa_spfli-cityto,
      wa_spfli-deptime,
      wa_spfli-arrtime.
    ENDLOOP.
  ENDIF.

Rob

PS - If you change your thread to a question, you might get more responses.

Message was edited by: Rob Burbank

0 Kudos

Hi,

The Program goes like this,

REPORT Z_ITAB_LOOP.

TYPES: SBC400_T_SPFLI TYPE STANDARD TABLE OF SPFLI.

*Note STANDARD TABLE is one of the Internal Tables Types,

*to gain more, place cursor on it and press F1

DATA: IT_SPFLI TYPE SBC400_T_SPFLI.

DATA: WA_SPFLI TYPE SPFLI.

START-OF-SELECTION.

SELECT * FROM SPFLI INTO TABLE IT_SPFLI.

IF SY-SUBRC = 0.

LOOP AT IT_SPFLI INTO WA_SPFLI.

WRITE: / WA_SPFLI-CARRID,

WA_SPFLI-CONNID,

WA_SPFLI-CITYFROM,

WA_SPFLI-CITYTO,

WA_SPFLI-DEPTIME,

WA_SPFLI-ARRTIME.

ENDLOOP.

ENDIF.

Note: Program will display only record without Field Lables.

Better to gain knowledge on basics first.

Goodday.

0 Kudos

HI Jen,

Do this way ...

DATA: IT_SPFLI LIKE SPFLI OCCURS 0.
DATA: WA_SPFLI TYPE SPFLI.

START-OF-SELECTION.
  SELECT * FROM SPFLI INTO TABLE IT_SPFLI.

  IF SY-SUBRC = 0.
    LOOP AT IT_SPFLI INTO WA_SPFLI.
      WRITE: / WA_SPFLI-CARRID,
      WA_SPFLI-CONNID,
      WA_SPFLI-CITYFROM,
      WA_SPFLI-CITYTO,
      WA_SPFLI-DEPTIME,
      WA_SPFLI-ARRTIME.
    ENDLOOP.
  ENDIF.

Regards,

Santosh