Application Development and Automation 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: 
Read only

ITAB LOOP

Former Member
0 Likes
907

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
Read only

Former Member
0 Likes
808

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
Read only

Former Member
0 Likes
808

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

Read only

Manohar2u
Active Contributor
0 Likes
808

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

Read only

Former Member
0 Likes
808

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.

Read only

Former Member
0 Likes
809

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

Read only

0 Likes
808

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.

Read only

0 Likes
808

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