You are on page 1of 196

SAP-SQL

SQL: - Structure query language.


o It is used to perform read/write operations on the database table.
o It is a negative language. It can be adopted directly into ABAP but it is not
recommended.
o SAP ABAP as introduced “OPEN SQL” instead of using negative SQL to make a
computable with ABAP language.

STATEMENT 1 :- ( SELECT *)
SYNTAX: - SELECT * FROM <DBTABLE> INTO TABLE <ITAB>.
EX: - select * from Mara into table lt_mara.
* represents all the fields of tables.

PROGRAM:-
Types : t_mara type mara.
Types : tt_mara type standard table of t_mara.
Data : lw_mata type t_mara,
lt_mara type tt_mara.
Select * from mara into table lt_mara.
Loop at lt_mara into lw_mara.
Write : / lw_mara-matnr, lw_mara-mbrsh,
lw_mara-mtart……lw_mara-fashgrd.
Endloop.

WHOLE STORY NARRATED BY VAMSI


STATEMENT 2:- (SELECT FILDS)
SYNTAX: - SELECT FLD1 FLD2 FLD3 FROM <DATABASE> INTO TABLE <ITAB>.
EX: - select matnr mbrsh mtart from mara into table lt_mara.

PROGRAM:-
Types : t_mara type mara.
Types : tt_mara type standard table of t_mara.
Data : lw_mata type t_mara,
lt_mara type tt_mara.
Select matnr mbrsh mtart from mara into table lt_mara.
Loop at lt_mara into lw_mara.
Write : / lw_mara-matnr, lw_mara-mbrsh,
Lw_mara-mtart.
Clear lw_mara.
Endloop.

WHOLE STORY NARRATED BY VAMSI


STATEMENT 3:- (WHERE CLASS).
SYNTAX: - SELECT FLD1 FLD2 FLD3 FROM <DBTABLE> INTO TABE <ITAB>
WHERE <FLD NAME>=?.
EX: - Select matnr mbrsh mtart from mara into table lt_mara
Where matnr = ‘123’.

PROGRAM:-
Types : begin of t_mara,
Matnr type matnr,
Mbrsh type mbrsh,
mtart type mtart,
End of t_mara.
Types : tt_mara type standard table of t_mara.
Data : lw_mata type t_mara,
t_mara type tt_mara.
Parameter : p_matnr type mara-matnr.
Select matnr mbrsh mtart from mara into table lt_mara
Where matnr = p_matnr.
Loop at lt_mara into lw_mara.
Write : / lw_mara-matnr, lw_mara-mbrsh,
Lw_mara-mtart.
Clear lw_mara.
Endloop.

WHOLE STORY NARRATED BY VAMSI


SELECT SINGLE:
SYNTAX: SELECT SINGLE FLD1 FROM <DBTABLE> INTO <WA>
WHERE FLD1 = ?.
EX: - Select single lifnr name1 land1 from lfa1 into lw_lfa1
Where lifnr = ?.
PROGRAM:-
Types: begin of t_marc,
Matnr type matnr,
Werks type werks_d,
Pstat type pstat_d,
End of t_marc.
Data : lw_marc type t_marc.
parameters : p_matnr type matnr obligatory.
Select single matnr werks pstat from marc
Into lw_marc
Where matnr = p_matnr.
Write : / lw_marc-matnr, lw_marc-werks,
Lw_marc-pstat.

(OR)
data : V_matnr type matnr,
V_werks type werks_d,
V_pstat type pstat_d.
Parameters : p_matnr type matnr obligatory.
Select single matnr werks pstat from marc
Into (v_matnr, v_werks, v_pstat)
Where matnr = p_matnr.
Write : / v_matnr, v_werks, v_pstat.

WHOLE STORY NARRATED BY VAMSI


SELECT UP TO <N> ROWS: -
SYNTAX: -SELECT FLD1 FLD2 FLD3 FROM <DBTABLE> INTO TABLE <ITAB>
UP TO <N> ROWS.

EX: - select fld1 fld2 from <dbtable> into table <itab>


Up to <n> rows.
PROGRAM:-
Types : begin of t_vbak,
Vbeln type vbeln_va,
Vkorg type vkorg,
Vtweg type vtweg,
Spart type spart,
End of t_vbak.
Types : tt_vbak type standard table of t_vbak.
Data : lw_vbak type t_vbak,
lt_vbak type tt_vbak.
Parameters : p_count type i obligatory.
Select vblen vkorg vtweg spart from vbak
Into table lt_vbak
Up to p_count rows.
Loop at lt_vbak into lw_vbak.
Write : / lw_vbak-vblen, w_vbak-vkorg,
Lw_vbak-vtweg, lw_vbak-spart.
Clear lw_vbak.
Endloop.

WHOLE STORY NARRATED BY VAMSI


SELECT…..INTO CORRESPONDING FIELDS OF TABLE:-
SYNTAX:- SELECT FLD3 FLD1 FLD2 FROM <DBTABLE>
INTO CORRESPONDING FILDS OF TABLE <ITAB>
WHERE FLD1 = ?.
EX: - Select mtart matnr mbrsh from mara
Into corresponding fields of table lt_mara
Where matnr = ?.

PROGRAM:-
Types : begin of t_mara,
Matnr type matnr,
Mbrsh type mbrsh,
Mtart type mtart,
End of t_mara.
Types : tt_mara type standard table of t_mara.
Data : lw_mata type t_mara,
t_mara type tt_mara.
Parameter : p_matnr type mara-matnr.
Select mbrsh mtart matnr from mara into table lt_mara
Into corresponding fields of table lt_mara
Where matnr = p_matnr.
Loop at lt_mara into lw_mara.
Write : / lw_mara-matnr, lw_mara-mbrsh,
Lw_mara-mtart.
Clear lw_mara.
Endloop.

WHOLE STORY NARRATED BY VAMSI


SELECT……ENDSELECT: -
SYNTAX: - SELECT FLD1 FLD2 FROM <DBTABLE> INTO TABLE <WA>
WHERE FLD1 = ?.
ENDSELECT

PROGRAM: -
Types : begin of t_likp,
Vbeln type vbeln_vl
Lfdat type lfdat_v,
Vstel type vstel,
End of likp.
Types : tt_likp type standard table of t_likp.
Data : lw_likp type t_likp,
lt_likp type tt_likp.
Parameters : p_vbeln type vbeln obligatory.
Select vbeln lfdat vstel from likp
into lw_likp
up to 3 rows.
endselect.

WHOLE STORY NARRATED BY VAMSI


SELECT-OPTIONS: -
These are used for complex selections on a selection screen and it has been built
by using “SELOPT STRUTCURE”. The fields are
• SING
• OPTION
• LOW
• HIGH
SYNTAX: - SELECT-OPTIONS : <S_NAME>FOR <DBTABLE_FLD>.

• A run time selection option is treated as an internal table have four fields in it having
SING
OPTION
LOW
HIGH
NOTE: - Select option need to be passed to the where clause using “IN” parameter.

Q HOW TO MAKE SELECT-OPTION AS A PARAMETER?


ANS: - Declare a select option with “NO INTERVALS NO-EXTENSION”
v If u does not pass any values to the select options it will get the whole data of the table.

PROGRAM: -
TYPES : begin of t_knal,
Kunnr type kunnr,
Name1 type name1,
Ort01 type ort01_gp,
Land1 type land1_gp
End of t_kna1.
Types : tt_kna1 type standard type of t_kna1.
Data : lw_knal type t_kna1,
T_kna1 type tt_kna1.
Seect-options : s_kunnr for kna1-kunnr.
Select kunnr name1 ort01 land1 from kna1
Into table lt_kna1
Where kunnr in s_kunnr.
Loop at lt_kna1 into lw_kna1.
Write : / lw_kna1-kunnr, lw_kna1-name1,
lw_kna1-ort01, lw_kna1-land1.
Clear lw_kna1.
Endloop.

WHOLE STORY NARRATED BY VAMSI


SY-SUBRC: - It is a system variable which keeps a return code of select statement. If it is
successful it will be “ZERO” if it is fail it will be “NOT EQUAL TO ZERO”.
SYNTAX: - SY-SUBRC = 0.
NOTE: - It is mandatory Patrice to check a sy-subrc after any select-option

PROGRAM: -
TYPES : begin of t_vbrk,
Vbeln type vbeln,
Fkdat type fkdat,
Kunrg type kunrg,
Netwr type netwr,
End of t_vbrk.
Types : tt_vbrk type standard table of t_vbrk.
Data : lw_vbrk type t_vbrk,
Lt_vbrk type tt_vbrk.
Parameters : p_vbeln type vbrk-vbeln.
Select vbeln fkdat kunrg netwr from vbrk
Into table lt_vbrk
Where vbeln = p_vbeln.
If sy-subrc = 0.
Loop at lt_vbrk type lw_vbrk.
Write : / lw_vbrk-vbeln, lw_vbrk-fkdat,
lw_vbrk-kunrg, lw_vbrk-netwr.
Endloop.
Else.
Write : / ‘NO DATA FOUND’.
Endif.

WHOLE STORY NARRATED BY VAMSI


VARIENT CRECATION: -
STEP1: - Run the ABAP program
Enter the values in the selection screen
Click on save button
Enter the variant name and meaning
Click on save
Back.
STEP: - Whenever you want to use the same data
Run the ABAP program
Click on get variant button
And select the variant.

CREATING A TRANCATION CODE FOR THE REPORT: -


STEP: - Go to SE93
Enter the T-code (EX: -ZBILL01)
Enter the transaction code which you want to create
Click on enter
Write short text
Select program and selection screen (Report transaction)
Press enter
Enter the program name for which you want create a T-code
Enter program-program name
Check all the checks boxes
Click on save.

WHOLE STORY NARRATED BY VAMSI


JOINS
JOINS: - In order to extract the data from more than one table we need to make use of
Joins. They are two types of joins: -
1. Inner join
2. Outer join
We cannot join a cluster tables, only transparent tables can be join.

JOINS: -
EXAMPLES OF INNER-JOIN: -

FIELD1 FIELD2 FIELD1 FIELD2

A T1 A T1

B T2 B T2

C T3 C T3

FEILD1 FEILD2 FEILD3 FEILD1 FEILD2 FEILD3

A T1 T4 A T1 T4

B T2 T5 B T2 T5

C T3

INNER-JOIN OUTER-JOIN

SYNTAX: - SELECT TAB1~FLD1


TAB1~FLD2
TAB1~FLD3
TAB2~FLD1
TAB2~FLD2
INTO TABLE <ITAB>
FROM <TAB1> INNER JOIN <TAB2>
ON TAB1~FLD1 = TAB2~FLD1
WHERE TAB1~FLD1 =? .

WHOLE STORY NARRATED BY VAMSI


STEP1: - Select fields from TAB1 and TAB2.
STEP2: - Put into internal table (ITAB).
STEP3: - Write an inner join on two tables.
STEP4: - Specify common Colum in two tables.
STEP5: - Where condition.

PROGRAM: -
Tables: Mara, marc.
Types: begin of t_mat,
matnr type matnr,
mbrsh type mbrsh,
mtart type mtart,
werks type werks_d,
pstat type pstat_d,
end of t_mat.
Types: tt_mat type standard table of t_mat.
Data: lw_mat type t_mat,
lt_mat type tt_mat.
Select-options: s_matnr for mara-matnr.
*-- inner join on material info mara marc
Select mara~matnr
mara~mbrsh
mara~mtart
marc~werks
marc~pstat
into table lt_mat
from mara inner join marc
on mara~matnr = marc~matnr
where mara~matnr in s_matnr.
if sy-subrc eq 0.
loop at lt_mat into lw_mat.
write : / lw_mat-matnr , lw_mat-mbrsh,
lw_mat-mtart, lw_mat-werks,
lw_mat-pstat.
clear lw_mat.
endloop.
else.
write : / 'no data found'.
endif.

WHOLE STORY NARRATED BY VAMSI


FOR ALL ENTERIES IN: -
• It is used to retrieve the data based on an already populated ITAB.
• It reduces the database access time.
• Before we use for all entries it is mandatory to check the header ITAB is filled or not.
• We need to pass all keys in the where clause.

PROGRAM: -
Tables : bkpf, bseg.
Types : begin of t_bkpf,
bukrs type bukrs,
belnr type belnr_d,
gjahr type gjahr,
blart type blart,
budat type budat,
end of t_bkpf.
Types : begin of t_bseg,
bukrs type bukrs,
belnr type belnr_d,
gjahr type gjahr,
buzei type buzei,
wrbtr type wrbtr,
end of t_bseg.
Types : tt_bkpf type standard table of t_bkpf,
tt_bseg type standard table of t_bseg.
Data : lw_bkpf type t_bkpf,
lw_bseg type t_bseg,
lt_bseg type tt_bseg,
lt_bkpf type tt_bkpf.
Select-options : s_bukrs for bkpf-bukrs.
Select-options : s_belnr for bkpf-belnr.
Select-options : s_gjahr for bkpf-gjahr.
*-- fetch the header data bkpf
Select
bukrs
belnr
gjahr
blart
budat
from bkpf
into table lt_bkpf

WHOLE STORY NARRATED BY VAMSI


where bukrs in s_bukrs
and belnr in s_belnr
and gjahr in s_gjahr.
if not lt_bkpf is initial.
*--- select ietm data
select bukrs
belnr
gjahr
buzei
wrbtr
from bseg
into table lt_bseg
for all entries in lt_bkpf
where bukrs = lt_bkpf-bukrs
and belnr = lt_bkpf-belnr
and gjahr = lt_bkpf-gjahr.
endif.
if not lt_bkpf is initial.
format color 1.
loop at lt_bkpf into lw_bkpf.
write : / lw_bkpf-bukrs, lw_bkpf-blart.
clear lw_bkpf.
endloop.
endif.
if not lt_bseg is initial.
format color 2.
loop at lt_bseg into lw_bseg.
write : / lw_bseg-bukrs, lw_bseg-buzei.
clear lw_bseg.
endloop.
endif.

WHOLE STORY NARRATED BY VAMSI


REPORTS
REPORTS: -
• Reports are used for viewing the data in an appropriate format as per the client’s
requirement.
• Reports basically consists of business information data
• The reports frequency will be daily, weekly, monthly, quarterly, half early, and annually.
There are two types of reports.
1. Classical reports
2. Interactive reports
CLASSICAL REPORTS: - It has only one output list with appropriate events used.
INTERACTIVE REPORTS: - It will have one basic list and 20 secondary lists.

EVENTS IN CLASSICAL REPORTS: -


1. INTIALIZATION
2. AT SELECTION-SCREEN
3. START-OF-SELECTION
4. TOP-OF-PAGE
5. END-OF-SELECTION
6. END-OF-PAGE

INITIALIZATION: - This event will trigger at first and it is used for initialization screen
field’s values.
CODE: - SELECT-OPTION : S_ebeln for ekko-ebeln
EX: - INITIALIZATION.
S_EBELN-SING = ‘I’.
S_EBELN-OPTION = ‘BT’.
S_BEBLN-LOW = ‘4500004824’.
S_EBELN-HIGH = ‘4500004824’.

AT SELECTION-SCREEN: - This event is used to validate the user input if the user input is
correct, allow HIM/HER for future processing if not raise an appropriate message.

MESSAGES: - (SE91)
They are 3 types of messages.
I- Information – gray color
W – Warning – yellow color
E – Error – red color
SYNTAX: - MESSAGE <MSG TYPE> <MSG NUM> (MSG CLASS).
EX: - Message E001 (ZVK).

WHOLE STORY NARRATED BY VAMSI


MESSAGE CLASS: -
STEP1: - Go to SE91
Enter the message class name (that name should be short name)
Click on create
Give a short text (a program related message)
Save.
STEP2: - Click on message tab, it has two sections MSG NUM & MSG TEXT
EX: - MESSAGE MESSAGE SHORT TEXT
001 Please enter po number .
002 Input valid po number .
Save
Back.

START-OF-SELECTION: -
These events are used to get data from database and man plicate the ITAB has per the
requirement.
In technical standard point normally will write core logic or processing logic like select
statements, and getting the data into ITAB’S and man placating the ITAB likes appending,
modifying, and deleting the data.
It is a mandatory event for ABAP code.

TOP-OF-PAGE: -
It is used to display list headings (or) reports headings with appropriate field’s
description.
TOP-OF-PAGE is the first line which will trigger on the list. Provided you have a write
statement in it.

END-OF-SELECTION: - This event is used to display the data on the list and normally it
triggers after the start-of-selection

END-OF-PAGE: - This event is used to trigger footer for the given page technically reversing
the lines for the footer
These can be achieved by an attribute “LINE-COUNT 65(5)”
Where 65 – No. of lines in a page
(5) – reserved for footer.

CLEAR: - It clears the header contents or work area contents.

REFERSH: - It removes the contents of a BODY/ITAB.

FREE: - It will de-allocate the memory from the ITAB.

WHOLE STORY NARRATED BY VAMSI


READ TABLE: - Read table will fetch you only record.
SYNTAX: - READ TABLE <ITAB> INTO <WA> WITH KEY <FLD1> = ? .

DESCRIBE TABLE: - Describe table is a key word which will let you know the No. of records
available in an ITAB.
SYNTAX: - DESCRIBE TABLE <ITAB> LINES <VAR>.

PROGRAMS FOR EVENTS IN CLASSICAL REPORTS: -


PROGRAM1: -
tables: vbrk,vbrp.
Types: begin of t_billheader,
vbeln type vbeln_vf, " billing document number
fkdat type fkdat, " billing date
kunrg type kunrg, " payer
vkorg type vkorg, " sales organization
vtweg type vtweg, " distribution channel
spart type spart, " division
fkart type fkart, " billing type
end of t_billheader.

Types: begin of t_billitem,


vbeln type vbeln_vf, " billing document number
posnr type posnr_vf, " billing item
matnr type matnr, " material number
arktx type arktx, " description
fkimg type fkimg, " quantity
netwr type netwr_fp, " net value
end of t_billitem.

Types: tt_billheader type standard table of t_billheader,


tt_billitem type standard table of t_billitem.

Data: lw_billheader type t_billheader,


lt_billheader type tt_billheader,
lw_billitem type t_billitem,
lt_billitem type tt_billitem.

selection-screen begin of block b with frame title text-001.


select-options: s_vbeln for vbrk-vbeln.
selection-screen end of block b.
data: v_subttl type p decimals 2,

WHOLE STORY NARRATED BY VAMSI


v_gndttl type p decimals 2.
*---------------------------------------------------------------------*
Initialization.
*---------------------------------------------------------------------*
s_vbeln-sign = 'i'.
s_vbeln-option = 'bt'.
s_vbeln-low = 0090005385.
s_vbeln-high = 0090005386.
append s_vbeln.

*---------------------------------------------------------------------*
At selection-screen.
*---------------------------------------------------------------------*
select single *
from vbrk into vbrk
where vbeln in s_vbeln.

if sy-subrc ne 0.
message e001(zcd).
endif.

*---------------------------------------------------------------------*
Start-of-selection.
*---------------------------------------------------------------------*
select vbeln fkdat kunrg vkorg vtweg spart fkart
from vbrk into table lt_billheader
where vbeln in s_vbeln.

if not lt_billheader is initial.


loop at lt_billheader into lw_billheader.
uline.
format color 1.
write:/ sy-vline,(16) 'billing number',
sy-vline,(16) 'billing date',
sy-vline,(16) 'payer',
sy-vline,(16) 'sales org.',
sy-vline,(16) 'dist. channel',
sy-vline,(16) 'division',
sy-vline,(16) 'billing type',
sy-vline.

WHOLE STORY NARRATED BY VAMSI


uline.
format color 2.
write:/ sy-vline,(16) lw_billheader-vbeln,
sy-vline,(16) lw_billheader-fkdat,
sy-vline,(16) lw_billheader-kunrg,
sy-vline,(16) lw_billheader-vkorg,
sy-vline,(16) lw_billheader-vtweg,
sy-vline,(16) lw_billheader-spart,
sy-vline,(16) lw_billheader-fkart, sy-vline.

clear lw_billitem.
refresh lt_billitem.
select vbeln posnr matnr arktx fkimg netwr
from vbrp into table lt_billitem
where vbeln = lw_billheader-vbeln.

if not lt_billitem is initial.


uline.
format color 4.
write:/ sy-vline,(16) 'billing item',
sy-vline,(16) 'material number',
sy-vline,(16) 'description',
sy-vline,(16) 'quantity.',
sy-vline,(16) 'net value',
sy-vline.
uline at 0(96).
loop at lt_billitem into lw_billitem.
format color 2.
write:/ sy-vline,(16) lw_billitem-posnr,
sy-vline,(16) lw_billitem-matnr,
sy-vline,(16) lw_billitem-arktx,
sy-vline,(16) lw_billitem-fkimg,
sy-vline,(16) lw_billitem-netwr, sy-vline.
v_subttl = v_subttl + lw_billitem-netwr.
endloop.
uline at 0(96).
write:/65 'sub total rs: ', v_subttl color 3.
v_gndttl = v_gndttl + v_subttl.
v_subttl = 0.
skip 1.

WHOLE STORY NARRATED BY VAMSI


else.
message: e000(zcd).
endif.
endloop.
skip 2.
uline.
write:/63 'grand total rs: ', v_gndttl color 3.
else.
message: e000(zcd).
endif.
PROGRAM2: -
report znsr_sales_report no standard page heading
line-size 255
line-count 65(5).
tables : vbak,vbap,mara.
types : begin of t_sales,
vbeln type vbeln,
vkorg type vkorg,
vtweg type vtweg,
spart type spart,
kunnr type kunnr,

posnr type posnr_va,


matnr type matnr,
arktx type arktx,
kwmeng type kwmeng,

mbrsh type mbrsh,


mtart type mtart,
end of t_sales.
types : tt_sales type standard table of t_sales.

data : lw_sales type t_sales.


data : lt_sales type tt_sales.
types : begin of t_mara,
matnr type matnr,
mbrsh type mbrsh,
mtart type mtart,
end of t_mara.

WHOLE STORY NARRATED BY VAMSI


types : tt_mara type standard table of t_mara.
data : lw_mara type t_mara,
lt_mara type tt_mara.
selection-screen begin of block b1 with frame title text-001.
select-options : s_vbeln for vbak-vbeln.
selection-screen end of block b1 .

start-of-selection.
clear lw_sales.
refresh lt_sales.
*-- fetch sales order header and item
select
vbak~vbeln
vbak~vkorg
vbak~vtweg
vbak~spart
vbak~kunnr

vbap~posnr
vbap~matnr
vbap~arktx
vbap~kwmeng

into table lt_sales


from vbak inner join vbap
on vbak~vbeln = vbap~vbeln
where vbak~vbeln in s_vbeln.
if not lt_sales is initial.
clear lw_mara.
refresh lt_mara.
*-- get material attributes
select matnr mbrsh mtart from mara
into table lt_mara
for all entries in lt_sales
where matnr = lt_sales-matnr.
endif.
*-- populating the data for mbrsh mtart
loop at lt_sales into lw_sales.
read table lt_mara into lw_mara
with key matnr = lw_sales-matnr.

WHOLE STORY NARRATED BY VAMSI


if sy-subrc eq 0.
lw_sales-mbrsh = lw_mara-mbrsh.
move lw_mara-mtart to lw_sales-mtart.
modify lt_sales from lw_sales.
clear lw_sales.
endif.
endloop.

"------displaying the final itab----


loop at lt_sales into lw_sales.
write: / lw_sales-vbeln,lw_sales-vkorg,lw_sales-vtweg,lw_sales-spart,
lw_sales-kunnr,lw_sales-posnr,lw_sales-matnr,lw_sales-arktx,
lw_sales-kwmeng,lw_sales-mbrsh,lw_sales-mtart.
clear lw_sales.
endloop.

end-of-page.
write: 'thank you.....visit again'.

EVENTS IN INTERACTIVE REPORTS: -


In interactive reports we can have one basic list and 20 secondary lists and list index will
be captured by an index variable “SY-INDEX”.
1. AT LINE-SELECTION
2. AT USER-COMMAND
3. TOP-OF-PAGE DURING LINE-SELECTION.

AT LINE-SELECTION: - When the user double click on the basic list at line selection event
will trigger.

AT USER-COMMAND: - These event will trigger when the user perform the action on the tool
bar along with exit buttons. The button click value will be stored in a system variable know as
“SY-UCOMM”. Technically it captures the functions code of a button.
TOP-OF-PAGE DURING LINE-SELECTION: -
This event is used to write the list headings on the secondary lists.

HIDE AREA: - If you define a field using hide statement that field value will be written into
temporary memory area know as hide area.
SYNTAX: - HIDE : <WA-FLD>.

WHOLE STORY NARRATED BY VAMSI


EX: - hide : lw_ekko-ebeln.

WORKING WITH AT USER COMMAND: -


• SY-UCOMM will have a function code for each button in the tool bar.
• A tool bar can be created using PF-STATUS.
SYNTAX: - SET PF-STATUS <STATUS NAME>.
EX: - SET PF-STATUS ‘ZSALES’.
It is also known as GUI STATUS.
STEP1: - Go to start-of-selection
Set PF-STATUS ‘ZDEL’.
Double click on ZDEL
Create object
Click on yes
Enter the short text (ex: -DELIVERY STATUS)
Press enter.
STEP2: - Click on application tool bar
Click on pulse button to expand
Place the cursor on the first box
Write display their
Double click on display
Press enter
Enter function text (ex: - DISPLAY)
Icon name (ex: - ICON-DISPLAY)
Enter info text (ex: - DISPLAY)
Press enter
Press enter
Select shortcut key for button (ex: - SHIFT+F7)
Enter icon text (ex: - DISPLAY)
Enter info text (ex: - DISPLAY)
Press enter
Save and activate
Back.
STEP3: - Function keys
Expand the function keys
Put BACK, EXIT, CANCLE…..
Save and activate
Back.
GET CURSOR: -
SYNTAX: - CURSOR FIELD <WA-FLD> VALUE <VARIABLE>.
EX: - cursor field lw_likp-vbeln value v_vbeln.

WHOLE STORY NARRATED BY VAMSI


PROGRAM FOR AT LINE-SELECTION AND TOP-OF-PAGE DURING LINE-
SELECTION: -
Tables : ekko,ekpo.
Types : begin of t_ekko,
ebeln type ebeln, "purchasing document number
ekorg type ekorg, "purchasing organization
ekgrp type bkgrp, "purchasing group
lifnr type elifn, "vendor number
end of t_ekko.
Types : begin of t_ekpo,
ebeln type ebeln, "purchasing document number
ebelp type ebelp, "item number
matnr type matnr, "material number
menge type bstmg, "quantity
netpr type bprei, "netprice
end of t_ekpo.

************ declare table


Types : tt_ekko type standard table of t_ekko,
tt_ekpo type standard table of t_ekpo.
Data : lw_ekko type t_ekko,
lw_ekpo type t_ekpo,
lt_ekko type tt_ekko,
lt_ekpo type tt_ekpo.
Select-options : s_ebeln for ekko-ebeln.
Start-of-selection.
*-- po header data
Select ebeln ekorg ekgrp lifnr from ekko
into table lt_ekko
where ebeln in s_ebeln.
if not lt_ekko is initial.
loop at lt_ekko into lw_ekko.
write : / lw_ekko-ebeln hotspot,
lw_ekko-ekorg , lw_ekko-ekgrp ,
lw_ekko-lifnr.
hide : lw_ekko-ebeln.
endloop.
endif.
At line-selection.
clear lw_ekpo.

WHOLE STORY NARRATED BY VAMSI


refresh lt_ekpo.
Select ebeln ebelp matnr menge netpr from ekpo
into table lt_ekpo
where ebeln = lw_ekko-ebeln.
if not lt_ekpo is initial.
loop at lt_ekpo into lw_ekpo.
write : /2 lw_ekpo-ebeln , 10 lw_ekpo-ebelp ,
17 lw_ekpo-matnr ,
40 lw_ekpo-menge , 62 lw_ekpo-netpr.
clear lw_ekpo.
endloop.
endif.
top-of-page during line-selection.
write : /2'po num' , 10 'item no', 17 'material',
40 'quantity' , 62 'netval'.

PROGRAM FOR AT USER-COMMAND: -


Tables : likp, lips.
Types : begin of t_likp,
vbeln type vbeln_vl, " delivery number
vstel type vstel, " shipping point
lfdat type lfdat_v, " delivery date
kunnr type kunwe,
end of t_likp.

Types : begin of t_lips,


vbeln type vbeln_vl, " delivery number
posnr type posnr_vl, " item number
erdat type erdat, " date created
matnr type matnr, " material number,
lfimg type lfimg, " quantity
end of t_lips.

**-- declaring table types


Types : tt_likp type standard table of t_likp,
tt_lips type standard table of t_lips.

**-- declaring wa and itab


Data : lw_likp type t_likp,
lw_lips type t_lips,
lt_likp type tt_likp,

WHOLE STORY NARRATED BY VAMSI


lt_lips type tt_lips.
Data : v_vbeln type vbeln_vl.
**-- declaring select-option
selection-screen begin of block a1 with frame title text-001.
select-options : s_vbeln for likp-vbeln .
selection-screen end of block a1.

start-of-selection.
*-- gui status
set pf-status 'zdel'.
clear lw_likp.
refresh lt_likp.
**-- populate the header data
select vbeln vstel lfdat kunnr from likp
into table lt_likp
where vbeln in s_vbeln.
if not lt_likp is initial.
format color 3.
loop at lt_likp into lw_likp.
write : / lw_likp-vbeln, lw_likp-vstel,
lw_likp-lfdat,
lw_likp-kunnr.
endloop.
endif.

At user-command.
case sy-ucomm.
when 'display'.
if not lt_likp is initial.
**-- populate the item data
clear lw_lips.
refresh lt_lips.
get cursor field lw_likp-vbeln value v_vbeln.
select vbeln posnr erdat matnr lfimg from lips
into table lt_lips
where vbeln = v_vbeln.
endif.
if not lt_lips is initial.
format color 4.
loop at lt_lips into lw_lips.

WHOLE STORY NARRATED BY VAMSI


write : / lw_lips-vbeln, lw_lips-posnr,
lw_lips-erdat, lw_lips-matnr,
lw_lips-lfimg.
clear lw_lips.
endloop.
else.
write : / 'no data found'.
endif.
when 'quit'.
* leave.
leave to screen 0.
* leave program.
when 'back' or 'cancel' or 'exit'.
leave.
endcase.

WHOLE STORY NARRATED BY VAMSI


CONTROL BREAK STATEMENTS
CONTROL BREAK STATEMENTS: -
Control break statements (CBS) are used for complex calculations like substitutes &
grand totals.
1. AT FIRST.
-------------
PO NUM ITEM MATERAIL QUANTITY
-------------
101 10 PEN 2
ENDAT.
101 20 PENCIL 4
2. AT NEW.
------------ 102 10 M-01 2
------------
102 20 M-02 3
ENDAT.
102 30 M-03 1
3. AT LAST.
------------- 104 10 PENCIL 2
-------------
105 10 M-01 2
ENDAT.
105 20 M-02 4
4. AT END OF.
-----------------
-----------------
ENDAT.

AT FIRST: - The first line of an ITAB.


AT LAST: - It is a last line (Record) of an ITAB.
AT NEW: - At new will fire beginning of group of lines.
AT END OF: - This will fire at end of group of lines.
At end is technically used for sub totals & grand totals. The IPF (Inter pack float) fields
can be totaled automatically using “SUM” key word.

PRE- REQUISITES FOR CONTROL BREAK STATEMENTS: -


1. Table need to be sorted.
SYNTAX: - SORT <ITAB> BY <FLD> <ASC/DESC>.
EX: - Sort lt_ekpo by ebeln.
2. All the control break statements need to be used with in LOOP and ENDLOOP.

NOTE: - In order to handle asterisks’ and zeros in the control break statements, we need to
move the data another work area or variables and used it along with write statements.

WHOLE STORY NARRATED BY VAMSI


PROGRAM1: - (WITH HEADER)
tables : ekpo.
data : BEGIN OF lt_ekpo OCCURS 0,
ebeln type ebeln,
ebelp type ebelp,
matnr type matnr,
menge type bstmg,
END OF lt_ekpo.
select-options : s_ebeln for ekpo-ebeln.
data : v_ebeln type ebeln,
v_ebelp type ebelp,
v_matnr type matnr,
v_menge type bstmg.
START-OF-SELECTION.
SELECT ebeln ebelp matnr menge from ekpo
into TABLE lt_ekpo
where ebeln in s_ebeln.
if sy-subrc eq 0.
sort lt_ekpo by ebeln.
loop at lt_ekpo.
v_ebeln = lt_ekpo-ebeln.
v_ebelp = lt_ekpo-ebelp.
v_matnr = lt_ekpo-matnr.
v_menge = lt_ekpo-menge.
at FIRST .
* WRITE : / LT_EKPO-EBELN,lt_ekpo-ebelp,
* lt_ekpo-matnr,lt_ekpo-menge.
write : / v_ebeln , v_ebelp, v_matnr,
v_menge.
endat.
*************************************************
*at last.
* write : / v_ebeln , v_ebelp, v_matnr,
* v_menge.
*endat.
**********************************************
* at new ebeln .
* write : / lt_ekpo-ebeln , v_ebelp, v_matnr,
* v_menge.
* endat.

WHOLE STORY NARRATED BY VAMSI


**********************************************
*at end of ebeln.
* sum.
* WRITE : / LT_EKPO-EBELN,v_ebelp,
* v_matnr,lt_ekpo-menge.
*endat.
endloop.
endif.

PROGRAM2: - (WITHOUT HEADER)


TABLES : EKPO.
TYPES : BEGIN OF T_EKPO,
ebeln type ebeln,
ebelp type ebelp,
matnr type matnr,
menge type bstmg,
END OF T_ekpo.
TYPES : TT_EKPO TYPE STANDARD TABLE OF T_EKPO.
DATA : LW_EKPO TYPE T_EKPO,
LT_EKPO TYPE TT_EKPO.
data : v_ebeln type ebeln,
v_ebelp type ebelp,
v_matnr type matnr,
v_menge type bstmg.
SELECTION-SCREEN BEGIN OF BLOCK B WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS: S_EBELN FOR EKPO-EBELN.
SELECTION-SCREEN END OF BLOCK B.
*---------------------------------------------------------------------*
INITIALIZATION.
*---------------------------------------------------------------------*
S_EBELN-SIGN = 'I'.
S_EBELN-OPTION = 'BT'.
S_EBELN-LOW ='4500004823'.
S_EBELN-HIGH ='4500004826'.
APPEND S_EBELN.

*---------------------------------------------------------------------*
AT SELECTION-SCREEN.
*---------------------------------------------------------------------*
SELECT SINGLE * FROM EKPO
INTO EKPO

WHOLE STORY NARRATED BY VAMSI


WHERE EBELN IN S_EBELN.
IF SY-SUBRC NE 0.
MESSAGE E002(ZBSR).
ENDIF.

START-OF-SELECTION.
SELECT ebeln ebelp matnr menge from ekpo
into TABLE lt_ekpo
where ebeln in s_ebeln.
if sy-subrc eq 0.
sort lt_ekpo by ebeln.
loop at lt_ekpo INTO LW_EKPO.
v_ebeln = lW_ekpo-ebeln.
v_ebelp = lW_ekpo-ebelp.
v_matnr = lW_ekpo-matnr.
v_menge = lW_ekpo-menge.
* at FIRST .
* WRITE : / LW_EKPO-EBELN,lW_ekpo-ebelp,
* lW_ekpo-matnr,lW_ekpo-menge.
* write : / v_ebeln , v_ebelp, v_matnr,
* v_menge.
* endat.
*************************************************
at last.
write : / v_ebeln , v_ebelp, v_matnr,
v_menge.
endat.
**********************************************
* at new ebeln .
* write : / lW_ekpo-ebeln , v_ebelp, v_matnr,
* v_menge.
* endat.
**********************************************
*at end of ebeln.
* sum.
* WRITE : / LW_EKPO-EBELN,
* V_EBELP,V_MATNR,lW_ekpo-menge.
*endat.
endloop.
endif.

WHOLE STORY NARRATED BY VAMSI


MODULARIZATION TECHNIQUES
MODULARIZATION TECHNIQUES: -
These will improve the performance of a program or report it is recommended to
implement modularization techniques.
They are 3 types of modularization techniques
1. Function modules
2. Subroutines
3. Includes

WORKING WITH FUNCTION MODULES (FM) : - (TCODE-SE37)


• FM are predefined and complied in status. Every FM is associated with a function group
as a parent object and we can keep ‘N’ No. of function modules inside a group.
• They are predefined SAP function modules as well as we can create custom function
modules.
• Function modules are stored in a table called as “TFDIR”.
They are 3 types of function modules in SAP.
1. Normal function modules
2. Remote-enable function module
3. Update function module

PREDEFINED SAP FUNCTION MODULES: -


v SD_DATETIME_DIFFERENCE
v RP_LAST_DAY_OF_MONTHS
v SPELL_AMOUNT
v FIMA_DAYS_AND_MONTHS_AND_YEARS
v FIMA_DAYS_BETWEEN_TWO_DATS
v CONVERSION_EXIT_ALPHA_INPUT
v CONVERSION_EXIT_ALPHA_OUTPUT

TESTING FM: -
STEP1: - Go to SE37
Enter the function module name (ex: - ISH_GET_WEEKDAY_NAME)
Press F8
Enter the import parameters values
Date
Language
Press F8
The output will be in export parameters

WHOLE STORY NARRATED BY VAMSI


CALLING FUNCTION MODULES: -
SYNTAX: - CALL FUNCTION <FUN NAME>.

ATTRIBUTES: - It describes about function group processing type of an FM and person


created etc.

IMPORT: - By using import option we can declare importing variable, structure, ITAB function
module is importing and ABAP program is exporting the values.

EXPORT: - By using export option we can export a variable, structure, ITAB and ABAP
program is importing those values.

CHANGING: - By using changing option, we can declare variable, structure, ITAB and we can
rewrite the existing values of a variable, structure & ITAB.

TABLES: - It is an obsolete option, it is not recommended to user from ECC 5.0 version
onwards. The reason is ITAB declared in this become with header line.

EXCEPTIONS: - It is need to be raised to handle invalid inputs and bad data.

CREATING CUSTOM FUNCTION: -


STEP1: - Create a function group in SE80
Go to SE80 (object navigator)
Select function group from the drop down
Enter the function group name (ex: - ZNSR_FG)
Press enter
Click on yes
Enter the short text (ex: - customer fun group)
Press enter
Press F7 (local object)
SPET2: - Select the function group root folder
Mouse right button
Activate
STEP3: - Go to function builder SE37
Enter the function module (ex: - Z_READ_CUSTOMER_DETAILS)
Click on create
Enter function group (ex: - ZVK_FG)
Enter Short text (ex: - CUSTOMER DETAILS)
STEP4: - Go to import tab (ex: - IM_KUNNR TYPE KUNNER)
STEP5: - Go to export tab declare a structure (ex: - KNA1 TYPE KNA1)
STEP6: - Go to exceptions (ex: - NO_DATA_FOUND NO DATA FOUND)

WHOLE STORY NARRATED BY VAMSI


STEP7: - Click on source code tab.
Write the ABAP code using import & export parameters.
Save and activate.
STEP8: - Test the function module
Run the FM (F8)
Enter the customer No. (IM_KUNNR 1390)
Press F8.
STEP9: - Develop a calling program.
Ø Build an ITAB with duplicated data manually.
Ø Delete adjacent duplicates from LT_MARA comparing MATNR.

CREATING A TABLE TYPE: -


STEP1: - Create a structure
Go to SE11
Select radio button data type (ex: - ZVKS_EKPO)
Click on create
Select structure
Press enter
Enter short description (ex: - T_EKPO)
In component tab
Enter EBELN EBELN
POSNR POSNR
MATNR MATNR
MENGE BSTMG
Select the menge field
Click on currency/quantity fields
REFERNCE TABLE REG FIELDS
EKPO MEINS
Save and activate.
STEP2: - Creating a table type
Go to SE11
Radio button data type (ex: - ZTT_EKPO)
In the line type tab enter the structure
Enter line type (ex: - ZVKS_EKPO)
Save and activate.

WHOLE STORY NARRATED BY VAMSI


CREATING A FUNCTION MODULE TO BRING BACK ITAB DATA: -
OBJECTIVE: - Find out the purchase order details for a given PO number.
STEP1: - Go to SE37
Enter the function name (ex: - Z_READ_PO_DETAILS)
Enter Function group (ex: - ZVK_FG)
Enter Short text (ex: - PO DETAILS)
Press enter.
STEP2: - In Import tab enter (ex: - IM_EBELN TYPE ZTT_EKPO)
STEP3: - In export tab enter (ex: - ET_EKPO TYPE ZTT_EKPO)
Save and activate
STEP4: - In exceptions tab enter (ex: - NO_DATA_FOUND NO DATA FOUND)
STEP5: - click on Source code
IF NOT IM_EBELN IS INITIAL.
SELECT EBELN EBELP MATNR MENGE FROM EKPO
INTO TABLE ET_EKPO
WHERE EBELN = IM_EBELN
IF SY_SUBRC = 0.
RAISE NO_DATA_FOUND.
ENDIF.
ENDIF.
Save and activate.
Test the FM (F8).
STEP6: - Create a calling program.

Q. How do we pass select-options to the function modules?


(OR)
How do we pass range values to the function modules?
Ans: - Using select-options with SELOPT structure.

WORKING WITH SUB-ROUTINES: -


Sub-routines are used for Re-usability and improve the performance of the report.
They are 3 types of Sub-Routines.
1. PERFORM <PERFORM NAME>
2. PERFORM <PERFORM NAME> USING <VAR/WA/ITAB>
3. PERFORM <PERFORM NAME> TABLES <ITAB>
Ø The parameters associated with PERFORM are known as actual parameters.
Ø The parameters associated with the FORM…………ENDFORM are known as formal
parameters.
STEP1: - Go to the start-of-selection
Write perform <perform name>
And double click on the perform name

WHOLE STORY NARRATED BY VAMSI


Click on yes
Select the main program
You will be awarded with FORM and ENDFORM
And write the ABAP logic on between them.
NOTE: - It is recommended that every PERFORM should have inline comment on top of it.

PROGRAM1: -
REPORT ZNSR_SUBROUTINES.
data : v_a type i,
v_b TYPE i,
v_c TYPE i.

START-OF-SELECTION.
PERFORM default_values.
PERFORM get_total USING v_a v_b
CHANGING v_c.
BREAK user4.
*&---------------------------------------------------------------------*
*& Form get_total
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_V_A text
* -->P_V_B text
* <--P_V_C text
*----------------------------------------------------------------------*
FORM get_total USING P_V_A
P_V_B
CHANGING P_V_C.
p_v_c = p_v_a + p_v_b.
WRITE : / p_v_c.
ENDFORM. " get_total
*&---------------------------------------------------------------------*
*& Form default_values
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*

WHOLE STORY NARRATED BY VAMSI


FORM default_values .
v_a = 20.
v_b = 30.
ENDFORM. " default_values

PROGRAM2: -
REPORT ZNSR_SUBROUTINES2.
TABLES : LIKP.
TYPES : BEGIN OF T_LIKP,
VBELN TYPE VBELN_VL, " Delivery Number
VSTEL TYPE VSTEL, " Shipping Point
LFDAT TYPE LFDAT_V, " Delivery Date
KUNNR TYPE KUNWE,
END OF T_LIKP.
**-- Declaring Table Types
TYPES : TT_LIKP TYPE STANDARD TABLE OF T_LIKP.
DATA : LW_LIKP TYPE T_LIKP,
LT_LIKP TYPE TT_LIKP.
SELECTION-SCREEN BEGIN OF BLOCK A1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS : S_VBELN FOR LIKP-VBELN .
SELECTION-SCREEN END OF BLOCK A1.

START-OF-SELECTION.

PERFORM GET_DATA TABLES LT_LIKP.


PERFORM display_data.
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_LT_LIKP text
*----------------------------------------------------------------------*
FORM GET_DATA TABLES PT_LIKP STRUCTURE lW_LIKP.
SELECT
VBELN
VSTEL
LFDAT
KUNNR
FROM LIKP
INTO TABLE PT_LIKP

WHOLE STORY NARRATED BY VAMSI


WHERE VBELN IN S_VBELN.
ENDFORM. " GET_DATA
*&---------------------------------------------------------------------*
*& Form display_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM display_data .
loop at lt_likp INTO lw_likp.
WRITE : / lw_likp-vbeln , lw_likp-vstel.
clear lw_likp.
ENDLOOP.
ENDFORM. "

PROGRAM3: -
REPORT ZVK_SUBROUTINES1.

TABLES : EKPO.
TYPES : BEGIN OF T_EKPO,
EBELN TYPE EKPO-EBELN,
EBELP TYPE EKPO-EBELP,
MATNR TYPE EKPO-MATNR,
MENGE TYPE EKPO-MENGE,
END OF T_EKPO.
TYPES: TT_EKPO TYPE STANDARD TABLE OF T_EKPO.
DATA : LW_EKPO TYPE T_EKPO,
LT_EKPO TYPE TT_EKPO.
SELECT-OPTIONS : S_EBELN FOR EKPO-EBELN.

START-OF-SELECTION.
PERFORM GET_DATA.
PERFORM display_data using lt_ekpo.
*&---------------------------------------------------------------------*
*& Form get_Data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text

WHOLE STORY NARRATED BY VAMSI


* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_DATA .
SELECT EBELN
EBELP
MATNR
MENGE FROM EKPO
INTO TABLE LT_EKPO WHERE EBELN IN S_EBELN.
*
SORT LT_EKPO BY EBELN.
ENDFORM. " get_Data
*&---------------------------------------------------------------------*
*& Form display_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_LT_EKPO text
*----------------------------------------------------------------------*
FORM display_data USING PT_EKPO TYPE TT_EKPO.
DATA : PW_EKPO TYPE T_EKPO.
LOOP AT PT_EKPO INTO PW_EKPO.
WRITE : / PW_EKPO-EBELN , PW_EKPO-EBELP,
PW_EKPO-MATNR , PW_EKPO-MENGE.
ENDLOOP.

ENDFORM. " display_data


DEBUGGING TIPS: -
F5 – Line by line execution
F6 – Execute (It goes to available perform or next available statement)
F7 – Return (You have been inside FROM and ENDFORM and where ever you want get out
from FORM and ENDFORM press F7)
F8 – Run.

NOTE: - If subroutine is declared with using or changing options the formal parameters need to
be declared same as actual parameters.

WHOLE STORY NARRATED BY VAMSI


ALV REPORTS
ALV REPORTS: - (ABAP LIST VIEWER)
ALV reports are used for complex reporting with the following futures.
1. Sort ascending / Descending
2. ∑ (Sum)
3. Select / Deselect
4. Filter
5. Local file
6. Send email
7. Change layout
ALV reports are user friendly in nature it enable the end user to design the layout as per
His/her choice.

They are 2 types of reports in ALV


1. ALV GRID DISPLAY
2. ALV LIST DISPLAY
They are 2 function modules associated with it.
1. RESUSE_ALV_GRID_DISPLAY
2. RESUSE_ALV_LIST_DIAPLAY
To search ALV related function modules enter like this (ex: - RESUSE*ALV*)

IN SLIS ROW NO: 73


TO GROUP (SE11)
WE HAVE FIELDCAT AT 73 ROW
IN THAT THERE IS A STRUCTURE (SLIS_FIELDCAT_MAIN0)
• COL_POS
• FEILDNAME
• TABNAME
• SELTEXT_M
IN 144 LINE (SLIS_FIELDCAT_ALV)

IMPORTANT PARAMETERS OF RESUSE_ALV_GRID_DISPLAY: -


I_CALLBACK_PROGRAM = ‘ABAP program name’
I_GRID_TITLE = ‘Report name’
IT_FIELDCAT = FIELDCAT INTERNAL TABLE
T_OUTTAB = DATA INTERNAL TABLE

SY-REPID: - Which gives the current program name or report name.

WHOLE STORY NARRATED BY VAMSI


NOTE: - In order to build the field catalog automatically
“RESUSE_ALV_FIELD CATALOG_MERGE”

INTERACTIVE ALV: -
Interactive ALV can be generated using a function module
“RESUSE_ALV_POPUP_TO_SELECT”.
PARAMETERS TO BE PASS: -
I_TABNAME
IT_FIELDCAT
TABLES
T_OUTTAB = DATA INTERNAL TABLE
Ø To capture information of cursor poison in ALV
Ø SLIS_SELFIELD structure is used VALUE field will have run time value of ALV grid
selfield value.
3 STEPS: -
1. Build catalog for items
2. Get the item data
3. Call the popup to select FM

TOP-OF-PAGE: - In order to trigger top-of-page for ALV, SLIS_LISTHEADER structure is


used. It has two attributes.
a. Typ
b. Info
Table type name: - SLIS_T_LISTHEADER
Ø In order to trigger a top-of-page RESUSE_ALV_COMMENTARY_WRITE is used for
this FM pass the list header ITAB.
Ø They are predefined “BALV” programs to know some idea about ABAP programs.

WHOLE STORY NARRATED BY VAMSI


PRIGRAM: -

REPORT ZVK_ALV_REPORTS.
INCLUDE ZVK_ALV.
TYPE-POOLS SLIS .
TABLES : EKKO,EKPO.
-
TYPES : BEGIN OF T_EKKO,
EBELN TYPE EBELN,
EKORG TYPE EKORG,
EKGRP TYPE BKGRP,
LIFNR TYPE ELIFN,
END OF T_EKKO.
TYPES : TT_EKKO TYPE STANDARD TABLE OF T_EKKO.
DATA : LW_EKKO TYPE T_EKKO,
LT_EKKO TYPE TT_EKKO.
TYPES : BEGIN OF T_EKPO,
EBELN TYPE EBELN,
EBELP TYPE EBELP,
MATNR TYPE MATNR,
MENGE TYPE BSTMG,
END OF T_EKPO.
TYPES : TT_EKPO TYPE STANDARD TABLE OF T_EKPO.
DATA : LW_EKPO TYPE T_EKPO,
LT_EKPO TYPE TT_EKPO.

*--ALV DECLERATION
*-- FIELD CATALOG FOR HEADER "MARA
DATA : LW_FCAT TYPE SLIS_FIELDCAT_ALV,
LT_FCAT TYPE SLIS_T_FIELDCAT_ALV.
*-- FIELD CATALOG FOR ITEM "MARC
DATA : LW_ICAT TYPE SLIS_FIELDCAT_ALV,
LT_ICAT TYPE SLIS_T_FIELDCAT_ALV.
*-- TOP OF PAGE
DATA : LW_HEADER TYPE SLIS_LISTHEADER,
LT_HEADER TYPE SLIS_T_LISTHEADER.

SELECT-OPTIONS : S_EBELN FOR EKKO-EBELN.


START-OF-SELECTION.
PERFORM BUILD_CATALOG.

WHOLE STORY NARRATED BY VAMSI


PERFORM BUILD_TOP_PAGE.
PERFORM TOP.
PERFORM GET_DATA.
PERFORM GRID_DISPLAY.
PERFORM list_display.
*&---------------------------------------------------------------------*
*& Form build_catalog
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM BUILD_CATALOG .
LW_FCAT-COL_POS = 1.
LW_FCAT-FIELDNAME = 'EBELN'.
LW_FCAT-TABNAME = 'LT_EKKO'.
LW_FCAT-SELTEXT_M = 'PO NUM'.
LW_FCAT-REF_FIELDNAME = 'EBELN'.
LW_FCAT-REF_TABNAME = 'EKKO'.
APPEND LW_FCAT TO LT_FCAT.
CLEAR LW_FCAT.

LW_FCAT-COL_POS = 2.
LW_FCAT-FIELDNAME = 'EKORG'.
LW_FCAT-TABNAME = 'LT_EKKO'.
LW_FCAT-SELTEXT_M = 'PUR ORG'.
LW_FCAT-REF_FIELDNAME = 'EKORG'.
LW_FCAT-REF_TABNAME = 'EKKO'.
APPEND LW_FCAT TO LT_FCAT.
CLEAR LW_FCAT.

LW_FCAT-COL_POS = 3.
LW_FCAT-FIELDNAME = 'EKGRP'.
LW_FCAT-TABNAME = 'LT_EKKO'.
LW_FCAT-SELTEXT_M = 'PO GROUP'.
LW_FCAT-REF_FIELDNAME = 'EKGRP'.
LW_FCAT-REF_TABNAME = 'EKKO'.
APPEND LW_FCAT TO LT_FCAT.

WHOLE STORY NARRATED BY VAMSI


CLEAR LW_FCAT.

LW_FCAT-COL_POS = 4.
LW_FCAT-FIELDNAME = 'LIFNR'.
LW_FCAT-TABNAME = 'LT_EKKO'.
LW_FCAT-SELTEXT_M = 'VENDOR'.
LW_FCAT-REF_FIELDNAME = 'LIFNR'.
LW_FCAT-REF_TABNAME = 'EKKO'.
APPEND LW_FCAT TO LT_FCAT.
CLEAR LW_FCAT.
*-- Build catalog for Item EKPO
LW_ICAT-COL_POS = 1.
LW_ICAT-FIELDNAME = 'EBELP'.
LW_ICAT-TABNAME = 'LT_EKPO'.
LW_ICAT-SELTEXT_M = 'ITEM NUM'.
LW_ICAT-REF_FIELDNAME = 'EBELP'.
LW_ICAT-REF_TABNAME = 'EKPO'.
APPEND LW_ICAT TO LT_ICAT.
CLEAR LW_ICAT.

LW_ICAT-COL_POS = 2.
LW_ICAT-FIELDNAME = 'MATNR'.
LW_ICAT-TABNAME = 'LT_EKPO'.
LW_ICAT-SELTEXT_M = 'MATERIAL'.
LW_ICAT-REF_FIELDNAME = 'MATNR'.
LW_ICAT-REF_TABNAME = 'EKPO'.
APPEND LW_ICAT TO LT_ICAT.
CLEAR LW_ICAT.

LW_ICAT-COL_POS = 3.
LW_ICAT-FIELDNAME = 'MENGE'.
LW_ICAT-TABNAME = 'LT_EKPO'.
LW_ICAT-SELTEXT_M = 'QUANTITY'.
LW_ICAT-REF_FIELDNAME = 'MENGE'.
LW_ICAT-REF_TABNAME = 'EKPO'.
APPEND LW_ICAT TO LT_ICAT.
CLEAR LW_ICAT.
ENDFORM. " build_catalog
*&---------------------------------------------------------------------*
*& Form get_data

WHOLE STORY NARRATED BY VAMSI


*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_DATA .
SELECT EBELN EKORG EKGRP LIFNR FROM EKKO
INTO TABLE LT_EKKO
WHERE EBELN IN S_EBELN.
ENDFORM. " get_data
*&---------------------------------------------------------------------*
*& Form grid_display
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GRID_DISPLAY .
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK =''
* I_BYPASSING_BUFFER =''
* I_BUFFER_ACTIVE =''
I_CALLBACK_PROGRAM = SY-REPID
* I_CALLBACK_PF_STATUS_SET =''
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_CALLBACK_TOP_OF_PAGE = 'TOP'
* I_CALLBACK_HTML_TOP_OF_PAGE =''
* I_CALLBACK_HTML_END_OF_LIST =''
* I_STRUCTURE_NAME =
* I_BACKGROUND_ID =''
* I_GRID_TITLE = 'THOS IS GRID TITLE'
* I_GRID_SETTINGS =
* IS_LAYOUT =
IT_FIELDCAT = LT_FCAT
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =

WHOLE STORY NARRATED BY VAMSI


* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE =''
* IS_VARIANT =
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN =0
* I_SCREEN_START_LINE =0
* I_SCREEN_END_COLUMN =0
* I_SCREEN_END_LINE =0
* I_HTML_HEIGHT_TOP =0
* I_HTML_HEIGHT_END =0
* IT_ALV_GRAPHICS =
* IT_HYPERLINK =
* IT_ADD_FIELDCAT =
* IT_EXCEPT_QINFO =
* IR_SALV_FULLSCREEN_ADAPTER =
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = LT_EKKO
EXCEPTIONS
PROGRAM_ERROR =1
OTHERS =2
.
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. " grid_display


*&---------------------------------------------------------------------*
*& Form list_display
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*

WHOLE STORY NARRATED BY VAMSI


* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM LIST_DISPLAY .
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
* I_INTERFACE_CHECK =''
* I_BYPASSING_BUFFER =
* I_BUFFER_ACTIVE =''
I_CALLBACK_PROGRAM = SY-REPID
* I_CALLBACK_PF_STATUS_SET =''
* I_CALLBACK_USER_COMMAND =''
* I_STRUCTURE_NAME =
* IS_LAYOUT =
IT_FIELDCAT = LT_FCAT
* IT_EXCLUDING =
* IT_SPECIAL_GROUPS =
* IT_SORT =
* IT_FILTER =
* IS_SEL_HIDE =
* I_DEFAULT = 'X'
* I_SAVE =''
* IS_VARIANT =
* IT_EVENTS =
* IT_EVENT_EXIT =
* IS_PRINT =
* IS_REPREP_ID =
* I_SCREEN_START_COLUMN =0
* I_SCREEN_START_LINE =0
* I_SCREEN_END_COLUMN =0
* I_SCREEN_END_LINE =0
* IR_SALV_LIST_ADAPTER =
* IT_EXCEPT_QINFO =
* I_SUPPRESS_EMPTY_DATA = ABAP_FALSE
* IMPORTING
* E_EXIT_CAUSED_BY_CALLER =
* ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = LT_EKKO
EXCEPTIONS

WHOLE STORY NARRATED BY VAMSI


PROGRAM_ERROR =1
OTHERS =2
.
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. " list_display


*&---------------------------------------------------------------------*
*& Form USER_COMMAND
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM USER_COMMAND USING V_UCOMM TYPE SY-UCOMM
LW_SELFIELD TYPE SLIS_SELFIELD .
CASE V_UCOMM.
WHEN '&IC1'.
SELECT EBELN EBELP MATNR MENGE FROM EKPO
INTO TABLE LT_EKPO
WHERE EBELN = LW_SELFIELD-VALUE.

CALL FUNCTION 'REUSE_ALV_POPUP_TO_SELECT'


EXPORTING
* I_TITLE =
* I_SELECTION = 'X'
* I_ALLOW_NO_SELECTION =
* I_ZEBRA =''
* I_SCREEN_START_COLUMN =0
* I_SCREEN_START_LINE =0
* I_SCREEN_END_COLUMN =0
* I_SCREEN_END_LINE =0
* I_CHECKBOX_FIELDNAME =
* I_LINEMARK_FIELDNAME =
* I_SCROLL_TO_SEL_LINE = 'X'
I_TABNAME = 'LT_EKPO'
* I_STRUCTURE_NAME =
IT_FIELDCAT = LT_ICAT
* IT_EXCLUDING =
* I_CALLBACK_PROGRAM =

WHOLE STORY NARRATED BY VAMSI


* I_CALLBACK_USER_COMMAND =
* IS_PRIVATE =
* IMPORTING
* ES_SELFIELD =
* E_EXIT =
TABLES
T_OUTTAB = LT_EKPO
EXCEPTIONS
PROGRAM_ERROR =1
OTHERS =2
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

ENDCASE.

ENDFORM. "USER_COMMAND
*&---------------------------------------------------------------------*
*& Form BUILD_TOP_PAGE
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM BUILD_TOP_PAGE .
DATA : V_STR TYPE STRING.
LW_HEADER-TYP = 'H'.
LW_HEADER-INFO = TEXT-001.
APPEND LW_HEADER TO LT_HEADER.
CLEAR LW_HEADER.
CONCATENATE 'FROM' S_EBELN-LOW ' TO ' S_EBELN-HIGH INTO V_STR
SEPARATED BY SPACE.
LW_HEADER-TYP = 'S'.
LW_HEADER-INFO = V_STR.
APPEND LW_HEADER TO LT_HEADER.
CLEAR LW_HEADER.
ENDFORM. " BUILD_TOP_PAGE

WHOLE STORY NARRATED BY VAMSI


*&---------------------------------------------------------------------*
*& Form TOP
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM TOP.
CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
IT_LIST_COMMENTARY = LT_HEADER
I_LOGO = 'ENJOYSAP_LOGO'
* I_END_OF_LIST_GRID =
* I_ALV_FORM =
.
ENDFORM. "TOP

WHOLE STORY NARRATED BY VAMSI


BDC
BDC (BATCH DATA COMMUNICATION): -
BDC methodology will be used to upload the data from LEGACY systems to SAP.
BDC upload can be in 2 ways.
1. Conversion LEGECY
2. Interfaces SYSTEM (NON-SAP)

SAP
SYATEM

WORKING WITH FILES: - Core team will supply files in .XLS format, .EXE format, .CVS
format.

CONVERTING XLS SHEET TO TAB-DELMITED FILE: -


STEP1: - Open excel sheet
Click on Conner
With mouse right click button
Format cells
Select text option
Press ok and save
STEP2: - Save file as
File name : (ex: - mat.txt)
Save as type : text (tab delimited)
Press save
Yes-ok

FILES CAN BE READ FROM 2 PLACES: -


1. PRESENTATION SERVER
2. APPLICATION SERVER

FILE FORMAT (In excel sheet): -

MANTR(18) MTART(4) MBRSH(1) MEINS(3)


PEN ROH M EA
PENCIL FERT M PC
BB ROH M EA

STEP1: - Declare an ITAB which is similar to 5 fields sequence and data type should be ‘c’.
In order to upload the data from file to ITAB we use “GUI_UPLOAD” function module.

WHOLE STORY NARRATED BY VAMSI


In order to upload the data from ITAB to file we use “GUI_DOWNLOAD” function module.

WORKING WITH APPLICATION SERVER: - (TCODE – ALL1)


Application server is the secure location in SAP technically it will be UNIX server or
LINUX server.

UNIX FILE PATH: - Go to AL11


Double click on DIR_HOME
And place your file
/usr/sap/LID/DVEBMGSOO/work
In application server we can write a file or we can read a file from it.

OPEN A FILE ON APPLICATION SERVER: -


By using open data set statement we can open a file on the application server. If file
opens successfully the SY-SUBRC = 0 and if it fails to open the SY-SUBRC = 8.

SYNTAX: - OPEN DATASET <DSN>.


------------
------------
------------
CLOSE DATASET <DSN>. (Where DSN – file name)

WRITE ACCESS: -
In order to write a file on application server, we have to “use output statement” along
with open dataset.

SYNTAX: - OPEN DATASET <DSN> FOR OUTPUT.


--------------
--------------
--------------
CLOSE DATASET <DSN>.

READ ACCESS: -
In order to read a file from application server we have to “use input statement” along with
open dataset.

SYNTAX: - OPEN DATASET <DSN> FOR INPUT.


--------------
--------------
--------------
CLOSE DATASET <DSN>.

WHOLE STORY NARRATED BY VAMSI


TEXT MODE: -
In order to open a file in text mode we have to “use in text mode” keyword.
SYNTAX: - OPEN DATASET <DSN> FOR <OUTPUT/INPUT> IN TEXT
MODE ENCODING DEFAULT.
-------------------------
-------------------------
-------------------------
CLOSE DATASET <DSN>.

TRANSFER: - Transfer statement does move the ITAB data to file.

SYNTAX: - TRANSFER <WA/ITAB> TO <DSN>.

READ DATASET: - Read dataset statement is used to move the data from file to ITAB.

SYNTAX: - READ DATASET <DSN> INTO <WA/ITAB>.

1. Read/write the file in application server.


2. Read/write the file in presentation server.

PROGRAM1: - (READ FILE FROM APPL SERVER)

REPORT ZVK_READ_FILE_APPL_SVR.
TYPES : BEGIN OF T_MAT,
MATNR(18) TYPE C,
MTART(4) TYPE C,
MBRSH(1) TYPE C,
MEINS(3) TYPE C,
END OF T_MAT.
TYPES : TT_MAT TYPE STANDARD TABLE OF T_MAT.
DATA : LW_MAT TYPE T_MAT,
LT_MAT TYPE TT_MAT.
DATA : V_DSN(100) TYPE C.

START-OF-SELECTION.
*-- read file form Appl server
PERFORM READ_FILE_FRM_APPL_SVR.
PERFORM DISPLAY_DATA.
*&---------------------------------------------------------------------*
*& Form read_file_frm_appl_svr
*&---------------------------------------------------------------------*
* text

WHOLE STORY NARRATED BY VAMSI


*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM READ_FILE_FRM_APPL_SVR .
V_DSN = '/usr/sap/LID/DVEBMGS00/work/material.txt'.
OPEN DATASET V_DSN FOR INPUT IN TEXT MODE ENCODING DEFAULT.
IF SY-SUBRC EQ 0.
DO.
READ DATASET V_DSN INTO LW_MAT.
IF SY-SUBRC EQ 0.
APPEND LW_MAT TO LT_MAT.
ELSE.
EXIT.
ENDIF.
ENDDO.
ELSE.
WRITE : / 'No data found'.
ENDIF.
CLOSE DATASET V_DSN.
ENDFORM. " read_file_frm_appl_svr
*&---------------------------------------------------------------------*
*& Form display_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM DISPLAY_DATA .
LOOP AT LT_MAT INTO LW_MAT.
WRITE : / LW_MAT-MATNR, LW_MAT-MBRSH.
ENDLOOP.
ENDFORM. " display_data
PROGRAM2: - (WRITE FILE TO APLL SERVER)
REPORT ZVK_WRITE_FILE_APPL_SVR.
TYPES : BEGIN OF T_MAT,
MATNR(18) TYPE C,
MTART(4) TYPE C,
MBRSH(1) TYPE C,

WHOLE STORY NARRATED BY VAMSI


MEINS(3) TYPE C,
END OF T_MAT.
TYPES : TT_MAT TYPE STANDARD TABLE OF T_MAT.
DATA : LW_MAT TYPE T_MAT,
LT_MAT TYPE TT_MAT.
DATA : V_DSN(100) TYPE C.

START-OF-SELECTION.
PERFORM GET_DATA.
PERFORM WRITE_FILE_ON_APPL_SVR.
*&---------------------------------------------------------------------*
*& Form get_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_DATA .
SELECT MATNR MTART MBRSH MEINS FROM MARA
INTO TABLE LT_MAT
UP TO 3 ROWS.
ENDFORM. " get_data
*&---------------------------------------------------------------------*
*& Form write_file_on_appl_svr
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM WRITE_FILE_ON_APPL_SVR .
V_DSN = '/usr/sap/LID/DVEBMGS00/work/material.txt'.
OPEN DATASET V_DSN FOR OUTPUT IN TEXT MODE
ENCODING DEFAULT.
IF SY-SUBRC EQ 0.
LOOP AT LT_MAT INTO LW_MAT.
TRANSFER LW_MAT TO V_DSN.
CLEAR LW_MAT.
ENDLOOP.

WHOLE STORY NARRATED BY VAMSI


WRITE : / 'File created ' , v_dsn.
ELSE.
WRITE : / 'File could not open'.
ENDIF.
CLOSE DATASET V_DSN.
ENDFORM. " write_file_on_appl_svr

PROGRAM3: - (READ FILE FROM PRESENTATION SERVER)


REPORT ZVK_READ_FILE_PRESENT_SERVER.
TYPES : BEGIN OF T_MAT,
MATNR(18) TYPE C,
MTART(4) TYPE C,
MBRSH(1) TYPE C,
MEINS(3) TYPE C,
END OF T_MAT.
TYPES : TT_MAT TYPE STANDARD TABLE OF T_MAT.
DATA : LW_MAT TYPE T_MAT,
LT_MAT TYPE TT_MAT.
PARAMETERS : p_file type localfile OBLIGATORY.
AT SELECTION-SCREEN on VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME =''
IMPORTING
FILE_NAME = p_file.
START-OF-SELECTION.
PERFORM read_file_data.
PERFORM display_data.
*&---------------------------------------------------------------------*
*& Form read_file_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM read_file_data .
data : l_fnm TYPE string.
l_fnm = p_file.

WHOLE STORY NARRATED BY VAMSI


CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = l_fnm
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = '#'
* HEADER_LENGTH =0
* READ_BY_LINE = 'X'
* DAT_MODE =''
* CODEPAGE =''
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* CHECK_BOM =''
* VIRUS_SCAN_PROFILE =
* NO_AUTH_CHECK =''
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
DATA_TAB = lt_mat
* EXCEPTIONS
* FILE_OPEN_ERROR =1
* FILE_READ_ERROR =2
* 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

WHOLE STORY NARRATED BY VAMSI


* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
DELETE lt_mat where matnr eq space.

ENDFORM. " read_file_data


*&---------------------------------------------------------------------*
*& Form display_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM display_data .
loop at lt_mat into lw_mat.
WRITE : / lw_mat-matnr.
clear lw_mat.
ENDLOOP.
ENDFORM. " display_data

CREATING MATERAIL MASTER (MM01): -


01 – CREATE
02 – CHANGE
03 – DISPLAY
STEP1: - Creating basic material
Go to MM01
Enter material (ex: - MAT - 01)
Industry sector (ex: - M MECHINICAL ENGINEER)
Material type (ex: - ROH RAW MATERAIL)
Click on select views button
Select basic data1 & basic data2
Click on default values button
Press enter.
STEP2: - Enter the material description (ex: - GLASS MATERAIL)
Enter the base unit of measure (ex: - EA)
Click on save button.

WHOLE STORY NARRATED BY VAMSI


CREATING A MATERAIL WITH MULTIPLE VIEWS: -
STEP1: - Go to MM01
Enter the 3 field’s material, industry sector, material type
Click on select views.
Select BASIC1, BASIC2, PURCHASING, MRP, ACCOUNTING1
Click on default values button
Press enter.
Plant (ex: - 1000)
Stor. Location (ex: - 0001)
Click on default values
Press enter
Enter the description (ex: - I DON’T KNOW)
Basic unit measure (ex: - PS)
Material group (ex: - 0001)
Click on purchasing tab
Purchasing group (ex: - 001)
Click on MRP1 tab
MRP type (ex: - ND)
Click on accounting1 tab
Standard price (ex: - 1234)
Valuation class (ex: - 3000)
Select MRP2 tab
Plant deliv. Time (ex: - 10) days.
Click on save.

CREATING CUSTOMER: - (VD01)


STEP1: - Go to VD01
Accounting group (ex: - 0001)
Customer (ex: - 90600)
Sales organization (ex: - 1000)
Distribution channel (ex: - 10)
Division (ex; - 00)
Press enter
Title (ex; - COMPANY)
Name (ex: - INFOSYS
TCS)
Search term ½ (ex: - KG)
City (ex; - HYD)
Country (ex: - IN)
Transporting zone (00000001)

WHOLE STORY NARRATED BY VAMSI


STEP2: - Click on sales area data button
Click on shipping tab
Shipping conditions (ex: - 01)
Click on billing documents tab
Click on tax classification (ex: - 1)
Click on save.

CREATING VENDOR: - (MK01)


STEPS: - Go to MK01
Vendor (ex: - 89346)
Purchasing organization (ex: - 0001)
Accounting group (ex: - 0001)
Press enter
Title (ex: - company)
Name (ex: - j & j)
Search term ½ (ex: - J)
Country (ex: - IN)
City (ex: - HYD)
Click on F8 (or) next screen arrow button
Click on next screen
Order currency (ex: - INR)
Terms of payment (ex: - 002)
Click on save.

CREATING PURCHAGE ORDER: - (ME21N)


STEP1: - Go to ME21N
Vendor (ex: - 1000)
Select org data tab
Purch. Org (ex: - 1000)
Purch. Group (ex: - 001)
Company code (ex: - 1000)
MATERAIL PQ QUANTITY PLANT
100-100 1 1000
Click on save.

CREATING SALES ORDER: - (VA01)


STEP1: - Go to VA01
Order type (ex: - OR)
Sales. Org (ex: - 1000)
Distribution channel (ex: - 10)
Division (ex: - 00)

WHOLE STORY NARRATED BY VAMSI


Press enter
Sold to party (ex: - 1000)
Ship to party (ex: - 1000)
MATERIAL QUANTITY
100-100 1
Press enter & save.
NOTE: - Data will be stored in VBRK, VBAP.

RECORDING AT TRANSACTION: - (SHDB)


NOTE: - While recording the transaction sees to those errors are not raised.
STEPS: - Go to SHDB
Click on new recoding
Enter the recording name (ex: - ZNSR_MM01_DEMO)
Enter the transaction code (ex: - MM01)
Press enter
Carefully enter the data for relative data and save it.
Save the recording as well
Change the material No. (ex: - RMMG1_MATNR_DDEE)
Click on process
Press enter
Answer ok-code box only
Go and verify in the database table.

BDC METHODS: - We can upload the data using BDC methods in 2 ways.
1. Session
2. Call transaction

SESSION: - It is a 2 step process. First we need to create a session and session need to be
processed.
They are 3 functions modules involved in session method
• BDC_OPEN_GROUP
• BDC_INSERT
• BDC_CLOSE_GROUP

BDC_OPEN_GROUP: - This FM is used to create a session and the following parameters need
to be passing.
GROUP = SESSION NAME
KEEP =X
USER = USER1

WHOLE STORY NARRATED BY VAMSI


BDC_INSERT: - This FM enables to pass the data on the given transactions using
“BDCDATA” structure and the following parameters need to be passing to the function module.
TCODE = MM01
DYNPRO TAB = LT_BDCDATA

BDC_CLOSE_GROUP: - It closes the currency open session if you do not pass any parameters
to it.

BDCDATA STRUCTURE: - It has 5 fields.


• PROGRAM
• DYNPRO
• DYNBEGIN
• FNAM
• FVAL

PROGRAM: - We need to pass transaction code program name to this attribute.


DYNPRO: - This attribute represents the screen number.
DYNBEGIN: - It is the new screen indicator.
FNAM: - This attribute represents the screen field name
FVAL: - This attribute represents the screen field value.

CALL TRANSACTION: - It is an online update and you can update the data synchronously or
asynchronously.

SYNRAX: - CALL TRANSACTION <TCODE> USING <BDCDATA>


MODE<A/N/E>
UPDATE <S/A>
MESSAGE INTO <BDCMSGCOLL>.
EX: - Call transaction ‘MM01’ using LT_BDCDATA
Mode ‘A’
Update ‘S’
Message into LT_BDCMSGCOLL.
Even call transaction user BDCDATA structure to move the data onto the transaction.

MODE: - ‘A’ Stands for all screen mode


‘N’ Stands for no screen mode
‘E’ Stands for error mode.
UPDATE: - ‘S’ – Synchronous update
‘A’ – asynchronous update

WHOLE STORY NARRATED BY VAMSI


SYNCHRONOUS UPDATE: - Until unless the transaction is commented it will wait.
EX: - COMMIT WORK AND WAIT.

ASYNCHRONOUS UPDATE: - It’s a vice versa of synchronous update.


EX: - COMMIT WORK.

MESSAGE: - In order to capture the log in call transaction, BDCMSGCOLL structure is used
and message need to handled explicitly, successes, warning, error, information.

v FILE→ITAB→TCODE→LT_BDCDATA→TCODE→DATABASE.

DOWNLOAD THE RECORDING AS A PROGRAM: -


STEPS: - Go to SHDB
Select yours recording name
Click on program button
Enter the program name (ex: - ZNSR_BDC_MM01_DEMO)
And click on radio button transfer
Press enter
Enter the title (ex; - BDC UPLOAD FOR MM01)
Click on source code button.

NOTE: - In the download program identify the material (or) key field of the transaction and
replace with the new number. (Find & replace).

RUNNING SESSION METHOD: -


STEPS: - Run the download program
Click on generate session radio button
Session name (ex: - ZNSR_SES)
User (ex: - user4)
Check the Keep session check box
Save as variant
Press F8
Session will be created
Go to SM35
Select the session name you created
Click on process button
Select process/foreground radio button
Click on process button
Continue with the OK-CODE box
You will get an information box (ex: - processing of batch input session completed)
Click on session over view button
If it is white color it indicates that it is not processed (new)

WHOLE STORY NARRATED BY VAMSI


If it is red color it indicates that it is processed with (error)
Select the successful processed session of yours
Click on analysis button
Click on log, created on tab
To see the logs

RUNNING CALL TRANSACTION METHID: -


STEPS: - Call transaction
Processing mode ‘A’
Update mode ‘S’
Save as variant
Continue with the recording.

FILE FORMAT: -
MATNR MBRSH MTART MAKTX MEINS
REC-01 M ROH PENCIL EA
REC-02 M ROH MARKER PC
REC-03 M ROH BULLET EA

FINAL STEPS OF BDC: -


STEP1: - Declare an internal table with the file sequence and data type should be ‘C’.
STEP2: - Provide a F4 help to give the file name
STEP3: - Get the file data to ITAB
STEP4: - Segregate the perform based on the screen number
STEP5: - Keep a loop after perform OPEN_GROUP
End loop it before perform CLOSE_GROUP
STEP6: - Substitute the hard coded values from the recording with work area fields
(Perform BDC_FIELD).

DEVELOPING A BDC PROGRAM WITH OUT STANDARD INCLUDE: -


It can be done in two ways
1. Using session method
2. Call transaction method

SESSION METHOD STEPS: -


STEP1: - Comment the standard include and check the syntax
STEP2: - Copy the FORM BDC_DYNPRO from include BDCRECX1
STEP3: - Check the syntax
STEP4: - Declare an ITAB of BDCDATA in the work area and replace the BDCDATA with
LW_BDCDATA and append it to LT_BDCDATA.
STEP5: - Check the syntax

WHOLE STORY NARRATED BY VAMSI


STEP6: - Copy the BDC_FIELD FORM from the include BDCRECX1 and replace BDCDATA
With LW_BDCDATA and append it to LW_BDCDATA (Remove IF and ENDIF
Condition from the FORM and ENDFORM).

STEP7: - Check the syntax


STEP8: - Comment the PERFORM BDC_TRANSACTION and write your own PERFORM.
Create session and call the function BDC_INSERT in that PERFORM
STEP9: - Check the syntax
STEP10: - Double click on the PERFORM OPEN_GROUP and call function
BDC_OPEN_GROUP
STEP11: - Double click on the PERFORM CLOSE_GROUP and call function
BDC_CLOSE_GROUP
STEP12: - Write a loop after PERFORM OPEN_GROUP and close it before PERFORM
CLOSE_GROUP
STEP13: - Substitute the hard coded values with work area.
NOTE: - Make sure that to refresh BDCDATA internal table after the loop statement. If you
doesn’t do that first recorded will be get promoted all the time.
SYNTAX: - REFRESH LT_BDCDATA.

WORKING WITH CALL TRANSACTION: -


STEP1: - Download the program from recording and comment the include
STEP2: - Comment performs open & close groups
STEP3: - Declare an ITAB and provide F4 help on the selection-screen and read the file data
into ITAB
STEP4: - Open include BDCRECX1, copy the forms BDC_DYNPRO and BDC_FIELD and
paste it in the call transaction program
STEP5: - Replace BDCDATA with LW_BDCDATA and append it to LT_BDCDATA.
STEP6: - Comment the PERFORM BDC_TRANSACTION, write a PERFORM
STEP7: - Write down the code
Call transaction ‘MM01’ using LT_BDCDATA
MODE ‘A’
UPDATE ‘S’
MESSAGE INTO LT_MSGCOLL.
STEP8: - Keep the loop after open group and end loop it before CLOSE_GROUP
STEP9: - Refresh LT_BDCDATA after the loop statement.
STEP10: - Segregate the PERFORMS based on the screen number and substitute hard coded
values with work area fields.

LOG IN CALL TRANSACTION: - While working with call transaction method we need to
capture the log expectedly. Where as in session method log will be generated automatically.
STEP1: - Declare an internal table with the structure of BDC message call “BDCMSGCOLL”

WHOLE STORY NARRATED BY VAMSI


TYPES : BEGIN OF T_MSGCOLL.
INCLUDES STRUCTURE BDCMSGCOLL.
TYPES : END OF T_MSGCOLL.
TYPES : TT_MSGCOLL TYPE STANDARD TABLE OF T_MSGCOLL.
DATA : LW_MSGCOLL TYPE T_MSGCOLL,
LT_MSGCOLL TYPE TT_MSGCOLL.
STEP2: - Pass the message to call transaction syntax.
FORMAT_MESSAGE is the function module which will write log on the list.

Q. Difference between SESSION and CALL TRANSACTION?


ANS: -
SESSION CALL TRANSACTION
1. Session is 2 steps process, first we need to 1. It’s an online update and data get update
create a session and process it expectedly to immediately on the database.
update the data.

2. Synchronous update is only possible. 2. Synchronous and asynchronous update is


possible.
3. Log generated automatically. 3. Log need to be handled expectedly
4. Sy-subrc will not be update. 4. Sy-subrc can be captured.
5. Large amount of data we can use in session 5. Low & medium data can be process
method through call transaction method.

NOTE: - Whenever a file comes from presentation server using session method we cannot run it
in a background.
GUI_UPLOAD_FM cannot be used in a background mode execution.

PROGRAM1: - (WITH INCLUDE)


report ZVK_BDC_MM01_DEMO
no standard page heading line-size 255.
include bdcrecx1.
TYPES : BEGIN OF T_MAT,
MATNR(18) TYPE C,
MBRSH(1) TYPE C,
MTART(4) TYPE C,
MAKTX(40) TYPE C,
MEINS(3) TYPE C,

END OF T_MAT.
TYPES : TT_MAT TYPE STANDARD TABLE OF T_MAT.
DATA : LW_MAT TYPE T_MAT,
LT_MAT TYPE TT_MAT.

WHOLE STORY NARRATED BY VAMSI


PARAMETERS : p_file type localfile OBLIGATORY.
AT SELECTION-SCREEN on VALUE-REQUEST FOR p_file.
CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME =''
IMPORTING
FILE_NAME = p_file.

start-of-selection.
PERFORM read_file_data.
perform open_group.
loop at lt_mat into lw_mat WHERE matnr ne space.
*-- 1st screen
perform screen_1.
*perform bdc_dynpro using 'SAPLMGMM' '0060'.
*perform bdc_field using 'BDC_CURSOR'
* 'RMMG1-MATNR'.
*perform bdc_field using 'BDC_OKCODE'
* '=AUSW'.
*perform bdc_field using 'RMMG1-MATNR'
* lw_mat-matnr.
*perform bdc_field using 'RMMG1-MBRSH'
* lw_mat-mbrsh.
*perform bdc_field using 'RMMG1-MTART'
* lw_mat-mtart.

*--2nd screen
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(02)'.
perform bdc_field using 'BDC_OKCODE'
'=DEF_SAVE'.
perform bdc_field using 'MSICHTAUSW-KZSEL(01)'
'X'.
perform bdc_field using 'MSICHTAUSW-KZSEL(02)'
'X'.
perform bdc_dynpro using 'SAPLMGMM' '0070'.
perform bdc_field using 'BDC_CURSOR'

WHOLE STORY NARRATED BY VAMSI


'MSICHTAUSW-DYTXT(01)'.
perform bdc_field using 'BDC_OKCODE'
'=ENTR'.

*-- 3rd screen


perform bdc_dynpro using 'SAPLMGMM' '4004'.
perform bdc_field using 'BDC_OKCODE'
'=BU'.
perform bdc_field using 'MAKT-MAKTX'
lw_mat-maktx.
perform bdc_field using 'BDC_CURSOR'
'MARA-MEINS'.
perform bdc_field using 'MARA-MEINS'
lw_mat-meins.

*--end of last screen


perform bdc_transaction using 'MM01'.
ENDLOOP.
perform close_group.
*&---------------------------------------------------------------------*
*& Form read_file_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM read_file_data .
data : l_fnm TYPE string.
l_fnm = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = l_fnm
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = '#'
* HEADER_LENGTH =0
* READ_BY_LINE = 'X'
* DAT_MODE =''
* CODEPAGE =''
* IGNORE_CERR = ABAP_TRUE

WHOLE STORY NARRATED BY VAMSI


* REPLACEMENT = '#'
* CHECK_BOM =''
* VIRUS_SCAN_PROFILE =
* NO_AUTH_CHECK =''
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
DATA_TAB = lt_mat
* EXCEPTIONS
* FILE_OPEN_ERROR =1
* FILE_READ_ERROR =2
* 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. " read_file_data
*&---------------------------------------------------------------------*
*& Form screen_1
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text

WHOLE STORY NARRATED BY VAMSI


*----------------------------------------------------------------------*
FORM screen_1 .
perform bdc_dynpro using 'SAPLMGMM' '0060'.
perform bdc_field using 'BDC_CURSOR'
'RMMG1-MATNR'.
perform bdc_field using 'BDC_OKCODE'
'=AUSW'.
perform bdc_field using 'RMMG1-MATNR'
lw_mat-matnr.
perform bdc_field using 'RMMG1-MBRSH'
lw_mat-mbrsh.
perform bdc_field using 'RMMG1-MTART'
lw_mat-mtart.
ENDFORM.

" screen_1

PROGRAM2: - (WITH OUT INCLUDE)


REPORT ZVK_BDC_SESSION_UPLOAD
NO STANDARD PAGE HEADING LINE-SIZE 255.
*REC-47 M ROH PENCIL EA
*REC-48 M ROH MARKER PC
*REC-49 M ROH BULLET EA
TYPES : BEGIN OF T_MAT,
MATNR(18) TYPE C,
MBRSH(1) TYPE C,
MTART(4) TYPE C,
MAKTX(40) TYPE C,
MEINS(3) TYPE C,
END OF T_MAT.
TYPES : TT_MAT TYPE STANDARD TABLE OF T_MAT.
DATA : LW_MAT TYPE T_MAT,
LT_MAT TYPE TT_MAT.

TYPES : BEGIN OF T_BDCDATA.


INCLUDE STRUCTURE BDCDATA.
TYPES: END OF T_BDCDATA.
TYPES : TT_BDCDATA TYPE STANDARD TABLE OF T_BDCDATA.
DATA : LW_BDCDATA TYPE T_BDCDATA,
LT_BDCDATA TYPE TT_BDCDATA.

WHOLE STORY NARRATED BY VAMSI


PARAMETERS : P_FILE TYPE LOCALFILE OBLIGATORY.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.


CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
IMPORTING
FILE_NAME = P_FILE.

START-OF-SELECTION.
PERFORM READ_FILE_DATA.
PERFORM OPEN_GROUP.
LOOP AT LT_MAT INTO LW_MAT WHERE MATNR NE SPACE.
REFRESH LT_BDCDATA.
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '0060'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'RMMG1-MATNR'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=AUSW'.
PERFORM BDC_FIELD USING 'RMMG1-MATNR'
LW_MAT-MATNR.
PERFORM BDC_FIELD USING 'RMMG1-MBRSH'
LW_MAT-MBRSH.
PERFORM BDC_FIELD USING 'RMMG1-MTART'
LW_MAT-MTART.

PERFORM BDC_DYNPRO USING 'SAPLMGMM' '0070'.


PERFORM BDC_FIELD USING 'BDC_CURSOR'
'MSICHTAUSW-DYTXT(02)'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=DEF_SAVE'.
PERFORM BDC_FIELD USING 'MSICHTAUSW-KZSEL(01)'
'X'.
PERFORM BDC_FIELD USING 'MSICHTAUSW-KZSEL(02)'
'X'.
PERFORM BDC_DYNPRO USING 'SAPLMGMM' '0070'.
PERFORM BDC_FIELD USING 'BDC_CURSOR'

WHOLE STORY NARRATED BY VAMSI


'MSICHTAUSW-DYTXT(01)'.
PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=ENTR'.

PERFORM BDC_DYNPRO USING 'SAPLMGMM' '4004'.


PERFORM BDC_FIELD USING 'BDC_OKCODE'
'=BU'.
PERFORM BDC_FIELD USING 'MAKT-MAKTX'
LW_MAT-MAKTX.
PERFORM BDC_FIELD USING 'BDC_CURSOR'
'MARA-MEINS'.
PERFORM BDC_FIELD USING 'MARA-MEINS'
LW_MAT-MEINS.

* PERFORM BDC_TRANSACTION USING 'MM01'.


PERFORM CREATE_SESSION.
clear lw_mat.
ENDLOOP.
PERFORM CLOSE_GROUP.
*&---------------------------------------------------------------------*
*& Form read_file_data
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM READ_FILE_DATA .
DATA : L_FNM TYPE STRING.
L_FNM = P_FILE.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = L_FNM
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = '#'
* HEADER_LENGTH =0
* READ_BY_LINE = 'X'
* DAT_MODE =''

WHOLE STORY NARRATED BY VAMSI


* CODEPAGE =''
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* CHECK_BOM =''
* VIRUS_SCAN_PROFILE =
* NO_AUTH_CHECK =''
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
DATA_TAB = LT_MAT
* EXCEPTIONS
* FILE_OPEN_ERROR =1
* FILE_READ_ERROR =2
* 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. " read_file_data
*&---------------------------------------------------------------------*
*& Form BDC_DYNPRO
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*

WHOLE STORY NARRATED BY VAMSI


* -->PROGRAM text
* -->DYNPRO text
*----------------------------------------------------------------------*
FORM BDC_DYNPRO USING PROGRAM DYNPRO.
CLEAR LW_BDCDATA.
LW_BDCDATA-PROGRAM = PROGRAM.
LW_BDCDATA-DYNPRO = DYNPRO.
LW_BDCDATA-DYNBEGIN = 'X'.
APPEND LW_BDCDATA TO LT_BDCDATA.
ENDFORM. "BDC_DYNPRO

*&---------------------------------------------------------------------*
*& Form BDC_FIELD
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->FNAM text
* -->FVAL text
*----------------------------------------------------------------------*
FORM BDC_FIELD USING FNAM FVAL.
CLEAR LW_BDCDATA.
LW_BDCDATA-FNAM = FNAM.
LW_BDCDATA-FVAL = FVAL.
APPEND LW_BDCDATA TO LT_BDCDATA.
ENDFORM. "BDC_FIELD
*&---------------------------------------------------------------------*
*& Form CREATE_SESSION
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*

FORM CREATE_SESSION .
CALL FUNCTION 'BDC_INSERT'
EXPORTING
TCODE = 'MM01'
TABLES
DYNPROTAB = LT_BDCDATA

WHOLE STORY NARRATED BY VAMSI


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-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

ENDFORM. " CREATE_SESSION


*&---------------------------------------------------------------------*
*& Form OPEN_GROUP
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM OPEN_GROUP .
CALL FUNCTION 'BDC_OPEN_GROUP'
EXPORTING
GROUP = 'ZVK_MM01_S1'
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
QUEUE_ERROR =7
RUNNING =8
SYSTEM_LOCK_ERROR = 9
USER_INVALID = 10
OTHERS = 11.

WHOLE STORY NARRATED BY VAMSI


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. " OPEN_GROUP


*&---------------------------------------------------------------------*
*& Form CLOSE_GROUP
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CLOSE_GROUP .
CALL FUNCTION 'BDC_CLOSE_GROUP'.
WRITE : / 'Session created Succfully'.

ENDFORM. " CLOSE_GROUP

BACKGROUND SHELUDING OF A JOB PROGRAM: - (SM36)


STEP1: - Click on job wizard
Click Continue
Enter the job name (finance report)
Enter job class (B-MIDDLE PRIROTY)
Target server (SAPLID_LID_00)
Clock on continue
Select radio button ABAP program step
Click on continue
Enter the ABAP program name which you want to run in a background
Select the variant (BSEG_DATA)
Click on continue
Click on radio button immediately or date/time
Click on continue
Click on continue again
Click on complete.
STEP2: - To know the job status click on job selection button
Enter the job (finance report)
User (user)
Enter the ABAP program name
Enter the date also and if you know time enter time also

WHOLE STORY NARRATED BY VAMSI


Press executes.
STEP3: - Select the job by checking on the check box
Click on the spool button
Click on the type icon.

JOB STATUS: - They are 6 types job status, they are


• Shed
• Released
• Ready
• Active
• Finished
• Cancelled (Error)

WHOLE STORY NARRATED BY VAMSI


SAP SCRIPTS
SAP SCRIPTS: - (SE71)
These are used as legal documents and tidily integrated into SAP to perform word
processing tasks.
SAP SCRIPTS are “client dependent” and we can translated into ‘N’ No. of languages.
They are predefined SAP SCRIPTS by sap.
MEDRUCK - Purchase order
RVORDER01 - Sales order
RVDELNOTE - Delivery
RVINVOICE01 - Billing/Invoice
Depending upon the clients requirements we can build custom scripts as well.

TESTING A SAP SCRIPTS: -


STEP1: - Go to SE71
Enter the scripts name as (MEDRUCK)
Language (EN)
Click on display
STEP2: - Utilities → printing test
Enter the output device (LOP1) - dummy printer name
Click on print preview button.

BUSSINESS NEED OF SAP SCRIPTS: -


They are different sap scripts according to business use. Let us see a few examples
• Generating bills or invoices
• Generating purchasing order ( po)
• Generating sales order (so)
• Generating shipping documents
• Employ pay slips
• Employ offer letter
• Chase receipts
• Dunning letters
SAP SCRIPTS SUBOBJECTS: -
Header
Pages
Windows
Page windows
Paragraph formats
Character formats
Documentations

WHOLE STORY NARRATED BY VAMSI


HEADER: - In header they are 2 sections, they are
1. Administrative data
2. Basic settings
Header describes about scripts name, description, status, and language attributes like
original language, keel in language.

BASIC SETTINGS: - Describes about page setup and orientation like portrait, landscape
format. First page and default paragraph.

PAGES: - While creating a page it is necessary to set a next page if there is only page in the
SAP SCRIPTS, same page will be the next page of it.

WINDOWS: - The windows develop for the SAP SCRIPTS are global to the pages of scripts.
They are 4 windows type in scripts
MAIN Main window (continues)
CONST Constant window
VAR Variable window
GRAPH Logo window

MAIN WINDOW: - It is used for continues output


CONSTANT WINDOW: - It is normally use to develop header and footer windows
VARIABLE WINDOW: - It is use to substitute a fixed value (blank) for a given requirement.
GRAPH WINDOW: - It is normally used for logo of the company or digital signature
PAGE WINDOWS: - It represents the window on the page
PRRAGRAPH FORMATS: - These are used to setup a font and alignment and font size.
CHARACTER FORMATS: - It is used to build character format bold, italic.

WHOLE STORY NARRATED BY VAMSI


SAMPLE SCRIPT PRIENT PERVIEW: -
Graphic window Constant window

LOGO CUSTOME INFO

CUSTOMER NO :
NAME :
CITY :
CONTURY :

Thank you for visiting

Main window Constant window

They are 3 function modules to print a sap script. They are


1. Open-form
2. Write-form
3. Close-form

OPEN –FORM: - It opens the form for printing and we need to pass the following parameters.
FORM = SCRIPT
LANGUAGE = EN

CLOSE-FORM: - It closes the current opened form.

WRITE-FORM: - Write form is the one which writes the data onto the window on a sap script,
below are the parameters used to pass for this function module.
ELEMENT = ----------------
WINDOW = WINDOW NAME

WHOLE STORY NARRATED BY VAMSI


CREATING A SCRIPT: -
STEP1: - Go to SE71
Enter the script name (ex: - zcustomer_script)
Language (ex: - EN)
Click on create
Press enter
Enter the description/meaning (ex: - customer information)
Click on save
Click on basic settings
Page format (ex: - DINA4)
Orientation (ex: - portrait format)
First page (ex: - ______)
Default paragraph (ex: - _______)
SREP2: - Pages
Click on pages button
Edit → create element
Enter the page (ex: - page1)
Meaning (ex: - customer info page)
Press enter
Next page (ex: - page1)
Save.
STEP3: - Windows
Click on windows button
By default we are awarded with main window
Go to edit → create element
Window name (ex: - header)
Meaning (ex: - heading window)
Press enter
Window type (ex: - constant)
Save
Edit → create element
Window name (footer)
Meaning (ex: - footer window)
Press enter
Window type (ex: - constant)
Click on save.
STEP4: - Page windows
Click on page window button
Edit → create element
It will list you all the window available in the sap script

WHOLE STORY NARRATED BY VAMSI


Double click on a particular window to generate a page window
Left margin 15 cm Window width 15 cm

Upper margin 15 LN Window height 15 LN


Click on save
Edit → create element
Paragraph format (ex: - ph)
Meaning (ex: - paragraph heading)
Press enter
Alignment (ex: - center)
Click on font button
Family (ex: - HELEVE)
Font size (ex: - 32) pt
Click on bold radio button ‘ON’
Click on save
Edit → create element
Paragraph format (ex: - pf)
Meaning (ex: - paragraph footer)
Alignment (ex: - center)
Family (ex: - TIMES)
Font size (ex: - 10) pt
Click on italic radio button ‘ON’
Edit → create element
Paragraph format (ex: - Pd)
Meaning (ex: - normal data paragraph)
Press enter
Alignment (ex: - left)
Click on font
Family (ex: - COURIER)
Font size (ex: - 12) pt
Click on save
STEP6: - Character formats
Click on character format button
Edit → create element
Character format (ex: - B)
Meaning (ex: - Bold)
Click on font
Family (ex: - courier)
Size (ex: - 12) pt
Click on bold radio button ‘ON’
Click on save.

WHOLE STORY NARRATED BY VAMSI


STEP7: - Page window
Always come back to page windows to code further
STEP8: - Click on header
Click on basis settings
First page (ex: - page1)
Default paragraph (Pd)
Click on page window button
Click on save
Form → activate
Put it back to display
Form → display.
STEP9: - Form painter
Check the check box of graphical form painter
Press enter
Mousse right button create graphic
Name click on F4
Resolution (ex: - 100)
Click on save.
STEP10: - Go to page windows
Double click on the header window
Click on text element button or F9
PH Customer information

Back
STEP11: - Double click on footer window
Press F9
PF Thank you for visiting

Back
STEP12: - Double click on main window
Press F9
PF Customer No : &lw_kna1-kunnr&

Press enter
PF Name : &lw_kna1-name1&

Press enter
Continue for city and land.
Back.
Save and activate.

WHOLE STORY NARRATED BY VAMSI


STEP13: - Driver program
It is mandatory to have a driver program
To pass the values from reports to scripts.

WHOLE STORY NARRATED BY VAMSI


SAMPLE SCRIPT DEVELOPMENT: -

Variable window variable window

Graphic window Constant window

LOGO INVOICE

CUSTOMER NAME : BILL DATE :


CITY : PAYER :
COUNTRY : BILL TYPE :
SALES ORG :

ITEN NO MATERAIL DESCRIPCTION QUANTITY NETVALUE

TOTAL :

AMOUNT IN WORDS:

Thank you for visiting

Main window variable window constant window variable window

WHOLE STORY NARRATED BY VAMSI


DRIVER PROGRAM: -
SREPS: - Declare a parameter to pas the billing document number
Create a work area for customer address (ex: - lw_kna1)
Create a work area for billing header data (ex: - lw_vbrk)
Create work area and itab for billing item data (ex: - lw_vbrp, lt_vbrp)
In the start-of selection write a perform to get the billing header data.

NOTE: - To draw the vertical lines lift the code from “MEDRUCK” in info window.

WORKING WITH STANDARD TEXT (TCODE – SO10): -


It is used to avid hard coding in the script and a standard text can be used in multiple
scripts.
STEP1: - Go to SO10
Text name (ex: - ZNSR_HEADING)
Text id (ex: - ST)
Language (ex: - EN)
Click on create
Write any text you want (ex: - CHASE INVOICE)
Click on save.

CALLING STANDARD TEXT: -


STEP1: - Go to the particular window like header
Click on text element F9
Remove the hard coded name
STEP2: - Insert → text → standard
Text name (ex: - ZNSR_BILL_SCRIPT)
Text id (ex: - ST)
Language (ex: - EN)
Press enter
/: include znsr_heading object text id st language en paragraph ph
Save and active
And put in display mode.

DEBUGGING SAP SCRIPT: -


STEP1: - Go to SE71
Enter the sap script name
Form (EX: - ZNSR_BILL_SCRIPT)
Language (ex: - EN)
Utilities → activate debugger
You will get a message sap script from debugger is activated.

WHOLE STORY NARRATED BY VAMSI


STEP2: - Run your driver program
You will get a dialog1e box named as sap script form debugger
Press enter
Click on print preview
Press F5 to debugger continually
Where ever you find variable or work area fields
Paste it on below boxes to see the run time value.

NOTE: - While debugging the sap script identify your script name, identify the page and
window and constantly monitor event to see the run time values.
Debugger → exit (to form come from debugger)

WHOLE STORY NARRATED BY VAMSI


DRIVER PROGRAM: -
TYPES : BEGIN OF T_VBRK,
VBELN TYPE VBELN_VF,
FKDAT TYPE FKDAT,
KUNRG TYPE KUNRG,
FKART TYPE FKART,
VKORG TYPE VKORG,
END OF T_VBRK.
DATA LW_VBRK TYPE T_VBRK.

WHOLE STORY NARRATED BY VAMSI


TYPES : BEGIN OF T_KNA1,
KUNNR TYPE KUNNR,
NAME1 TYPE NAME1_GP,
ORT01 TYPE ORT01_GP,
LAND1 TYPE LAND1_GP,
END OF T_KNA1.
DATA : LW_KNA1 TYPE T_KNA1.
TYPES : BEGIN OF T_VBRP,
VBELN TYPE VBELN,
POSNR TYPE POSNR_VF,
MATNR TYPE MATNR,
ARKTX TYPE ARKTX,
FKIMG TYPE FKIMG,
NETWR TYPE NETWR,
END OF T_VBRP.
TYPES : TT_VBRP TYPE STANDARD TABLE OF T_VBRP.
DATA : LW_VBRP TYPE T_VBRP,
LT_VBRP TYPE TT_VBRP.
PARAMETERS : P_VBELN TYPE VBRK-VBELN OBLIGATORY.

START-OF-SELECTION.
PERFORM GET_BILL_HEADER_DATA.
PERFORM GET_CUSTEMER_ADDRES.
PERFORM GET_ITEM_DATA.
PERFORM CALL_SCRIPT.
PERFORM WRITE_CUSTOMER_ADDRESS.
PERFORM WRITE_BILLING_INFO.
PERFORM WRITE_ITEM_DATA.
PERFORM CLOSE_SCRIPT.
*&---------------------------------------------------------------------*
*& Form GET_BILL_HEADER_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_BILL_HEADER_DATA .
SELECT SINGLE VBELN FKDAT KUNRG FKART VKORG FROM VBRK
INTO LW_VBRK
WHERE VBELN = P_VBELN.
ENDFORM. " GET_BILL_HEADER_DATA
*&---------------------------------------------------------------------*
*& Form GET_CUSTEMER_ADDRES
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_CUSTEMER_ADDRES .
SELECT SINGLE KUNNR NAME1 ORT01 LAND1 FROM KNA1
INTO LW_KNA1
WHERE KUNNR = LW_VBRK-KUNRG.
ENDFORM. " GET_CUSTEMER_ADDRES
*&---------------------------------------------------------------------*
*& Form GET_ITEM_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text

WHOLE STORY NARRATED BY VAMSI


* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_ITEM_DATA .
SELECT VBELN POSNR MATNR ARKTX FKIMG NETWR FROM VBRP
INTO TABLE LT_VBRP
WHERE VBELN = P_VBELN.
ENDFORM. " GET_ITEM_DATA
*&---------------------------------------------------------------------*
*& Form CALL_SCRIPT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CALL_SCRIPT .
CALL FUNCTION 'OPEN_FORM'
EXPORTING
* APPLICATION = 'TX'
* ARCHIVE_INDEX =
* ARCHIVE_PARAMS =
* DEVICE = 'PRINTER'
* DIALOG = 'X'
FORM = 'ZNSR_SCRIPT'
LANGUAGE = SY-LANGU
* OPTIONS =
* MAIL_SENDER =
* MAIL_RECIPIENT =
* MAIL_APPL_OBJECT =
* RAW_DATA_INTERFACE = '*'
* SPONUMIV =
* IMPORTING
* LANGUAGE =
* NEW_ARCHIVE_PARAMS =
* RESULT =
EXCEPTIONS
CANCELED = 1
DEVICE = 2
FORM = 3
OPTIONS = 4
UNCLOSED = 5
MAIL_OPTIONS = 6
ARCHIVE_ERROR = 7
INVALID_FAX_NUMBER = 8
MORE_PARAMS_NEEDED_IN_BATCH = 9
SPOOL_ERROR = 10
CODEPAGE = 11
OTHERS = 12
.
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. " CALL_SCRIPT


*&---------------------------------------------------------------------*
*& Form CLOSE_SCRIPT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text

WHOLE STORY NARRATED BY VAMSI


* <-- p2 text
*----------------------------------------------------------------------*
FORM CLOSE_SCRIPT .
CALL FUNCTION 'CLOSE_FORM'.
ENDFORM. " CLOSE_SCRIPT
*&---------------------------------------------------------------------*
*& Form WRITE_CUSTOMER_ADDRESS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM WRITE_CUSTOMER_ADDRESS .
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'CUST'
* FUNCTION = 'SET'
* TYPE = 'BODY'
WINDOW = 'TOP1'
* IMPORTING
* PENDING_LINES =
EXCEPTIONS
ELEMENT = 1
FUNCTION = 2
TYPE = 3
UNOPENED = 4
UNSTARTED = 5
WINDOW = 6
BAD_PAGEFORMAT_FOR_PRINT = 7
SPOOL_ERROR = 8
CODEPAGE = 9
OTHERS = 10
.
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. " WRITE_CUSTOMER_ADDRESS


*&---------------------------------------------------------------------*
*& Form WRITE_BILLING_INFO
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM WRITE_BILLING_INFO .
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'BILL'
* FUNCTION = 'SET'
* TYPE = 'BODY'
WINDOW = 'TOP2'
* IMPORTING
* PENDING_LINES =
EXCEPTIONS
ELEMENT = 1
FUNCTION = 2
TYPE = 3

WHOLE STORY NARRATED BY VAMSI


UNOPENED = 4
UNSTARTED = 5
WINDOW = 6
BAD_PAGEFORMAT_FOR_PRINT = 7
SPOOL_ERROR = 8
CODEPAGE = 9
OTHERS = 10
.
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. " WRITE_BILLING_INFO


*&---------------------------------------------------------------------*
*& Form WRITE_ITEM_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM WRITE_ITEM_DATA .
LOOP AT LT_VBRP INTO LW_VBRP.
CALL FUNCTION 'WRITE_FORM'
EXPORTING
ELEMENT = 'ITEM'
* FUNCTION = 'SET'
* TYPE = 'BODY'
WINDOW = 'MAIN'
* IMPORTING
* PENDING_LINES =
EXCEPTIONS
ELEMENT = 1
FUNCTION = 2
TYPE = 3
UNOPENED = 4
UNSTARTED = 5
WINDOW = 6
BAD_PAGEFORMAT_FOR_PRINT = 7
SPOOL_ERROR = 8
CODEPAGE = 9
OTHERS = 10
.
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDLOOP.
ENDFORM. " WRITE_ITEM_DATA

RUNTIME EXECUTION COMMANDS/STATEMENTS IN SAP SCRIPTS: -


1. /: TOP
/: ENDTOP
2. /: BOTTOM
/: ENDBOTTOM

WHOLE STORY NARRATED BY VAMSI


3. /: IF
/: ENDIF
4. /: PROECT
/: ENDPROTECT
Protect/Endprotect is used for page protection. In order to avoid split in the paragraph, that
paragraph need to be inside protect and end protect.
If heir is no sufficient space it will move the data to next page.
EX: - A
/: protect
Include znsr_test
/: endprotect

DEVELOPMENT WORK IN SAP SCRIPTS: -


1. Design and develop standard sap script
2. Modification of a layout (or) modification of driver program.

TRIGGERING SAP SCRIPTS USING OUTPUT TYPES: -


PURCHASE ORDER (ME22N): -
STEP1: - Go to ME22N
Click on other purchase order button
Enter the purchase order number you created
Click on message button
Select the existing output type NEU
Click on delete button.
STEP2: - Enter output type (ex: - NEU)
Medium (ex: - 1(print out))
Language (ex: - EN)
Select the output type
Click on further data button
Dispatch time (ex: - 4 send immediately)
Back
Select the output type again
Click on communication method button
Logic destination (ex: - LP01)
Back
Select output type again
Click on save button
The status should green and processed

OUTPUT TYPE CONFIGURATION: -


It has to be done by the function consultant using “NACE” t-code.

WHOLE STORY NARRATED BY VAMSI


An output type internally connected with application, driver program and sap script and
medium (print out)
APPLICATION OUTPUT TYPE SCRIPT NAME PROGRAM DESCRIPCTION
EF NEU MEDRUCK SAPFM06P PURCHASEORDER
V1 BA00 RVORDER01 RVODER01 SALES ORDER
V2 LD00 RVDELNOTE RLE_DELNOTE DELIVER
V3 RD00 RVINVOICE01 RVADIN01 INVOICE
The above entries are registers in a table “TNAPR”

NACE: -
STEP1: - Copying standard sap scripts
Go to SE71
Utilities → copy from client
Form name = medruck
Source client = 000
Target form = znsr_po
It will copy into ‘N’ No. of languages
Press F8.
STEP2: - Open the zvk_po script
Click on change
Save and activate.
STEP3: - Attaching sap script to the output type
Go to “NACE” transaction
Select EF application
Click on output types button
Click on position button
Output type (ex: - NEU)
Press enter
Select NEU output type
Double click on folder processing routines
Click on change button
Select the medium one printout row
Change the script name (form_znsr_po)
Click on save.

NOTE: - When there is no provision to modify the driver program we need to write an external
subroutine. In order to pass parameters from program to script or vice versa.

SYNTAX: - /: PERFORM <PERFORM NAME> IN PROGRAM <PROGRAMNAME>


/: USING &&
/: USING &&
/: ENDFORM.

WHOLE STORY NARRATED BY VAMSI


NOTE: - We can have 99 main windows in a sap script.

SMART FORMS
WORKING WITH SMART FORMS: - (TCODE - SMARTFORMS)
Smart forms are used as legal documents to perform print related operations.
In today’s modern world smart forms are widely used to generate documents like.
1. Chase invoice
2. Sales invoice
3. Order confirmation
4. Vender check receipts
5. Employ offer letters
6. Pay slips
7. Donning letters
8. Purchase order
9. Packing slips.
Smart forms are user friendly in nature with drag and drop facilities.
Smart forms are wed compatible like HTML, XML, and XSF
Smart forms has 3 major components
Form
Style
Text module

FORM: - Form is used to design the layout of the smart form and we write the driver program
inside as well.
STYLE: - It is used to build paragraph and character formats

TEXT MODULE: - It is similar to standard text in the script and it is the transportable object.

NOTE: - Every smart form does generate a function module has and an interface.
THEY ARE PREDEFINED SMART FORMS IN SAP (Normally they never use predefined
smart forms for our development)
Custom smart forms are highly used in sap.

SMART FORM WINDOW: -


STEP1: - Enter the form name (ex: - ZNSR_CUSTOMER_SF)
Click on create
Smart forms will have 2 components majorly

WHOLE STORY NARRATED BY VAMSI


STEP2: - Form znsr_customer_sf
Global settings
Form attributes
Form interface
Global definitions
Pages and windows
%page1 new page
Main main window

GLOBAL SETTINGS: -
FORM ATTRIBUTES: - It describes about form name and description and page format, output
format

FORM INTERFACE: - It points to function module parameters to which we pass the data.

GLOBAL DEFINATIONS: - It is use to declare, variable, work area, itab, types etc.

PAGES AND WINDOWS: - Every page need to have a next page with page format having a
background picture.

WINDOW TYPES: -
Window type M main window
C copies window
L final window
T secondary window

MAIN WINDOW: - It is used for continuous output text

SECOUNDARY WINDOW: - It is similar to variable window in the sap script it is used to fix
the fixed values.

FINAL WINDOW: - It is the one which is triggered last for the output on the page.

COPIES WINDOW: - It is use for printing related operations.

CREATING A FORM: -
STEP1: - Double click on the form attributes
Enter the smart form description
Save.
STEP2: - Click on output options
Page format (ex: - DINA4)

WHOLE STORY NARRATED BY VAMSI


Style (ex: - system)
Output format (ex: - standard output)
Click on save.
STEP3: - Double click on form interface
Import tab FW_KNA1 TYPE ZNSR_KNA1.
STEP3: - Double click on the page folder
Change the page name (ex: - page1)
Meaning (ex: - customer detail page)
Click on save
Next page = page1
Click on output option tab
Portrait format
Click on background picture tab
Name : /SMB40/LEAF_BACKGROUND
Color bitmap image (BCOL)
Resolution (ex: - 100) PI
Output mode (ex: - print)
Save and activate
Run
Run
LP01→ F8.
STEP5: - Double click on the main window
Window type (ex: - main window)
Click on output options tab
Set the position and size
Come back to general attributes all the time.
STEP6: - Select the page folder
Click on mouse right button → create → window
Window type (ex: - T secondary window)
Save
Create the graphic window
STEP7: - Click on form painter for alignment
Place the window as per your choice
STEP8: - Add the text for all the windows you created
Select window → create → text
Change the text names as per the requirements
Double click on the text
Text (ex: - head_txt)
Meaning (ex: - heading text)
Add the heading in the general attributes like (customer information)

WHOLE STORY NARRATED BY VAMSI


STEP9: - Field list on/off (ctrl+shift+F4)
Click on field list on/off
Select the main window text
And bee in the general attributes
Expand the import interface
Expand FW_KNA1
Drag KUNNR drop at customer
Continue for NAME1, ORT01, LAND1
Click on field list on/off
Save
Check the syntax
Activate it
Press F8
Press F8
Click on FW_KNA1 import structure
Click on
Fill all the details
KUNNR 1390
NAME1 KING
ORT01 HYDERBAD
LAND1 IN
Press enter
Back
F8
LP01 → F8
STEP10: - Double click on a window
Check the check box on output options tab
STEP11: - Developing a driver program

NOTE: - Before you write a driver program and calling it smart form should be activated.
SSF_FUNCTION_MODULE_NAME this will give the name of smart form function module
name.

WHOLE STORY NARRATED BY VAMSI


DESIGN AND DEVELOP SALES ORDER CONFIRMATION FORM: -

Constant window (graphic) constant window variable window

LOGO HEADER

CUSTOMER INFO

FOOTER

Constant window variable window


STEP1: - Create a structure for header and footer.
Go to SE11 → data type → znsr_vbak → create
Vbeln type vbeln

WHOLE STORY NARRATED BY VAMSI


Eroat type kroat

Go to SE11 → data type→ znsr_vbap → create


Vbeln type vbeln
Posnr type posnr
Matnr type matnr
Kwmeng type werks
Create a table type: - SE11 → data type → table type → create
Table type
STEP2: - Go to the form interface
Click on import tab (FW_VBAK TYPE ZNSR_VBAK)
Go to tables tab (FW_VBAP TYPE ZTT_VBAP)
STEP3: - Using template to develop information window
Double click on info window
Create → template
In templates tab →DETAILS
Click on the details button
Click on the draw icon and design as per our requirements
And have a look on the measurements which is displayed on the side window
STEP4: - Select all the cells using control button
Click on select pattern button
Click on display framed pattern
Select the 2nd one on displayed frames
Select the template
→ create → text
Add like that eight texts
Go to appropriate text
Write the data whatever you want to display
In conditions tab line 1
Colum
1
STEP5: - Tables node
Displaying item data
Select the main window
Create → table
Double click on the table node
Change the name (ex: - ft_vbap)
Meaning (ex: - item data)
Click on the details button

WHOLE STORY NARRATED BY VAMSI


Create line type
Item_data divide in to four columns
Table width 16cm
Select appropriate frame as per your requirements
STEP6: - Double click on the table node
Click on data tab
Internal table FT_VBAP INTO FW_VBAP
Go to the global definitions and declare a work area
FW_VBAP TYPE ZNSR_VBAP
STEP7: - Select the main area
Create → table line
It will ask for a line type
Line type (ex: - item_data)
And whole cells will create automatically
Add a text to each cell
STEP8: - Select cell1, text1
Be in the general attributes tab
Click on field list ON/OFF
Expand the global data
Expand the work area FW_VBAP
Drag and drop to the corresponding text
Save and activate.
STEP9: - Test the smart form
Press F8
Press F8
Pass the data to FW_VBAK
Pass the data to FW_VBRP
Press F8 (when get error)
Go to the global definitions
Select currency/quantity tab
FW_VBAP-KWMENG V_QTY QUANTY
In global data tab declare a variable
V_QTY TYPE VBRP-VRKME
WORKING WITH SMART FORMS WITHOUT A DRIVER PROGRAM: -
OBJECTIVE: - Design and develop a smart form having five purchase order headers and
respective items to it having sub-totals and grand-totals.
STEP1: - Go to global definitions
Go to types tab
Types : begin of t_ekko,
Ebeln type ebeln,

WHOLE STORY NARRATED BY VAMSI


Ekorg type ekorg,
Ekgrp type ekgrp,
Lifnr type lifnr,
End of t_ekko.
Types : begin of t_ekpo,
Ebeln type ebeln,
Ebelp type ebelp,
Matnr type matnr,
Menge type menge,
End of t_ekpo.
STEP2: - Go to global data
Declare a data
Lw_ekko type t_ekpo
Lt_ekko type tt_ekpo
Lw_ekpo type t_ekpo
Lt_ekpo type tt_ekpo
V_subtot type ekpo-menge
V_gradtot type ekpo-menge
STEP3: - Program lines
Select the main window
Create → flow logic → program lines
Double click on the program lines
Program lines name (ex: - get_data)
Meaning (ex: - get po data)
Input parameters output parameters
Lw_ekko lt_ekko
Lw_ekpo lt_ekpo
Write the code
Select ebeln ekorg ekgrp lifnr from ekko
Into lw_ekko
Up to 5 rows
Where bukrs = ‘1000’
Ekorg = ‘1000’
Ekgrp = ‘001’
Select ebeln ebelp metnr menge from ekpo
Into lw_ekpo
Where ebeln = lw_ekko-ebeln
Append lw_ekpo to lt_ekpo.
Endselect.
Append lw_ekko to lt_ekpo.

WHOLE STORY NARRATED BY VAMSI


Endselect.
STEP4: - Create a table
Select the program lines
Create → table
Double click on the table node
Table (ex: - lt_ekko)
Meaning (ex: - header data-po)
In the table tab
Click on the details button
Create line types
Header 4 cm 4cm 4cm 4cm
Item 4cm 4cm 4cm 4cm
Total 8cm 8cm
Grand-total 8cm 8cm
Select a frame for box
Click on save
Go to data tab LT_EKKO INTO LW_EKKO

SORT CRITERIA
Field name event on sort B event on sort E
EBELN
Save and activate
STEP5: - Select the main area
Create → table line
It will ask for a line type (header)
Add text to each cell
Open the first cell text
Be in the general attributes tab
Field list On/Off
Expand the global data
Lw_ekko
Drag the fields to corresponding cell text of each
Save and activate
STEP6: - Place the cussor on the row1/table line
Create → flow logic → loop
Double click on the loop node
Loop name (ex: - item_data)
Meaning (ex: - ekpo data)
In loop node
Click on the data tab

WHOLE STORY NARRATED BY VAMSI


LT_EKPO INTO LW_EKPO

FLD NAME COMPARISION VALUE


EBELN LW_EKPO-EBELN
STEP7: - Select the loop node
Create → table line
Line type (ex: - item)
Add the text to cells
Select the cell; be in the text general attributes
Drag and drop the lw_ekpo with corresponding cells of text
STEP8: - Got to the global definitions
Declare a variable for quantity
V_QTY TYPE EKPO-MEINS
Select the currency/quantity fields tab
LW_EKPO-MENGE V_QTY QUNTITY
Save and activate.
STEP9: - Select sort end
Create → table line
Line type → total
Add the text to each cell
In first cell text, write subtotal in it
In the 2nd cell text
Drag and drop v_subtot
Save and activate
STEP10: - Calculating the subtotal
Double click on the loop node
Click on calculactions tab
Operation = sum
Field name = lw_ekpo-menge
Target field name = v_subtot
Time = A after loop
Save and activate
Initialization =
WORKING WITH STYLE: -
Styles are used for creating paragraph formats, characters formats. There is a default style
given by sap known as “SYSTEM”.
STEP1: - Select radio button style (ex: - znsr_po_style)
Click on create
Enter the description (po style)
Click on Save

WHOLE STORY NARRATED BY VAMSI


In the standard settings tab
Font = courier
Font size = 12
Save.
STEP2: - Double click on the paragraph format folder
Click on create button
Paragraph format PH
Description (ex: - heading para)
Aliment (ex: - center)
Click on the font tab
Font family (ex: - helve)
Font size (ex: - 32)
Color (ex: - red)
Save
STEP3: - Double click on the characters formats
Click on create
Character format (ex: - B)
Description (ex: - Bold)
Click on font tab
Font style (ex: - Bold)
CREATING BAR CODES: -
Using the character formats we can create the bar codes
Click on character formats
Character format (ex: - BC)
Description (ex: - Bar code)
Bar code
Name (ex: - AUFNR)
Width 4.80cm
Height 1.30cm
Save
STEP4: - Double click on the header data folder
Set the standard paragraph (ex: - pd)
Save activate.
STEP5: - Attaching a style to the smart form
In the form attributes of the smart form
In the output options tab
Style = (ex: - znsr_po_style)
Save and activate.

WORKING WITH TEXT MODULES: -


STEP1: - Text module is similar to standard text in the sap script

WHOLE STORY NARRATED BY VAMSI


Click on radio button text module (ex: - znsr_heading_tm)
Click on create
Meaning (ex: - heading text)
Go to the management tab
Style name (ex: - znsr_po_style) and it is optional
Save.

STEP2: - Click on the text tab


Write the text (ex: - order summary)
Select the text
And set the paragraph format (ex: - ph)
STEP3: - Call the module in the smart form
Open the smart form
Open header text
In the general attributes tab
Type (ex: - M text module)
Name (ex: - znsr_header_tm)
Language (ex: - En)
No errors if not exits
Always copy style from text module
Click on copy button
NOTE: - We can call standard text in to the smart form as well in place of text module. In text
node → general attributes.
Type (ex: - I include text)
Text name (ex: - znsr_heading)
Text object (ex: - text)
Text id (ex: - ST)
Language (ex: - En)
No errors if not exits
Std paragraph (ex: - ph)

DOWNLOADING SMART FORM IN AN XML FORMATS: -


STEP1: - Go to smart form
Utilities → download form
Enter the form name to download form
Form (ex: - znsr_po_sf)
Press enter
Click on save.

CREATING PDF SMART FORM: -

WHOLE STORY NARRATED BY VAMSI


STEP1: - Run the driver program
In the print dialoug box
Check the check box on new spool request
Click on print button
STEP2: - Go to SP01 t-code
Enter the user id
Create ted by (ex: - user7)
Date created (ex: - 23.08.2011)
Press F8
Check the check box
10917
Click on display button
STEP3: - Open SE38 editor
Enter the program name (ex: - RSTXPDF T4)
Run (F8)
Spool request (10917)
Download pdf file
Pdf file name C:\SO.PDF
Press F8.

COMMAND: -
It is used as a new page break
Double click on the command
Go to the general attributes tab
Go to new page % PAGE

Q. Design and develop a smart form having a driver program to display one purchase order
details in a page
ANS: -
Alternatives: - Go to main area
In the row1 cell1 text1
Select the ce11
Create → flow logic → alternatives
Cell1 should not have any text
Select true add a text
Select false add a text
Alternative will allow the developer to print true or flase
In true text box
Go to general attributes
Place the &lw_ekkoebeln&
Click on conditions tab

WHOLE STORY NARRATED BY VAMSI


Lw_ekko-ebeln ‘550000000000’
Go to false text box
Go to the conditions tab
Lw_ekko-ebeln ‘550000000000’
Go to the conditions
Go to the general attributes tab
Lw_ekko_ebeln ‘550000000000’

PAGE PROTECTION: -
Page protection can be done using folder
• Paragraph
• Text node
• Folder
• Line type
DIFFERENCE BETWEEN SAP SCRIPTS AND SMART FORMS: -

SAP SCRIPTS SMART FORMS


A script does not generate a function module. Smart form does generate a function module.
Scripts are client dependent. Smart forms are client independent.
Main window is mandatory in scripts. Main window is optional.
It is mandatory to have a driver program in scripts. We can have a smart form without having a driver
program.
Multiple page formats are not allowed. Multiple page formats are allowed like
portrait/landscape.
Scripts are not wed compatible. Smarts forms are web compatible we can generate
in HTML, XML, and XSF.

WHOLE STORY NARRATED BY VAMSI


MODULE POOL
MODULE POOL PROGRAMING: -
Dialog means screen programming
Dialog programming is used to build custom transaction in sap as per the client’s
requirement
A transaction is nothing but sequence of connected dialog steps
When ever a transaction is maintained data will be uploaded in the database
Maintains means it can be create change, delete or display
DIALOG PROGRAM COMPONENTS: -
1. Screen
2. Gui status
3. Flow logic
4. T-code
By using “SE80” t-code we can build a custom transaction.
A module program is not an executable program it is a module program and program type is
‘M’.
Every module pool program name should start with “SAPMZ”.
EVENTS IN MODULE POOL: -
1. Process before output (PBO)
2. Process after input (PAI)
3. Process on value request (POV)
4. Process on help request (POM)
POB: - This event will trigger before we see the output and it is normally used for initialization
the screen attributes like enable/disable and clearing, refreshing work area and itab. GUI status
will be attached in PBO.
PAI: - This event will trigger when the user performs an action on the screen like inputting the
data, clicking a button, checking a check box, or selecting a radio button etc.
POV: - This event is used to generate input help like F4 help
POH: - This event is used to generate F1 help
FLOW LOGIC: - In the dialog programming module procedure calls will be identified only.
STEP1: - Go to SE80

WHOLE STORY NARRATED BY VAMSI


Select program
Enter the program name (SAPMZNSR_CUSTOMER)
Press enter
Click on yes
Press enter
Press enter
Change the program title (ex: - customer information)
Press enter
Click on local object
You are awarded by a main program, folder for includes
Top include: - It is basically meant for declare a global variables, work area, itsb’s etc.
Select the top include, mouse right button → activate.
STEP2: - Select the main program
Mouse right button → create → screen
Enter the screen number (ex: - 1111)
Press enter
Enter the short description for the screen (ex: - customer information)
Screen type (Normal)
Click on save
Click on the layout button to design the screen as per your requirement.
Take a text field just place it on screen and drag it
Double click on it to set the attributes.
Name = LB1
Text = Customer information
Close it
Save the screen
Close the window.
STEP3: - GUI status
Select the main program
Create → GUI status
Status = Customer/ST-2222
Short text = Customer status
Press enter
Expand the function keys
Set back, exit, cancel
Double click on the back
Set the function type = E
Set for reaming two also
Save and activate
STEP4: - GUI title

WHOLE STORY NARRATED BY VAMSI


Select the main program
Create → gui title
Title code (ex: - TT_2222)
Press enter
Save and activate.
STEP5: - Expand the screen folder
Double click on the screen number
Click on flow logic tab
In the PBO uncomment the module status_2222
Double click on the module name
Press yes
Select o01 include
Press enter
Press enter
Go inside the module
Uncomment the PF-status and title bar
Replace ‘xxxxxx’ with PF-status = ‘ST_2222’
Title bar = ‘TT_2222’
Click on save
Put it in display
Activate.
STEP6: - Go to screen flow logic again
In PAI write a module (ex: - module quit at exit-command)
Double click on the module quit
Press yes
Select I01 include
Press enter
Press enter
Click on save
Module quit input.
Case sy-ucomm.
When ‘BACK’ or ‘EXIT’ or ‘CANCLE’
Leave to screen 0.
Endcase.
Endmodule.
Save and put in display
Activate.
STEP7: - Create a transaction
Select the main program
Create → transaction

WHOLE STORY NARRATED BY VAMSI


Transaction code (ex: - ZMP02)
Short text (ex: - customer info)
Select first radio button.
Press enter
Program name = SAPMZNSR_CUSTOMER
Screen number = 2222
Check the check boxes
Save
STEP8: - Select the main program
Put it in display mode
Activate
Press enter.
STEP9: - Test the program trancation
Open a session
Enter the t-code and see it and test.
They are 3 ways to develop a module pool using
1. Global variables
2. Work area/itab
3. Database tables (data dictionary references)
I. DEVELOPING MODULE POOL PROGRAM USING GLOBAL VARIABLES
STEP1: - Go to the top include
Declare 3 global variables
Click on save
Put it in display
And activate.
STEP2: - Go to the screen layout
Deign the screen
Click on dictionary/program window (F6)
Table/field name get from program
Click on get from program button
Select the field
Press enter
Enter customer details

CUSTOMER INFORMATION

CUSTOMER
NAME
COUNTRY

DISPLAY
WHOLE STORY NARRATED BY VAMSI
PUSH BUTTON ATTRIBUTES: -
`NAME – PB1
TEXT – DISPLAY
ICON NAME – ICON_DISPLAY
TOOLTIP – DISPLAY
FCTCODE – DISP
STEP2: - Go to the screen flow logic
In the PAI write a module (ex: - module display_data)
Double click on the display_data
Generate the module
Click on yes
Select I01 include
Press enter
Press yes
Write the following code below
Case sy-ucomm.
When ‘DISPLAY’.
Select single kunnr name1 land1 from kna1
Into (v_kunnr, v_name1, v_land1)
Where kunnr = v+kunnr.
Endcase.
Activate the main program.
II. DEVELOPING A MODULE POOL PROGRAM USING WORK AREA: -
STEP1: - Go to the top include
Declare a work area
Types : begin of t_mara,
Matnr type matnr,
Mbrsh type mbrsh,
Mtart type mtart,
End of t_mara.
Data : lw_mara type t_mara.
Save and activate.

WHOLE STORY NARRATED BY VAMSI


STEP2: - Go to screen layout
Press F6
Get from program,
Select 3 fields

Material master

MATERIAL
IND SEE
MST TYPE

VIEW

STEP3: - Go to screen flow logic


In PAI uncomment the module user-command 1111.
Double click on the user-command module
Click on yes
Select the I01 include
Press enter
Write following code
Case sy-ucomm.
When ‘VIEW’.
Select single matnr mbrsh mtart from mara
Into lw_mara
Where matnr = lw_mara-matnr
Endcase.
Save and activate
STEP4: - Activate the main program
STEP5: - Test the program run the t-code
Write a perform inside a module
Double click on the perform name (ex: - perform conversertion)
Click on yes
Select FO1 include
Press enter
Click on yes

WHOLE STORY NARRATED BY VAMSI


Click on pattern (ex: - call function-(conversation_exit_alpha_input))
Input – lw_mara-matnr
Output – lw_mara-matnr
Click on save
Press preety printer
STEP6: - Activate the main program
STEP7: - Run the t-code.

III. DEVELOPING A MODULE POOL PROGRAM USONG DATABASE TABLES: -


STEP1: - Go to the top include
Declare a table
Tables : lfa1.
Click on Save activate.
STEP2: - Go to screen layout
Press F6
Enter the table name (ex: - LFA1)
Click on get from dictionary
Select the fields.

VENDER
NAME
CITY

DISPLAY

Save and close.


STEP3: - Go to screen flow logic
Go to PAI
Uncomment module user-command
Double click on the user-command module
Click on yes
Select the PAI01 include
Press enter
Click on yes
Write the following code
Case sy-ucomm.
When ‘DISP’.
Select single lifnr name1 ort01 from lfa1

WHOLE STORY NARRATED BY VAMSI


Into (lfa1-lifnr, lfa1-name1, lfa1-ort01)
Where lifnr = lfa1-lifnr.
Endcase.
Save and activate.
STEP4: - Activate the main program.
SEARCH HELP: - It will provide F4 help for the input/output field. In order to find out search
help for the given object got to SE11. Double click on the data element of the field in the further
characteristics tab search help
NAME = C_KUNNR.
CONVERSATION EXIT: -
It can be found in the domain of the field
Domain = kunnr
Convers-routine = alpha
Get the conversation routine
Go to the screen painter
Select the field attributes
Convr.exit = alpha
MAKING A FIELD REQUIRED/OBLIGOTARY: -
Double click on the customer field
In the program tab
Input = required
Screen fields can be set had output only, input field, output field.
INSERT: -
SYNTAX: - INSERET INTO <ZTABLE> VALUES <WORK AREA>.
EX: - Insert into znsr_stud values lw_stud.
MODIFY: -
SYNTAX: - MODIFY <ZTABLE> FROM <WORK AREA>.
DELETE: -
SYNTAX: - DELETE <ZTABLE> FROM R TABLE <ITAB>.
WORKING WITH SUB-SCREEN: -
Sub-screen can be placed on the main screen using a screen area.
SYNTAX: - In main screen.
In PBO
CALL SUBSCREEN <SRC AREA> INCLUDING <PROG NAME> <SRC NO>.
In PAI
CALL SUBSCREEN <SCR AREA>.
STEP1: - Go to top include
Declare a customer variable
Declare a work area for customer
Data : v_kunnr type kunnr

WHOLE STORY NARRATED BY VAMSI


Types : begin of t_kna1,
Kunnr type kunnr,
Name1 type name1_gp,
Land1 type land1_gp,
End of t_kna1.
Data : lw_kna1 type t_kna1.
STEP2: - Go to screen layout
Press F6
Click on get from program
Select v_kunnr
STEP3: - Screen area of a sub screen
Name the sub screen (ex: - sa1)

CUSTOMER
DISPLAY

STEP4: - Select the screen folder


Mouse right button → create
Enter screen number 2222
Press enter
Enter the short description (ex: - customer details)
Screen type ( sub screen)
Click on save
Go to the layout
Press F6
Pull up all 3 fields and label them

CUSTOMER
NAME
COUNTRY

Save and activate

WHOLE STORY NARRATED BY VAMSI


STEP5: - Select the main screen (1111)
Go to the flow logic
In PBO
Call subscreen sa1 including sy-repid ‘0111’
In PAI
Call subscreen sa1
Save and activate main program
STEP6: - Go to main screen PAI
Double click on the user command
Write the following code
Case sy-ucomm
When ‘DISP’.
Select single kunnr name1 land1 from kna1
Into lw_kna1
Where kunnr = v_kunnr.
Endcase.
STEP7: - Go to the subscreen
In the screen flow logic
In PBO
Create a module (ex: - module display_data)
Generate the module by double clicking on it
Kna1-kunnr = lw_kna1-kunnr.
Kna1-name1 = lw_kna1-kunnr.
Kna1-land1 = lw_kna1-land1.
Save and activate.
PROGRAM: -
STEP1: - Go to top include
Tables : kna1, knb1, knc1.
Data : v_kunnr type kunnr.
Type : begin of t_kna1,
Kunnr type kunnr,
Name1 type name1_gp,
Land1 type land1_gp,
End of t_kna1.
Types : begin of t_knb1,
Kunnr type kunnr,
Bukrs type bukrs,
Akent type akent,
End of knb1.
Types : begin of t_knc1,

WHOLE STORY NARRATED BY VAMSI


Kunnr type kunnr,
Bukrs type bukrs,
Gjahr type gjahr,
End of t_knc1.
Data : lw_kna1 type t_kna1,
Lw_knb1 type t_knb1,
Lw_knc1 type t_knc1.
Data : v_scrno(4) type c,
Rb1 type c,
Rb2 type c,
Rb3 type c.
Go to layout
Press F6
Select v_kunnr
Place 3 radio buttons
Select all
Edit → grouping → radio button group → define
Click on save
Place a screen area

CUSTOMER DISPLAY

KNA1 KNB1 KNC1

STEP2: - Design 3 sub screens using work area/dictionary/refrences


Create sub screen for kna1 – 0444
CUSTOMER
NAME
COUNTRY

WHOLE STORY NARRATED BY VAMSI


Save and close
Create sub screen for knb1 - 0555
CUSTOMER
COMPANY CODE
RECON ACCOUNT

Save and close

Create sub screen foe knc1 – 0666


CUSTOMER
COMPANY CODE
FISCAL YEAR

Save and close


Go to main screen
In PBO
Call subscreen sa1 including sy-repid ‘1111’.
In PAI
Call subscreen sa1.
Go to PAI module user-command
Generate the module by double clicking on it
Write the following code
Case sy-ucomm.
When ‘DISP’.
If RB1 = ‘X’.
V_scrno = ‘0444’.
Select single kunnr name1 land1 from kna1
Into lw_kna1
Where kunnr = v_kunnr.
V_scrno = ‘0555’.
Select single kunnr bukrs akont from knb1
Into lw_knb1
Where kunnr = v_kunnr.
V_scrno = ‘0666’.
Select single kunnr bukrs gjahr from knc1
Into lw_knc1
Where kunnr = v_kunnr.
Go to the subscreen – 0444

WHOLE STORY NARRATED BY VAMSI


In PBO
Create module display-0444.
Generate the module by double clicking on it
Write the following code in it
Kna1-kunnr = lw_kna1-kunnr.
Kna1-name1 = lw_kna1-name1.
Kna1-land1 = lw_kna1-land1.
Go to subscreen-0555
In PBO
Create module display-0555.
Generate the module by double clicking on it
Write the following code
Knb1-kunnr = lw_knb1-kunnr.
Knb1-bukrs = lw_knb1-bukrs.
Knb1-akont = lw_knb1-akont.
Go to subscreen-0666.
In PBO
Create the module display-0666.
Generate the module by double clicking on it
Write the following code in it
Knc1-kunnr = lw_knc1-kunnr.
Knc1-bukrs = lw_knc1-bukrs.
Knc1-gjahr = lw_knc1-gjahr.
CREATE A LIST BOX: -
STEP1: - Go to the top include
Write the following code
Data : v_kunnr type kunnr.
Save and activate.
STEP2: - Screen layout
Go to screen layout
Press F6
Click on get form program
Select v_kunnr
Double click on v_kunnr field
Droupdown = listbox with key
Save and activate.
STEP3: - Go to screen flow logic in PBO
Create a Module populate_listbox.
Generate the module by double clicking on it
Write the following code in it

WHOLE STORY NARRATED BY VAMSI


Type-pools : VRM.
Data : lt_values type vrm_values,
Lw_values type vrm_value.
If v_flg ne ‘x’.
Select kunnr name1 from kna1
Into table lt_kna1
Up to 5 rows.
Loop at lt_kna1 into lw_kna1.
Move lw_kna1-kunnr to lw_values-key.
Lw_values-text = lw_kna1-name1.
Append lw_values to lt_values.
Endloop.
Call function ‘VRM_SET_VALUES’.
ID : ‘V_KUNNR’
VALUES : LT_VALUES
V_flg = ‘x’.
Endif.
WORKING WITH TABLE CONTROL (TC): -
It is used as a multi record block in sap. Table control is normally used to display itab
data.
Table control is build upon rows and columns.
They are two ways to work with table control.
• Table control with wizard
• Table control wizard
I. WORKING WITH TABLE CONTROL WIZARD: -
STEP1: - Go to screen layout
Place the table control with wizard control on the screen
Click on continue
Name of table control (ex: - tc_2222)
Click on continue
Select radio button dictionary table (ex: - vbap)
Click on continue
Select the fields you want to display on table control
Vbeln
Posnr
Matnr
Click on continue
Select radio button input control
Click on continue
Check the check box scroll

WHOLE STORY NARRATED BY VAMSI


Click on continue
It will promote/generate the includes
Click on continue
Click on complete
Save and close the screen

SINGLE FIELD INPUT CHECK: -


STEP1: - Go to the top include
Declare variables
Data : T1(10) type c,
T2(10) type c,
T3(10) type c.
Save and activate.
STEP2: - Go to screen layout
Press F6
Get from program
Select 3 variables

HIT ME

Save and close.


STEP3: - Go to PAI in the module user-command
Write the following code in it
Case sy-ucomm.
When ‘HIT’.
If t1 is initial.
Meassage ‘t1 can not be empty’ type ‘E’.
Elseif t2 is initial.
Message ‘t2 can be empty’ type ‘E’.

WHOLE STORY NARRATED BY VAMSI


Elseif t3 is initial.
Message ‘t3 can not be empty’ type ‘E’.
Endif.
SYNTAX: - FIELD : <SCR FLD NAME> MODULE <MODULE NAME>.
Go to screen floe logic
In PAI
Field : T1 module check_t1,
T2 module check_t2,
T3 module check_t3.
Generate 3 modules by double clicking on it
In T1 module
Case sy-ucomm.
When ‘HIT’.
If T1 is initial.
Message ‘t1 can not be empty’ type ‘E’.
Endif.
Write this code for remaining two t2 and t3 modules also.
CHAIN AND ENDCHAIN: -
SYNTAX: - CHAIN.
FIELD : FLD1, FLD2.
MODULE <MOD NAME> ON CHAIN-REQUEST
ENDCHAIN.
Chain……..endchain is used for screen input validations it is similar to at selection-screen event.
In order to avoid disabling the screen fields we need to put the fields under chain…….endchain
in PAI.
STEP1: - Got o screen layout
Press F6
Get from program
Select 3 variables

HIT ME

Save and close


STEP3: - Go to screen flow logic

WHOLE STORY NARRATED BY VAMSI


In PAI
Chain.
Field : t1, t2, t3.
Module check_input on chain-request.
Endchain.
Double click on the module name
Write the following code in it
Case sy-ucomm.
When ‘HIT’.
If t1.
Message ‘enter data her’ type ‘E’.
Elseif t2.
Message ‘enter data her’ type ‘E’.
Elseif t3.
Message ‘enter data her’ type ‘E’.
Endif.
Endcase.
Save and activate.
STEP4: - Activate the main program.
ON CHAIN-REQUEST: - It will trigger if at least one of the field is input in the
chain……endchain.
STEP1: - G o to the top include declare the table control
Tables : ekko.
Controls : tc_2222 type tableview usong screen 2222.
Declare the itab
Types : begin of t_ekpo,
Ebeln type ebeln,
Ebelp type ebelp,
Matnr type matnr,
Menge type bstmg,
End of t_ekpo.
Types : tt_ekpo type standard table of t_ekpo.
Data : lw_ekpo type t_ekpo,
Lt_ekpo type tt_ekpo.
Save and activate.
STEP2: - Go to screen layout
Press F6
Enter table name ekko
Hit the button get from dictionary
Select ekko ebeln fields

WHOLE STORY NARRATED BY VAMSI


Press enter
Take a table control place it on the screen.

PURCHASE DOC DETAILS

Select the table control again


Press F6
Hit the button egt from profram
Scroll down
Select lw_ekpo ebeln
Place it as a first Colum in the table control and continue with the rest of the fields
Place the text fields for each Colum and label them.

PURCHASE DOC DETAILS

PO NUM ITEM NO MATERAIL QUANTITY

WHOLE STORY NARRATED BY VAMSI


Save and close.
Try to activate the screen it will throw an error
That we need to do loop in PBO & PAI
STEP3: - Go to PBO
Write the loop …… endloop using table control.
SYNTAX PBO: - LOOP AT <ITAB> INTO <WA> WITH CONTROL <TC_NAME>
CUSSOR <TC_NAME> - CURRENT_LINE.

SYNTAX PAI: - LOOP AT <ITAB>.


CHAIN.
FIELD : F1, F2, F3.
MODULE <MODULE NAME> ON CHAIN-REQUEST.

Loop at lt_ekpo into lw_ekpo


With control tc_2222
Cursor tc_2222-current_line.
Endloop.
Loop at lt_ekpo.
Chain.
Field : lw_ekpo-ebeln, lw_ekpo-ebelp, lw_ekpo-matnr, lw_ekpo-menge.
Module modify_data on chain-request.
Endchain.
Endloop.
STEP4: - Go to PAI
Uncomment the module user_command
Double click on it
Generate the module
Write the following code in it
Case sy-ucomm.
When ‘DETL’.
Select ebeln ebelp matnr menge from ekpo
Into table lt_ekpo
Where ebeln = ekko-ebeln.
Endcase.
Table control properties: -
Current_line
Top_line
Lines

WHOLE STORY NARRATED BY VAMSI


Cols
Sy-loop: - No. of visible rows in a page.
Current_line: - Cursor blinking location in the table control is know as current_line.
Lines: - No. of rows in the table clntrol
Top_line: - It is firt row of the each page.
STEP5: - Attaching a scroll
Go to PBO
Create a module get_scroll
Generate the module by double click on it
Write the following code in it
Data : v_line type i.
Describe table lt_ekpo lines v_line.
Tc_2222-lines = v_lin + 100.
STEP6: - Go to PAI
In the module modify_data
Inside chain and endchain
Double click on it
Modify lt_ekpo
From lw_ekpo
Index tc_2222-current_line.
Append lw_ekpo to lt_ekpo.
WORKING WITH TABSTRIP (TS): -
It is used as a multi screen block in sap we can call ‘n’ No. of subscreens on to the
tabstrip.
TA COMPONENTS: -
1. Push button
2. Subscreen
3. Subscreen area
ATTRIBUTES OF TS: -
NAME : TS
ACTIVETAB : FUNCTION CODE
They are two ways to work with tabstrip
1. With wizard
2. Without wizard
I. WORKING WITH TABSTRIP WIZARD: -
STEPS: - Go to screen layout
Place the tabstrip control with wizard
Click on continue
Enter tbstrip name ts_9999
Click on continue

WHOLE STORY NARRATED BY VAMSI


Enter the tab names
Customer
Material
Vender
Click on continue
Click on continue
System will propose the include accordingly
Click on continue
Click on complete
Save and close
Save and activate.
DECLARING THE TABSTRIP: -
CONTROLS : <TS_NBAME> TYPE TABSTRIP.
II. WORKING WITH TABSTRIP WITHOUT WIZARD: -
STEP1: - Go to the top include declare a tbstrip
Controls : ts_2222 type tabstrip.
Save and activate
STEP2: - Go to screen layput
Place the normal tabstrip control
Double click on the tablestrip control
Name = ts_2222
Double click on the tab1
Name = pb1
Text = customer
Fcode = cust
Double click on the tab2
Name = pb2
Text = material
Fcode = matr
Drag the push buton place it on the tabstrip to add a tab
Double lick on it
Name =pb3
Text = vender
Fcode = vend
Select the customer tab
Place the subscreen area
Double clck on the subscreen area
Name = sa1
Keep one more subscreen for maerail
Name it as sa2

WHOLE STORY NARRATED BY VAMSI


Place one more subscreen area for vender tab
Name it as sa3.
Save and close.
STEP3: - Create a subscreen 0333, 0444, 0555
Select the screen → create
Enter the short descripction customer
Subscreen
Click on layout
Press F6
Enter table name = kna
Click on get from dictionary
Select kunnr, land1, name1
Do this for remaining screens also
For 0444 select mara table
For 0555 select lfa1 table
STEP4: - Go to main screen flow logic
Call the subscreeens in PBO and PAI
Save and activate hole project.
STEP5: - Go to main screen flow logic PAI
Uncomment the module user_command.
Generate the module by double clicking on it
Write the following code in it
Case sy-ucomm.
When ‘CUST’.
Ts_2222-activeta = ‘CUST’.
When ‘MATR’.
T_2222-activetab = ‘MATR’.
When ‘VEND’.
Ts_2222-activetab = ‘VEND’.
Endcase.
Save and activate.
WORKING WITH POV: - (PROCESS ON VALUE REQUEST)
It is used to generate F4 help for the screen field. By using
‘F4IF_INT_TABLE_VALUE_REQUEST’ function module is used to generate F4 help for a
given screen field.
STEP1: - Go to top include
Declare a variable
Data : v_kunnr type kunnr.
Save and activate.
STEP2: - Go to screen flow logic

WHOLE STORY NARRATED BY VAMSI


Write a new event
Process on value-request
Field : v_kunnr module get_F4.
Go to layout of screen
Press F6
Get from program
Select v_kunnr field

CUSTOMER
Double click on the f4 module
To generate the module……endmodule
Write the following code
Capture the customer entries in the itab
Pass it to function module
Data : begin of lt_kna1 occurs 0,
Kunnr type kunnr,
End of lt_kna1.
Select kunnr from kna1 into table lt_kna1
Up to 10 rows.
Call the function ‘F4IF_INT_TABLE_VALUE_REQUEST’.
RETFIELD = ‘V_KUNNR’
DYNPPROG = ‘SAPMZNSR_CUSTOMER’
DYNPNR = ‘1111’
DYNPROFIELD = ‘V_KUNNR’.
VALUE_ORG = ‘S’
VALUE_TAB = LT_KNA1
SREEN VALIDATIONS: -
STEP1: - Go to top include
Declare a variable
Data : T1(16) type c,
T2(16) type c,
T3(16) type c.
STEP2: - Go to screen flow logic
In PBO
Create a module
Module set_screen_arttributes
Generate a module by double clicking on it
Write the following code in it
Loop t screen.
If screen-group1 = ‘GP1’.

WHOLE STORY NARRATED BY VAMSI


Case sy-ucomm.
When ‘DISPLAY’.
Screen-input = ‘0’.
When ‘CHANGE’.
Screen-input = ‘1’.
Endcase.
Modify screen.
Endif.
Endloop.
STEP3: - before doing step2 and step1
Go to screen layout
Take 3 input/out fields

In first box name = T1


Group = GP1
In 2 and 3rd box name = T2, T3
nd

Group = GP1, GP1


STEP4: - Go to GUI status
In application toolbar
Create display and create buttons
Save and activate.

WHOLE STORY NARRATED BY VAMSI


EXITS
EXITS: - (ENHANCEMENT)
Enhancement will trigger on standard transactions.
Enhancements are used for enhancing standard transactions without tampering the current
functionality of the standard transaction.
They are two types of enhancement
1. Customer exits
2. User exits.
WORKING WITH CUSTOMER EXITS: -
They are four types of customer exits available.
1. Function exit
2. Menu exit
3. Screen exit
4. Field exit
SMOD: - (SAP ENHANCEMENT)
By using SMOD we can find the exits for a given transaction.
SMOD is enhancement repository for master data and transactional data transaction.
TABLES FOR ENHANCEMENT/EXITS: - (SEARCH MOD*)
STEPS: - Go to SE11
Database table name (ex: - MOD*)
Press F4.
You will get the list of tables for enhancement.
Ex: - MODSAP - Sap enhancement
MODACT - Modifications
SEARCHIG FOR AN EXIT FOR A GIVEN TRANSACTION: -
STEP1: - Go to SMOD
Press F4
Package = -------
STEP2: - Package identification for a transaction
Go to the standard transaction
System → status
Double click on the program
Go to → attributes
Package = VA
STEP3: - Go to SMOD again
Press F4
Package = VA
Press enter

WHOLE STORY NARRATED BY VAMSI


CMOD: - (Project MGMT)
It is used for building a project for enhancement and abap coding will done her.
STEPS FOR CODING EXITS: -
i. Search for an exit for a t-code
ii. Triggering the exit using the break point
iii. Test the standard transaction
STEP1: - Go to CMOD
Enter project name (ex: - znsr_sp)
Click on create
Enter the short text (ex: - predefined sp)
Click on save
STEP2: - Click on enhancement assignment button
Search for an exit
Press F4
Click on information system button
Enter the package
Press enter
Select V45A0002
Click on save
STEP3: - Click on the components button
Click on change mode
Double click on the function module
Double click on the include
Put a break point (ex: - break user7)
Save and activate
Back
Activate
Back
Activate
It turns to green color
Back
Activate whole project
STEP4: - Test the transaction VA01
PRACTICE EXCISES ON EXITS: -
OBJECTIVE: -
• If customer first name and last name is same through an error message (package is VS)
• If a customer is taxed then raise an error message that customer cannot be taxed (fields
KNV1-TAXKD).
• If two vendor addresses are similar raise an error message duplicate address by company
below Fields Street, country, postal code and post box.

WHOLE STORY NARRATED BY VAMSI


• Replace the 1st 3 characters of po number with NSR (package is ME).
CREATION OF PRODUCTION ORDER (TCODE – CO01): -
TABLES – AFKO, AFPO
Order number – 100004200
STEP5: - Go to co01
Material = 100-100
Production plant = 1000
Planning plant = 1000
Order type = ID01
Press enter
Total qty = 10
Finish date = 14.10.2011
Start date = 10.10.2011
Click on save
Click on yes
Order number – 100004201
WORKING WITH SCREEN EXITS: -
Package for production order – CO
STEP1: - Go CMOD
Enter the project name
Click on create
Click on enhancement assignment button
Press F4
Click on PPCO0012
Click on save
Click on components
Function exit EXIT_SAPLCOK01-001
EXIT_SAPLOCK01-002
Menu exit SAPLCOUC +COI
SCREEN EXIT SAPLCOK01 0900 SCR115 SAPLXC01
NOTE: - menu exits are identical by ‘+’ symbol
Place the cursor on the +COI
Double click on it
Function text = material attributes
Icon = icon_location
click on copy
Press enter
STEP2: - place the cursor on the 900 screen exit
Double click on it
Press enter

WHOLE STORY NARRATED BY VAMSI


Press enter
A 100 subscreen is generated automatically
Go to the layout
Press F6
Place mara table fields from dictionary
Mbrsh
Save and close
Activate it
Activate the whole project
Save and activate
STEP3: - Go to co03
Open the tab you added
ADDING A SCREEN TO PURCHASE ORDER: -
STEP1: - Go to CMOD
Enter project name (ex: - znsr_po)
Enter the short text
Click on assignment enhancement
Press F4
Click on MM06E005
Click on 1 documentation
Click on components button
In documentation
0 SAPLXM06 0101 subscreen header purchase order
Click on components
STEP2: - Select include CIEKKODB
Double click on it
Enter the field name
Zz_visa_typ char10
Save and activate
STEP3: - Screen exit
Select the I01 screen
Click on maint org language
Click on layout
Press F6
Enter table name EKKO
Click on get from dictionary
Select zz_visa_typ field
Press enter
Put a label to it = visa type
Save and close

WHOLE STORY NARRATED BY VAMSI


Activate
Back
Double click on 111 screen
Activate it
Make all screens activate
Ensure you activate the below screens 111, 201, 211, 301, 311
Activate
Back
Activate whole project
STEP4: - Create a purchase order

BADI
BUSSINESS ADDINS (BADI): -
BADI’S are building up on object oriented articheture and it is union of customer exits
and business transaction events
ADVANTAGES OF BADI: -
1. We can have multiple implementations
2. Upgrade compatible
BADI’S can be triggered upon standard transaction to chance standard transaction
STEPS INVOLUED IN BADI: -
1. Searching for a badi
2. Triggering a badi
3. Test the standard transaction
BADI ARCHITECTURE: -
BADI definitions are available in SE18 (and it is similar to SM0d) BADI
implementations need to build using SE19 (and it is similar to CMOD)
BADI DEFINATIONS COMPONENTS: -

WHOLE STORY NARRATED BY VAMSI


Go to SE18
Select radio button BADI name
Press F4
Click on new selection button
Package = ME
Select ME_PURCHDOC_POSTED
Click on display
In the attributes tab
Name of bus add-in class : CL_EX_ME_PURCHDOC_POSTED
Multiple use (If thi check box is check this can have multiple
implementations)
In the interface tab of badi definition
You will find method
Interface name = IF_EX_ME_PURCHASE_POSTED
Posted purchase document posted
OBJECT ORIENTED PROGRAMING: -
OBJECT: - An instance of a class
CLASS: - It is reversible code component and it consists of member function like properties
methods events.

INSTANCE: - A template functional behavior and allocates memory to an object.


SE18

BADI definition (Name = GET_TOTAL_OF_NUM)

Class (addin class)
CL_EX
Interface Created by sap
IF_EX
An interface will be implemented by addin class

Method
Get_total
IM_A
IM_B
EX_C

WHOLE STORY NARRATED BY VAMSI


STEP1: - Searching for a BADI (TCODE – SE24)
Go to class builder (SE24)
Enter the class name (CL_EXITHANDLER)
Click on display
Double click on GET_INSTANCE
Place a break point on
CALL METHOD CL_EXITHANDLER => GET_CLASS_NAME_BY_INTERFACE
EXIT_NAME is a variable which it will gives us BADI definition name
In debugger look for this value
EXIT_NAME = BADINAME
Copy into a notepad and segregates before save badi and after save badi
STEP2: - Triggering a badi (TCODE – SE19)
Go to SE19
Create implementation
Classic badi
Badi definition name = BADI_MATERAIL_CHECK
Click on create implementation name = ZNSR_MAT_IMP
Press enter
Implementation short text = material text change
Click on save
Click on interface tab
Double click on check data method
Go inside the method IF+EX_
Write the code
Break user7.
Click on signature button to see the parameters of the button
Save and activate
Back
Activate again
Back
STEP3: - Test the transaction (TCODE – MM02)
Enter the material
Change the description
Click on save
STEP4: - Go to SE19
In edit implementation
Select classic badi
Implementation = ZNSR_MAT_IMPL
Click on change
Go to interface tab

WHOLE STORY NARRATED BY VAMSI


Double click on check_data
Click on signature
Write the following code
Break user7.
Data : lw_text type short_desc.
Loop at stext into lw_text.
Concatenate ‘changed’ lw_text-maktx
Into lw_text-maktx.
Modify stext from lw_text.
Endloop.
Save and activate
Activate whole project
ACTIVE IMP0LEMENTATION: -
OBJECTIVE: - While doing goods receipt (GR) the following needs to be populated
automatically.
1. Storage location
2. Unloading point
3. Text
STEPS CREATING FOR MIGO: -
STEP1: - Go to MIGO T-code
AO1 GOODS RECIPT RO1 PURCHSE ORDER 4500017408
Press enter
Go to the where tab
Storage location = _______
Unloading point = ________
Text =_________
STEP2: - Go to SE18
Badi name = MB_MIGO_ITEM_BADI
Click on create
Implementation name = ZNSR_MIGO_IMPL
Press enter
Implementation short text = MIGO attributes
Click on save
Click on interface tab
Double click on the method
Keep a break point = break user7.
Use the signature button to know the import (export parameters of the method)
If matnr = ‘100-100’.
E_STGE_LOC = ‘1000’.
E_ITEM_TEXT = ‘USELESS MATERAIL’.

WHOLE STORY NARRATED BY VAMSI


Endif.
Save and activate
Back
Activate
STEP4: - Run the transaction MIGO
Enter the po number = 4500017408
IMPORTANT BADI’S FOR PURCHASE ORDER: -
ME_PURCHDOC_POSTED
BILLING BADI’S (T-CODE -VF01, VF02): -
SC_CIN_LV60AV02
VOR_WA_FAKTURA
SEARCHING ACTIVE IMPLEMENTATION FOR BADI: -
Go to SE18
Enter the badi definition name = BADI_MATERAIL_CHECK
Press display
Implementation → display
ASSIGNMENT: -
ME21 – ME_HOLD_PO
ME_PURCHDOC_POSTED
If purchase order is created po = 1000, pg= 001, company code = 1000 and raise an
error message that you cant create of the user break user7.

BAPI
BAPI: - (BUSINESS APPLICATION PROGRAMING INTERFACE)
TCODES: - SWO1 (Bus object repository) and
BAPI (Bapi explorer)
BAPI is a middle way component and it is used for interfacing with sap to sap and sap
to non sap systems.
BAPI is language independent and exclusive used for
1. Data uploads
2. Interfacing with external systems like DB, JAVA, DOTNET, and any internet
applications.
• BAPI has capability to communicate with external systems due to RFC enable function
modules.
RFC – Remote function call
• BAPI uses a business object to derive its methods, attributes, events.

WHOLE STORY NARRATED BY VAMSI


•They are predefined sap business object by sap and we can create custom business object
as well.
BUS – Business object.
PREDEFINED BUSINESS OBJECT: -
Go to SWo1
Object/interface type BUS* F4
BUS2012 – Purchase order (PO)
BUS2032 – Sales order (SO)
BUS1001 – Material
BUSINESS OBJECTS COMPONENTS: -
Interfaces
Key fields
Attributes
Methods
Events
TESTING BUSINESS OBJECT: -
Go to SWO1
Enter BUS2032
Click on display
Press F8
Click on instance button
Sales document (4969)
Press enter
Go to methods
Place a cursor on the display
Click on execute.
CREATING A SUBTYPE OF A BUSINESS OBJECT: -
OBJECTIVE: - develop a custom method to get the sold to party name for a given sales order.
STEP1: - Go to SWO1
Enter BUS2032
Click on subtype
Object type (znsr_so)
Name (ex: - znsr_so)
Description (ex: - sales order bus)
Program (ex: - znsr_so)
Application (ex: - *)
Press enter
Package = Z_IDES
Click on save (Not put in to local object. If it is in local object we can not transport it
through the landscape).

WHOLE STORY NARRATED BY VAMSI


It will ask for request
Press enter
STEP2: - Place the cursor on the methods
Click on create
Click on ‘NO’
Method (ex: - Getsp name)
Name (ex: - Getsp name)
Description (ex: - Sold to party name)
Press enter
STEP3: - Place the cursor on the method on which you created
Click on parameter button
Click on create
Click on ‘NO’
Name (ex: - EX_NAME1)
Description (ex: - SP name)
Export ( multiple – to declare itab)
Reference table KNA1
Reference field NAME1
Press enter
Save and back.
STEP4: - Place a cursor on method you created
Click on program
Click on yes
Data :
EX_NAME1 TYPE KNA1-NAME1
V_KUNNR TYPE KUNNR.
Select single kunnr from vbak into v_kunnr
Where vbeln = v_kunnr.
SWC_SET_ELEMENT container ‘ex_name1’ EX_NAME1.
Save and check the syntax
Keep a break point
Save and activate
Back
Save business object
STEP5: - Place a cursor on the method you created
Edit → change release status → object type component → to implement
Select the root object ZNSR_SO
Edit → change release status → object type → to implement
Click on yes
Edit → change release status → object type → to released

WHOLE STORY NARRATED BY VAMSI


Press enter
Go to method you created
Place a cursor on it
Edit → change release status → object type component → to released
Click on generate button (ctrl+F3)
Put a break point on the select statement in the program
STEP6: - Test it
Press F8
Click on instance
Place a cursor on GETSPNAME method
Click on execute.
EXPORT: - SWC_SET_ELEMENT CONTAINER ‘ex_name1’ EX_NAME1.
IMPORT: - SWC_GET_ELEMENT CONTAINER ‘v_kunnr’ V_KUNNR.
DATA UPLOADS USING BAPI: -
BAPI function modules are used heavily to upload the data into sap.
What is the difference between BDC upload and BAPI upload?
ANS: - BAPI upload is not based on a screen and it is upgrade compatible.
It is recommended to use BAPI than BDC.
SEARCHING FOR A BAPI: - (TCODE - BAPI)
We can search for BAPI in two ways
1. Hierarchical (functional consultant)
2. Alphabetical (ABAP developers)
Go to alphabetical
Search for purchase order
Expand it
Select the method (create from data1)
In detail tab its points the functional module (BAPI_PO_CREATE1)
Click on the documentation tab
SALES ORDER BAPI
BAPI_SALESORDER_CREATEFORMDATA2.
SIMULATING THE BAPI IN FUNCTION BUILDER: -
Go to SE37
Enter the function module (ex: - BAPI_PO_CREATE1)
Run the function module
Fill the data structure (POHEADER, POHEADERX)
In tables (POITEM, POITEMX)
Poheader structure attributes
COMP_CODE = 1000
DOC_TYPE = ND
VENDER = 1000

WHOLE STORY NARRATED BY VAMSI


PURCH_ORG = 1000
Press enter
Back
Fill the values for poheaderx
COMP_CODE =X
DOC_TYPE =X
VENDER =X
PURCH_ORG =X
Go to tables
Fill the values for poitem
PO_ITEM = 00010
MATERAIL = M-01
PLANT = 1000
QUANTITY =1
Press enter
Back
Fill the values for poitemx
PO_ITEM =X
MATERAIL =X
PLANT =X
QUANTITY =X
Press enter
Back
Click on save as variant
RETURN: - (STRUCTURE- BADIRET2, BAPIRETURN)
It is a return structure and it is used to build a log for success and failure.
ZNSR_PO_BAPI_UPLOAD: -
VENDER PURCH_ORG PUR_GROUP COMP_CODE MATERAIL QUANTITY PLANT
1000 1000 001 1000 M-01 1 1000

PROGRAM: -
REPORT ZNSR_PO_BAPI_UPLOAD.
TYPES : BEGIN OF T_PO,
LIFNR(10) TYPE C,
EKORG(4) TYPE C,
EKGRP(3) TYPE C,
BUKRS(4) TYPE C,
MATNR(18) TYPE C,
MENGE(16) TYPE C,
WERKS(4) TYPE C,
END OF T_PO.

WHOLE STORY NARRATED BY VAMSI


TYPES : TT_PO TYPE STANDARD TABLE OF T_PO.
DATA : LW_PO TYPE T_PO,
LT_PO TYPE TT_PO.
*-- BAPI STRUCS
DATA : LW_POHEAD TYPE BAPIMEPOHEADER,
LW_POHEADX TYPE BAPIMEPOHEADERX.

DATA : BEGIN OF LT_ITEM OCCURS 0.


INCLUDE STRUCTURE BAPIMEPOITEM.
DATA : END OF LT_ITEM.

DATA : BEGIN OF LT_ITEMX OCCURS 0.


INCLUDE STRUCTURE BAPIMEPOITEMX.
DATA : END OF LT_ITEMX.

DATA : LT_RETURN LIKE BAPIRET2 OCCURS 0 WITH HEADER LINE.


PARAMETERS : P_FILE TYPE LOCALFILE OBLIGATORY.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.


CALL FUNCTION 'F4_FILENAME'
EXPORTING
PROGRAM_NAME = SYST-CPROG
DYNPRO_NUMBER = SYST-DYNNR
FIELD_NAME = ' '
IMPORTING
FILE_NAME = P_FILE.

START-OF-SELECTION.
PERFORM GET_DATA.
PERFORM FILL_BAPI_STRUCS. "Header data
PERFORM header_x.
PERFORM item_Data.
PERFORM ITEM_X.
PERFORM CALL_BAPI.
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text

WHOLE STORY NARRATED BY VAMSI


* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_DATA .
DATA : L_FNM TYPE STRING.
L_FNM = P_FILE.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = L_FNM
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = '#'
* HEADER_LENGTH =0
* READ_BY_LINE = 'X'
* DAT_MODE =''
* CODEPAGE =''
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* CHECK_BOM =''
* VIRUS_SCAN_PROFILE =
* NO_AUTH_CHECK =''
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
DATA_TAB = LT_PO
EXCEPTIONS
FILE_OPEN_ERROR =1
FILE_READ_ERROR =2
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

WHOLE STORY NARRATED BY VAMSI


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. " GET_DATA


*&---------------------------------------------------------------------*
*& Form FILL_BAPI_STRUCS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM FILL_BAPI_STRUCS .
LOOP AT LT_PO INTO LW_PO.
*-- Bapi po header
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
INPUT = lw_po-lifnr
IMPORTING
OUTPUT = lw_po-lifnr
.

LW_POHEAD-VENDOR = LW_PO-LIFNR.
LW_POHEAD-PURCH_ORG = LW_PO-EKORG.
LW_POHEAD-PUR_GROUP = LW_PO-EKGRP.
LW_POHEAD-COMP_CODE = LW_PO-BUKRS.
LW_POHEAD-DOC_TYPE = 'NB'.
ENDLOOP.
ENDFORM. " FILL_BAPI_STRUCS
*&---------------------------------------------------------------------*
*& Form HEADER_X
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text

WHOLE STORY NARRATED BY VAMSI


* <-- p2 text
*----------------------------------------------------------------------*
FORM HEADER_X .
*---header X
LW_POHEADX-VENDOR = 'X'.
LW_POHEADX-PURCH_ORG = 'X'.
LW_POHEADX-PUR_GROUP = 'X'.
LW_POHEADX-COMP_CODE = 'X'.
LW_POHEADX-DOC_TYPE = 'X'.
ENDFORM. " HEADER_X
*&---------------------------------------------------------------------*
*& Form ITEM_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM ITEM_DATA .
loop at lt_po INTO lw_po.
LT_ITEM-PO_ITEM = '00010'.
LT_ITEM-MATERIAL = LW_PO-MATNR.
LT_ITEM-PLANT = LW_PO-WERKS.
LT_ITEM-QUANTITY = LW_PO-MENGE.
APPEND LT_ITEM.
ENDLOOP.
ENDFORM. " ITEM_DATA
*&---------------------------------------------------------------------*
*& Form ITEM_X
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM ITEM_X .
LT_ITEMX-PO_ITEM = '00010'.
LT_ITEMX-MATERIAL = 'X'.
LT_ITEMX-PLANT = 'X'.
LT_ITEMX-QUANTITY = 'X'.

WHOLE STORY NARRATED BY VAMSI


append lt_itemx.
ENDFORM. " ITEM_X
*&---------------------------------------------------------------------*
*& Form CALL_BAPI
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CALL_BAPI .
CALL FUNCTION 'BAPI_PO_CREATE1'
EXPORTING
POHEADER = LW_POHEAD
POHEADERX = LW_POHEADX
* POADDRVENDOR =
* TESTRUN =
* MEMORY_UNCOMPLETE =
* MEMORY_COMPLETE =
* POEXPIMPHEADER =
* POEXPIMPHEADERX =
* VERSIONS =
* NO_MESSAGING =
* NO_MESSAGE_REQ =
* NO_AUTHORITY =
* NO_PRICE_FROM_PO =
* PARK_COMPLETE =
* PARK_UNCOMPLETE =
* IMPORTING
* EXPPURCHASEORDER =
* EXPHEADER =
* EXPPOEXPIMPHEADER =
TABLES
RETURN = LT_RETURN
POITEM = LT_ITEM
POITEMX = LT_ITEMX
* POADDRDELIVERY =
* POSCHEDULE =
* POSCHEDULEX =
* POACCOUNT =

WHOLE STORY NARRATED BY VAMSI


* POACCOUNTPROFITSEGMENT =
* POACCOUNTX =
* POCONDHEADER =
* POCONDHEADERX =
* POCOND =
* POCONDX =
* POLIMITS =
* POCONTRACTLIMITS =
* POSERVICES =
* POSRVACCESSVALUES =
* POSERVICESTEXT =
* EXTENSIONIN =
* EXTENSIONOUT =
* POEXPIMPITEM =
* POEXPIMPITEMX =
* POTEXTHEADER =
* POTEXTITEM =
* ALLVERSIONS =
* POPARTNER =
* POCOMPONENTS =
* POCOMPONENTSX =
* POSHIPPING =
* POSHIPPINGX =
* POSHIPPINGEXP =
* SERIALNUMBER =
* SERIALNUMBERX =
* INVPLANHEADER =
* INVPLANHEADERX =
* INVPLANITEM =
* INVPLANITEMX =
.
LOOP AT LT_RETURN where TYPE = 'S'.
WRITE : / LT_RETURN-MESSAGE.
ENDLOOP.
COMMIT WORK.
ENDFORM. " CALL_BAPI

BAPI-TRANSACTION: -
In this function module is used to commit into the database (or) else we can use
“COMMIT WORK”.
BAPI STEPS: -

WHOLE STORY NARRATED BY VAMSI


STEP1: - Build an itab of file structure
Get the data in an itab
Fill the data in BAPI structure / tables / variables from the itab
STEP2: - ITAB to BAPI function module
Pass import / export tables from the field structures.
NOTE: - Before you write an ABAP code to BAPI test it in function builder SE37.
FUNCTION MODULE FOR MIGO: - BAPI_GOODSMVT_CREATE

WHOLE STORY NARRATED BY VAMSI


CROSS APPLICATIONS
T-CODES OF CROSS APPLICATIONS: -
SM59 - RFC destination
BD54 - Define logical systems
SCC4 - Assign logical systems
WE81 - Create message type
WE82 - Assign IDOC to message typr
WE30 - IDOC creation
WE31 - Segment creation
WE21 - Port creation
WE20 - Partner profile
BD64 - Distribution model
BD10 - Send material
BD12 - Send customer
DB14 - Send vender
WE02 - IDOC Display
WE05 - IDOC List
BD75 - Commit IDOC
WE41 - Outbound process code
WE42 - Inbound process code
WE19 - Test bound IDOC
BD53 - IDOC Reduction
BD56 - Segment document
SCDO - Change document
BD61 - Activate change pointers
BD52 - Change DOC items
CROSS APPLICATIONS (*): - Cross applications are widely used to distribute the data
between sap to sap systems and sap to non sap systems as well.
ALE: - (APPLICATION LINKING AND ENABELING)
ALE technology is used to distribute the data between sap to sap systems.
Normally we distribute the master data and transactional data using ALE.
EDI: - (ELECTRONIC DATA INTERCHANGE)
EDI technology is used to distribute the data between sap to non sap systems.
EDI uses a sub system to transmit the IDOCS.
ALE data is distributed using memory buffers.
EDI data is distributed using files.
IDOC: - (INTERMEDAITE DOCUMENT)

WHOLE STORY NARRATED BY VAMSI


In order to distribute the data between two systems IDOCS are used.
RFC DESTINATION: - (TCODE – SM59)
In order to communicate between two different systems RFC destination is used.
RFC FM: - In order to read / write the data RFC function module will be used.
OUTBOUND SYSTEM – SENDER
INBOUND SYSTEM – RECEIVER
CREATING RFC DESTINATION: - (TCODE – SM59)
RFC destination has to be created in the sender system by providing the login details
of the receiver.
STEP1: - Go to SM59
Select ABAP connections
Click on create
RFC destination (Z_CONNECT) (note: - it is case sensitive)
Description1 (ex: - Get connected stay connected)
Description2 (ex: - Connecting LID 800 to LID 810)
Connection type (ex: - 3)
Click on save
Click on the technical setting tab
Target host 121.241.50.175 system number 00
Target host is the IP address of receiver.
Click on save.
STEP2: - Click on logon and security tab
Language = EN
Client = 810
User = user1
Password = global
Logon credentials should be receiver system
Click on save
Press enter
STEP3: - Click on connection test button
Back
Click on remote logon button
BUILDING AN RFC FUNCTION MODULE: -
OBJECTIVE: - Read the data from 810 servers and display it in 800.
STEPS IN 810: -
STEP1: - Go to SE80
Create a function group (ex: - znsr_rfc)
Activate it
STEP2: - Go to SE37
Function module (ex: - znsr_customer_rfc)

WHOLE STORY NARRATED BY VAMSI


Click on create
Function group (ex: - znsr_rfc)
Short text (ex: - customer details)
Click on save.
STEP3: - Go to attributes tab
Select remote-enable module
Go to import tab PASS BY VALUES

IM_KUNNR TYPE KUNNR


REFERENCE PARAMETER ARE NOT ALLOWED WITH RFC
Go to export tab PASS BY VALUES

EX_KNA1 TYPE KNA1


Go to source code tab
Write the following code
IF NOT IM_KUNNR IS INITIAL.
SELECT SINGLE * FROM KNA1 INTO EX_KNA1
WHERE KUNNR = IM_KUNNR.
ENDIF.
Save and activate.
STEP4: - Calling RFC FM in LID 800
Go to SE38
Call function module (ex: - znsr_customer_rfc)
Parameters : p_kunnr type kunnr
Data : lw_kna1 type kna1.
Start-of-selection.
Call function ‘znsr_customer_rfc’ destination ‘z_connect’
Im_kunnr = p_kunnr
Ex_kna1 = lw_kna1
Write : lw_kna1-kunnr, lw_kna1-name1.
IDOC: - (INTERMEDATE DOCUMENT)
It’s a data container which has capability to understand semanticist of the data and its
rules.
IDOC is used to exchange the data between two systems an outbound IDOC is
generated as a result of initiating outbound process.
An inbound IDOC is served as an input to clear application document in the receiver
system.
IDOC is independent of direction and data is in the text format.
They are predefined IDOC’S by sap and we can create custom IDOC as well.
WE30 is the t-code for IDOC.

DIRECTION = 1 (OUTBOUND IDOC)

WHOLE STORY NARRATED BY VAMSI


DIRECTION = 2 (INBOUND IDOC)
PREDEFIEND IDOC: -
MATMAS05 - Material master IDOC
DEBMAS05 - Customer master IDOC
CREMAS05 - Vender master IDOC

ORDERS05 - PO / SO
SEARCHING FOR AN IDOC: - (TCODE – WE02)
Go to WE02
Created on 13.06.2005 13.06.2005
Direction = 1
Basic type = MATMAS05
Press F8
Double click on any IDOC number to see the run time components of it
IDOC RUN TIME COMPONENTS: -
An IDOC is 16 digits unique number and it consists of 3 components
i. Control record
ii. Data record
iii. Status record
CONTROL RECORD: - There will be only one control record per an IDOC and it describes
about the direction.
• Direction
• Current status
• Basic type
• Extension
• Message type
• Partner NO.
• Partner type
• Port
Table for control record of IDOC is “EDIDC”
DATA RECORD: - Segments are translated into data records at run time.
Table for data record of IDOC is “EDIDD OR EDID4”
STATUS RECORD: - It informs about successful or failure of an IDOC.
Table for status record of IDOC is “EDIDS”.
OUTBOUND IDOC STATUS CODES: -
0 – 50 (OUTBOUND IDOCS) : 03 SUCCESSES
51 – 75 (INBOUND IDOCS) : 53 SUCCESSES
MESSAGE TYPE: - (TCODE – WE81)
It describes about the business information is being exchanged by two partners and
internally a message type will point to an IDOC type (WE82).

WHOLE STORY NARRATED BY VAMSI


PARTNER NO.: - It should be always a receiver system.
PARTNER TYPE: - Characterize the communication partner. Partner type and partner number
identify.
Partner type = LS (Logical system)
PORT: - It is a medium through which data is being exchanged port carriers the IDOC to the
partner.
CREATING LOGICAL SYSTEMS: - (TCODE – BD54)
STEP1: - Go to BD54
Press enter
Click on new entries
Yahoo sender sys 800-lid (where 800-lid is the client address of server)
Google receiver sys 810-lid (where 810-lid is the client address of server)
Click on save
STEP2: - SCC4 (Assigning local systems)
Go to SCC4
Click on change button
Click on details button
Client = sender sys 800-lid (Be careful by this)
Logical system = Yahoo
Press enter
Save and back
Select 810
Click on details
Client = sender sys 810-lid (Be careful by this)
Logical system = Google
Press enter
Click on save and back
STEP3: - SM59 (RFC Destination)
Go to SM59
RFC destination (ex: - Z_CONNECT)
STEP4: - WE30 (IDOC Creation)
Go to WE30
Enter obj. name (ex: - MATMAS05)
Have close look on it
STEP5: - WE81 (Creating message type)
Go to WE81
Click on positions button
Message type (ex: - MATMAS)
STEP6: - WE82 (Linking message type to IDOC type)
Go to WE82

WHOLE STORY NARRATED BY VAMSI


Click on positions button
Message type (ex: - MATMAS)
Basic type (ex: - MATMAS05)
Press enter
MESSAGE TYPE BASIC TYPE EXTENSION RELEASE
MATMAS MATMAS05 470
STEP7: - WE21 (Port creation)
Go to WE21
Select transactional RFC
Click on create
Own port name
Name (ex: - DHL)
Press enter
Description (ex: - Yahoo to Google)
RFC destination (ex: - Z_CONNECT)
STEP8: - WE20 (Partner profile)
Go to WE20
Select partner type LS
Click on create
Partner NO. = Google → receiver system name
Partner type = LS
Type (ex: - US)
Agent (ex: - user1)
Language (ex: - EN)
Select the outbound partner
Click on button
Message type (ex: - MATMAS)
Receiver port (ex: - DHL)
Transfer IDOC immediately
Basic type (ex: - MATMAS05)
Click on save
STEP9: - In LID 810 – WE20 (Partner profile)
Go to WE20
Select partner type LS
Click on create
Partner NO. = Yahoo → sender system name
Partner type = LS
Type (ex: - US)
Agent (ex: - user1)
Language (ex: - EN)

WHOLE STORY NARRATED BY VAMSI


Select inbound parameters
Click on button
Message type (ex: - MATMAS)
Process code (ex: - MATM)
NOTE: - MATM is the process code for MATMAS
DEBM is the process code for DEBMAS
CRE1 is the process code for CREMAS
ORDE is the process code for ORDERS.
STEP10: - BD64 (Distribution model)
NOTE: - Before you perform BD64 ensure connections are intact
Go to BD64
Click on change button
Click on create model view button
Short text = master data distribution
Technical name = Dist_mm01
Press enter
Select the model view you have created
Click on add message type button
Sender = Yahoo
Receiver = Google
Message type = MATMAS
Press enter
Click on save
Select the model you have created
Environment → generate partner profile
Partner system = Google
Press F8
Back
Select the model you created
Edit → model view → distribute
Press enter
Model view DIST_MM01 has been created
Back
Put it in display mode
STEP11: - MM01 (Create a material)
Material (ex: - cross-mat1)
Industry sector (ex: - mechanical engineering)
Material type (ex: - raw material)
Press enter
Select basic1 and basic2 data

WHOLE STORY NARRATED BY VAMSI


Click on default values
Press enter
Enter material description (ex: - TCS info)
Base unit of measure (ex: - ea)
Click on save.
STEP12: - BD10 (Send material)
Go to BD10
Material = cross-mat1
Message type (standard) = MATMAS
Press F8
1 mater IDOC is created
1 communication IDOC is created
If we get 0 master & 0 communications go to BD64 and delete
STEP13: - BD75 (Commit IDOC)
Go to BD75
Press F8
Press enter
STEP14: - WE02 (IDOC Display)
Go to WE02
Created on 20.09.2011 20.09.2011
Direction = 1
Basic type = MATMAS05
Press F8
STEP15: - Login to receiver system LID-810
Go to WE02 (search for an IDOC)
Created on 20.09.2011 20.09.2011
Direction = 2
Basic type = MATMAS05
Double click on the error IDOC
Go to the status record
Double click on the 51 error
Click on application log to see the error.

SEGMENT FILTERING: - (TCODE – BD56)


Segment filtering is used to suppress the unwanted segments in the distribution of an
IDOC.
The reasons can be security and finical reasons
We cannot suppress mandatory segments in an IDOC.
STEP1: - Go to BD54
Press enter
Click on new entries

WHOLE STORY NARRATED BY VAMSI


Yahoo sender sys 800-lid (where 800-lid is the client address of server)
Google receiver sys 810-lid (where 810-lid is the client address of server)
Click on save
STEP2: - SCC4 (Assigning local systems)
Go to SCC4
Click on change button
Click on details button
Client = sender sys 800-lid (Be careful by this)
Logical system = Yahoo
Press enter
Save and back
Select 810
Click on details
Client = sender sys 810-lid (Be careful by this)
Logical system = Google
Press enter
Click on save and back
STEP3: - SM59 (RFC Destination)
Go to SM59
RFC destination (ex: - Z_CONNECT)
STEP4: - WE30 (IDOC Creation)
Go to WE30
Enter obj. name (ex: - MATMAS05)
Have close look on it
STEP5: - WE81 (Creating message type)
Go to WE81
Click on positions button
Message type (ex: - MATMAS)
STEP6: - WE82 (Linking message type to IDOC type)
Go to WE82
Click on positions button
Message type (ex: - MATMAS)
Basic type (ex: - MATMAS05)
Press enter
MESSAGE TYPE BASIC TYPE EXTENSION RELEASE
MATMAS MATMAS05 470
STEP7: - WE21 (Port creation)
Go to WE21
Select transactional RFC
Click on create

WHOLE STORY NARRATED BY VAMSI


Own port name
Name (ex: - DHL)
Press enter
Description (ex: - Yahoo to Google)
RFC destination (ex: - Z_CONNECT)
STEP8: - WE20 (Partner profile)
Go to WE20
Select partner type LS
Click on create
Partner NO. = Google → receiver system name
Partner type = LS
Type (ex: - US)
Agent (ex: - user1)
Language (ex: - EN)
Select the outbound partner
Click on button
Message type (ex: - MATMAS)
Receiver port (ex: - DHL)
Transfer IDOC immediately
Basic type (ex: - MATMAS05)
Click on save
STEP9: - In LID 810 – WE20 (Partner profile)
Go to WE20
Select partner type LS
Click on create
Partner NO. = Yahoo → sender system name
Partner type = LS
Type (ex: - US)
Agent (ex: - user1)
Language (ex: - EN)
Select inbound parameters
Click on button
Message type (ex: - MATMAS)
Process code (ex: - MATM)
STEP10: - BD64 (Distribution model)
NOTE: - Before you perform BD64 ensure connections are intact
Go to BD64
Click on change button
Click on create model view button
Short text = master data distribution

WHOLE STORY NARRATED BY VAMSI


Technical name = Dist_mm01
Press enter
Select the model view you have created
Click on add message type button
Sender = Yahoo
Receiver = Google
Message type = MATMAS
Press enter
Click on save
Select the model you have created
Environment → generate partner profile
Partner system = Google
Press F8
Back
Select the model you created
Edit → model view → distribute
Press enter
Model view DIST_MM01 has been created
Back
Put it in display mode
STEP11: - BD56 (Maintain table view)
Go to BD56
Message type = MATMAS
Press enter
Click on new entries
TYPE SENDER TYPE RECEIVER SEGMENT TYPE
LS YAHOO LS GOOGLE E1MLGNM
Press enter
Click on save.
STEP12: - BD10 (Send material)
Go to BD10
Material = cross-mat1
Message type (standard) = MATMAS
Press F8
1 mater IDOC is created
1 communication IDOC is created
If we get 0 master & 0 communications go to BD64 and delete.
STEP13: - BD75 (Commit IDOC)
Go to BD75
Press F8

WHOLE STORY NARRATED BY VAMSI


Press enter
STEP14: - WE02 (IDOC Display)
Go to WE02
Created on 21.09.2011 21.09.2011
Direction = 1
Basic type = MATMAS05
Pres F8.
WORKING WITH CUSTOM IDOC’S AND DEVELOPING OUTBOUND INTERFACE:
STEP1: - Go to BD54
Press enter
Click on new entries
Yahoo sender sys 800-lid (where 800-lid is the client address of server)
Google receiver sys 810-lid (where 810-lid is the client address of server)
Click on save.
STEP2: - SCC4 (Assigning local systems)
Go to SCC4
Click on change button
Click on details button
Client = sender sys 800-lid (Be careful by this)
Logical system = Yahoo
Press enter
Save and back
Select 810
Click on details
Client = sender sys 810-lid (Be careful by this)
Logical system = Google
Press enter
Click on save and back.
STEP3: - SM59 (RFC Destination)
Go to SM59
RFC destination (ex: - Z_CONNECT).
STEP4: - WE31 (Creating segment)
Go to WE31
Segment type = Z1MATM
Click on create
Short description = (ex: - Basic material data)
POSITION FIELD NAME DATA ELEMENT
1 MATNR MATNR
2 MBRSH MBRSH
3 MTART MTART

WHOLE STORY NARRATED BY VAMSI


Press enter
Click on save
Press enter
Click on local object
Back
Edit → set release
If you want to add a one more field
Cancel the release
Edit → cancel release
Click on change button.
STEP5: - WE30 (Creating ZIDOC)
Go to we30
Obj. name = (ex: - ZMATIDOC)
Basic type
Click on create
Create new
Description = (ex: - basic material IDOC)
Press enter
Place the cursor on the IDOC
Click on create
Seg. Type = (ex: - Z1MATM) → It should be your created name before
Mandatory seg.
Minimum number = 1
Maximum number = 99
Hier. Level = 0
Press enter
Click on save to save the IDOC
Back
Edit → set release
Click on yes
Click on the header button to know the release.
STEP6: - WE81 (Logical message type)
Go to WE81
Click on change icon
Click on new entries
MESSAGE TYPE SHORT TEXT
ZMATMSG MATERIAL MESSAGE TYPE
Click on save.
STEP7: - WE21 (Port creation)
Go to WE21

WHOLE STORY NARRATED BY VAMSI


Select transactional RFC
Click on create
Own port name
Name (ex: - DHL)
Press enter
Description (ex: - Yahoo to Google)
RFC destination (ex: - Z_CONNECT)
STEP8: - WE20 (Partner profile)
Go to WE20
Select partner type LS
Click on create
Partner NO. = Google → receiver system name
Partner type = LS
Type (ex: - US)
Agent (ex: - user1)
Language (ex: - EN)
Go to outbound parameters
Remove any existing entries
Select the outbound partner
Click on button
Message type = (ex: - ZMATMSG)
Receiver port = (ex: - DHL)
Transfer IDOC immediately
Basic type = (ex: - ZMATIDOC)
Click on save
STEP9: - In LID 810 – WE20 (Partner profile)
Go to WE20
Select partner type LS
Click on create
Partner NO. = Yahoo → sender system name
Partner type = LS
Type (ex: - US)
Agent (ex: - user1)
Language (ex: - EN)
Select inbound parameters
Click on button
Message type (ex: - MATMAS)
Process code (ex: - MATM)
STEP10: - Outbound interface
Go to se38

WHOLE STORY NARRATED BY VAMSI


Write the following code
TABLES : mara.
TYPES : BEGIN OF t_mara,
matnr type matnr,
mbrsh type mbrsh,
mtart TYPE mtart,

END OF t_mara.
TYPES : tt_mara TYPE STANDARD TABLE OF t_mara.
data : lw_mara TYPE t_mara,
lt_mara type tt_mara.
*-- Control record
data : lw_edidc TYPE edidc,
lt_edidc TYPE STANDARD TABLE OF edidc.

*-- Data Record


data : lw_edidd TYPE edidd,
lt_edidd TYPE STANDARD TABLE OF edidd.
*-- Segment data
data : lw_z1matm TYPE z1matm.
SELECT-OPTIONS : s_matnr for mara-matnr.

START-OF-SELECTION.
PERFORM get_Data.
PERFORM create_control_rec.
PERFORM CREATE_DATA_REC.
PERFORM CREATE_IDOC.
break user8.
*&---------------------------------------------------------------------*
*& Form GET_DATA
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM GET_DATA .
SELECT matnr mbrsh mtart FROM mara
into TABLE lt_mara
WHERE matnr in s_matnr.

WHOLE STORY NARRATED BY VAMSI


ENDFORM. " GET_DATA
*&---------------------------------------------------------------------*
*& Form CREATE_CONTROL_REC
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CREATE_CONTROL_REC .
lw_edidc-DIRECT = '1'. "OUTBOUND IDOC DIR
lw_edidc-DOCTYP = 'ZMATDOC'. "IDOC NAME
LW_EDIDC-MESTYP = 'ZMATMSG'. " MESSAGE TYPE
LW_EDIDC-RCVPRN = 'GOOGLE'. "PARTNER
LW_EDIDC-RCVPRT = 'LS'. "PARTNER TYPE
LW_EDIDC-RCVPOR = 'DHL'. "PORT

ENDFORM. " CREATE_CONTROL_REC


*&---------------------------------------------------------------------*
*& Form CREATE_DATA_REC
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CREATE_DATA_REC .
LOOP AT LT_MARA INTO LW_MARA.
lw_Z1MATM-MATNR = LW_MARA-MATNR.
lw_z1matm-mbrsh = lw_mara-mbrsh.
lw_z1matm-mtart = lw_mara-mtart.

move 'Z1MATM' TO LW_EDIDD-SEGNAM.


MOVE LW_Z1MATM TO LW_EDIDD-SDATA.
APPEND LW_EDIDD TO LT_EDIDD.
ENDLOOP.
ENDFORM. " CREATE_DATA_REC
*&---------------------------------------------------------------------*
*& Form CREATE_IDOC
*&---------------------------------------------------------------------*

WHOLE STORY NARRATED BY VAMSI


* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM CREATE_IDOC .
CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
EXPORTING
MASTER_IDOC_CONTROL = LW_EDIDC
* OBJ_TYPE = ''
* CHNUM = ''
TABLES
COMMUNICATION_IDOC_CONTROL = LT_EDIDC
MASTER_IDOC_DATA = LT_EDIDD
* EXCEPTIONS
* ERROR_IN_IDOC_CONTROL =1
* ERROR_WRITING_IDOC_STATUS =2
* ERROR_IN_IDOC_DATA =3
* SENDING_LOGICAL_SYSTEM_UNKNOWN =4
* OTHERS =5
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
COMMIT WORK.
READ TABLE LT_EDIDC INTO LW_EDIDC INDEX 1.
CHECK SY-SUBRC EQ 0.
WRITE : / LW_EDIDC-DOCNUM.
ENDFORM. " CREATE_IDOC

CHECK THE STRUCTURE (CTU_PARAMS)

Data record has two sections


1. Administrative section
2. Data section
ADMINISTRATIVE SECTION: -
It describes about segment name, number, parent segment and document number
DATA SECTION: - It is an application data and having a capacity of 1000 character length
CHANGE POINTER: - This technique is used to generate change documents change pointers
are triggered on master data creation or change.

WHOLE STORY NARRATED BY VAMSI


Change document are registered in tables: -
CDHDR – Header table
COPOS – Item table
Change pointers are returned in the following tables
BDCP – Change pointer
BDCPS – Change pointer status
STEP1: - Go to BD54
Press enter
Click on new entries
Yahoo sender sys 800-lid (where 800-lid is the client address of server)
Google receiver sys 810-lid (where 810-lid is the client address of server)
Click on save
STEP2: - SCC4 (Assigning local systems)
Go to SCC4
Click on change button
Click on details button
Client = sender sys 800-lid (Be careful by this)
Logical system = Yahoo
Press enter
Save and back
Select 810
Click on details
Client = sender sys 810-lid (Be careful by this)
Logical system = Google
Press enter
Click on save and back
STEP3: - SM59 (RFC Destination)
Go to SM59
RFC destination (ex: - Z_CONNECT)
STEP4: - WE30 (IDOC Creation)
Go to WE30
Enter obj. name (ex: - MATMAS05)
Have close look on it
STEP5: - WE81 (Creating message type)
Go to WE81
Click on positions button
Message type (ex: - MATMAS)
STEP6: - WE82 (Linking message type to IDOC type)
Go to WE82
Click on positions button

WHOLE STORY NARRATED BY VAMSI


Message type (ex: - MATMAS)
Basic type (ex: - MATMAS05)
Press enter
MESSAGE TYPE BASIC TYPE EXTENSION RELEASE
MATMAS MATMAS05 470
STEP7: - BD61 (Active change pointer generally)
Go to bd61
Change pointer activated generally
STEP8: - BD50 (Active change pointer for message type)
Click on positions
Message type = (ex: - MATMAS)
Press enter
Message type activate
MATMAS
STEP9: - SCDO (Change document object)
Change document is a collection of table fields
MATERIAL
Press enter
Double click on the material object
` Click on yes
It will show you list of table’s involved
STEP10: - BD52 (Maintain table view)
Enter message type = (ex: - MATMAS)
Press enter
OBJECT TABLE NAME FIELD NAME
MATERIAL DMAKT MAKTX
STEP11: - WE21 (Ports in IDOC processing)
Go to WE21
Select transactional RFC
Click on create
Own port name
Name (ex: - DHL)
Press enter
Description (ex: - Yahoo to Google)
RFC destination (ex: - Z_CONNECT)
STEP12: - WE20 (Partner profile)
Go to WE20
Select partner type LS
Click on create
Partner NO. = Google → receiver system name

WHOLE STORY NARRATED BY VAMSI


Partner type = LS
Type (ex: - US)
Agent (ex: - user1)
Language (ex: - EN)
Go to outbound parameters
Remove any existing entries
Select the outbound partner
Click on button
Message type = (ex: - MATMAS)
Receiver port = (ex: - DHL)
Transfer IDOC immediately
Basic type = (ex: - MATMAS05)
Click on save
STEP13: - In LID 810 – WE20 (Partner profile)
Go to WE20
Select partner type LS
Click on create
Partner NO. = Yahoo → sender system name
Partner type = LS
Type (ex: - US)
Agent (ex: - user1)
Language (ex: - EN)
Select inbound parameters
Click on button
Message type (ex: - MATMAS)
Process code (ex: - MATM)
STEP14: - BD64 (Distribution model)
Go to BD64
Click on change button
Click on create model view button
Short text = master data distribution
Technical name = Dist_mm01
Press enter
Select the model view you have created
Click on add message type button
Sender = Yahoo
Receiver = Google
Message type = MATMAS
Press enter
Click on save

WHOLE STORY NARRATED BY VAMSI


Select the model you have created
Environment → generate partner profile
Partner system = Google
Press F8
Back
Select the model you created
Edit → model view → distribute
Press enter
Model view DIST_MM01 has been created
Back
Put it in display mode
STEP15: - Go to MM02
Material = (ex: - cross-mat3)
Change the material description
Click on save
STEP16: - Go to se38
Run the program “RBDMIDOC”
Press F8
Message type = (ex: - MATMAS)
Press F8
1 master IDOC is created
1 communication IDOC is created
STEP17: - WE02 (IDOC Display)
Go to WE02
Created on 21.09.2011 21.09.2011
Direction = 1
Basic type = MATMAS05
Press F8.
REDUCTION OF IDOC: - (TCODE – BD53)
Reduction of IDOC is used to suppress or filter particular fields of segment.
This can be done using reduction message type
STEP1: - Go to BD54
Press enter
Click on new entries
Yahoo sender sys 800-lid (where 800-lid is the client address of server)
Google receiver sys 810-lid (where 810-lid is the client address of server)
Click on save
STEP2: - SCC4 (Assigning local systems)
Go to SCC4
Click on change button

WHOLE STORY NARRATED BY VAMSI


Click on details button
Client = sender sys 800-lid (Be careful by this)
Logical system = Yahoo
Press enter
Save and back
Select 810
Click on details
Client = sender sys 810-lid (Be careful by this)
Logical system = Google
Press enter
Click on save and back
STEP3: - SM59 (RFC Destination)
Go to SM59
RFC destination (ex: - Z_CONNECT)

STEP4: - DB53 (IDOC Reduction)


Go to BD53
Reduction message type = (ex: - ZRD_CUST)
Click on create
Message type reference = (ex: - DEBMAS)
Press enter
Description = (ex: - Reduction message type for customer)
Press enter
It will point an IDOC DEBMAS60
The segments are colored in green as well as red
Green colored segments are mediatory, we cannot filter them
Red color segments can be filter them
Double click on E1KNA1M
Name 3 fields
Click on select
Press enter
Click on save to save the IDOC
Back.
STEP5: - WE82 (Linking message type to IDOC type)
Go to WE82
Click on positions button
Message type (ex: - ZRD_CUST)
Basic type (ex: - DEBMAS06)
Press enter
MESSAGE TYPE BASIC TYPE EXTENSION RELEASE

WHOLE STORY NARRATED BY VAMSI


ZRD_CUST DEBMAS06 470
STEP6: - WE21 (Port creation)
Go to WE21
Select transactional RFC
Click on create
Own port name
Name (ex: - DHL)
Press enter
Description (ex: - Yahoo to Google)
RFC destination (ex: - Z_CONNECT)
STEP8: - WE20 (Partner profile)
Go to WE20
Select partner type LS
Click on create
Partner NO. = Google → receiver system name
Partner type = LS
Type (ex: - US)
Agent (ex: - user1)
Language (ex: - EN)
Select the outbound partner
Click on button
Message type (ex: - ZRD_CUST)
Receiver port (ex: - DHL)
Transfer IDOC immediately
Basic type (ex: - DEBMAS06)
Click on save
STEP9: - BD64 (Distribution model)
Go to BD64
Click on change button
Click on create model view button
Short text = master data distribution
Technical name = Dist_VD01
Press enter
Select the model view you have created
Click on add message type button
Sender = Yahoo
Receiver = Google
Message type = DEBMAS
Press enter
Click on save

WHOLE STORY NARRATED BY VAMSI


Select the model you have created
Environment → generate partner profile
Partner system = Google
Press F8
Back
Select the model you created
Edit → model view → distribute
Press enter
Model view DIST_VD01 has been created
Back
Put it in display mode
STEP10: - Create a customer
Go to VD01
Account group = (ex: - sold-to party - 0001)
Customer = 7586
Sales organization = (ex: - 1000)
Distribution channel = (ex: - 10)
Division = (ex: - 00)
Press enter
Title = (ex: - Mr.)
Name = (ex: - Donthireddy)
Naga
Search term ½ = (ex: - Reddy)
Postal code/city = (ex: - Hyd)
Country = (ex: - IN)
Transportation zone = (ex: - 0000000001)
Click names box
Add name for remaining (ex: - Shanmukh)
Reddy
Click on sales area button
Click on shipping tab
Shipping conditions = (ex: - 01)
Click on billing documents tab
Tax = (ex: - 1)
Click on save.
STEP11: - BD12 (Send customer)
Go to BD12
Customer = (ex: - 7586)
Output type = (ex: - ZRD_CUST)
Press F8

WHOLE STORY NARRATED BY VAMSI


Press enter (1 master IDOC set up for message type DEBMAS)
Press enter (1 communication IDOC generated for message type BEDMAS).
STEP12: - WE02 (IDOC Display)
Go to WE02
Created on 22.09.2011 22.09.2011
Direction = 1
Basic type = (ex: - DEBMAS)
Partner number = (ex: - Google)
Press F8.
EXTENSION OF IDOC: -
In order to need the client’s requirement we need to extend standard IDOC using
extension option.
The data need to be populated in the extended segment using exits.
OBJECTIVE: - Add a custom segment to determine the long test of the material under
E1MAKTM segment.
STEP1: - Go to BD54
Press enter
Click on new entries
Yahoo sender sys 800-lid (where 800-lid is the client address of server)
Google receiver sys 810-lid (where 810-lid is the client address of server)
Click on save
STEP2: - SCC4 (Assigning local systems)
Go to SCC4
Click on change button
Click on details button
Client = sender sys 800-lid (Be careful by this)
Logical system = Yahoo
Press enter
Save and back
Select 810
Click on details
Client = sender sys 810-lid (Be careful by this)
Logical system = Google
Press enter
Click on save and back
STEP3: - SM59 (RFC Destination)
Go to SM59
RFC destination (ex: - Z_CONNECT)
STEP4: - WE30 (IDOC Creation)
Go to WE30

WHOLE STORY NARRATED BY VAMSI


Enter obj. name (ex: - ZEX_MAT05)
Extension
Click on create button
Press enter
Create new like basic type = (ex: - MATMAS05)
Description = (ex: - Extended IDOC for MATMAS05)
Press enter
Select E1MAKTM and click on create
Press enter
Segm. Type = Z1DESC
Mandatory seg.
Minimum number = 1
Maximum number = 99
Hier.level = 0
Press enter
Save and back
Edit → set release
Click on yes
STEP5: - Go to WE31
Segment type = (ex: - Z1DESC)
Click on create
Short description = (ex: - long text)
FIELD NAME DATA ELEMENT
LONG TEXT CHAR40
Click on save
Back
Edit → set release
STEP6: - WE82 (Linking message type to IDOC type)
Go to WE82
Click on positions button
Message type (ex: - MATMAS)
Basic type (ex: - MATMAS05)
Press enter
MESSAGE TYPE BASIC TYPE EXTENSION RELEASE
MATMAS MATMAS05 ZEX_MAT05 470
Click on save
STEP7: - WE21 (Port creation)
Go to WE21
Select transactional RFC
Click on create

WHOLE STORY NARRATED BY VAMSI


Own port name
Name (ex: - DHL)
Press enter
Description (ex: - Yahoo to Google)
RFC destination (ex: - Z_CONNECT)
STEP8: - WE20 (Partner profile) → Google
Go to WE20
Select partner type LS
Click on create
Partner NO. = Google → receiver system name
Partner type = LS
Type (ex: - US)
Agent (ex: - user1)
Language (ex: - EN)
Select the outbound partner
Click on button
Message type (ex: - MATMAS)
Receiver port (ex: - DHL)
Transfer IDOC immediately
Basic type (ex: - MATMAS05)
Extension = (ex: - ZRX_MAT05)
Click on save
STEP9: - In LID 810 – WE20 (Partner profile) → Yahoo
Go to WE20
Select partner type LS
Click on create
Partner NO. = Yahoo → sender system name
Partner type = LS
Type (ex: - US)
Agent (ex: - user1)
Language (ex: - EN)
Select inbound parameters
Click on button
Message type (ex: - MATMAS)
Process code (ex: - MATM)
Click on save
STEP10: - BD64 (Distribution model)
Go to BD64
Click on change button
Click on create model view button

WHOLE STORY NARRATED BY VAMSI


Short text = master data distribution
Technical name = Dist_mm01
Press enter
Select the model view you have created
Click on add message type button
Sender = Yahoo
Receiver = Google
Message type = MATMAS
Press enter
Click on save
Select the model you have created
Environment → generate partner profile
Partner system = Google
Press F8
Back
Select the model you created
Edit → model view → distribute
Press enter
Model view DIST_MM01 has been created
Back
Put it in display mode.
STEP11: - BD10 (Send material)
Go to BD10
Material = cross-mat1
Message type (standard) = MATMAS
Press F8
1 mater IDOC is created
1 communication IDOC is created
If we get 0 master & 0 communications go to BD64 and delete
STEP12: - WE02 (IDOC Display)
Go to WE02
Created on 23.09.2011 23.09.2011
Direction = 1
Basic type = MATMAS05
Press F8.
STEP13: - Go to CMOD
Project = (ex: - ZEX_MAT)
Click on create button
Short text = (ex: - populating data for custom segment)
Click on enhancement assignments

WHOLE STORY NARRATED BY VAMSI


Click on F4
Package = (ex: - MGV)
Press enter
MGV00001
Click on change
Double click on EXIT_SAPLMV01_002
Double click on include ZXMGV003
Write the following code
BREAK USER7.
DATA : LW_DESC TYPE Z1DESC.
CASE ‘SEGMENT_NAME’.
WHEN ‘E1MAKTM’.
LW_DESC_LONG_TEXT = ‘IT’S NOT LIE’.
MOVE ‘Z1DESC’ TO IDOC_DATA-SEGNAM.
MOVE LW_DESC TO IDOC_DATA-SDATA.
APPEND IDOC_DATA.
Activate it.
Activate the whole project.
STEP14: - BD10 (Send material)
Go to BD10
Material = cross-mat3
Message type (standard) = MATMAS
Press F8
1 mater IDOC is created
1 communication IDOC is created
If we get 0 master & 0 communications go to BD64 and delete
STEP15: - WE02 (IDOC Display)
Go to WE02
Created on 23.09.2011 23.09.2011 → IDOC created date
Direction = 1
Basic type = MATMAS05
Press F8.
WORKING WITH TRANSACTIONAL IDOC AND DISTRIBUTING IT USING
MESSAGE CONTROL: -
Transactional IDOC’S will be distributed using message control with an outbound
process code and having ALE distribution as a medium in the transaction.
OBJECTIVE: - Create an outbound IDOC when ever sales order getting created or changed.
IDOC type = ORDERS05
Message type = ORDRSP
Outbound process code = SD10

WHOLE STORY NARRATED BY VAMSI


Medium = A-ALE DISTRIBUTION
Program = RSMASTED “this generate an IDOC
Inbound process code = ORDE
STEP1: - Go to BD54
Press enter
Click on new entries
Yahoo sender sys 800-lid (where 800-lid is the client address of server)
Google receiver sys 810-lid (where 810-lid is the client address of server)
Click on save
STEP2: - SCC4 (Assigning local systems)
Go to SCC4
Click on change button
Click on details button
Client = sender sys 800-lid (Be careful by this)
Logical system = Yahoo
Press enter
Save and back
Select 810
Click on details
Client = sender sys 810-lid (Be careful by this)
Logical system = Google
Press enter
Click on save and back
STEP3: - SM59 (RFC Destination)
Go to SM59
RFC destination (ex: - Z_CONNECT)
STEP4: - WE30 (Creating IDOC)
Go to WE30
Obj. name = (ex: - ORDERS05)
Basic type
Click on create
Create new
Description = (ex: - basic sales order IDOC)
Press enter
Place the cursor on the IDOC
Click on create
Seg. Type = (ex: - ORDE) → It should be your created name before
Mandatory seg.
Minimum number = 1
Maximum number = 99

WHOLE STORY NARRATED BY VAMSI


Hier. Level = 0
Press enter
Click on save to save the IDOC
Back
Edit → set release
Click on yes
Click on the header button to know the release.
STEP5: - WE81 (Creating message type)
Go to WE81
Click on positions button
Message type (ex: - ORDRSP)
STEP6: - WE82 (Linking message type to IDOC type)
Go to WE82
Click on positions button
Message type (ex: - ORDRSP)
Basic type (ex: - ORDERS05)
Press enter
MESSAGE TYPE BASIC TYPE EXTENSION RELEASE
ORDRSP ORDERS05 470
STEP7: - WE21 (Port creation)
Go to WE21
Select transactional RFC
Click on create
Own port name
Name (ex: - DHL)
Press enter
Description (ex: - Yahoo to Google)
RFC destination (ex: - Z_CONNECT)
STEP8: - WE20 (Partner profile) → Google
Go to WE20
Select partner type LS
Click on create
Partner NO. = Google → receiver system name
Partner type = LS
Type (ex: - US)
Agent (ex: - user1)
Language (ex: - EN)
Select the outbound partner
Click on button
Message type (ex: - ORDRSP)

WHOLE STORY NARRATED BY VAMSI


Receiver port (ex: - DHL)
Transfer IDOC immediately
Basic type (ex: - ORDERS05)
Click on message control tab
Click on button
APPLICATION MESSAGE TYPE PROCESS CODE CHANGE
V1 BA00 SD10
Click on save
STEP9: - In LID 810 – WE20 (Partner profile) → Yahoo
Go to WE20
Select partner type LS
Click on create
Partner NO. = Yahoo → sender system name
Partner type = LS
Type (ex: - US)
Agent (ex: - user1)
Language (ex: - EN)
Select inbound parameters
Click on button
Message type (ex: - ORDRSP)
Process code (ex: - ORDE)
STEP10: - BD64 (Distribution model)
Go to BD64
Click on change button
Click on create model view button
Short text = master data distribution
Technical name = Dist_VA01
Press enter
Select the model view you have created
Click on add message type button
Sender = Yahoo
Receiver = Google
Message type = ORDRSP
Press enter
Click on save
Select the model you have created
Environment → generate partner profile
Partner system = Google
Press F8
Back

WHOLE STORY NARRATED BY VAMSI


Select the model you created
Edit → model view → distribute
Press enter
Model view DIST_VA01 has been created
Back
Put it in display mode
STEP11: - VA01 (Create sales order)
Go to VA01
Order type = (ex: - OR)
Sales organization = 1000
Distribution channel = 10
Division = 00
Press enter
Sold-to-party = 1000
Ship-to-party = 1000
Material = 100-100
Order quantity = 1
Extras → output → header → edit
Change the medium = distributed ALE
Select it and click on save.
STEP12: - WE02 (IDOC Display)
Go to WE02
Created on 20.09.2011 20.09.2011
Direction = 1
Basic type = ORDERS05
Press F8
TESTING INBOUND IDOC’S: - (TCODE – WE19)
In order to test inbound IDOC we need to make use WE19.
STEP1: - Get the IDOC number
Go to WE19
Existing IDOC = 000000000082334
Press F8
Double click on any segment
Modify the field data as per your requirement
Press enter
Click on inbound module button
Function module IDOC_INPUT_MATMAS01
Call in debugging mode
In foreground
Press enter.

WHOLE STORY NARRATED BY VAMSI


PROCESS CODE: - A process code identifies the type of data processing for inbound
processing.
USE: - The IDOC interface uses the process code to find the business process which controls the
conversation of the IDOC into the sap document.
Every process code will find a function module and function module consist of IDOC
generation code.
To see the function module of process code.
Go to WE20
Select your partner, in the inbound parameters
Double click on the process code
You will see the function module (IDOC_INPUT_MATMAS01).
CORRESCTION TRANSPORT SYSTEM (CTS): -
LANDSCAPE: -

DEV QUALITY PRODUCTION


SERVER SERVER SERVER
Q/A

LIVE
END USERS
CONFIG
SERVER
CLIENT

Q) What is your system landscape?


ANS: - Development → Quantity → Production
Production is used by end users.
DEVELOPMENT SERVERS: - It is used by ABAP developers to build programs and custom
requirements.
The program and custom requirement objects are transported to quality and production
servers respectively.
QUALITY SERVER: - It is the place where testing will take place.
In this server functions and business people will test.
After performing “VAT” (User acceptance test) a sign of will be given by the business
or client then the program is moved to production.

WHOLE STORY NARRATED BY VAMSI


PRODUCTION SERVER: - It is highly integrated system with secured mechanism will build
and audit compliant and has been used by end users.
CONFIG CLIENT: - It is used by functional consultant.
TRANSPORT ORGINZATION: - (TCODE – SE09)
They are two types of requests.
1. Work bench request
2. Customizing request
WORK BENCH REQUEST: - It is raised by ABAP developers.
CUSTOMIZING REQUEST: - It will be created by functional consultant.
REQUEST NUMBER: - LIDK1234
REQUEST STATUS: -
1. Modifiable
2. Released
MODIFIABLE: - When you develop an ABAP program having a request know as modifiable
transport.
RELEASED: -In order to transport a request the request need to release.

REQUEST

TASK

Select the task click on icon (F9)


Place the cursor on the request (F9).
VERSION MANAGEMENT: -
Go to SE38
Utilities → versions → version management
Select the versions you want to compare
Click on button
Click on setting button
Parallel display
Display all
Press enter.

WHOLE STORY NARRATED BY VAMSI


CUSTOMER UPLOADS FILE FORMAT: -
FILE FIELDS HARD CODED FIELDS
CUSTOMER SALES ORGINZATION
NAME DISTRIBUTION CHANNEL
CITY DIVISION
SEARCH TERM COUNTRY
POSTAL CODE LANGUAGE
TRANSPORT
TAX
NOTE PAD FILE FORMAT: -
8579 JACK1 HYD1 J1 333444
8580 JACK2 HYD2 J2 333445
8581 JACK3 HYD3 J3 333446

WHOLE STORY NARRATED BY VAMSI


LSMW
LSMW: - (LEGACY SYSTEM MIGRATION WORK BENCH)
It is a data transfer tool which is used to upload the data into sap form legacy systems.
They are four methods to upload the data.
1. Direct input
2. Batch input (BDC)
3. BAPI
4. IDOC
As per the industry standards it is normally used by functional consultant.
Go to LSMW
Project = (ex: - ZCUST_P)
Subproject = (ex: - ZCUST_S)
Object = (ex: - ZCUST_O)
Press enter
Click on create
Description = (ex: - customer upload)
Press enter
Description = (ex: - customer upload)
Press enter
Description = (ex: - customer upload)
Press enter
Click on execute (F8)
It consist of process steps
STEP1: - Maintain object attributes
Click on execute (ctrl+F8)
Batch input recording
Click on button
Create a recording for VD01
Click on create
Recording = ZNSR_CUST
Description = (ex: - VD01 recording)
Press enter
Transaction code = VD01
And continue with the recording steps.
Press enter
Click on default all buttons
Click on Save
Back

WHOLE STORY NARRATED BY VAMSI


Back
Recording = ZNSR_CUST
Click on save
Back
STEP2: - Maintain source structures
Click on execute (ctrl+F8)
Click on create
Source structure = ZCUST_T
Description = (ex: - ITAB for flat file – customer data)
Press enter
Click on save
Back
STEP3: - Maintain source fields
Click on execute (ctrl+F8)
Place the cursor on structure ZCUST_LT
Click on create
Field name = KUNNR
Field description = CUSTOMER
Field length = 10
Field type = c
Press enter
Place a cursor on KUNNR field
Click on create
Add the remaining five fields (NAME1, ORT01, SORTL, PSTLZ)
Click on save
Back
STEP4: - Maintain structure relations
Click on execute (ctrl+F8)
Relationship
Click on save
Back
STEP5: - Maintain field mapping and conversion rules
Click on execute (ctrl+F8)
Extras → auto-field mapping
Press enter
System will propose the proposal
Click on accept proposal
Till it complete
For hard coded fields
Place the cursor on the VKORG

WHOLE STORY NARRATED BY VAMSI


Click on constant button
Sales org = 1000
Press enter
Place the cursor on the VTWEG
Click on constant button
Jjgjhgkhsjgh = 0
Place a cursor on the SPARK
Click on constant button
Fskfhskghjksg= 00
Place a cursor on the LAND1
Click on constant button
Country = IN
Place a cursor on the SPRAS
Click on constant button
Jjfdsajkafk = 00000000001
Place a cursor on the TAXAD
Click on constant button
Jjsijlksjglja = 0
Place a cursor on the KTOKD
Click on constant button
SjfljaJKLJA = 0001
Click on save
Back
STEP6: - Maintain fixed values, translations, user-defined routines. (Skip this step need not
Necessary)
STEP7: - Specify fields
Click on execute (ctrl+F8)
Place a cursor of legacy data on the PC (Frontend)
Click on create
File = C:\documents&settings\desktop\customer.txt
Name = Customer
Tabulator
Press enter
Click on save
Back
SREP8: - Assign files
Click on execute (ctrl+F8)
Click on save
Back
STEP9: - Read data

WHOLE STORY NARRATED BY VAMSI


Click on execute (ctrl+F8)
Transaction number to
Click on execute (ctrl+F8)
Back
Back
STEP10: - Display read data
Click on execute (ctrl+F8)
From line
To line
Press enter
Back
STEP11: - Convert data
Click on execute (ctrl+F8)
Click on execute (ctrl+F8)
Back
Back
STEP12: - Display converted data
Click on execute (ctrl+F8)
Press enter
Please verify the data correct or not
Clicking on a row
Back.
STEP13: - Create both input sessions
Click on execute (ctrl+F8)
Name of batch input folder (s) = ZCUST_SESS
Keep batch input folder (s)?
Click on execute (ctrl+F8)
Press enter.
STEP14: - Run batch input session
Click on execute (ctrl+F8)
Session = ZCUST_SESS
Press enter
Select the session
Click on process
Process/foreground
Press enter/process
Continue with ok-code box.
USER EXITS: - For a every given transaction their will be proposed user exits and it is used for
system modifications.

WHOLE STORY NARRATED BY VAMSI


User exits are associated with form routines and we require access key to modify the
code.
The impacts are global, while performing modifications using user exits.
DISADVANTAGES: -
• These are not upgrade compatible
• The code put in a user exits will be wiped out during upgrades and applying patches.
Q) What are the differences between customer exits and user exits?
ANS: - Customer exits can be identified by package or call customer function.
Whereas user exits are associated with form….endform (from routines).
SEARCHING FOR USER EXITS FOR A GIVEN TRANSACTION: -
Go to the transaction VA01
System → status
Double click on the program name SAPMV45A
Double click on the include MV45AFZZ.
SALES ORDER IMPORTANT USER EXITS: -
FORM USEREXITS_SAVE_DOCUMENT_PREPARE
This user exit can be used for changes or checks before document is saved.
FORM USEREXIT_SAVE_DOCUMENT
This user exit can be used to save data in additional when a document is saved.
ENHANCEMENTS FRAME WORK: -
It was introduced in ECC6.0 where we can modify the sap standard code with out
taking an access key.
ADVANTAGES: -
Upgrade compatible.
IMPLICIT ENHANCEMENTS: -
For a given transaction they are predefined implicit enhancements points by making
use of it, we can modify the standard code without taking an a access key.
Technically we can create an implementation on it.
OBJECTIVE: - If a sales order net value is more than 1000 raise an error message.
STEP1: - Go to SE38
Program = SAPMV45A
Go to SAPMV45A
Double click on the MV45AFZZ include
Edit → enhancement operations → shoe implicit enhancement options
Every form routine we get a coated line.
FROM……
““““““““““““““““““““““““““““““““““““““
““““““““““““““““““““““““““““““““““““““
ENDFORM……
Click on

WHOLE STORY NARRATED BY VAMSI


STEP2: - Go to form USEREXIT_SAVE_DOCUMENT
Place a cursor on the coated lines
Mouse right button → enhancement implementation → create implementation
Click on code button
Click on create
Enhancement implementation = ZGS_NETVALUE
Short text = net value restriction
Press enter
Put it in local object
Select the implementation you created (ZGS_NETVALUE)
Press enter
If VBAK-NETWR GT ‘1000.00’.
Message ‘net value can be greater than 1000’ type ‘E’.
Endif.
Click on save
Click on activate enhancement button
If you want to change the code place a cursor on the form
Mouse right button → enhancement implementation → change implementation
STEP3: - Test the transaction
Go to VA01
Try to save the net value greater than 1000
To check it is working or not.

ADOBE FORMS
ADOBE FORMS: - (TCODE - SFP)
Adobe forms are PDF based forms, they have integrated a smart form with PDF
option.
It has two components.
1. Form
2. Interface
FORM: - It is used to build a layout

WHOLE STORY NARRATED BY VAMSI


INTERFACE: - Interface is an independent component which can be relieved into any form to
build PDF based forms.
STEP1: - Go to SFP
Created an interface
Interface = ZNSR_BILL_INTF
Click on create
Description = billing interface
Interface = ABAP dictionary-based interface
(Or)
Smart form interface
Press enter
Expand the type’s global definitions
Go inside the types
Declare the global data
CREATE
Go to global data STRUCTURE AND
Click on create / append row TABLE TYPE

FT_VBRP TYPE TT_VBRP


FS_VBRP TYPE T_VBRP
STEP2: - Go to form interface
Select import
Click on create/append row
FT_VBRP TYPE TT_VBRP
Click on save and activate
STEP3: - Go to form = ZNSR_BILL_SFP
Click on create
Description = Billing form
Interface = ZNSR_BILL_INTF
Press enter
Expand the import folder
Select FT_VBRP table
Drag and drop on the context folder
Click on save
STEP4: - Click on the layout tab
Their will be two views in the layout
1. Hierarchy
2. Data view
Select the data view
Select the FT_VBRP table
Drop it on design view tab
Click on save and activate

WHOLE STORY NARRATED BY VAMSI


STEP5: - Write a driver program
Go to SE38
Program = ZNSR_BILL_SFP
Run the adobe form to get the run time function module
Copy the function module
For future references use the adobe form name ‘FP_EXAMPLE_01’.

**********************************THE END***********************************

WHOLE STORY NARRATED BY VAMSI

You might also like