Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

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

*& Report Z46035435_INTERNALTABLES_PRO2


*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT Z46035435_INTERNALTABLES_PRO2.

" Defination of structure for internal table


TYPES: BEGIN OF struct_it,
carrid TYPE sbook-carrid,
connid TYPE sbook-connid,
fldate TYPE sbook-fldate,
bookid TYPE sbook-bookid,
customid TYPE sbook-customid,
loccurkey TYPE sbook-loccurkey,
order_date TYPE sbook-order_date,
passname TYPE sbook-passname,
END OF struct_it.

" Declaration of Internal Table


DATA: itsbook TYPE TABLE OF struct_it with NON-UNIQUE key passname,
wasbook TYPE struct_it.

" Fetching data from sbook to internal table


SELECT carrid
connid
fldate
bookid
customid
loccurkey
order_date
passname
UP TO 20 ROWS
FROM sbook INTO TABLE itsbook.

START-OF-SELECTION.

" Displaing Basic list for user selection of operation


WRITE:/ 'Display' HOTSPOT,
/ 'dispaly_2to5' HOTSPOT,
/ 'display_5th' HOTSPOT,
/ 'display_Johann_Ryan' HOTSPOT,
/ 'modify_5th_to_steve' HOTSPOT,
/ 'delete_Johann_Ryan' HOTSPOT,
/ 'delete_10th' HOTSPOT,
/ 'delete_12to16' HOTSPOT.

AT LINE-SELECTION.

*----------------Sub-routine actions---------------------------------------------

" case statement declaration for subroutine action


CASE sy-lisel.
WHEN 'Display'.
PERFORM display.
WHEN 'dispaly_2to5'.
PERFORM display_2to5.
WHEN 'display_5th'.
PERFORM display_5th.
WHEN 'display_Johann_Ryan'.
PERFORM display_Johann_Ryan.
WHEN 'modify_5th_to_steve'.
PERFORM modify_5th_to_steve.
WHEN 'delete_Johann_Ryan'.
PERFORM delete_Johann_Ryan.
WHEN 'delete_10th'.
PERFORM delete_10th.
WHEN 'delete_12to16'.
PERFORM delete_12to16.
ENDCASE.

*--------------These are sub-routine definations.------------------------------

" Subroutine for display


FORM display.
LOOP AT itsbook INTO wasbook.
WRITE:/ wasbook.
ENDLOOP.
ENDFORM.

" Subroutine for displaying 2 to 5


FORM display_2to5.
LOOP AT itsbook INTO wasbook.
IF sy-tabix GE 2 AND sy-tabix LE 5.
WRITE:/ wasbook.
ENDIF.
ENDLOOP.
ENDFORM.

" Subroutine to Display 5th record


FORM display_5th.
LOOP AT itsbook INTO wasbook.
IF sy-tabix = 5.
WRITE:/ wasbook.
ENDIF.
ENDLOOP.
ENDFORM.

" Subroutine to display adam heller


" info: using johann ryan instead of adam heller, because adam heller not available
in sbook
FORM display_Johann_Ryan.
LOOP AT itsbook INTO wasbook.
IF wasbook-passname = 'Johann Ryan'.
WRITE:/ wasbook.
ENDIF.
ENDLOOP.
ENDFORM.

" Subroutine to modify 5th record to steve


FORM modify_5th_to_steve.
LOOP AT itsbook INTO wasbook.
IF sy-index = 5.
wasbook-passname = 'STEVE'.
APPEND wasbook TO itsbook.
ENDIF.
ENDLOOP.
PERFORM display.
ENDFORM.

" Subroutine to deleting adam heller


" info: using johann ryan instead of adam heller, because adam heller not available
in sbook
FORM delete_Johann_Ryan.
LOOP AT itsbook INTO wasbook.
IF wasbook-passname = 'Johann Ryan'.
DELETE itsbook INDEX sy-tabix.
ENDIF.
ENDLOOP.
PERFORM display.
ENDFORM.

" Subroutine to delete 10th record


FORM delete_10th.
DELETE itsbook INDEX 10.
PERFORM display.
ENDFORM.

" Subroutine to display record from 12 to 16


FORM delete_12to16.
LOOP AT itsbook INTO wasbook.
IF sy-tabix GE 12 AND sy-tabix LE 16.
DELETE itsbook INDEX sy-tabix.
ENDIF.
ENDLOOP.
PERFORM display.
ENDFORM.

You might also like