0% found this document useful (0 votes)
18 views

Topic 06 - Exercise - NHATLM7

Uploaded by

nhatlmse171573
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Topic 06 - Exercise - NHATLM7

Uploaded by

nhatlmse171573
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
You are on page 1/ 19

System : S4J

Exercise 1: Modulize your program


Step 1 : Copy your Program of Exercise Topic 05 - Internal Tble
Bước 1: Copy chương trình của phần 5 - internal table ra program mới

Step 2 : Modularize your source code using Subroutine


Bước 2: Mô đun hoá chương trình mới bằng subroutine

Step 3 : Check the source code and make sure you follow below Coding covnentio
Bước 3: Kiểm tra code xem có giống convention bên dưới chưa, nếu chưa thì sửa lại

Step 4 : Take screenshot of every subroutine


Bước 4: Chụp lại hình từng xử lý đã mô đun hoá xong

Exercise 2: Recursion
1. Research what Recursion is in programming
https://afteracademy.com/blog/what-is-recursion-in-programming
*** For vietnamese material please check Google

2. Use Recursion to solve Fibonacci problem in Topic 2, instead of using LOOP

3. Recursion can make your program run forever. Please check careful that you can exit the Recu

4. Trường hợp vướn phải vòng lặp vô hạn hoặc xử lý không thể kết thúc, sử dụng tcode SM50 để tắt cưỡ

Exercise 3: Experience on USING and CHANGING


For this exercise, you should Read the help from command FORM completely.
Then, write an executable program that has a routine that receives 4 global variables and change their va
Each variable will be received in a different way: 2 of them using the addition USING and the other 2 usin
For each pair use and omit the adding VALUE.

Print the contents of all global variables before the routine is called, at the beginning of the routine, at the

Exercise 4: Mini Program - Users Report

Write an executable program that contains 2 routines that prints all usernames in the system. (Check tab
1. First Routine: Get data from USR04
2. Second Routine: Print all the data
below Coding covnention
l that you can exit the Recursion. And DEBUG in your first run

ử dụng tcode SM50 để tắt cưỡng bức (End Process) hoặc thông báo Senior trong nhóm

variables and change their value.


n USING and the other 2 using the addition CHANGING from the FORM command.

eginning of the routine, at the end of the routine (after all values are changed) and after the PERFORM statement.

mes in the system. (Check table USR04 and its content in transaction SE11, SE16 or SE16N).
ORM statement.
System : S4J

Exercise 1:
Target Table: SPFLI Flight schedule
SLFIGHT Flight Information
T005T Country Name
SCARR Airline

Selection Screen:

Report Output:
*** You can check the Technical design for program outline
*&---------------------------------------------------------------------*
*& DATA DECLARATION
*&---------------------------------------------------------------------*

1. Declare a structure TY_REPORT for final report


Field Name Type Desciption
COUNTRYFR SPFLI-COUNTRYFR,
CITYFROM SPFLI-CITYFROM,
COUNTRYTO SPFLI-COUNTRYTO,
CITYTO SPFLI-CITYTO,
FLDATE SFLIGHT-FLDATE,
CARRID SPFLI-CARRID,
CONNID SPFLI-CONNID,
DEPTIME SPFLI-DEPTIME,
ARRTIME SPFLI-ARRTIME,
PERIOD SPFLI-PERIOD,
SEATSMAX SFLIGHT-SEATSMAX, So ghe khoang Economy
SEATSMAX_B SFLIGHT-SEATSMAX_B, So ghe khoang Business
SEATSMAX_F SFLIGHT-SEATSMAX_F, So ghe khoang First Class
SEATSOCC SFLIGHT-SEATSOCC, So ghe Economy da dat
SEATSOCC_B SFLIGHT-SEATSOCC_B, So ghe Business da dat
SEATSOCC_F SFLIGHT-SEATSOCC_F, So ghe First Class da dat

2. Declare a structure TY_COUNTRY to store Country Name


Field Name Type Desciption
LAND1 T005T-LAND1 Country Code
LANDX T005T-LANDX Country Name

3. Create an internal table from TY_REPORT

4. Create a sorted table from structure TY_COUNTRY to store Country Name

5. Create a sorted table from Table Name SCARR to store Airliner Name

*&---------------------------------------------------------------------*
*& SELECTION SCREEN
*&---------------------------------------------------------------------*

*** Check Exercise sheet

*&---------------------------------------------------------------------*
*& START-OF-SELECTION
*&---------------------------------------------------------------------*

1. Select data from SFLIGHT inner join SPFLI

* Select data from SFLIGHT inner join SPFLI


**************************************************************************************
* Into: Standard Table of TY_REPORT
**************************************************************************************
* Join Condition: SFLIGHT~CARRID = SPFLI~CARRID and SFLIGHT~CONNID = SPFLI~CONNID
**************************************************************************************
* Query Condition: SFLIGHT~FLDATE IN S_FLDATE
* AND SPFLI~CARRID IN S_CARRID
* AND SPFLI~CONNID IN S_CONNID
* AND SPFLI~COUNTRYFR IN S_CTRFR
* AND SPFLI~CITYFROM IN S_CTYFR
* AND SPFLI~COUNTRYTO IN S_CTRTO
* AND SPFLI~CITYTO IN S_CTYTO
**************************************************************************************
* Order By: SPFLI~CITYFROM
* SPFLI~CITYTO
* SFLIGHT~FLDATE
* SPFLI~DEPTIME
* SPFLI~ARRTIME
**************************************************************************************
* SELECT fields: SFLIGHT~FLDATE " Flight Date
* SPFLI~CARRID " Airliner
* SPFLI~CONNID " Flight Number
* SPFLI~COUNTRYFR " From Country
* SPFLI~CITYFROM " From City
* SPFLI~COUNTRYTO " To Country
* SPFLI~CITYTO " To City
* SPFLI~DEPTIME " Departure Time
* SPFLI~ARRTIME " Arrival Time
* SPFLI~PERIOD " Flight Period in Days
* SFLIGHT~SEATSMAX, " Max seats in Economy
* SFLIGHT~SEATSMAX_B, " Max seats in Business Class
* SFLIGHT~SEATSMAX_F, " Max seats in First Class
* SFLIGHT~SEATSOCC, " Occupied seats in Economy
* SFLIGHT~SEATSOCC_B, " Occupied seats in Business Class
* SFLIGHT~SEATSOCC_F " Occupied seats in First Class
**************************************************************************************

2. Select data from Country Text Table T005T

* Select data from Country Text Table T005T


**************************************************************************************
* Into: Sorted Table of TY_COUNTRY
**************************************************************************************
* Join Condition: N/A
**************************************************************************************
* Query Condition: SPRAS (Language) = SY-LANGU (Logon Language)
**************************************************************************************
* Order By: N/A
**************************************************************************************
* SELECT fields: LAND1 " Country code
* LANDX " Country Name
**************************************************************************************

3. Select data from Airline Table SCARR

* Select data from Airline Table SCARR


**************************************************************************************
* Into: Sorted Table of SCARR
**************************************************************************************
* Join Condition: N/A
**************************************************************************************
* Query Condition: N/A
**************************************************************************************
* Order By: N/A
**************************************************************************************
* SELECT fields: *
**************************************************************************************

4. Loop at internal table of TY_REPORT to output report

4.1. At new block of FLDATE, CARRID, CONNID, COUNTRYFR, CITYFROM, COUNTRYTO, CITYTO

Read Sorted Table of TY_COUNTRY into a work area (Work Area: Country From)
using table key LAND1 = COUNTRYFR of current looping record

Read Sorted Table of TY_COUNTRY into a work area (Work Area: Country To)
using table key LAND1 = COUNTRYTO of current looping record

Output Country From and Country To


WRITE: /(20) 'Country From :', (20) GS_COUNTRYFR-LANDX, (20) ' - Country From :', (20) GS_COUNTRYTO

Output City From and City To


WRITE: /(20) 'City From :', (20) GS_REPORT-CITYFROM, (20) ' - City To :', (20) GS_REPORT-CITYTO.

Output column header for the list of flights


WRITE: /(12) 'Flight Date'
(12) 'Airline Cd'
(20) 'Airline Name'
(20) 'Flight Number'
(20) 'Depart Time'
(20) 'Arrival Time'
(15) 'Free Seats'

4.2. For every line of the loop

Read Sorted Table of SCARR into a work area


using table key CARRID = CARRID of current looping record
Calculate free seat: ( SEATSMAX - SEATSOCC ) + ( SEATSMAX_B - SEATSOCC_B ) + ( SEATSMAX_F - SEATS

Output list of flights


WRITE: /(12) FLDATE of current looping record
(12) CARRID of current looping record
(20) Field CARRNAME from work area of SCARR
(20) CONNID of current looping record
(20) DEPTIME of current looping record
(20) ARRTIME of current looping record
(15) Calculated free seats
*************
*************
NID = SPFLI~CONNID
*************

*************

*************

*************

*************

*************

*************

*************

*************
*************

*************

*************

*************

*************

*************

*************

, COUNTRYTO, CITYTO

From :', (20) GS_COUNTRYTO-LANDX.

) GS_REPORT-CITYTO.
_B ) + ( SEATSMAX_F - SEATSOCC_F )
Exercise/Remarks Screenshots

Exercise 1 Program Name: <your program name>

<screenshot>

Exercise 3 Program Name: <your program name>

<screenshot>

You might also like