0% found this document useful (0 votes)
39 views298 pages

Fixing Excel Columns in RICEF Training

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

Fixing Excel Columns in RICEF Training

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

Volume - II

RICEF

By Irfan
RICEF

About the Author

Irfan is a professional certified ABAP consultant. Having 18+ years of


experience in the ABAP/Workflow/ABAP HR/ABAP on HANA and Migration,
throughout India all critical and production stoppage issues were handled by
him.

Irfan worked in number of MNC’s such as IBM, NTTDATA, WIPRO. The


industries he worked for are Oil and Gas, Petroleum, Automobiles, Textiles,
Pharma, Telecommunications, Retail, Chemical Industries, Electrical, etc. He was
Principal Consultant worked as SME (Subject Matter Expert) or COE (Centre of
Excellence) in an MNC.

Considering his experience in this field, he has turned his interest into
training young candidates. He has trained thousands of students by enlightening
them by his knowledge and experience. He is currently offering excellent
training services in Abap on S/4 Hana. This training provides complete course on
Abap core concepts, RICEF, Abap Oops, Cross Application, Abap new features,
Abap on Hana and Migration (ECC to S/4 Hana), Real-time Projects and complete
preparation for the interview until a person gets selected in his dream job.

P a g e 1 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

INDEX
Sl no. Concepts Page no.

1 Reports 3

2 Module Pool Program 91

3 Screens 91

4 File Handling 153

5 BAPI (Business Application Programming Interfaces) 197

6 LSMW (Legacy System Migration Workbench) 217

7 Smartforms 229

8 Enhancements 254

9 ABAP/SAP QUERY 287

P a g e 2 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

RICEF
RICEF full form:
o R – Reports.
o I – Interfaces (Bapi’s, Rfc’s, Webservices).
o C – Conversions (BDC, LSMW, etc).
o E – Enhancements (Customer, exits, Badi’s, Enhancement Frame Work).
o F – Smartforms, Adobe forms.

Report: It is used to retrieve or fetch data from database tables and display it to
the user in user understandable format.
There are different types of Reports:
1) Classical ALV Report.
2) Interactive ALV Report or Drill Down Report.
3) Group Report.
4) Report with Logical database.

1) Classical ALV report: It is an abap program which generates a single output


screen called as ALV grid with complete detailed information is called as Classical
ALV report.
• An ALV Report is developed with the help of standard function modules
which takes very less time to develop it.
• The output screen called as ALV grid generated with the help of ALV report
will have different output options such as sort, sum, subtotal, grand total,
ascending/descending orders, filter, export to excel etc.
• The look and feel of the output screen generated by ALV Report is very good
so that user can do the analysis more easily.
• Report program is an executable Program and it is a program type 1.
Reports has following events in sequence:
* Load Program.
1) Initialization.
2) At selection-screen output.
3) At selection-screen.
4) At selection-screen on <f>.
5) At selection-screen on value-request for <f>.

P a g e 3 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

6) At selection-screen on help-request for <f>.


7) Start-of-selection.
8) End-of-selection.
9) Top-of-page.
10) End-of-page.
Load Program: First event triggered by the system to load the program into
memory.
1) Initialization: This event is triggered before the selection-screen is
displayed and it is used to initialize the values of selection-screen fields.
2) At selection-screen output: This event is triggered whenever you change
the properties of the selection-screen elements such as disable, invisible,
mandatory, etc.
3) At selection-screen: This event is triggered when the user enters data onto
selection-screen fields and click on pushbutton. This event is generally used
to validate the data entered onto selection-screen fields.
4) At selection-screen on <f>: This event is triggered when the user enters
data onto a particular selection-screen field and used to validate that
particular field.
5) At selection-screen on value-request for <f>: This event is triggered when
user press F4 function key on selection-screen field which is used to display
custom list of values by avoiding standard list of values.
6) At selection-screen on help-request for <f>: This event is triggered when
user press F1 function key on selection-screen field which is used to display
custom help documentation by avoiding standard help documentation.
7) Start-of-selection: This event is triggered when the user starts fetching or
selecting data from database tables. This is first event triggered for output
screen(list).
8) End-of-selection: This event is triggered when fetching of data from
database tables is ended and it helps the user to display the fetched data
onto output screen(list).
9) Top-of-page: This event is triggered when top of the page is reached and
it is used to display page and column headings.
10) End-of-page: This event is triggered when end of page is reached and it
is used to display footer data.

P a g e 4 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

Standard Function keys are:


F1- Help.
F2- Double click.
F3- Back.
F4- List of values or possible entries.
F11- Save (ctrl+s).
F12- Cancel.

Note: Screen: It is a standard structure in abap dictionary which contains


group of fields but acts as an internal table with the statement loop at screen
in the event ‘At selection-screen output’ (PBO).

Reuse ALV_grid_display: This is a standard function module used to display


data in tabular format onto output screen ALV grid with different options
such as sort, filter, sum, etc.

*sy-repid = contains a current program name.


*Field catalog: it contains the field descriptions of the fields to be considered
for the list output (alv grid)

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'


EXPORTING
I_CALLBACK_PROGRAM=provide program name which calls this function m
odule(sy-repid)
I_STRUCTURE_NAME = provide abap dictionary structure with which syste
m generates fieldcatalog(fields of output screen).It is optional if ‘it_fieldcat’
is used.
I_GRID_TITLE= provide title which is displayed onto output screen(alv grid
)
IT_FIELDCAT = is an internal table with field descriptions or field labels ont
o output screen(alv grid)
TABLES
T_OUTTAB= provide an internal table whose data is displayed onto output
screen(alv gid).

P a g e 5 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

Field catalog: It is used to design the columns or output fields of output screen
(alv grid) by providing the properties for each column or field such as column
position, column name, column as sum, column without leading zero's,
column as left or right or centred, etc.
SLIS: It is a built-in type group which contains group of data types and constants.
Such as:
types: slis_t_fieldcat_alv type slis_fieldcat_alv occurs 1.

Example:
REPORT ZCLASICAL_ALV_REPORT.

*to creates implicit work area.


tables: sscrfields, mara.
**to create internal table referring to mara structure
data it_mara type table of mara.

*to create range of input fields onto selection-screen


select-options s_matnr for mara-matnr.

*to create blank lines onto selection-screen


selection-screen skip 3.

*to create pushbuttons onto selection-screen


selection-screen PUSHBUTTON :/10(10) push1 USER-COMMAND FCT1,
40(10) push2 USER-COMMAND FCT2.
*to create pushbuttons onto application toolbar of selection-screen
selection-screen FUNCTION KEY:1,2.

initialization.
s_matnr-low = '100-100'.
s_matnr-high = '100-800'.
append s_matnr.
push1 = 'Display'.
Push2 = 'Exit'.
sscrfields-functxt_01 = 'Print'.
sscrfields-functxt_02 = 'Leave'.

at SELECTION-SCREEN .
if sscrfields-ucomm = 'FCT1' or sscrfields-ucomm = 'FC01'.
P a g e 6 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

sscrfields-ucomm = 'ONLI'.
elseif sscrfields-ucomm = 'FCT2' or sscrfields-ucomm = 'FC02'.
leave program.
endif.

start-OF-SELECTION.
perform fetch_data.

end-of-SELECTION.
perform display_data.

*to get data from database table -mara


form fetch_data.
** to get data from database table mara into internal table it_mara
select * from mara into table it_mara where matnr in s_matnr.
endform.

*to display data onto output list-alv grid


form display_data.
**Reuse_alv_grid_display: is used to display data onto alv grid
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
I_STRUCTURE_NAME = 'MARA'
I_GRID_TITLE = 'Material Master data'
TABLES
T_OUTTAB = it_mara
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.

endform.
Wa_fcat-emphasize = ‘CXYZ’.
C->constant
X->color(1-7)
y->intensified(1->active,0->inactive):it applies background.
z->inverse(1->enable,0->disable):it applies to alphabets.
P a g e 7 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

Example-2: Classical ALV Report.


REPORT ZCLASICAL_ALV_REPORT1.

*to creates implicit work area.


tables: sscrfields, mara.

*to include type group-slis


type-pools slis.

*to create line type with some fields of mara


types:BEGIN OF line_type,
MATNR type MATNR,
ERSDA type ERSDA,
ERNAM type ERNAM,
MTART type MTART,
MBRSH type MBRSH,
MATKL type MATKL,
MEINS type MEINS,
end of line_type.
**to create internal table referring to mara structure
data it_mara type table of line_type.

*to create work area referring to line_type


data wa_mara type line_type.

*to create internal table it_fcat of structure slis_fieldcat_alv


data it_fcat type table of slis_fieldcat_alv.

*to create work area of structure slis_fieldcat_alv


data wa_fcat type slis_fieldcat_alv.

*to create range of input fields onto selection-screen


select-options s_matnr for mara-matnr.

*to create blank lines onto selection-screen


selection-screen skip 3.

*to create pushbuttons onto selection-screen


selection-screen PUSHBUTTON :/10(10) push1 USER-COMMAND FCT1,
40(10) push2 USER-COMMAND FCT2.
P a g e 8 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

*to create pushbuttons onto application toolbar of selection-screen


selection-screen FUNCTION KEY:1,2.

initialization.
s_matnr-low = '100-100'.
s_matnr-high = '100-800'.
append s_matnr.
push1 = 'Display'.
Push2 = 'Exit'.
sscrfields-functxt_01 = 'Print'.
sscrfields-functxt_02 = 'Leave'.

at SELECTION-SCREEN .
if sscrfields-ucomm = 'FCT1' or sscrfields-ucomm = 'FC01'.
sscrfields-ucomm = 'ONLI'.
elseif sscrfields-ucomm = 'FCT2' or sscrfields-ucomm = 'FC02'.
leave program.
endif.

start-OF-SELECTION.
perform fetch_data.
perform build_fcat.

end-of-SELECTION.
perform display_data.

*to get data from database table -mara


form fetch_data.
** to get data from database table mara into internal table it_mara
select matnr ersda ernam mtart mbrsh matkl meins from mara into table it_
mara where matnr in s_matnr.

endform.

***to build fieldcatalog


form build_fcat.
*to define properties for columns of output screen(alv grid)
P a g e 9 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

** row_pos like sy-curow, " output in row


** col_pos like sy-cucol, " position of the column
** fieldname type slis_fieldname,
** tabname type slis_tabname,
** currency(5) type c,
** cfieldname type slis_fieldname, " field with currency unit
** ctabname type slis_tabname, " and table
** ifieldname type slis_fieldname, " initial column
** quantity(3) type c,
** qfieldname type slis_fieldname, " field with quantity unit
** qtabname type slis_tabname, " and table
** round type i, " round in write statement
** exponent(3) type c, " exponent for floats
** key(1) type c, " column with key-color
** icon(1) type c, " as icon
** symbol(1) type c, " as symbol
** checkbox(1) type c, " as checkbox
** just(1) type c, " (R)ight (L)eft (C)ent.
** lzero(1) type c, " leading zero
** no_sign(1) type c, " write no-sign
** no_zero(1) type c, " write no-zero
** no_convext(1) type c,
** edit_mask type slis_edit_mask, "
** emphasize(4) type c, " emphasize
** fix_column(1) type c, " Spalte fixieren
** do_sum(1) type c, " sum up
** no_out(1) type c, " (O)blig.(X)no out
** tech(1) type c, " technical field
** outputlen like dd03p-outputlen,
** offset type dd03p-outputlen, " offset
** seltext_l like dd03p-scrtext_l, " long key word
** seltext_m like dd03p-scrtext_m, " middle key word
** seltext_s like dd03p-scrtext_s, " short key word
** ddictxt(1) type c, " (S)hort (M)iddle (L)ong
** rollname like dd03p-rollname,
** datatype like dd03p-datatype,
** inttype like dd03p-inttype,
** intlen like dd03p-intlen,
** lowercase like dd03p-lowercase,

P a g e 10 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

**1st column-MATNR
wa_fcat-row_pos = 1.
wa_fcat-col_pos = 1.
wa_fcat-fieldname = 'MATNR'.
wa_fcat-tabname = 'IT_MARA'.
wa_fcat-just = 'L'.
wa_fcat-seltext_s = 'Matnr'.
wa_fcat-seltext_m = 'Material'.
wa_fcat-seltext_l = 'Material Number'.
append wa_fcat to it_fcat.

clear wa_fcat.
wa_fcat-row_pos = 1.
wa_fcat-edit_mask = '__/__/____'.
wa_fcat-col_pos = 2.
wa_fcat-fieldname = 'ERSDA'.
wa_fcat-tabname = 'IT_MARA'.
wa_fcat-just = 'R'.
wa_fcat-seltext_s = 'Created'.
wa_fcat-seltext_m = 'Created On'.
wa_fcat-seltext_l = 'Created On '.
wa_fcat-emphasize = 'C511'.
append wa_fcat to it_fcat.

clear wa_fcat.
wa_fcat-row_pos = 1.
wa_fcat-col_pos = 3.
wa_fcat-fieldname = 'ERNAM'.
wa_fcat-tabname = 'IT_MARA'.
wa_fcat-just = 'R'.
wa_fcat-seltext_s = 'Person '.
wa_fcat-seltext_m = 'Created By'.
wa_fcat-seltext_l = 'Created By '.
wa_fcat-outputlen = '20'.
wa_fcat-emphasize = 'C710'.
append wa_fcat to it_fcat.

clear wa_fcat.
wa_fcat-row_pos = 1.
P a g e 11 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

wa_fcat-col_pos = 4.
wa_fcat-fieldname = 'MTART'.
wa_fcat-tabname = 'IT_MARA'.
wa_fcat-just = 'R'.
wa_fcat-seltext_s = 'Mtype'.
wa_fcat-seltext_m = 'Material type'.
wa_fcat-emphasize = 'C601'.

* wa_fcat-seltext_l = 'Created On '.


append wa_fcat to it_fcat.

clear wa_fcat.
wa_fcat-row_pos = 1.
wa_fcat-col_pos = 5.
wa_fcat-fieldname = 'MBRSH'.
wa_fcat-tabname = 'IT_MARA'.
wa_fcat-just = 'C'.
wa_fcat-seltext_s = 'Industry'.
wa_fcat-seltext_m = 'Industry Sect'.
wa_fcat-seltext_l = 'Industry Sector'.
append wa_fcat to it_fcat.

clear wa_fcat.
wa_fcat-row_pos = 1.
wa_fcat-col_pos = 6.
wa_fcat-fieldname = 'MATKL'.
wa_fcat-tabname = 'IT_MARA'.
wa_fcat-just = 'R'.
wa_fcat-seltext_s = 'Mat Grp'.
wa_fcat-seltext_m = 'Material group'.
wa_fcat-seltext_l = 'Material Group'.
append wa_fcat to it_fcat.

clear wa_fcat.
wa_fcat-row_pos = 1.
wa_fcat-col_pos = 7.
wa_fcat-fieldname = 'MEINS'.
wa_fcat-tabname = 'IT_MARA'.
wa_fcat-just = 'R'.
P a g e 12 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

wa_fcat-seltext_s = 'Uom'.
wa_fcat-seltext_m = 'Unit Measurement'.
wa_fcat-seltext_l = 'Unit of Measurement'.
append wa_fcat to it_fcat.

endform.

*to display data onto output list-alv grid


form display_data.
**Reuse_alv_grid_display: is used to display data onto alv grid
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_GRID_TITLE = 'Material Information'
IT_FIELDCAT = IT_FCAT
TABLES
T_OUTTAB = it_mara
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.

endform.

Note: As of release 6.40, you can avoid ‘SLIS’ ALV library to be included in abap
ALV Reporting, directly you can access data types and constants of type group:
Slis without including it with type-pools slis.

To build fieldcatalog automatically using function module:

Reuse_alv_fieldcatalog_merge:
This function module is used to build fieldcatalog(fields of output screen) auto
matically with the help of abap dictionary structure or internal table.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'


EXPORTING
I_PROGRAM_NAME = Provide program name which calls the function(sy-
repid)
P a g e 13 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

I_INTERNAL_TABNAME = provide internal table name with which system buil


ds fieldcatalog(output fields of alv grid)
I_STRUCTURE_NAME = provide abap dictionary structure with which system
builds fieldcatalog.
I_INCLNAME = provide an abap program name where internal table is declare
d
CHANGING
CT_FIELDCAT = provide an internal table it_fcat of structure slis_t_fieldcat_al
v
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.

Note: When you use FM: ‘Reuse_alv_fieldcatalog_merge’ then you will get 2
errors as the following runtime errors(dump), so to void that dump, do the
following settings:

1) First dump or runtime error:

P a g e 14 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

Solution:
➢ Go with Tcode: SE38.
➢ Provide an existing report program name: ZCLASICAL_ALV_REPORT2.
➢ Click on ‘change’ button.
➢ Go with menu option: Utilities->settings.

2) Second dump or runtime Error:

Solution:
The internal table (it_mara) you pass to this function module
‘reuse_alv_fieldcatalog_merge’ with which fieldcatalog is generated should
have its fields created with ‘Like’ keyword but not ‘type’ keyword.

P a g e 15 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

Example:
REPORT ZCLASICAL_ALV_REPORT2.

*to creates implicit work area.


tables:sscrfields, mara.

*to include type group-slis


*type-pools slis. Note : From Netweaver 7.4 onwards ,you can avoid
*type-pools slis, as SAP directly considers type group components.

*to create line type with some fields of mara


*types:BEGIN OF line_type,
* MATNR type MATNR,
* ERSDA type ERSDA,
* ERNAM type ERNAM,
* MTART type MTART,
* MBRSH type MBRSH,
* MATKL type MATKL,
* MEINS type MEINS,
* end of line_type.
data:BEGIN OF it_mara OCCURS 0,
MATNR like mara-MATNR,
ERSDA like mara-ERSDA,
ERNAM like mara-ERNAM,
MTART like mara-MTART,
MBRSH like mara-MBRSH,
MATKL like mara-MATKL,
MEINS like mara-MEINS,
end of it_mara.

*to create work area referring to line_type


data wa_mara type line_type.

*to create internal table it_fcat of structure slis_fieldcat_alv


*data it_fcat type table of slis_fieldcat_alv.
data it_fcat type slis_t_fieldcat_alv.

*to create work area of structure slis_fieldcat_alv


P a g e 16 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

data wa_fcat type slis_fieldcat_alv.

*to create range of input fields onto selection-screen


select-options s_matnr for mara-matnr.

*to create blank lines onto selection-screen


selection-screen skip 3.

*to create pushbuttons onto selection-screen


selection-screen PUSHBUTTON :/10(10) push1 USER-COMMAND FCT1,
40(10) push2 USER-COMMAND FCT2.
*to create pushbuttons onto application toolbar of selection-screen
selection-screen FUNCTION KEY:1,2.

initialization.
s_matnr-low = '100-100'.
s_matnr-high = '100-800'.
append s_matnr.
push1 = 'Display'.
Push2 = 'Exit'.
sscrfields-functxt_01 = 'Print'.
sscrfields-functxt_02 = 'Leave'.

at SELECTION-SCREEN .
if sscrfields-ucomm = 'FCT1' or sscrfields-ucomm = 'FC01'.
sscrfields-ucomm = 'ONLI'.
elseif sscrfields-ucomm = 'FCT2' or sscrfields-ucomm = 'FC02'.
leave program.
endif.

start-OF-SELECTION.
perform fetch_data.
perform build_fcat_automatically.

end-of-SELECTION.
perform display_data.

*to get data from database table -mara


form fetch_data.
P a g e 17 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

** to get data from database table mara into internal table it_mara
select matnr ersda ernam mtart mbrsh matkl meins from mara into table
it_mara where matnr in s_matnr.

endform.

***to build fieldcatalog


form build_fcat_automatically.
*to define properties for columns of output screen(alv grid)
*Reuse_alv_fieldcatalog_merge:This function module is used to build
*fieldcatalog(fields of output screen) automatically with the help of
*abap dictionary structure or internal
* table.
***CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
*** EXPORTING
*** I_PROGRAM_NAME = Provide program name which calls
*the function(sy-repid)
*** I_INTERNAL_TABNAME = provide internal table name with
*which system builds fieldcatalog(output fields of alv grid)
*** I_STRUCTURE_NAME = provide abap dictionary structure
*with which system builds fieldcatalog.
*** I_INCLNAME = provide an abap program name where
*internal table is declared
*** CHANGING
*** CT_FIELDCAT = provide an internal table it_fcat
*of structure slis_t_fieldcat_alv
*** EXCEPTIONS
*** INCONSISTENT_INTERFACE =1
*** PROGRAM_ERROR =2
*** OTHERS =3
*** .
***IF SY-SUBRC <> 0.
**** Implement suitable error handling here
***ENDIF.

CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'


EXPORTING
I_PROGRAM_NAME = sy-repid
P a g e 18 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

I_INTERNAL_TABNAME = 'IT_MARA'
* I_STRUCTURE_NAME =
I_INCLNAME = sy-repid
CHANGING
CT_FIELDCAT = it_fcat
* EXCEPTIONS
* INCONSISTENT_INTERFACE =1
* PROGRAM_ERROR = 2
* OTHERS =3
.
IF SY-SUBRC = 0.
loop at it_fcat into wa_fcat.

case wa_fcat-fieldname.
when 'MATNR'.
WA_FCAT-JUST = 'C'.
WHEN 'ERSDA'.
WA_FCAT-EDIT_MASK = '__/__/____'.
WHEN 'ERNAM'.
WA_FCAT-OUTPUTLEN = 22.
WHEN 'MTART'.
WA_FCAT-EMPHASIZE = 'C601'.
endcase.
MODIFY IT_FCAT FROM WA_FCAT.
endloop.
ENDIF.

endform.

*to display data onto output list-alv grid


form display_data.
**Reuse_alv_grid_display: is used to display data onto alv grid
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_GRID_TITLE = 'Material Information'
IT_FIELDCAT = IT_FCAT
TABLES
T_OUTTAB = it_mara
EXCEPTIONS
P a g e 19 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.

endform.

Text Elements: It is used to provide text as labels for selection-screen elements


and also onto output screen list.
Different text elements are:
1) List heading.
2) Column heading.
3) Selection text.
4) Text symbols.

1) List Heading: It is used to provide headings for the output screen called as list.
2) Column heading: It is used to provide headings for the columns of output
screen(list).
3) Selection text: It is used to provide labels for the input fields, checkbox and
radio buttons of selection-screen.
4) Text symbols: It is a 3-character id which is maintained outside of an abap
program for the literals which are hard coded in an abap program, in order to
make an abap program language independent.

Steps to create selection text and text symbols:


➢ Tcode: SE38.
➢ Provide program name: ZCLASICAL_ALV_REPORT2.
➢ Click on ‘change’ button.
➢ Go with menu option: goto->text elements->selection texts.
➢ Opens a screen: Provide the labels as follows:

➢ Activate(ctrl+f3).

P a g e 20 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Click on ‘text symbols’ tab button and provide the text as follows:

➢ Activate(ctrl+f3).

ALV Interactive Report: It is an abap program which generates a limited


information onto 1st ALV grid from where user calls further information onto
second ALV grid by double clicking or selecting pushbutton.
To handle Events in ALV Reports: When the user double clicks or selects
pushbutton or menu item onto ALV grid then the event triggered is
‘User_command’ and its respective subroutine is called and executed by the
system by passing two parameters to subroutine such as function code and work
area of structure slis_selfield which has group of fields such as tabindex,
fieldname, value, etc.
Note: when the user double clicks on output screen (ALV Grid) then its function
code is ‘&IC1’.

Tcode: SE41: MENU PAINTER: It is used to create GUI (Graphical user interface)
or Status which contains menu bar with different menu options, pushbuttons on
application toolbar, etc, so that user can more easily interact with the screen.
Some of the ALV events are:
USER_COMMAND,PF_STATUS_SET,TOP_OF_PAGE,ETC.
Note: To trigger events in ALV Reports, you need to activate them by passing
subroutine to the events in the function module ‘Reuse_alv_grid_display’ then
whenever event is triggered their respective subroutine is automatically called
and executed.

USER_COMMAND: It is an event triggered when the user double clicks or select


pushbutton on output screen ALV grid in order to get further data onto next ALV
grid.
PF_STATUS_SET: It is an event used to attach GUI or Status to the output screen
(ALV Grid). So that user can interact with the output screen. The statement to
attach GUI or Status to output screen(ALV grid) is
set pf-status <gui_name> [excluding <fcodes>]

P a g e 21 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

[Excluding <fcodes>]: This option is used to remove or exclude the pushbuttons


or menu items from GUI or Status.
TOP_OF_PAGE: It is an event triggered by the system which is used to display
page heading and logo onto output screen(ALV Grid).
Whenever the events such as ‘USER_COMMAND’, ‘PF_STATUS_SET’ AND
‘TOP_OF_PAGE’ are triggered then their respective subroutines are
automatically called by the system and set of statements in that subroutine gets
executed.

Reuse_alv_commentary_write: This function module is used to display list


heading and logo onto top of page of output screen (ALV grid).
Note: ‘Hotspot’ property if used in fieldcatalog makes user single click as double
click.
wa_fcat-hotspot = 'X'.

conversion routines: It is used to convert data from display format to internal


