Skip to Content
0
Former Member
Mar 25, 2010 at 11:38 AM

interactive alv report......with one table having more than 2 foreign key

17 Views

&----


*& Report ZRAHUL_ALV_SFLIGHT2

*&

&----


*&

*&

&----


REPORT zrahul_alv_sflight2 NO STANDARD PAGE HEADING.

TYPE-POOLS slis.

DATA: fcat TYPE slis_fieldcat_alv,

it_fcat TYPE slis_t_fieldcat_alv,

fcat1 TYPE slis_fieldcat_alv,

it_fcat1 TYPE slis_t_fieldcat_alv,

fcat2 TYPE slis_fieldcat_alv,

it_fcat2 TYPE slis_t_fieldcat_alv,

lout TYPE slis_layout_alv,

head TYPE slis_listheader,

it_head TYPE slis_t_listheader.

TABLES: SFLIGHT, SCURX, SAPLANE.

DATA: BEGIN OF it_sflight OCCURS 0,

carrid TYPE sflight-carrid, "PK

connid TYPE sflight-connid,

fldate TYPE sflight-fldate,

currency TYPE sflight-currency, "FK 1

planetype TYPE sflight-planetype, "FK 2

END OF it_sflight.

DATA: BEGIN OF it_scurx OCCURS 0,

currkey TYPE scurx-currkey, "PK 1

currdec TYPE scurx-currdec,

END OF it_scurx.

DATA: BEGIN OF it_saplane OCCURS 0,

planetype TYPE saplane-planetype, "PK 2

seatsmax TYPE saplane-seatsmax,

tankcap TYPE saplane-tankcap,

weight TYPE saplane-weight,

END OF it_saplane.

SELECTION-SCREEN: BEGIN OF BLOCK blk WITH FRAME TITLE t.

SELECT-OPTIONS: id FOR it_sflight-carrid,

id2 FOR it_sflight-connid.

SELECTION-SCREEN END OF BLOCK blk.

INITIALIZATION.

t = 'enter required criterias'.

lout-zebra = 'X'.

START-OF-SELECTION.

SELECT * FROM sflight INTO CORRESPONDING FIELDS OF TABLE it_sflight

WHERE carrid IN id AND connid IN id2.

END-OF-SELECTION.

****FCAT F0R IT_SFLIGHT

fcat-col_pos = 1.

fcat-tabname = 'IT_SFLIGHT'.

fcat-fieldname = 'CARRID'.

fcat-outputlen = 10.

fcat-seltext_m = 'PLANE ID'.

APPEND fcat TO it_fcat.

CLEAR fcat.

fcat-col_pos = 2.

fcat-tabname = 'IT_SFLIGHT'.

fcat-fieldname = 'CONNID'.

fcat-outputlen = 10.

fcat-seltext_m = 'CONN ID'.

APPEND fcat TO it_fcat.

CLEAR fcat.

fcat-col_pos = 3.

fcat-tabname = 'IT_SFLIGHT'.

fcat-fieldname = 'FLDATE'.

fcat-outputlen = 10.

fcat-seltext_m = 'FLDATE'.

APPEND fcat TO it_fcat.

CLEAR fcat.

fcat-col_pos = 4.

fcat-tabname = 'IT_SFLIGHT'.

fcat-fieldname = 'CURRENCY'.

fcat-outputlen = 10.

fcat-seltext_m = 'CURRENCY'.

APPEND fcat TO it_fcat.

CLEAR fcat.

fcat-col_pos = 5.

fcat-tabname = 'IT_SFLIGHT'.

fcat-fieldname = ';PLANETYPE'.

fcat-outputlen = 10.

fcat-seltext_m = 'PLANETYPE'.

APPEND fcat TO it_fcat.

CLEAR fcat.

*****GRID DISPLAY

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

i_callback_program = 'ZRAHUL_ALV_SFLIGHT2'

  • I_CALLBACK_PF_STATUS_SET = ' '

i_callback_user_command = 'CLICK'

i_callback_top_of_page = 'HEADER'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

i_grid_title = 'GRID 1'

  • I_GRID_SETTINGS =

is_layout = lout

it_fieldcat = it_fcat

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS =

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • IR_SALV_FULLSCREEN_ADAPTER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

t_outtab = it_sflight

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

  • OTHERS = 2

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

&----


*& Form header

&----


  • text

----


FORM header.

CLEAR it_head.

