Professional Documents
Culture Documents
Sap Abap Material PDF
Sap Abap Material PDF
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.
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.
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.
(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.
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.
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.
• 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.
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.
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.
JOINS: -
EXAMPLES OF INNER-JOIN: -
A T1 A T1
B T2 B T2
C T3 C T3
A T1 T4 A T1 T4
B T2 T5 B T2 T5
C T3
INNER-JOIN OUTER-JOIN
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.
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
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).
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.
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>.
*---------------------------------------------------------------------*
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.
clear lw_billitem.
refresh lt_billitem.
select vbeln posnr matnr arktx fkimg netwr
from vbrp into table lt_billitem
where vbeln = lw_billheader-vbeln.
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
end-of-page.
write: 'thank you.....visit again'.
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>.
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.
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.
*---------------------------------------------------------------------*
AT SELECTION-SCREEN.
*---------------------------------------------------------------------*
SELECT SINGLE * FROM EKPO
INTO EKPO
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.
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
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.
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
*----------------------------------------------------------------------*
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.
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
NOTE: - If subroutine is declared with using or changing options the formal parameters need to
be declared same as actual parameters.
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
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.
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.
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
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
SAP
SYATEM
WORKING WITH FILES: - Core team will supply files in .XLS format, .EXE format, .CVS
format.
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.
WRITE ACCESS: -
In order to write a file on application server, we have to “use output statement” along
with open dataset.
READ ACCESS: -
In order to read a file from application server we have to “use input statement” along with
open dataset.
READ DATASET: - Read dataset statement is used to move the data from file to ITAB.
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
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.
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
BDC_CLOSE_GROUP: - It closes the currency open session if you do not pass any parameters
to it.
CALL TRANSACTION: - It is an online update and you can update the data synchronously or
asynchronously.
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.
NOTE: - In the download program identify the material (or) key field of the transaction and
replace with the new number. (Find & replace).
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
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”
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.
END OF T_MAT.
TYPES : TT_MAT TYPE STANDARD TABLE OF T_MAT.
DATA : LW_MAT TYPE T_MAT,
LT_MAT TYPE TT_MAT.
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'
" screen_1
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.
*&---------------------------------------------------------------------*
*& 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
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
CUSTOMER NO :
NAME :
CITY :
CONTURY :
OPEN –FORM: - It opens the form for printing and we need to pass the following parameters.
FORM = SCRIPT
LANGUAGE = EN
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
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.
LOGO INVOICE
TOTAL :
AMOUNT IN WORDS:
NOTE: - To draw the vertical lines lift the code from “MEDRUCK” in info window.
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)
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
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.
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.
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
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.
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)
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.
LOGO HEADER
CUSTOMER INFO
FOOTER
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
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
PAGE PROTECTION: -
Page protection can be done using folder
• Paragraph
• Text node
• Folder
• Line type
DIFFERENCE BETWEEN SAP SCRIPTS AND SMART FORMS: -
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.
Material master
MATERIAL
IND SEE
MST TYPE
VIEW
VENDER
NAME
CITY
DISPLAY
CUSTOMER
DISPLAY
CUSTOMER
NAME
COUNTRY
CUSTOMER DISPLAY
HIT ME
HIT ME
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’.
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: -
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.
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.
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
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
BAPI-TRANSACTION: -
In this function module is used to commit into the database (or) else we can use
“COMMIT WORK”.
BAPI STEPS: -
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).
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.
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.
LIVE
END USERS
CONFIG
SERVER
CLIENT
REQUEST
TASK
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
**********************************THE END***********************************