format and vice versa.
CONVERSION_EXIT_MATN1_OUTPUT: This function module is used to convert
internal format data (here it is in leading zero's which are removed)
to display format.
CONVERSION_EXIT_MATN1_INPUT:
This function module is used to convert display format data
(here it adds leading zero's) to internal format.
Example: material number: 000000000000000023(this is internal format)
Material number: 23(display format or external format)

CALL FUNCTION 'CONVERSION_EXIT_MATN1_OUTPUT'


EXPORTING
INPUT = wa_mara-matnr
IMPORTING
OUTPUT = wa_mara-matnr.

Variant: It is used to store set of values of range of input fields of selection-


screen.
Note: Variant helps the user to schedule a report program in background.

Steps to create variant:


➢ Tcode: SE38.
➢ Provide program name: ZINTERACTIVE_ALV_REPORT1.
P a g e 22 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Click on execute button(F8).


➢ Provide some values to the input fields of selection-screen as follows:

➢ Click on save (ctrl+s).


➢ Provide variant name as follows:

➢ Save it.

Steps to upload logo or image in order to include in ALV Report:


➢ Tcode: OAER.
➢ Provide the details as follows:

➢ Note: ‘VITLOGO’ is an image or logo which need to be created or made


available from client(business) and should be a bmp image.
➢ Click on execute button.
➢ Expand ‘standard [Link]’.
➢ Double click on ‘screen’ and browse and select your logo for uploading into
SAP and enter.
Example: Interactive ALV Report

P a g e 23 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

REPORT ZINTERACTIVE_ALV_REPORT1.
*to creates implicit work area.
tables: sscrfields, mara.

*to include type group-slis


*type-pools slis.

*to create line type with some fields of mara


types:BEGIN OF line_type,
MATNR like mara-MATNR,
ERSDA type ERSDA,
ERNAM type ERNAM,
MTART type MTART,
MBRSH type MBRSH,
MATKL type MATKL,
MEINS type MEINS,
end of line_type.

**to create marc line type with some fields


types:begin of marc_type,
matnr type matnr,
werks type werks_d,
ekgrp type ekgrp,
minbe type minbe,
bistmi type bstmi,
end of marc_type.
**to create internal table referring to mara structure
data it_mara type table of line_type.

*to create work area referring to line_type


data wa_mara type line_type.

*to create internal table it_marc of structure marc_type,


data it_marc type table of marc_type.

*to create internal table it_fcat of structure slis_fieldcat_alv


data it_fcat type table of slis_fieldcat_alv.

*to create work area of structure slis_fieldcat_alv


data wa_fcat type slis_fieldcat_alv.
P a g e 24 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

*to create internal table it_fcat2 of structure slis_fieldcat_alv


data it_fcat2 type table of slis_fieldcat_alv.

*to create range of input fields onto selection-screen


select-options s_matnr for mara-matnr.

*to create blank lines onto selection-screen


selection-screen skip 3.

*to create pushbuttons onto selection-screen


selection-screen PUSHBUTTON :/10(10) push1 USER-COMMAND FCT1,
40(10) push2 USER-COMMAND FCT2.
*to create pushbuttons onto application toolbar of selection-screen
selection-screen FUNCTION KEY:1,2.

initialization.
s_matnr-low = '100-100'.
s_matnr-high = '100-800'.
append s_matnr.
push1 = 'Display'.
Push2 = 'Exit'.
sscrfields-functxt_01 = 'Print'.
sscrfields-functxt_02 = 'Leave'.

at SELECTION-SCREEN .
if sscrfields-ucomm = 'FCT1' or sscrfields-ucomm = 'FC01'.
sscrfields-ucomm = 'ONLI'.
elseif sscrfields-ucomm = 'FCT2' or sscrfields-ucomm = 'FC02'.
leave program.
endif.

start-OF-SELECTION.
perform fetch_data.
perform build_fcat.

end-of-SELECTION.
perform display_data.

P a g e 25 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

*to get data from database table -mara


form fetch_data.
refresh it_mara.
** to get data from database table mara into internal table it_mara
select matnr ersda ernam mtart mbrsh matkl meins from mara into table it_m
ara where matnr in s_matnr.

endform.

***to build fieldcatalog


form build_fcat.
refresh it_fcat.
**1st column-MATNR
wa_fcat-row_pos = 1.
wa_fcat-col_pos = 1.
wa_fcat-fieldname = 'MATNR'.
wa_fcat-tabname = 'IT_MARA'.
wa_fcat-just = 'L'.
wa_fcat-outputlen = 20.
wa_fcat-seltext_s = 'Matnr'.
wa_fcat-seltext_m = 'Material'.
wa_fcat-seltext_l = 'Material Number'.
wa_fcat-hotspot = 'X'.
append wa_fcat to it_fcat.

clear wa_fcat.
wa_fcat-row_pos = 1.
wa_fcat-edit_mask = '__/__/____'.
wa_fcat-col_pos = 2.
wa_fcat-fieldname = 'ERSDA'.
wa_fcat-tabname = 'IT_MARA'.
wa_fcat-just = 'R'.
wa_fcat-seltext_s = 'Created'.
wa_fcat-seltext_m = 'Created On'.
wa_fcat-seltext_l = 'Created On '.
wa_fcat-emphasize = 'C511'.
append wa_fcat to it_fcat.

P a g e 26 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

clear wa_fcat.
wa_fcat-row_pos = 1.
wa_fcat-col_pos = 3.
wa_fcat-fieldname = 'ERNAM'.
wa_fcat-tabname = 'IT_MARA'.
wa_fcat-just = 'R'.
wa_fcat-seltext_s = 'Person '.
wa_fcat-seltext_m = 'Created By'.
wa_fcat-seltext_l = 'Created By '.
wa_fcat-outputlen = '20'.
wa_fcat-emphasize = 'C710'.
append wa_fcat to it_fcat.

clear wa_fcat.
wa_fcat-row_pos = 1.
wa_fcat-col_pos = 4.
wa_fcat-fieldname = 'MTART'.
wa_fcat-tabname = 'IT_MARA'.
wa_fcat-just = 'R'.
wa_fcat-seltext_s = 'Mtype'.
wa_fcat-seltext_m = 'Material type'.
wa_fcat-emphasize = 'C601'.

* wa_fcat-seltext_l = 'Created On '.


append wa_fcat to it_fcat.

clear wa_fcat.
wa_fcat-row_pos = 1.
wa_fcat-col_pos = 5.
wa_fcat-fieldname = 'MBRSH'.
wa_fcat-tabname = 'IT_MARA'.
wa_fcat-just = 'C'.
wa_fcat-seltext_s = 'Industry'.
wa_fcat-seltext_m = 'Industry Sect'.
wa_fcat-seltext_l = 'Industry Sector'.
append wa_fcat to it_fcat.

clear wa_fcat.
wa_fcat-row_pos = 1.
P a g e 27 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

wa_fcat-col_pos = 6.
wa_fcat-fieldname = 'MATKL'.
wa_fcat-tabname = 'IT_MARA'.
wa_fcat-just = 'R'.
wa_fcat-seltext_s = 'Mat Grp'.
wa_fcat-seltext_m = 'Material group'.
wa_fcat-seltext_l = 'Material Group'.
append wa_fcat to it_fcat.

clear wa_fcat.
wa_fcat-row_pos = 1.
wa_fcat-col_pos = 7.
wa_fcat-fieldname = 'MEINS'.
wa_fcat-tabname = 'IT_MARA'.
wa_fcat-just = 'R'.
wa_fcat-seltext_s = 'Uom'.
wa_fcat-seltext_m = 'Unit Measurement'.
wa_fcat-seltext_l = 'Unit of Measurement'.
append wa_fcat to it_fcat.

endform.

*to display data onto output list-alv grid


form display_data.
**Reuse_alv_grid_display: is used to display data onto alv grid
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_USER_COMMAND = 'HANDLE_DCLICK'
I_CALLBACK_TOP_OF_PAGE = 'PAGE_HEADING'
I_GRID_TITLE = 'Material Information'
IT_FIELDCAT = IT_FCAT
TABLES
T_OUTTAB = it_mara
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
P a g e 28 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

ENDIF.

endform.

form HANDLE_DCLICK using v_fcode like sy-ucomm wa type slis_selfield.

case v_fcode.
when '&IC1'.
*to pick material number from where the user double click on 1st alv grid of int
ernal table it_mara
read table it_mara into wa_mara INDEX wa-tabindex.
if sy-subrc = 0.
perform get_marc_data.
perform build_fcat_marc.
perform display_alv_grid2.
endif.
endcase.

endform.

form get_marc_data.
refresh it_marc.
data:str1 type string.
** to get plant data from marc into internal table it_marc.
select matnr werks ekgrp bstmi minbe from marc into TABLE it_marc WHERE
matnr = wa_mara-matnr.
if sy-subrc <> 0.
*conversion routines: is used to convert the data from display format to interna
l format and vice versa.
*CONVERSION_EXIT_MATN1_OUTPUT: this function module is used to convert i
nternal format data(here it is in leading zero's) to display format
CALL FUNCTION 'CONVERSION_EXIT_MATN1_OUTPUT'
EXPORTING
INPUT = wa_mara-matnr
IMPORTING
OUTPUT = wa_mara-matnr
.

P a g e 29 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

concatenate 'Plant data not found for material-' wa_mara-matnr into str1.
message str1 type 'I'.
leave program.
endif.
endform.

form build_fcat_marc.
refresh it_fcat2.
**1st column-MATNR
clear wa_fcat.
wa_fcat-col_pos = 1.
wa_fcat-fieldname = 'MATNR'.
wa_fcat-tabname = 'IT_MARC'.
wa_fcat-just = 'L'.
wa_fcat-outputlen = 20.
wa_fcat-seltext_s = 'Matnr'.
wa_fcat-seltext_m = 'Material'.
wa_fcat-seltext_l = 'Material Number'.
append wa_fcat to it_fcat2.

clear wa_fcat.
wa_fcat-col_pos = 2.
wa_fcat-fieldname = 'WERKS'.
wa_fcat-tabname = 'IT_MARC'.
wa_fcat-just = 'L'.
wa_fcat-seltext_s = 'PLANT'.
wa_fcat-seltext_m = 'PLANT'.
* wa_fcat-seltext_l = 'Material Number'.
append wa_fcat to it_fcat2.

clear wa_fcat.
wa_fcat-col_pos = 3.
wa_fcat-fieldname = 'EKGRP'.
wa_fcat-tabname = 'IT_MARC'.
* wa_fcat-just = 'L'.
wa_fcat-seltext_s = 'PURCH GRP'.
wa_fcat-seltext_m = 'PURCHASE GRP'.
wa_fcat-seltext_l = 'PURCHASING GROUP'.
append wa_fcat to it_fcat2.
P a g e 30 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

clear wa_fcat.
wa_fcat-col_pos = 4.
wa_fcat-fieldname = 'MINBE'.
wa_fcat-tabname = 'IT_MARC'.
wa_fcat-seltext_s = 'RE-ORDER POINT'.
wa_fcat-seltext_m = 'RE-ORDER LEVEL'.
* wa_fcat-seltext_l = 'Material Number'.
append wa_fcat to it_fcat2.

clear wa_fcat.
wa_fcat-col_pos = 5.
wa_fcat-fieldname = 'BSTMI'.
wa_fcat-tabname = 'IT_MARC'.
wa_fcat-seltext_s = 'MIN. ORDER QTY'.
wa_fcat-seltext_m = 'MIN. ORDER QUANTITY'.
* wa_fcat-seltext_l = 'Material Number'.
append wa_fcat to it_fcat2.

ENDFORM.

FORM DISPLAY_ALV_GRID2.

*REUSE_ALV_GRID_DISPLAY:IS USED TO DISPLAY DATA ONTO ALV GRID IN TAB


ULAR FORMAT WITH DIFFERENT OUTPUT OPTIONS SUCH AS SUM,FILTER,SORT,
ETC
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
* I_CALLBACK_TOP_OF_PAGE =''
I_GRID_TITLE = 'Plant data for Material'
IT_FIELDCAT = it_fcat2
TABLES
T_OUTTAB = it_marc
EXCEPTIONS
PROGRAM_ERROR =1
OTHERS =2
.
IF SY-SUBRC <> 0.
P a g e 31 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

* Implement suitable error handling here


ENDIF.

ENDFORM.

FORM PAGE_HEADING.

*TO CREATE INTERNAL TABLE IT_LIST OF STRUCTURE SLIS_T_LISTHEADER


DATA IT_LIST TYPE SLIS_T_LISTHEADER WITH HEADER LINE.

*TO FILL INTERNAL TABLE IT_LIST


IT_LIST-TYP = 'H' . "HEADER
IT_LIST-KEY = 'MATNR'.
IT_LIST-INFO = 'Material master data'.
append it_list.

IT_LIST-TYP = 'S'. "selection


IT_LIST-INFO = 'Material data'.
append it_list.

*REUSE_ALV_COMMENTARY_WRITE:THIS FUNCTION IS SEUD TO DISPLAY PAG


E HEADING AND LOGO OR IMAGE ONTO TOP OF PAGE OF ALV GRID
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LIST[]
I_LOGO = 'VITLOGO1' "'ENJOYSAP_LOGO'
* I_END_OF_LIST_GRID =
* I_ALV_FORM =
.
ENDFORM.

Steps to find the standard GUI or Status of output screen (ALV Grid):
➢ Tcode: SE38.
➢ Provide an existing ALV Report Name:
ZINTERACTIVE_ALV_REPORT_BUTTON
➢ Click on execute button(F8).
➢ Again, click on Execute button(F8).

P a g e 32 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Go with menu option->system->status.


Program (GUI) SAPLKKBL
GUI status STANDARD_FULLSCREEN

Steps to copy the standard GUI of ALV Grid to custom GUI:


➢ Tcode: SE41.
➢ Provide program name and GUI Status as follows:

➢ Click on ‘Status’ button (copy status) from application toolbar.

P a g e 33 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Click on ‘Copy’ button.


➢ Again, click on ‘Copy’ button.
➢ Click on ‘change’ button.
➢ Expand ‘Menu bar’.

➢ Provide ‘Menu1’ and its items as above (display and exit).


➢ Expand ‘APPLICATION TOOLBAR’.

➢ Provide function code: ‘SELE’ and ‘LEAV’ then double click on it.
➢ Opens a screen.

➢ Enter.
➢ Provide the details as follows:
P a g e 34 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Enter 2 times.
➢ Select any function key (as buttons as shortcut key as function key).

➢ Select ‘F7’ and enter.


➢ Similarly provide details for another fcode: LEAV as follows:

➢ Enter.
➢ Provide the following details:

➢ Enter.

P a g e 35 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Select ‘F9’ and enter.


➢ Save (CTRL+S) AND Activate (CTRL+F3).

Example-2: ALV INTERACTIVE REPORT WITH EVENTS


REPORT ZINTERACTIVE_ALV_REPORT_BUTTON.

*to creates implicit work area.


tables:sscrfields, mara.

*to include type group-slis


*type-pools slis.

*to create line type with some fields of mara


types:BEGIN OF line_type,
MATNR like mara-MATNR,
ERSDA type ERSDA,
ERNAM type ERNAM,
MTART type MTART,
MBRSH type MBRSH,
MATKL type MATKL,
MEINS type MEINS,
end of line_type.

**to create marc line type with some fields


types:begin of marc_type,
matnr type matnr,
werks type werks_d,
ekgrp type ekgrp,
P a g e 36 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

minbe type minbe,


bistmi type bstmi,
end of marc_type.
**to create internal table referring to mara structure
data it_mara type table of line_type.

*to create work area referring to line_type


data wa_mara type line_type.

*to create internal table it_marc of structure marc_type,


data it_marc type table of marc_type.

*to create internal table it_fcat of structure slis_fieldcat_alv


data it_fcat type table of slis_fieldcat_alv.

*to create work area of structure slis_fieldcat_alv


data wa_fcat type slis_fieldcat_alv.

*to create internal table it_fcat2 of structure slis_fieldcat_alv


data it_fcat2 type table of slis_fieldcat_alv.

*to create range of input fields onto selection-screen


select-options s_matnr for mara-matnr.

*to create blank lines onto selection-screen


selection-screen skip 3.

*to create pushbuttons onto selection-screen


selection-screen PUSHBUTTON :/10(10) push1 USER-COMMAND FCT1,
40(10) push2 USER-COMMAND FCT2.
*to create pushbuttons onto application toolbar of selection-screen
selection-screen FUNCTION KEY:1,2.

initialization.
s_matnr-low = '100-100'.
s_matnr-high = '100-800'.
append s_matnr.
push1 = 'Display'.
Push2 = 'Exit'.
sscrfields-functxt_01 = 'Print'.
P a g e 37 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

sscrfields-functxt_02 = 'Leave'.

at SELECTION-SCREEN .
if sscrfields-ucomm = 'FCT1' or sscrfields-ucomm = 'FC01'.
sscrfields-ucomm = 'ONLI'.
elseif sscrfields-ucomm = 'FCT2' or sscrfields-ucomm = 'FC02'.
leave program.
endif.

start-OF-SELECTION.
perform fetch_data.
perform build_fcat.

end-of-SELECTION.
perform display_data.

*to get data from database table -mara


form fetch_data.
refresh it_mara.
** to get data from database table mara into internal table it_mara
select matnr ersda ernam mtart mbrsh matkl meins from mara into table it_m
ara where matnr in s_matnr.

endform.

***to build fieldcatalog


form build_fcat.
refresh it_fcat.
**1st column-MATNR
wa_fcat-row_pos = 1.
wa_fcat-col_pos = 1.
wa_fcat-fieldname = 'MATNR'.
wa_fcat-tabname = 'IT_MARA'.
wa_fcat-just = 'L'.
wa_fcat-outputlen = 20.
wa_fcat-seltext_s = 'Matnr'.
wa_fcat-seltext_m = 'Material'.
P a g e 38 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

wa_fcat-seltext_l = 'Material Number'.


* wa_fcat-hotspot = 'X'.
append wa_fcat to it_fcat.

clear wa_fcat.
wa_fcat-row_pos = 1.
wa_fcat-edit_mask = '__/__/____'.
wa_fcat-col_pos = 2.
wa_fcat-fieldname = 'ERSDA'.
wa_fcat-tabname = 'IT_MARA'.
wa_fcat-just = 'R'.
wa_fcat-seltext_s = 'Created'.
wa_fcat-seltext_m = 'Created On'.
wa_fcat-seltext_l = 'Created On '.
wa_fcat-emphasize = 'C511'.
append wa_fcat to it_fcat.

clear wa_fcat.
wa_fcat-row_pos = 1.
wa_fcat-col_pos = 3.
wa_fcat-fieldname = 'ERNAM'.
wa_fcat-tabname = 'IT_MARA'.
wa_fcat-just = 'R'.
wa_fcat-seltext_s = 'Person '.
wa_fcat-seltext_m = 'Created By'.
wa_fcat-seltext_l = 'Created By '.
wa_fcat-outputlen = '20'.
wa_fcat-emphasize = 'C710'.
append wa_fcat to it_fcat.

clear wa_fcat.
wa_fcat-row_pos = 1.
wa_fcat-col_pos = 4.
wa_fcat-fieldname = 'MTART'.
wa_fcat-tabname = 'IT_MARA'.
wa_fcat-just = 'R'.
wa_fcat-seltext_s = 'Mtype'.
wa_fcat-seltext_m = 'Material type'.
wa_fcat-emphasize = 'C601'.
P a g e 39 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

* wa_fcat-seltext_l = 'Created On '.


append wa_fcat to it_fcat.

clear wa_fcat.
wa_fcat-row_pos = 1.
wa_fcat-col_pos = 5.
wa_fcat-fieldname = 'MBRSH'.
wa_fcat-tabname = 'IT_MARA'.
wa_fcat-just = 'C'.
wa_fcat-seltext_s = 'Industry'.
wa_fcat-seltext_m = 'Industry Sect'.
wa_fcat-seltext_l = 'Industry Sector'.
append wa_fcat to it_fcat.

clear wa_fcat.
wa_fcat-row_pos = 1.
wa_fcat-col_pos = 6.
wa_fcat-fieldname = 'MATKL'.
wa_fcat-tabname = 'IT_MARA'.
wa_fcat-just = 'R'.
wa_fcat-seltext_s = 'Mat Grp'.
wa_fcat-seltext_m = 'Material group'.
wa_fcat-seltext_l = 'Material Group'.
append wa_fcat to it_fcat.

clear wa_fcat.
wa_fcat-row_pos = 1.
wa_fcat-col_pos = 7.
wa_fcat-fieldname = 'MEINS'.
wa_fcat-tabname = 'IT_MARA'.
wa_fcat-just = 'R'.
wa_fcat-seltext_s = 'Uom'.
wa_fcat-seltext_m = 'Unit Measurement'.
wa_fcat-seltext_l = 'Unit of Measurement'.
append wa_fcat to it_fcat.

endform.

P a g e 40 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

*to display data onto output list-alv grid


form display_data.
**Reuse_alv_grid_display: is used to display data onto alv grid
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = 'HANDLE_GUI'
I_CALLBACK_USER_COMMAND = 'HANDLE_DCLICK'
I_CALLBACK_TOP_OF_PAGE = 'PAGE_HEADING'
I_GRID_TITLE = 'Material Information'
IT_FIELDCAT = IT_FCAT
TABLES
T_OUTTAB = it_mara
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.

endform.

form HANDLE_DCLICK using v_fcode like sy-ucomm wa type slis_selfield.

case v_fcode.
when '&IC1' OR 'SELE' OR 'COD1'.
*to pick material number from where the user double click on 1st alv grid of int
ernal table it_mara
read table it_mara into wa_mara INDEX wa-tabindex.
if sy-subrc = 0.
perform get_marc_data.
perform build_fcat_marc.
perform display_alv_grid2.
endif.
WHEN 'COD2' OR 'LEAV'.
LEAVE TO SCREEN 0.
endcase.

P a g e 41 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

endform.

form get_marc_data.
refresh it_marc.
data:str1 type string.
** to get plant data from marc into internal table it_marc.
select matnr werks ekgrp bstmi minbe from marc into TABLE it_marc WHERE
matnr = wa_mara-matnr.
if sy-subrc <> 0.
*conversion routines: is used to convert the data from display format to interna
l format and vice versa.
*CONVERSION_EXIT_MATN1_OUTPUT: this function module is used to convert i
nternal format data(here it is in leading zero's) to display format
CALL FUNCTION 'CONVERSION_EXIT_MATN1_OUTPUT'
EXPORTING
INPUT = wa_mara-matnr
IMPORTING
OUTPUT = wa_mara-matnr
.

concatenate 'Plant data not found for material-' wa_mara-matnr into str1.
message str1 type 'I'.
leave program.
endif.
endform.

form build_fcat_marc.
refresh it_fcat2.
**1st column-MATNR
clear wa_fcat.
wa_fcat-col_pos = 1.
wa_fcat-fieldname = 'MATNR'.
wa_fcat-tabname = 'IT_MARC'.
wa_fcat-just = 'L'.
wa_fcat-outputlen = 20.
wa_fcat-seltext_s = 'Matnr'.
wa_fcat-seltext_m = 'Material'.
wa_fcat-seltext_l = 'Material Number'.
append wa_fcat to it_fcat2.

P a g e 42 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

clear wa_fcat.
wa_fcat-col_pos = 2.
wa_fcat-fieldname = 'WERKS'.
wa_fcat-tabname = 'IT_MARC'.
wa_fcat-just = 'L'.
wa_fcat-seltext_s = 'PLANT'.
wa_fcat-seltext_m = 'PLANT'.
* wa_fcat-seltext_l = 'Material Number'.
append wa_fcat to it_fcat2.

clear wa_fcat.
wa_fcat-col_pos = 3.
wa_fcat-fieldname = 'EKGRP'.
wa_fcat-tabname = 'IT_MARC'.
* wa_fcat-just = 'L'.
wa_fcat-seltext_s = 'PURCH GRP'.
wa_fcat-seltext_m = 'PURCHASE GRP'.
wa_fcat-seltext_l = 'PURCHASING GROUP'.
append wa_fcat to it_fcat2.

clear wa_fcat.
wa_fcat-col_pos = 4.
wa_fcat-fieldname = 'MINBE'.
wa_fcat-tabname = 'IT_MARC'.
wa_fcat-seltext_s = 'RE-ORDER POINT'.
wa_fcat-seltext_m = 'RE-ORDER LEVEL'.
* wa_fcat-seltext_l = 'Material Number'.
append wa_fcat to it_fcat2.

clear wa_fcat.
wa_fcat-col_pos = 5.
wa_fcat-fieldname = 'BSTMI'.
wa_fcat-tabname = 'IT_MARC'.
wa_fcat-seltext_s = 'MIN. ORDER QTY'.
wa_fcat-seltext_m = 'MIN. ORDER QUANTITY'.
* wa_fcat-seltext_l = 'Material Number'.
append wa_fcat to it_fcat2.

P a g e 43 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

ENDFORM.

FORM DISPLAY_ALV_GRID2.

*REUSE_ALV_GRID_DISPLAY:IS USED TO DISPLAY DATA ONTO ALV GRID IN TAB


ULAR FORMAT WITH DIFFERENT OUTPUT OPTIONS SUCH AS SUM,FILTER,SORT,
ETC
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
* I_CALLBACK_TOP_OF_PAGE =''
I_GRID_TITLE = 'Plant data for Material'
IT_FIELDCAT = it_fcat2
TABLES
T_OUTTAB = it_marc
EXCEPTIONS
PROGRAM_ERROR =1
OTHERS =2
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.

ENDFORM.

FORM PAGE_HEADING.

*TO CREATE INTERNAL TABLE IT_LIST OF STRUCTURE SLIS_T_LISTHEADER


DATA IT_LIST TYPE SLIS_T_LISTHEADER WITH HEADER LINE.

*TO FILL INTERNAL TABLE IT_LIST


IT_LIST-TYP = 'H' . "HEADER
IT_LIST-KEY = 'MATNR'.
IT_LIST-INFO = 'Material master data'.
append it_list.

IT_LIST-TYP = 'S'. "selection


IT_LIST-INFO = 'Material data'.
append it_list.
P a g e 44 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

*REUSE_ALV_COMMENTARY_WRITE:THIS FUNCTION IS SEUD TO DISPLAY PAG


E HEADING AND LOGO OR IMAGE ONTO TOP OF PAGE OF ALV GRID
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LIST[]
I_LOGO = 'ENJOYSAP_LOGO'
* I_END_OF_LIST_GRID =
* I_ALV_FORM =
.

ENDFORM.

FORM HANDLE_GUI USING IT_FCODES TYPE SLIS_T_EXTAB.

*TO ATTACH USER-INTERFACE(GUI) OR STATUS TO ALV GRID


SET PF-STATUS 'GUI_ALV'.

ENDFORM.

Steps to create a Tcode for Report Program:


➢ Go with Tcode: SE93.
➢ Provide Transaction: ZMATERIAL_REP.
➢ Click on ‘create’ button.
➢ Provide Short text: Material master Information.
➢ Select radio button as below:

➢ Enter.
➢ Provide program: ZCLASICAL_ALV_REPORT.
➢ In ‘GUI’ support, tick all the checkboxes as below:

P a g e 45 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Save it(CTrl+s).

Navigation steps to Schedule Report program in Background:


➢ Tcode: SM36.
➢ Provide the following details:

➢ Click on ‘Step’ button from application toolbar.


➢ Provide program name and variant as below:

➢ Click on Save button(ctrl+s).


➢ Go back(F3).

P a g e 46 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Click on ‘Start condition’ button from application toolbar.


➢ Click on ‘date/time’ button.

➢ Click on ‘period values’ button (if you want to execute your report at some
intervals).
➢ Opens a screen.

➢ Click on ‘Other Period’ button and provide the frequency as ‘3 minutes’


below and save it.

➢ Save(ctrl+s).
➢ Save (ctrl+s) and again save(ctrl+s).

To view/know the status of background job:


➢ Tcode: SM37.
➢ Jobname: rjob2.

P a g e 47 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Note: In user name: *(means all users). If you user name provide it.
➢ Click on ‘Execute’ button.
➢ Select the job as below:

➢ Click on ‘spool’ button from application toolbar.

➢ Select your spool no.’474800’ and click no display button from application
toolbar.

To exclude buttons from GUI or status, code is as below:

FORM HANDLE_GUI USING IT_FCODES TYPE SLIS_T_EXTAB.

*to create work area


data wa_fcode type slis_extab.
*to fill internal table it_fcodes inorder to exclude the buttons from gui or status
wa_fcode-fcode = '&OL0'.
append wa_fcode to it_fcodes.

clear wa_fcode.
wa_fcode-fcode = '&OAD'.
append wa_fcode to it_fcodes.

clear wa_fcode.

P a g e 48 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

wa_fcode-fcode = '&AVE'.
append wa_fcode to it_fcodes.

clear wa_fcode.
wa_fcode-fcode = '&INFO'.
append wa_fcode to it_fcodes.

*TO ATTACH USER-INTERFACE(GUI) OR STATUS TO ALV GRID


* SET PF-STATUS 'GUI_ALV'.

SET PF-STATUS 'GUI_ALV' EXCLUDING it_fcodes.

ENDFORM.

To handle Events in ALV Interactive Report:


It_events

Name (Event) Form


PF_STATUS_SET HANDLE_GUI
USER_COMMAND HANDLE_DCLICK
TOP_OF_PAGE PAGE_HEADING

Example:
REPORT ZINTERACTIVE_ALV_REPORT_EVENTS.

*to creates implicit work area.


tables:sscrfields, mara.

*to include type group-slis


*type-pools slis.

*to create line type with some fields of mara


P a g e 49 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

types:BEGIN OF line_type,
MATNR like mara-MATNR,
ERSDA type ERSDA,
ERNAM type ERNAM,
MTART type MTART,
MBRSH type MBRSH,
MATKL type MATKL,
MEINS type MEINS,
end of line_type.

**to create marc line type with some fields


types:begin of marc_type,
matnr type matnr,
werks type werks_d,
ekgrp type ekgrp,
minbe type minbe,
bistmi type bstmi,
end of marc_type.
**to create internal table referring to mara structure
data it_mara type table of line_type.

*to create work area referring to line_type


data wa_mara type line_type.

*to create internal table it_marc of structure marc_type,


data it_marc type table of marc_type.

*to create internal table it_fcat of structure slis_fieldcat_alv


data it_fcat type table of slis_fieldcat_alv.

*to create work area of structure slis_fieldcat_alv


data wa_fcat type slis_fieldcat_alv.

*to create internal table it_fcat2 of structure slis_fieldcat_alv


data it_fcat2 type table of slis_fieldcat_alv.

*to create event internal table


data it_event type slis_t_event WITH HEADER LINE.

*to create range of input fields onto selection-screen


P a g e 50 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

select-options s_matnr for mara-matnr.

*to create blank lines onto selection-screen


selection-screen skip 3.

*to create pushbuttons onto selection-screen


selection-screen PUSHBUTTON :/10(10) push1 USER-COMMAND FCT1,
40(10) push2 USER-COMMAND FCT2.
*to create pushbuttons onto application toolbar of selection-screen
selection-screen FUNCTION KEY:1,2.

initialization.
s_matnr-low = '100-100'.
s_matnr-high = '100-800'.
append s_matnr.
push1 = 'Display'.
Push2 = 'Exit'.
sscrfields-functxt_01 = 'Print'.
sscrfields-functxt_02 = 'Leave'.

at SELECTION-SCREEN .
if sscrfields-ucomm = 'FCT1' or sscrfields-ucomm = 'FC01'.
sscrfields-ucomm = 'ONLI'.
elseif sscrfields-ucomm = 'FCT2' or sscrfields-ucomm = 'FC02'.
leave program.
endif.

start-OF-SELECTION.
perform fetch_data.
perform build_fcat.

end-of-SELECTION.
perform display_data.

*to get data from database table -mara


form fetch_data.
refresh it_mara.
** to get data from database table mara into internal table it_mara
select matnr ersda ernam mtart mbrsh matkl meins from mara into table it_m
P a g e 51 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

ara where matnr in s_matnr.

endform.

***to build fieldcatalog


form build_fcat.
refresh it_fcat.
**1st column-MATNR
wa_fcat-row_pos = 1.
wa_fcat-col_pos = 1.
wa_fcat-fieldname = 'MATNR'.
wa_fcat-tabname = 'IT_MARA'.
wa_fcat-just = 'L'.
wa_fcat-outputlen = 20.
wa_fcat-seltext_s = 'Matnr'.
wa_fcat-seltext_m = 'Material'.
wa_fcat-seltext_l = 'Material Number'.
* wa_fcat-hotspot = 'X'.
append wa_fcat to it_fcat.

clear wa_fcat.
wa_fcat-row_pos = 1.
wa_fcat-edit_mask = '__/__/____'.
wa_fcat-col_pos = 2.
wa_fcat-fieldname = 'ERSDA'.
wa_fcat-tabname = 'IT_MARA'.
wa_fcat-just = 'R'.
wa_fcat-seltext_s = 'Created'.
wa_fcat-seltext_m = 'Created On'.
wa_fcat-seltext_l = 'Created On '.
wa_fcat-emphasize = 'C511'.
append wa_fcat to it_fcat.

clear wa_fcat.
wa_fcat-row_pos = 1.
wa_fcat-col_pos = 3.
wa_fcat-fieldname = 'ERNAM'.
P a g e 52 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

wa_fcat-tabname = 'IT_MARA'.
wa_fcat-just = 'R'.
wa_fcat-seltext_s = 'Person '.
wa_fcat-seltext_m = 'Created By'.
wa_fcat-seltext_l = 'Created By '.
wa_fcat-outputlen = '20'.
wa_fcat-emphasize = 'C710'.
append wa_fcat to it_fcat.

clear wa_fcat.
wa_fcat-row_pos = 1.
wa_fcat-col_pos = 4.
wa_fcat-fieldname = 'MTART'.
wa_fcat-tabname = 'IT_MARA'.
wa_fcat-just = 'R'.
wa_fcat-seltext_s = 'Mtype'.
wa_fcat-seltext_m = 'Material type'.
wa_fcat-emphasize = 'C601'.

* wa_fcat-seltext_l = 'Created On '.


append wa_fcat to it_fcat.

clear wa_fcat.
wa_fcat-row_pos = 1.
wa_fcat-col_pos = 5.
wa_fcat-fieldname = 'MBRSH'.
wa_fcat-tabname = 'IT_MARA'.
wa_fcat-just = 'C'.
wa_fcat-seltext_s = 'Industry'.
wa_fcat-seltext_m = 'Industry Sect'.
wa_fcat-seltext_l = 'Industry Sector'.
append wa_fcat to it_fcat.

clear wa_fcat.
wa_fcat-row_pos = 1.
wa_fcat-col_pos = 6.
wa_fcat-fieldname = 'MATKL'.
wa_fcat-tabname = 'IT_MARA'.
wa_fcat-just = 'R'.
wa_fcat-seltext_s = 'Mat Grp'.
P a g e 53 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

wa_fcat-seltext_m = 'Material group'.


wa_fcat-seltext_l = 'Material Group'.
append wa_fcat to it_fcat.

clear wa_fcat.
wa_fcat-row_pos = 1.
wa_fcat-col_pos = 7.
wa_fcat-fieldname = 'MEINS'.
wa_fcat-tabname = 'IT_MARA'.
wa_fcat-just = 'R'.
wa_fcat-seltext_s = 'Uom'.
wa_fcat-seltext_m = 'Unit Measurement'.
wa_fcat-seltext_l = 'Unit of Measurement'.
append wa_fcat to it_fcat.

endform.

*to display data onto output list-alv grid


form display_data.
**Reuse_alv_grid_display: is used to display data onto alv grid

*** Fill interanl table it_event


it_event-name = 'PF_STATUS_SET'.
it_event-form = 'HANDLE_GUI'.
append it_event.
clear it_event.

it_event-name = 'USER_COMMAND'.
it_event-form = 'HANDLE_DCLICK'.
append it_event.
clear it_event.

it_event-name = 'TOP_OF_PAGE'.
it_event-form = 'PAGE_HEADING'.
append it_event.
clear it_event.

P a g e 54 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'


EXPORTING
I_CALLBACK_PROGRAM = sy-repid
I_GRID_TITLE = 'Material Information'
IT_FIELDCAT = IT_FCAT
IT_EVENTS = it_event[]
TABLES
T_OUTTAB = it_mara
EXCEPTIONS
PROGRAM_ERROR =1
OTHERS =2
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.

endform.

form HANDLE_DCLICK using v_fcode like sy-ucomm wa type slis_selfield.

case v_fcode.
when '&IC1' OR 'SELE' OR 'COD1'.
*to pick material number from where the user double click on 1st alv grid of int
ernal table it_mara
read table it_mara into wa_mara INDEX wa-tabindex.
if sy-subrc = 0.
perform get_marc_data.
perform build_fcat_marc.
perform display_alv_grid2.
endif.
WHEN 'COD2' OR 'LEAV'.
LEAVE TO SCREEN 0.
endcase.

endform.

form get_marc_data.
P a g e 55 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

refresh it_marc.
data:str1 type string.
** to get plant data from marc into internal table it_marc.
select matnr werks ekgrp bstmi minbe from marc into TABLE it_marc WHERE
matnr = wa_mara-matnr.
if sy-subrc <> 0.
*conversion routines: is used to convert the data from display format to interna
l format and vice versa.
*CONVERSION_EXIT_MATN1_OUTPUT: this function module is used to convert i
nternal format data(here it is in leading zero's) to display format
CALL FUNCTION 'CONVERSION_EXIT_MATN1_OUTPUT'
EXPORTING
INPUT = wa_mara-matnr
IMPORTING
OUTPUT = wa_mara-matnr
.

concatenate 'Plant data not found for material-' wa_mara-matnr into str1.
message str1 type 'I'.
leave program.
endif.
endform.

form build_fcat_marc.
refresh it_fcat2.
**1st column-MATNR
clear wa_fcat.
wa_fcat-col_pos = 1.
wa_fcat-fieldname = 'MATNR'.
wa_fcat-tabname = 'IT_MARC'.
wa_fcat-just = 'L'.
wa_fcat-outputlen = 20.
wa_fcat-seltext_s = 'Matnr'.
wa_fcat-seltext_m = 'Material'.
wa_fcat-seltext_l = 'Material Number'.
append wa_fcat to it_fcat2.

clear wa_fcat.
wa_fcat-col_pos = 2.
wa_fcat-fieldname = 'WERKS'.
P a g e 56 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

wa_fcat-tabname = 'IT_MARC'.
wa_fcat-just = 'L'.
wa_fcat-seltext_s = 'PLANT'.
wa_fcat-seltext_m = 'PLANT'.
* wa_fcat-seltext_l = 'Material Number'.
append wa_fcat to it_fcat2.

clear wa_fcat.
wa_fcat-col_pos = 3.
wa_fcat-fieldname = 'EKGRP'.
wa_fcat-tabname = 'IT_MARC'.
* wa_fcat-just = 'L'.
wa_fcat-seltext_s = 'PURCH GRP'.
wa_fcat-seltext_m = 'PURCHASE GRP'.
wa_fcat-seltext_l = 'PURCHASING GROUP'.
append wa_fcat to it_fcat2.

clear wa_fcat.
wa_fcat-col_pos = 4.
wa_fcat-fieldname = 'MINBE'.
wa_fcat-tabname = 'IT_MARC'.
wa_fcat-seltext_s = 'RE-ORDER POINT'.
wa_fcat-seltext_m = 'RE-ORDER LEVEL'.
* wa_fcat-seltext_l = 'Material Number'.
append wa_fcat to it_fcat2.

clear wa_fcat.
wa_fcat-col_pos = 5.
wa_fcat-fieldname = 'BSTMI'.
wa_fcat-tabname = 'IT_MARC'.
wa_fcat-seltext_s = 'MIN. ORDER QTY'.
wa_fcat-seltext_m = 'MIN. ORDER QUANTITY'.
* wa_fcat-seltext_l = 'Material Number'.
append wa_fcat to it_fcat2.

ENDFORM.

FORM DISPLAY_ALV_GRID2.

P a g e 57 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

*REUSE_ALV_GRID_DISPLAY:IS USED TO DISPLAY DATA ONTO ALV GRID IN TAB


ULAR FORMAT WITH DIFFERENT OUTPUT OPTIONS SUCH AS SUM,FILTER,SORT,
ETC
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
* I_CALLBACK_TOP_OF_PAGE =''
I_GRID_TITLE = 'Plant data for Material'
IT_FIELDCAT = it_fcat2
TABLES
T_OUTTAB = it_marc
EXCEPTIONS
PROGRAM_ERROR =1
OTHERS =2
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.

ENDFORM.

FORM PAGE_HEADING.

*TO CREATE INTERNAL TABLE IT_LIST OF STRUCTURE SLIS_T_LISTHEADER


DATA IT_LIST TYPE SLIS_T_LISTHEADER WITH HEADER LINE.

*TO FILL INTERNAL TABLE IT_LIST


IT_LIST-TYP = 'H' . "HEADER
IT_LIST-KEY = 'MATNR'.
IT_LIST-INFO = 'Material master data'.
append it_list.

IT_LIST-TYP = 'S'. "selection


IT_LIST-INFO = 'Material data'.
append it_list.

*REUSE_ALV_COMMENTARY_WRITE:THIS FUNCTION IS SEUD TO DISPLAY PAG


E HEADING AND LOGO OR IMAGE ONTO TOP OF PAGE OF ALV GRID
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
P a g e 58 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

IT_LIST_COMMENTARY = IT_LIST[]
I_LOGO = 'ENJOYSAP_LOGO'
* I_END_OF_LIST_GRID =
* I_ALV_FORM =
.

ENDFORM.

FORM HANDLE_GUI USING IT_FCODES TYPE SLIS_T_EXTAB.

*to create work area


data wa_fcode type slis_extab.
*to fill internal table it_fcodes inorder to exclude the buttons from gui or status
wa_fcode-fcode = '&OL0'.
append wa_fcode to it_fcodes.

clear wa_fcode.
wa_fcode-fcode = '&OAD'.
append wa_fcode to it_fcodes.

clear wa_fcode.
wa_fcode-fcode = '&AVE'.
append wa_fcode to it_fcodes.

clear wa_fcode.
wa_fcode-fcode = '&INFO'.
append wa_fcode to it_fcodes.

*TO ATTACH USER-INTERFACE(GUI) OR STATUS TO ALV GRID


* SET PF-STATUS 'GUI_ALV'.

SET PF-STATUS 'GUI_ALV' EXCLUDING it_fcodes.

ENDFORM.

REUSE_ALV_EVENTS_GET: This function module is used to get all the events in


ALV.

P a g e 59 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

Assignment: Please use FM: reuse_alv_events_get and develop an ALV


Interactive report.

To call standard transaction from output screen -ALV grid:


Syntax:
Call transaction ‘Tcode’ AND SKIP FIRST SCREEN.
Example:
call TRANSaction 'MM03' AND SKIP FIRST SCREEN.

To execute another report:


Syntax:
Submit <report_name> and return.

Example:
submit ZREPORT_EXAMPLE1 and RETURN.

SAP Memory: It is a global memory area where data is stored so that all the
programs of all the sessions can access it.
To store data in Sap Memory (SPA)
Syntax:
set parameter id <id_name> field <f>.

Example:
REPORT ZSPA.

*to create variable


data var(40) value 'Abap/4 is a programming language'.
set PARAMETER ID 'VIT' field var.
Activate and execute(F8).

To Read data from Sap Memory (GPA)


Syntax:
get parameter id <id_name> field <f>.

Example:

P a g e 60 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

REPORT ZGPA.

*to create variable


data text(40).

get PARAMETER ID 'VIT' field text.

write text.
Activate and execute(F8)

Example:
ALV interactive Report to call Another Report and standard Transaction -MM03
REPORT ZINTERACTIVE_ALV_REPORT_BUTTON.

*to creates implicit work area.


tables:sscrfields, mara.

*to include type group-slis


*type-pools slis.

*to create line type with some fields of mara


types:BEGIN OF line_type,
MATNR like mara-MATNR,
ERSDA type ERSDA,
ERNAM type ERNAM,
MTART type MTART,
MBRSH type MBRSH,
MATKL type MATKL,
MEINS type MEINS,
end of line_type.

**to create marc line type with some fields


types:begin of marc_type,
matnr type matnr,
werks type werks_d,
ekgrp type ekgrp,
minbe type minbe,
bistmi type bstmi,
P a g e 61 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

end of marc_type.
**to create internal table referring to mara structure
data it_mara type table of line_type.

*to create work area referring to line_type


data wa_mara type line_type.

*to create internal table it_marc of structure marc_type,


data it_marc type table of marc_type.

*to create internal table it_fcat of structure slis_fieldcat_alv


data it_fcat type table of slis_fieldcat_alv.

*to create work area of structure slis_fieldcat_alv


data wa_fcat type slis_fieldcat_alv.

*to create internal table it_fcat2 of structure slis_fieldcat_alv


data it_fcat2 type table of slis_fieldcat_alv.

*to create range of input fields onto selection-screen


select-options s_matnr for mara-matnr.

*to create blank lines onto selection-screen


selection-screen skip 3.

*to create pushbuttons onto selection-screen


selection-screen PUSHBUTTON :/10(10) push1 USER-COMMAND FCT1,
40(10) push2 USER-COMMAND FCT2.
*to create pushbuttons onto application toolbar of selection-screen
selection-screen FUNCTION KEY:1,2.

initialization.
s_matnr-low = '100-100'.
s_matnr-high = '100-800'.
append s_matnr.
push1 = 'Display'.
Push2 = 'Exit'.
sscrfields-functxt_01 = 'Print'.
sscrfields-functxt_02 = 'Leave'.

P a g e 62 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

at SELECTION-SCREEN .
if sscrfields-ucomm = 'FCT1' or sscrfields-ucomm = 'FC01'.
sscrfields-ucomm = 'ONLI'.
elseif sscrfields-ucomm = 'FCT2' or sscrfields-ucomm = 'FC02'.
leave program.
endif.

start-OF-SELECTION.
perform fetch_data.
perform build_fcat.

end-of-SELECTION.
perform display_data.

*to get data from database table -mara


form fetch_data.
refresh it_mara.
** to get data from database table mara into internal table it_mara
select matnr ersda ernam mtart mbrsh matkl meins from mara into table it_m
ara where matnr in s_matnr.

endform.

***to build fieldcatalog


form build_fcat.
refresh it_fcat.
**1st column-MATNR
wa_fcat-row_pos = 1.
wa_fcat-col_pos = 1.
wa_fcat-fieldname = 'MATNR'.
wa_fcat-tabname = 'IT_MARA'.
wa_fcat-just = 'L'.
wa_fcat-outputlen = 20.
wa_fcat-seltext_s = 'Matnr'.
wa_fcat-seltext_m = 'Material'.
wa_fcat-seltext_l = 'Material Number'.
* wa_fcat-hotspot = 'X'.
P a g e 63 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

append wa_fcat to it_fcat.

clear wa_fcat.
wa_fcat-row_pos = 1.
wa_fcat-edit_mask = '__/__/____'.
wa_fcat-col_pos = 2.
wa_fcat-fieldname = 'ERSDA'.
wa_fcat-tabname = 'IT_MARA'.
wa_fcat-just = 'R'.
wa_fcat-seltext_s = 'Created'.
wa_fcat-seltext_m = 'Created On'.
wa_fcat-seltext_l = 'Created On '.
wa_fcat-emphasize = 'C511'.
append wa_fcat to it_fcat.

clear wa_fcat.
wa_fcat-row_pos = 1.
wa_fcat-col_pos = 3.
wa_fcat-fieldname = 'ERNAM'.
wa_fcat-tabname = 'IT_MARA'.
wa_fcat-just = 'R'.
wa_fcat-seltext_s = 'Person '.
wa_fcat-seltext_m = 'Created By'.
wa_fcat-seltext_l = 'Created By '.
wa_fcat-outputlen = '20'.
wa_fcat-emphasize = 'C710'.
append wa_fcat to it_fcat.

clear wa_fcat.
wa_fcat-row_pos = 1.
wa_fcat-col_pos = 4.
wa_fcat-fieldname = 'MTART'.
wa_fcat-tabname = 'IT_MARA'.
wa_fcat-just = 'R'.
wa_fcat-seltext_s = 'Mtype'.
wa_fcat-seltext_m = 'Material type'.
wa_fcat-emphasize = 'C601'.

* wa_fcat-seltext_l = 'Created On '.


P a g e 64 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

append wa_fcat to it_fcat.

clear wa_fcat.
wa_fcat-row_pos = 1.
wa_fcat-col_pos = 5.
wa_fcat-fieldname = 'MBRSH'.
wa_fcat-tabname = 'IT_MARA'.
wa_fcat-just = 'C'.
wa_fcat-seltext_s = 'Industry'.
wa_fcat-seltext_m = 'Industry Sect'.
wa_fcat-seltext_l = 'Industry Sector'.
append wa_fcat to it_fcat.

clear wa_fcat.
wa_fcat-row_pos = 1.
wa_fcat-col_pos = 6.
wa_fcat-fieldname = 'MATKL'.
wa_fcat-tabname = 'IT_MARA'.
wa_fcat-just = 'R'.
wa_fcat-seltext_s = 'Mat Grp'.
wa_fcat-seltext_m = 'Material group'.
wa_fcat-seltext_l = 'Material Group'.
append wa_fcat to it_fcat.

clear wa_fcat.
wa_fcat-row_pos = 1.
wa_fcat-col_pos = 7.
wa_fcat-fieldname = 'MEINS'.
wa_fcat-tabname = 'IT_MARA'.
wa_fcat-just = 'R'.
wa_fcat-seltext_s = 'Uom'.
wa_fcat-seltext_m = 'Unit Measurement'.
wa_fcat-seltext_l = 'Unit of Measurement'.
append wa_fcat to it_fcat.

endform.

P a g e 65 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

*to display data onto output list-alv grid


form display_data.
**Reuse_alv_grid_display: is used to display data onto alv grid
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = 'HANDLE_GUI'
I_CALLBACK_USER_COMMAND = 'HANDLE_DCLICK'
I_CALLBACK_TOP_OF_PAGE = 'PAGE_HEADING'
I_GRID_TITLE = 'Material Information'
IT_FIELDCAT = IT_FCAT
TABLES
T_OUTTAB = it_mara
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.

endform.

form HANDLE_DCLICK using v_fcode like sy-ucomm wa type slis_selfield.

case v_fcode.
when '&IC1' OR 'SELE' OR 'COD1'.
*to pick material number from where the user double click on 1st alv grid of int
ernal table it_mara
read table it_mara into wa_mara INDEX wa-tabindex.
if sy-subrc = 0.
perform get_marc_data.
perform build_fcat_marc.
perform display_alv_grid2.
endif.
WHEN 'COD2' OR 'LEAV'.
LEAVE TO SCREEN 0.
when 'MM03'.
read table it_mara into wa_mara INDEX wa-tabindex.
P a g e 66 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

if sy-subrc = 0.
set PARAMETER ID 'MAT' field wa_mara-matnr.
call TRANSaction 'MM03' AND SKIP FIRST SCREEN.
**Note:Parameter ID is available in data element -
>further characteristic (for matnr)
endif.
when 'REP1'.
submit ZREPORT_EXAMPLE1 and RETURN.
endcase.

endform.

form get_marc_data.
refresh it_marc.
data:str1 type string.
** to get plant data from marc into internal table it_marc.
select matnr werks ekgrp bstmi minbe from marc into TABLE it_marc WHERE
matnr = wa_mara-matnr.
if sy-subrc <> 0.
*conversion routines: is used to convert the data from display format to interna
l format and vice versa.
*CONVERSION_EXIT_MATN1_OUTPUT: this function module is used to convert i
nternal format data(here it is in leading zero's) to display format
CALL FUNCTION 'CONVERSION_EXIT_MATN1_OUTPUT'
EXPORTING
INPUT = wa_mara-matnr
IMPORTING
OUTPUT = wa_mara-matnr
.

concatenate 'Plant data not found for material-' wa_mara-matnr into str1.
message str1 type 'I'.
leave program.
endif.
endform.

form build_fcat_marc.
refresh it_fcat2.
**1st column-MATNR
P a g e 67 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

clear wa_fcat.
wa_fcat-col_pos = 1.
wa_fcat-fieldname = 'MATNR'.
wa_fcat-tabname = 'IT_MARC'.
wa_fcat-just = 'L'.
wa_fcat-outputlen = 20.
wa_fcat-seltext_s = 'Matnr'.
wa_fcat-seltext_m = 'Material'.
wa_fcat-seltext_l = 'Material Number'.
append wa_fcat to it_fcat2.

clear wa_fcat.
wa_fcat-col_pos = 2.
wa_fcat-fieldname = 'WERKS'.
wa_fcat-tabname = 'IT_MARC'.
wa_fcat-just = 'L'.
wa_fcat-seltext_s = 'PLANT'.
wa_fcat-seltext_m = 'PLANT'.
* wa_fcat-seltext_l = 'Material Number'.
append wa_fcat to it_fcat2.

clear wa_fcat.
wa_fcat-col_pos = 3.
wa_fcat-fieldname = 'EKGRP'.
wa_fcat-tabname = 'IT_MARC'.
* wa_fcat-just = 'L'.
wa_fcat-seltext_s = 'PURCH GRP'.
wa_fcat-seltext_m = 'PURCHASE GRP'.
wa_fcat-seltext_l = 'PURCHASING GROUP'.
append wa_fcat to it_fcat2.

clear wa_fcat.
wa_fcat-col_pos = 4.
wa_fcat-fieldname = 'MINBE'.
wa_fcat-tabname = 'IT_MARC'.
wa_fcat-seltext_s = 'RE-ORDER POINT'.
wa_fcat-seltext_m = 'RE-ORDER LEVEL'.
* wa_fcat-seltext_l = 'Material Number'.
append wa_fcat to it_fcat2.
P a g e 68 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

clear wa_fcat.
wa_fcat-col_pos = 5.
wa_fcat-fieldname = 'BSTMI'.
wa_fcat-tabname = 'IT_MARC'.
wa_fcat-seltext_s = 'MIN. ORDER QTY'.
wa_fcat-seltext_m = 'MIN. ORDER QUANTITY'.
* wa_fcat-seltext_l = 'Material Number'.
append wa_fcat to it_fcat2.

ENDFORM.

FORM DISPLAY_ALV_GRID2.

*REUSE_ALV_GRID_DISPLAY:IS USED TO DISPLAY DATA ONTO ALV GRID IN TAB


ULAR FORMAT WITH DIFFERENT OUTPUT OPTIONS SUCH AS SUM,FILTER,SORT,
ETC
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
* I_CALLBACK_TOP_OF_PAGE =''
I_GRID_TITLE = 'Plant data for Material'
IT_FIELDCAT = it_fcat2
TABLES
T_OUTTAB = it_marc
EXCEPTIONS
PROGRAM_ERROR =1
OTHERS =2
.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.

ENDFORM.

FORM PAGE_HEADING.

*TO CREATE INTERNAL TABLE IT_LIST OF STRUCTURE SLIS_T_LISTHEADER


P a g e 69 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

DATA IT_LIST TYPE SLIS_T_LISTHEADER WITH HEADER LINE.

*TO FILL INTERNAL TABLE IT_LIST


IT_LIST-TYP = 'H' . "HEADER
IT_LIST-KEY = 'MATNR'.
IT_LIST-INFO = 'Material master data'.
append it_list.

IT_LIST-TYP = 'S' . "selection


IT_LIST-INFO = 'Material data'.
append it_list.

*REUSE_ALV_COMMENTARY_WRITE:THIS FUNCTION IS SEUD TO DISPLAY PAG


E HEADING AND LOGO OR IMAGE ONTO TOP OF PAGE OF ALV GRID
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = IT_LIST[]
I_LOGO = 'ENJOYSAP_LOGO'
* I_END_OF_LIST_GRID =
* I_ALV_FORM =
.

ENDFORM.

FORM HANDLE_GUI USING IT_FCODES TYPE SLIS_T_EXTAB.

*to create work area


data wa_fcode type slis_extab.
*to fill internal table it_fcodes inorder to exclude the buttons from gui or status
wa_fcode-fcode = '&OL0'.
append wa_fcode to it_fcodes.

clear wa_fcode.
wa_fcode-fcode = '&OAD'.
append wa_fcode to it_fcodes.

clear wa_fcode.
wa_fcode-fcode = '&AVE'.
append wa_fcode to it_fcodes.

P a g e 70 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

clear wa_fcode.
wa_fcode-fcode = '&INFO'.
append wa_fcode to it_fcodes.

*TO ATTACH USER-INTERFACE(GUI) OR STATUS TO ALV GRID


* SET PF-STATUS 'GUI_ALV'.

SET PF-STATUS 'GUI_ALV' EXCLUDING it_fcodes.

ENDFORM.

Group Report: It is an abap program which generates a basic list (output screen)
with the help of control break statements or internal table events.
Control break statements or internal table events: It defines set of statements
that process specific lines of internal table.
Control break statements or internal table events are:
1) At First.
2) At New <f>.
3) At end of <f>.
4) At Last.

1) At First: This event is triggered when you read the first record of internal table
and it is triggered only once within loop and endloop. This event is generally
used to display page and column headings.
2) At New <f>: This event is triggered whenever a new field value is read from
an internal table. This event can be written more than once but the field name
should be different.
3) At end of <f>: This event is triggered at the end of group of lines which has
the same field value. This event is generally used to calculate subtotals.
o This event can be written more than once but the field name should be
different.
o ‘SUM’ is the keyword used to add or calculate the numeric fields of internal
table to the numeric fields of work area.

