Thursday, September 25, 2008

Go to any page of a list directly form selection screen

By Joyjit Ghosh,
Kolkata, India.


Code:

*&---------------------------------------------------------------------*

*& Report Z_DEMO_JG

*&

*&---------------------------------------------------------------------*

*& Go to any page of a list directly form selection screen

*&---------------------------------------------------------------------*

REPORT z_demo_jg LINE-SIZE 80 LINE-COUNT 50

NO STANDARD PAGE HEADING.

TABLES: sflight.

* Type declaration

TYPES : BEGIN OF ty_flight,

carrid(19) TYPE c,

connid(18) TYPE c,

fldate LIKE sflight-fldate,

fldate1(14) TYPE c,

planetype(13) TYPE c,

END OF ty_flight.

* Data declaration

DATA: i_flight TYPE STANDARD TABLE OF ty_flight,

w_flight TYPE ty_flight.

DATA: field(50) TYPE c.

DATA: part1(30) TYPE c,

part2(30) TYPE c.

DATA: l_counter TYPE i.

* Selection screen

SELECT-OPTIONS: s_carrid FOR sflight-carrid.

PARAMETERS: p_page TYPE int3.

START-OF-SELECTION.

* Fetch data from sflight table

SELECT carrid

connid

fldate

planetype

FROM sflight

INTO CORRESPONDING FIELDS OF TABLE i_flight

WHERE carrid IN s_carrid.

CHECK sy-subrc = 0.


* Display final data

PERFORM display_data.

TOP-OF-PAGE.

* Display report header

PERFORM display_column_name.

*&---------------------------------------------------------------------*

*& Form display_column_name

*&---------------------------------------------------------------------*

* Display column header

*----------------------------------------------------------------------*

* None

*----------------------------------------------------------------------*

FORM display_column_name .


WRITE: /10 'Program name:', sy-repid.

WRITE: /10 'Page no:', sy-pagno.

* Store report header texts

w_flight-carrid = 'Airline Code'(001).

w_flight-connid = 'Flight Connection'(002).

w_flight-fldate1 = 'Flight date'(003).

w_flight-planetype = 'Aircraft Type'(004).

* Display report header

SKIP.

ULINE.

FORMAT INTENSIFIED ON COLOR 1.

WRITE: 1 sy-vline,

2 w_flight-carrid,

21 sy-vline,

22 w_flight-connid,

40 sy-vline,

41 w_flight-fldate1,

55 sy-vline,

56 w_flight-planetype,

80 sy-vline.

ULINE.

ENDFORM. " display_column_name

*&---------------------------------------------------------------------*

*& Form display_data

*&---------------------------------------------------------------------*

* Display flight data

*----------------------------------------------------------------------*

* None

*----------------------------------------------------------------------*

FORM display_data .

CLEAR w_flight.

* Display report final data

LOOP AT i_flight INTO w_flight.

w_flight-fldate1 = w_flight-fldate.

FORMAT INTENSIFIED ON COLOR 2.

WRITE: 1 sy-vline,

2 w_flight-carrid,

21 sy-vline,

22 w_flight-connid,

40 sy-vline,

41 w_flight-fldate1,

55 sy-vline,

56 w_flight-planetype,

80 sy-vline.

ULINE.

ENDLOOP.

IF p_page IS NOT INITIAL.

* Check whether any page exist with the number entered

* in the selection screen

READ LINE 1 OF PAGE p_page.

IF sy-subrc = 0.

* If exist then scroll down to that page

SCROLL LIST TO PAGE p_page LINE 1 .

ELSE.

* Otherwise display information message and continue

* processing

MESSAGE i000(z_zzz_ca_messages)

WITH 'Page number does not exist'(001).

ENDIF.

ENDIF.

ENDFORM. " display_data

Screen shots:

Input:

Output:

Input:



Output:

No comments: