Skip to Content
0
Former Member
Apr 20, 2007 at 11:31 AM

internal tables

27 Views

Hi all,

i am trying to fetch data using four internal tables, but i am getting the same output repeated several times. please help me in resolving this issue.

the code is:

TYPES: BEGIN OF outtab,

carrid LIKE spfli-carrid,

connid LIKE spfli-connid,

fldate LIKE sflight-fldate,

cityfrom LIKE spfli-cityfrom,

cityto LIKE spfli-cityto,

deptime LIKE spfli-deptime,

arrtime LIKE spfli-arrtime,

price LIKE sflight-price,

CURRENCY LIKE SFLIGHT-CURRENCY,

SEATSMAX LIKE SFLIGHT-SEATSMAX,

SEATSOCC LIKE SFLIGHT-SEATSOCC,

CURRCODE LIKE SCARR-CURRCODE,

CARRNAME LIKE SCARR-CARRNAME,

URL LIKE SCARR-URL,

END OF outtab.

TYPES:BEGIN OF st_spfli,

carrid LIKE spfli-carrid,

connid LIKE spfli-connid,

CITYFROM LIKE SPFLI-CITYFROM,

CITYTO LIKE SPFLI-CITYTO,

DEPTIME LIKE SPFLI-DEPTIME,

ARRTIME LIKE SPFLI-ARRTIME,

END OF st_spfli.

TYPES: BEGIN OF st_sflight,

carrid LIKE sflight-carrid,

connid LIKE sflight-connid,

fldate LIKE sflight-fldate,

price LIKE sflight-price,

CURRENCY LIKE SFLIGHT-CURRENCY,

SEATSMAX LIKE SFLIGHT-SEATSMAX,

SEATSOCC LIKE SFLIGHT-SEATSOCC,

END OF st_sflight.

TYPES: BEGIN OF ST_SBOOK,

CARRID LIKE SBOOK-CARRID,

CONNID LIKE SBOOK-CONNID,

FLDATE LIKE SBOOK-FLDATE,

BOOKID LIKE SBOOK-BOOKID,

ORDER_DATE LIKE SBOOK-ORDER_DATE,

PASSNAME LIKE SBOOK-PASSNAME,

LOCCURAM LIKE SBOOK-LOCCURAM,

FORCURKEY LIKE SBOOK-FORCURKEY,

END OF ST_SBOOK.

TYPES: BEGIN OF ST_SCARR,

CARRID LIKE SCARR-CARRID,

CURRCODE LIKE SCARR-CURRCODE,

CARRNAME LIKE SCARR-CARRNAME,

URL LIKE SCARR-URL,

END OF ST_SCARR.

DATA: it_outtab TYPE TABLE OF outtab,

it_spfli TYPE TABLE OF st_spfli,

it_sflight TYPE TABLE OF st_sflight,

IT_SBOOK TYPE TABLE OF ST_SBOOK,

IT_SCARR TYPE TABLE OF ST_SCARR,

wa_outtab TYPE outtab,

wa_spfli TYPE st_spfli,

wa_sflight TYPE st_sflight,

WA_SBOOK TYPE ST_SBOOK,

WA_SCARR TYPE ST_SCARR.

************SELECTION SCREEN***************

SELECTION-SCREEN: BEGIN OF BLOCK B1 WITH FRAME.

SELECTION-SCREEN BEGIN OF LINE.

SELECTION-SCREEN COMMENT 1(40) TEXT-001.

SELECTION-SCREEN END OF LINE.

PARAMETERS: p_from TYPE spfli-cityfrom,

p_to TYPE spfli-cityto,

p_date TYPE sflight-fldate.

SELECTION-SCREEN: END OF BLOCK B1.

SELECT carrid

connid

CITYFROM

CITYTO

DEPTIME

ARRTIME

FROM spfli

INTO TABLE it_spfli

WHERE cityfrom EQ p_from

AND cityto EQ p_to.

IF IT_SPFLI[] IS NOT INITIAL.

SELECT carrid

connid

fldate

price

CURRENCY

SEATSMAX

SEATSOCC

FROM sflight

INTO table it_sflight

for all entries in it_spfli

WHERE carrid EQ it_spfli-carrid

AND connid EQ it_spfli-connid

and fldate eq p_date.

LOOP AT IT_SPFLI INTO WA_SPFLI.

MOVE-CORRESPONDING WA_SPFLI TO WA_OUTTAB.

LOOP AT IT_SFLIGHT INTO WA_SFLIGHT WHERE CARRID = WA_SPFLI-CARRID AND CONNID = WA_SPFLI-CONNID.

MOVE-CORRESPONDING WA_SFLIGHT TO WA_OUTTAB.

SELECT CARRID

CURRCODE

CARRNAME

URL

FROM SCARR

INTO TABLE IT_SCARR

WHERE CARRID = WA_SFLIGHT-CARRID.

LOOP AT IT_SCARR INTO WA_SCARR WHERE CARRID = WA_SFLIGHT-CARRID.

MOVE-CORRESPONDING WA_SCARR TO WA_OUTTAB.

APPEND WA_OUTTAB TO IT_OUTTAB.

ENDLOOP.

ENDLOOP.

ENDLOOP.

ELSE.

MESSAGE ' NO FLIGHT AVAILABLE' TYPE 'I'.

ENDIF.

LOOP AT IT_SFLIGHT INTO WA_SFLIGHT.

SELECT CARRID

CONNID

FLDATE

BOOKID

ORDER_DATE

PASSNAME

LOCCURAM

FORCURKEY

FROM SBOOK

INTO TABLE IT_SBOOK

WHERE CARRID EQ WA_SFLIGHT-CARRID

AND CONNID EQ WA_SFLIGHT-CONNID

AND FLDATE EQ WA_SFLIGHT-FLDATE.

LOOP AT IT_SBOOK INTO WA_SBOOK.

MOVE-CORRESPONDING WA_SBOOK TO WA_OUTTAB.

APPEND WA_OUTTAB TO IT_OUTTAB.

ENDLOOP.

ENDLOOP.

LOOP AT IT_OUTTAB INTO WA_OUTTAB.

WRITE:/ wa_outtab-carrid,

wa_outtab-connid,

wa_outtab-fldate,

wa_outtab-cityfrom,

wa_outtab-cityto,

wa_outtab-deptime,

wa_outtab-arrtime,

wa_outtab-price,

wa_outtab-CURRENCY,

wa_outtab-SEATSMAX,

wa_outtab-SEATSOCC,

wa_outtab-CURRCODE,

wa_outtab-CARRNAME,

wa_outtab-URL.

ENDLOOP.

regards

vivek