P a g e 71 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

4) At Last: This event is triggered when you read the last record of internal table
and is triggered only once within loop and endloop. This event is generally used
to calculate grand total.
o ‘SUM’ is the keyword used to add or calculate the numeric fields of internal
table to the numeric fields of work area.
Note: All these events are used within loop and endloop of internal table and
the internal table should be sorted.
Note: Whenever you use internal table events within loop and endloop, your
internal table should be created with header line.
o All the events will end with ‘Endat’ keyword.
On change of <f1> or <f2>: This event is similar to At New but the advantage of
‘On change of’ event is you can provide more than one field and if any of the
field value changes then this event is triggered.

Vbak: Contains sales document: Header data.


Vbap: Contains sales document: Item data.
Note: For each sale there will be one record in database table Vbak and multiple
records (item data) in the database table Vbap.

Example:

REPORT ZGROUP_REPORT.

Tables vbap.

*to create internal table it_vbap with some fields of vbap


data:BEGIN OF it_vbap occurs 10,
VBELN like vbap-vbeln,
POSNR like vbap-posnr,
MATNR like vbap-matnr,
NETWR like vbap-NETWR,
KWMENG like vbap-KWMENG,
ERDAT like vbap-ERDAT,
NETPR LIKE vbap-NETPR,
end of it_vbap.

**To provide range of input fields as date


P a g e 72 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

select-OPTIONS s_erdat for vbap-erdat.

start-OF-SELECTIOn.
perform get_data.
perform display_data.

Form get_data.
** To get sales document item data from database table vbap into internal tab
le it_vbap
select vbeln posnr matnr netwr kwmeng erdat netpr from vbap into table it_v
bap where erdat in s_erdat.

*** To sort an internal table it_vbap


sort it_vbap.
endform.

Form display_data.

*To display an internal table it_vbap data onto basic list(output screen) using c
ontrol break statements or internal table events.
loop at it_vbap.

** To displaay page heading


at first.
write:/25 'Sales Information' color 6 INVERSE.
endat.

at new vbeln.
write:/2 it_vbap-vbeln color 3 INVERSE.
endat.

write:/15 it_vbap-posnr color 1 INVERSE,23 it_vbap-


matnr color 4 INVERSE,43 it_vbap-netwr color 6 INVERSE,60 it_vbap-
kwmeng color 3 INVERSE,77 it_vbap-netpr color 7 INVERSE,
95 it_vbap-erdat color 2 INVERSE.

** to calculate subtotal
at end of vbeln.
sum.
write:/43 it_vbap-netwr color 2,60 it_vbap-kwmeng color 1,77 it_vbap-
P a g e 73 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

netpr color 5.
endat.

*** To calculate grand total


at last.
sum.
write:/43 it_vbap-netwr color 4,60 it_vbap-kwmeng color 7,77 it_vbap-
netpr color 1.
endat.
endloop.

endform.

Logical database: It is a special abap program which fetches data from database
and makes it available to an executable program.
o Tcode to create Logical database is SE36.
Logical database has 3 main areas:
1) Structure.
2) Selection.
3) Database program or Source Code.

1) Structure: Each Logical database has root node and under root node we can
create number of child nodes. Each node has the same name and structure as
database table. Execution of nodes will be in the hierarchy provided in the
structure.
Mara->Marc->Mard.
2) Selection: It is used to provide range of input fields onto the selection-screen
based on which data is fetched from database table.
3) Database program or Source Code: It is the place where actual fetching logic
is written.

Navigation steps to create logical database


➢ Tcode: SE36.
➢ Provide Logical database: zldb1 and click on ‘create’ button.
➢ Note: By default, radio button ‘Structure’ is selected.
➢ Provide: Short text: Logical Database.

P a g e 74 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Click on Enter button ->save to package or local object.

➢ Click on ‘create’ button.


➢ Select ‘Mara’ ->Right click->Insert node.

➢ Click on ‘Create’ button.


➢ Select ‘Marc’ ->Right click->Insert node.

➢ Click on ‘Create’ button.


➢ Save it (Ctrl+S).
➢ Click on ‘Selection’ button from Application toolbar.
➢ Click on ‘Yes’ button.

P a g e 75 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Click on ‘Transfer’ button.


➢ Select option: s_matnr for MARA-MATNR.
➢ Activate (Ctrl+f3).
➢ Back(F3).
➢ Click on ‘Source code’ button from application toolbar.
➢ Click on ‘Yes’ button.
➢ System generates the code as below:
include DBZLDB1TOP. " header
include DBZLDB1NXXX. " all system routines
➢ Note: Double click and check the include DBZLDB1TOP , you have
declaration part here.
➢ Double click on include DBZLDB1NXXX.
➢ Opens a screen as below:
include DBZLDB1N001. " Node MARA
include DBZLDB1N002. " Node MARC
include DBZLDB1N003. " Node MARD
include DBZLDB1FXXX. " init, PBO, PAI
include DBZLDB1SXXX. " Search help
➢ Double click on ‘include DBZLDB1N001. " Node MARA
and edit select statement as below:
SELECT *
FROM MARA
WHERE MATNR IN s_matnr.

PUT MARA.
ENDSELECT.

P a g e 76 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Activate (Ctrl+F3).
➢ Go back(F3).
➢ Double click on include DBZLDB1N002. " Node MARC
and edit select statement as below:
SELECT * FROM MARC
INTO MARC
WHERE MATNR = MARA-MATNR.

PUT MARC.

ENDSELECT.
➢ Activate (CTrl+F3).
➢ Go back(F3).
➢ Double click on include DBZLDB1N003. " Node MARD

SELECT * FROM MARD


INTO MARD
WHERE MATNR = MARC-MATNR
AND WERKS = MARC-WERKS.

PUT MARD.

ENDSELECT.
➢ Activate (CTRL+F3).

Now create a Report Program (Executable Program) and Link logical database
to it:
➢ Tcode: SE38.
➢ Provide Program name: zreport_ldb1.
➢ Click on ‘create’ button.
➢ Provide the below details with Logical database:

P a g e 77 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Click on ‘save’ button to Local object or package.


➢ Example:
REPORT ZREPORT_LDB1.
*to create implicit work
Nodes: mara, marc, mard.

get mara.
write:/ mara-matnr, mara-mtart, mara-mbrsh, mara-meins.
get marc.
write:/5 marc-werks, marc-ekgrp, marc-minbe, marc-bstmi.
get mard.
write:/7 mard-lgort, mard-labst.
➢ Activate (Ctrl+F3).

Get <node>: This event will trigger Logical database where the data is fetched
from database table.
Put <node>: This event when triggered will transfer the work area data from
logical database to report program.
Get <node> Late: This event will trigger the specified node once all its previous
nodes get executed.

To Calculate Subtotal and Grand total in ALV Report:


➢ To achieve this, you need to consider 2 points:
1) In the fieldcatalog, you need to provide a property ‘do_sum = ‘X’ for the
following fields:

P a g e 78 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

wa_fcat-col_pos = 4.
wa_fcat-fieldname = 'NETWR'.
wa_fcat-tabname = 'it_vbap'.
wa_fcat-seltext_m = 'Net value'.
wa_fcat-do_sum = 'X'.
append wa_fcat to it_fcat.
clear wa_fcat.

wa_fcat-col_pos = 5.
wa_fcat-fieldname = 'NETPR'.
wa_fcat-tabname = 'it_vbap'.
wa_fcat-seltext_m = 'Net price'.
wa_fcat-do_sum = 'X'.
append wa_fcat to it_fcat.
clear wa_fcat.

wa_fcat-col_pos = 6.
wa_fcat-fieldname = 'KWMENG'.
wa_fcat-tabname = 'it_vbap'.
wa_fcat-seltext_m = 'Quantity'.
wa_fcat-do_sum = 'X'.
append wa_fcat to it_fcat.
clear wa_fcat.

2) You need to create an internal table it_sort of structure slis_t_sortinfo_alv


and activate a field ‘subtot’ for the field ‘Vbeln’ in it and pass it_sort to
‘reuse_alv_grid_display’.
To fill an internal table it_sort:
Wa_sort-fieldname = 'VBELN'.
Wa_sort-up = 'X'. “Ascending Order
Wa_sort-subtot = 'X'. “This will activate subtotal
append Wa_sort to it_sort.
clear Wa_sort.

Example:
REPORT ZALV_SUBTOTAL_GRANDTOTAL.
tables: vbap,sscrfields.
types: BEGIN OF vbap_struct,
P a g e 79 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

VBELN TYPE VBAP-VBELN,


POSNR TYPE VBAP-POSNR,
MATNR TYPE VBAP-MATNR,
NETWR TYPE VBAP-NETWR,
KWMENG type KWMENG,
NETPR TYPE VBAP-NETPR,
END OF VBAP_struct.

data: it_vbap TYPE TABLE OF vbap_struct,


wa_vbap type vbap_struct,
it_fcat type SLIS_T_FIELDCAT_ALV,
wa_fcat type SLIS_FIELDCAT_ALV,
it_sort type slis_t_sortinfo_alv,
Wa_sort type slis_sortinfo_alv.

select-OPTIONS s_vbeln for VBAP-VBELN.


selection-SCREEN skip 4.

selection-SCREEN: PUSHBUTTON 10(10) push1 USER-COMMAND FCT1,


PUSHBUTTON 25(10) push2 USER-COMMAND FCT2.

at SELECTION-SCREEN.
if sscrfields-UCOMM = 'FCT1'.
sscrfields-UCOMM = 'ONLI'.
perform validate.

elseif sscrfields-UCOMM = 'FCT2'.


leave PROGRAM.
endif.

initialization.
push1 = 'display'.
push2 = 'leave'.

start-OF-SELECTION.
perform fetch_data.
perform field_cat.
P a g e 80 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

perform sort.
perform display_res.

end-of-SELECTION.

form sort.
Wa_sort-fieldname = 'VBELN'.
Wa_sort-up = 'X'.
Wa_sort-subtot = 'X'.
append Wa_sort to it_sort.
clear Wa_sort.
endform.

form validate.
select single
VBELN
POSNR
MATNR
NETWR
KWMENG
NETPR
from vbap into wa_vbap where VBELN in s_VBELN.

if sy-subrc <> 0.
message 'Enter valid data' type 'W' DISPLAY LIKE 'W'.

endif.
endform.

form fetch_data.
select
VBELN
POSNR
MATNR
NETWR
kwmeng
NETPR
from vbap into table it_vbap where VBELN in s_VBELN.
P a g e 81 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

endform.

form field_cat.
* col_pos like sy-cucol, " position of the column
* fieldname type slis_fieldname,
* tabname type slis_tabname,
* emphasize(4)
* seltext_m
* seltext_s

wa_fcat-col_pos = 1.
wa_fcat-fieldname = 'VBELN'.
wa_fcat-tabname = 'it_vbap'.
wa_fcat-seltext_m = 'Sales doc'.
wa_fcat-no_convext = 'X'.
append wa_fcat to it_fcat.
clear wa_fcat.

wa_fcat-col_pos = 2.
wa_fcat-fieldname = 'POSNR'.
wa_fcat-tabname = 'it_vbap'.
wa_fcat-seltext_m = 'Sales item'.
append wa_fcat to it_fcat.
clear wa_fcat.

wa_fcat-col_pos = 3.
wa_fcat-fieldname = 'MATNR'.
wa_fcat-tabname = 'it_vbap'.
wa_fcat-seltext_m = 'Material num'.
append wa_fcat to it_fcat.
clear wa_fcat.

wa_fcat-col_pos = 4.
wa_fcat-fieldname = 'NETWR'.
wa_fcat-tabname = 'it_vbap'.
wa_fcat-seltext_m = 'Net value'.
wa_fcat-do_sum = 'X'.
append wa_fcat to it_fcat.
P a g e 82 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

clear wa_fcat.

wa_fcat-col_pos = 5.
wa_fcat-fieldname = 'NETPR'.
wa_fcat-tabname = 'it_vbap'.
wa_fcat-seltext_m = 'Net price'.
wa_fcat-do_sum = 'X'.
append wa_fcat to it_fcat.
clear wa_fcat.

wa_fcat-col_pos = 6.
wa_fcat-fieldname = 'KWMENG'.
wa_fcat-tabname = 'it_vbap'.
wa_fcat-seltext_m = 'Quantity'.
wa_fcat-do_sum = 'X'.
append wa_fcat to it_fcat.
clear wa_fcat.
endform.

form display_res.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_GRID_TITLE = 'VBAP'
IT_FIELDCAT = it_fcat
IT_SORT = it_sort
TABLES
T_OUTTAB = it_vbap
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
endform.

P a g e 83 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

Layout: This concept will help in ALV report to display checkbox, signal lights,
colors, etc row wise and of should be of structure slis_layout_alv and should be
passed to FM:reuse_alv_grid_display.

wa_layout-box_fieldname = 'BOX'. " To create checkbox on ALV layout


wa_layout-no_colhead = 'X'. "this will not display column heading
wa_layout-zebra = 'X'. "This will display striped pattern
wa_layout-no_vline = 'X'. "this will not display vertical lines
wa_layout-no_hline = 'X'. "this will not display horizontal lines
wa_layout-no_keyfix = 'X'. "This will make the key column to scroll
wa_layout-
colwidth_optimize = 'X'. "this will display complete text in the columns
wa_layout-lights_fieldname = 'LIGHTS'. "this will provide signal lights
wa_layout-info_fieldname = 'COLOR'. "this will color rows accordingly

Example:

REPORT ZCLASICAL_ALV_REPORT_LAYOUT.

*to creates implicit work area.


tables:sscrfields, mara.

*to include type group-slis


*type-pools slis.

*to create line type with some fields of mara


types:BEGIN OF line_type,
MATNR type MATNR,
ERSDA type ERSDA,
ERNAM type ERNAM,
MTART type MTART,
MBRSH type MBRSH,
MATKL type MATKL,
MEINS type MEINS,
box,
lights,
color(4),
end of line_type.
**to create internal table referring to mara structure
P a g e 84 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

data it_mara type table of line_type WITH HEADER LINE.

*to create work area referring to line_type


data wa_mara type line_type.

*to create internal table it_fcat of structure slis_fieldcat_alv


data it_fcat type table of slis_fieldcat_alv.

*to create work area of structure slis_fieldcat_alv


data wa_fcat type slis_fieldcat_alv.

*to create work area for layout of structure slis_layout_alv


data wa_layout type slis_layout_alv.

*to create range of input fields onto selection-screen


select-options s_matnr for mara-matnr.

*to create blank lines onto selection-screen


selection-screen skip 3.

*to create pushbuttons onto selection-screen


selection-screen PUSHBUTTON :/10(10) push1 USER-COMMAND FCT1,
40(10) push2 USER-COMMAND FCT2.
*to create pushbuttons onto application toolbar of selection-screen
selection-screen FUNCTION KEY:1,2.

initialization.
s_matnr-low = '100-100'.
s_matnr-high = '100-800'.
append s_matnr.
push1 = 'Display'.
Push2 = 'Exit'.
sscrfields-functxt_01 = 'Print'.
sscrfields-functxt_02 = 'Leave'.

at SELECTION-SCREEN .
if sscrfields-ucomm = 'FCT1' or sscrfields-ucomm = 'FC01'.
sscrfields-ucomm = 'ONLI'.
elseif sscrfields-ucomm = 'FCT2' or sscrfields-ucomm = 'FC02'.
leave program.
P a g e 85 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

endif.

start-OF-SELECTION.
perform fetch_data.
perform build_fcat.
perform build_layout.

end-of-SELECTION.
perform display_data.

*to get data from database table -mara


form fetch_data.
** to get data from database table mara into internal table it_mara
select matnr ersda ernam mtart mbrsh matkl meins from mara into CORRESP
ONDING FIELDS OF table it_mara where matnr in s_matnr.

*to provide colors and signal to some of the displayed records on alv grid
it_mara-lights = '1'.
it_mara-color = 'C301'.
modify it_mara TRANSPORTING lights color where matnr between '100-
100' and '100-200'.

it_mara-lights = '2'.
it_mara-color = 'C511'.
modify it_mara TRANSPORTING lights color where matnr between '100-
201' and '100-400'.

it_mara-lights = '3'.
it_mara-color = 'C701'.
modify it_mara TRANSPORTING lights color where matnr between '100-
401' and '100-800'.
endform.

form build_layout.
wa_layout-box_fieldname = 'BOX'. " To create checkbox on ALV layout
wa_layout-no_colhead = 'X'. "this will not display column heading
wa_layout-zebra = 'X'. "This will display striped pattern
wa_layout-no_vline = 'X'. "this will not display vertical lines
wa_layout-no_hline = 'X'. "this will not display horizontal lines
P a g e 86 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

wa_layout-no_keyfix = 'X'. "This will make the key column to scroll


wa_layout-
colwidth_optimize = 'X'. "this will display complete text in the columns
wa_layout-lights_fieldname = 'LIGHTS'. "this will provide signal lights
wa_layout-info_fieldname = 'COLOR'. "this will color rows accordingly
endform.

***to build fieldcatalog


form build_fcat.
*to define properties for columns of output screen(alv grid)
** row_pos like sy-curow, " output in row
** col_pos like sy-cucol, " position of the column
** fieldname type slis_fieldname,
** tabname type slis_tabname,
** currency(5) type c,
** cfieldname type slis_fieldname, " field with currency unit
** ctabname type slis_tabname, " and table
** ifieldname type slis_fieldname, " initial column
** quantity(3) type c,
** qfieldname type slis_fieldname, " field with quantity unit
** qtabname type slis_tabname, " and table
** round type i, " round in write statement
** exponent(3) type c, " exponent for floats
** key(1) type c, " column with key-color
** icon(1) type c, " as icon
** symbol(1) type c, " as symbol
** checkbox(1) type c, " as checkbox
** just(1) type c, " (R)ight (L)eft (C)ent.
** lzero(1) type c, " leading zero
** no_sign(1) type c, " write no-sign
** no_zero(1) type c, " write no-zero
** no_convext(1) type c,
** edit_mask type slis_edit_mask, "
** emphasize(4) type c, " emphasize
** fix_column(1) type c, " Spalte fixieren
** do_sum(1) type c, " sum up
** no_out(1) type c, " (O)blig.(X)no out
** tech(1) type c, " technical field
** outputlen like dd03p-outputlen,
** offset type dd03p-outputlen, " offset
P a g e 87 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

** seltext_l like dd03p-scrtext_l, " long key word


** seltext_m like dd03p-scrtext_m, " middle key word
** seltext_s like dd03p-scrtext_s, " short key word
** ddictxt(1) type c, " (S)hort (M)iddle (L)ong
** rollname like dd03p-rollname,
** datatype like dd03p-datatype,
** inttype like dd03p-inttype,
** intlen like dd03p-intlen,
** lowercase like dd03p-lowercase,

**1st column-MATNR
wa_fcat-row_pos = 1.
wa_fcat-col_pos = 1.
wa_fcat-fieldname = 'MATNR'.
wa_fcat-tabname = 'IT_MARA'.
wa_fcat-just = 'L'.
wa_fcat-seltext_s = 'Matnr'.
wa_fcat-seltext_m = 'Material'.
wa_fcat-seltext_l = 'Material Number'.
append wa_fcat to it_fcat.

clear wa_fcat.
wa_fcat-row_pos = 1.
wa_fcat-edit_mask = '__/__/____'.
wa_fcat-col_pos = 2.
wa_fcat-fieldname = 'ERSDA'.
wa_fcat-tabname = 'IT_MARA'.
wa_fcat-just = 'R'.
wa_fcat-seltext_s = 'Created'.
wa_fcat-seltext_m = 'Created On'.
wa_fcat-seltext_l = 'Created On '.
wa_fcat-emphasize = 'C511'.
append wa_fcat to it_fcat.

clear wa_fcat.
wa_fcat-row_pos = 1.
wa_fcat-col_pos = 3.
wa_fcat-fieldname = 'ERNAM'.
wa_fcat-tabname = 'IT_MARA'.
P a g e 88 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

