SAP-SQLSQL: - 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 INTO TABLE . 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-mtartlw_mara-fashgrd. Endloop.
WHOLE STORY NARRATED BY VAMSI
STATEMENT 2:- (SELECT FILDS) SYNTAX: - SELECT FLD1 FLD2 FLD3
FROM INTO TABLE . 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 INTO TABE WHERE =?. 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 INTO 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 ROWS: SYNTAX: -SELECT FLD1 FLD2 FLD3 FROM INTO
TABLE UP TO ROWS. EX: - select fld1 fld2 from into table Up to
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 INTO CORRESPONDING FILDS OF TABLE 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
SELECTENDSELECT: SYNTAX: - SELECT FLD1 FLD2 FROM INTO TABLE
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 : FOR
. 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 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
JOINSJOINS: - 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:
FIELD1A B C
FIELD2T1 T2 T3
FIELD1A B C
FIELD2T1 T2 T3
FEILD1 FEILD2 FEILD3A B T1 T2 T4 T5
FEILD1A B C
FEILD2 FEILD3T1 T2 T3 T4 T5
INNER-JOIN
OUTER-JOIN
SYNTAX: - SELECT TAB1~FLD1 TAB1~FLD2 TAB1~FLD3 TAB2~FLD1
TAB2~FLD2 INTO TABLE FROM INNER JOIN 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
REPORTSREPORTS: Reports are used for viewing the data in an
appropriate format as per the clients 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 fields 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 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
ITABS 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 fields 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 INTO WITH KEY = ? . DESCRIBE TABLE: - Describe table is
a key word which will let you know the No. of records available in
an ITAB. SYNTAX: - DESCRIBE TABLE LINES . 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 : .
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 . 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 VALUE . EX: - cursor field
lw_likp-vbeln value v_vbeln. WHOLE STORY NARRATED BY VAMSI
PROGRAM FOR AT LINE-SELECTION AND TOP-OF-PAGE DURING
LINESELECTION: 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, posnr type posnr_vl, erdat
type erdat, matnr type matnr, lfimg type lfimg, end of t_lips.
" delivery number " item number " date created " material
number, " quantity
**-- 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 STATEMENTSCONTROL 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 10 20 30 10 10 20
PENCIL M-01 M-02 M-03 PENCIL M-01 M-02 4 2 3 1 2 2 4
2. AT NEW. ----------------------ENDAT. 3. AT LAST.
------------------------ENDAT. 4. AT END OF.
--------------------------------ENDAT.
102 102 102 104 105 105
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 BY . 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 TECHNIQUESMODULARIZATION 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: SD_DATETIME_DIFFERENCE RP_LAST_DAY_OF_MONTHS SPELL_AMOUNT
FIMA_DAYS_AND_MONTHS_AND_YEARS FIMA_DAYS_BETWEEN_TWO_DATS
CONVERSION_EXIT_ALPHA_INPUT 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 . 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. 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. Q. 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 2. PERFORM USING 3. PERFORM
TABLES The parameters associated with PERFORM are known as actual
parameters. The parameters associated with the FORMENDFORM are
known as formal parameters. STEP1: - Go to the start-of-selection
Write perform 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 * p1 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 REPORTSALV 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 * p1 text * p1 text * p1 text * p1 text * p1 text
* 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 * p1 text * p1 text * p1 text * p1 text * p1 text
* p1 text
WHOLE STORY NARRATED BY VAMSI
* p1 text
WHOLE STORY NARRATED BY VAMSI
* p1 text * p1 text * p1 text *