head-typ = 'H'.

head-info = 'KINGFISHER'.

APPEND head TO it_head.

head-typ = 'S'.

head-key = 'KEY'.

head-info = 'AIRLINES'.

APPEND head TO it_head.

CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'

EXPORTING

it_list_commentary = it_head

i_logo = 'KING_LOGO'

  • I_END_OF_LIST_GRID =

  • I_ALV_FORM =

.

ENDFORM. "header

&----


*& Form CLICK

&----


  • text

----


  • -->OK text

  • -->SEL text

----


FORM click USING ok TYPE sy-ucomm

sel TYPE slis_selfield.

CLEAR it_fcat.

CASE ok.

WHEN '&IC1'.

********SAPLANE RELATION

READ TABLE it_sflight INDEX sel-tabindex.

SELECT * FROM saplane INTO CORRESPONDING FIELDS OF TABLE it_saplane WHERE planetype = it_sflight-planetype.

fcat-col_pos = 1.

fcat-tabname = 'IT_SAPLANE'.

fcat-fieldname = 'PLANETYPE'.

fcat-outputlen = 10.

fcat-seltext_m = 'TYPE OF PLANE'.

APPEND fcat TO it_FCAT.

CLEAR fcat.

fcat-col_pos = 2.

fcat-tabname = 'IT_SAPLANE'.

fcat-fieldname = 'SEATSMAX'.

fcat-outputlen = 10.

fcat-seltext_m = 'MAX SEATS'.

APPEND fcat TO it_FCAT.

CLEAR fcat.

fcat-col_pos = 3.

fcat-tabname = 'IT_SAPLANE'.

fcat-fieldname = 'TANKCAP'.

fcat-outputlen = 10.

fcat-seltext_m = 'FUEL TANK CAPACITY'.

APPEND fcat TO it_FCAT.

CLEAR fcat.

fcat-col_pos = 4.

fcat-tabname = 'IT_SAPLANE'.

fcat-fieldname = 'WEIGHT'.

fcat-outputlen = 10.

fcat-seltext_m = 'WEIGHT F PLANE'.

APPEND fcat TO it_FCAT.

CLEAR fcat.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

i_callback_program = 'ZRAHUL_ALV_SFLIGHT2'

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

i_callback_top_of_page = 'HEADER'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

i_grid_title = 'GRID 2'

  • I_GRID_SETTINGS =

is_layout = LOUT

it_fieldcat = IT_FCAT

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS =

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • IR_SALV_FULLSCREEN_ADAPTER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

tables

t_outtab = IT_SAPLANE

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

  • OTHERS = 2

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

*******SCURX RELATION

CLEAR: IT_FCAT2,IT_FCAT.

READ TABLE IT_SFLIGHT INDEX SEL-TABINDEX.

SELECT * FROM SCURX INTO CORRESPONDING FIELDS OF TABLE IT_SCURX WHERE CURRKEY = IT_SFLIGHT-CURRENCY.

FCAT2-COL_POS = 1.

FCAT2-TABNAME = 'IT_SCURX'.

FCAT2-FIELDNAME = 'CURRKEY'.

FCAT2-OUTPUTLEN = 15.

FCAT2-SELTEXT_M = 'CURRENCY'.

APPEND FCAT2 TO IT_FCAT2.

CLEAR FCAT2.

FCAT2-COL_POS = 2.

FCAT2-TABNAME = 'IT_SCURX'.

FCAT2-FIELDNAME = 'CURRDEC'.

FCAT2-OUTPUTLEN = 15.

FCAT2-SELTEXT_M = 'CURRENCY DEC'.

APPEND FCAT2 TO IT_FCAT2.

CLEAR FCAT2.

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = 'ZRAHUL_ALV_SFLIGHT2'

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

I_CALLBACK_TOP_OF_PAGE = 'HEADER'

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

I_GRID_TITLE = 'GRID 3'

  • I_GRID_SETTINGS =

IS_LAYOUT = LOUT

IT_FIELDCAT = IT_FCAT2

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

  • IT_SORT =

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS =

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • IR_SALV_FULLSCREEN_ADAPTER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

t_outtab = IT_SCURX

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

  • OTHERS = 2

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

ENDCASE.

ENDFORM. "click

this program runs fine when one navigation is used......but when both the foreign keys come in picture then its shows sequencialy...cant we jump directly to the third one which i require....

plz guide me.thank u.