wa_fcat-just = 'R'.
wa_fcat-seltext_s = 'Person '.
wa_fcat-seltext_m = 'Created By'.
wa_fcat-seltext_l = 'Created By '.
wa_fcat-outputlen = '20'.
wa_fcat-emphasize = 'C710'.
append wa_fcat to it_fcat.

clear wa_fcat.
wa_fcat-row_pos = 1.
wa_fcat-col_pos = 4.
wa_fcat-fieldname = 'MTART'.
wa_fcat-tabname = 'IT_MARA'.
wa_fcat-just = 'R'.
wa_fcat-seltext_s = 'Mtype'.
wa_fcat-seltext_m = 'Material type'.
wa_fcat-emphasize = 'C601'.

* wa_fcat-seltext_l = 'Created On '.


append wa_fcat to it_fcat.

clear wa_fcat.
wa_fcat-row_pos = 1.
wa_fcat-col_pos = 5.
wa_fcat-fieldname = 'MBRSH'.
wa_fcat-tabname = 'IT_MARA'.
wa_fcat-just = 'C'.
wa_fcat-seltext_s = 'Industry'.
wa_fcat-seltext_m = 'Industry Sect'.
wa_fcat-seltext_l = 'Industry Sector'.
append wa_fcat to it_fcat.

clear wa_fcat.
wa_fcat-row_pos = 1.
wa_fcat-col_pos = 6.
wa_fcat-fieldname = 'MATKL'.
wa_fcat-tabname = 'IT_MARA'.
wa_fcat-just = 'R'.
wa_fcat-seltext_s = 'Mat Grp'.
wa_fcat-seltext_m = 'Material group'.
P a g e 89 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

wa_fcat-seltext_l = 'Material Group'.


append wa_fcat to it_fcat.

clear wa_fcat.
wa_fcat-row_pos = 1.
wa_fcat-col_pos = 7.
wa_fcat-fieldname = 'MEINS'.
wa_fcat-tabname = 'IT_MARA'.
wa_fcat-just = 'R'.
wa_fcat-seltext_s = 'Uom'.
wa_fcat-seltext_m = 'Unit Measurement'.
wa_fcat-seltext_l = 'Unit of Measurement'.
append wa_fcat to it_fcat.

endform.

*to display data onto output list-alv grid


form display_data.
**Reuse_alv_grid_display: is used to display data onto alv grid
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_GRID_TITLE = 'Material Information'
IS_LAYOUT = wa_layout
IT_FIELDCAT = IT_FCAT
TABLES
T_OUTTAB = it_mara
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.

endform.

P a g e 90 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

Note: ALV Report which uses ‘Reuse_ALV_grid_display’ cannot be scheduled in


background, so to schedule ALV Report in background you need to use
‘Reuse_alv_list_display’.

Module pool program (or) Dialog Program (or) Transaction:


It is a collection of screens which is used to update the data to database tables.
The Module pool program contains two main components:
1) Screen (Dynpro).
2) Abap module pool program.

1) Screen (Dynpro): It is a graphical container where you can provide screen


elements such as input/output fields, pushbuttons, checkbox, radiobuttons, etc.
o Screen is designed with the help of Abap workbench tool called as Screen
painter. Tcode is SE51.
o Screen is identified by number which ranges from 0 to 9999.
A Screen contains 4 components
i) Screen Attributes.
ii) Screen flow logic.
iii) Screen layout.
iv) Field attributes.
i) Screen Attributes: It describes the properties of screen such as short
description, screen type which can be normal, subscreen or model dialog box.
ii) Screen flow logic: It is a code that process a screen with the help of events,
they are
a) PBO (Process Before Output).
b) PAI (Process After Input).
c) POH (Process on Help-request).
d) POV (Process on Value-request).
a) PBO (Process Before Output): It is triggered before the screen is displayed,
which is used to initialize the values for screen fields. It is also used to change
the properties of screen elements such as read only, mandatory, invisible, etc.
b) PAI (Process After Input): This event is triggered when the user enters data
onto screen fields and click on pushbutton or menu item then its respective PAI
modules are called and set of statements on those modules gets executed. Also,

P a g e 91 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

the selected pushbutton or menu item function code is captured in the system
field sy-ucomm.
c) POH (Process on Help-request): This event is triggered when the user press
F1 function key, which is used to display custom help documentation.
d) POV (Process on Value-request): This event is triggered when the user press
F4 function key, which is used to display custom list of values by avoiding
standard list of values.

iii) Screen layout: It is used to design the layout of the screen with the help of
screen elements such as input/output fields, pushbuttons, check boxes,
radiobuttons, etc.
iv) Field attributes: It is used to define the properties of screen fields such as
read only, disable, required, invisible, etc.
Note: Each screen is considered as a logical unit of work (LUW). Each LUW will
update the data to database table.

LUW (Logical Unit of Work): It is a sequence of database operations which are


executed completely (commit work) or not at all (Rollback).

2) Abap module pool program: It contains data declarations and set of modules
that are called by screen flow logic.
Module pool program is a program type ‘M’.
The flow of Module Pool Program or Dialog program is as follows:

P a g e 92 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

1) When the user executes the transaction, the screen processor executes the
screen where in the screen flow logic gets executed which then triggers the first
event PBO (Process Before Output), before the screen is displayed. when PBO
event is triggered then its respective module (module_status_100) is called then
the control from screen flow logic (screen) is transferred to module pool
program and the set of statements in that module (module_status_100) get
executed.
2) The movement end-module of module: module_status_100 reaches then the
control from module pool program is transferred back to screen flow logic.
(Refer above diagram).
3) After the execution of PBO event, a screen is displayed where user can enter
some data and click on pushbutton then the event triggered is PAI (Process after
Input) then its respective module (here in above diagram: user_command_100)
is called then the control from screen flow logic is transferred to module pool
program and the set of statements in that module (user_command_100) get
executed.
4)When End-module of module: user_command_100 reaches then the control
from module pool program is transferred back to the screen which then
completes the transaction.

Naming convention for module pool program:


Example:
sapmzxxxx or sapmyxxxx.
Or
zmpp1 or ympp1.
Object Navigator or Object Browser: Tcode:SE80: It is used to develop module
pool program.

Navigation steps to create module Pool program:

P a g e 93 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Tcode: SE38.
➢ Provide program name: sapmzmpp1.
➢ Click on ‘create’ button.
➢ Provide title: module pool program.
➢ Type: module pool program (program type ‘M’).
➢ Click on ‘save’ to package.
➢ Activate(ctrl+F3).

Steps to create Screen:


➢ Tcode:SE51
➢ Provide the program name: sapmzmpp1 (program should exit).
➢ Screen: 100
➢ Click on ‘create’ button.
➢ Short Description: normal screen-100

➢ Save(ctrl+s).
➢ Click on ‘layout’ button from application tool bar.
➢ Click on ‘Dictionary or program fields’ icon from application toolbar.
P a g e 94 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Opens a screen.
➢ Provide table: MARA and ‘enter’.
➢ Select the fields as below and enter.

➢ Enter and drag and drop onto the layout.


➢ To provide text field.
➢ Click on ‘text field’ ( ) icon from left panel and drag and drop onto layout.
➢ Double click on text field and provide text and icon as below:

P a g e 95 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ To provide pushbuttons as below: for ‘display’ and ‘exit’.


➢ Select the ‘pushbutton’ from left panel and drag and drop onto layout.
➢ Double click on pushbutton to provide label and function code to it as
below:

➢ Similarly provide another pushbutton as ‘EXIT’ by dragging and dropping


onto layout from left panel and double click onto it to provide label and
function code as below:

P a g e 96 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Save (ctrl+S).
➢ Click on ‘flow logic’ button from application toolbar.
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
*
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0100.
➢ Save (ctrl+S).
➢ Double click on ‘MODULE STATUS_0100.’
➢ Opens a screen as below:

➢ Click on ‘yes’ button.


➢ Opens a screen.

P a g e 97 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Select ‘sapmzmpp1’ and enter.


PROGRAM SAPMZMPP1.

tables mara. "it create implicit work.

*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
* SET PF-STATUS 'xxxxxxxx'.
* SET TITLEBAR 'xxx'.

if mara-matnr is INITIAL.
mara-matnr = '100-100'.
endif.

ENDMODULE.

➢ Activate (Ctrl+F3).
➢ Go back(F3).
➢ Double click on process after input (PAI) module ‘USER_COMMAND_0100.’.
➢ Opens a screen.

P a g e 98 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Click on ‘Yes’ button.

➢ Select ‘SAPMZMPP1’ and click on ‘enter’ button.


*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0100 INPUT.
case sy-ucomm.
when 'FCT1'.
** TO GET Material master data from database table mara
SELECT single * from mara into mara where matnr = mara-matnr.
when 'FCT2'.
** To comeout ot screen
leave PROGRAM.
endcase.

ENDMODULE.
➢ Save (CTRl+S) and Activate (Ctrl+F3).
➢ Go back (F3).

P a g e 99 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Activate screen (Ctrl+F3).

Steps to create Transaction or Tcode:


➢ Tcode: SE93 (Transaction Code: ZMPP1).
➢ Click on ‘Create’ button.
➢ Provide the details as below:

➢ Enter.
➢ Provide program name and screen number and check the check boxes as
below:

➢ Save (Ctrl+s).
P a g e 100 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ To execute the module pool program or dialog program.


➢ Provide the Tcode: zmpp1 in the command field and enter.

Navigation steps to find the screen field name and its data element, etc:
➢ Press F1 function key on the screen field, opens a screen.
➢ Click on ‘technical information’ icon and find the details as below:

Note: If the program field names and screen field names are same then system
will automatically transfers the data from program fields to screen fields and
vice-versa.

Steps to Create Module Pool Program or Dialog Program with Tcode: SE80
(Another way):

P a g e 101 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Tcode: SE80.
➢ In dropdown List: select ‘Program’.
➢ Provide program name: sapmzmpp.
➢ Enter 2 times and tick ‘Create with TOP include as below:


➢ Opens a screen and provide top include name as below:

➢ Enter.
➢ Opens a screen: keep as it is:

P a g e 102 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Click on ‘Save’ button to your package.

➢ Double click on ‘sapmzmpp’ from left panel.


➢ Click on ‘change’ button( ) from application toolbar.
INCLUDE ZMPPTOP. " global Data
INCLUDE ZMPPO01. " PBO-Modules
INCLUDE ZMPPI01. " PAI-Modules
* INCLUDE ZMPPF01. " FORM-Routines

➢ Double click on top include: INCLUDE ZMPPTOP." global Data


➢ Opens a screen.
PROGRAM SAPMZMPP.
tables mara. "it creates implicit work area.
➢ Save (ctrl+s) and back(F3).
➢ Double click on include: INCLUDE ZMPPO01. " PBO-Modules.
➢ Click on ‘yes’.
➢ Click on ‘yes’.
P a g e 103 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Screen appears as below:

➢ Click on ‘Save’ button to local object (package).


➢ Save (Ctrl+S) and back (F3).
➢ Similarly create another include: by double clicking on it .then save it and go
back(F3).
INCLUDE ZMPPI01. " PAI-Modules

P a g e 104 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Save (CTRL+S).
➢ Double click on the object (Sapmzmpp) from the left panel and right click-
>create ->screen.
➢ Opens a screen , provide screen number: 100 (as below).

➢ Enter.
➢ Opens a screen as below:
➢ Provide short description: Normal Screen-100.

➢ Save (Ctrl+S).
➢ Click on ‘Layout’ button from application toolbar.
➢ Click on ‘Dic./Program fields’ Icon from standard toolbar.
➢ Provide table: ‘Mara’ and enter.
➢ Select some of the fields as below: and drag and drop onto layout.

P a g e 105 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Select ‘pushbutton’ from left panel and drag and drop onto screen.
➢ Double click on ‘pushbutton’ and provide the properties such as Label and
Function code as below:

P a g e 106 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Select ‘pushbutton’ from left panel and drag and drop onto layout and
provide label and function code as below:

➢ Save it (Ctrl+S).
➢ Click on ‘flow logic’ button from application toolbar.
➢ Uncomment PBO and PAI modules as below and create them by double
clicking on them:
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
*
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0100.

➢ Save (Ctrl+S).
➢ Double click on Module ‘Status_0100’.
➢ Create? ‘Yes’.

P a g e 107 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Select PBO include, i.e., Include ZMPPO01 and ‘Enter’.


MODULE STATUS_0100 OUTPUT.
* SET PF-STATUS 'xxxxxxxx'.
* SET TITLEBAR 'xxx'.
if mara-matnr is INITIAL.
mara-matnr = '100-101'.
endif.
ENDMODULE.
➢ Save (Ctrl+S).
➢ Go back (F3).
➢ Double click on MODULE USER_COMMAND_0100. And create it
o Create Object? ‘Yes’

P a g e 108 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Select PAI include, i.e., Include ZMPPI01 and ‘Enter’.


MODULE USER_COMMAND_0100 INPUT.

case sy-ucomm.
when 'FCT1'.
** TO GET MATERIAL MASTER DATA FROM MARA
select SINGLE * from mara into mara where matnr = mara-matnr.
if sy-subrc <> 0.
message 'Material is invalid' type 'I'.
endif.
when 'FCT2'.
**** To comeout of screen
LEAVE PROGRAM.
endcase.
ENDMODULE.

➢ Save (Ctrl+S).
➢ Double click on the object: SAPMZMPP from the left panel.
➢ Right click->Activate.

P a g e 109 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Opens a screen.
➢ Enter.
➢ Select the Object (SAPMZMPP) from the left panel and right click->create-
>Transaction.
➢ Opens a screen, provide the details as below:

➢ Enter.
➢ Provide the details as below:

P a g e 110 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Enter.
➢ Save (CTrl+s).
➢ Execute (F8).

There are 2 ways to navigate to the next screen:


1) Static Navigation.
2) Dynamic Navigation.
1) Static Navigation: In this method, the second screen is called from the first
screen based on the properties of the first screen i.e., the next screen number
provided in the field ‘Next screen’.
Navigation steps to call 2nd screen statically:

P a g e 111 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

To create Abap module pool program:


➢ Tcode: SE38.
➢ Provide program name: zmpp4.
➢ Click on ‘create’ button.
➢ Provide title: module pool program.
➢ Type: module pool.
➢ Save to local object.
➢ Activate (ctrl+f3).
➢ To create first screen-100.
➢ Tcode: SE51.
➢ Program: ZMPP4.
➢ Screen number :0100.
➢ Click on ‘create’ button.
➢ Short Description: first screen-100
➢ Click on ‘Layout’ button from application toolbar.
➢ Click on ‘dictionary/program fields icon from standard toolbar.
➢ Provide table: mara and enter.
➢ Select ‘MATNR’ and drag and drop onto layout.
➢ Select the ‘pushbutton’ from left panel and drag and drop onto layout.
➢ Double click on pushbutton and provide details as below:
Text: Display.
FctCode: FCT1.
➢ Click on ‘flow logic’ button from application toolbar.
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.

PROCESS AFTER INPUT.


MODULE USER_COMMAND_0100.
➢ Save (ctrl+s).
➢ Double click on ‘module status-0100’.
➢ Opens a screen.

P a g e 112 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Click on ‘Yes’ button to create module status_0100.

➢ Select ‘main program’ and enter.


PROGRAM ZMPP4.

TABLES mara.
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
* SET PF-STATUS 'xxxxxxxx'.
* SET TITLEBAR 'xxx'.
if mara-matnr IS INITIAL.
mara-matnr = '100-400'.
endif.

ENDMODULE.

➢ Save (ctrl+s) and go back (f3).


➢ Double click on module ‘USER_COMMAND_0100’.
➢ Create object?
➢ Click on ‘yes’ button.
➢ Select ‘main program’ and enter.
MODULE USER_COMMAND_0100 INPUT.
case sy-ucomm.
when 'FCT1'.
** to get mara data from database table mara
select SINGLE * from mara into mara where matnr = mara-matnr.
P a g e 113 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

if sy-subrc <> 0.
message 'Material not found' type 'I'.
endif.
ENDCASE.

ENDMODULE.

➢ Save (ctrl+s) and go back (F3).


➢ Click on ‘attributes’ tab button.
➢ In ‘Other Attributes’.
➢ Next Screen: 200 (Note provide the screen number which should be your
second screen).
➢ Activate (Ctrl+F3).
➢ Now create Second screen-200.
➢ Tcode: SE51.
➢ Program: ZMPP4 (provide same program name).
➢ Screen number: 0200.
➢ Click on ‘create’ button.
Short Description second screen-200
➢ Click on ‘layout’ button.
➢ Click on ‘dictionary’ fields icon from standard toolbar.
➢ Provide table/field name: MARA and enter.
➢ Select the following fields:

P a g e 114 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Drag and drop onto layout.


➢ Select pushbutton from left panel and drag and drop onto layout and
double click and provide text and fctcode as below:

➢ Click on ‘Flow logic’ button from application toolbar.


➢ Save (ctrl+s).
PROCESS BEFORE OUTPUT.
* MODULE STATUS_0200.
*
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0200.
->Double click on ‘User_command_0200’ and create it
->create object? ‘yes’.
->select ‘Main program(zMPP4)’ and enter
MODULE USER_COMMAND_0200 INPUT.
case sy-ucomm.
when 'FCT2'.
** TO COMEOUT OF SCREEN
LEAVE PROGRAM.
endcase.
ENDMODULE.
➢ Activate (Ctrl+F3).
➢ Go back(F3).
➢ Activate (Ctrl+F3) the second screen-200.
➢ Finally create Tcode (Transaction code).
P a g e 115 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Tcode: SE93.
➢ Transaction Code: ZMPP0.
➢ Click on ‘create’ button.
Short text call next screen statically

➢ Enter.
➢ Provide the following details:

➢ Save (Ctrl+S).
➢ Now run the Tcode: ZMPP0 and enter.

2) Dynamic Navigation: In this method multiple screens are called dynamically


with the help of following commands:
i) Set sceen <scrno>.
ii) Call screen <scrno> [starting at <row> <col>]
[ending at <row> <col>].
iii) Leave to screen <scrno>.
iv) Set screen <scrno>.
Leave screen.
i) Set screen <scrno>: This command is used to call the second screen from the
first screen by displaying some data onto it when the user click on pushbutton
of first screen. To go back to first screen from second screen, you need to
provide a pushbutton and its respective functionality onto second screen.
ii) Call screen <scrno>: This command is used to call second screen from the first
screen by displaying some data onto it. This second screen is a pop-up screen
and to make it a pop-up screen, you need to select screen type as model dialog
P a g e 116 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

box and also the next screen field should be empty. To come back to the first
screen from the second screen (popup screen), you no need to provide
pushbutton onto second screen (popup screen) but just press enter button will
make you to go back to first screen.
iii) Leave to screen <scrno>: This command is used to call the second screen
from the first screen when the user clicks on pushbutton by displaying some
data onto it. To come back to the first screen from the second screen, you need
to provide pushbutton and its functionality onto second screen.
iv) Set screen <scrno>. Leave screen: This is similar to the command ‘leave to
screen <scrno>’.

Navigation Steps to call Next Screen dynamically:


DYNAMIC NAVIGATION

P a g e 117 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Tcode: SE80.
➢ Program: SAPMZMPP2.
➢ Enter 2 Times and Tick below and enter.

➢ Provide Top include name as below:


TOP include: zmpp2TOP
➢ Enter.
➢ Click on ‘Save’ button to local object.
➢ Double click on Object (SAPMZMPP2) from left panel.
➢ Click on ‘change’ button from application toolbar
INCLUDE ZMPP2TOP. " Global Data
INCLUDE ZMPP2O01. " PBO-Modules
INCLUDE ZMPP2I01. " PAI-Modules
➢ Uncomment PBO and PAI Includes and create them by double clicking.
➢ Double click on include ZMPP2O01.
➢ Create Object? ->click on ‘Yes’ button.
➢ Click on ‘save’ button to local object.
➢ Save (ctrl+S) and back (F3).
➢ Similarly create Include: INCLUDE ZMPP2I01. " PAI-Modules by double
clicking on it and save it.
➢ Double click on INCLUDE ZMPP2TOP. " Global Data
PROGRAM SAPMZMPP2.
TABLES: mara, marc, mard, makt. " To create implicit work areas
➢ Save it (Ctrl+S).
➢ Select the Object (SAPMZMPP2) from left panel and right click->create-
>screen.
➢ Provide the details as below:
P a g e 118 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Enter.
➢ Provide short description: Main screen-100(normal).
➢ Click on ‘layout’ button.
➢ Click on ‘Dic/Program Field’ Icon from standard toolbar.
➢ Provide table: Mara and enter.
➢ Select field ‘Matnr’ and drag and drop onto layout.
➢ Select pushbutton from left panel and drag and drop onto layout as below:

➢ Now provide label and Function code to it by double clicking on it.

P a g e 119 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Similarly, do it for all the pushbuttons.


➢ Save (Ctrl+S).
➢ Click on ‘Flow Logic’ button.
➢ Uncomment PAI module
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0100.
➢ Save (ctrl+S).
➢ To create user_command_0100->double click on it.
➢ Create Object? ->click on ‘yes’ button.
➢ Select I01 include as below:

➢ Enter.
MODULE USER_COMMAND_0100 INPUT.

case sy-ucomm.
when 'FCT1'.
** To get material master data from database table - Mara
select SINGLE * from mara into mara where matnr = mara-matnr.
if sy-subrc <> 0.
MESSAGE 'Material number not found' type 'I'.
endif.
* To call Next screen-200
set SCREEN 200.
when 'FCT2'.
** TO GET PLANT DATA FROM DATABASE TABLE -MARC
SELECT SINGLE * FROM MARC INTO MARC WHERE MATNR = MARA-
MATNR.
** TO CALL NEXT SCREEN-300(POP-UP SCREEN)
P a g e 120 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

CALL SCREEN 300 STARTING AT 5 4 ENDING AT 50 40.


WHEN 'FCT3'.
** TO GET STORAGE LOCATION DATA FROM DBTABLE - MARD
SELECT SINGLE * FROM MARD WHERE MATNR = MARA-MATNR.
** TO CALL NEXT SCREEN-400
LEAVE TO SCREEN 400.
WHEN 'FCT4'.
** TO GET MATERIAL DESCRIPTION FROM DBTABLE MAKT
SELECT SINGLE * FROM MAKT WHERE MATNR = MARA-
MATNR AND SPRAS = SY-LANGU.
** TO CALL NEXT SCREEN DYNAMICALLY-500
SET SCREEN 500.
LEAVE SCREEN.
WHEN 'FCT5'.
** TO COMEOUT OF SCREEN
LEAVE PROGRAM.
ENDCASE.

ENDMODULE.

➢ Select the object (sapmzpp2) from left panel and right click->create->screen
o Screen number: 200 and enter.
o Short Description: second screen-200.
➢ Click on ‘layout’ button.
➢ Click on ‘dic fields’ button.
➢ Provide table: mara and select some of fields such as matnr, mtart, matkl,
meins and drag and drop onto layout.
➢ Select pushbutton from left panel and drag and drop onto layout, double
click onto it and provide label and function code to the back pushbutton.

P a g e 121 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Click on flow logic button.


➢ Uncomment the pai module as below:
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0200.
➢ Save it (ctrl+S).
➢ Double click on module ‘user_command_0200’ and create it.
➢ By selecting I01 include.

MODULE USER_COMMAND_0200 INPUT.


case sy-ucomm.
when 'BACK'.
*** TO GO BACK TO MAIN SCREEN-100
LEAVE TO SCREEN 100.
ENDCASE.

ENDMODULE.
➢ Save it (Ctrl+S).
➢ Create another screen-300 (Modal dialog box).
➢ Select Screen->right click->create.
➢ Provide screen: 300 and enter.
➢ Short Description: Modal dialog box-300.

P a g e 122 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Note: Make Next Screen: __________(empty).


➢ Save (Ctrl+S).
➢ Click on ‘Layout’ button.
➢ Click on ‘dictionary field’ icon.
➢ Provide table: marc and enter.
➢ Select ‘matnr’, werks, ekgrp, minbe and bstmi, drag and drop onto layout
➢ Save (Ctrl+S).
➢ Back (F3).
➢ Select ‘Screen’ from left panel and right click->create.
➢ Provide screen: 400.
➢ Enter.
➢ Provide short description: Normal screen-400.
➢ Screen type:

➢ Click on ‘layout’ button.


➢ Click on ‘dictionary field’ icon.
➢ Provide table: Mard and enter.
➢ Select some fields such as: matnr, werks, lgort, labst and drag and drop
onto layout.
➢ Select ‘pushbutton’ from left panel and drag and drop onto layout.
➢ Double click on ‘pushbutton’, provide text: Back and FctCode: BACK.
➢ Save (ctrl+S).
➢ Click on ‘flow logic’ button.

P a g e 123 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

PROCESS AFTER INPUT.


MODULE USER_COMMAND_0400.
➢ Double click on ‘user_command_0400’.
➢ Create Object? ‘Yes’.

➢ Select ‘I01’ include as above and enter.


MODULE USER_COMMAND_0400 INPUT.
case sy-ucomm.
when 'BACK'.
*** TO GO BACK TO MAIN SCREEN-100
LEAVE TO SCREEN 100.
ENDCASE.

ENDMODULE.

➢ Save (Ctrl+S).
➢ Select the ‘Screen’ from left panel and right click->Create.
➢ Provide screen number: 500 and enter.
➢ Short Description: Normal screen-500.
➢ Click on ‘layout’ button.
➢ Click on ‘dictionary field’ icon.
➢ Provide table: Makt and enter.
➢ Select some of fields such as: matnr, maktx and drag and drop onto layout.
➢ Select ‘pushbutton’ from left panel and drag and drop onto layout.
➢ Double click on ‘pushbutton’, provide text: Back and FctCode: BACK.
P a g e 124 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Save (ctrl+S).
➢ Click on ‘flow logic’ button.
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0500.
➢ Save (ctrl+S).
➢ Double click on ‘user_command_0500’.
➢ Create Object? ‘Yes’.

➢ Enter.
MODULE USER_COMMAND_0500 INPUT.
case sy-ucomm.
when 'BACK'.
*** TO GO BACK TO MAIN SCREEN-100
LEAVE TO SCREEN 100.
ENDCASE.
ENDMODULE.

➢ Save (Ctrl+S).
➢ Double click on object (SAPMZMPP2) from left panel, right click->activate.
➢ Select object (SAPMZMPP2), right click->create->Transaction.

P a g e 125 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Enter and provide the details as below:

➢ Save (Ctrl+S).
➢ Execute (F8).

Navigation steps to create user-interface or status and attach at PBO event:


➢ Double click on 100 screen from left panel in Tcode: SE80 (SAPMZMPP2).
➢ Click on ‘change’ button from application toolbar.
o PROCESS BEFORE OUTPUT.
o MODULE STATUS_0100.
P a g e 126 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Double click on Module ‘Status_0100’.


MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'GUI'.
SET TITLEBAR 'xxx'.
if mara-matnr IS INITIAL.
mara-matnr = '100-400'.
endif.
ENDMODULE.
➢ Save (CTRl+S).
➢ Double click on ‘GUI’.
➢ Create GUI status? ‘Yes’.
➢ Provide Short Text: User Interface.
➢ Enter.
➢ Expand Menu bar.
➢ Provide Menu options as below:

➢ Double click on ‘Menu1’.


➢ Provide function codes as ‘COD1’,’COD2’ AND ‘COD3’ as below:

➢ Double click on ‘Menu2’ and provide details as below:

P a g e 127 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Expand Application toolbar.

➢ Double click on Fctcode ‘MARA’.


➢ Opens a screen.

➢ Enter and provide the details as below:

P a g e 128 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Enter.
➢ Select the Function key as ‘F5’ and enter.
➢ Similarly do the same for another function code: ’MARC’.
➢ Activate (Ctrl+F3).

To provide title to the Normal screen:


➢ In PBO event.
➢ In PBO module.
MODULE STATUS_0100 OUTPUT.
SET PF-STATUS 'GUI'.
SET TITLEBAR 'TITLE'.
ENDMODULE.
➢ Double click on ‘title’.
➢ Create title? ‘Yes’.
➢ Provide Title: Material Information.
➢ Click on ‘All Title’ button.
➢ Activate (CTrl+F3) and enter.
➢ Back (F3).
➢ Activate (Ctrl+F3).

SUBSCREEN: Is a screen within a screen.


Steps to work with Subscreen:
➢ Create a main screen as normal screen and provide sub-screen area onto it,
then name it.
P a g e 129 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Create another screen as type Sub-screen.


➢ Arrange fields onto the Sub-screen such that they should fit the sub-screen
area.
➢ Call the sub-screen in the Screen flow logic.

Navigation steps to create Sub-screens:


➢ Tcode: SE80.
➢ Program
➢ sapmzmpp3.
➢ Enter 2 times.

➢ Enter.
➢ Provide include name: zmpp3top.
➢ Enter.
➢ Save to local object.
➢ Click on ‘change’ button
INCLUDE ZMPP3TOP.
" global Data

* INCLUDE ZMPP3O01.
" PBO-Modules
* INCLUDE ZMPP3I01.
" PAI-Modules
* INCLUDE ZMPP3F01.
" FORM-Routines
➢ Save (Ctrl+S).
➢ DOUBLE CLICK ON: INCLUDE ZMPP3TOP.

P a g e 130 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

PROGRAM SAPMZMPP3.
*to create implicit work area
TABLES: MARA, MARC, MARD, MAKT.
*TO CREATE VARIABLE TO STORE SUBSCREEN NUMBER
DATA SCRNO(4).
➢ Save it (CTRL+S).
➢ Back (F3).
DOUBLE CLICK AND CREATE FOLLOWING INCLUDES:
INCLUDE ZMPP3O01.
" PBO-Modules
INCLUDE ZMPP3I01.
" PAI-Modules
->Save them.

To create main screen as normal screen:


➢ Select object (sapmzmpp3) from left panel and right click->create->screen.
➢ Provide screen number: 100 as below and enter.

➢ Short description: main screen-100.


➢ Click on ‘layout’ button.
➢ Click on ‘dictionary fields’ icon.
➢ Provide table: mara and enter.
➢ Select field ‘matnr’ and drag and drop onto layout.
➢ Select ‘sub-screen area’ from the left panel and drag and drop onto layout.
➢ Double click onto ‘sub-screen area’ and provide name to it as ‘sub’.
➢ Provide 5 pushbuttons such as ‘mara’, ‘marc’,’mard’, ’makt’ and ‘exit’ with
their respective function codes.
➢ Save (ctrl + s).
➢ Click on ‘flow logic’ button.
Process before output.
P a g e 131 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

module status_0100.
call subscreen sub including sy-repid scrno.
*sub: subscreen area
*sy-repid: contains current program name
*scrno:subscreen number

process after input.


module user_command_0100.
➢ Save (ctrl+s).
➢ Double click on module ‘user_command_0100’.
➢ Create object? ‘yes’.
➢ Select ‘i01’ include and enter.
MODULE USER_COMMAND_0100 INPUT.

case sy-ucomm.
when 'FCT1'.
* to get material master data from dbtable mara
select single * from mara into mara where matnr = mara-matnr.
** To call subscreen-200
scrno = 200.

when 'FCT2'.
** To get plant data for material from dbtable marc
select SINGLE * from marc where matnr = mara-matnr.
* to call subscreen-300
scrno = 300.
WHEN 'FCT3' .
** TO GET STORAGE LOCATION DATA FROM DBTABLE - MARD
SELECT SINGLE * FROM MARD WHERE MATNR = MARA-MATNR.
** TO CALL SUBSCREEN-400
scrno = 400.
WHEN 'FCT4' .
** TO GET MATERIAL DESCRIPTION FROM DBTABLE MAKT
SELECT SINGLE * FROM MAKT WHERE MATNR = MARA-MATNR AND
SPRAS = SY-LANGU.
P a g e 132 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

** TO CALL SUBSCREEN -500


SCRNO = 500.
WHEN 'FCT5' .
** TO COMEOUT OF SCREEN
LEAVE PROGRAM.
ENDCASE.

ENDMODULE.
➢ Save (Ctrl+S).
➢ Select the ‘Screen’ from left panel->right click->create.

➢ Enter.
➢ Provide short description: subscreen-200.
➢ Screen type as:

➢ Save (Ctrl+S).
➢ Click on ‘Layout’ button.
➢ Click on ‘Dictionary fields’.
➢ table: mara and enter.
➢ Select fields matnr, ersda, ernam, mtart, matkl, meins and drag and drop
onto layout.
➢ Adjust the fields so that they can fit the sub-screen area.
➢ Save.
P a g e 133 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Back (F3).
➢ Select ‘screen’ from left panel and right click->create.
➢ Provide screen number as ‘300’ as below: and enter.

➢ Provide short description and screen type as below:

➢ Save (ctrl+S).
➢ Click on ‘layout’ button.
➢ Click on ‘dictionary fields’.
➢ Table: marc and enter.
➢ Select some of the fields such as matnr, werks, ekgrp, minbe and bstmi and
drag and drop onto layout.
➢ Adjust to fit them into sub-screen area.
➢ Save and back (f3).
➢ Save(ctrl+S).
➢ Similarly, do it for 400 and 500 as sub-screens.
➢ Double click object (sapmzmpp3) from left panel->right click->activate.
➢ Select object (sapmzmpp3)->right click->create ->transaction.

P a g e 134 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Enter.
Program: sapmzmpp3.
Screen:100

➢ Save (Ctrl+S).

Note: To execute or Test: F8

To provide Custom help documentation using the event POH


In the screen flow logic of screen-100:
process on HELP-REQUEST.
field mara-matnr MODULE help1.
➢ Save (Ctrl+S).
➢ Double click on module ‘Help1’.
➢ Create object? ‘yes’.
➢ Select ‘IO1’ include and enter.
P a g e 135 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

MODULE HELP1 INPUT.


*POPUP_TO_DISPLAY_TEXT: This funciton module is used to display custom
help documentation onto popup screen when
*user press F1 function key.
CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT'
EXPORTING
TITEL = 'Custom Help Documentaion'
TEXTLINE1 = 'Material Number'
TEXTLINE2 = 'Enter Alpha numeric text'
* START_COLUMN = 25
* START_ROW =6.
ENDMODULE.
➢ Activate (Ctrl+F3).
➢ Back (F3).
➢ Activate (ctrl+F3) screen.

