ABAP Tutorial (Verdy)
ABAP Tutorial (Verdy)
(Revision 7)
Created by :
Albertus Reinandang
Revision by:
Contributor
Technical Functional
Mawan Sugiyanto Dyan Pravita Sari
Alfarisi
Kenindi Setawijaya
Muhammad Fajrin
Kristian Fredy
i
BAB 1
ABAP-BASIC KNOWLEDGE
a. ABAP-Editor
i. Create New Program
1
7. Package is filled to make program able to transport to the other client, but if it's for
practice, you dont need to fill it.
8. Press Button if you want program able to transport to the other client. Press
Button for practice only.
2. Fill program name want to change. if you forget it, type keyword of it, for example
"Y*". Then Press button or press F4 to open program's search menu.
3. Double Click to choose program or put kursor over list, and then klik
4. Click button
2
iii. ABAP Debugger
Menu Path SAP Menu > Tools > ABAP Workbench >
Development > ABAP Editor
Transaction code SE38 > Debugging
ABAP Debugger is one of SAP fitur which most used by ABAP'er to analize
program/report made in SAP.
3
These are bassic example to debug program.
5. Press enter
6. Press button " "
7. It will be enter ABAP Debugger menu like picture below :
4
10. Double Click at " " and will be appear "Internal Table" menu
5
14. Now, double click on " APPEND gi_itab." so it will be appear Break Point like
picture below.
15. Then Click " " once again, then cursor will jump into icon" " inside repetition
block coding.
16. Now, Double Click at " APPEND gi_itab." or icon " " to remove Break Point
17. Then Click " " to exit from ABAP Debugger
18. Finish
In ABAP Programing, there are two type of naming convention, naming initiate by
letter "Y" and "Z".
1. Y Convention
ABAP Dictionary.
YTA_ = prefix
Example: YTA_FAKPJK
6
Structures Structure name: YST_XXXXXXXX
YST_ = prefix
Example: YST_DOLIST
Data Element Data Element name: YXXXXXX
Y = prefix
Example: YMATNR
Domain Domain name: YD_XXXXXX
YD_ = prefix
Example: YD_MATNR
Search Help Search Help name: YSH_XXXXXX
YSH_ = prefix
Example:YSH_ITEM
View Table View name: YTV_XXXXXX
YTV_ = prefix
Example:YTV_CUSTOMER
Example:
· GI_VBRK
GI_FAKPJK
7
2. Local Internal Table: LI_XXXXX
LI_ = Prefix
XXXXX = self defined name
Example:
· LI_VBRK
· LI_FAKPJK
Working Area 1. Global Working Area: GW_XXXXXX
GW_ = Prefix
XXXXXX = self defined name
Example:
· GW_LIKP
· GW_XTEXT
Example:
LW_LIPS
LW_POORDER
All programs, after prefix and before self defined name, are inserted with a
module code XX999. Meaning:
For FI =FI001-FI999
For CO =CO001-CO999
For MM = MW001-MW999
For WM = WM001-WM999
For PP = PP001-PP999
For QM = QM001-QM999
For SD = SD001-SD999
For HR = HR001-HR999
8
Example:
· YDR_SD001_FAKPJKSEDERHANA
· YDR_FI002_GIRO
· YDR_MM012_PO
YRE_ = prefix
Example:
· YRE_SD001_INVOICELIST
· YRE_FI004_TAXLIST
YIF_ = prefix
Example:
· YIF_PP001_UPLOAD_BOM
· YIF_SD007_SALES_ORDER
Example:
· YIN_SD001_INVOICELIST_TOP
· YIN_FI004_TAXLIST_TOP
9
Subroutines includes:
2. YIN_XX999_XXXXXXXX_FXX
YIN_ = prefix
XX999_ = module code
XXXXXXXXX = self defined name
FXX = Sequence number (F01, F02, F03,
…, F99)
Example:
· YIN_SD001_INVOICELIST_F01
YIN_FI004_TAXLIST_F02
·
Process Before Output includes:
3. YIN_XX999_XXXXXXXX_PBO
YIN_ = prefix
XX999_ = module code
XXXXXXXXX = self defined name
PBO = suffix process before output
Example:
· YIN_SD001_INVOICELIST_PBO
YIN_FI004_TAXLIST_PBO
·
Process After Input includes:
4. YIN_XX999_XXXXXXXX_PAI
YIN_ = prefix
XX999_ = module code
XXXXXXXX = self defined name
PAI = suffix process after input
Example:
· YIN_SD001_INVOICELIST_PAI
· YIN_FI004_TAXLIST_PAI
Function Builder
YFG_ = prefix
Example:
· YFG_BCS
YFG_UTILITIES
10
Function Module Structure name: YFM_XXXXXXXX
YFM_ = prefix
Example:
· YFM_CHANGE_DATE_FORMAT
Selection Screen
SO_ = prefix
Example:
SO_VBELN
PA_ = prefix
Example:
PA_VBELN
YFO_ = prefix
Example:
YFO_DELIVERY
YFO_INVOICE
11
Smartstyles Name: YFO_XXXXXXXX_STYLE
YFO_ = prefix
_STYLE = suffix
Example:
YFO_DELIVERY_STYLE
YFO_INVOICE_STYLE
Subroutines
FM_ = prefix
Input Parameters:
Tables:
o FT_XXXXX
o FT_ = prefix
o XXXXX = self defined name
Using:
o FU_XXXXX or FV_XXXXX
o FU_ = prefix
o XXXXX = self defined name
Changing:
o FC_XXXXX or FV_XXXXX
o FC_ = prefix
o XXXXX = self defined name
Example:
Form FM_COLLECT_DATA
tables FT_VBRK
Using FU_VBELN
Changing FC_LFIMG
…………………
12
Modules Free definition
Example:
Various Variable
Example:
· GV_KUNNR
GV_DATE
·
2. Local Variables: LV_XXXXX
LV_ = Prefix
XXXXX = self defined name
Example:
LV_MATNR
LV_MATERIAL
Example:
· GR_KUNNR
GR_DATE
·
2. Local Ranges: LR_XXXXX
LR_ = Prefix
XXXXXX = self defined name
Example:
LR_MATNR
LR_MATERIAL
2. Z Convention
ABAP Dictionary.
13
ZTA_ = prefix
Example:
ZTA_FAKPJK
Structures Structure name: ZST_XXXXXXXX
ZST_ = prefix
Example:
ZST_DOLIST
Data Element Data Element name: ZXXXXXX
Z = prefix
Example:
ZMATNR
Domain Domain name: ZD_XXXXXX
ZD_ = prefix
Example:
ZD_MATNR
Search Help Search Help name: ZSH_XXXXXX
ZSH_ = prefix
Example:
ZSH_ITEM
View Table View name: ZTV_XXXXXX
ZTV_ = prefix
14
XXXXXX = self defined name
Example:
ZTV_CUSTOMER
Example:
· GI_VBRK
GI_FAKPJK
·
2. Local Internal Table: LI_XXXXX
LI_ = Prefix
XXXXX = self defined name
Example:
· LI_VBRK
· LI_FAKPJK
Working Area 1. Global Working Area: GW_XXXXXX
GW_ = Prefix
XXXXXX = self defined name
Example:
· GW_LIKP
· GW_XTEXT
Example:
LW_LIPS
LW_POORDER
All programs, after prefix and before self defined name, are inserted with a
module code XX999. Meaning:
For FI =FI001-FI999
For CO =CO001-CO999
15
For MM = MW001-MW999
For WM = WM001-WM999
For PP = PP001-PP999
For QM = QM001-QM999
For SD = SD001-SD999
For HR = HR001-HR999
Example:
· ZDR_SD001_FAKPJKSEDERHANA
· ZDR_FI002_GIRO
· ZDR_MM012_PO
ZRE_ = prefix
Example:
· ZRE_SD001_INVOICELIST
· ZRE_FI004_TAXLIST
Interface Program name: ZIF_XX999_XXXXXXXXX
ZIF_ = prefix
Example:
16
· ZIF_PP001_UPLOAD_BOM
· ZIF_SD007_SALES_ORDER
Includes Data Declaration includes:
1. ZIN_XX999_XXXXXXXX_TOP
ZIN_ = prefix
XX999_ = module code
XXXXXXX = self defined name
TOP = suffix
Example:
· ZIN_SD001_INVOICELIST_TOP
ZIN_FI004_TAXLIST_TOP
·
Subroutines includes:
2. ZIN_XX999_XXXXXXXX_FXX
ZIN_ = prefix
XX999_ = module code
XXXXXXXXX = self defined name
FXX = Sequence number (F01, F02, F03,
…, F99)
Example:
· ZIN_SD001_INVOICELIST_F01
ZIN_FI004_TAXLIST_F02
·
Process Before Output includes:
3. ZIN_XX999_XXXXXXXX_PBO
ZIN_ = prefix
XX999_ = module code
XXXXXXXXX = self defined name
PBO = suffix process before output
Example:
· ZIN_SD001_INVOICELIST_PBO
· ZIN_FI004_TAXLIST_PBO
Example:
· ZIN_SD001_INVOICELIST_PAI
· ZIN_FI004_TAXLIST_PAI
17
Function Builder
ZFG_ = prefix
Example:
· ZFG_BCS
· ZFG_UTILITIES
Function Module Structure name: ZFM_XXXXXXXX
ZFM_ = prefix
Example:
· ZFM_CHANGE_DATE_FORMAT
Selection Screen
SO_ = prefix
Example:
SO_VBELN
Parameters Name: PA_XXXXX
PA_ = prefix
Example:
PA_VBELN
18
ZFO_ = prefix
Example:
ZFO_DELIVERY
ZFO_INVOICE
Smartstyles Name: ZFO_XXXXXXXX_STYLE
ZFO_ = prefix
_STYLE = suffix
Example:
ZFO_DELIVERY_STYLE
ZFO_INVOICE_STYLE
Subroutines
FM_ = prefix
Input Parameters:
Tables:
o FT_XXXXX
o FT_ = prefix
o XXXXX = self defined name
Using:
o FU_XXXXX or FV_XXXXX
o FU_ = prefix
o XXXXX = self defined name
Changing:
o FC_XXXXX or FV_XXXXX
o FC_ = prefix
o XXXXX = self defined name
Example:
Form FM_COLLECT_DATA
tables FT_VBRK
19
Using FU_VBELN
Changing FC_LFIMG
…………………
Example:
Various Variable
Example:
· GV_KUNNR
· GV_DATE
Example:
LV_MATNR
LV_MATERIAL
Ranges 1. Global Ranges: GR_XXXXX
GR_ = Prefix
XXXXX = self defined name
Example:
· GR_KUNNR
· GR_DATE
Example:
LR_MATNR
LR_MATERIAL
20
c. ABAP Data Types
START-OF-SELECTION.
a = 10.
b = 100.
c = a / b.
WRITE : / 'Hitung : ', a, '/', b, '=', c.
21
>> Display :
Elementary Types
Elementary Types are simple data type which refer to another declarated type,
not to Built-in Elementary. Elementary Types are sorted into two :
2. Global ==> declarated data type inside Include Program or inside ABAP
Dictionay ( Domain, Data Element, etc).
Example of Domain :
22
Example :
START-OF-SELECTION.
A = 10.
B = 100.
C = A / B.
D = C.
WRITE : / 'Hitung : ', A, '/', B, '=', D.
>> Display :
Complex Types
Complex types are data type which consist of many data types.
Example :
Structures
*Second Style
data: begin of l_wa2,
a type i,
b type i,
hasil type p decimals 2,
23
end of l_wa2. " Sturcture (Workarea)
START-OF-SELECTION.
l_wa1-a = p_a.
l_wa1-b = p_b.
>> Display :
Selection Screen:
Display:
Table
*-----------------------------*
24
START-OF-SELECTION.
* Insert data to itab
CLEAR lv_counter.
DO p_n TIMES.
lv_counter = lv_counter + 1.
>> Display :
Selection Screen
Display:
25
ABAP Keywords
ABAP is more excellent than other language programs because it have more
than 700 keyword syntax to make program or customizing.
Keywords Description
, [, ], {, } Syntax conventions, Syntax notation
*, " Comments
** Arithm. Operator: Exponentiation (COMPUTE)
+, -, *, / Arithmetical operators (COMPUTE)
->, =>, ->>, ~, ?= Operators in ABAP Objects
ABS Mathematical function: Absolute amount
COMPUTE)
ACOS Mathematical function: Cosine arc (COMPUTE)
ADD Add
ADD- Field string addition
CORRESPONDING
ADJACENT Delete duplicates from internal table (DELETE)
DUPLICATES
AND Comparison operator: and
ANY TABLE Generic table type for internal tables
APPEND Append line to internaltable
ASIN Mathematical function: Sine arc (COMPUTE)
ASSIGN Assign field symbol
AT Event, control break, field group determination
ATAN Mathematical function: Tangent arc
AUTHORITY-CHECK Check authorization
AVG Aggregate expression: Average (SELECT)
BACK Positioning in list
BETWEEN Relational operator: Between
BINARY SEARCH Binary read of internaltable (READ TABLE)
BIT-NOT Bit calculation operator: NOT (COMPUTE)
BIT-AND Bit calculation operator: AND (COMPUTE)
BIT-OR Bit calculation operator: OR (COMPUTE)
BIT-XOR Bit calculation operator: AND/OR (COMPUTE)
SET BIT Set bit of an X field
GET BIT Read bit of an X field
BLANK LINES Switch on blank lines in list
BREAK-POINT Stop processing in debug mode
C Data type for fixed-length character string
CA Contains any characters -Relational operator
forstring comparison
CALL Call external component
CASE Begin case distinction
CATCH Exception handling (catch runtime errors)
CEIL Mathematical function: Smallest whole value
CENTERED Output format: Centered(WRITE)
CHECK Check condition
26
CHECKBOX Display as checkbox
PARAMETERS ... AS on the selection screen
CHECKBOX
WRITE ... AS in a list
CHECKBOX
CLASS Definition of a class
CLASS-DATA Static attributes in classes
CLASS-METHODS Static methods in classes
CLASS-EVENTS Static events in classes
CLASS-POOL Introduction for type Kprograms
CLEAR Initialize data object
CLIENT Client handling when
DELETE ... CLIENT deleting from a database
SPECIFIED
EXPORT ... TO Storing a data cluster
DATABASE ... CLIENT
IMPORT ... FROM Reading a data cluster
DATABASE ... CLIENT
EXPORT ... TO Storing a data cluster
SHARED BUFFER ...
CLIENT
IMPORT ... FROM Reading a data cluster
SHARED BUFFER ...
CLIENT
INSERT ... CLIENT inserting into a database
SPECIFIED
MODIFY ... CLIENT Insert/Modify in database(s)
SPECIFIED
SELECT ... CLIENT reading from a database
SPECIFIED
UPDATE ... CLIENT updating a database
SPECIFIED
CLOSE Close file/cursor
CN Contains Not Only - Relational operator for
character comparison:
CNT Field groups: Number ofdifferent values
CO Contains Only - Relational operator for character
comparison:
CODE PAGE Character set
TRANSLATE ... Translate character codes
FROM/TOCODE PAGE
COLLECT Internal table: Add entries
COLOR Output format: Color (FORMAT)
COMMENT Comment on selection screen
SELECTION-SCREEN Generate comment
COMMENT
COMMIT Close processing unit
COMMUNICATION Data exchange
27
COMPUTE Perform calculations
CONCATENATE Concatenate character fields
CONDENSE Condense character fields
CONSTANTS Defing constants
CONTEXTS Communicate contexts
CONTINUE Exit current loop pass
CONTROLS Define controls for visualization
CONVERT Convert fields
COS Mathematical function: Cosine (COMPUTE)
COSH Mathematical function: Hyperbola cosine
(COMPUTE)
COUNT Aggregate expression: Count (SELECT)
COUNTRY Set country ID (SET)
CP Relational operator forcharacter comparison:
DATABASE Contains Pattern
CREATE Generate an object or data object
CS Contains character - Relational operator
forcharacter comparison
CURRENCY Output format: Correct format for currency
(WRITE)
CURSOR Cursor
CLOSE Close database cursor
FETCH NEXT CURSOR Read lines with a database cursor
GET CURSOR FIELD Get field name
OPEN CURSOR Open database cursor
SET CURSOR Position cursor
CUSTOMER- Call customer enhancement
FUNCTION
DATA Define data
DATABASE Data cluster
DELETE FROM Delete from a database table
DATABASE
EXPORT ... TO Store in a databasetable
DATABASE
IMPORT ... FROM Read from a database table
DATABASE
DATASET Sequential file
CLOSE DATASET Close file
DELETE DATASET Delete file
EXPORT ... TO Store data cluster in file
DATASET
IMPORT ... FROM Read data cluster from file
DATASET
OPEN Open file
DATASET Open file
READ DATASET Read from a file
TRANSFER Output to a file
DECIMALS Output format: Places after the decimal point -
28
(WRITE)
DEFINE Define macro
DELETE Delete from tables or from objects
DEMAND Request information from a context
DESCRIBE Determine attributes ofdata objects
DIALOG Call a dialog module (CALL)
DISTINCT Duplicates
SELECT DISTINCT Selection set without duplicates
AVG( DISTINCT ... ) Average without duplicates (SELECT)
COUNT( DISTINCT ... Sequential file
)
MAX( DISTINCT ... ) Maximum without duplicates (SELECT)
MIN( DISTINCT ... ) Minimum without duplicates (SELECT)
SUM( DISTINCT ... ) Sum without duplicates (SELECT)
DIV Arithmetic operator: Whole number division
DIVIDE Divide
DIVIDE- Field string division
CORRESPONDING
Field string division
DO Loop
DYNPRO Screen Screen
DELETE Delete
DYNPRO Delete
EXPORT Export
DYNPRO Export
GENERATE Generate
DYNPRO Generate
IMPORT Import
DYNPRO Import
SYNTAX-CHECK FOR Check
DYNPRO Check
EDITOR-CALL Call editor
ELSE Query
ELSEIF Query
END-OF-DEFINITION End of a macro definition
END-OF-PAGE Event: End of page handling in lists
END-OF-SELECTION Event: After processingof all records in a LDB
ENDAT End of an event introduced by AT
ENDCASE End of case distinction
ENDCATCH End of exception handling
ENDDO End of a DO loop
ENDEXEC End of a Native SQL statement
ENDFORM End of a subroutine
ENDFUNCTION End of a function module
ENDIF End of a query
ENDINTERFACE End of an interface definition
ENDLOOP End of a LOOP
ENDMODULE End of a module definition
29
ENDON End of a conditional statement
ENDPROVIDE End of a PROVIDE loop
ENDSELECT End of a SELECT loop
ENDWHILE End of a WHILE loop
EQ Relational operator: Equals
EXEC SQL Native SQL statement
EXIT Exit loop or terminate processing
EXP Mathematical function: Exponential function
EXPONENT Output format: Exponentdisplay (WRITE)
EXPORT Export data
EXTENDED CHECK Switch extended syntax check on/off (SET)
EXTRACT Generate extract dataset
FETCH Read line from a database table
FIELD-GROUPS Define field groups
FIELD-SYMBOLS Define field symbols
FLOOR Mathematical function:Largest whole value
FORM Define subroutine
FORMAT Output format for lists
FOR UPDATE Read database table with lock (SELECT)
FRAC Mathematical function: Fraction (COMPUTE)
FREE Release resources no longer needed
FUNCTION Define function module
CALL FUNCTION Call function module
FUNCTION-POOL Introduction for type Fprograms
GE Relational operator: Greater than or equal
GENERATE Generate a program or screen
GET Event, read settings
GT Relational operator: Greater than
HASHED TABLE Table type for internalhashed tables
HEADER LINE Define an internal table with header line (DATA)
HELP-ID Help ID for F1 help
DESCRIBE FIELD ... Determine help ID
HELP-ID
HELP-REQUEST Self-programmed help (F1)
PARAMETERS ... for parameters
HELP-REQUEST
SELECT-OPTIONS ... for selection options
HELP-REQUEST
HIDE Store line information
HOTSPOT Output format: Hotspot,interaction by simple -
mouse click (FORMAT)
ICON Icons in lists
IF Query
IMPORT Import data or a screen
IN Relational operator: Selection criterion
INCLUDE Include program components
INDEX Line index in an internal table
30
INDEX TABLE
DELETE ... INDEX Delete line
INSERT ... INDEX Insert line
MODIFY ... INDEX Modify line
READ TABLE ... INDEX Read line
INFOTYPES Declare HR info type
INITIAL Relational operator: Initial value
INITIAL SIZE Define an internal table type (TYPES)
INITIALIZATION Event: Before display of the selection screen
INPUT Output format: Ready for input (FORMAT)
INSERT Insert into tables or objects
INTENSIFIED Output format: Intensified (FORMAT)
INTERFACE Definition of an interface
INTERFACES Class component interface
INTERFACE-POOL Introduction fortype J programs
INVERSE Output format: Inverse (FORMAT)
IS Relational operator
IS ASSIGNED Relational operator: Is the field symbol assigned?
IS INITIAL Relational operator: Initial value
IS REQUESTED Relational operator: Existence of a formal
parameter
JOIN Join (SELECT)
LANGUAGE Set language for text elements (SET)
LE Relational operator: Less than or equal
LEAVE Leave processing
LEFT-JUSTIFIED Output format: Left-justified (WRITE)
LIKE Use an existing field as areference
TYPES ... LIKE Create a type
DATA ... LIKE Create a field
LINE Line in a list
MODIFY LINE Modify line
READ LINE Read line
LINE-COUNT Number of lines per page (NEW-PAGE)
LINE-SIZE Line size (NEW-PAGE)
LIST-PROCESSING List processing (LEAVE)
LOAD Load program componentsin internal table
LOAD-OF- Execution at load time
PROGRAM
LOCAL Rescue actual parameters of a subroutine
LOCAL COPY Assign local copy to a field symbol
LOCALE Set text environment (SET)
SET LOCALE Set text environment
GET LOCALE Determine text environment
LOG Mathematical function: Natural logarithm
(COMPUTE)
Logical condition
SELECT ... WHERE when reading database tables
31
UPDATE ... WHERE when changing database tables
DELETE ... WHERE when deleting fromdatabase tables
SELECT ... FROM ... when reading usinga join
ON
LOG10 Mathematical function: Base 10 logarithm
(COMPUTE)
LOOP Loop
LT Relational operator: Less than
M Relational operator: Byte contains zeros and ones
MARGIN List output: Distance from edge (SET)
MATCHCODE Matchcode handling
PARAMETERS ... for parameters
MATCHCODE
SELECT-OPTIONS ... for selection options
MATCHCODE
MAX Aggregate expression: Maximum (SELECT)
MEMORY ABAP/4 memory
EXPORT ... TO Roll out data to memory
MEMORY
IMPORT ... FROM Restore data from memory
MEMORY
MESSAGE Output message
MESSAGE-ID Specify message class (REPORT)
METHOD Definition of a method
METHODS Class component method
MIN Aggregate expression: Minimum (SELECT)
MOD Arithmetic operator: Remainder after division
(COMPUTE)
MODIFY Modify tables or objects
MODULE Flow logic: Module
MOVE Assignment
MOVE- Component-by-component assignment
CORRESPONDING
MULTIPLY Multiply
MULTIPLY- Field string multiplication
CORRESPONDING
NA Relational operator forcharacter comparison:
Contains not any characters
NE Relational operator: Not equal
NEW-LINE List processing: New line
NEW-PAGE List processing: New page
NODES Interface work area forlogical databases
NO-GAP Output format: Leave nogaps (WRITE)
NO-HEADING Display no column headers (NEW-PAGE)
NO-SCROLLING Do not scroll line (NEW-LINE)
NO-SIGN Output format: No preceding signs (WRITE)
NO-TITLE Do not display standardpage header (NEW-PAGE)
NO-ZERO Output format: No leading zeros (WRITE)
32
NON-UNIQUE Defines an
TYPES internal table type
DATA internal table object
NP Relational operator forcharacter comparison:
Does not contain pattern
NS Relational operator forcharacter comparison:
Does not contain character
O Relational operator: Byte positions occupied by1
OBJECT External object
CREATE OBJECT Generate
FREE OBJECT Release
OCCURS Defines an
TYPES internal table type
DATA internal table object
ON CHANGE Control break
OPEN Open file/cursor
OR Relational operator: OR
ORDER BY Sort table rows (SELECT)
OVERLAY Overlay character fields
PACK Conversion
PARAMETER Parameter in global SAP memory
GET Read parameter
SET Set parameter
PARAMETERS Define report parameters
PERFORM Execute subroutine
PF-STATUS Set GUI status
POSITION List processing: Defineoutput position
PRINT Print formatting (NEW-PAGE)
PRINT-CONTROL Define print format
PRIVATE Class area not visible from outside
PROGRAM Introduction for type Mand S programs
LEAVE PROGRAM Leave program
PROPERTY Object property
GET PROPERTY Get property
SET PROPERTY Set property
PROVIDE Internal tables: Interval-related processing
PUT Trigger event
RADIOBUTTON Radio button (PARAMETERS)
RAISE Raise exceptions and events
RAISING Raise error message in function module
RANGES Define internal table for selection criterion
READ Read tables or objects
RECEIVE Receive results (RFC)
REFRESH Delete internal table
REFRESH CONTROL Initialize control
REJECT Do not process current database line further
REPLACE Replace characters
33
REPORT Introduction for type 1programs
DELETE REPORT Delete program
EDITOR-CALL FOR Call ABAP program editor
REPORT
INSERT REPORT Insert program in library
READ REPORT Read program
RESERVE List processing: Conditional new page
RESET Output format: Reset all formats (FORMAT)
RIGHT-JUSTIFIED Output format: Right justified (WRITE)
ROLLBACK Roll back database changes
ROUND Output format: Scaled (WRITE)
RTTI Runtime type identification
RUN TIME ANALYZER Activate/Deactivate runtime analysis (SET)
SCAN Analyze ABAP/4 source code
SCREEN Screen
CALL SCREEN Call screen
SET SCREEN Set next screen
LEAVE SCREEN Leave screen
LEAVE TO SCREEN Branch to a screen
LOOP AT SCREEN Loop through screen fields
MODIFY SCREEN Modify screen fields
SCROLL List processing: Scroll
SCROLL- List processing: Fix lead columns (SET)
BOUNDARY
SEARCH Find character
SELECT Read database table
SELECT-OPTIONS Define selection criterion
SELECTION-SCREEN Design selection screen
AT SELECTION- After editing ofselection screen
SCREENEvent:
SHARED BUFFER Cross-transaction application buffer
DELETE FROM delete from application buffer
SHARED BUFFER
EXPORT ... TO Store data in application buffer
SHARED BUFFER
IMPORT ... FROM Read data from application buffer
SHARED BUFFER
SELECTION-TABLE Selection table (SUBMIT)
SET Set different processing parameters
SHIFT Move character
SIGN Mathematical function: Sign (COMPUTE)
SIN Mathematical function: Sine (COMPUTE)
SINGLE Select single record (SELECT)
SINH Mathematical function: Hyperbola sine
(COMPUTE)
SKIP List processing: Outputblank line
SORT Sort internal table or extract dataset
SORTED TABLE Table type for internaltables that are always kept
34
SPLIT Split character fields
SQRT Mathematical function: Square root (COMPUTE)
STANDARD TABLE Table type for standardinternal tables
START-OF- Event: Before first access to LDB
SELECTION
STATICS Define static data
STOP Stop data selection (LDB)
STRING Data type for variable-length character sequence
STRLEN Character function: Current length (COMPUTE)
STRUCTURE Data structure
INCLUDE Use structure
STRUCTURE
SUBMIT Program call
SUBTRACT Subtract
SUBTRACT- Field string subtraction
CORRESPONDING
SUM Calculate control total
SELECT ... SUM Aggregate expression: Total
SUPPLY Supply context key fields
SUPPRESS DIALOG Suppress dialog
SYMBOL Output as symbol (WRITE)
SYNTAX-CHECK Syntax check for programs and screens
SYNTAX-TRACE Syntax check log
SYSTEM-CALL Call to various system services
SYSTEM- Catch runtime errors (CATCH)
EXCEPTIONS
TABLE LINE Unstructured lines in internal tables
TABLE_LINE Unstructured lines in internal tables
TABLES Declare database table
TABLE Set or array operations for database tables
DELETE ... FROM Delete block of lines
TABLE
INSERT ... FROM Insert block of lines
TABLE
MODIFY ... FROM Insert/update block of lines
TABLE
UPDATE ... FROM Update block of lines
TABLE
SELECT ... INTO Copy block of lines to internal table
TABLE
TAN Mathematical function: Tangent (COMPUTE)
TANH Mathematical function: Hyperbola tangent
(COMPUTE)
TEXT Locale-specific
CONVERT TEXT Set format
SORT itab AS TEXT Sort an internal table
SORT AS TEXT Sort an extract dataset
TEXTPOOL Text elements
35
DELETE TEXTPOOL Delete
INSERT TEXTPOOL Insert
READ TEXTPOOL Read
TIME Time measurement
GET RUN TIME Get runtime
GET TIME Get time
SET RUN TIME Switch runtime analysison/off
ANALYZER
TIME STAMP Time stamp
GET TIME STAMP Get time stamp
CONVERT TIME Convert time stamps to date/time
STAMP
WRITE f TIME ZONE Output of time stamps to lists
TITLEBAR Set screen title (SET)
TOP-OF-PAGE Event: Top of page handling in lists
TRANSACTION SAP transaction
CALL TRANSACTION Call
LEAVE TO Leave to
TRANSACTION
TRANSFER Output to file
TRANSLATE Character conversion incharacter fields
TRANSPORTING Selective field transport
MODIFY ... Modify lines of an internal table
TRANSPORTING
READ ... Read lines of an internal table
TRANSPORTING
LOOP ... Loop through an internal table
TRANSPORTING
TRUNC Mathematical function: Whole number part
(COMPUTE)
TYPE Define a type
TYPES ... TYPE Define a type
DATA ... TYPE Define a field
TYPE-POOL Introduction for type Tprograms
TYPE-POOLS Include type group
TYPES Define types
ULINE List processing: Underscore
UNDER Output format: One under the other (WRITE)
UNIQUE Define an
TYPES internal table type
DATA internal table object
UNIT Output format: Unit (WRITE)
UNPACK Conversion
UPDATE Update database table
USER-COMMAND List processing: Execute command immediately
(SET)
USING Use parameter or format
USING Parameter of a subroutine
36
USING EDIT MASK Output format: Use template (WRITE)
VALUE-REQUEST Self-programmed value help(F4)
PARAMETERS ... for parameters
VALUE-REQUEST
SELECT-OPTIONS ... for selection options
VALUE-REQUEST
WHEN Case distinction
SELECT ... WHERE when reading from databasetables
UPDATE ... WHERE when changing database tables
DELETE ... WHERE when deleting database tables
LOOP AT ... WHERE when looping at internal tables
DELETE ... WHERE when deleting from internal tables
WHILE Loop
WINDOW List processing: Outputin window
WITH-TITLE Output standard page header (NEW-PAGE)
WORK Processing unit
COMMIT WORK Close unit
ROLLBACK WORK Close unit, but undo changes
WRITE List processing: Output
WRITE TO Correct type output in a variable
X Data type for fixed-length byte sequence
XSTRING Data type for variable-length byte sequence
Z Relational bit operator: Bit positions occupiedby
d. ABAP Syntax
Syntax at ABAP program consist of few type, these are:
1. Statement
>> Display
Statements are always begined by ABAP Keywords (Example: TYPES , DATA , write
dst). Keyword determine statement Catagory.
1. Data Types
2. Declaration Data Types
37
This statement use to define a data type or object as variable of program.
Example :
TYPES <variable_name> TYPE <type>.
DATA <variable_name> TYPE <type>.
3. Compound Statement
Example :
FORM <form_name>.
Statement 1.
Statement 2.
...
Statement n.
ENDFORM.
FUNCTION <function_name>.
Statement 1.
Statement 2.
...
Statement n.
ENDFUNCTION.
MODULE <module_name>.
Statement 1.
Statement 2.
...
Statement n.
ENDMODULE.
4. Control Statement
Example :
IF <condition1>.
<statement block>
ELSEIF <condition2>
<statement block>.
ELSEIF <condition3>.
<statement block>
.....
ELSE.
<statement block>
ENDIF.
5. Operator Statement
38
Example :
WRITE <statement>.
ADD <variable 1> to <variable 2>.
6. Database Statement
7. Structures
8. Internal Tables
2. Literal
1. Numerical Literal
Example :
a = 10.
b = 100.
2. Text Literal
Example :
write 'Hello, World !!'.
3. Chained Statement
ABAP has classical language program caracteristic, that is, in every statement in
main program or in block statement will be executed in sequence from the top to
bottom.
Example :
No. Statement
1 Data : a TYPE i,
b TYPE i,
c TYPE p DECIMALS 2.
2 START-OF-SELECTION.
3 a = 10.
4 b = 100.
5 c = a / b.
39
From the example above, ABAP will execute from number 1 to 6.
4. Comment
Example :
FORM fm_process_data.
*Get other requirement information
LOOP AT gi_header.
* Get Material Description
READ TABLE gi_makt WITH KEY matnr = gi_header-matnr.
IF sy-subrc = 0.
gi_header-maktx = gi_makt-maktx.
ENDIF.
MODIFY gi_header.
ENDLOOP.
ENDFORM.
Example :
FORM fm_process_data.
"Get other requirement information
LOOP AT gi_header.
"Get Material Description
READ TABLE gi_makt WITH KEY matnr = gi_header-matnr.
IF sy-subrc = 0.
gi_header-maktx = gi_makt-maktx.
ENDIF.
MODIFY gi_header.
ENDLOOP.
ENDFORM.
40
e. ABAP Dictionary
Menu Path SAP Menu > Tools > ABAP Workbench > Development >
ABAP Dictionary
Transaction code SE11
Domain
Domain is a part of Elementary Types with global type, which use at all Data
Element.
4. Click Button
5. Fill in Short Description. Then fill in Data Type, No. Characters, Decimal
places and Output length like below.
41
6. Click button
7. Package is filled to make Transportable Domain into other client, but you
don't need to fill it if practice only.
Data Element
42
Data Element is a part of Elementary Types with global type, which use at all
Field (in Table) and to be reference data type in ABAP program.
4. Click Button
6. Fill in Short Description. Then fill in Domain if you want to use data type
from Domain. But if you want to make data type then activate Built-int type.
43
7. Activate Field label's type then Fill in Field label as requirement, for finish
press enter.
8. Click Button
9.Package is filled to make Transportable Data Element into other client, but
you don't need to fill it if practice only.
44
10. Click button to make Transportable Data Element into other client.
Click button for practice only.
Structure
Structure is a part of Complex Types with global type structures, which able to
be reference data type in all ABAP Program.
4. Click Button
7. Fill in fields as requirement. If fields have same data type with in Data
Element, then fill it in Data Element Coloums. If some fields have dfferent
45
data type with SAP Data Element, then click button to activate
Data Type Coloum. If you finish, click button again to activate
Data Element Coloums.
8. Click Button
9. Package is filled to make Transportable Structure into other client, but you
don't need to fill it if practice only
10. Click button to make Transportable Structure into other client. Click
button ”Local Object” for practice only.
46
11. Click button to activate Structure.
Table
Table is a part of Complex Types with global type tables but, Table is able to
filled in and saved at server, which to be reference data type in ABAP
program
4. Click Button
5. Fill in Short Description. Then fill in Delivery Class and Data
Browser/Table View Maint. like picture below..
6. Activate tab of Fields. Then filled in Field and it's attribut like below.
Note :
" MANDT " Field have to make to differentiate data by client, If there are
more than one· client in a server.
If CheckBox Key is activated then the current field is mandatory and to be
primary key. ·
if initial CheckBox is activated, then current field have initial
value appropriate
· with it's data type when to be append and
47
inserted.
7. Fill in fields as requirement. If fields have same data type with in Data
Element, then fill it in Data Element Coloums. If some fields have dfferent
data type with SAP Data Element, then click button to
activate Data Type Coloum. If you finish, click button again
to activate Data Element Coloums.
8. Click Button
9. Package is filled to make Transportable Table into other client, but you
don't need to fill itif practice only
48
10. Click button to make Transportable Table into other client. Click button
for practice only.
49
View
View is a part of Complex Types with global type tables with content of
collaborate of table. Beside that, it can be reference data type in all ABAP
Program.
Steps to make Table
1. Open t-code SE11
2. Activate Radio Button
3. Insert Structure name, initiate with letter Z or Y
4. Click Button
5. Choose Database view, then Click Button
50
7. Join two table with name YTEST and YTEST2 like picture below.
8. Activate field View Fields. Then fill the coloums like below.
9. Click Button
51
10. Package is filled to make Transportable View into other client, but you
don't need to fill it if practice only.
11. Click button to make Transportable View into other client. Click button
for practice only.
a. Function Builder
Function Group
Function group is group to cluster Function Module.
Steps to make Function Group
3. Fill Function Group name and Short text, but the naming must initiate by letter
Z or Y.
4. Click button
52
5. Package is filled to make Transportable Function Group into other client, but
you don't need to fill it if practice only.
6. Click button to make Transportable Function Group into other client. Click
button for practice only.
Function Module
Steps to make Function Module
1. Open t-code SE37
2. Fill Function Module name, initiate by letter Z or Y
3. Click Button
4. Fill in Function Group And Short Text
5. Click Button
6. Click Button .
53
g. Form
Menu Path SAP Menu > Tools > Form Printout > Smart Forms
Transaction code SMARTFORMS
Smartform
Menu Path SAP Menu > Tools > Form Printout > Smart Forms
Transaction code SMARTFORMS
SAP Smart Forms allow you to execute simple modifications to the form and in
the form logic by using simple graphical tools; in 90% of all cases, this won't
include any programming effort. Same with ABAP Editor, SAP User must have
Developer Key to create SmartForms.
54
1. Open t-Code SMARTFORMS
2. Insert name of program, program name must begin with the letter Z or Y
4. Click .
6. Click .
55
7. Optional insert Package to create programs that can transport to another client,
if only for training package need not be filled.
Smartstyles
h. Enhancement
Jalur Menu SAP Menu > Tools > ABAP Workbench > Utilities >
Business Add-Ins > Implementation
SAP Menu > Tools > ABAP Workbench > Utilities >
Enhancements > Project Management
Kode Transaksi SE19 dan CMOD
Basis
Job
SAP Communication
Spool Printer
57
sp02 - List of Spool Requests
i. Examples
▪ Result
▪ Source Code
Creating Report
*--------------------------------------------------------------------*
*GLOBAL VARIABLE DECRALATION
*--------------------------------------------------------------------*
DATA : a TYPE i,
b TYPE i,
c TYPE p DECIMALS 2.
*====================================================================*
*MAIN PROGRAM
*Execute after Input Screen
*====================================================================*
START-OF-SELECTION.
58
a = 10.
b = 100.
c = a / b.
WRITE : / 'Hitung : ', a, '/', b, '=', c.
Result
Input:
None.
Output:
▪ Result
▪ Source Code
Creating Report
59
*================================================================*
*MAIN PROGRAM
*Execute after Input Screen
*================================================================*
START-OF-SELECTION.
a = 10.
b = 100.
c = a / b.
d = c.
WRITE : / 'Hitung : ', a, '/', b, '=', d.
4. Activated and Run
5. Finished
Result
Input:
None.
Output:
▪ Result
▪ Source Code
Creating Report
*----------------------------------------------------------------*
*GLOBAL VARIABLE DECRALATION
*----------------------------------------------------------------*
*First Style
types : begin of ty_wa,
a type i,
b type i,
hasil type p decimals 2,
end of ty_wa.
60
Data : l_wa1 type ty_wa. " Sturcture (Workarea)
*Second Style
data: begin of l_wa2,
a type i,
b type i,
hasil type p decimals 2,
end of l_wa2. " Sturcture (Workarea)
*----------------------------------------------------------------*
*Input Screen/Selection
*----------------------------------------------------------------*
parameter p_a like l_wa1-a default 12.
parameter p_b like l_wa1-b default 14.
*================================================================*
*MAIN PROGRAM
*Execute after Input Screen
*================================================================*
START-OF-SELECTION.
l_wa1-a = p_a.
l_wa1-b = p_b.
Result
Input Selection:
Output:
61
Objective ▪ Creating Report
▪ Result
▪ Source Code
Creating Report
*First Style
TYPES : BEGIN OF ty_wa,
a TYPE i,
b TYPE i,
hasil TYPE p DECIMALS 2,
END OF ty_wa.
*----------------------------------------------------------------*
*Input Screen/Selection
*----------------------------------------------------------------*
*================================================================*
*MAIN PROGRAM
*Execute after Input Screen
*================================================================*
START-OF-SELECTION.
62
* insert Into itab
CLEAR lv_counter.
DO p_n TIMES.
lv_counter = lv_counter + 1.
Result
Input Selection:
Output:
63
Objective ▪ Creating Report
▪ Result
▪ Source Code
Creating Report
*----------------------------------------------------------------*
*Input Screen/Selection
*----------------------------------------------------------------*
64
LOOP AT gi_header.
write : /'|' no-gap,(9) gi_header-matkl centered,
'|' no-gap,(18) gi_header-matnr,
'|' no-gap.
ENDLOOP.
Result
Input Selection:
Output:
65
BAB 2
ABAP-REPORT
a. Basic Knowledge
Input Selection
Output
I. REQUEST
Module MM (Material Date 21 April 2008
Management)
Request - Initial Name
By
66
Request ABAP Report Characteristic Display Output
Type
Printer - Reference T- MM03
Code
Report (101)
Creating Report
67
Display Steps
Press enter and *Select ”Basic Data 1” and ”Basic Data 2”. Then press
Display Material
3. Start writing ABAP Code. First declare table ( Functional Specification III-3 )
*----------------------------------------------------------------------*
*Tables
*----------------------------------------------------------------------*
68
4. Declare Global Variable
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
DEFINE macro_data_possition.
if &1 = 'HEADER'.
else.
write :
END-OF-DEFINITION.
*----------------------------------------------------------------------*
*Input Screen/Selection
*----------------------------------------------------------------------*
SELECT-OPTIONS so_matkl FOR mara-matkl.
SELECT-OPTIONS so_matnr FOR mara-matnr.
69
*======================================================================*
*MAIN PROGRAM
*Execute after Input Screen
*======================================================================*
START-OF-SELECTION.
gv_width = 113.
PERFORM fm_collect_data.
PERFORM fm_process_data.
PERFORM fm_display_data.
END-OF-SELECTION.
*======================================================================*
*SUB PROGRAM / SUB ROUTINE
*======================================================================*
FORM fm_collect_data.
ENDFORM.
FORM fm_process_data.
ENDFORM.
FORM fm_display_data.
ENDFORM.
70
matnr = gi_header-matnr AND
spras = sy-langu.
* Notes :
* Avoid using inner join
ENDFORM.
FORM fm_process_data.
*Get other requirement information
LOOP AT gi_header.
* Get Material Description
READ TABLE gi_makt WITH KEY matnr = gi_header-matnr.
IF sy-subrc = 0.
gi_header-maktx = gi_makt-maktx.
ENDIF.
MODIFY gi_header.
ENDLOOP.
ENDFORM.
10. Write code for sub routine fm_display_data (Functional Specification III-5)
FORM fm_display_data.
* Create Header Text
ULINE AT (gv_width). " Upper frame border
FORMAT COLOR COL_HEADING INTENSIFIED. " Title color
macro_data_possition : 'HEADER' 'Mat. Group' 'Mat. No.' 'Description'
'Old Mat. No.' 'Base Unit' 'Measure'.
WRITE: AT gv_width sy-vline. " Right border
ULINE AT (gv_width). " Line below titles
FORMAT COLOR OFF.
* End of Line
ULINE AT (gv_width). " Line below last data
ENDFORM.
71
11. Activated and run.
12. Create T-Code ”YP101”
3) Then click ” ”
4) Fill Short Text
"Program and screen" for the ABAP program with Dialog Programming
techniques.
"Program and selection screen" for the ABAP program ABAP Technical
Report (Selection Screen).
5) Click ” ”
6) Fill program name and Screen number. If you have an authorization object
of your program, then fill it.
72
7) Click ” ” and exit.
8) Test Transaction Code.
9) Finished.
13. Finished.
b. Display Output
Input Selection
73
Output
Input Selection
Output
74
Test Printing to PDF Writer
I. REQUEST
Module MM (Material Management) Date 22 April 2008
Request By - Initial Name
Request ABAP Report Characteristic Display Output
Type
Printer - Reference T- MM03
Code
75
II. OBJECT INFO
1 Package $TMP 4 T-Code YP201
2 Program Name YPRACTICE_201 5 Include
Program
3 Function Module 6
III.DETAIL DESCRIPTION
1 Background Display List of Master Material
2 Flow of Process Select Material Data -> Display
3 Table MARA, MAKT, T006A
4 Input Screen/Selection Selection Parameter
Page Setup
Max. Width
eg : report have 3 pages, and Report must show like this bellow
Page : 1/3
Page : 2/3
76
Mat. Mat. No. Description Old Mat. Base Unit of Measure
Group No. Measure
(MARA-MATKL) (MARA-MATNR) (MAKT-MAKTX) (MARA-BISMT) (MARA-MEINS) (T006A-MSEHT)
Page : 3/3
Report (201)
Creating Report
1) Open SE38.
2) Copy Program ”YPRACTICE_101” to ”YPRACTICE_201”.
3) Open GoTo > Attributes, and change title with ”201 – Display List of
Material”.
4) Modified Report Declaration.
Before
REPORT ypractice_101.
After
REPORT ypractice_201
NO STANDARD PAGE HEADING.
After
*---------------------------------------------------------------------
-*
*Input Screen/Selection
*---------------------------------------------------------------------
-*
SELECTION-SCREEN BEGIN OF BLOCK groupbox1 WITH FRAME TITLE text_101.
"Declare Group Box 1
77
SELECTION-SCREEN BEGIN OF BLOCK groupbox2 WITH FRAME TITLE text_201.
"Declare Group Box 2
7) Create event and initialization code, write it after input Screen Block.
*--------------------------------------------------------------------*
*EVENT
*--------------------------------------------------------------------*
AT SELECTION-SCREEN OUTPUT.
text_101 = 'Selection Parameter'.
text_102 = 'Material Group'.
text_103 = 'Material Number'.
*--------------------------------------------------------------------*
*INITIALIZATION
*--------------------------------------------------------------------*
INITIALIZATION.
Before
*====================================================================*
*MAIN PROGRAM
*Execute after Input Screen
*====================================================================*
START-OF-SELECTION.
gv_width = 113.
PERFORM fm_collect_data.
PERFORM fm_process_data.
PERFORM fm_display_data.
END-OF-SELECTION.
After
*====================================================================*
*MAIN PROGRAM
*Execute after Input Screen
*====================================================================*
START-OF-SELECTION.
NEW-PAGE LINE-SIZE p_mwidth.
NEW-PAGE LINE-COUNT p_mline.
PERFORM fm_collect_data.
PERFORM fm_process_data.
PERFORM fm_display_data.
END-OF-SELECTION.
78
9) Modified sub routine “fm_display_data”
Before
*&-------------------------------------------------------------------*
*& Form fm_display_data
*&-------------------------------------------------------------------*
* text
*--------------------------------------------------------------------*
FORM fm_display_data.
* Create Header Text
ULINE AT (gv_width). " Upper frame border
FORMAT COLOR COL_HEADING INTENSIFIED. " Title color
macro_data_possition : 'HEADER' 'Mat. Group' 'Mat. No.'
'Description' 'Old Mat. No.' 'Base Unit' 'Measure'.
WRITE: AT gv_width sy-vline. " Right border
ULINE AT (gv_width). " Line below titles
FORMAT COLOR OFF.
* End of Line
ULINE AT (gv_width). " Line below last data
ENDFORM. "fm_display_data
After
*&-------------------------------------------------------------------*
*& Form fm_display_data
*&-------------------------------------------------------------------*
* text
*--------------------------------------------------------------------*
FORM fm_display_data.
DATA: lv_total_data TYPE i,
lv_header_line TYPE i,
lv_footer_line TYPE i,
lv_max_content TYPE i,
lv_max_data TYPE i,
lv_page_count TYPE i. " LENGTH 4.
79
gi_header-maktx
gi_header-bismt
gi_header-meins
gi_header-mseht.
IF sy-linno = lv_max_data.
PERFORM fm_footer USING lv_page_count.
NEW-PAGE.
ENDIF.
ENDLOOP.
ENDFORM. "fm_display_data
*&-------------------------------------------------------------------*
*& Form fm_footer
*&-------------------------------------------------------------------*
* text
*--------------------------------------------------------------------*
* -->FV_PAGE_COUtext
*--------------------------------------------------------------------*
FORM fm_footer USING fv_page_count.
* Create Footer Text ( 3 Lines )
ULINE AT (p_mwidth). " Upper frame border
FORMAT COLOR COL_TOTAL INTENSIFIED. " Footer color
WRITE : /'|' NO-GAP, 'Page : ' NO-GAP, (4) sy-pagno NO-GAP, '/',(4)
fv_page_count NO-GAP.
*====================================================================*
*STANDARD EVENT
*====================================================================*
*--------------------------------------------------------------------*
*Page Header
*--------------------------------------------------------------------*
TOP-OF-PAGE.
* Create Header Text ( 3 Lines )
ULINE AT (p_mwidth). " Upper frame border
FORMAT COLOR COL_HEADING INTENSIFIED. " Title color
macro_data_possition : 'HEADER' 'Mat. Group' 'Mat. No.'
'Description' 'Old Mat. No.' 'Base Unit' 'Measure'.
ULINE AT (p_mwidth). " Line below titles
FORMAT COLOR OFF.
80
Report (202)
Creating Report
1) Open SE38
2) Copy Program ”YPRACTICE_201” to ”YPRACTICE_202”
3) Open GoTo > Attributes and change title with ”202 – Display and Print List
of Master Material”
4) Modified Report Declaration
Before
REPORT ypractice_201
NO STANDARD PAGE HEADING.
After
REPORT ypractice_202
NO STANDARD PAGE HEADING
.
5) Add 2 Global Variable
DATA: gw_pri_params TYPE pri_params,
gv_valid TYPE c.
Before
*--------------------------------------------------------------------*
*Input Screen/Selection
*--------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK groupbox1 WITH FRAME TITLE text_101.
"Declare Group Box 1
81
After
*--------------------------------------------------------------------*
*Input Screen/Selection
*--------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK groupbox1 WITH FRAME TITLE text_101.
"Declare Group Box 1
SELECTION-SCREEN ULINE.
82
7) Add new text in ”Event”
Before
*=====================================================================
=*
*MAIN PROGRAM
*Execute after Input Screen
*=====================================================================
=*
START-OF-SELECTION.
NEW-PAGE LINE-SIZE p_mwidth.
NEW-PAGE LINE-COUNT p_mline.
PERFORM fm_collect_data.
PERFORM fm_process_data.
PERFORM fm_display_data.
END-OF-SELECTION.
After
*=====================================================================
=*
*MAIN PROGRAM
*Execute after Input Screen
*=====================================================================
=*
START-OF-SELECTION.
FORMAT RESET.
PERFORM fm_collect_data.
PERFORM fm_process_data.
END-OF-SELECTION.
*&-------------------------------------------------------------------*
*& Form fm_print_setup
*&-------------------------------------------------------------------*
* text
83
*--------------------------------------------------------------------*
FORM fm_print_setup.
DATA: lv_dialog TYPE c.
IF p_prt = 'X'.
IF p_dialog = 'X'.
lv_dialog = ' '.
ELSE.
lv_dialog = 'X'.
ENDIF.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDIF.
ENDFORM. "fm_print_setup
*&-------------------------------------------------------------------*
*& Form fm_showmessage
*&-------------------------------------------------------------------*
* text
*--------------------------------------------------------------------*
FORM fm_showmessage.
MESSAGE 'File not found.' TYPE 'I'.
ENDFORM. "fm_showmessage
84
c. HTML
Input Selection
Output
Functional Specification
I. REQUEST
Module MM (Material Management) Date 23 April 2008
85
Request By - Initial Name
Request ABAP Report Characteristic Html - Web Page
Type
Printer - Reference T-Code MM03
III.DETAIL DESCRIPTION
1 Background Display List of Master Material
2 Flow of Process Select Material Data -> Display
3 Table MARA, MAKT, T006A
4 Input Screen/Selection Selection Parameter
File Location
5 Output
Mat. Mat. No. Description Old Mat. Base Unit of Measure
Group No. Measure
(MARA-MATKL) (MARA-MATNR) (MAKT-MAKTX) (MARA-BISMT) (MARA-MEINS) (T006A-MSEHT)
Report 301
Creating Report
1) Open SE38
86
2) Copy Program ”YPRACTICE_101” to ”YPRACTICE_301”
3) Change Program ”YPRACTICE_301”
4) Open GoTo > Attributes, and change title with ”301 – Display List of
Material”
5) Modified Report Declaration
Before
REPORT ypractice_101.
After
REPORT ypractice_301.
87
Click ”” to save design layout.
Close design layout and back to previous screen.
Click ”Element List” tab.
Fill on the blank cell with ”OK_CODE”
DEFINE write_code1.
clear gi_html_code.
gi_html_code-line_code = &1.
append gi_html_code.
END-OF-DEFINITION.
DEFINE write_code2.
clear gi_html_code.
concatenate &1 &2 into gi_html_code-line_code.
append gi_html_code.
END-OF-DEFINITION.
DEFINE write_code3.
clear gi_html_code.
concatenate &1 &2 &3 into gi_html_code-line_code.
append gi_html_code.
END-OF-DEFINITION.
88
Before
*--------------------------------------------------------------------*
*Input Screen/Selection
*--------------------------------------------------------------------*
SELECT-OPTIONS so_matkl FOR mara-matkl.
SELECT-OPTIONS so_matnr FOR mara-matnr.
After
*--------------------------------------------------------------------*
*Input Screen/Selection
*--------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK groupbox1 WITH FRAME TITLE text_101.
"Declare Group Box 1
*&-------------------------------------------------------------------*
*& Form fm_initialization
*&-------------------------------------------------------------------*
* text
*--------------------------------------------------------------------*
FORM fm_initialization.
IF cc_report_display IS INITIAL.
89
*--------------------------------------------------------------------*
*INITIALIZATION
*--------------------------------------------------------------------*
INITIALIZATION.
text_101 = 'Selection Parameter'.
text_102 = 'Material Group'.
text_103 = 'Material Number'.
PERFORM fm_initialization.
*&-------------------------------------------------------------------*
*& Form fm_create_css
*&-------------------------------------------------------------------*
* text
*--------------------------------------------------------------------*
* -->FV_CSS text
*--------------------------------------------------------------------*
FORM fm_create_css.
write_code1 '<style type="text/css">'.
write_code1 '<!--'.
write_code1 '.styleHeader {'.
write_code1 ' font-family: Arial, Helvetica, sans-serif;'.
write_code1 ' font-size: 12px;'.
write_code1 ' font-weight: bold;'.
write_code1 ' text-align: center;'.
write_code1 ' }'.
write_code1 '.style1 {'.
write_code1 ' font-family: Arial, Helvetica, sans-serif;'.
write_code1 ' font-size: 12px;'.
write_code1 ' text-align: center;'.
write_code1
' }'.
write_code1 '-->'.
write_code1 '</style>'.
ENDFORM. "fm_create_css
*&-------------------------------------------------------------------*
*& Form fm_create_temp_html
*&-------------------------------------------------------------------*
* text
*--------------------------------------------------------------------*
* -->FI_FILE text
* -->FV_URL text
*--------------------------------------------------------------------*
FORM fm_create_html_file TABLES fi_file STRUCTURE gi_html_code USING
fv_url.
CONDENSE fv_url NO-GAPS.
90
EXPORTING
filename = fv_url
filetype = 'ASC'
TABLES
data_tab = fi_file
EXCEPTIONS
file_open_error = 1
file_write_error = 2
invalid_filesize = 3
invalid_table_width = 4
invalid_type = 5
no_batch = 6
unknown_error = 7
OTHERS = 8.
ENDFORM. "fm_create_temp_html
*&-------------------------------------------------------------------*
*& Form fm_load_html
*&-------------------------------------------------------------------*
* text
*--------------------------------------------------------------------*
* -->URL text
*--------------------------------------------------------------------*
FORM fm_load_html USING fv_url.
CALL METHOD cc_report_display->show_url
EXPORTING
url = fv_url.
ENDFORM. "fm_load_html
Before
*&-------------------------------------------------------------------*
*& Form fm_display_data
*&-------------------------------------------------------------------*
* text
*--------------------------------------------------------------------*
FORM fm_display_data.
* Create Header Text
ULINE AT (gv_width). " Upper frame border
FORMAT COLOR COL_HEADING INTENSIFIED. " Title color
macro_data_possition : 'HEADER' 'Mat. Group' 'Mat. No.'
'Description' 'Old Mat. No.' 'Base Unit' 'Measure'.
WRITE: AT gv_width sy-vline. " Right border
ULINE AT (gv_width). " Line below titles
FORMAT COLOR OFF.
* End of Line
ULINE AT (gv_width). " Line below last data
ENDFORM. "fm_display_data
91
After
*&-------------------------------------------------------------------*
*& Form fm_display_data
*&-------------------------------------------------------------------*
* text
*--------------------------------------------------------------------*
FORM fm_display_data.
REFRESH gi_html_code.
PERFORM fm_create_css.
write_code1 '<body>'.
write_code1 '<table width="100%" border="0" cellspacing="2"
cellpadding="0">'.
ENDLOOP.
* End of Line
write_code1 '</table>'.
write_code1 '</body>'.
ENDFORM. "fm_display_data
92
Fill Status with ”ST_2000” and Short Text with ”GUI Status for
Screen 2000”
Click ” ”
Open Function Key
Choose Standard Toolbar and enter BACK on icon mumber 3 on the
left
93
18) Modified Screen 2000 Flow Logic
Before
PROCESS BEFORE OUTPUT.
* MODULE STATUS_2000.
*
PROCESS AFTER INPUT.
* MODULE USER_COMMAND_2000.
After
PROCESS BEFORE OUTPUT.
MODULE STATUS_2000.
*
PROCESS AFTER INPUT.
MODULE USER_COMMAND_2000.
Before
*&-------------------------------------------------------------------*
*& Module STATUS_2000 OUTPUT
*&-------------------------------------------------------------------*
* text
*--------------------------------------------------------------------*
module STATUS_2000 output.
* SET PF-STATUS 'xxxxxxxx'.
* SET TITLEBAR 'xxx'.
After
*&-------------------------------------------------------------------*
*& Module STATUS_2000 OUTPUT
94
*&-------------------------------------------------------------------*
* text
*--------------------------------------------------------------------*
module STATUS_2000 output.
SET PF-STATUS 'ST_2000'.
* SET TITLEBAR 'xxx'.
Before
*&-------------------------------------------------------------------*
*& Module USER_COMMAND_2000 INPUT
*&-------------------------------------------------------------------*
* text
*--------------------------------------------------------------------*
module USER_COMMAND_2000 input.
After
*&-------------------------------------------------------------------*
*& Module USER_COMMAND_2000 INPUT
*&-------------------------------------------------------------------*
* text
*--------------------------------------------------------------------*
MODULE user_command_2000 INPUT.
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
WHEN OTHERS.
ENDCASE.
CLEAR ok_code.
ENDMODULE. " USER_COMMAND_2000 INPUT
95
29) Click ”” to active the program
30) Test and run program
31) Create T-Code ”YP301”
32) Finished
Input Selection
96
Output
Functional Specification
I. REQUEST
Module MM (Material Management) Date 23 April 2008
Request By - Initial Name
Request ABAP Report Characteristic Html - Web Page
Type
Printer - Reference T-Code MM03
97
III.DETAIL DESCRIPTION
1 Background Display List of Master Material
2 Flow of Process Select Material Data -> Display
3 Table MARA, MAKT, T006A
4 Input Screen/Selection Selection Parameter
File Location
Report (302)
Creating Report
1) Open SE38
2) Copy Program ”YPRACTICE_301” to ”YPRACTICE_302”
3) Select all object
98
4) Change program ”YPRACTICE_302”
5) Open GoTo > Attributes and change Title with ”302 – Display List of
Material”
6) Modified Report Declaration
Before
REPORT ypractice_301.
After
REPORT ypractice_302.
7) Click ” ”
8) Add New Include Program
99
10) Click ” ” to create new include
11) Save into same package with ”YPRACTICE_302” and then click ” ” to
insert the include into main program.
12) Create global variable at ”YPRACTICE_302_CLASSES”
*--------------------------------------------------------------------*
*GLOBAL VARIABLE DECRALATION
*--------------------------------------------------------------------*
DATA : gv_html_event_tab TYPE cntl_simple_events,
gv_html_event TYPE cntl_simple_event,
gv_repid LIKE sy-repid,
gv_frame(255),
gv_action(256),
gv_getdata(2048),
gv_postdataline(1024),
gi_postdata_tab TYPE cnht_post_data_tab,
gi_query_table TYPE TABLE OF w3query WITH HEADER LINE.
*--------------------------------------------------------------------*
* CLASS cl_html_event_handler DEFINITION
*--------------------------------------------------------------------*
*
*--------------------------------------------------------------------*
CLASS cl_html_event_handler DEFINITION.
PUBLIC SECTION.
* Activate event
METHODS: on_sapevent
FOR EVENT sapevent OF cl_gui_html_viewer
IMPORTING action frame getdata postdata query_table.
100
14) Create class implementation ”YPRACTICE_302_CLASSES”
*--------------------------------------------------------------------*
* CLASS cl_html_event_handler IMPLEMENTATION
*--------------------------------------------------------------------*
*
*--------------------------------------------------------------------*
CLASS cl_html_event_handler IMPLEMENTATION.
* Event Procedure
METHOD on_sapevent.
CLEAR gv_action.
CLEAR gv_frame.
CLEAR gv_getdata.
CLEAR gv_postdataline.
gv_action = action.
gv_frame = frame.
gv_getdata = getdata.
gi_postdata_tab = postdata.
IF NOT gi_postdata_tab IS INITIAL.
READ TABLE gi_postdata_tab INDEX 1 INTO gv_postdataline.
ENDIF.
gi_query_table[] = query_table[].
CASE action.
* Action "OPEN_PAGE" when press a button in the html page
WHEN 'SUBMIT_PAGE_NO'.
PERFORM fm_display_data.
WHEN OTHERS.
ENDCASE.
ENDMETHOD. "on_sapevent
...
concatenate &1 &2 &3 into gi_html_code-line_code.
append gi_html_code.
END-OF-DEFINITION.
*--------------------------------------------------------------------*
*INCLUDE PROGRAM
*--------------------------------------------------------------------*
*You can put the include program at the bottom of code
INCLUDE ypractice_302_classes.
*--------------------------------------------------------------------*
*Input Screen/Selection
*--------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK groupbox1 WITH FRAME TITLE text_101.
"Declare Group Box 1
...
101
16) Modified ”Input Screen / Selection” and add new parameters
Before
...
SELECTION-SCREEN BEGIN OF BLOCK groupbox2 WITH FRAME TITLE text_201.
"Declare Group Box 2
After
...
SELECTION-SCREEN BEGIN OF BLOCK groupbox2 WITH FRAME TITLE text_201.
"Declare Group Box 2
102
IF lv_counter = fv_active_page_no.
CONCATENATE '<option value="' lv_counter '" selected>'
lv_counter '</option>' INTO lv_item.
ELSE.
CONCATENATE '<option value="' lv_counter '" >' lv_counter
'</option>' INTO lv_item.
ENDIF.
write_code1 lv_item.
ENDWHILE.
ENDFORM. "fm_create_paging_menu
Before
*&--------------------------------------------------------------------
*
*& Form fm_display_data
*&--------------------------------------------------------------------
*
* text
*---------------------------------------------------------------------
*
FORM fm_display_data.
REFRESH gi_html_code.
PERFORM fm_create_css.
write_code1 '<body>'.
write_code1 '<table width="100%" border="0" cellspacing="2"
cellpadding="0">'.
ENDLOOP.
* End of Line
write_code1 '</table>'.
103
write_code1 '</body>'.
ENDFORM. "fm_display_data
After
*&--------------------------------------------------------------------
*
*& Form fm_display_data
*&--------------------------------------------------------------------
*
* text
*---------------------------------------------------------------------
*
FORM fm_display_data.
DATA : lv_active_page_no TYPE n LENGTH 4,
lv_limit_top TYPE i,
lv_limit_bottom TYPE i,
lv_total_page LIKE lv_active_page_no,
lv_remainder LIKE lv_active_page_no.
IF lv_remainder > 0.
lv_total_page = lv_total_page+1.
ENDIF.
REFRESH gi_html_code.
PERFORM fm_create_css.
write_code1 '<body>'.
104
write_code1 ' <td>Base Unit of Measure</td>'.
write_code1 ' <td>Measure</td>'.
write_code1 ' </tr>'.
ENDLOOP.
* End of Line
write_code1 ' <td bgcolor="#999999" class="styleHeader"
colspan="6"> </td>'.
PERFORM fm_create_paging_menu USING lv_total_page lv_active_page_no.
write_code1 '</table>'.
write_code1 '</body>'.
ENDFORM. "fm_display_data
Before
*&--------------------------------------------------------------------
*
*& Form fm_load_html
*&--------------------------------------------------------------------
*
* text
*---------------------------------------------------------------------
*
* -->URL text
*---------------------------------------------------------------------
*
FORM fm_load_html USING fv_url.
CALL METHOD cc_report_display->show_url
EXPORTING
url = fv_url.
ENDFORM. "fm_load_html
After
*&--------------------------------------------------------------------
*
*& Form fm_load_html
*&--------------------------------------------------------------------
*
* text
*---------------------------------------------------------------------
*
* -->URL text
*---------------------------------------------------------------------
*
FORM fm_load_html USING fv_url.
105
TRY.
CALL METHOD cc_report_display->show_url
EXPORTING
url = fv_url.
CATCH cx_sy_ref_is_initial.
LEAVE TO SCREEN 0.
ENDTRY.
ENDFORM. "fm_load_html
Before
*&--------------------------------------------------------------------
-*
*& Module STATUS_2000 OUTPUT
*&--------------------------------------------------------------------
-*
* text
*---------------------------------------------------------------------
-*
MODULE status_2000 OUTPUT.
SET PF-STATUS 'ST_2000'.
* SET TITLEBAR 'xxx'.
After
*&--------------------------------------------------------------------
-*
*& Module STATUS_2000 OUTPUT
*&--------------------------------------------------------------------
-*
* text
*---------------------------------------------------------------------
-*
MODULE status_2000 OUTPUT.
SET PF-STATUS 'ST_2000'.
* SET TITLEBAR 'xxx'.
* register event
IF NOT cc_report_display IS INITIAL.
gv_html_event-eventid = cc_report_display->m_id_sapevent.
gv_html_event-appl_event = 'x'.
APPEND gv_html_event TO gv_html_event_tab.
Before
106
*&--------------------------------------------------------------------
-*
*& Module USER_COMMAND_2000 INPUT
*&--------------------------------------------------------------------
-*
* text
*---------------------------------------------------------------------
-*
MODULE user_command_2000 INPUT.
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
WHEN OTHERS.
ENDCASE.
CLEAR ok_code.
ENDMODULE. " USER_COMMAND_2000 INPUT
After
*&--------------------------------------------------------------------
-*
*& Module USER_COMMAND_2000 INPUT
*&--------------------------------------------------------------------
-*
* text
*---------------------------------------------------------------------
-*
MODULE user_command_2000 INPUT.
save_ok = ok_code.
CLEAR ok_code.
CASE save_ok.
WHEN 'BACK'.
REFRESH gi_query_table.
IF NOT cc_report_display IS INITIAL.
CALL METHOD cc_report_display->free.
FREE cc_report_display.
ENDIF.
LEAVE TO SCREEN 0.
WHEN OTHERS.
CALL METHOD cl_gui_cfw=>dispatch.
ENDCASE.
CLEAR ok_code.
ENDMODULE. " USER_COMMAND_2000 INPUT
107
27) Create T-Code ”YP302”
28) Finished
d. ALV
ALV List
Report (401) – Create Simple ALV List Report
Input Selection
Output
108
Functional Specification (401)
I.REQUEST
109
Report (401)
1) Open SE38.
2) Copy Program ”YPRACTICE_101” to ”YPRACTICE_401”.
3) Open GoTo > Attributes, and change Title with ”401 – Display List of
Master Material”.
4) Modification Report Declaration.
Before
REPORT ypractice_101.
After
REPORT ypractice_401 .
5) Click ” ”.
6) Add new Include Program.
110
9) Save into same peckage with ”YPRACTICE_401” and then click ” ” to
insert the include into main program.
10) Insert the source code from page of ”YPRACTICE_401_ALV” into the
include program.
*&-------------------------------------------------------------------*
*& Include YPRACTICE_502_ALV
*
*&-------------------------------------------------------------------*
TYPE-POOLS : slis.
*&-------------------------------------------------------------------*
*& Form fm_alv_show
*&-------------------------------------------------------------------*
* text
*--------------------------------------------------------------------*
* -->FT_ITAB text
111
*--------------------------------------------------------------------*
FORM fm_alv_show TABLES ft_itab.
CLEAR gi_it_event_exit.
gi_it_event_exit-ucomm = '&OUP'.
gi_it_event_exit-after = 'X'.
APPEND gi_it_event_exit.
CLEAR gi_it_event_exit.
gi_it_event_exit-ucomm = '&ODN'.
gi_it_event_exit-after = 'X'.
APPEND gi_it_event_exit.
CLEAR gi_it_event_exit.
gi_it_event_exit-ucomm = '&ETA'.
gi_it_event_exit-after = 'X'.
APPEND gi_it_event_exit.
CLEAR gi_it_event_exit.
gi_it_event_exit-ucomm = '&IC1'.
gi_it_event_exit-after = 'X'.
APPEND gi_it_event_exit.
ENDFORM. "fm_alv_show
*&--------------------------------------------------------------------
*
112
*& Form fm_alv_reset_data
*&--------------------------------------------------------------------
*
* text
*---------------------------------------------------------------------
*
FORM fm_alv_reset_data.
CLEAR : gw_is_layout,
gi_it_fieldcat,
gi_it_excluding,
gi_it_special_groups,
gi_it_sort,
gi_it_filter,
gw_is_sel_hide,
gv_i_default,
gv_i_save,
gw_is_variant,
gi_it_events,
gi_it_event_exit,
gw_is_print,
gw_is_reprep_id.
REFRESH : gi_it_fieldcat,
gi_it_excluding,
gi_it_special_groups,
gi_it_sort,
gi_it_filter,
gi_it_events,
gi_it_event_exit.
ENDFORM. "fm_alv_reset_data
*&-------------------------------------------------------------------*
*& Form fm_alv_set_layout
*&-------------------------------------------------------------------*
* text
*--------------------------------------------------------------------*
FORM fm_alv_set_layout USING fu_title.
gw_is_layout-window_titlebar = fu_title.
gw_is_layout-zebra = 'X'.
gw_is_layout-colwidth_optimize = 'X'.
gw_is_layout-no_colhead = space.
gw_is_layout-group_change_edit = 'X'.
* gw_is_layout-box_fieldname = 'CHBOX'.
ENDFORM. "fm_alv_set_layout
*&-------------------------------------------------------------------*
*& Form fm_alv_set_print
*&-------------------------------------------------------------------*
* text
*--------------------------------------------------------------------*
FORM fm_alv_set_print.
gw_is_print-no_print_listinfos = 'X'.
gw_is_print-no_print_selinfos = 'X'.
gw_is_print-no_coverpage = 'X'.
gw_is_print-no_print_hierseq_item = 'X'.
ENDFORM. "fm_alv_set_print
*&-------------------------------------------------------------------*
*& Form fm_alv_add_fieldcat
*&-------------------------------------------------------------------*
* text
*--------------------------------------------------------------------*
* -->FU_1 text
* -->FU_2 text
* -->FU_3 text
113
* -->FU_4 text
* -->FU_5 text
* -->FU_6 text
* -->FU_7 text
* -->FU_8 text
* -->FU_9 text
* -->FU_10 text
* -->FU_11 text
* -->FU_12 text
* -->FU_13 text
* -->FU_14 text
* -->FU_15 text
* -->FU_16 text
* -->FU_17 text
* -->FU_18 text
* -->FU_19 text
* -->FU_20 text
* -->FU_21 text
*--------------------------------------------------------------------*
FORM fm_alv_add_fieldcat USING
fu_1 fu_2 fu_3 fu_4 fu_5 fu_6 fu_7 fu_8 fu_9 fu_10
fu_11 fu_12 fu_13 fu_14 fu_15 fu_16
fu_17 fu_18 fu_19 fu_20 fu_21.
CLEAR: gi_it_fieldcat.
gi_it_fieldcat-fieldname = fu_1. " Fieldname
gi_it_fieldcat-ref_tabname = fu_2. " Reference Tablename
gi_it_fieldcat-ref_fieldname = fu_3. " Reference Fieldname
gi_it_fieldcat-no_out = fu_4. " (O)blig.(X)no out
gi_it_fieldcat-outputlen = fu_5. " Output length
gi_it_fieldcat-seltext_l = fu_6. " long key word
gi_it_fieldcat-seltext_m = fu_7. " middle key word
gi_it_fieldcat-seltext_s = fu_8. " short key word
gi_it_fieldcat-reptext_ddic = fu_9. " heading (ddic)
gi_it_fieldcat-round = fu_10. " round in write statement
gi_it_fieldcat-do_sum = fu_11. " sum up
gi_it_fieldcat-hotspot = fu_12. " 'X' = hotspot is active ->
Event click
gi_it_fieldcat-decimals_out = fu_13. " decimals in write statement
gi_it_fieldcat-currency = fu_14.
gi_it_fieldcat-quantity = fu_15.
gi_it_fieldcat-qfieldname = fu_16. " field with quantity unit
gi_it_fieldcat-cfieldname = fu_17. " field with currency unit
gi_it_fieldcat-checkbox = fu_18. " 'X' = checkbox or ' ' = not
checkbox
gi_it_fieldcat-icon = fu_19. " 'X' = icon or ' ' = not icon
gi_it_fieldcat-fix_column = fu_20. " 'X' = Fix Column On or ' ' =
Fix Column off gi_it_fieldcat-key = &21. "
gi_it_fieldcat-key = fu_21. " 'X' = Key or ' ' = not Key
APPEND gi_it_fieldcat.
ENDFORM. "fm_alv_add_fieldcat
*&-------------------------------------------------------------------*
*& Form FM_ALV_SET_PF_STATUS
*&-------------------------------------------------------------------*
* text
*--------------------------------------------------------------------*
* -->RT_EXTAB text
*--------------------------------------------------------------------*
FORM fm_alv_set_pf_status USING rt_extab TYPE slis_t_extab.
SET PF-STATUS 'YSTANDARD'.
ENDFORM. "fm_alv_set_pf_status
*&-------------------------------------------------------------------*
*& Form FM_USER_COMMAND
114
*&-------------------------------------------------------------------*
* text
*--------------------------------------------------------------------*
FORM fm_alv_user_command USING fu_ucomm LIKE sy-ucomm
fu_selfield TYPE slis_selfield.
DATA: lt_dynpread LIKE dynpread OCCURS 0 WITH HEADER LINE,
lv_ok_code LIKE sy-ucomm.
ENDCASE.
ENDFORM. "FM_USER_COMMAND
11) Open new session of SE38, by pressing ‘/oSE38’ tehne enter at the command
field.
12) Fill program name with ”SAPLKKBL”.
115
16) Copy GUI Status of ”Standard”.
116
17) Fill program with ”YPRACTICE_401” and status with ”YSTANDARD”.
18) Click ” ”.
After
*--------------------------------------------------------------------*
*Input Screen/Selection
*--------------------------------------------------------------------*
117
SELECTION-SCREEN BEGIN OF BLOCK groupbox1 WITH FRAME TITLE text_101.
"Declare Group Box 1
INCLUDE ypractice_401_alv.
*--------------------------------------------------------------------*
*GLOBAL VARIABLE DECRALATION
*--------------------------------------------------------------------*
TYPES: BEGIN OF ty_header,
...
118
25) Modified global variable declaration.
Before
*--------------------------------------------------------------------*
*GLOBAL VARIABLE DECRALATION
*--------------------------------------------------------------------*
DEFINE macro_data_possition.
if &1 = 'HEADER'.
write : /'|' no-gap,(9) &2 centered,
'|' no-gap,(18) &3 centered,
'|' no-gap,(40) &4 centered,
'|' no-gap,(18) &5 centered,
'|' no-gap,(5) &6 centered,
'|' no-gap,(10) &7 centered,
'|' no-gap.
else.
write : /'|' no-gap,(9) &2 centered,
'|' no-gap,(18) &3 ,
'|' no-gap,(40) &4 ,
'|' no-gap,(18) &5 ,
'|' no-gap,(5) &6 ,
'|' no-gap,(10) &7 ,
'|' no-gap.
endif.
END-OF-DEFINITION.
After
*--------------------------------------------------------------------*
*GLOBAL VARIABLE DECRALATION
*--------------------------------------------------------------------*
119
TYPES: BEGIN OF ty_header,
matkl TYPE mara-matkl, " Material Group
matnr TYPE mara-matnr, " Material Number
maktx TYPE makt-maktx, " Material Description
bismt TYPE mara-bismt, " Old material number
meins TYPE mara-meins, " Base Unit of Measure
mseht TYPE t006a-mseht, " Unit of Measurement Text
END OF ty_header.
Before
*&-------------------------------------------------------------------*
*& Form fm_collect_data
*&-------------------------------------------------------------------*
* text
*--------------------------------------------------------------------*
FORM fm_collect_data.
* Collect Master Material
SELECT matnr matkl bismt meins
INTO CORRESPONDING FIELDS OF TABLE gi_header
FROM mara
WHERE
matkl IN so_matkl AND
matnr IN so_matnr.
* Notes :
* Avoid using inner join
120
ENDFORM. "FM_COLLECT_DATA
After
*&-------------------------------------------------------------------*
*& Form fm_collect_data
*&-------------------------------------------------------------------*
text
*--------------------------------------------------------------------*
FORM fm_collect_data.
* Collect Master Material
SELECT matnr
matkl
bismt
meins
INTO TABLE gi_mara
FROM mara
WHERE
matkl IN so_matkl AND
matnr IN so_matnr.
SELECT matnr
maktx
INTO TABLE gi_makt
FROM makt
FOR ALL ENTRIES IN gi_mara
WHERE
matnr = gi_mara-matnr AND
spras = sy-langu.
SELECT msehi
mseht
INTO TABLE gi_t006a
FROM t006a
FOR ALL ENTRIES IN gi_mara
WHERE
msehi = gi_mara-meins AND
spras = sy-langu.
ENDIF.
* Notes :
* Avoid using inner join
ENDFORM. "FM_COLLECT_DATA
Before
*&-------------------------------------------------------------------*
*& Form FM_PROCESS_DATA
*&-------------------------------------------------------------------*
* text
*--------------------------------------------------------------------*
FORM fm_process_data.
*Get other requirement information
LOOP AT gi_header.
121
* Get Material Description
READ TABLE gi_makt WITH KEY matnr = gi_header-matnr.
IF sy-subrc = 0.
gi_header-maktx = gi_makt-maktx.
ENDIF.
MODIFY gi_header.
ENDLOOP.
ENDFORM. "FM_PROCESS_DATA
After
*&-------------------------------------------------------------------*
*& Form FM_PROCESS_DATA
*&-------------------------------------------------------------------*
* text
*--------------------------------------------------------------------*
FORM fm_process_data.
ENDFORM. "FM_PROCESS_DATA
Before
*&-------------------------------------------------------------------*
*& Form fm_display_data
*&-------------------------------------------------------------------*
122
* text
*--------------------------------------------------------------------*
FORM fm_display_data.
* Create Header Text
ULINE AT (gv_width). " Upper frame border
FORMAT COLOR COL_HEADING INTENSIFIED. " Title color
macro_data_possition : 'HEADER' 'Mat. Group' 'Mat. No.'
'Description' 'Old Mat. No.' 'Base Unit' 'Measure'.
WRITE: AT gv_width sy-vline. " Right border
ULINE AT (gv_width). " Line below titles
FORMAT COLOR OFF.
* End of Line
ULINE AT (gv_width). " Line below last data
ENDFORM. "fm_display_data
After
*&-------------------------------------------------------------------*
*& Form fm_display_data
*&-------------------------------------------------------------------*
* text
*--------------------------------------------------------------------*
FORM fm_display_data.
PERFORM fm_alv_reset_data.
GV_I_DEFAULT = 'X'.
GV_I_SAVE = 'A'.
ENDFORM. "fm_display_data
29) Create new sub routine ”fm_alv_set_column” at the bottom of source code.
*&-------------------------------------------------------------------*
*& Form fm_alv_set_column
*&-------------------------------------------------------------------*
* text
*--------------------------------------------------------------------*
FORM fm_alv_set_column.
* matkl LIKE mara-matkl, " Material Group
* matnr LIKE mara-matnr, " Material Number
* maktx LIKE makt-maktx, " Material Description
* bismt LIKE mara-bismt, " Old material number
* meins LIKE mara-meins, " Base Unit of Measure
* mseht LIKE t006a-mseht, " Unit of Measurement Text
123
* Displaying Column by Fieldname
ENDFORM. "fm_alv_set_column
INCLUDE ypractice_401_alv.
*----------------------------------------------------------------------*
*GLOBAL VARIABLE DECRALATION
*----------------------------------------------------------------------*
124
meins TYPE mara-meins,
END OF ty_mara.
*internal table
DATA: gi_header TYPE STANDARD TABLE OF ty_header,
gi_mara TYPE STANDARD TABLE OF ty_mara,
gi_makt TYPE STANDARD TABLE OF ty_makt,
gi_t006a TYPE STANDARD TABLE OF ty_t006a.
*workarea
DATA: wa_header TYPE ty_header,
wa_mara TYPE ty_mara,
wa_makt TYPE ty_makt,
wa_t006a TYPE ty_t006a.
*----------------------------------------------------------------------*
*Input Screen/Selection
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK groupbox1 WITH FRAME TITLE text_101.
"Declare Group Box 1
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(18) text_102 FOR FIELD so_matkl.
SELECT-OPTIONS so_matkl FOR mara-matkl.
SELECTION-SCREEN END OF LINE.
INITIALIZATION.
*======================================================================*
*MAIN PROGRAM
*Execute after Input Screen
*======================================================================*
START-OF-SELECTION.
gv_width = 113.
PERFORM fm_collect_data.
PERFORM fm_process_data.
PERFORM fm_display_data.
END-OF-SELECTION.
*&--------------------------------------------------------------------*
*& Form fm_collect_data
125
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM fm_collect_data.
* Collect Master Material
SELECT matkl
matnr
bismt
meins
INTO TABLE gi_mara
FROM mara
WHERE
matkl IN so_matkl AND
matnr IN so_matnr.
* "For SAP 4.6C
* DATA : lv_total_data type i.
* DESCRIBE TABLE gi_header LINES lv_total_data.
* IF LINES( lv_total_data ) > 0.
*&--------------------------------------------------------------------*
*& Form FM_PROCESS_DATA
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM fm_process_data.
*Get other requirement information
LOOP AT gi_mara INTO wa_mara.
IF sy-subrc = 0.
wa_header-matkl = wa_mara-matkl.
wa_header-matnr = wa_mara-matnr.
wa_header-bismt = wa_mara-bismt.
wa_header-meins = wa_mara-meins.
* Get Material Description
READ TABLE gi_makt INTO wa_makt WITH KEY matnr = wa_mara-matnr.
IF sy-subrc = 0.
wa_header-maktx = wa_makt-maktx.
ENDIF.
* Get Measurement Text
READ TABLE gi_t006a INTO wa_t006a WITH KEY msehi = wa_mara-meins.
IF sy-subrc = 0.
wa_header-mseht = wa_t006a-mseht.
ENDIF.
126
ENDIF.
APPEND wa_header TO gi_header.
ENDLOOP.
ENDFORM. "FM_PROCESS_DATA
*&--------------------------------------------------------------------*
*& Form fm_display_data
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM fm_display_data.
PERFORM fm_alv_reset_data.
* Set ALV Parameters and Data
PERFORM fm_alv_set_layout USING 'Display List of Master Material'.
PERFORM fm_alv_set_print.
PERFORM fm_alv_set_column.
gv_i_default = 'X'.
gv_i_save = 'A'.
PERFORM fm_alv_show TABLES gi_header.
ENDFORM. "fm_display_data
*======================================================================
*Set ALV
*======================================================================
*&--------------------------------------------------------------------*
*& Form fm_alv_set_column
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM fm_alv_set_column.
* matkl type mara-matkl, " Material Group
* matnr type mara-matnr, " Material Number
* maktx type makt-maktx, " Material Description
* bismt type mara-bismt, " Old material number
* meins type mara-meins, " Base Unit of Measure
* mseht type t006a-mseht, " Unit of Measurement Text
* Displaying Column by Fieldname
ALV GRID
127
Report (402) – Create Simple ALV Grid Report
Input Selection
Output
128
I.REQUEST
Module MM (Material Management) Date 15 July 2008
Request By - Initial Name
Request ABAP Report Characteristic ALV List
Type
Printer - Reference T- MM03
Code
Report (402)
Creating Report
1) Open SE38.
129
2) Copy Program ”YPRACTICE_401” to ”YPRACTICE_402”.
3) Select all object.
4) Click ” ”.
Before
REPORT ypractice_401.
After
130
REPORT ypractice_402.
INCLUDE YPRACTICE_402_ALV.
*INCLUDE ypractice_501_alv.
*--------------------------------------------------------------------*
*GLOBAL VARIABLE DECRALATION
*--------------------------------------------------------------------*
TYPES: BEGIN OF ty_header,
...
Before
...
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
..
After
...
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
...
131
12) Create T-Code ”YP402”.
13) Finished.
INCLUDE ypractice_402_alv.
*INCLUDE ypractice_501_alv.
*----------------------------------------------------------------------*
*GLOBAL VARIABLE DECRALATION
*----------------------------------------------------------------------*
*internal table
DATA: gi_header TYPE STANDARD TABLE OF ty_header,
gi_mara TYPE STANDARD TABLE OF ty_mara,
gi_makt TYPE STANDARD TABLE OF ty_makt,
gi_t006a TYPE STANDARD TABLE OF ty_t006a.
*workarea
DATA: wa_header TYPE ty_header,
wa_mara TYPE ty_mara,
wa_makt TYPE ty_makt,
wa_t006a TYPE ty_t006a.
*----------------------------------------------------------------------*
*Input Screen/Selection
*----------------------------------------------------------------------*
SELECTION-SCREEN BEGIN OF BLOCK groupbox1 WITH FRAME TITLE text_101.
"Declare Group Box 1
132
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(18) text_102 FOR FIELD so_matkl.
SELECT-OPTIONS so_matkl FOR mara-matkl.
SELECTION-SCREEN END OF LINE.
INITIALIZATION.
*======================================================================*
*MAIN PROGRAM
*Execute after Input Screen
*======================================================================*
START-OF-SELECTION.
gv_width = 113.
PERFORM fm_collect_data.
PERFORM fm_process_data.
PERFORM fm_display_data.
END-OF-SELECTION.
*&--------------------------------------------------------------------*
*& Form fm_collect_data
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM fm_collect_data.
* Collect Master Material
SELECT matkl
matnr
bismt
meins
INTO TABLE gi_mara
FROM mara
WHERE
matkl IN so_matkl AND
matnr IN so_matnr.
* "For SAP 4.6C
* DATA : lv_total_data type i.
* DESCRIBE TABLE gi_header LINES lv_total_data.
* IF LINES( lv_total_data ) > 0.
133
mseht
INTO TABLE gi_t006a
FROM t006a
FOR ALL ENTRIES IN gi_mara
WHERE
msehi = gi_mara-meins AND
spras = sy-langu.
ENDIF.
* Notes :
* Avoid using inner join
ENDFORM. "FM_COLLECT_DATA
*&--------------------------------------------------------------------*
*& Form FM_PROCESS_DATA
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM fm_process_data.
*Get other requirement information
LOOP AT gi_mara INTO wa_mara.
IF sy-subrc = 0.
wa_header-matkl = wa_mara-matkl.
wa_header-matnr = wa_mara-matnr.
wa_header-bismt = wa_mara-bismt.
wa_header-meins = wa_mara-meins.
* Get Material Description
READ TABLE gi_makt INTO wa_makt WITH KEY matnr = wa_mara-matnr.
IF sy-subrc = 0.
wa_header-maktx = wa_makt-maktx.
ENDIF.
* Get Measurement Text
READ TABLE gi_t006a INTO wa_t006a WITH KEY msehi = wa_mara-meins.
IF sy-subrc = 0.
wa_header-mseht = wa_t006a-mseht.
ENDIF.
ENDIF.
APPEND wa_header TO gi_header.
ENDLOOP.
ENDFORM. "FM_PROCESS_DATA
*&--------------------------------------------------------------------*
*& Form fm_display_data
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM fm_display_data.
PERFORM fm_alv_reset_data.
* Set ALV Parameters and Data
PERFORM fm_alv_set_layout USING 'Display List of Master Material'.
PERFORM fm_alv_set_print.
PERFORM fm_alv_set_column.
gv_i_default = 'X'.
gv_i_save = 'A'.
PERFORM fm_alv_show TABLES gi_header.
ENDFORM. "fm_display_data
*======================================================================
*Set ALV
*======================================================================
*&--------------------------------------------------------------------*
*& Form fm_alv_set_column
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM fm_alv_set_column.
* matkl type mara-matkl, " Material Group
134
* matnr type mara-matnr, " Material Number
* maktx type makt-maktx, " Material Description
* bismt type mara-bismt, " Old material number
* meins type mara-meins, " Base Unit of Measure
* mseht type t006a-mseht, " Unit of Measurement Text
* Displaying Column by Fieldname
e. SmartForms
Seleksi Input:
Output:
135
Functional Specification
I.PERMINTAAN
Module MM (Material Management) Date 15 Oktober 2009
Request By - Initial Name
Request Report ABAP Characteristic FORM (SmartForms)
Type
Printer - Reference T-Code MM03
INFO
II. OBJEK
136
Name Program
3 Function 6
Modul
DISKRIPSI
III.DETAIL
Page Setup
Max. Row
5 Output
Mat. Mat. No. Description Old Mat. Base Unit of Measure
Group No. Measure
(MARA-MATKL) (MARA-MATNR) (MAKT-MAKTX) (MARA-BISMT) (MARA-MEINS) (T006A-MSEHT)
Report (501)
Creating Report
Click
137
Change the word on the ”Meaning” with ”Form List of Master Material”.
Click
Optional insert Package to create programs that can transport to another
client, if only for training package need not be filled.
138
Click “ ” save if you want to create program that can be transported to
another client, or click “ ” if only for training.
SmartForms be made.
2) Double click on the menu ”Form Interface”.
3) Open the tab ”Import” and add the import parameters, like the image below.
4) Open the tab ”Table” and add the table parameters, like the image below.
139
5) Firstly you must create Function Builder of ”YST_HEADER_101,
YST_RANGE_MATKL and YST_RANGE_MATNR”.
Click ” ”.
Select ”Structure”.
140
Add component / field like this below.
Create Function
Open T-Code ”SE37”.
Enter new Function ”YFM_RFC_PRACTICE_101”
Click “ ”
Fill function group with “YFG MIL” and short text with “RFC Practice
101”
141
Edit and set Processing type to “Remote enabled menu”
Add new source code, copy and paste this source code bellow
to”Source Code” tab
FUNCTION yfm_rfc_practice_101.
*"-------------------------------------------------------------
--------
*"*"Local interface:
*" IMPORTING
*" VALUE(GV_MATKL) LIKE MARA-MATKL OPTIONAL
*" VALUE(GV_MATNR) LIKE MARA-MATNR OPTIONAL
*" VALUE(GV_MAX_ROW) TYPE I DEFAULT 100
*" TABLES
*" GI_HEADER STRUCTURE YTA_HEADER_101 OPTIONAL
142
*"-------------------------------------------------------------
--------
LOOP AT gi_header.
* Get Material Description
READ TABLE gi_makt WITH KEY matnr = gi_header-matnr.
IF sy-subrc = 0.
gi_header-maktx = gi_makt-maktx.
ENDIF.
143
gi_header-mseht = gi_t006a-mseht.
ENDIF.
MODIFY gi_header.
ENDLOOP.
ENDFUNCTION.
Click “ ”
Select ”Structure”
144
Fill short description “Structure for RANGE of Material Group”
145
Enter Data Type “YST_RANGE_MATNR”
Click “ ”
Select ”Structure”
146
Add component/field like this bellow
Create Function
Open T-Code “SE37”
Copy function YFM_RFC_PRACTICE_101 to
YFM_RFC_PRACTICE_102
Click “ ”
Fill the function module with “YFM_RFC_PRACTICE_102”
147
Edit the short text with “RFC Practice 102”
Add new source code, copy and paste this source code bellow
to”Source Code” tab
FUNCTION yfm_rfc_practice_102.
*"-------------------------------------------------------------
---------
*"*"Local interface:
*" IMPORTING
*" VALUE(GV_MAX_ROW) TYPE I DEFAULT 100
*" TABLES
*" GI_HEADER STRUCTURE YTA_HEADER_101 OPTIONAL
*" GR_MATKL STRUCTURE YST_RANGE_MATKL OPTIONAL
*" GR_MATNR STRUCTURE YST_RANGE_MATNR OPTIONAL
*"-------------------------------------------------------------
---------
148
* DATA: lv_counter TYPE i.
LOOP AT gi_header.
* Get Material Description
READ TABLE gi_makt WITH KEY matnr = gi_header-matnr.
IF sy-subrc = 0.
gi_header-maktx = gi_makt-maktx.
ENDIF.
MODIFY gi_header.
ENDLOOP.
ENDFUNCTION.
149
Open the tab “Global Data” and add parameter like the image bellow
150
Open the tab “Output Options” and set the value “Possition and Size”
as shown bellow
Right click on the menu “Main” and click on “Create> Table” to create
a table (List Data)
151
Fill in value as the image bellow
Note: The total value of all columns must be no more than “Table
Width”
152
Add the value at the column number 6 with value like this image
bellow
153
Press “ ”
154
Right-click on the menu “Header” and click “Create> Table Line” to
make header on the List Data
155
Open the tab “General Attribute” and content of text “Mat. Group” like
the picture bellow.
156
Right-click on the menu “Main Area” and click “Create > Table Line”
to make Line Data
157
Right-click on the menu “%CELL7” and click “Create > Text” to
create a row of data in column
158
Click “Utilities > Field List on/off” or press “Ctrl + Shift + F4” to open
the list of parameters in the declaration onsteps 3-7
159
Drag and Drop “MATKL” into tab “General Attribute”
Create Report
Open SE38
Copy program “YPRACTICE_101” become “YPRACTICE_501”
Open GoTo > Attributes and change “Title” with “501-Display List
of Master Material”
Modification declaration Report
Before
REPORT ypractice_101.
After
REPORT ypractice_601.
160
Before
*--------------------------------------------------------------
--------*
*GLOBAL VARIABLE DECRALATION
*--------------------------------------------------------------
--------*
DEFINE macro_data_possition.
if &1 = 'HEADER'.
write : /'|' no-gap,(9) &2 centered,
'|' no-gap,(18) &3 centered,
'|' no-gap,(40) &4 centered,
'|' no-gap,(18) &5 centered,
'|' no-gap,(5) &6 centered,
'|' no-gap,(10) &7 centered,
'|' no-gap.
else.
write : /'|' no-gap,(9) &2 centered,
'|' no-gap,(18) &3 ,
'|' no-gap,(40) &4 ,
'|' no-gap,(18) &5 ,
'|' no-gap,(5) &6 ,
'|' no-gap,(10) &7 ,
'|' no-gap.
endif.
END-OF-DEFINITION.
After
*--------------------------------------------------------------
--------*
*GLOBAL VARIABLE DECRALATION
*--------------------------------------------------------------
--------*
DATA: gi_header LIKE STANDARD TABLE OF yst_header_101 WITH
HEADER LINE,
gi_makt LIKE STANDARD TABLE OF makt WITH HEADER LINE,
gi_t006a LIKE STANDARD TABLE OF t006a WITH HEADER LINE.
Before
*--------------------------------------------------------------
--------*
*Input Screen/Selection
*--------------------------------------------------------------
--------*
SELECT-OPTIONS so_matkl FOR mara-matkl.
SELECT-OPTIONS so_matnr FOR mara-matnr.
161
After
*--------------------------------------------------------------
--------*
*Input Screen/Selection
*--------------------------------------------------------------
--------*
SELECTION-SCREEN BEGIN OF BLOCK groupbox1 WITH FRAME TITLE
text_101. "Declare Group Box 1
Create event and initialization code, write down the input Screen Block
*--------------------------------------------------------------
--------*
*EVENT
*--------------------------------------------------------------
--------*
AT SELECTION-SCREEN OUTPUT.
text_101 = 'Selection Parameter'.
text_102 = 'Material Group'.
text_103 = 'Material Number'.
*--------------------------------------------------------------
--------*
*INITIALIZATION
*--------------------------------------------------------------
--------*
INITIALIZATION.
Before
*==============================================================
========*
*MAIN PROGRAM
*Execute after Input Screen
162
*==============================================================
========*
START-OF-SELECTION.
gv_width = 113.
PERFORM fm_collect_data.
PERFORM fm_process_data.
PERFORM fm_display_data.
END-OF-SELECTION.
After
*==============================================================
========*
*MAIN PROGRAM
*Execute after Input Screen
*==============================================================
========*
START-OF-SELECTION.
PERFORM fm_collect_data.
PERFORM fm_process_data.
PERFORM fm_display_data.
END-OF-SELECTION.
Before
*&-------------------------------------------------------------
-------*
*& Form fm_display_data
*&-------------------------------------------------------------
-------*
* text
*--------------------------------------------------------------
-------*
FORM fm_display_data.
* Membuat Teks header
ULINE AT (gv_width). " Upper frame border
FORMAT COLOR COL_HEADING INTENSIFIED. " Title color
macro_data_possition : 'HEADER' 'Mat. Group' 'Mat. No.'
'Description' 'Old Mat. No.' 'Base Unit' 'Measure'.
WRITE: AT gv_width sy-vline. " Right border
ULINE AT (gv_width). " Line below titles
FORMAT COLOR OFF.
ENDFORM. "fm_display_data
After
163
*&-------------------------------------------------------------
-------*
*& Form fm_display_data
*&-------------------------------------------------------------
-------*
* text
*--------------------------------------------------------------
-------*
FORM fm_display_data.
DATA: lv_fmname TYPE rs38l_fnam,
lw_options TYPE ssfcompop,
lw_control TYPE ssfctrlop,
lw_tdbool TYPE tdbool.
lw_control-no_dialog = ''.
lw_control-preview = 'X'.
* lw_options-tddest = nast-ldest.
lw_options-tdimmed = 'X'.
lw_options-tddelete = 'X'.
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
164
ENDIF.
ENDFORM. "fm_display_data
REPORT ypractice_501 .
*----------------------------------------------------------------------*
* Tables
*----------------------------------------------------------------------*
TABLES : mara, makt, t006a.
*----------------------------------------------------------------------*
*GLOBAL VARIABLE DECRALATION
*----------------------------------------------------------------------*
*----------------------------------------------------------------------*
*Input Screen/Selection
*----------------------------------------------------------------------*
165
SELECTION-SCREEN COMMENT 1(18) txt_102 FOR FIELD so_matkl.
SELECT-OPTIONS so_matkl FOR mara-matkl.
SELECTION-SCREEN END OF LINE.
*----------------------------------------------------------------------*
*EVENT
*----------------------------------------------------------------------*
AT SELECTION-SCREEN OUTPUT.
txt_101 = 'Selection Parameter'.
txt_102 = 'Material Group'.
txt_103 = 'Material Number'.
*----------------------------------------------------------------------*
*INITIALIZATION
*----------------------------------------------------------------------*
INITIALIZATION.
*======================================================================*
*MAIN PROGRAM
*Execute after Input Screen
*======================================================================*
START-OF-SELECTION.
PERFORM fm_collect_data.
PERFORM fm_process_data.
PERFORM fm_display_data.
END-OF-SELECTION.
*======================================================================*
*SUB PROGRAM / SUB ROUTINE
*======================================================================*
*&--------------------------------------------------------------------*
*& Form fm_collect_data
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM fm_collect_data.
SELECT matnr
matkl
bismt
meins
INTO TABLE gi_mara
166
FROM mara
WHERE
matkl IN so_matkl AND
matnr IN so_matnr.
SELECT matnr
maktx
INTO TABLE gi_makt
FROM makt
FOR ALL ENTRIES IN gi_mara
WHERE
matnr = gi_mara-matnr AND
spras = sy-langu.
SELECT msehi
mseht
INTO TABLE gi_t006a
FROM t006a
FOR ALL ENTRIES IN gi_mara
WHERE
msehi = gi_mara-meins AND
spras = sy-langu.
ENDIF.
* Notes :
* Avoid using inner join
ENDFORM. "FM_COLLECT_DATA
*&--------------------------------------------------------------------*
*& Form FM_PROCESS_DATA
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM fm_process_data.
yst_header_101-matnr = wa_mara-matnr.
yst_header_101-matkl = wa_mara-matkl.
yst_header_101-bismt = wa_mara-bismt.
yst_header_101-meins = wa_mara-meins.
167
* Get Measurement Text
ENDIF.
ENDLOOP.
ENDFORM. "FM_PROCESS_DATA
*&--------------------------------------------------------------------*
*& Form fm_display_data
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM fm_display_data.
lv_fmname = 'YFO_PRACTICE_101'.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = lv_fmname
IMPORTING
fm_name = lv_fmname
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
lw_tdbool = space.
lw_control-no_dialog = ''.
lw_control-preview = 'X'.
* lw_options-tddest = nast-ldest.
lw_options-tdimmed = 'X'.
lw_options-tddelete = 'X'.
168
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDFORM. "fm_display_data
169