0% found this document useful (0 votes)
27 views16 pages

Unit 4 - Modularization Function Module - DEV-203

The document outlines a series of exercises for creating executable programs and function modules in a specified programming environment. It includes instructions for handling file uploads, performing date calculations, and converting amounts to text, with specific coding rules and parameter requirements. Each exercise emphasizes the use of subroutines and function groups, along with testing the developed modules.
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)
27 views16 pages

Unit 4 - Modularization Function Module - DEV-203

The document outlines a series of exercises for creating executable programs and function modules in a specified programming environment. It includes instructions for handling file uploads, performing date calculations, and converting amounts to text, with specific coding rules and parameter requirements. Each exercise emphasizes the use of subroutines and function groups, along with testing the developed modules.
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/ 16

System : S4J

Exercise 1:
Check the program design on next sheet and create an executable program
YXXX_MOD_FM_EX01 XXX is your ID number

*** Please follow the coding rule below


*** All process must be put in Subroutine

*** Hint: Search help for File Path should look like below.
Gợi ý: cách tạo search help cho cái File Path
Test File: <any file>.txt or .csv

AA,0017,US,NEW YORK,JFK,US,SAN FRANCISCO,SFO, 361,110000,140100, 2572,MI,,


AA,0026,DE,FRANKFURT,FRA,US,NEW YORK,JFK, 440,083000,095000, 3851,MI,,
AA,0064,US,SAN FRANCISCO,SFO,US,NEW YORK,JFK, 321,090000,172100, 2572,MI,,
AZ,0555,IT,ROME,FCO,DE,FRANKFURT,FRA, 125,190000,210500, 845,MI,,
AZ,0788,IT,ROME,FCO,JP,TOKYO,TYO, 775,120000,085500, 6130,MI,, 1
AZ,0789,JP,TOKYO,TYO,IT,ROME,FCO, 940,114500,192500, 6130,MI,, 0
AZ,0790,IT,ROME,FCO,JP,OSAKA,KIX, 815,103500,081000, 6030,MI,X, 1
AZ,0791,JP,OSAKA,KIX,IT,ROME,FCO, 975,111500,193000, 6030,MI,X, 0
DL,0106,US,NEW YORK,JFK,DE,FRANKFURT,FRA, 475,193500,093000, 3851,MI,,
DL,1699,US,NEW YORK,JFK,US,SAN FRANCISCO,SFO, 382,171500,203700, 2572,MI,,
DL,1984,US,SAN FRANCISCO,SFO,US,NEW YORK,JFK, 325,100000,182500, 2572,MI,,
JL,0407,JP,TOKYO,NRT,DE,FRANKFURT,FRA, 725,133000,173500, 9100,KM,,
JL,0408,DE,FRANKFURT,FRA,JP,TOKYO,NRT, 675,202500,154000, 9100,KM,X,
LH,0400,DE,FRANKFURT,FRA,US,NEW YORK,JFK, 444,101000,113400, 6162,KM,,
LH,0401,US,NEW YORK,JFK,DE,FRANKFURT,FRA, 435,183000,074500, 6162,KM,,
LH,0402,DE,FRANKFURT,FRA,US,NEW YORK,JFK, 455,133000,150500, 6162,KM,X,
LH,0454,DE,FRANKFURT,FRA,US,SAN FRANCISCO,SFO, 680,101000,123000, 9150,KM
LH,045A,US,SAN FRANCISCO,SFO,DE,FRANKFURT,FRA, 630,150000,103000, 9150,KM
LH,2402,DE,FRANKFURT,FRA,DE,BERLIN,SXF, 65,103000,113500, 555,KM,,
LH,2407,DE,BERLIN,TXL,DE,FRANKFURT,FRA, 65,071000,081500, 555,KM,,
LH,2415,DE,BERLIN,SXF,DE,FRANKFURT,FRA, 65,092500,103000, 555,KM,,
LH,2436,DE,FRANKFURT,FRA,DE,BERLIN,THF, 65,173000,183500, 555,KM,,
LH,2462,DE,FRANKFURT,FRA,DE,BERLIN,TXL2, 65,063000,073500, 555,KM,,
LH,2463,DE,BERLIN,SXF,DE,FRANKFURT,FRA, 65,212500,223000, 555,KM,,
LH,3577,IT,ROME,FCO,DE,FRANKFURT,FRA, 120,070500,090500, 1351,KM,X,
QF,0005,SG,SINGAPORE,SIN,DE,FRANKFURT,FRA, 825,225000,053500,10000,KM,,
QF,0006,DE,FRANKFURT,FRA,SG,SINGAPORE,SIN, 670,205500,150500,10000,KM,,
SQ,0002,SG,SINGAPORE,SIN,US,SAN FRANCISCO,SFO, 1105,170000,192500, 8452,MI,,
SQ,0015,US,SAN FRANCISCO,SFO,SG,SINGAPORE,SIN, 1125,160000,024500, 8452,MI,,
SQ,0066,SG,SINGAPORE,SIN,TH,BANGKOK,BKK, 140,160000,172000, 937,MI,,
SQ,0067,TH,BANGKOK,BKK,SG,SINGAPORE,SIN, 145,183000,215500, 937,MI,,
SQ,0114,SG,SINGAPORE,SIN,MY,KUALA LUMPUR,KUL, 70,091500,102500, 250,MI,,
SQ,0117,MY,KUALA LUMPUR,KUL,SG,SINGAPORE,SIN, 70,120000,131000, 250,MI,,
SQ,0158,SG,SINGAPORE,SIN,ID,JAKARTA,JKT, 95,152500,160000, 560,MI,,
SQ,0161,ID,JAKARTA,JKT,SG,SINGAPORE,SIN, 95,184000,211500, 560,MI,,
SQ,0325,DE,FRANKFURT,FRA,SG,SINGAPORE,SIN, 685,204500,151000,10000,KM,,
SQ,0326,SG,SINGAPORE,SIN,DE,FRANKFURT,FRA, 840,235500,065500,10000,KM,,
SQ,0863,HK,HONGKONG,HKG,SG,SINGAPORE,SIN, 270,162000,205000, 1625,MI,X,
SQ,0866,SG,SINGAPORE,SIN,HK,HONGKONG,HKG, 270,071000,114000, 1625,MI,,
SQ,0988,SG,SINGAPORE,SIN,JP,TOKYO,TYO, 400,163500,001500, 3125,MI,,
SQ,0997,JP,TOKYO,TYO,SG,SINGAPORE,SIN, 299,180000,215900, 3125,MI,,
UA,0007,US,NEW YORK,JFK,US,SAN FRANCISCO,SFO, 370,144500,175500, 2572,MI,,
UA,0941,DE,FRANKFURT,FRA,US,SAN FRANCISCO,SFO, 696,143000,170600, 5685,MI,
UA,3504,US,SAN FRANCISCO,SFO,DE,FRANKFURT,FRA, 630,150000,103000, 5685,MI,
UA,3516,US,NEW YORK,JFK,DE,FRANKFURT,FRA, 445,162000,054500, 6162,KM,,
UA,3517,DE,FRANKFURT,FRA,US,NEW YORK,JFK, 495,104000,125500, 6162,KM,,

Exercise 2:
1. Create a Function Group
Function Group name: YXXX_FGRP_EX02

2. Create a Function Module in FGroup created above


Function Module Name: Y_XXX_DAYS_ADD
Parameter:
IMPORTING
I_DATE
I_NUMBER_OF_DAYS
EXPORTING
E_DATE

** Please use standard data element or create your data element to use as parameters' data t

3. Write logic to calulate E_DATE by adding I_NUMBER_OF_DAYS to I_DATE

4. Test the function module

Exercise 3:
1. Create a Function Module in FGroup created in Ex2
Function Module Name: Y_XXX_CALCULATE_DATE
Parameter:
IMPORTING
I_DATE
I_NUMBER_OF_DAYS
I_NUMBER_OF_MONTHS
I_NUMBER_OF_YEARS
EXPORTING
E_DATE
EXCEPTION
NOTHING_TO_CALCULATE

** Please use standard data element or create your data element to use as parameters' data t

2. Write logic to calulate E_DATE by adding days, months, years to I_DATE

3. If all parameters of days months years are initial, RAISE exception NOTHING_TO_CALCULATE
4. Test the function module

Exercise 4:
1. Create a Function Module in FGroup created in Ex2
Function Module Name: Y_XXX_CONVERT_AMOUNT2TEXT
Parameter:
IMPORTING
IV_AMOUNT
EXPORTING
EV_STRING
EXCEPTION
NO_GREATER_THAN_1B

** Please create your data element to use as parameters' data type

2. Write logic to convert Amount to Vietnamese Text, given that the number is less than 1 billion

3. If RAISE exception NO_GREATER_THAN_1B, when IV_AMOUNT >= 1,000,000,000

4. Test the function module


cutable program
1,110000,140100, 2572,MI,, 0
3000,095000, 3851,MI,, 0
1,090000,172100, 2572,MI,, 0
10500, 845,MI,, 0
, 6130,MI,, 1
, 6130,MI,, 0
6030,MI,X, 1
6030,MI,X, 0
500,093000, 3851,MI,, 1
2,171500,203700, 2572,MI,, 0
5,100000,182500, 2572,MI,, 0
173500, 9100,KM,, 0
154000, 9100,KM,X, 1
000,113400, 6162,KM,, 0
000,074500, 6162,KM,, 1
000,150500, 6162,KM,X, 0
80,101000,123000, 9150,KM,, 0
630,150000,103000, 9150,KM,, 1
113500, 555,KM,, 0
081500, 555,KM,, 0
103000, 555,KM,, 0
183500, 555,KM,, 0
0,073500, 555,KM,, 0
223000, 555,KM,, 0
90500, 1351,KM,X, 0
5000,053500,10000,KM,, 1
5500,150500,10000,KM,, 1
05,170000,192500, 8452,MI,, 0
25,160000,024500, 8452,MI,, 2
00,172000, 937,MI,, 0
00,215500, 937,MI,, 0
0,091500,102500, 250,MI,, 0
0,120000,131000, 250,MI,, 0
,160000, 560,MI,, 0
,211500, 560,MI,, 0
04500,151000,10000,KM,, 1
35500,065500,10000,KM,, 1
62000,205000, 1625,MI,X, 0
71000,114000, 1625,MI,, 0
001500, 3125,MI,, 1
215900, 3125,MI,, 0
0,144500,175500, 2572,MI,, 0
696,143000,170600, 5685,MI,, 0
630,150000,103000, 5685,MI,, 1
2000,054500, 6162,KM,, 1
4000,125500, 6162,KM,, 0

to use as parameters' data type

(Optional)
(Optional)
(Optional)

to use as parameters' data type

NOTHING_TO_CALCULATE
mber is less than 1 billion

1,000,000,000
1. Create structure raw data and declare internal table GT_RAWDATA
* TYPES: BEGIN OF TY_RAWDATA,
* DATA TYPE STRING,
* END OF TY_RAWDATA.

2. Selection Screen

* Screen field: File path (P_LPATH) with type FILE_TABLE-FILENAME

3. Search help for file path field: Customer can choose the file using popup
**- Use event: AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_LPATH.
3-1. Call Function Module 'TMP_GUI_FILE_OPEN_DIALOG'
EXPORTING
WINDOW_TITLE = 'Open CDS List'
FILE_FILTER = 'Text files or CSV files (*.txt;*.csv)|*.txt;*.csv'
TABLES
FILE_TABLE = GT_FILE_TABLE " Internal table store file paths (ta
EXCEPTIONS
CNTL_ERROR = 1
OTHERS = 2

If FM return error
Output ERROR message 'Cannot open file dialog. Return code: ' && SY-SUBR
else
read the first line of GT_FILE_TABLE in some work area
P_LPATH = field FILENAME of above work area

4. Main process

4-1. Upload the file from local pc using inputted file path
* Call Function Module 'GUI_UPLOAD'
EXPORTING
FILENAME = GD_FILENAME " Variable store file path
FILETYPE = 'ASC'
TABLES
DATA_TAB = GT_RAWDATA " Internal table of raw data
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSF= 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED= 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17

* If Function Module return error


* Output ERROR message 'Cannot upload file. Return code:' && SY-SUBRC

4-2. Output demo data


*
* CL_DEMO_OUTPUT=>DISPLAY( GT_RAWDATA ).
.csv)|*.txt;*.csv'

ore file paths (table of type FILE_TABLE)

code: ' && SY-SUBRC

ile path

w data
' && SY-SUBRC
Exercise/Remarks Screenshots

Exercise 1 Program Name: Y203_U4_UP_FILE

<screenshot>

<screenshot>
Exercise 2 Program Name: Y203_FGRP_EX02 (Function Group),
Program Name: Y_203_DAYS_ADD (Function Module),
Exercise 2 Program Name: Y203_FGRP_EX02 (Function Group),
Program Name: Y_203_CALCULATE_DATE
Exercise 2 Program Name: Y203_FGRP_EX02 (Function Group),
Program Name: Y_203_CONVERT_AMOUNT2TEXT

You might also like