To Provide custom list of values with the help of event-POV


In Screen Flow Logic-100:
Process on value-request.
Field mara-matnr module list_values.
➢ Save (Ctrl+S).
➢ Double click on module ‘list_values’.
➢ Create object? ‘yes’.
➢ Select ‘IO1’ include and enter.
MODULE LIST_VALUES INPUT.
*POPUP_WITH_TABLE_DISPLAY:This function is used to display custom list o
f values when the user press F4 Funciton key
* on the screen field.

*to create internal table itab


data itab type TABLE OF matnr WITH HEADER LINE.
*to create variable
data ch type i.

P a g e 136 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

* to fill internal table itab with material numbers


select matnr from mara into table itab UP TO 50 rows.

CALL FUNCTION 'POPUP_WITH_TABLE_DISPLAY'


EXPORTING
ENDPOS_COL = 22
ENDPOS_ROW = 30
STARTPOS_COL = 5
STARTPOS_ROW = 3
TITLETEXT = 'Custome List of Values'
IMPORTING
CHOISE = ch
TABLES
VALUETAB = itab
EXCEPTIONS
BREAK_OFF = 1
OTHERS = 2.
IF SY-SUBRC = 0.
READ TABLE itab index ch.
if sy-subrc = 0.
mara-matnr = itab.
endif.
else.
message 'Invalid cusor position ' type 'I'.
ENDIF.

ENDMODULE.

➢ Activate (Ctrl+F3).
➢ Back (F3).
➢ Activate (ctrl+F3) screen.

TabStrip:
A TabStrip is a control that contains a collection of one or more tabs.

P a g e 137 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

Navigation Steps to create Tabstrip Control:


➢ Tcode: SE80.
➢ Please check the steps in video.
➢ Table Control: It is a screen table which displays multiple records onto it.
➢ Screen table acts as loop when code is written for it.

Navigation steps to create Table control

P a g e 138 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Tcode: SE38.
➢ Provide Program Name: sapmzmpp7.
➢ Click on ‘create’ button.
➢ Title: mpp with table control.
➢ Type: module pool.
➢ Save to local object.
➢ Activate (Ctrl+F3).
➢ Now create screen-100.
➢ Tcode: SE51.
Program: SAPMZMPP7
Screen number: 100
➢ Click on ‘create’.
Short Description: Normal screen-100
P a g e 139 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Click on ‘layout’ button.


➢ Click on ‘dictionary field’, provide table: Vbak and select vbeln, erdat,
ernam and vkorg and drag and drop onto layout as below:

➢ Select table control from left panel and drag and drop onto it.
➢ Double click onto table control and provide name and details as below:

➢ Click on Dictionary fields icon.


➢ Provide table: vbap.
➢ Select some of the fields such as vbeln, posnr, matnr, matkl, netwr,
kwmeng, netpr and drag and drop onto table control-TCL.
➢ Provide ‘Exit’ button.
➢ Click on ‘flow logic’.
PROCESS BEFORE OUTPUT.
LOOP at itab WITH CONTROL TCL CURSOR tcl-top_line.
MODULE STATUS_0100.
P a g e 140 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

endloop.
*
PROCESS AFTER INPUT.
loop .
ENDLOOP.
MODULE USER_COMMAND_0100.

➢ Create module ‘status_0100’ by double clicking on it.


➢ Create object? ‘yes’.
➢ Select main program: SAPMZMPP7 and enter.
PROGRAM SAPMZMPP7.

TABLES:vbak,vbap.
*to create internal table itab of structure vbap
data itab type table of vbap WITH HEADER LINE.
*to define table control-TCL in this program
CONTROLS TCL type tableview USING SCREEN '100'.

*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE STATUS_0100 OUTPUT.
MOVE-CORRESPONDING itab to vbap.
ENDMODULE.

➢ Save (Ctrl+S).
➢ Activate (CTrl+F3).
➢ Back (F3).
➢ Double click on module ‘user_command_0100’.
➢ Create object? ‘yes’.
➢ Select main program: SAPMZMPP7 and enter.
P a g e 141 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

MODULE USER_COMMAND_0100 INPUT.


case sy-ucomm.
when 'FCT1'.
** To get sales header data from vbak
SELECT single * from vbak where vbeln = vbak-vbeln.
** to get sales item data from vbap
SELECT * FROM VBAP INTO TABLE ITAB WHERE VBELN = VBAK-VBELN.
WHEN 'FCT2'.
REFRESH ITAB.
WHEN 'EXIT'.
LEAVE PROGRAM.
ENDCASE.
ENDMODULE.

➢ Activate (ctrl+f3).
➢ Back (f3).
➢ Activate screen (ctrl+f3).

Now to create Tcode: SE93:

➢ Enter.

P a g e 142 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Enter.
➢ Save (Ctrl+S).
➢ Execute or Test (F8).

Note: LOOP at itab WITH CONTROL TCL CURSOR tcl-top_line.


MODULE STATUS_0100.
endloop.
This loop statement reads a record from internal table itab and puts in a header
line, parallelly positioning the cursor at the top of line of table control-Tcl and
immediately a module ‘status_0100’ is called where header line (itab) data is
moved to implicit work area vbap. As program field names of implicit work area
vbap and table control-tcl screen fields which are also designed with vbap are
same, therefore system automatically transfers the data from implicit work area
vbap to table control-tcl. This continues till all records of internal table itab are
fetched.

P a g e 143 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

To update or manipulate records of Database table


1) To insert single record into database table
Syntax:
Insert <dbtable> from <wa>.
Or
Insert <dbtable>.
Or
Insert into <dbtable> values <wa>.

To insert multiple records into database table


Syntax:
Insert <dbtable> from table <itab>.

To update or change single record into database table


Syntax:
Update <dbtable> from <wa>.
Or
Update <dbtable>.

To change multiple records of database table


Syntax:
Update <dbtable> set f1 = val1 f2 = val2………..fn = valn
where <condition>.
Or
Update <dbtable> from table <itab>.
This ‘Update’ command will change the existing records of database table. If
record does not exist then this statement fails which is known through the
return value of sy-subrc, i.e sy-subrc <> 0.

To modify/Insert single record into database table


Syntax:
Modify <dbtable> from <wa>.
Or
Modify <dbtable>.

P a g e 144 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

To Modify/Insert multiple records of database table


Syntax:
Modify <dbtable> from table <itab.

To delete a single record from database table


Syntax:
Delete <dbtable> from <wa>.
Or
Delete <dbtable>.

To delete multiple records from database table


Syntax:
Delete <dbtable> from table <itab.

Note: In all these commands only those records of database table are changed
or deleted which matches the primary key fields.

Note: Modify command will check the record whether exist or not. If it exists
then ‘Modify’ command will modify the data to an existing record and if the
record you are going to modify does not exist then ‘Modify’ command will create
a new record into database table.

Assignment: Create module pool program for custom table zemp with
pushbuttons onto screen such as ‘Insert’, ’modify’, ’display’, ’update’ and
‘delete’.
Note: Please create new custom table: zemp.

To validate Screen fields:


There are different ways to validate screen fields:
1) Automatic checks.
2) Checks in Screen flow logic.
3) Checks in Abap module pool program.

P a g e 145 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

1) Automatic Checks: These are the check done by the system automatically
based on the Abap dictionary properties and also based on the standard system
settings.
Different Automatic checks are:
i) Required or mandatory.
ii) Proper data format such as date or time fields, etc.
iii) Valid value for input field.
i) Required or Mandatory: If you make a screen field required or mandatory
then if the user does not enter data onto it then system displays an error
message.
Navigation steps to make a screen field required or mandatory:
➢ Go to 100 screen (module pool program and screen-100 should exist).
➢ Tcode: SE51.
Program: SAPMZMPP.
Screen number: 0100.
➢ Click on ‘change’ button.
➢ Click on ‘layout’ button.
➢ Double click on ‘mara-matnr’ field.
➢ In attributes, click on ‘program’ tab button.
➢ Input: Required.
➢ Activate (Ctrl+F3).
Or
➢ Click on ‘element list’ tab button.
➢ Click on ‘special attribute’ tab button.
Mara-matnr ___required____
➢ Activate (Ctrl+F3).

ii) Proper Data Format: For some of screen fields such as ‘date field’ if user is
entering a value in the month more than ‘12’ or in days a value more than ‘31’
then system will automatically display an error message.
iii) Valid Value for Input field: If the screen fields are created with the help of
data element that contains value range such as fixed values or intervals or value
table in its domain then the entered value on the screen field is checked in value
range. If it does not exist then system will automatically displays an error
message.
P a g e 146 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

Note: Valid value for input field is used in BDC (Batch Data Communication) or
conversions.

To avoid Automatic Checks: To avoid automatic check, you need to create a PAI
module with an option ‘At Exit-command’ before the module ‘User_command’
and also you need to provide a property for ‘Exit’ pushbutton as ‘FCTtype’: ‘E’.

Navigation steps to avoid Automatic checks:


➢ Go to 100 screen (module pool program and screen-100 should exist).
➢ Tcode: SE51.
Program: SAPMZMPP.
Screen number: 0100.
➢ Click on ‘change’ button.
➢ Click on ‘layout’ button.
➢ Double click on ‘exit’ button.
➢ Provide the property: FCTtype: ‘E’.
➢ Click on ‘flow logic’ button.
PROCESS AFTER INPUT.
Module auto_out at exit-command.
MODULE USER_COMMAND_0100.
➢ Double click on ‘auto out’ and create it.
➢ Create object? ‘yes’.
➢ Select ‘I01’ include and enter.
MODULE AUTO_OUT INPUT.
case sy-ucomm.
when 'FCT2'.
**** To comeout of screen
LEAVE PROGRAM.
endcase.
ENDMODULE.
➢ Activate (Ctrl+F3) both module pool program and screen-100.

P a g e 147 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

2) Checks in Screen flow logic: Field command is used to validate a screen field
by providing list of values to it in the event PAI (Process After Input) before the
module ‘User_command’.
’Values’ keyword is used along with the field command for a particular screen
field in-order to provide list of values and this list of values should be provided
in single quotes and also in capital letters within the internal format.

In PAI Event before module ‘user_command’.


PROCESS AFTER INPUT.
*FIELD MARA-MATNR VALUES ('100-100','100-101').
FIELD MARA-MATNR VALUES (BETWEEN '000000000000000010' AND
'000000000000001000').
field mara-mtart values ('ROH','FERT').

Chain and endchain: It is used to validate group of screen fields and if any of the
screen field has error then it makes all the screen fields disabled expect the fields
in chain and endchain.
Example:
PROCESS AFTER INPUT.
Module auto_out at exit-command.
chain.
*FIELD MARA-MATNR VALUES ('100-100','100-101').
FIELD MARA-MATNR VALUES (BETWEEN '000000000000000010' AND
'000000000000001000').
field mara-mtart values ('ROH','FERT').
endchain.
MODULE USER_COMMAND_0100.

3) Checks in Abap module pool program: Module command is used along with
field command in the PAI Event before module ‘user_command’ inorder to
validate a particular screen field by calling a module which is written in abap
module pool program where validation is done.
Example:
In PAI Event
P a g e 148 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

Field mara-matnr module validate_matnr.


➢ Double click on module ‘validate_matnr’.
➢ Create object? ‘yes’.
➢ Select ‘I01’ include and enter.
Module validate_matnr input.
To validate material number:
select single * from mara into mara where matnr = mara-matnr and mtart =
mara-mtart.
If sy-subrc <> 0.
Message ‘material not found’ type ‘I’.
Endif.
➢ Activate both mpp and screen(ctrl+F3).

Standard Transaction codes:

MM (Material Management)
Tcodes:
o MM01: To create material master data.
o MM02: To change Material master data.
o MM03: To display Material master data.
o ME21: To create purchase order.
o ME22: To change Purchase order.
o ME23: To display Purchase order.
o ME21N: To create Purchase order.
o ME22N: To change Purchase order.
o ME23N: To display Purchase order.
o ME29N: To release Purchase order.
o ME31L: To create PO (Purchase Order) schedule agreement.
o ME32l: To change PO schedule agreement.
o ME33L: To display PO schedule agreement.
o ME31K: To create PO contract.
o ME32K: To change PO contract.
o ME33K: To display PO contract.
o ME41: To create RFQ (Request for Quotation).
o ME42: To change RFQ.
P a g e 149 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

o ME43: To display RFQ.


o ME45: To release RFQ.
o ME47: Create quotation.
o ME48: Display quotation.
o ME51: Create Purchase Requisition (PR).
o ME52: Change PR.
o ME53: Display PR.
o ME51N: Create PR.
o ME52N: Change PR.
o ME53N: Display PR.
o ME54/ME54N: To release PR.
o MIGO: Inbound delivery.
o MIRO: Incoming Invoice.

SD (Sale and Distribution)


o VA11: To create Enquiry (RFQ).
o VA12: To change Enquiry (RFQ).
o VA13: To display Enquiry (RFQ).
o VA21: To create Quotation.
o VA22: To change Quotation.
o VA23: To display Quotation.
o VA01: To create Sales order.
o VA02: To change Sales order.
o VA03: To display Sales order.

Outbound Delivery
o VL01/VL01N: To create Outbound Delivery.
o VL02/VL02N: To change Outbound Delivery.
o VL03/VL03N: To display Outbound Delivery.
o VT01: To create Shipment.
o VT02: To change Shipment.
o VT03: To display Shipment.

Billing / Invoice
o VF01: To Create billing document.
P a g e 150 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

o VF02: To Change billing document.


o VF03: To Display billing document.

To view all transaction codes: SM01

BDC (Batch Data Communication) or Conversion


Definition: It is used to transfer non-sap data (legacy system) to SAP R/3
system.

P a g e 151 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

Steps to Create BDC Program:


Note: Flat file is given to you as a text file or excel file from where this non-SAP
data is transferred to SAP R/3 system.

Step1: Read flat file data to an internal table (itab).


Step2: From internal table itab, data is not directly transferred to the database
of SAP R/3 system instead it has to go through screens and screen fields, i.e.,
through a particular transaction in a particular format called as BDCDATA
structure which stores both data and actions where the validation takes place.
Step3: There are 2 batch input methods to transfer non-sap data to SAP R/3
system. They are
i) Call transaction Method.
ii) Session Method.
i) Call Transaction Method: It is one of the Batch Input Method used to transfer
non-sap data to SAP R/3 system.
Syntax:
Call Transaction ‘Tcode’ using it_bdcdata [mode
‘A/N/E’] [update ‘A/S’] [messages into it_msg].
-> Tcode: It is a Transaction Code
-> it_bdcdata: It is an internal table of structure BDCDATA which contains 5 fields
such as:
i) Program: Module pool Program.
ii) Dynpro: Screen Number.
iii) Dynbegin: Start of screen.
iv) FNAM: Screen field name.
v) FVAL: Screen field value.
Mode A: All screens display (Foreground).
N: No screens display (Background).
E: Error screen display.
> Default mode is ‘A’, if you omit this option.
Update A (Asynchronous Update): It is the process in which a BDC Program
sends a record to update work process and will not wait for acknowledgement
instead it sends the next record to update work process. Update work process
will update the data to database table.

P a g e 152 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

Update S (Synchronous update): It is the process in which BDC Program sends


a record to update work process and will wait for the acknowledgement to come
from update work process. Once it gets the acknowledgement then it sends the
next record to update work process. The update work process will update the
data to database table.
> By default, Update is ‘A’, if you omit this option.
Messages into it_msg: It is used to handle both success and failure (errors)
messages. Internal table it_msg should be of structure ‘BDCMSGCOLL’.

ii) Session Method: It is one of the Batch Input Method which is used to transfer
Non-SAP data to SAP R/3 System.
-> In this Method, Sessions are created as files on application server and unless
and until you process session, data is not transferred to SAP R/3 system.
-> To process Session, Tcode is SM35.

File Handling: There are 2 types of files:


1) Local files
2) Sequential file or datasets.
1) Local files: Files present on presentation server or desktop or front end are
called as local files.
ALSM_EXCEL_TO_INTERANL_TABLE: This function module is used to upload
excel file present on presentation server or desktop to an internal table.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = Provide excel file along with path
I_BEGIN_COL = Provide begin of column position
I_BEGIN_ROW = Provide end of column position
I_END_COL = provide end of column position
I_END_ROW = provide end of row position
TABLES
INTERN = Provide an internal table of structure ALSMEX_TABLINE.

Note: ALSMEX_TABLINE: This structure has 3 fields such as row, col and value.

P a g e 153 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

WS_upload: This function module is used to upload text file or excel file
present on presentation server or desktop to an internal table.

Note: This Function WS_UPLOAD is outdated and not used now.


Gui_upload: This function module is used to upload text file or excel file
present on presentation server or desktop to an internal table.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = provide flat file name along with path
FILETYPE = 'ASC' or ‘BIN’
‘ASC’->means text file
‘BIN’->means binary file
->Default is ‘ASC’
HAS_FIELD_SEPARATOR = ' ' or ‘X’
‘X‘->means flat file fields are separated by tab space
‘ ’->means flat file fields can be separated by any delimiter or separator such as
‘,’ or ‘:’ or ‘;’ or ‘|’ or single space ,etc
Default is ‘ ‘.
TABLES
DATA_TAB = provide an internal table.

Gui_download: This function module is used to download internal table data


onto desktop or presentation server as text file or excel file.

Example: To read flat file data (Excel file) to an internal table.


REPORT ZUPLOAD_FILE1.

*TO CREATE LINE TYPE


TYPES:BEGIN OF LINE_TYPE,
MATNR TYPE MATNR,
MTART TYPE MTART,
MBRSH TYPE MBRSH,
MATKL TYPE MATKL,
MEINS TYPE MEINS,
MAKTX TYPE MAKTX,
P a g e 154 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

END OF LINE_TYPE.

*TO CREATE INTERNAL TABLE IT_MAT OF STRUCTURE LINE_TYPE


DATA IT_MAT TYPE TABLE OF LINE_TYPE WITH HEADER LINE.
*TO CREATE AN INTERNAL TABLE IT_EXCEL OF STRUCTURE ALSMEX_TABLINE
DATA IT_EXCEL TYPE TABLE OF ALSMEX_TABLINE WITH HEADER LINE.
** TO CREATE AN INPUT FIELD TO ENTER FLAT FILE ALONG WITH PATH
PARAMETERS P_FILE LIKE IBIPPARMS-PATH.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.


PERFORM BROWSE_FILE.

START-OF-SELECTION.
PERFORM UPLOAD_EXCEL_FILE.

*&---------------------------------------------------------------------*
*& Form BROWSE_FILE
*&---------------------------------------------------------------------*

FORM BROWSE_FILE .
*F4_FILENAME: THIS FUNCTION MODULE IS USED TO DISPLAY LIST OF FILES
AND RETURN THE SELECTED FILE.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
FILE_NAME = P_FILE.

ENDFORM.

*&---------------------------------------------------------------------*
*& Form UPLOAD_EXCEL_FILE
*&---------------------------------------------------------------------*
FORM UPLOAD_EXCEL_FILE .
*ALSM_EXCEL_TO_INTERNAL_TABLE:THIS FUNCTION MODULE IS USED TO
P a g e 155 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

UPLOAD EXCEL FILE DATA WHICH IS PRESENT ON PRESENTATION SERVER OR


DESKTOP OR
* FRONT END INTO AN INTERNAL TABLE.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
FILENAME = P_FILE
I_BEGIN_COL =1
I_BEGIN_ROW =1
I_END_COL =6
I_END_ROW = 10
TABLES
INTERN = IT_EXCEL
EXCEPTIONS
INCONSISTENT_PARAMETERS = 1
UPLOAD_OLE =2
OTHERS = 3.
IF SY-SUBRC = 0.
* LOOP AT IT_EXCEL.
* WRITE:/ IT_EXCEL-ROW,IT_EXCEL-COL,IT_EXCEL-VALUE.
* ENDLOOP.
loop at it_excel.
case it_excel-col.
when '1'.
it_mat-matnr = it_excel-value.
when '2'.
it_mat-mtart = it_excel-value.
when '3'.
it_mat-mbrsh = it_excel-value.
when '4'.
it_mat-matkl = it_excel-value.
when '5'.
it_mat-meins = it_excel-value.
when '6'.
it_mat-maktx = it_excel-value.
ENDCASE.
P a g e 156 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

at END OF row.
append it_mat.
clear:it_mat,it_excel.
endat.

ENDLOOP.
ELSE.
* MESSAGE 'Error in Excle file' type 'I'.
message text-001 type 'I'.
* Implement suitable error handling here
ENDIF.
loop at it_mat.
write:/ it_mat-matnr,it_mat-mtart,it_mat-mbrsh,it_mat-matkl,it_mat-
meins,it_mat-maktx.
ENDLOOP.
ENDFORM.

Recording: It is a sequence of steps recorded by the system automatically for


the screens and screen fields, i.e., for a particular transaction in a particular
format called as BDCDATA structure with which system generates a BDC
Program.
Tcode for Recording is SHDB.

Navigation steps to do recording for a particular Tcode: MM01


➢ Tcode: SHDB.
➢ Click on ‘New Recording’ button from application toolbar.
➢ Provide Recording: zrec1.
➢ Transaction: MM01.
➢ Click on ‘start recording’ button.

P a g e 157 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Click on ‘select view’ button from application toolbar.


➢ Select ‘basic data’.
➢ Click on enter button.

➢ Save it (ctrl+S).
➢ Save it (ctrl+S).
➢ Go back (F3).
➢ Select your recording (Zrec1).
➢ Click on ‘Program’ button from application toolbar.

P a g e 158 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Enter.
➢ Provide title: Bdc program using call transaction method.
➢ Click on ‘source code’ button.
➢ Save to your package (here local object).

report ZBDC_CALL_TRANS_MM01
no standard page heading line-size 255.
include bdcrecx1.
start-of-selection.
perform open_group.

perform bdc_dynpro using 'SAPLMGMM' '0060'.


perform bdc_field using 'BDC_CURSOR' 'RMMG1-MTART'.
perform bdc_field using 'BDC_OKCODE' '=AUSW'.
perform bdc_field using 'RMMG1-MATNR' '111B'.
perform bdc_field using 'RMMG1-MBRSH' 'M'.
perform bdc_field using 'RMMG1-MTART' 'FERT'.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR' 'MSICHTAUSW-DYTXT(01)'.
perform bdc_field using 'BDC_OKCODE' '=ENTR'.
perform bdc_field using 'MSICHTAUSW-KZSEL(01)' 'X'.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE' '=BU'.
perform bdc_field using 'MAKT-MAKTX' 'material text-111B'.
perform bdc_field using 'BDC_CURSOR' 'MARA-MEINS'.
perform bdc_field using 'MARA-MEINS' 'kg'.
P a g e 159 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

perform bdc_field using 'MARA-MTPOS_MARA' 'NORM'.


perform bdc_transaction using 'MM01'.

perform close_group.

TEXT_CONVERT_XLS_TO_SAP: This function module is used to upload excel


file present on presentation server or desktop to an internal table.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_FIELD_SEPERATOR =
I_LINE_HEADER = provide 'X' or space.
'X'->means your excel file has header data as first row.
I_TAB_RAW_DATA = provide an internal table it_raw of table structure TRUXS_
T_TEXT_DATA
I_FILENAME = provide file name along with path
TABLES
I_TAB_CONVERTED_DATA = provide an internal table of any stucture
EXCEPTIONS
CONVERSION_FAILED =1
OTHERS =2
.
IF SY-SUBRC <> 0.
MESSAGE 'Error while uploading excel file' type 'I'.
else.

ENDIF.

Example: To upload flat file data to an internal table


REPORT ZUPLOAD_FLATFILE1.

*TO CREATE LINE TYPE


TYPES:BEGIN OF LINE_TYPE,
MATNR TYPE MATNR,
MTART TYPE MTART,
MBRSH TYPE MBRSH,
P a g e 160 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

MATKL TYPE MATKL,


MEINS TYPE MEINS,
MAKTX TYPE MAKTX,
END OF LINE_TYPE.

*TO CREATE INTERNAL TABLE IT_MAT OF STRUCTURE LINE_TYPE


DATA IT_MAT TYPE TABLE OF LINE_TYPE WITH HEADER LINE.
*TO CREATE AN INTERNAL TABLE IT_RAW OF TABLE STRUCTURE TRUXS_T_TEX
T_DATA
DATA IT_RAW TYPE TRUXS_T_TEXT_DATA .
** TO CREATE AN INPUT FIELD TO ENTER FLAT FILE ALONG WITH PATH
PARAMETERS P_FILE LIKE RLGRAP-FILENAME.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.


PERFORM BROWSE_FILE.

START-OF-SELECTION.
PERFORM UPLOAD_EXCEL_FILE.

*&---------------------------------------------------------------------*
*& Form BROWSE_FILE
*&---------------------------------------------------------------------*

FORM BROWSE_FILE .
*F4_FILENAME: THIS FUNCTION MODULE IS USED TO DISPLAY LIST OF FILES AN
D RETURN THE SELECTED FILE.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
FILE_NAME = P_FILE.

ENDFORM.

*&---------------------------------------------------------------------*
P a g e 161 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

*& Form UPLOAD_EXCEL_FILE


*&---------------------------------------------------------------------*
FORM UPLOAD_EXCEL_FILE .
*TEXT_CONVERT_XLS_TO_SAP: This function module is used to upload excel fil
e present on presentation server or desktop to an internal table.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
I_LINE_HEADER = 'X'
I_TAB_RAW_DATA = IT_RAW
I_FILENAME = P_FILE
TABLES
I_TAB_CONVERTED_DATA = IT_MAT
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE 'Error while uploading excel file' type 'I'.
else.
loop at it_mat.
write:/ it_mat-matnr,it_mat-mtart,it_mat-mbrsh,it_mat-matkl,it_mat-
meins,it_mat-maktx.
ENDLOOP.
ENDIF.

ENDFORM.

Example: BDC Program using Call Transaction Method.


report ZBDC_CALL_TRANS_MM01
no standard page heading line-size 255.

*TO CREATE LINE TYPE


TYPES:BEGIN OF LINE_TYPE,
MATNR TYPE MATNR,
MTART TYPE MTART,
MBRSH TYPE MBRSH,
P a g e 162 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

* MATKL TYPE MATKL,


MEINS TYPE MEINS,
MAKTX TYPE MAKTX,
END OF LINE_TYPE.

*TO CREATE INTERNAL TABLE IT_MAT OF STRUCTURE LINE_TYPE


DATA IT_MAT TYPE TABLE OF LINE_TYPE WITH HEADER LINE.
*TO CREATE AN INTERNAL TABLE IT_RAW OF TABLE STRUCTURE
TRUXS_T_TEXT_DATA
DATA IT_RAW TYPE TRUXS_T_TEXT_DATA .
*TO CREATE AN INTERNAL TABLE IT_BDCDATA OF STRUCTURE BDCDATA
DATA IT_BDCDATA TYPE TABLE OF BDCDATA WITH HEADER LINE.

** TO CREATE AN INPUT FIELD TO ENTER FLAT FILE ALONG WITH PATH


PARAMETERS P_FILE LIKE IBIPPARMS-PATH.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.


PERFORM BROWSE_FILE.

start-of-selection.
PERFORM UPLOAD_EXCEL_FILE.
PERFORM MAP_DATA.

*&---------------------------------------------------------------------*
*& Form BROWSE_FILE
*&---------------------------------------------------------------------*

FORM BROWSE_FILE .
*F4_FILENAME: THIS FUNCTION MODULE IS USED TO DISPLAY LIST OF FILES
AND RETURN THE SELECTED FILE.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
FILE_NAME = P_FILE.

ENDFORM.
P a g e 163 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

*&---------------------------------------------------------------------*
*& Form UPLOAD_EXCEL_FILE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM UPLOAD_EXCEL_FILE .
*TEXT_CONVERT_XLS_TO_SAP: This function module is used to upload excel
file present on presentation server or desktop to an internal table.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_LINE_HEADER = 'X'
I_TAB_RAW_DATA = IT_RAW
I_FILENAME = P_FILE
TABLES
I_TAB_CONVERTED_DATA = IT_MAT
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE 'Error while uploading excel file' type 'I'.
else.
* loop at it_mat.
* write:/ it_mat-matnr,it_mat-mtart,it_mat-mbrsh,it_mat-matkl,it_mat-
meins,it_mat-maktx.
* ENDLOOP.
ENDIF.

ENDFORM.

*&---------------------------------------------------------------------*
P a g e 164 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

*& Form MAP_DATA


*&---------------------------------------------------------------------*
FORM MAP_DATA .

LOOP AT IT_MAT.
REFRESH IT_BDCDATA.
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MTART'.
perform bdc_field using 'BDC_OKCODE'
'=AUSW'.
perform bdc_field using 'RMMG1-MATNR'
IT_MAT-MATNR.
perform bdc_field using 'RMMG1-MBRSH'
IT_MAT-MBRSH.
perform bdc_field using 'RMMG1-MTART'
IT_MAT-MTART."'FERT'.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
'X'.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
perform bdc_field using 'MAKT-MAKTX'
IT_MAT-MAKTX."'material text-111B'.
perform bdc_field using 'BDC_CURSOR'
'MARA-MEINS'.
perform bdc_field using 'MARA-MEINS'
IT_MAT-MEINS."'kg'.
perform bdc_field using 'MARA-MTPOS_MARA'
'NORM'.
P a g e 165 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

*TO CALL TRANSACTION CODE-MM01


CALL TRANSACTION 'MM01' USING IT_BDCDATA MODE 'A' UPDATE 'A' .
IF SY-SUBRC = 0.
ENDIF.
ENDLOOP.
ENDFORM.

*----------------------------------------------------------------------*
* Start new screen *
*----------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR IT_BDCDATA.
IT_BDCDATA-PROGRAM = PROGRAM.
IT_BDCDATA-DYNPRO = DYNPRO.
IT_BDCDATA-DYNBEGIN = 'X'.
APPEND IT_BDCDATA.
ENDFORM.

*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM FVAL.
CLEAR IT_BDCDATA.
IT_BDCDATA-FNAM = FNAM.
IT_BDCDATA-FVAL = FVAL.
APPEND IT_BDCDATA.

ENDFORM.

*Gui_download: This function module is used to download internal table data o


nto desktop or presentation server as text file or excel file.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = Provide file name along with path
P a g e 166 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

FILETYPE = 'ASC' or 'BIN'


'ASC' ->means text file
'BIN' ->means binary file
Default is 'ASC'.
APPEND = 'X' or ' '
'X'-
>means the download records are appended to the end of flat file but will not
overwrite
' '->means it will overwrite.
default is ' '.

WRITE_FIELD_SEPARATOR = 'X' or ' '


'X'->means flat file fields are seperated by any delimitor or seperator
' '->means flat file fields are seperated by tabspace.
TABLES
DATA_TAB = provide an internal table whose data is downloade
d to desktop or front end

Example: BDC Program using Call Transaction Method with Errors:

REPORT ZBDC_CALL_TRANSACTION_MM01_ERR.

*TO CREATE LINE TYPE


TYPES:BEGIN OF LINE_TYPE,
MATNR TYPE MATNR,
MTART TYPE MTART,
MBRSH TYPE MBRSH,
* MATKL TYPE MATKL,
MEINS TYPE MEINS,
MAKTX TYPE MAKTX,
END OF LINE_TYPE.

*TO CREATE INTERNAL TABLE IT_MAT OF STRUCTURE LINE_TYPE


DATA IT_MAT TYPE TABLE OF LINE_TYPE WITH HEADER LINE.
*TO CREATE AN INTERNAL TABLE IT_RAW OF TABLE STRUCTURE TRUXS_T_TEX
P a g e 167 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

T_DATA
DATA IT_RAW TYPE TRUXS_T_TEXT_DATA .
*TO CREATE AN INTERNAL TABLE IT_BDCDATA OF STRUCTURE BDCDATA
DATA IT_BDCDATA TYPE TABLE OF BDCDATA WITH HEADER LINE.
*to create an internal table it_msg of structure BDCMSGCOLL
DATA IT_MSG TYPE TABLE OF BDCMSGCOLL WITH HEADER LINE .
** TO CREATE AN INPUT FIELD TO ENTER FLAT FILE ALONG WITH PATH
*TO CREATE AN INNTERNAL TABLE IT_ERRORS TO CAPTURE ERROR MESSAGES
DATA:BEGIN OF IT_ERRORS OCCURS 0,
MATNR TYPE MATNR,
MSG(100),
END OF IT_ERRORS.
** TO CREATE VARIABLES
DATA:S1 TYPE I,E1 TYPE I.
**To provide an input field to enter uploaded file along with path
PARAMETERS P_FILE LIKE IBIPPARMS-PATH.

**To provide an input field to enter downloaded file along with path
PARAMETERS P_EFILE LIKE IBIPPARMS-PATH.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.


PERFORM BROWSE_FILE USING P_FILE..

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_EFILE.


PERFORM BROWSE_FILE USING P_EFILE.

start-of-selection.
PERFORM UPLOAD_EXCEL_FILE.
PERFORM MAP_DATA.

END-OF-SELECTION.
PERFORM DOWNLOAD_FILE.

*&---------------------------------------------------------------------*
*& Form BROWSE_FILE
P a g e 168 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

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

FORM BROWSE_FILE USING FILE.


*F4_FILENAME: THIS FUNCTION MODULE IS USED TO DISPLAY LIST OF FILES AN
D RETURN THE SELECTED FILE.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
FILE_NAME = FILE.

ENDFORM.

*&---------------------------------------------------------------------*
*& Form UPLOAD_EXCEL_FILE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM UPLOAD_EXCEL_FILE .
*TEXT_CONVERT_XLS_TO_SAP: This function module is used to upload excel fil
e present on presentation server or desktop to an internal table.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
I_LINE_HEADER = 'X'
I_TAB_RAW_DATA = IT_RAW
I_FILENAME = P_FILE
TABLES
I_TAB_CONVERTED_DATA = IT_MAT
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE 'Error while uploading excel file' type 'I'.
else.
P a g e 169 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

* loop at it_mat.
* write:/ it_mat-matnr,it_mat-mtart,it_mat-mbrsh,it_mat-matkl,it_mat-
meins,it_mat-maktx.
* ENDLOOP.
ENDIF.

ENDFORM.

*&---------------------------------------------------------------------*
*& Form MAP_DATA
*&---------------------------------------------------------------------*
FORM MAP_DATA .

LOOP AT IT_MAT.
REFRESH :IT_MSG,IT_BDCDATA.
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MTART'.
perform bdc_field using 'BDC_OKCODE'
'=AUSW'.
perform bdc_field using 'RMMG1-MATNR'
IT_MAT-MATNR.
perform bdc_field using 'RMMG1-MBRSH'
IT_MAT-MBRSH.
perform bdc_field using 'RMMG1-MTART'
IT_MAT-MTART."'FERT'.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
'X'.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
P a g e 170 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

perform bdc_field using 'BDC_OKCODE'


'=BU'.
perform bdc_field using 'MAKT-MAKTX'
IT_MAT-MAKTX."'material text-111B'.
perform bdc_field using 'BDC_CURSOR'
'MARA-MEINS'.
perform bdc_field using 'MARA-MEINS'
IT_MAT-MEINS."'kg'.
perform bdc_field using 'MARA-MTPOS_MARA'
'NORM'.
*TO CALL TRANSACTION CODE-MM01
CALL TRANSACTION 'MM01' USING IT_BDCDATA MODE 'N' UPDATE 'A' MES
SAGES INTO IT_MSG.
READ TABLE IT_MSG WITH KEY MSGTYP = 'E'.
IF SY-SUBRC = 0.
IT_ERRORS-MATNR = IT_MAT-MATNR.
**FORMAT_MESSAGE:THIS FUNCTION MODULE IS USED TO COLLECT COMPLET
E MESSAGE.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
ID = IT_MSG-MSGID
LANG = '-D'
NO = IT_MSG-MSGNR
V1 = IT_MSG-MSGV1
V2 = IT_MSG-MSGV2
V3 = IT_MSG-MSGV3
V4 = IT_MSG-MSGV4
IMPORTING
MSG = IT_ERRORS-MSG
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.
P a g e 171 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

APPEND IT_ERRORS.
E1 = E1 + 1.
CLEAR : IT_ERRORS.
DELETE IT_MAT.
ELSE.
S1 = S1 + 1.
ENDIF.
ENDLOOP.
IF SY-SUBRC = 0.
* MESSAGE text-001 S1 text-002 E1 type 'I'.
message i000(zmsg) with text-001 s1 e1 'Records has errors'.
ENDIF.
ENDFORM.

*----------------------------------------------------------------------*
* Start new screen *
*----------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR IT_BDCDATA.
IT_BDCDATA-PROGRAM = PROGRAM.
IT_BDCDATA-DYNPRO = DYNPRO.
IT_BDCDATA-DYNBEGIN = 'X'.
APPEND IT_BDCDATA.
ENDFORM.

*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM FVAL.
CLEAR IT_BDCDATA.
IT_BDCDATA-FNAM = FNAM.
IT_BDCDATA-FVAL = FVAL.
APPEND IT_BDCDATA.

ENDFORM.
P a g e 172 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

*&---------------------------------------------------------------------*
*& Form DOWNLOAD_FILE
*&---------------------------------------------------------------------*
FORM DOWNLOAD_FILE .
DATA L_FILE TYPE STRING.
L_FILE = P_EFILE.
*Gui_download: This function module is used to download internal table data o
nto desktop or presentation server as text file or excel file.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
FILENAME = L_FILE
FILETYPE = 'ASC'
APPEND = 'X'
WRITE_FIELD_SEPARATOR = ' '
TABLES
DATA_TAB = IT_ERRORS
EXCEPTIONS
FILE_WRITE_ERROR =1
NO_BATCH =2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE =4
NO_AUTHORITY =5
UNKNOWN_ERROR =6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
P a g e 173 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.

ENDFORM.

ii) Session Method: It is one of the batch input methods used to transfer non-
SAP data to SAP R/3 system.
o In Session method, sessions are created as files onto application server and
unless and until you process session, data is not transferred to database of
SAP R/3 system.
o To process session Tcode is SM35.
o In Session method, errors are automatically handled by the system and you
no need to explicitly handle them.
o Session method uses 3 function modules:
1) BDC_OPEN_Group: This function module is used to create session (file) on
application server.
Syntax:
Call function ‘BDC_OPEN_Group’
Exporting
Group = name of session
Holdate = provide the date on which session is locked
Keep = ‘X’ or ‘ ‘
‘X’ ->means hold or keep the processed session on application server
‘ ‘ -> space means , it is used to delete the processed session from
application server.
User = provide the name of sapuser.

P a g e 174 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

2) BDC_INSERT: This function module is used to insert internal table (it_bdcdata)


of structure BDCDATA along with Tcode (ex:mm01) into session.
Call function ‘BDC_INSERT’
Exporting
Tcode = provide the Tcode(MM01)
Tables
Dynprotab = provide an internal table it_bdcdata of structure BDCDATA

3) BDC_Close_group: This Function is used to close the session (file).

Example: BDC Program using Session Method:


REPORT ZBDC_SESSION_METHOD.

*TO CREATE LINE TYPE


TYPES:BEGIN OF LINE_TYPE,
MATNR TYPE MATNR,
MTART TYPE MTART,
MBRSH TYPE MBRSH,
* MATKL TYPE MATKL,
MEINS TYPE MEINS,
MAKTX TYPE MAKTX,
END OF LINE_TYPE.

*TO CREATE INTERNAL TABLE IT_MAT OF STRUCTURE LINE_TYPE


DATA IT_MAT TYPE TABLE OF LINE_TYPE WITH HEADER LINE.
*TO CREATE AN INTERNAL TABLE IT_RAW OF TABLE STRUCTURE TRUXS_T_TEX
T_DATA
DATA IT_RAW TYPE TRUXS_T_TEXT_DATA .
*TO CREATE AN INTERNAL TABLE IT_BDCDATA OF STRUCTURE BDCDATA
DATA IT_BDCDATA TYPE TABLE OF BDCDATA WITH HEADER LINE.

** TO CREATE AN INPUT FIELD TO ENTER FLAT FILE ALONG WITH PATH


PARAMETERS P_FILE LIKE IBIPPARMS-PATH.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.


P a g e 175 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

PERFORM BROWSE_FILE.

start-of-selection.
PERFORM UPLOAD_EXCEL_FILE.
PERFORM open_group.
PERFORM MAP_DATA.
PERFORM close_group.

*&---------------------------------------------------------------------*
*& Form BROWSE_FILE
*&---------------------------------------------------------------------*

FORM BROWSE_FILE .
*F4_FILENAME: THIS FUNCTION MODULE IS USED TO DISPLAY LIST OF FILES AN
D RETURN THE SELECTED FILE.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
FILE_NAME = P_FILE.

ENDFORM.

*&---------------------------------------------------------------------*
*& Form UPLOAD_EXCEL_FILE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM UPLOAD_EXCEL_FILE .
*TEXT_CONVERT_XLS_TO_SAP: This function module is used to upload excel fil
e present on presentation server or desktop to an internal table.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
I_LINE_HEADER = 'X'
P a g e 176 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

I_TAB_RAW_DATA = IT_RAW
I_FILENAME = P_FILE
TABLES
I_TAB_CONVERTED_DATA = IT_MAT
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE 'Error while uploading excel file' type 'I'.
else.
* loop at it_mat.
* write:/ it_mat-matnr,it_mat-mtart,it_mat-mbrsh,it_mat-matkl,it_mat-
meins,it_mat-maktx.
* ENDLOOP.
ENDIF.

ENDFORM.

*&---------------------------------------------------------------------*
*& Form MAP_DATA
*&---------------------------------------------------------------------*
FORM MAP_DATA .

LOOP AT IT_MAT.
REFRESH IT_BDCDATA.
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MTART'.
perform bdc_field using 'BDC_OKCODE'
'=AUSW'.
perform bdc_field using 'RMMG1-MATNR'
IT_MAT-MATNR.
perform bdc_field using 'RMMG1-MBRSH'
IT_MAT-MBRSH.
P a g e 177 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

perform bdc_field using 'RMMG1-MTART'


IT_MAT-MTART."'FERT'.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
'X'.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
perform bdc_field using 'MAKT-MAKTX'
IT_MAT-MAKTX."'material text-111B'.
perform bdc_field using 'BDC_CURSOR'
'MARA-MEINS'.
perform bdc_field using 'MARA-MEINS'
IT_MAT-MEINS."'kg'.
perform bdc_field using 'MARA-MTPOS_MARA'
'NORM'.
*TO insert mapped data into session(mysession1)
perform bdc_insert.
ENDLOOP.
IF SY-SUBRC = 0.
MESSAGE 'Records updated successfully' type 'I'.
ENDIF.
ENDFORM.

*----------------------------------------------------------------------*
* Start new screen *
*----------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR IT_BDCDATA.
IT_BDCDATA-PROGRAM = PROGRAM.
IT_BDCDATA-DYNPRO = DYNPRO.
P a g e 178 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

IT_BDCDATA-DYNBEGIN = 'X'.
APPEND IT_BDCDATA.
ENDFORM.

*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM FVAL.
CLEAR IT_BDCDATA.
IT_BDCDATA-FNAM = FNAM.
IT_BDCDATA-FVAL = FVAL.
APPEND IT_BDCDATA.

ENDFORM.

*&---------------------------------------------------------------------*
*& Form OPEN_GROUP
*&---------------------------------------------------------------------*
FORM OPEN_GROUP .
**1)BDC_OPEN_Group: This function module is used to create session(file) on a
pplication server.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
GROUP = 'mysession1'
* HOLDDATE = FILLER8
KEEP = 'X'
USER = sy-uname
EXCEPTIONS
CLIENT_INVALID = 1
DESTINATION_INVALID = 2
GROUP_INVALID =3
GROUP_IS_LOCKED = 4
HOLDDATE_INVALID = 5
INTERNAL_ERROR = 6
P a g e 179 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

QUEUE_ERROR =7
RUNNING =8
SYSTEM_LOCK_ERROR = 9
USER_INVALID = 10
OTHERS = 11.
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.

*&---------------------------------------------------------------------*
*& Form BDC_INSERT
*&---------------------------------------------------------------------*

FORM BDC_INSERT .
**2)BDC_INSERT: This function module is used to insert internal table (it_bdcda
ta) of structure BDCDATA along with Tcode(ex:mm01) into session
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'MM01'
TABLES
DYNPROTAB = it_bdcdata
EXCEPTIONS
INTERNAL_ERROR = 1
NOT_OPEN =2
QUEUE_ERROR = 3
TCODE_INVALID = 4
PRINTING_INVALID = 5
POSTING_INVALID = 6
OTHERS = 7.
IF SY-SUBRC <> 0.
MESSAGE id sy-msgid type sy-msgty NUMBER sy-msgno with sy-msgv1 sy-
P a g e 180 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

msgv2 sy-msgv3 sy-msgv4.


ENDIF.

ENDFORM.

*&---------------------------------------------------------------------*
*& Form CLOSE_GROUP
*&---------------------------------------------------------------------*
FORM CLOSE_GROUP .
**3)BDC_Close_group:this Function is used to close the session(file)
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
NOT_OPEN = 1
QUEUE_ERROR = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.

ENDFORM.

Steps to Process Session


➢ Tcode: SM35.
➢ Select your session: mysession1.
➢ Click on ‘process’ button from application toolbar.
➢ Opens a screen.

P a g e 181 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

o *Process/foreground: means ‘A’ (All Screens).


o *Display errors only: means ‘E’ (only error screen).
o *Background: means ‘N’ (No screens).
➢ Once all the records are processed system displays the following window:

➢ Click on ‘session overview’ button.


➢ Select your session (mysession1) and click on ‘Analysis’ button from
application toolbar.
➢ Click on ‘log created’ tab as below:

P a g e 182 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

Note: Execute your BDC program: ZBDC_SESSION_METHOD and process your


created session in background as below:
Steps to Process Session in Background
➢ Tcode: SM35.
➢ Select your session (mysession1).
➢ Click on ‘process’ button from application toolbar.
➢ Processing mode

➢ Click on ‘process’.
➢ Will get the following message: 1 session(s) transferred to background
processing.
➢ Note: To check the background job status: Tcode: SM37. Here provide your
session name as below:
➢ Job Name: MYSESSION1 and click on execute button, you can find the status
of background job.
➢ Click on ‘Analysis’ button in your SM35 screen.
➢ Click on ‘log created’ tab button and view success and failure messages.

P a g e 183 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

Example#2: BDC Program using Session Method with flat file as Text file.

REPORT ZBDC_SESSION_METHOD_TEXT_FILE.

*TO CREATE LINE TYPE


TYPES:BEGIN OF LINE_TYPE,
MATNR TYPE MATNR,
MTART TYPE MTART,
MBRSH TYPE MBRSH,
* MATKL TYPE MATKL,
MEINS TYPE MEINS,
MAKTX TYPE MAKTX,
END OF LINE_TYPE.

*TO CREATE INTERNAL TABLE IT_MAT OF STRUCTURE LINE_TYPE


DATA IT_MAT TYPE TABLE OF LINE_TYPE WITH HEADER LINE.
*TO CREATE AN INTERNAL TABLE IT_RAW OF TABLE STRUCTURE TRUXS_T_TEX
T_DATA
DATA IT_RAW TYPE TRUXS_T_TEXT_DATA .
*TO CREATE AN INTERNAL TABLE IT_BDCDATA OF STRUCTURE BDCDATA
DATA IT_BDCDATA TYPE TABLE OF BDCDATA WITH HEADER LINE.

** TO CREATE AN INPUT FIELD TO ENTER FLAT FILE ALONG WITH PATH


PARAMETERS P_FILE LIKE IBIPPARMS-PATH.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.


PERFORM BROWSE_FILE.

start-of-selection.
PERFORM UPLOAD_text_FILE.
PERFORM open_group.
PERFORM MAP_DATA.
PERFORM close_group.

*&---------------------------------------------------------------------*
P a g e 184 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

*& Form BROWSE_FILE


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

FORM BROWSE_FILE .
*F4_FILENAME: THIS FUNCTION MODULE IS USED TO DISPLAY LIST OF FILES AN
D RETURN THE SELECTED FILE.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
FILE_NAME = P_FILE.

ENDFORM.

*&---------------------------------------------------------------------*
*& Form UPLOAD_EXCEL_FILE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM UPLOAD_text_FILE .
data l_file type string.
l_file = p_file.
*gui_upload:this funtion is used to upload flat file data which can be excel file o
r text file to an internal table
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = l_file
FILETYPE = 'ASC' "it tells text file
HAS_FIELD_SEPARATOR = 'X'
TABLES
DATA_TAB = it_mat
EXCEPTIONS
FILE_OPEN_ERROR =1
FILE_READ_ERROR =2
P a g e 185 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

NO_BATCH =3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE =5
NO_AUTHORITY =6
UNKNOWN_ERROR =7
BAD_DATA_FORMAT =8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17.
IF SY-SUBRC <> 0.
MESSAGE id sy-msgid type sy-msgty NUMBER sy-msgno with sy-msgv1 sy-
msgv2 sy-msgv3 sy-msgv4.
ENDIF.

ENDFORM.

*&---------------------------------------------------------------------*
*& Form MAP_DATA
*&---------------------------------------------------------------------*
FORM MAP_DATA .

LOOP AT IT_MAT.
REFRESH IT_BDCDATA.
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MTART'.
perform bdc_field using 'BDC_OKCODE'
'=AUSW'.
P a g e 186 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

perform bdc_field using 'RMMG1-MATNR'


IT_MAT-MATNR.
perform bdc_field using 'RMMG1-MBRSH'
IT_MAT-MBRSH.
perform bdc_field using 'RMMG1-MTART'
IT_MAT-MTART."'FERT'.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.
perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
'X'.
perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
perform bdc_field using 'MAKT-MAKTX'
IT_MAT-MAKTX."'material text-111B'.
perform bdc_field using 'BDC_CURSOR'
'MARA-MEINS'.
perform bdc_field using 'MARA-MEINS'
IT_MAT-MEINS."'kg'.
perform bdc_field using 'MARA-MTPOS_MARA'
'NORM'.
*TO insert mapped data into session(mysession1)
perform bdc_insert.
ENDLOOP.
IF SY-SUBRC = 0.
MESSAGE 'Records updated successfully' type 'I'.
ENDIF.
ENDFORM.

*----------------------------------------------------------------------*
* Start new screen *
*----------------------------------------------------------------------*
P a g e 187 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

FORM BDC_DYNPRO USING PROGRAM DYNPRO.


CLEAR IT_BDCDATA.
IT_BDCDATA-PROGRAM = PROGRAM.
IT_BDCDATA-DYNPRO = DYNPRO.
IT_BDCDATA-DYNBEGIN = 'X'.
APPEND IT_BDCDATA.
ENDFORM.

*----------------------------------------------------------------------*
* Insert field *
*----------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM FVAL.
CLEAR IT_BDCDATA.
IT_BDCDATA-FNAM = FNAM.
IT_BDCDATA-FVAL = FVAL.
APPEND IT_BDCDATA.

ENDFORM.

*&---------------------------------------------------------------------*
*& Form OPEN_GROUP
*&---------------------------------------------------------------------*
FORM OPEN_GROUP .
**1)BDC_OPEN_Group: This function module is used to create session(file) on a
pplication server.
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
GROUP = 'mysession1'
* HOLDDATE = FILLER8
KEEP = 'X'
USER = sy-uname
EXCEPTIONS
CLIENT_INVALID = 1
DESTINATION_INVALID = 2
P a g e 188 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

GROUP_INVALID =3
GROUP_IS_LOCKED = 4
HOLDDATE_INVALID = 5
INTERNAL_ERROR = 6
QUEUE_ERROR =7
RUNNING =8
SYSTEM_LOCK_ERROR = 9
USER_INVALID = 10
OTHERS = 11.
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.

*&---------------------------------------------------------------------*
*& Form BDC_INSERT
*&---------------------------------------------------------------------*

FORM BDC_INSERT .
**2)BDC_INSERT: This function module is used to insert internal table (it_bdcda
ta) of structure BDCDATA along with Tcode(ex:mm01) into session
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'MM01'
TABLES
DYNPROTAB = it_bdcdata
EXCEPTIONS
INTERNAL_ERROR = 1
NOT_OPEN =2
QUEUE_ERROR = 3
TCODE_INVALID = 4
PRINTING_INVALID = 5
P a g e 189 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

POSTING_INVALID = 6
OTHERS = 7.
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.

*&---------------------------------------------------------------------*
*& Form CLOSE_GROUP
*&---------------------------------------------------------------------*
FORM CLOSE_GROUP .
**3)BDC_Close_group:this Function is used to close the session(file)
CALL FUNCTION 'BDC_CLOSE_GROUP'
EXCEPTIONS
NOT_OPEN = 1
QUEUE_ERROR = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
* Implement suitable error handling here
ENDIF.

ENDFORM.

Assignment: Please create BDC Program using Session Method or Call


transaction method with flat file as text file where text file fields are separated
by ‘,’ (comma).

Sequential file or Datasets: The files present on application server are called as
datasets or sequential file.

P a g e 190 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

Syntax To create Sequential File or Dataset on Application Server:


Open dataset <dsn> for input/output/appending in
text/binary mode endcoding default.

➢ dsn: dataset name or sequential file.


➢ Input: It is used to read the data from dataset or sequential file.
➢ Output: It is used to write the data onto dataset or sequential file.
➢ Appending: It is used, if the sequential file already exists then this option will
not overwrite the data to it, instead it will add the data at the end of existing
file. If the sequential file does not exist then it will create it.
➢ Text Mode: The sequential file contains alphanumeric text.
➢ Binary mode: The sequential file contains 0’s and 1’s.
➢ Encoding default: Before the version 4.7EE, each character is represented as
ASCII code i.e., one byte but from 4.7EE onwards each character is
represented in Unicode i.e., 2 bytes therefore we need this option.

To read data from sequential file


Syntax:
Read dataset <dsn> into <wa>.
To transfer data to Sequential file
Syntax: Transfer <wa> to <dsn>.
P a g e 191 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

To close dataset or sequential file


Syntax: Close dataset <dsn>.

Note: To view sequential files Tcode: AL11 and by default sequential files are
stored in directories DIR_Home and DIR_temp.

Example: To create sequential file or dataset at application server

REPORT ZCREATE_DSN.

*TO CREATE LINE TYPE WITH SOME FIELDS OF MARA


TYPES:BEGIN OF LINE_TYPE,
MATNR TYPE MATNR,
MTART TYPE MTART,
MBRSH TYPE MBRSH,
MATKL TYPE MATKL,
MEINS TYPE MEINS,
END OF LINE_TYPE.

* *TO CREATE AN INTERNAL TABLE OF STRUCTURE LINE_TYPE


DATA ITAB TYPE TABLE OF LINE_TYPE .
** *TO CREATE WORK AREA OF STRUCTURE LINE_TYPE
DATA WA TYPE LINE_TYPE.

START-OF-SELECTION.
PERFORM FILL_ITAB.
** TO CREATE DATA SET
PERFORM CREATE_DSN.
** TO FILL SEQUENTIAL FILE
PERFORM FILL_DSN.
** TO CLOSE DATASET
PERFORM CLOSE_DSN.

*&---------------------------------------------------------------------*
P a g e 192 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

*& Form FILL_ITAB


*&---------------------------------------------------------------------*
FORM FILL_ITAB .

*TO FILL INTERNAL TABLE ITAB


SELECT MATNR MTART MBRSH MATKL MEINS FROM MARA INTO TABLE ITAB
UP TO 30 ROWS.

ENDFORM.

*&---------------------------------------------------------------------*
*& Form CREATE_DSN
*&---------------------------------------------------------------------*
FORM CREATE_DSN .

**TO CREATE DATASET OR SEQUENTIAL FILE


OPEN DATASET 'SFILE1' FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.

ENDFORM.

*&---------------------------------------------------------------------*
*& Form FILL_DSN
*&---------------------------------------------------------------------*

FORM FILL_DSN .

LOOP AT ITAB INTO WA.


** tO TRANSFER THE DATA TO DATASET
CALL FUNCTION 'CONVERSION_EXIT_MATN1_OUTPUT'
EXPORTING
INPUT = WA-MATNR
IMPORTING
OUTPUT = WA-MATNR
P a g e 193 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

TRANSFER WA TO 'SFILE1'.
ENDLOOP.

ENDFORM.

*&---------------------------------------------------------------------*
*& Form CLOSE_DSN
*&---------------------------------------------------------------------*
FORM CLOSE_DSN .

***TO CLOSE DATASET


CLOSE DATASET 'SFILE1'.

ENDFORM.

To read or upload the data from dataset or sequential file


Example:
REPORT ZREAD_DSN.

*TO CREATE LINE TYPE WITH SOME FIELDS OF MARA


TYPES:BEGIN OF LINE_TYPE,
MATNR TYPE MATNR,
MTART TYPE MTART,
MBRSH TYPE MBRSH,
MATKL TYPE MATKL,
MEINS TYPE MEINS,
END OF LINE_TYPE.

* *TO CREATE AN INTERNAL TABLE OF STRUCTURE LINE_TYPE


DATA ITAB TYPE TABLE OF LINE_TYPE .
** *TO CREATE WORK AREA OF STRUCTURE LINE_TYPE
P a g e 194 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

DATA WA TYPE LINE_TYPE.

START-OF-SELECTION.
** TO OPEN DATA SET
PERFORM OPEN_DSN.
** TO CLOSE DATASET
PERFORM CLOSE_DSN.

*&---------------------------------------------------------------------*
*& Form CREATE_DSN
*&---------------------------------------------------------------------*
FORM OPEN_DSN .

**TO OPEN DATASET OR SEQUENTIAL FILE


OPEN DATASET 'SFILE1' FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF SY-SUBRC = 0.
DO .
*** TO READ DATA FROM SEQUENTIAL FILE.
READ DATASET 'SFILE1' INTO WA.
IF SY-SUBRC = 0.
APPEND WA TO ITAB.
CLEAR WA.
ELSE.
EXIT.
ENDIF.
ENDDO.
ELSE.
MESSAGE 'FILE NOT FOUND' TYPE 'I'.
ENDIF.
LOOP AT ITAB INTO WA.
WRITE:/ WA-MATNR,WA-MTART,WA-MBRSH,WA-MATKL,WA-MEINS.
ENDLOOP.

P a g e 195 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

ENDFORM.

*&---------------------------------------------------------------------*
*& Form CLOSE_DSN
*&---------------------------------------------------------------------*
FORM CLOSE_DSN .

***TO CLOSE DATASET


CLOSE DATASET 'SFILE1'.

ENDFORM.

Note: If you want to execute your BDC program in background then the BDC
program (call transaction method) which uses function modules such as
‘gui_upload’ or ‘alsm_excel_to_internal_table’ or
‘TEXT_CONVERT_XLS_TO_SAP’ will not work therefore you need to consider
datasets or sequential files present on application server (AL11) to upload it to
database of SAP R/3 system using batch input methods (call transaction method)
and can be schedule in background using Tcode: SM36.

P a g e 196 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

Difference between Call Transaction method and Session method

Call Transaction method Session method


1) Errors must be handled 1) System will automatically handle errors.
explicitly.
2) It has both synchronous 2) It has only synchronous update.
and Asynchronous update
process.
3) sy-subrc is returned. 3) sy-subrc is not returned.
4) Data from internal table 4) Data from internal table it_bdcdata is not
it_bdcdata is directly
directly transferred instead it will go to
transferred to SAP database. Session and unless and until you process
session using Tcode: SM35, data is not
transferred to sap database.
5)It is faster as it can use 5)It is slow as it uses ‘Synchronous Update’
‘Asynchronous update’ which which will wait for acknowledgement.
will not wait for Ex: Transaction data
acknowledgement.
Ex: Master data updation.

Assignment: Please create BDC program using call transaction method by


picking data from dataset or sequential file and also schedule the program in
background using Tcode: SM36.

BAPI (Business Application Programming Interface): It is a remote function


module defined as business object method in the business object repository
(BOR), so that an external systems (.Net, Java) can access SAP data.
o BAPI has no exceptions because sy-subrc cannot be understandable to the
non-sap systems. Therefore, BAPI has an exporting parameter of structure
BAPIRET2.
o BAPI’s are also used for transferring Non-Sap data to SAP R/3 system for
enjoy transactions or transactions which ends with ‘N’(New) such as follows:
• ME21N: To create Purchase Order.
• ME22N: To change Purchase Order.
P a g e 197 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

• ME51N: To create Purchase Requisition.


• VL01N: To create Delivery).
• VT01N: To create shipment, etc.
o For the above Tcodes, you cannot use BDC’s as for these transactions
recording (SHDB) fails because it contains many GUI controls(subscreen).
Therefore, for these Tcodes, you need to compulsory use BAPI’s in order to
transfer Non-Sap data to SAP.
o FI01: This Tcode is used to create Bank Master data.
o BNKA: Standard database table which stores Bank Master data.
o Navigation Steps to Create Bank Master data using Tcode: FI01.
o Tcode: FI01.
o Enter.
o Click on ‘Save’ button (Ctrl+S).
o Note: Data is stored in database table: BNKA.

Navigation Steps to find BAPI for the Tcode: FI01


Step1: To find program name and its package of Tcode:FI01.
➢ Tcode: FI01.
➢ Enter.
➢ Go with menu optio: System ->Status.
➢ Program (screen): SAPMF02B->Double click on it.
➢ Go with menu option: Go to->attributes.
➢ Package: BF_BANK.

Step2: To find Business object type


➢ Tcode: SE80.
➢ Enter.
➢ Expand: Business Engineering.
➢ Expand Business objects.
➢ Bus1011: Bank.

Step3: To Find BAPI


➢ Tcode: BAPI.
➢ Click on ‘Alphabetical’ tab button.
➢ To Find: Ctrl+F.
P a g e 198 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Enter.
➢ Expand ‘BANK’ from the left panel.
➢ Click on ‘Create’ method as above.
➢ Function Module: BAPI_BANK_CREATE.
➢ Double on ‘BAPI_BANK_CREATE’.
➢ Click on ‘Attributes’ tab button.
➢ Click on ‘Import’ tab button.
➢ Click on ‘Export’ tab button.
Bapi_transaction_commit: This function module is used to commit (insert) the
data to the database tables.
Bapi_transaction_rollback: This function module is used to roll back the data of
the database tables.
BAPI: As Inbound and Outbound.
Inbound Bapi: Is used to insert the data to database tables.
Ex: BAPI_BANK_CREATE.
Outbound Bapi: Is used to get the data from database tables.
Ex: BAPI_BANK_GETDETAIL.
Flat file: Excel file.

IN 57 citi bank 01 Ameerpet Hyderabad Ameerpet Branch, Hyd

IN 58 citi bank 01 Ameerpet Hyderabad Ameerpet Branch, Hyd

IN 59 citi bank 01 Ameerpet Hyderabad Ameerpet Branch, Hyd

IN 60 citi bank 01 Ameerpet Hyderabad Ameerpet Branch, Hyd

IN 61 citi bank 01 Ameerpet Hyderabad Ameerpet Branch, Hyd

IN 62 citi bank 01 Ameerpet Hyderabad Ameerpet Branch, Hyd

IN 63 citi bank 01 Ameerpet Hyderabad Ameerpet Branch, Hyd

IN 64 citi bank 01 Ameerpet Hyderabad Ameerpet Branch, Hyd

IN 65 citi bank 01 Ameerpet Hyderabad Ameerpet Branch, Hyd

IN 66 citi bank 01 Ameerpet Hyderabad Ameerpet Branch, Hyd

P a g e 199 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

Example: To transfer Non-SAP data to Sap using BAPI- BAPI_BANK_CREATE.

REPORT ZBAPI_BANK_CREATE.
*to create line type
TYPES:begin of line_type,
bank_ctry like BAPI1011_KEY-BANK_CTRY,
bank_key like BAPI1011_KEY-BANK_KEY,
BANK_name like BAPI1011_ADDRESS-BANK_NAME,
REGION like BAPI1011_ADDRESS-REGION,
STREET like BAPI1011_ADDRESS-STREET,
city like BAPI1011_ADDRESS-CITY,
bank_BRNCH like BAPI1011_ADDRESS-BANK_BRANCH,
END OF line_type.
** To create internal table, it_bank referring to line_type
data it_bank type table of line_type.
** to create work area of structure line_type
data wa_bank type line_type.
** to create work area wa_bank_address of structure BAPI1011_ADDRESS
data wa_bank_address type BAPI1011_ADDRESS.
**to create work area to capture errors
data wa_return like BAPIRET2.
*TO CREATE AN INTERNAL TABLE IT_RAW OF TABLE STRUCTURE
TRUXS_T_TEXT_DATA
DATA IT_RAW TYPE TRUXS_T_TEXT_DATA.
* ** TO CREATE AN INPUT FIELD TO ENTER FLAT FILE ALONG WITH PATH
PARAMETERS P_FILE LIKE IBIPPARMS-PATH.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.
PERFORM BROWSE_FILE.
start-of-selection.
PERFORM UPLOAD_EXCEL_FILE.
PERFORM MAP_DATA.

*&---------------------------------------------------------------------*
*& Form BROWSE_FILE
P a g e 200 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

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

FORM BROWSE_FILE.
*F4_FILENAME: THIS FUNCTION MODULE IS USED TO DISPLAY LIST OF FILES
AND RETURN THE SELECTED FILE.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
FILE_NAME = P_FILE.

ENDFORM.

*&---------------------------------------------------------------------*
*& Form UPLOAD_EXCEL_FILE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM UPLOAD_EXCEL_FILE.
*TEXT_CONVERT_XLS_TO_SAP: This function module is used to upload excel
file present on presentation server or desktop to an internal table.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_LINE_HEADER = 'X'
I_TAB_RAW_DATA = IT_RAW
I_FILENAME = P_FILE
TABLES
I_TAB_CONVERTED_DATA = IT_bank
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE 'Error while uploading excel file' type 'I'.
else.
P a g e 201 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

* loop at it_mat.
* write:/ it_mat-matnr, it_mat-mtart, it_mat-mbrsh, it_mat-matkl, it_mat-
meins, it_mat-maktx.
* ENDLOOP.
ENDIF.

ENDFORM.

*&---------------------------------------------------------------------*
*& Form MAP_DATA
*&---------------------------------------------------------------------*

FORM MAP_DATA.
loop at it_bank into wa_bank.
*to fill bank address
wa_bank_address-BANK_NAME = wa_bank-bank_name.
wa_bank_address-REGION = wa_bank-region.
wa_bank_address-STREET = wa_bank-STREET.
wa_bank_address-CITY = wa_bank-CITY.
wa_bank_address-BANK_BRANCH = wa_bank-bank_BRNCH.
***To call bapi-BAPI_BANK_CREATE
CALL FUNCTION 'BAPI_BANK_CREATE'
EXPORTING
BANK_CTRY = wa_bank-bank_ctry
BANK_KEY = wa_bank-bank_key
BANK_ADDRESS = wa_bank_address
IMPORTING
RETURN = wa_return.
if wa_return-type = 'E'.
write:/ wa_return-type,wa_return-id,wa_return-number,wa_return-
message.
*Bapi_transaction_rollback: This function module is used to roll back the data
of the database tables.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
else.
P a g e 202 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

*Bapi_transaction_commit: This function module is used to commit(insert) the


data to the database tables.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
write:/ 'Bank master data created-', wa_bank-bank_key.
endif.
ENDLOOP.
ENDFORM.

BAPI (Business Application Programming Interface): It is a remote function


module defined as business object method in the business object repository
(BOR), so that an external systems (.Net, Java) can access SAP data.

➢ BAPI has no exceptions because sy-subrc cannot be understandable to the


non-sap systems. Therefore, BAPI has an exporting parameter of structure
BAPIRET2.

➢ BAPI’s are also used for transferring Non-SAP data to SAP R/3 system for
enjoy transactions or transactions which ends with ‘N’(New) such as follows:
o ME21N-> To create Purchase Order.
o ME22N-> To change Purchase Order.
o ME51N-> To create Purchase Requisition.
P a g e 203 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

o VL01N-> To create Delivery).


o VT01N-> To create shipment, etc.

➢ For the above Tcodes, you cannot use BDC’s as for these transactions
recording (SHDB) fails because it contains many GUI controls (sub-screen).
Therefore, for these Tcodes, you need to compulsory use BAPI’s in order to
transfer Non-Sap data to SAP.

➢ FI01-> This Tcode is used to create Bank Master data.


➢ BNKA: Standard database table which stores Bank Master data.

Navigation Steps to Create Bank Master data using Tcode: FI01


➢ Tcode: FI01.

➢ Enter.

P a g e 204 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Click on ‘Save’ button (Ctrl+S).


➢ Note: Data is stored in database table: BNKA.

Navigation Steps to find BAPI for the Tcode: FI01


Step1: To find program name and its package of Tcode:FI01.
➢ Tcode: FI01.
➢ Enter.
➢ Go with menu option: System ->Status.
➢ Program (screen): SAPMF02B->Double click on it.
➢ Go with menu option: Goto->attributes.
➢ Package: BF_BANK.

Step2: To find Business object type.


➢ Tcode: SE80.

➢ Enter.
➢ Expand: Business Engineering.
➢ Expand Business objects.
➢ Bus1011: Bank.
P a g e 205 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

Step3: To Find BAPI.


➢ Tcode: BAPI.
➢ Click on ‘Alphabetical’ tab button.
➢ To Find: Ctrl+F.

➢ Enter.
➢ Expand ‘BANK’ from the left panel.

P a g e 206 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Click on ‘Create’ method as above.

➢ Function Module: BAPI_BANK_CREATE.


➢ Double on ‘BAPI_BANK_CREATE’.
➢ Click on ‘Attributes’ tab button.

P a g e 207 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Click on ‘Import’ tab button.

➢ Click on ‘Export’ tab button.

P a g e 208 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

Bapi_transaction_commit: This function module is used to commit (insert) the


data to the database tables.
Bapi_transaction_rollback: This function module is used to roll back the data of
the database tables.
BAPI: As Inbound and Outbound.
Inbound Bapi: It is used to insert the data to database tables.
Ex: BAPI_BANK_CREATE.
Outbound Bapi: Is used to get the data from database tables.
Ex: BAPI_BANK_GETDETAIL.

Flat file: Excel file.


Ameerpet
IN 57 citi bank 01 Ameerpet Hyderabad Branch, Hyd
Ameerpet
IN 58 citi bank 01 Ameerpet Hyderabad Branch, Hyd
Ameerpet
IN 59 citi bank 01 Ameerpet Hyderabad Branch, Hyd
Ameerpet
IN 60 citi bank 01 Ameerpet Hyderabad Branch, Hyd
Ameerpet
IN 61 citi bank 01 Ameerpet Hyderabad Branch, Hyd
Ameerpet
IN 62 citi bank 01 Ameerpet Hyderabad Branch, Hyd
Ameerpet
IN 63 citi bank 01 Ameerpet Hyderabad Branch, Hyd
Ameerpet
IN 64 citi bank 01 Ameerpet Hyderabad Branch, Hyd
Ameerpet
IN 65 citi bank 01 Ameerpet Hyderabad Branch, Hyd
Ameerpet
IN 66 citi bank 01 Ameerpet Hyderabad Branch, Hyd

P a g e 209 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

Example: To transfer non-SAP data to Sap using BAPI- BAPI_BANK_CREATE


REPORT ZBAPI_BANK_CREATE.

*to create line type


TYPES:begin of line_type,
bank_ctry like BAPI1011_KEY-BANK_CTRY,
bank_key like BAPI1011_KEY-BANK_KEY,
BANK_name like BAPI1011_ADDRESS-BANK_NAME,
REGION like BAPI1011_ADDRESS-REGION,
STREET like BAPI1011_ADDRESS-STREET,
city like BAPI1011_ADDRESS-CITY,
bank_BRNCH like BAPI1011_ADDRESS-BANK_BRANCH,
END OF line_type.
** To create internal table it_bank referring to line_type
data it_bank type table of line_type.
** to create work area of structure line_type
data wa_bank type line_type.
** to create work area wa_bank_address of structure BAPI1011_ADDRESS
data wa_bank_address type BAPI1011_ADDRESS.
**to create work area to capture errors
data wa_return like BAPIRET2.
*TO CREATE AN INTERNAL TABLE IT_RAW OF TABLE STRUCTURE TRUXS_T_TEX
T_DATA
DATA IT_RAW TYPE TRUXS_T_TEXT_DATA .

* ** TO CREATE AN INPUT FIELD TO ENTER FLAT FILE ALONG WITH PATH


PARAMETERS P_FILE LIKE IBIPPARMS-PATH.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.


PERFORM BROWSE_FILE.

start-of-selection.
PERFORM UPLOAD_EXCEL_FILE.
PERFORM MAP_DATA.
P a g e 210 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

*&---------------------------------------------------------------------*
*& Form BROWSE_FILE
*&---------------------------------------------------------------------*

FORM BROWSE_FILE .
*F4_FILENAME: THIS FUNCTION MODULE IS USED TO DISPLAY LIST OF FILES AN
D RETURN THE SELECTED FILE.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
FILE_NAME = P_FILE.

ENDFORM.

*&---------------------------------------------------------------------*
*& Form UPLOAD_EXCEL_FILE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM UPLOAD_EXCEL_FILE .
*TEXT_CONVERT_XLS_TO_SAP: This function module is used to upload excel fil
e present on presentation server or desktop to an internal table.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_LINE_HEADER = 'X'
I_TAB_RAW_DATA = IT_RAW
I_FILENAME = P_FILE
TABLES
I_TAB_CONVERTED_DATA = IT_bank
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2.
P a g e 211 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

IF SY-SUBRC <> 0.
MESSAGE 'Error while uploading excel file' type 'I'.
else.
* loop at it_mat.
* write:/ it_mat-matnr,it_mat-mtart,it_mat-mbrsh,it_mat-matkl,it_mat-
meins,it_mat-maktx.
* ENDLOOP.
ENDIF.

ENDFORM.

*&---------------------------------------------------------------------*
*& Form MAP_DATA
*&---------------------------------------------------------------------*

FORM MAP_DATA .

loop at it_bank into wa_bank.

*to fill bank address


wa_bank_address-BANK_NAME = wa_bank-bank_name.
wa_bank_address-REGION = wa_bank-region.
wa_bank_address-STREET = wa_bank-STREET.
wa_bank_address-CITY = wa_bank-CITY.
wa_bank_address-BANK_BRANCH = wa_bank-bank_BRNCH.

***To call bapi-BAPI_BANK_CREATE


CALL FUNCTION 'BAPI_BANK_CREATE'
EXPORTING
BANK_CTRY = wa_bank-bank_ctry
BANK_KEY = wa_bank-bank_key
BANK_ADDRESS = wa_bank_address
IMPORTING
P a g e 212 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

RETURN = wa_return.

if wa_return-type = 'E'.
write:/ wa_return-type,wa_return-id,wa_return-number,wa_return-
message.
*Bapi_transaction_rollback: This function module is used to roll back the data o
f the database tables.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
else.
*Bapi_transaction_commit: This function module is used to commit(insert) the
data to the database tables.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
write:/ 'Bank master data created-' ,wa_bank-bank_key.

endif.

ENDLOOP.

ENDFORM.

To upload non-SAP data to sap with changes using BAPI.


Example:
REPORT ZBAPI_BANK_CHANGE.

*to create line type


TYPES:begin of line_type,
bank_ctry like BAPI1011_KEY-BANK_CTRY,
bank_key like BAPI1011_KEY-BANK_KEY,
BANK_name like BAPI1011_ADDRESS-BANK_NAME,
REGION like BAPI1011_ADDRESS-REGION,
STREET like BAPI1011_ADDRESS-STREET,
city like BAPI1011_ADDRESS-CITY,
bank_BRNCH like BAPI1011_ADDRESS-BANK_BRANCH,
END OF line_type.
P a g e 213 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

** To create internal table it_bank referring to line_type


data it_bank type table of line_type.
** to create work area of structure line_type
data wa_bank type line_type.
** to create work area wa_bank_address of structure BAPI1011_ADDRESS
data wa_bank_address type BAPI1011_ADDRESS.
** to create work area wa_bank_addressx of structure BAPI1011_ADDRESSx
data wa_bank_addressx type BAPI1011_ADDRESSx.
**to create work area to capture errors
data wa_return like BAPIRET2.
*TO CREATE AN INTERNAL TABLE IT_RAW OF TABLE STRUCTURE TRUXS_T_TEX
T_DATA
DATA IT_RAW TYPE TRUXS_T_TEXT_DATA .

* ** TO CREATE AN INPUT FIELD TO ENTER FLAT FILE ALONG WITH PATH


PARAMETERS P_FILE LIKE IBIPPARMS-PATH.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.


PERFORM BROWSE_FILE.

start-of-selection.
PERFORM UPLOAD_EXCEL_FILE.
PERFORM MAP_DATA.

*&---------------------------------------------------------------------*
*& Form BROWSE_FILE
*&---------------------------------------------------------------------*

FORM BROWSE_FILE .
*F4_FILENAME: THIS FUNCTION MODULE IS USED TO DISPLAY LIST OF FILES AN
D RETURN THE SELECTED FILE.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
FILE_NAME = P_FILE.
P a g e 214 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

ENDFORM.

*&---------------------------------------------------------------------*
*& Form UPLOAD_EXCEL_FILE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM UPLOAD_EXCEL_FILE .
*TEXT_CONVERT_XLS_TO_SAP: This function module is used to upload excel fil
e present on presentation server or desktop to an internal table.
CALL FUNCTION 'TEXT_CONVERT_XLS_TO_SAP'
EXPORTING
* I_LINE_HEADER = 'X'
I_TAB_RAW_DATA = IT_RAW
I_FILENAME = P_FILE
TABLES
I_TAB_CONVERTED_DATA = IT_bank
EXCEPTIONS
CONVERSION_FAILED = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
MESSAGE 'Error while uploading excel file' type 'I'.
else.
* loop at it_mat.
* write:/ it_mat-matnr,it_mat-mtart,it_mat-mbrsh,it_mat-matkl,it_mat-
meins,it_mat-maktx.
* ENDLOOP.
ENDIF.

ENDFORM.

P a g e 215 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

*&---------------------------------------------------------------------*
*& Form MAP_DATA
*&---------------------------------------------------------------------*

FORM MAP_DATA .

loop at it_bank into wa_bank.

*to fill bank address


wa_bank_address-BANK_NAME = wa_bank-bank_name.
wa_bank_address-REGION = wa_bank-region.
wa_bank_address-STREET = wa_bank-STREET.
wa_bank_address-CITY = wa_bank-CITY.
wa_bank_address-BANK_BRANCH = wa_bank-bank_BRNCH.

*to fill bank address fields which need to be updated or changed


wa_bank_addressx-BANK_NAME = 'X'.
* wa_bank_addressx-REGION = ' '.
wa_bank_addressx-STREET = 'X'.
* wa_bank_addressx-CITY = ' '.
wa_bank_addressx-BANK_BRANCH = 'X'.

***To call bapi-BAPI_BANK_CHANGE


CALL FUNCTION 'BAPI_BANK_CHANGE'
EXPORTING
BANKCOUNTRY = wa_bank-bank_ctry
BANKKEY = wa_bank-bank_key
BANK_ADDRESS = wa_bank_address
BANK_ADDRESSX = wa_bank_addressx
IMPORTING
RETURN = wa_return.

P a g e 216 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

if wa_return-type = 'E'.
write:/ wa_return-type,wa_return-id,wa_return-number,wa_return-
message.
*Bapi_transaction_rollback: This function module is used to roll back the data o
f the database tables.
CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'.
else.
*Bapi_transaction_commit: This function module is used to commit(insert) the
data to the database tables.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
write:/ 'Bank master data changed-' ,wa_bank-bank_key.

endif.

ENDLOOP.

ENDFORM.

RFC BAPI
1) It has exceptions. 1) It has no exceptions.
2) Each RFC cannot be a BAPI unless 2) Each BAPI is RFC.
it is defined as a method in the
Business object.
3) It is used to access the 3) It is generally used by Non-SAP
functionality of Remote SAP systems, Systems to access SAP data.
i.e., It between SAP to SAP.

LSMW (Legacy System Migration Workbench):


Definition: It is a tool used to transfer non-SAP data to SAP R/3 system with
the help of some navigation steps.
Navigation steps to transfer Non-SAP data to SAP R/3 system using LSMW
➢ Tcode: LSWM.
➢ Enter.
P a g e 217 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Click on ‘create’ button from application toolbar.


➢ Provide description as below:

➢ Enter.
➢ Provide description as below:

➢ Enter.
➢ Provide description as below:

P a g e 218 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Enter.
➢ Click on ‘Execute’ button.
Step-1:

➢ Note: This step contains different methods such as direct input, bapi, idoc,
batch input recording. Here we are using Batch input recording.
➢ Click on ‘Execute’ button.
➢ Click on ‘change’ button.

➢ Click on ‘Recoding Overview’ Icon.


➢ Select ‘Recordings’ and click on ‘create’ button.
➢ Provide recording and description as below:

➢ Enter.
➢ Provide Tcode (MM01) as below:

P a g e 219 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Enter.
➢ Provide material, industry sector and material type as below:

➢ Click on ‘select view’ button.


➢ Select ‘basic data’.
➢ Enter.
➢ Provide material description and BUM as below:

➢ Save it (ctrl+S).

P a g e 220 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Double click on field: RMMG1-MATNR and delete default value ‘701abc’ and
provide name as mara-matnr below:

➢ Enter.
➢ Similarly, double click on field: RMMG1-MBRSH and delete default value ‘M’
and provide name as mara-mbrsh as below:

P a g e 221 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Enter.
➢ Similarly do the same for fields: mtart, maktx and meins.
➢ Save it (ctrl+S) and go back (F3).
➢ Again, go back (F3).
➢ Provide the recording as below:

➢ Save (ctrl+S).
➢ Back (F3).

Step-2:

➢ Here we provide name for internal table.


➢ Click on ‘execute’ button.
Click on ‘change’ button.
➢ Select ‘source structure’ and click on ‘create’ button.
➢ Provide internal table name as below:
➢ Source structure: Ktab.
➢ Description: internal table.
➢ Enter.
➢ Save (ctrl+S) and back (F3).

Step-3:

➢ Here we create fields for internal table.


P a g e 222 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Click on ‘execute’ button.


➢ Click on ‘change’ button.
➢ Select ‘ktab’ and click on ‘create’ button.
➢ Provide the details as below:

➢ Enter.
➢ Select field ‘matnr’ and click on ‘create’ button.
➢ Provide the details as below:

➢ Enter.
➢ Select field ‘mbrsh’ and click on ‘create’ button.

P a g e 223 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Enter.
➢ Select ‘mtart’ and click on ‘create’ button.

➢ Enter.
➢ Select ‘maktx’ and click on ‘create’ button.

P a g e 224 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Enter.
➢ Save (ctrl+S) and back (F3).

Step-4:

➢ Here we relate screen fields with internal table fields.


➢ Click on ‘execute’ button.
➢ Click on ‘change’ button.
➢ Select your recording ‘zrec07’ and click on ‘relationship’ button.
➢ Enter.
➢ Save (ctrl+S) and back (F3).

Step-5:

➢ Here we map internal table fields with screen fields.


➢ Click on ‘execute’ button.
➢ Click on ‘change’ button.
➢ Select ‘mara-matnr’ and click on ‘Assign source field’ button.
➢ Double click on ‘matnr’ field.
➢ Select ‘mara-mbrsh’ and click on ‘Assign source field’ button.
➢ Double click on ‘mbrsh’ field.
➢ Select ‘mara-mtart’ and click on ‘Assign source field’ button.

P a g e 225 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Double click on ‘mtart’ field.


➢ Select ‘makt-maktx’ and click on ‘Assign source field’ button.
➢ Double click on ‘maktx’ field.
➢ Select ‘mara-meins’ and click on ‘Assign source field’ button.
➢ Double click on ‘meins’ field.
➢ Save (ctrl+S) and back (F3).

Step-6:

➢ This step is ignored as we are not using routines (subroutines).

Step-7:

➢ This step is used to specify flat file along with path and also provide field type:
’ASC’ or ‘Binary’, field separator, etc.
➢ Click on ‘execute’ button.
➢ Click on ‘change’ button.
➢ Select ‘Legacy Data on the PC (Frontend)’ and click on ‘create’ button.
➢ Provide the following details:

P a g e 226 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Enter.
➢ Save (ctrl+S) and back (F3).

Step-8:

➢ Here we will assign flat file to internal table.


➢ Click on ‘execute’ button.
➢ Click on ‘change’ button.
➢ Select ‘ktab’.
➢ Click on ‘Assignment’ button.
➢ Save (ctrl+S) and back (F3).

Step-9:

➢ Here the data from flat file is read into internal table (gui_upload).
➢ Click on ‘execute’ button.
➢ Click on ‘execute’ button.
P a g e 227 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Go back 2 times (F3).

Step-10:

➢ Here the data of internal table (ktab) is displayed.


➢ Click on ‘execute’ button.
➢ Enter.
➢ Back (F3).

Step-11:

➢ Here the mapping and conversion process takes place in-order to validate
the data.
➢ Click on ‘execute’ button.
➢ Click on ‘execute’ button.
➢ Back (F3) 2 times.

Step-12:

➢ Here we display the converted data.


➢ Click on ‘execute’ button.
➢ Enter.
➢ Back (F3).

Step-13:

➢ Here session is created in the Tcode: SM35 (application server).


➢ Click on ‘execute’ button.
➢ Provide the details as below highlighted:

➢ Click on ‘execute’ button.


P a g e 228 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ ‘1 batch input folder with 10 transactions created’.


➢ Enter.

Step-14:

➢ It takes you to ‘SM35’ where you can process or execute the session.
➢ Click on ‘execute’ button.
➢ Sess.: *
➢ Enter.
➢ Select: VITS1 (your session).
➢ Click on ‘process’ button.
➢ Select ‘background’ and enter.
➢ Now check the data in dbtables: Mara and makt.

Assignment: Do the LSMW with excel file.

SAP SCRIPT: It is a tool to design business documents such as purchase order,


sales order, billing document etc, so that the different business partners can
communicate with each other.
o Tcode for Sap Script is SE71.
o But Sap Scripts are not used now in ECC 6.0 as they are outdated.
Therefore, SAP provided Smartforms and Adobe Forms.
Smart Forms: It is an advance concept which is used to design business
documents such as purchase order, sales order, billing document etc, so that the
different business partners can communicate with each other.
o Form Painter is the tool to design Smartforms.
o Tcode For Smartforms is SMARTFORMS
o Components of Smart Forms are:
1) Global Settings.
• Form Attributes.
• Form Interface.
• Global definition.
2) Pages and Windows.
o Page1.
o Main window
P a g e 229 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

Form Attributes: It defines the properties of form such as style (paragraph and
character format), short description, etc.
Form Interface: It is used to pass the data to and from Smart form such as
import, export, tables and exceptions.
Global Definition: It is used to define data types, variables such as work area,
internal table, etc, so that they can be used throughout smart form.
o In Smart forms system automatically creates page1 and also main window
when smart form is created. Also, main window is attached to page1.
o Form is a collection of pages and page is a collection of windows and window
is a container of text or graphics.
There are 4 types of windows:
o Main window.
o Secondary Window.
o Copies window.
o Final window.
Main Window: It is an output area where continuous text is displayed. If main
window is filled with text, then the remaining text will not be truncated, instead
it is displayed in the main window of next page.
You can create only one main window per page in smart forms whereas in Sap
Scripts you can create 99 windows per page.
Secondary Window: It is an output area where fixed lines of data is displayed. If
the secondary window is filled with the text, then the remaining text will be
truncated, therefore in secondary window you need to display fixed lines of
data.
Copies Window: It is an output area where copies of data are displayed, i.e.,
original, duplicate, triplicate, quadruple.
Final Window: It is an output area where some data is displayed and this
window is executed only at the last though it is present in the middle of smart
form.
Paragraph format: It is used to format group of lines of paragraph.
Character format: It is used to format a group of words within a paragraph.
Symbols or place holders: It contains a value at the time of printing.
Syntax:
&name& or &var&
Example: &hno&, &street& , &city& ,etc.
P a g e 230 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

There are 4 types of symbols:


1) System symbols.
2) Program symbols.

1) System symbols: These are the symbols provided by SAP.


Ex: &sfsy-date&, &sfsy-time&

2) Program symbols: There are the variables created in print program or driver
program and transferred to Smartforms.
Ex: print or driver program
Tables mara.
data:name(22) value 'Irfan',
hno(20) value '9-4/5A',
street(20) value 'Ameerpet'.
Smartform
&mara-matnr&
&mara-mtart&…
&name&
&hno&
&street&

Tag column: It contains format keys which defines formatting of text at the time
of printing.
*: default paragraph: It is used to apply the default paragraph settings to the
text at the time of printing.
/ (New line): The text written here will be printed in the new line.
/* (comment line): These lines contents are not printed at the time of printing.
/: (control command): This text in this line is not printed as it is but is considered
as command.
= (extended line): the text content in this line is appended directly to the
character of the preceding line which was displayed last.

P a g e 231 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

Navigation steps to create Smartform:

➢ Tcode: Smartforms.
➢ Select the radiobutton form as below:

➢ Click on ‘Create’ button.


➢ Double click on ‘Form Interface’ from left panel.
➢ Click on ‘import’ tab button.
➢ Provide parameters as below:

P a g e 232 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Select your page1 ->right click ->creat->window.


➢ Provide the window name on right panel as below:
➢ Window: ADDRESS.
➢ Meaning: Address window

➢ Click on ‘output options’ tab button.


➢ Provide the details as below:

➢ To write or populate data onto address window.


➢ Select address window ->Right click ->create ->text.
➢ Click on ‘general attributes’ tab button.
➢ Click on ‘editor’ icon beside paragraph format.
➢ Go with menu option: go to ->change editor and provide text as below:

➢ Back (f3).
➢ Double click on ‘Main Window’.
➢ Click on ‘output options’.

P a g e 233 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Save (Ctrl+S).
➢ To provide text onto main window.
➢ Select main window ->right click ->create ->text.
➢ Click on ‘general attributes’ tab button.
➢ Click on ‘editor’ button.
➢ Go with menu option: go to ->change editor.

➢ Go back (F3).
➢ Select ‘main window’ from left panel ->right click ->create ->window.
➢ Provide the window details as below:

➢ Click on ‘output options’ tab button.

➢ To insert text into Footer window.


P a g e 234 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Select ‘Footer Window’ ->right click ->create ->text.


➢ Click on ‘general attributes’ tab button.
➢ Click on ‘editor’ button.
➢ Go with menu option: goto->change editor.

➢ Back (F3).
➢ Save (Ctrl+S) and Activate (Ctrl+F3).

To view the Layout of page1:


Click on ‘Form painter’ button from application toolbar and to unseen also click
on ‘Form painter’.
To execute or test(F8) Smartform: Press F8 or click on execute (F8) button
from application toolbar. Then system generates the function module as
below:

System generates a function module upon executing(F8) of smartform, which


helps the print program (executable program) to call and execute smart form.
Note: Smartforms are not executed directly, to execute smartforms, you need
a print or driver program.
Print or Driver Program: It is an Abap Program which fetches the data from
database tables and transfer it to Smartform.

Create an Executable Program (Print or Driver Program)


Tcode: SE38
REPORT ZPRINT_ZSFORM1.

*To create variables


data:name(22) value 'Irfan',
hno(20) value '9-4/5A',
street(20) value 'Ameerpet',
STATE(22) value 'Telangana',

P a g e 235 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

city(20) value 'Hyderabad',


country(15) value 'India',
text(50) value 'This is my Permanent Address'.

*to create variables


data:v_sform type TDSFNAME,
v_fname type RS38L_FNAM.

START-OF-SELECTION.
v_sform = 'ZSFORM1'.
PERFORM display_sform.

*&---------------------------------------------------------------------*
*& Form DISPLAY_SFORM
*&---------------------------------------------------------------------*

FORM DISPLAY_SFORM .
*SSF_FUNCTION_MODULE_NAME:This function module is used to generate F
unction module for the provided smartform.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = V_SFORM
IMPORTING
FM_NAME = V_FNAME
EXCEPTIONS
NO_FORM =1
NO_FUNCTION_MODULE = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGE 'Error reached' type 'I'.
ENDIF.

***/1BCDWB/SF00000285:This function module will call and execute smartfor


P a g e 236 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

m-ZSFORM1
CALL FUNCTION v_fname "'/1BCDWB/SF00000285'
EXPORTING
NAME = name
HNO = hno
STREET = street
STATE = state
CITY = city
COUNTRY = country
STR1 = text
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR =3
USER_CANCELED = 4
OTHERS = 5.
IF SY-SUBRC <> 0.
message 'Error in Smartform' type 'I'.
ENDIF.

ENDFORM.

Note: LP01: is a default printer device used in smartforms.


LOCL: This is also used for print device.

To display data in tabular format:


Template Table
1) It is used to display fixed lines onto 1) It is used to display ‘n’ no. of lines
it. onto it.
2) It has a different line structure for 2) All the lines should have the same
its lines. structure.
3) It is displayed on any window. 3) It is displayed only on main
window.
4) Work area is the input for it. 4) Internal table is the input for it.

P a g e 237 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

Navigation steps to design a Purchase Order using Smartforms:


➢ Tcode: Smartforms.

➢ Click on ‘create’ button.


➢ Double click on ‘Form Interface’ from left side.
➢ Click on ‘Import’ tab button.

➢ Note: LFA1: contains vendor master data.


➢ Note: EKKO: Contains Purchase order header data.
➢ EKPO: Contains Purchase Order Item data.
➢ Click on ‘Tables’ tab button.

➢ Save it (Ctrl+S).
➢ Select ‘Page1’ from left side ->Right click ->create window.
➢ Window: Title.
➢ Meaning: title window.
➢ Click on ‘output’ options.

➢ Select title window ->right click ->create ->text.


➢ Click on ‘general attributes’ tab button.
➢ Click on ‘editor’ button.
➢ Click on goto ->change editor.

➢ Back (F3).

P a g e 238 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Select the ‘title window’ ->right click ->create ->window.


➢ Window: Vendor_address.
➢ Meaning: Vendor address.
➢ Click on ‘output options’ tab button.

➢ Select ‘vendor Address’ window->right click->create->template.


➢ Click on ‘template’ tab button.
➢ Click on ‘details’ button.

➢ Note: Reference: It is used to take the properties of the already existing line.
➢ Click on ‘table painter’ button.
➢ Click on ‘select pattern’ button.
➢ Select the pattern

➢ Save (ctrl+S).
➢ Select template ->right click ->create ->text.
➢ Click on ‘editor’ button.
➢ Goto ->change editor.

➢ Go back (F3).
➢ Click on ‘output options’ tab button.

P a g e 239 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Select text ->right click ->create ->text.


➢ Click on ‘general attributes’ tab button ->click on ‘editor’ button.
➢ Goto ->change editor.

➢ Back (F3).
➢ Click on ‘output options’ tab button.

➢ Select text ->right click ->create ->text.


➢ Click on ‘general attributes’ tab button ->click on ‘editor’ button.
➢ Goto ->change editor.

➢ Back (F3).
➢ Click on ‘output options’ tab button.

➢ Select text ->right click ->create ->text.


➢ Click on ‘general attributes’ tab button ->click on ‘editor’ button.
➢ Goto ->change editor.

➢ Back (F3).
➢ Click on ‘output options’ tab button.

P a g e 240 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Select text ->right click ->create ->text.


➢ Click on ‘general attributes’ tab button ->click on ‘editor’ button.
➢ Goto ->change editor.

➢ Back (F3).
➢ Click on ‘output options’ tab button.

➢ Select text ->right click ->create ->text.


➢ Click on ‘general attributes’ tab button ->click on ‘editor’ button.
➢ Goto ->change editor.

➢ Back (F3).
➢ Click on ‘output options’ tab button.

➢ Select text ->right click ->create ->text.


➢ Click on ‘general attributes’ tab button ->click on ‘editor’ button.
➢ Goto ->change editor.

➢ Back (F3).
➢ Click on ‘output options’ tab button.

P a g e 241 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Select text ->right click ->create ->text.


➢ Click on ‘general attributes’ tab button ->click on ‘editor’ button.
➢ Goto ->change editor.

➢ Back (F3).
➢ Click on ‘output options’ tab button.

➢ Select text ->right click ->create ->text.


➢ Click on ‘general attributes’ tab button ->click on ‘editor’ button.
➢ Goto ->change editor.

➢ Back (F3).
➢ Click on ‘output options’ tab button.

➢ Select text ->right click ->create ->text.


➢ Click on ‘general attributes’ tab button ->click on ‘editor’ button.
➢ Goto ->change editor.

➢ Back (F3).
➢ Click on ‘output options’ tab button.

P a g e 242 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

Navigation steps to upload logo to Sap R/3 system from Non-Sap system
➢ There are 2 ways to upload logo:
1) To Upload TIF files (Tag Information format).
2) To Upload Bit Map Image (BMP) files.
Navigation steps to upload TIF file:
➢ Tcode: SE38.
➢ Program: RSTXLDMC.
➢ Click on ‘execute’ button (F8).
➢ Provide the following details.

➢ Click on ‘execute’ button.


➢ It will ask you the file path, provide it.

2) Navigation steps to upload bit map image (bmp):


➢ Tcode: SE78.
➢ Expand ‘Graphics’.
➢ Double click on ‘BMAP’ Bitmap images.
➢ Click on ‘import’ button from application toolbar.
➢ Provide the following details:

P a g e 243 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Enter.

To view your uploaded bmp image:


➢ Tcode: SE78.
➢ Expand ‘Graphics’.
➢ Double click on ‘BMAP’ Bitmap images.
➢ Provide the details as follows:

➢ Click on ‘Print Preview’ button from application toolbar.


➢ Select window ‘Vendor Address’ ->Right click->Create window.
Window: company_logo.
Meaning: company logo.
➢ Click on ‘output options’.
➢ Provide left, upper margin, width and height as below:

P a g e 244 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Select company_logo->Right click->create graphics.


➢ Click on ‘general attributes’ tab button.
➢ Provide the following details:

➢ Save (ctrl+S).
➢ Select main window and double click on it.
➢ Click on ‘output options’ tab button from right side.
➢ Provide the details as below:

➢ Select ‘main window’ ->right click ->create ->table.


➢ Click on ‘table’ tab button from right side.
➢ Click on ‘details’ button.
➢ Provide the following details:

P a g e 245 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ To provide one more column as ‘6th’ column, do the following:

➢ Click on ‘right column’ as above and provide width for 6th column as below:

➢ Click on ‘table painter’ button.

➢ Click on ‘select pattern’ button .


➢ Click on ‘display framed patterns’ button.

➢ Click on ‘ ’.
➢ Click on ‘data’ tab button.
➢ Provide the internal table as below:

➢ Select ‘Header’ ->right click->create->table line.


➢ Click on ‘output options’ tab button.
➢ Provide line type as below:

➢ Select ‘cell1’->right click->create->text.


➢ Click on ‘general attributes’->click on editor button->go to ‘change editor’

P a g e 246 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Back (F3).
➢ Select ‘cell2’->right click->create->text.
➢ Click on ‘general attributes’->click on editor button->go to ‘change editor’.

➢ Back (F3).
➢ Select ‘cell3’->right click->create->text.
➢ Click on ‘general attributes’->click on editor button->go to ‘change editor’

➢ Back (F3).
➢ Select ‘cell4’->right click->create->text.
➢ Click on ‘general attributes’->click on editor button->go to ‘change editor’

➢ Back (F3).
➢ Select ‘cell5’->right click->create->text.
➢ Click on ‘general attributes’->click on editor button->go to ‘change editor’

➢ Back (F3).
➢ Select ‘cell6’->right click->create->text.
➢ Click on ‘general attributes’->click on editor button->go to ‘change editor’.

➢ Back (F3).
➢ Save (Ctrl+S).
➢ Select ‘Main Area’ from left side->right click->create->table line.
➢ Click on ‘output options’ tab button.
➢ Provide line type as below:

➢ Select Cell7->create->text.
➢ Click on general attributes tab button.

P a g e 247 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Click on ‘editor’ button.


➢ Click on ‘goto change editor’.

➢ Back (F3).
➢ Select cell8->create->text.

➢ Back (F3).
➢ Select cell9->create->text.

➢ Back (F3).
➢ Select cell10->create->text.

➢ Back (F3).
➢ Select cell11->create->text.

➢ Back (F3).
➢ Select cell12->create->text.

➢ Save (Ctrl+S).
➢ Back (F3).
➢ Select main window->right click->create->window.
Window: page_window.
Meaning: page window.
➢ Click on ‘output options’.

P a g e 248 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Select page window->right click->create->text.

➢ Back (F3).
➢ Save it (Ctrl+S).
➢ Activate (Ctrl+F3).

Note: To view system fields in smartform, click on ‘field list on/off’ button from
application tool then you can field system fields at the bottom in the left panel,
from where you can drag and drop them onto text area.

Now we need to create Print or Driver Program:


➢ Tcode: SE38.
➢ Provide program name: PRINT_ZPO_SF1.
REPORT ZPRINT_ZPO_SF1.

*to create implicit work area


tables:lfa1,ekko.
*to create internal table it_ekpo of structure ekpo
data it_ekpo type table of ekpo.
*to create an input field to enter purchase document number
*to create variables
data:v_sform type TDSFNAME value 'ZPO_SFORM11',
v_fm type RS38L_FNAM.
PARAMETERS p_ebeln like ekko-ebeln.

START-OF-SELECTION.
perform get_data.
P a g e 249 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

perform display_sform.

*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
FORM GET_DATA .

*to get purchase document header data from database table -ekko
select single LIFNR from ekko into ekko-lifnr where ebeln = p_ebeln.

*** To get purchase document item data from database table -ekpo
select * FROM ekpo into table it_ekpo where ebeln = p_ebeln.
*** to get Vendor Address from database table lfa1.
select SINGLE * from lfa1 into lfa1 where lifnr = ekko-lifnr.

ENDFORM.
*&---------------------------------------------------------------------*
*& Form DISPLAY_SFORM
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DISPLAY_SFORM .
*SSF_FUNCTION_MODULE_NAME:This function module is pass smart form and
get its function module.
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
FORMNAME = v_sform
IMPORTING
FM_NAME = v_fm
EXCEPTIONS
P a g e 250 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

NO_FORM =1
NO_FUNCTION_MODULE = 2
OTHERS = 3.
IF SY-SUBRC <> 0.
MESSAGE 'Error while generating function with sform' type 'E'.
ENDIF.

"/1BCDWB/SF00000287:This function module will call and execute smartform-


ZPO_SFORM11
CALL FUNCTION v_fm
EXPORTING
LFA1 = lfa1
TABLES
IT_EKPO = it_ekpo
EXCEPTIONS
FORMATTING_ERROR = 1
INTERNAL_ERROR = 2
SEND_ERROR =3
USER_CANCELED = 4
OTHERS = 5.
IF SY-SUBRC <> 0.
MESSAGE 'Error in Smartform' type 'E'.
ENDIF.

ENDFORM.

Style: It is used to create both paragraph and character formats.

Navigation Steps to create Style:


➢ Tcode: Smartstyles or smartforms.
➢ Provide style: zstyle1.
➢ Select paragraph format from left side->right click->create node.
➢ Paragraph Format: P1.
P a g e 251 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Enter.
➢ Description: Paragraph P1

➢ Click on ‘Font ‘ tab button.

➢ Select ‘character format’ from left side->right click->create node.


Character format: c1 and enter.
Description: Char format
➢ Click on ‘Font’ tab button.
➢ Provide the details as below:

➢ Save (ctrl+S).
➢ Double click on ‘header data’ from left panel.

P a g e 252 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Click on ‘standard setting’ tab button from right panel.


Standard paragraph: P1.
➢ Activate (Ctrl+F3).

Steps to apply Style in Smartforms:


➢ Tcode: Smartforms.

➢ Click on ‘change’ button.


➢ Click on ‘output options’ tab button.
➢ Style: ZSTYLE1.
➢ Note: Here ‘*’ means your P1 paragraph.
➢ Also, to apply character format.
➢ Goto any of the text, click on ‘general attributes’.
➢ Click on ‘editor’ button.
➢ Goto ->change editor.

➢ Back (F3).
➢ Activate (Ctrl+F3).

P a g e 253 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

Difference between Sapscript and Smartform


Sap Script Smart Forms
1) It is complicated to design. 1) It is easy to design.
2) It has no interface. 2) It has interface such as import,
export, tables, etc.
3) It is text element dependent. 3) It is text element independent.
4) It is paragraph dependent. 4) It is paragraph independent.
5) It is client and language dependent. 5) It is client and language
independent.
6) Box, colouring, etc cannot be 6) Box, colouring can be applied.
applied.
7) Data in tabular format cannot be 7) Data in tabular format can be
represented. represented using template and table
nodes.
8) Line type cannot be applied. 8) Line type can be applied.
9) ’99’ main windows can be created 9) Only one main window is created
per page. per page.
10) Both layout (sapscript) and print 10) Both layout (smartform) and print
program are separate. program can be written in smartform.
11) To invoke Sapscript you need 11) Smartform itself returns function
function modules such as open_form, module which is used in print program
start_form, write_form, etc. to invoke it.
12) Tcode:SE71. 12) Tcode: Smartforms.

Enhancement: It is used to add custom functionality to the standard R/3 system


without modifying it.
Enhancements are empty shells or empty spaces provided by SAP for the
standard transactions where user can provide or write custom code.
Different Enhancements are:
1) Enhancement using Customer Exits.
2) Enhancement to Abap Dictionary.
3) Enhancement using User Exits.
4) Enhancement Spots.
i) Implicit Enhancement.
P a g e 254 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

ii) Explicit Enhancement.


5) Badi’s.

SAP can provide one or more Enhancements to the transactions.

1) Enhancement using Customer Exits:


Customer Exits: It is used to add custom functionality in the standard R/3
system.
Different Customer Exits are:
1) Function Exit.
2) Menu Exit.
3) Screen Exit.
4) Field Exit.
1) Function Exit: It is used to add custom functionality to the standard R/3
application without modifying it.
o Function Exit is a standard function module with the name ‘EXIT_XXX’ and
contains an include program which starts with the name ‘Z’ and is not
created. You need to create it by double clicking on it and press enter and
click on ‘yes’ button. This ‘Z’ include program is the place where custom code
or custom functionality is written.
o The interface such as import, export, changing and tables of function exit
helps you with an input data with which a developer writes custom code.
o Tcode to find Customer Exits is ‘SMOD’.
P a g e 255 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

o Tcode to implement custom exits is ‘CMOD’.


o Customer Exits are implemented by creating a project with the help of Tcode:
CMOD.
o Customer Exits can have single implementation for it and cannot have
multiple implementations for it.

Navigation Steps to find Enhancement code or Enhancement for a


Transaction-MM01:
Step-1: To find program name and its package of Tcode-MM01.
➢ Tcode: MM01.
➢ Go with Menu option: System->status.
➢ Program (screen): SAPLMGMM.
➢ Double click on ‘SAPLMGMM’.
➢ Go with menu option: goto->attributes.
➢ Package: MGA.

Step-2: To find Enhancement (Customer Exits).


➢ Tcode: SMOD.

➢ (Press F4).
➢ Opens a screen.
➢ Provide package as below:

➢ Enter.
➢ Opens a screen with Customer exits as below:

P a g e 256 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Double click on Exit name: MGA00001.


➢ Select the radiobutton as below:

➢ Click on ‘Display’ button.


➢ Then system displays the different exits as below:

➢ Note: In the above enhancement (Customer Exit): MGA00001, you have only
Function exit and don’t have menu exits and screen exits. Therefore, in this
custom exit, you can only add custom functionality in the function exit but
cannot add custom menu’s and custom screens.
➢ Back (F3).
P a g e 257 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Select
➢ Click on ‘Display’.
➢ Sap provides help documentation to developer to write custom code as
below:
You can use this customer enhancement for the material master for the
following purposes:
• To extend existing checks.
• To add checks for customer-defined fields.
• To change data (certain limitations apply here).

Navigation steps to implement Function Exit for Tcode: MM01


➢ Tcode: Cmod.
➢ Project: Zprj1.
➢ Click on ‘create’ button.
➢ Short text: to implement function exit.
➢ Save it (Ctrl+S).
➢ Click on ‘Enhancement Assignment’ button from application toolbar.
➢ Provide enhancement code as below:

➢ Save (Ctrl+S).
➢ Click on ‘components’ button from application toolbar.
➢ Opens a screen with following function exits.

➢ Double click on ‘EXIT_SAPLMG02_001’.


➢ Click on ‘import’ tab button.

P a g e 258 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Click on ‘Source code’ tab button.


INCLUDE ZXMG0U03.
➢ To create include ‘ZXMG0U03’, double click on it and press enter button.
➢ Opens a screen.

➢ Click on ‘yes’ button.


➢ Save it to local object.
*&---------------------------------------------------------------------*
*& Include ZXMG0U03
*&---------------------------------------------------------------------*
if MMUE2-numki = '01'.
message 'Its an internal number range' type 'I'.
endif.
➢ Activate (Ctrl+F3).
➢ Go back (F3) 2 times.
➢ Activate (Ctrl+F3).

Now Run standard Transaction-MM01


➢ Tcode: MM01.
➢ Provide material details as below:

➢ Click on ‘select view’ button.


P a g e 259 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Select ‘basic data’ and enter.


➢ Provide material description: material text-a55.
o Base Unit of Measure: kg.
➢ Save (ctrl+s).

Assignment: Develop an Enhancement (Function exit) for Tcode-XK01 (Vendor


master data creation) and XD01 (Customer Master data creation).

Navigation Steps to find Enhancement code or Enhancement for a Transaction-


XD01:
Step-1: To find program name and its package of Tcode-XD01:
➢ Tcode: XD01.
➢ Click on ‘F1’ function key on any of the screen field and click on ‘technical
information’ icon.
➢ Program Name: SAPMF02D->Double click on it and go with menu option:
goto -> Object Directory entry.
➢ Package: VS

Step-2:
➢ Tcode: SMOD.

➢ Press F4 function key.


➢ Click on ‘Information system’ button.
o Package: VS and enter.

➢ Please check its documentation as follows:


➢ User Exit for Customer Master Data
➢ Description
P a g e 260 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ The following user exits exist for customer master records:


➢ Check entered data before saving
➢ Please refer to the interface description of the function module to see
➢ which data is available.

Navigation steps to implement customer exit (function exit) for Tcode: XD01
➢ To create project to implement function exit: Tcode: CMOD
➢ Project: zprj_xd0.
➢ Click on ‘create’ button.
o Short text: to implement function exit.
➢ Save (ctrl+S).
➢ Click on ‘enhancement assignment’ button.
➢ Provide enhancement as below:
SAPMF02D: User exits: Customer master data.
➢ Save (ctrl+S).
➢ Click on ‘components’ button.
➢ function exit EXIT_SAPMF02D_001->double click
➢ Opens a screen with include as below:
INCLUDE ZXF04U01.->double click and enter and click on ‘yes’ button
➢ Opens a screen.
➢ Click on ‘change’ button.
IF i_kna1-land1 = 'DE' AND i_kna1-regio IS INITIAL.
MESSAGE 'For Country DE, Region is mandatory' TYPE 'E'.
elseif i_kna1-land1 = 'IN' AND i_kna1-PSTLZ IS INITIAL.
MESSAGE 'For India, Postal code is compulsory' type 'E' DISPLAY LIKE 'I'.
ENDIF.
➢ Activate (ctrl+F3).
➢ Go back 2 times.
➢ Activate project (ctrl+F3).

Now run standard transaction-XD01


➢ Tcode: XD01.
➢ Provide the details as below:

P a g e 261 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Enter.
➢ Provide Title: Company
Name: Vit.
Country: IN.
➢ Save (ctrl+S) then system executes our custom code written in enhancement
(customer exit-function exit) and popup the error message as follows: (As
postal code is empty: i_kna1-pstlz).

Menu Exit: It is used to add custom menu items to the standard menu bar of the
SAP R/3 application.
o Menu Exit contains predefined function codes which starts with ‘+’ but are
not active. You need to activate them by providing function text and
functionality(code) to it.
o Along with Menu exit, Sap also provides function exit so that for the newly
added menu items you can provide functionality(code).

Navigation steps to find enhancement (customer exit-menu exit) for the


Tcode-MC94(To change plan in flexible planning)
Step-1: To find program name and its package.
➢ Program: SAPMMCP6
➢ Package: MCP2

Step-2: To find enhancement-menu exit


➢ Tcode: SMOD.
P a g e 262 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

o Enhancement: ______ (Press F4).


➢ Click on ‘Information system’ button.
o Package: mcp2 and enter.
➢ Note: Here you have number of customer exits, you need to find out a
customer exit which has menu exit.
➢ MCP20003: SOP: create function code for flexible planning
➢ Double click on ‘MCP20003’.
➢ Select as below:

➢ Click on ‘display’ button.


➢ Displays exits as follows:

➢ Go back (F3).
➢ Select radio button ‘documentation’ and click on ‘display’ button.
Use this enhancement to define your own function codes in flexible
P a g e 263 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

planning. For this purpose, you must change status CHAK0500 for module
SAPLMCPA. You must also change the texts in Extras -> Customer function
Customer function x of the menu so that they refer to your new function
codes.
➢ Confirm the warning that these menu entries are also used in other
statuses and that the changes will also be made here.
➢ You can then call these self-defined function codes in your own program
'ZXSOPU03'. If you want to use this enhancement, you must create
thisprogram yourself.

Navigation steps to implement enhancement (Menu Exit) for tcode- MC94:


➢ Tcode: Cmod.
➢ Project: zprj_MC9.
➢ Click on ‘Create’ button.
➢ Provide short text: To implement menu exit.
➢ Save (ctrl+S).
➢ Click on ‘Enhancement assignment’ button.
➢ Enhancement: MCP20003.
➢ Save (ctrl+S).
➢ Click on ‘components’ button.
Function exit EXIT_SAPMMCP6_003
Menu exit SAPLMCPA +CU1
SAPLMCPA +CU2
SAPLMCPA +CU3
SAPLMCPA +CU4
SAPLMCPA +CU5
SAPLMCPA +CU6
SAPLMCPA +CU7
SAPLMCPA +CU8
SAPLMCPA +CU9
➢ Click on ‘change’ button.
➢ Double click on ‘+CU1’.
➢ Provide the details as below:

P a g e 264 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Click on ‘copy’ button and enter.


➢ Double click on ‘+CU2’.
➢ Provide the details as below:

➢ Click on ‘copy’ button and ‘enter’.


➢ Double click on ‘+CU3’.
➢ Provide the details as below:

➢ Click on ‘copy’ button and ‘enter’.


P a g e 265 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Double click on function exit: EXIT_SAPMMCP6_003.


INCLUDE ZXSOPU03.->Double click here and press enter button then click on
‘yes’ button
*&---------------------------------------------------------------------*
*& Include ZXSOPU03
*&---------------------------------------------------------------------*
case I_FCODE.
when '+CU1'.
** To call Abap dictionary
call TRANSACTION 'SE11'.
when '+CU2'.
** To call Screen painter
call TRANSACTION 'SE51'.
when '+CU1'.
** To call Menu painter
call TRANSACTION 'SE41'.
endcase.
➢ Activate (Ctrl+F3) and enter.
➢ Go back (two times) F3.
➢ Activate the project (Ctrl+F3).

Now Run Standard Transaction-MC94


➢ Tcode: MC94.
➢ Planning type: REPL and enter.
➢ Click on ‘Active version’ button.

➢ Go with menu option: Extras->Customer Functions->DDIC-SE11 ->Screen


Painter ->Menu painter.

Screen Exit: It is used to add custom screens to standard R/3 applications


without modifying it.
o Along with screen exits, SAP provides 2 function exits, i.e., one function exit
is to write the code for PBO event of custom screen and another function
exit to write code for PAI event of custom screen.
P a g e 266 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

o Custom screen, we add to the standard screen is of type ‘subscreen’ and its
number is proposed by SAP but is not created, we need to create it. Also,
subscreen is called onto subscreen area.

Navigation steps to find Enhancement (Screen Exit) for tcode-VX11(Create


financial document)
Step-1: To find program name and its package
➢ Program: SAPMV86E
➢ Package: VEI

Step-2: To find Enhancement (Screen Exit).


➢ Tcode: SMOD.
➢ Enhancement: ____________(F4).
➢ Click on ‘Information system’.
➢ Package: VEI.
Exit_name Short Text
RVEXAKK1 Document Transaction: Screen Exit for Additional Data
➢ Double click on ‘RVEXAKK1’.
➢ Select ‘radiobutton’ components.
➢ Click on ‘display’ button.

➢ Back (F3).
➢ Select ‘Documentation’ as below:

P a g e 267 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Click on ‘Display’.

General
Using this enhancement, you can add additional documentary payments data
in a subscreen for the relevant document header. You must define this data in
an append structure in table AKKP.
Applications
For this purpose, you should carry out the following steps:
o Extend table AKKP with an append structure in which you include the
required new fields.
o Create a screen with screen number '0101' in function group XAKK and add
the new fields to the screen.
• Edit the fields in screen control by using the customer functions:
EXIT_SAPMV86E_001 and EXIT_SAPMV86E_002.
• In the second exit, the new values must be copied into the internal
table XAKKP.

Navigation steps to implement screen exit

Step-1: To add custom fields to standard database table AKKP using Append
Structure.
➢ Tcode: SE11.

➢ Click on ‘Display’ button.


➢ Click on ‘Append Structure’ button from application toolbar.
➢ Append Name: zastruct1.
➢ Enter.

P a g e 268 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Save (Ctrl+S).
➢ Activate (Ctrl+F3).

Step2: To create Project


➢ Tcode: CMOD.
➢ Project: Zprj_vx.
➢ Click on ‘create’ button.
➢ Short text: To implement screen exit.
➢ Save it (ctrl+S).
➢ Click on ‘Enhancement Assignment’ button.
➢ Provide enhancement: RVEXAKK1.
➢ Enter.
➢ Save (Ctrl+S).
➢ Click on ‘components’ button.
Function exit: EXIT_SAPMV86E_001 (PBO Event).
▪ EXIT_SAPMV86E_002 (PAI event).

Screen exit
SAPMV86E 0101 ZUSATZ SAPLXAKK 0100
➢ Double click on ‘EXIT_SAPMV86E_001’.
INCLUDE ZXAKKU01.

To create an implicit work area in main program-function group


➢ Go with menu option: goto->main program.
INCLUDE LXAKKTOP. " Global Data
➢ Double click on ‘LXAKKTOP’.

P a g e 269 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Again, double click on ‘ZXAKKTOP’ and press enter button and click on ‘Yes’
button.
➢ Save to your package.
*&---------------------------------------------------------------------*
*& Include ZXAKKTOP
*&---------------------------------------------------------------------*
*to create implicit work area
tables akkp.
➢ Activate (Ctrl+F3).
➢ Go back 3 times.
➢ Double on include ‘ZXAKKU01’ and press enter and click on ‘Yes’ button.
➢ Save to your package.
*&---------------------------------------------------------------------*
*& Include ZXAKKU01
*&---------------------------------------------------------------------*
**To initialize values to your custom screen fields
AKKP-ZZACNO = 'Acno_101'.
AKKP-ZZSYSNO = 'Sysno_11'.
➢ Activate (Ctrl+F3).
➢ Back (F3) 2 times.
➢ Double click on another exit: EXIT_SAPMV86E_002 (PAI Event).
INCLUDE ZXAKKU02.
➢ Double on include ‘ZXAKKU02’ and press enter and click on ‘Yes’ button.
➢ Save to your package.
*&---------------------------------------------------------------------*
*& Include ZXAKKU02
*&---------------------------------------------------------------------*
*to transfer screen values to work area from where system will update it to sta
ndard database table : AKKP
XAKKP-ZZACNO = AKKP-ZZACNO.
XAKKP-ZZSYSNO = AKKP-ZZSYSNO.
➢ Activate (Ctrl+F3).
Screen exit
SAPMV86E 0101 ZUSATZ SAPLXAKK 0100

P a g e 270 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Double click on ‘100’ screen.


➢ Opens a screen.

➢ Enter.
➢ Short Description: subscreen-100.

➢ Click no ‘layout’ button.


➢ Click on ‘Dictionary Fields’.
➢ Tables: AKKP and enter.
➢ Select custom fields as below:

➢ Drag and drop onto layout.


➢ Back (F3).
➢ Activate (Ctrl+F3).
➢ Click on ‘Maint. In [Link].’ button.
➢ Back (F3).
➢ Activate project (Ctrl+F3).

Now Run Standard Transactoin-VX11


➢ Tcode: VX11.
➢ Provide the details the as below:

P a g e 271 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Provide the following details:

➢ Save it (Ctrl+S).
➢ Click on cancel (As we don’t want to go with other screens).
➢ Enter.
➢ Now check the data in database table: AKKP.

P a g e 272 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

Field Exit: It is an old enhancement technology linked to a screen input field


which executes custom Abap code that is allowed to:
1) Change the value of field.
2) Trigger an error message on that field.
Field exit is deactivated by default since NetWeaver 6.10 and is obsolete since
SAP Basis 4.6a.

User Exit: It is used to add custom code to the SAP Standard program without
modifying it but requires Access key.
SAP provides User Exits in the form of empty subroutines with Form. Endform in
the SAP standard programs where custom code can be written.
There are 2 ways to implement User Exits:
i) Before ECC 5.0 (i.e., SAP R/3 4.7EE, etc), we need access key to add custom
code in the SAP Standard program and you can get access key by registering
object name (program name) in the SAP Service Market place and then providing
it in ECC system which allows to add custom code in the standard program.
ii) From ECC 5.0 and ECC 6.0 onwards, SAP provided implicit enhancement to
add custom code in the SAP Standard program without modifying it and without
access key.
In SD (Sales and Distribution) module, these user exits are found in an include
program ‘MV45AFZZ’ of the standard SAP Sales order creation program
SAPMV45A.
In SD Module:
MV45*: Include program which has Order related User Exits.
MV50*: Include program which has Delivery related User Exits.
RV60*: Include program which has Billing related User Exits.

Implicit Enhancement: It is used to add custom code in the standard Program of


SAP R/3 system without modifying it.
o Implicit Enhancements are available at the beginning and at the end of
subroutines, function modules, methods and even at the end of structure
(type) definition.
o For implicit enhancement, when you click on ‘enhance or spiral’ button
(shift+F4) from application toolbar of any standard program then if there are
double inverted comma in between form and endform, function and
P a g e 273 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

endfunction, method and endmethod then you can create your


implementation over there.
o To view Enhancement Spots and Badi’s: Tcode: SE18.
o To implement Enhancement options and Badi’s: Tcode: SE19.

To find implicit enhancement and implement it for tcode-FI01


➢ Tcode: FI01.
Bank Country IN
Bank Key 711
➢ Enter.
➢ Opens a screen.
➢ Go with menu option: system->status.
Program (screen) SAPMF0
Screen number 110
➢ Double click here.
PROCESS AFTER INPUT.
MODULE OKCODE_VERARBEITUNG.->double click here

MODULE okcode_verarbeitung.
……………..
…………………

* ------ Update --------------------------------------------------------


WHEN 'UPDA'.

* ------ ... UPDATE oder INSERT ----------------------------------------


CASE t020tab-aktyp.
WHEN 'V'.
PERFORM bnka_update.
WHEN 'H'.
PERFORM bnka_insert.
ENDCASE.
……………..
………………
Double click on perform bnka_insert
P a g e 274 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

FORM bnka_insert.

* ------ Bankanschrift hinzufügen --------------------------------------


upd_bnka = 'I'.
PERFORM verbuchungsaufruf.
SET PARAMETER ID 'BKL' FIELD bnka-banks.
SET PARAMETER ID 'BLZ' FIELD bnka-bankl.

* ------ Bearbeitungsmeldung -------------------------------------------


MESSAGE s208(bf00) WITH bnka-banks bnka-bankl.
* Bank & & wurde angelegt
ENDFORM.
➢ Here click on ‘enhance or spiral’ button from application toolbar
➢ Menu option: edit->enhancement operations->show implicit enhancement
options.
➢ Get the following:
FORM bnka_insert.
""""""""""""""""""""""""""""""$\SE:(11) Form BNKA_INSERT, Start
➢ Right click on the double inverted comma ->enhancement operations-
>create implementation
➢ Opens a screen as below:

➢ Click on code button.

➢ Enter.
➢ Save to your package.
P a g e 275 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

ENHANCEMENT 1 ZIM_ENH_BANK_NUMBER. "active version


""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""$"$\SE:(12) Form BNKA_INSERT, Start, Enhancement ZIM_ENH_BA
NK_NUMBER, Start A
*
if sy-tcode = 'FI01'.
IF BNKA-BNKLZ <> 'VIT123'.
MESSAGE 'INVALID BANK NUMBER ' TYPE 'E'.
ENDIF.
ENDIF.
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""$"$\SE:(13) Form BNKA_INSERT, Start, Enhancement ZIM_ENH_BA
NK_NUMBER, End A
ENDENHANCEMENT.

➢ Activate (ctrl+f3).

* ------ Bankanschrift hinzufügen --------------------------------------


upd_bnka = 'I'.
PERFORM verbuchungsaufruf.
SET PARAMETER ID 'BKL' FIELD bnka-banks.
SET PARAMETER ID 'BLZ' FIELD bnka-bankl.

* ------ Bearbeitungsmeldung -------------------------------------------


MESSAGE s208(bf00) WITH bnka-banks bnka-bankl.
* Bank & & wurde angelegt
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""$"$\SE:(12) Form BNKA_INSERT, End
A
ENDFORM.

Now run Tcode: Fi01:


Bank Country IN
Bank Key 7112
➢ Enter.
P a g e 276 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Provide details as below:

➢ Save (ctrl+S).
➢ System display error message as below; because your implicit enhancement
is triggered.

➢ Note: Tcode: SE18: Badi and Enhancement Spots definition.


Tcode: SE19: Badi and Enhancement Spots Implementation.

Assignment: Do implicit enhancement for XD01 and XK01.

Enhancement Options: They are positions or empty shells in the repository


objects where enhancement (custom code) is written. These can be explicit or
implicit.
Explicit Enhancement can be explicit enhancement point and explicit
enhancement section.
Explicit Enhancement Point: It is used to add custom code in the standard SAP
program where your custom code is executed along with SAP standard Code.

P a g e 277 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

Explicit Enhancement Points are provided by SAP at different areas for different
objects. It looks as below:
Enhancement-Point <name> spots <spot name>
[static/Dynamic]

Note: ’Static’ option is used for data declaration whereas ‘Dynamic’ option is
used for coding. If ‘Static’ option is not there means by default it is ‘Dynamic’.

Explicit Enhancement Section: It is used to add custom code in the standard SAP
program and also provides a provision to even comment or deactivate the
Standard Abap code.
Enhancement Spots: It is a container of explicit enhancements such as point and
section.
Difference between Point and Section is when explicit enhancement point is
implemented then its custom code is executed along with Standard Abap code
but when explicit enhancement section is implemented then here you can
comment or deactivate standard abap code and make only your custom code
executed.
Example: Say in standard code you have an abap statement as ‘select * from
mara upto 1 rows’ here if I want to provide where <condition> in standard code
you cannot do it. So, we can deactivate or comment standard code ‘select * from
mara upto 1 rows’ and can write custom code to be executed as ‘select single *
from mara where matnr = mara-matnr.’.

Navigation steps to find Explicit Enhancement Point and implement it.


➢ Tcode: Xd01.

P a g e 278 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Enter.

➢ Press F1 function key on street or postal code/city field.


➢ Click on ‘technical information’ icon.
Program Name SAPLSZA
Screen Number 0301
➢ Double click on ‘0301’.
➢ In Process After Input (PAI).
MODULE d0100_ok_code.
➢ Double click here.
➢ At [Link].: 110.
ENHANCEMENT-POINT ENH_LSZA1I02 SPOTS ES_LSZA1I02.

P a g e 279 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

To implement Enhancement Point:


➢ Click on ‘Enhance’ or ‘Spiral’ button.
ENHANCEMENT-POINT ENH_LSZA1I02 SPOTS ES_LSZA1I02.
➢ Right click on ‘ENH_LSZA1I02’->Enhancement Operations->create
implementation.
➢ Opens a screen.
➢ Click on ‘create’ button.

➢ Enter.
➢ Save to your custom package.
➢ Select your implemented explicit enhancement and enter.
ENHANCEMENT 1 ZEXPLICIT_ENH7. "inactive version
*
if sy-tcode = 'XD01'.
if ADDR1_DATA-COUNTRY = 'IN' and ADDR1_DATA-REGION is INITIAL.
MESSAGE 'Region is mandatory for indian customers' type 'E'.
endif.
endif.

ENDENHANCEMENT.
➢ Activate (Ctrl+F3) and enter.
➢ Now Run: XD01.

P a g e 280 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Enter.

➢ Enter or save.
➢ Displays error message on status bar as below:

➢ Provide region: TS and save (Ctrl+S).

To check implemented Explicit Enhancement-point in Enhancement Spot:


➢ Tcode: SE19.
➢ Provide the details as below:

P a g e 281 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Click on ‘Display’ button.


➢ Opens a screen.

➢ Double click on Enhancement Spot: ES_LSZA1I02.


➢ Opens a screen:

➢ Click on ‘Enhancement Implementation’ tab button.


➢ Opens a screen as below:

P a g e 282 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

Navigation steps to find Enhancement Spots (Explicit Point and Section) for a
particular Tcode:
➢ Tcode: Xd01.
➢ Press F1 key on any screen field.
➢ Click on ‘Technical Information’.
Program Name: SAPMF02D
➢ Double click on ‘SAPMF02D’.
➢ Go with Menu option: Edit->Find/Replace

➢ Enter.
➢ Here you can search or check with keywork ‘point’ or ‘section’ and get your
explicit point/section and according implement it.

Navigation steps to implement Explicit Enhancement Section:


To find Explicit Enhancement Section:
➢ Tcode: Xd01.
➢ Press F1 key on any screen field.
➢ Click on ‘Technical Information’.
Program Name: SAPMF02D
P a g e 283 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Double click on ‘SAPMF02D’.


➢ Go with Menu option: Edit->Find/Replace.

➢ Enter.
➢ Select the below: line: 2341.
➢ 2841: ENHANCEMENT-SECTION OKCODE_BEARBEITEN_04 SPOTS
ES_SAPMF02D
➢ Select ‘SAPMF02D’. and enter.
ENHANCEMENT-
SECTION OKCODE_BEARBEITEN_04 SPOTS ES_SAPMF02D.
IF ok-code(2) = 'P-'
OR ok-code(2) = 'P+'.
PERFORM okcode_blaettern.
ENDIF.
END-ENHANCEMENT-SECTION.
➢ Click on ‘Enhance’ or ‘Spiral’ button.
➢ Double click on ‘SAPMF02D’.
➢ ENHANCEMENT-SECTION OKCODE_BEARBEITEN_04->Right click-
>Enhancement Operations->Create Implementation.

P a g e 284 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Click on ‘Create’ button(F8).

➢ Enter.
➢ Save to your custom package.
➢ Enter.
if sy-tcode = 'XD01'.
if kna1-land1 = 'IN' and Kna1-regio is INITIAL.
MESSAGE 'Country India need to have Region' type 'I'.
endif.
endif.
➢ Activate (Ctrl+F3).
➢ Now Run Tcode-Xd01.

➢ Enter.

P a g e 285 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Enter.

➢ Save (Ctrl+S).

Difference between Modification and Enhancement


Modification Enhancement
1) We need Access key from service 1) No need of Access key.
market place.
2) Once Modification is done, it is not 2) SAP here also will not support.
supported by SAP.
3) More work during Upgrade. 3) Very less work during Upgrade.
4) All the objects are replaced by new 4) Very less changes after update.
version during Upgrade. Customer
need to make the changes again.

P a g e 286 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

ABAP/SAP QUERY: It is a reporting tool used to develop Report with the help
of some steps.
Step-1:
To create Information Set (InfoSet-Functional area or Information area).
➢ Tcode: SQ02.
➢ Go with menu option: Settings->Settings.

➢ Enter.
➢ InfoSet: zinfoset1.
➢ Click on ‘Create’ button.
➢ Provide the details as below:

➢ Enter.
P a g e 287 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Provide the database tables and click on tick mark as below:

➢ After clicking tick mark on two database tables Kna1 and Vbak, Go with
menu option: Edit->define condition.
➢ Go with menu option: Edit->specify condition.
➢ Opens a screen.

➢ Click on ‘yes’ button.


➢ Go back (F3).
➢ Tick mark ‘vbak’ and ‘vbap’ as below:

P a g e 288 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Go with menu option: Edit->define condition.


➢ Place cursor on Join condition ‘Vbak’.
➢ Go with menu option: Edit->specify condition.
➢ Opens a screen.

➢ Click on ‘yes’ button.


➢ Go back (F3).
➢ Back (F3).
➢ Opens a screen, select the radio button as below:

➢ Enter.
➢ Opens a screen, select the field groups as below and delete them.

➢ Click on ‘ ’ button.
➢ Click on ‘Create’ button (In order to create field group).
➢ Opens a screen and provide ‘FG’ and description as below:

P a g e 289 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Enter.
➢ Expand Kna1 from left side.

➢ Select some fields by selecting shift button and drag and drop into field
group (FG) (Right side).
➢ Expand Vbak from left side.

P a g e 290 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Select some fields by selecting shift button and drag and drop into field
group (FG) (Right side).
➢ Similarly Expand ‘VBAP’.

➢ Select some fields by selecting shift button and drag and drop into field
group (FG) (Right side).
➢ The following fields are selected from kna1, vbak and vbap:

P a g e 291 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Save (Ctrl+S).
➢ Check (F8).
➢ Click on Generate button.

Step-2: To create User Group and link it to Info Set (Zinfoset1)


➢ Tcode: SQ03.
➢ User group: zusergrp1.
➢ Click on ‘Create’ button.

➢ Save to your package.


➢ Click on ‘Assign Users and Infosets’ button.
➢ Click on ‘Assign Infosets’ button from application toolbar.

P a g e 292 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Select our info set: zinfoset1.


➢ Save (Ctrl+S).

Step-3: To Create Query (Report)


➢ Tcode: SQ01.
➢ Query: Zquery1.
➢ Click on ‘create’ button.
➢ Double click on ‘Zinfoset1’.
➢ Provide Title: Sales Detailed Report.

➢ Click on ‘Next screen’ ( ) button from application toolbar.


➢ Click on check box below:

➢ Click on ‘Next screen’ ( ) button from application toolbar.


➢ Select the fields as below:

P a g e 293 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Click on next page icon ( ) and select some more fields as below:

➢ Click on ‘Next screen’ ( ) button from application toolbar.


➢ To provide range of input fields on to selection-screen, choose some of the
fields as below:

P a g e 294 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Click on ‘Basic List’ button from application toolbar.


➢ Expand ‘Kna1’,’Vbak’ and ‘vbap’ and check the check box as below:

➢ To colour some of the fields then select that field from right side and on the
bottom of left side you have colour list box as below:

P a g e 295 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Click on ‘Apply’ button.


➢ Save (Ctrl+S).
➢ Check.
➢ Click on Test (ctrl+F8).
➢ Enter.
➢ Execute (F8).

Navigation steps to create Tcode for Sap/Abap Query:


To find program name of your sap query:
➢ Tcode: SQ01.
➢ Query: ZQUERY1.
➢ Click on ‘execute’ button.
➢ Go with menu option: system->status.
Program: AQZZZUSERGRP1…..(double click here).
Report: AQZZZUSERGRP1===ZQUERY1=======.

Now create Tcode for Query:


➢ Tcode: SE93.
➢ Transaction Code: ztquery.
➢ Click on ‘create’ button.
➢ Provide the following details:

P a g e 296 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.


RICEF

➢ Enter.

➢ Save (ctrl+s).
➢ Test (F8).
➢ Execute (F8).

P a g e 297 | 297

Abap S4 Hana Faculty: Irfan, VersionIT, [Link], [Link]: 9014629911, Ameerpet.

You might also like