SlideShare une entreprise Scribd logo
1  sur  44
Basic Programming
• WRITE :
1. Use to print the output.
2. Ex:
a) write : ‘Donald’.
b) Write : ‘Donald’ , ‘Sap abap’.
c) Write : ‘Donald ‘ , / ‘Sap abap’.
d) Write : ‘Donald ‘ , / ‘Sap abap’ color 2. (1-7)
e) Write : 30 ‘Donald ‘ , / ‘Sap abap’.
f) Write : 30 ‘Donald ‘ , / 30 ‘Sap abap’.
g) Write : 30 ‘Donald ‘ , / , /30 ‘Sap abap’.
or
Write : 30 ‘Donald ‘ .
skip.
write : ‘Sap abap’.
a) Skip 10.
Parameters :
• To provide the input option to the user.
• Ex :
parameters : p_name type c.
write : p_name.
• Every program is having 3 screens.
1. ABAP Editor
2. Selection Screen
3. Output Screen
Data:
• Used to declare variables.
ex : data : p3 type i.
SELECT-OPTIONS : To provide the range input option to the user.
Ex: select-options : p_vbeln for VBAK-vbeln.
Data Declaration
Data Type Description Length Declaration Default Value
C CHAR REQUIRE VAR(10) TYPE C SPACE
I INT --- VAR TYPE I 0
N NUM REQUIRE VAR(3) TYPE N 000
D DATE ----- VAR TYPE D 00000000
T TIME --------- VAR TYPE T 000000
F FLOAT
(MAX 8)
VAR TYPE F 0.0000000000
0E+00
P PACKED
DECIMAL
(MAX 16) VAR TYPE P DECIMAL 2 0.00
X XSTRING ----- VAR TYPE X 00
STRING STRING -------- VAR TYPE STRING SPACE
Control Break Statements:
1. Do --- endo.
2. While -- endwhile.
3. If.. Endif.
4. Case … endcase.
5. If…. Elseif … elseif … endif.
Do enddo
• Ex:
Data : count type I.
Parameters : num type I.
count = 1.
Do num times.
write : / count.
count = count + 1.
enddo.
While .. Endwhile
• Ex:
DATA: COUNT TYPE I.
PARAMETERS : NUM TYPE I.
COUNT = 1.
WHILE COUNT <= NUM .
WRITE : / COUNT .
COUNT = COUNT + 1.
ENDWHILE.
If … endif
• Ex:
PARAMETERS : SAL TYPE I.
IF SAL > 25000.
WRITE : 'software engineer'.
ENDIF.
If… else … endif
• Ex :
PARAMETERS : SAL TYPE I.
IF SAL > 25000.
WRITE : 'software engineer'.
else.
WRITE : 'Support Engineer'.
ENDIF.
Case .. endcase
• Ex:
PARAMETERS: color TYPE i.
CASE COLOR.
WHEN '1'.
WRITE 'color 1' COLOR 1.
WHEN '2'.
WRITE 'color 2' COLOR 2.
WHEN '3'.
WRITE 'color 3' COLOR 3.
WHEN '4'.
WRITE 'color 4' COLOR 4.
WHEN '5'.
WRITE 'color 5' COLOR 5.
WHEN OTHERS.
WRITE : 'color not found'.
ENDCASE.
System Variables
• SY-DATUM : System date.
• SY-UZEIT : System time
• SY-CPROG: Current program name
• SY-REPID: Current program name
• SY-UNAME: System username
• SY-LANGU: System language
• SY-LINNO: Current line number
• SY-ULINE: Horizontal line
• SY-VLINE: Vertical Line
• SY-TCODE : Current Transaction code
All the system variable available in structure SYST
• SY-SUBRC : returns 0 if previous statement executed successfully.
• SY-TABIX: Stores internal table index.
• SY-INDEX : Can be used as a counter in the loops.
• SY-LSIND : returns list index.
Operation on string
• Concatenate : Used to combine the character.
• Ex:
data: name(20) TYPE c.
PARAMETERS : name1(10) TYPE c,
name2(10) TYPE c.
CONCATENATE name1 name2 INTO name.
WRITE name.
• Separated by : To maintain the space between 2 strings.
Ex:
data: name(20) TYPE c.
PARAMETERS : name1(10) TYPE c,
name2(10) TYPE c.
CONCATENATE name1 name2 INTO name SEPARATED BY space.
WRITE name.
• Alignments
• RIGHT-JUSTIFIED AND LEFT-JUSTIFIED :
• By default always characters are left justified and numbers are
right justified.
Ex :
PARAMETERS : name(10) TYPE c,
num TYPE i.
WRITE : name COLOR 2 RIGHT-JUSTIFIED,
/ num COLOR 3 LEFT-JUSTIFIED.
CENTERED :
PARAMETERS : name(10) TYPE c,
num TYPE i.
WRITE : name COLOR Centered ,
/ num COLOR 3 LEFT-JUSTIFIED.
• Split : Using to split.
Ex:
data: var1(10) TYPE c,
var2(10) TYPE c.
PARAMETERS : p_name(20) TYPE c.
SPLIT p_name at '.' INTO var1 var2.
WRITE : / var1,
/ var2 .
• Replace : It replace only 1st occurrence in string.
Ex:
PARAMETERS : p_name(20) TYPE c.
REPLACE 'A' WITH 'B' into p_name.
WRITE : p_name.
• Replace all occurrences of : To replace the all the occurrence
of given string.
• Ex :
PARAMETERS : p_name(20) TYPE c.
REPLACE ALL OCCURRENCES OF 'A' in p_name WITH 'B'.
WRITE : p_name.
• TRANSLATE : It works similar to replace all occurrences of
PARAMETERS : p_text(20) TYPE c.
TRANSLATE p_text USING 'AB'.
WRITE : p_text.
• Offset : Splitting based on position.
Ex :
DATA : p1(10) TYPE c,
p2(10) TYPE c.
PARAMETERS : p_text(10) TYPE c.
p1 = p_text(2).
p2 = p_text+2(8).
WRITE : / p1 , / p2.
• CONDENSE :
Ex :
PARAMETERS : k(5) TYPE c.
CONDENSE k NO-GAPS.
WRITE : k .
• NO-GAP : Use to remove the gap.
Ex:
WRITE : 'jugul' , 'donald'.
WRITE : / 'jugul' NO-GAP, 'donald'.
• NO-ZERO : Use to remove zero’s.
Ex :
PARAMETERS : k(5) TYPE n.
WRITE : k no-zero.
Structures
• Structures are combination of different variables or types.
• Syntax :
types : Begin of <structure name>,
------
------
End of <structure name>.
Ex :
Types: Begin of ABC,
name(10) type c,
DOB type d,
age(2) type c,
End of ABC.
A variable which has been declared with reference of structure
is Know as Work Area.
DATA: WA type ABC.
• Assigning value to Work area.
WA-NAME = ‘STEVE’.
WA-DOB = ‘22-07-1990’.
WA-AGE = ’26’.
WRITE : / WA-NAME , WA-DOB, WA-AGE.
• Clear : Clear is used to clear the content of variable.
TYPES : BEGIN OF T_STD,
NAME(20) TYPE C,
AGE TYPE I,
CLASS TYPE I,
END OF T_STD.
DATA : WA TYPE T_STD.
WA-NAME = 'DONALD'.
WA-AGE = 25.
WA-CLASS = 2.
WRITE : / WA-NAME , WA-AGE ,WA-CLASS.
CLEAR WA.
WA-NAME = 'JUGUL'.
WA-CLASS = 3.
WRITE : / WA-NAME , WA-AGE ,WA-CLASS.
Internal Table
• Internal table is like table which can be able to hold multiple
records.
• Syntax :
< variable name> type table of <structure/table name >.
Ex :
TYPES : BEGIN OF T_STD,
NAME(20) TYPE C,
AGE TYPE I,
CLASS TYPE I,
END OF T_STD.
DATA : WA TYPE T_STD,
ITAB TYPE TABLE OF T_STD.
WA-NAME = 'DONALD'.
WA-AGE = 25.
WA-CLASS = 2.
• Append is used to append the record from work area to
internal table.
APPEND WA TO ITAB.
CLEAR WA.
WA-NAME = 'JUGUL'.
WA-CLASS = 3.
APPEND WA TO ITAB.
CLEAR WA.
• To access data from internal table .
LOOP AT ITAB INTO WA.
WRITE : / WA-NAME ,WA-AGE , WA-CLASS.
ENDLOOP.
To select record from Database
table into work Area.
• Ex:
DATA : WA TYPE ZSTUD.
SELECT SINGLE * FROM ZSTUD
INTO WA
WHERE STUDID = '124'.
WRITE:/ WA-STUDID , WA-DEPARTID1, WA-STUDNAME , WA-
FEES.
Corresponding fields of
• Used to place the selected fields at corresponding fields in
WA/internal table.
• Ex :
DATA : WA TYPE ZSTUD.
SELECT SINGLE DEPARTID1 STUDNAME FROM ZSTUD
INTO CORRESPONDING FIELDS OF WA
WHERE STUDID = '124'.
WRITE:/ WA-DEPARTID1, WA-STUDNAME .
• If we want to put data into work area , then we have to use
single in our selection statement.
• Using corresponding fields of in program reduces the
performance.
• How to avoid ?
Ans : create the structure for required field.
Ex :
TYPES: BEGIN OF T_STD,
DEPARTID1(2) TYPE C,
STUDNAME(60) TYPE C,
END OF T_STD.
DATA: WA TYPE T_STD.
SELECT SINGLE DEPARTID1 STUDNAME FROM ZSTUD
INTO WA
WHERE STUDID = '124'.
WRITE:/ WA-DEPARTID1, WA-STUDNAME .
• In structure instead of assigning data type and length ,we can
also assign the database table and field name.
Ex:
TYPES: BEGIN OF T_STD,
DEPARTID1 TYPE ZSTUD-DEPARTID1,
STUDNAME TYPE ZSTUD-STUDNAME,
END OF T_STD.
DATA: WA TYPE T_STD.
SELECT SINGLE DEPARTID1 STUDNAME FROM ZSTUD
INTO WA
WHERE STUDID = '124'.
WRITE:/ WA-DEPARTID1, WA-STUDNAME .
• Also we can do it, by assigning data element directly.
• Ex:
TYPES: BEGIN OF T_STD,
DEPARTID1 TYPE ZDEPID,
STUDNAME TYPE ZSTUDNAME1,
END OF T_STD.
DATA: WA TYPE T_STD.
SELECT SINGLE DEPARTID1 STUDNAME FROM ZSTUD
INTO WA
WHERE STUDID = '124'.
WRITE:/ WA-DEPARTID1, WA-STUDNAME .
• Using parameter:
Ex :
TYPES: BEGIN OF T_STD,
DEPARTID1 TYPE ZDEPID,
STUDNAME TYPE ZSTUDNAME1,
END OF T_STD.
DATA: WA TYPE T_STD.
PARAMETERS : STUID TYPE ZSTUD-STUDID.
SELECT SINGLE DEPARTID1 STUDNAME FROM ZSTUD
INTO WA
WHERE STUDID = STUID.
WRITE:/ WA-DEPARTID1, WA-STUDNAME .
Select ---- EndSelect
• Used to select multiple records directly from database table.
Ex :
DATA : WA TYPE MAKT.
PARAMETERS : P_MATNR TYPE MAKT-MATNR.
SELECT * FROM MAKT
INTO WA WHERE MATNR = P_MATNR.
WRITE : / WA-MATNR , WA-SPRAS, WA-MAKTX, WA-MAKTG.
ENDSELECT.
• It fetches records multiple time from database table. So it
reduces the performance.
Internal Table
Ex:
DATA : WA TYPE MAKT,
ITAB TYPE TABLE OF MAKT.
PARAMETERS : P_MATNR TYPE MAKT-MATNR.
SELECT * FROM MAKT
INTO TABLE ITAB WHERE MATNR = P_MATNR.
LOOP AT ITAB INTO WA.
WRITE : / WA-MATNR , WA-SPRAS, WA-MAKTX, WA-MAKTG.
ENDLOOP.
Note : if there is no composite key , then work area is sufficient to fetch data from
database.
Fetching data from 2 tables.
• Ex :
TYPES : BEGIN OF T_VBAP,
VBELN TYPE VBAP-VBELN,
POSNR TYPE VBAP-POSNR,
MATNR TYPE VBAP-MATNR,
END OF T_VBAP.
DATA : ITAB TYPE TABLE OF T_VBAP,
WA TYPE T_VBAP,
WA1 TYPE MAKT.
PARAMETERS : P_VBELN TYPE VBAP-VBELN.
SELECT VBELN POSNR MATNR FROM VBAP
INTO TABLE ITAB WHERE VBELN = P_VBELN.
LOOP AT ITAB INTO WA.
WRITE : / WA-VBELN , WA-POSNR , WA-MATNR.
SELECT SINGLE * FROM MAKT INTO WA1 WHERE MATNR = WA-MATNR AND SPRAS = 'EN'.
WRITE : WA1-MAKTX.
ENDLOOP.
Note: It reduces the performance . Because within the loop fetching data from database number of times.
Inner JoinEx:
TYPES : BEGIN OF T_STR,
VBELN TYPE VBAP-VBELN,
POSNR TYPE VBAP-POSNR,
MATNR TYPE VBAP-MATNR,
MAKTX TYPE MAKT-MAKTX,
END OF T_STR.
DATA : ITAB TYPE TABLE OF T_STR,
WA TYPE T_STR.
PARAMETERS : P_VBELN TYPE VBAP-VBELN.
SELECT VBELN
POSNR
A~MATNR
MAKTX
INTO TABLE ITAB
FROM VBAP AS A INNER JOIN MAKT AS B ON B~MATNR = A~MATNR
WHERE VBELN = P_VBELN AND SPRAS = 'EN'.
LOOP AT ITAB INTO WA.
WRITE : / WA-VBELN , WA-POSNR , WA-MATNR , WA-MAKTX.
ENDLOOP.
Note : Whenever tables are less than or equal 3 go for inner join technique.
For all entries in
Ex :
TYPES : BEGIN OF T_VBAP,
VBELN TYPE VBAP-VBELN,
POSNR TYPE VBAP-POSNR,
MATNR TYPE VBAP-MATNR,
END OF T_VBAP.
TYPES : BEGIN OF T_MAKT,
MATNR TYPE MAKT-MATNR,
MAKTX TYPE MAKT-MAKTX,
END OF T_MAKT.
TYPES : BEGIN OF T_FINAL,
VBELN TYPE VBAP-VBELN,
POSNR TYPE VBAP-POSNR,
MATNR TYPE VBAP-MATNR,
MAKTX TYPE MAKT-MAKTX,
END OF T_FINAL.
DATA : WA TYPE T_VBAP,
ITAB TYPE TABLE OF T_VBAP,
WA1 TYPE T_MAKT,
ITAB1 TYPE TABLE OF T_MAKT,
WA2 TYPE T_FINAL,
ITAB2 TYPE TABLE OF T_FINAL.
PARAMETERS : P_VBELN TYPE VBAP-VBELN.
START-OF-SELECTION.
SELECT VBELN POSNR MATNR FROM VBAP
INTO TABLE ITAB
WHERE VBELN = P_VBELN .
IF ITAB IS NOT INITIAL.
SELECT MATNR MAKTX FROM MAKT
INTO TABLE ITAB1 FOR ALL ENTRIES IN ITAB
WHERE MATNR = ITAB-MATNR AND SPRAS = 'EN'.
ENDIF.
LOOP AT ITAB INTO WA.
WA2-VBELN = WA-VBELN.
WA2-POSNR = WA-POSNR.
WA2-MATNR = WA-MATNR.
CLEAR WA1.
READ TABLE ITAB1 INTO WA1 WITH KEY MATNR = WA-MATNR.
If sy-subrc = 0.
WA2-MAKTX = WA1-MAKTX.
Endif.
APPEND WA2 TO ITAB2.
ENDLOOP.
LOOP AT ITAB2 INTO WA2.
WRITE : / WA2-VBELN , WA2-POSNR , WA2-MATNR , WA2-MAKTX.
ENDLOOP.
• Note :
1. Check the for all entries table is not empty .
2. Write all key field in selection criteria.
3. Data type and length of for all entries matching field should
be match for both the table.
• Important : Read table.
1. Clear the work area before read the table.
2. After reading table use sy-subrc .
3. To improve the performance use Binary search in read
statement.
Ex :
READ TABLE ITAB1 INTO WA1 WITH KEY MATNR = WA-
MATNR binary search.
* before the loop sort the internal table.
sort itab1 by matnr.
Different Types of Internal
Table
• Based on header line internal tables are classified into 2 types:
• Header Line nothing but work area.
1. Internal table with header line .
2. Internal table without header line.
• Internal table without header line
Ex:
Types : begin of stru,
name(20) type c,
age(2) type c,
end of stru.
Data: wa type stru,
itab type table of stru.
• Internal table with header line.
Ex
Types : begin of stru,
name(20) type c,
age(2) type c,
end of stru.
Data: itab type table of stru with header line.
Itab-name = ‘Donald’.
Itab-age = 25.
Append itab.
Loop at itab.
write : / itab-name , itab-age.
Endloop.
• Based on sorting technique internal tables can divided 3 types.
1. Standard internal table.
2. Sorted internal table.
3. Hashed internal table.
• By default any internal table is standard internal table.
1. Standard internal table.
• This is follows linear search(one by one) algorithm.
• Searching time is proportional to number of records.
• Syntax:
Data : <internal table > TYPE STANDARD TABLE OF <TB /STR
name> WITH NON-UNIQUE KEY <key > WITH HEADER LINE.
<optional>
• Sorted internal tables :
1. This is follows binary search help.
2. It supports unique as well as no-unique key.
3. Syntax :
Data : <internal table > TYPE SORTED TABLE OF <tab/str name>
WITH <UNIQUE / non-unique > KEY <keyname> WITH
HEADER LINE .
<optional >
• Hashed internal table.
1. There is no non-unique key.
2. Its follows index based search.
3. Syntax :
Data : <internal table > TYPE HASHED TABLE OF <TB/STR NAME>
WITH UNIQUE KEY <KEY> WITH HEADER LINE.
<OPTIONAL>

Contenu connexe

Tendances

abap list viewer (alv)
abap list viewer (alv)abap list viewer (alv)
abap list viewer (alv)Kranthi Kumar
 
Top 10 sap abap faqs-www.bigclasses.com
Top 10 sap abap faqs-www.bigclasses.comTop 10 sap abap faqs-www.bigclasses.com
Top 10 sap abap faqs-www.bigclasses.combigclasses.com
 
Oracle Configurator Developer
Oracle Configurator DeveloperOracle Configurator Developer
Oracle Configurator DeveloperPritesh Mogane
 
ABAP Event-driven Programming &Selection Screen
ABAP Event-driven Programming &Selection ScreenABAP Event-driven Programming &Selection Screen
ABAP Event-driven Programming &Selection Screensapdocs. info
 
Abap data dictionary
Abap data dictionaryAbap data dictionary
Abap data dictionarySmartGokul4
 
Ooabap notes with_programs
Ooabap notes with_programsOoabap notes with_programs
Ooabap notes with_programsKranthi Kumar
 
Table maintenance generator and its modifications
Table maintenance generator and its modificationsTable maintenance generator and its modifications
Table maintenance generator and its modificationsscribid.download
 
Object oriented approach to ALV Lists in ABAP
Object oriented approach to ALV Lists in ABAPObject oriented approach to ALV Lists in ABAP
Object oriented approach to ALV Lists in ABAPNoman Mohamed Hanif
 
Dialog Programming Overview
Dialog Programming OverviewDialog Programming Overview
Dialog Programming Overviewsapdocs. info
 
Module-Pool-Tutorial.pdf
Module-Pool-Tutorial.pdfModule-Pool-Tutorial.pdf
Module-Pool-Tutorial.pdfSuman817957
 
Packages in PL/SQL
Packages in PL/SQLPackages in PL/SQL
Packages in PL/SQLPooja Dixit
 
Unit 4 - Basic ABAP statements, ABAP Structures and ABAP Logical Expressions
Unit 4 - Basic ABAP statements, ABAP Structures and ABAP Logical ExpressionsUnit 4 - Basic ABAP statements, ABAP Structures and ABAP Logical Expressions
Unit 4 - Basic ABAP statements, ABAP Structures and ABAP Logical Expressionsdubon07
 
105322956 advance-pricing-total-oracle-apps
105322956 advance-pricing-total-oracle-apps105322956 advance-pricing-total-oracle-apps
105322956 advance-pricing-total-oracle-appsShivakumar Karajagi
 

Tendances (20)

abap list viewer (alv)
abap list viewer (alv)abap list viewer (alv)
abap list viewer (alv)
 
Top 10 sap abap faqs-www.bigclasses.com
Top 10 sap abap faqs-www.bigclasses.comTop 10 sap abap faqs-www.bigclasses.com
Top 10 sap abap faqs-www.bigclasses.com
 
Oracle Configurator Developer
Oracle Configurator DeveloperOracle Configurator Developer
Oracle Configurator Developer
 
ABAP Event-driven Programming &Selection Screen
ABAP Event-driven Programming &Selection ScreenABAP Event-driven Programming &Selection Screen
ABAP Event-driven Programming &Selection Screen
 
SAP ABAP data dictionary
SAP ABAP data dictionarySAP ABAP data dictionary
SAP ABAP data dictionary
 
Alv theory
Alv theoryAlv theory
Alv theory
 
Abap Questions
Abap QuestionsAbap Questions
Abap Questions
 
Abap data dictionary
Abap data dictionaryAbap data dictionary
Abap data dictionary
 
Ooabap notes with_programs
Ooabap notes with_programsOoabap notes with_programs
Ooabap notes with_programs
 
Table maintenance generator and its modifications
Table maintenance generator and its modificationsTable maintenance generator and its modifications
Table maintenance generator and its modifications
 
Field symbols
Field symbolsField symbols
Field symbols
 
Module pool programming
Module pool programmingModule pool programming
Module pool programming
 
plsql.ppt
plsql.pptplsql.ppt
plsql.ppt
 
Object oriented approach to ALV Lists in ABAP
Object oriented approach to ALV Lists in ABAPObject oriented approach to ALV Lists in ABAP
Object oriented approach to ALV Lists in ABAP
 
Dialog Programming Overview
Dialog Programming OverviewDialog Programming Overview
Dialog Programming Overview
 
Module-Pool-Tutorial.pdf
Module-Pool-Tutorial.pdfModule-Pool-Tutorial.pdf
Module-Pool-Tutorial.pdf
 
Packages in PL/SQL
Packages in PL/SQLPackages in PL/SQL
Packages in PL/SQL
 
VIEWS
VIEWSVIEWS
VIEWS
 
Unit 4 - Basic ABAP statements, ABAP Structures and ABAP Logical Expressions
Unit 4 - Basic ABAP statements, ABAP Structures and ABAP Logical ExpressionsUnit 4 - Basic ABAP statements, ABAP Structures and ABAP Logical Expressions
Unit 4 - Basic ABAP statements, ABAP Structures and ABAP Logical Expressions
 
105322956 advance-pricing-total-oracle-apps
105322956 advance-pricing-total-oracle-apps105322956 advance-pricing-total-oracle-apps
105322956 advance-pricing-total-oracle-apps
 

En vedette

Computer programing
Computer programingComputer programing
Computer programingJT Taylor
 
Object-Oriented Programming 2
Object-Oriented Programming 2Object-Oriented Programming 2
Object-Oriented Programming 2Warawut
 
System software lecture infs429
System software lecture infs429System software lecture infs429
System software lecture infs429Edmund Sowah
 
Introduction to basic programming
Introduction to basic programmingIntroduction to basic programming
Introduction to basic programmingJordan Delacruz
 
The Basics of programming
The Basics of programmingThe Basics of programming
The Basics of programming692sfrobotics
 
Introduction to Computer and Programing - Lecture 04
Introduction to Computer and Programing - Lecture 04Introduction to Computer and Programing - Lecture 04
Introduction to Computer and Programing - Lecture 04hassaanciit
 
Basic programming concepts
Basic programming conceptsBasic programming concepts
Basic programming conceptssalmankhan570
 
Introduction to visual basic programming
Introduction to visual basic programmingIntroduction to visual basic programming
Introduction to visual basic programmingRoger Argarin
 
C Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpointC Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpointJavaTpoint.Com
 
Programming language
Programming languageProgramming language
Programming languageMakku-Sama
 
Beginning programming for dummies 3rd edition
Beginning programming for dummies 3rd editionBeginning programming for dummies 3rd edition
Beginning programming for dummies 3rd editionAndrea Filippo
 
Intro to Functional Programming
Intro to Functional ProgrammingIntro to Functional Programming
Intro to Functional ProgrammingJordan Parmer
 
Lect 1. introduction to programming languages
Lect 1. introduction to programming languagesLect 1. introduction to programming languages
Lect 1. introduction to programming languagesVarun Garg
 
Programming For Non-Programmers: 2013
Programming For Non-Programmers: 2013Programming For Non-Programmers: 2013
Programming For Non-Programmers: 2013Chris Castiglione
 

En vedette (20)

Computer Programing
Computer ProgramingComputer Programing
Computer Programing
 
Computer programing
Computer programingComputer programing
Computer programing
 
Programing techniques
Programing techniquesPrograming techniques
Programing techniques
 
Object-Oriented Programming 2
Object-Oriented Programming 2Object-Oriented Programming 2
Object-Oriented Programming 2
 
System software lecture infs429
System software lecture infs429System software lecture infs429
System software lecture infs429
 
Introduction to basic programming
Introduction to basic programmingIntroduction to basic programming
Introduction to basic programming
 
The Basics of programming
The Basics of programmingThe Basics of programming
The Basics of programming
 
Introduction to Computer and Programing - Lecture 04
Introduction to Computer and Programing - Lecture 04Introduction to Computer and Programing - Lecture 04
Introduction to Computer and Programing - Lecture 04
 
Programing Fundamental
Programing FundamentalPrograming Fundamental
Programing Fundamental
 
Basic programming concepts
Basic programming conceptsBasic programming concepts
Basic programming concepts
 
Basic programming
Basic programmingBasic programming
Basic programming
 
Introduction to visual basic programming
Introduction to visual basic programmingIntroduction to visual basic programming
Introduction to visual basic programming
 
Introduction to C Programming
Introduction to C ProgrammingIntroduction to C Programming
Introduction to C Programming
 
C Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpointC Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpoint
 
Computer Languages.
Computer Languages.Computer Languages.
Computer Languages.
 
Programming language
Programming languageProgramming language
Programming language
 
Beginning programming for dummies 3rd edition
Beginning programming for dummies 3rd editionBeginning programming for dummies 3rd edition
Beginning programming for dummies 3rd edition
 
Intro to Functional Programming
Intro to Functional ProgrammingIntro to Functional Programming
Intro to Functional Programming
 
Lect 1. introduction to programming languages
Lect 1. introduction to programming languagesLect 1. introduction to programming languages
Lect 1. introduction to programming languages
 
Programming For Non-Programmers: 2013
Programming For Non-Programmers: 2013Programming For Non-Programmers: 2013
Programming For Non-Programmers: 2013
 

Similaire à Basic programming

List Processing in ABAP
List Processing in ABAPList Processing in ABAP
List Processing in ABAPsapdocs. info
 
1582627
15826271582627
1582627tabish
 
ABAP Programming Overview
ABAP Programming OverviewABAP Programming Overview
ABAP Programming Overviewsapdocs. info
 
Abapprogrammingoverview 090715081305-phpapp02
Abapprogrammingoverview 090715081305-phpapp02Abapprogrammingoverview 090715081305-phpapp02
Abapprogrammingoverview 090715081305-phpapp02wingsrai
 
Chapter 1abapprogrammingoverview-091205081953-phpapp01
Chapter 1abapprogrammingoverview-091205081953-phpapp01Chapter 1abapprogrammingoverview-091205081953-phpapp01
Chapter 1abapprogrammingoverview-091205081953-phpapp01tabish
 
chapter-1abapprogrammingoverview-091205081953-phpapp01
chapter-1abapprogrammingoverview-091205081953-phpapp01chapter-1abapprogrammingoverview-091205081953-phpapp01
chapter-1abapprogrammingoverview-091205081953-phpapp01tabish
 
Chapter 1 Abap Programming Overview
Chapter 1 Abap Programming OverviewChapter 1 Abap Programming Overview
Chapter 1 Abap Programming OverviewAshish Kumar
 
Abapprogrammingoverview 090715081305-phpapp02
Abapprogrammingoverview 090715081305-phpapp02Abapprogrammingoverview 090715081305-phpapp02
Abapprogrammingoverview 090715081305-phpapp02tabish
 
Lab 3 Set Working Directory, Scatterplots and Introduction to.docx
Lab 3 Set Working Directory, Scatterplots and Introduction to.docxLab 3 Set Working Directory, Scatterplots and Introduction to.docx
Lab 3 Set Working Directory, Scatterplots and Introduction to.docxDIPESH30
 
Sap abap-data structures and internal tables
Sap abap-data structures and internal tablesSap abap-data structures and internal tables
Sap abap-data structures and internal tablesMustafa Nadim
 
Abap slides user defined data types and data
Abap slides user defined data types and dataAbap slides user defined data types and data
Abap slides user defined data types and dataMilind Patil
 
Abap programming overview
Abap programming overview Abap programming overview
Abap programming overview k kartheek
 
Open Gurukul Language PL/SQL
Open Gurukul Language PL/SQLOpen Gurukul Language PL/SQL
Open Gurukul Language PL/SQLOpen Gurukul
 
Open SQL & Internal Table
Open SQL & Internal TableOpen SQL & Internal Table
Open SQL & Internal Tablesapdocs. info
 
03 abap3-090715081232-phpapp01-100511101016-phpapp02
03 abap3-090715081232-phpapp01-100511101016-phpapp0203 abap3-090715081232-phpapp01-100511101016-phpapp02
03 abap3-090715081232-phpapp01-100511101016-phpapp02tabish
 

Similaire à Basic programming (20)

List Processing in ABAP
List Processing in ABAPList Processing in ABAP
List Processing in ABAP
 
1582627
15826271582627
1582627
 
ABAP Programming Overview
ABAP Programming OverviewABAP Programming Overview
ABAP Programming Overview
 
Abapprogrammingoverview 090715081305-phpapp02
Abapprogrammingoverview 090715081305-phpapp02Abapprogrammingoverview 090715081305-phpapp02
Abapprogrammingoverview 090715081305-phpapp02
 
Chapter 1abapprogrammingoverview-091205081953-phpapp01
Chapter 1abapprogrammingoverview-091205081953-phpapp01Chapter 1abapprogrammingoverview-091205081953-phpapp01
Chapter 1abapprogrammingoverview-091205081953-phpapp01
 
chapter-1abapprogrammingoverview-091205081953-phpapp01
chapter-1abapprogrammingoverview-091205081953-phpapp01chapter-1abapprogrammingoverview-091205081953-phpapp01
chapter-1abapprogrammingoverview-091205081953-phpapp01
 
Chapter 1 Abap Programming Overview
Chapter 1 Abap Programming OverviewChapter 1 Abap Programming Overview
Chapter 1 Abap Programming Overview
 
Abapprogrammingoverview 090715081305-phpapp02
Abapprogrammingoverview 090715081305-phpapp02Abapprogrammingoverview 090715081305-phpapp02
Abapprogrammingoverview 090715081305-phpapp02
 
Lab 3 Set Working Directory, Scatterplots and Introduction to.docx
Lab 3 Set Working Directory, Scatterplots and Introduction to.docxLab 3 Set Working Directory, Scatterplots and Introduction to.docx
Lab 3 Set Working Directory, Scatterplots and Introduction to.docx
 
Abap basics 01
Abap basics 01Abap basics 01
Abap basics 01
 
Sap abap-data structures and internal tables
Sap abap-data structures and internal tablesSap abap-data structures and internal tables
Sap abap-data structures and internal tables
 
Abap slides user defined data types and data
Abap slides user defined data types and dataAbap slides user defined data types and data
Abap slides user defined data types and data
 
Sql
SqlSql
Sql
 
Tables in dd
Tables in ddTables in dd
Tables in dd
 
Abap programming overview
Abap programming overview Abap programming overview
Abap programming overview
 
04 pig data operations
04 pig data operations04 pig data operations
04 pig data operations
 
Open Gurukul Language PL/SQL
Open Gurukul Language PL/SQLOpen Gurukul Language PL/SQL
Open Gurukul Language PL/SQL
 
Awk programming
Awk programming Awk programming
Awk programming
 
Open SQL & Internal Table
Open SQL & Internal TableOpen SQL & Internal Table
Open SQL & Internal Table
 
03 abap3-090715081232-phpapp01-100511101016-phpapp02
03 abap3-090715081232-phpapp01-100511101016-phpapp0203 abap3-090715081232-phpapp01-100511101016-phpapp02
03 abap3-090715081232-phpapp01-100511101016-phpapp02
 

Plus de Jugul Crasta

Plus de Jugul Crasta (9)

SAP Adobe forms
SAP Adobe formsSAP Adobe forms
SAP Adobe forms
 
SAP ALE Idoc
SAP ALE IdocSAP ALE Idoc
SAP ALE Idoc
 
SAP Smart forms
SAP Smart formsSAP Smart forms
SAP Smart forms
 
Sap scripts
Sap scriptsSap scripts
Sap scripts
 
SAP Batch data communication
SAP Batch data communicationSAP Batch data communication
SAP Batch data communication
 
SAP Modularization techniques
SAP Modularization techniquesSAP Modularization techniques
SAP Modularization techniques
 
Sap abap
Sap abapSap abap
Sap abap
 
Sap architecture
Sap architectureSap architecture
Sap architecture
 
Sap erp introduction
Sap erp introductionSap erp introduction
Sap erp introduction
 

Dernier

EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 

Dernier (20)

EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 

Basic programming

  • 2. • WRITE : 1. Use to print the output. 2. Ex: a) write : ‘Donald’. b) Write : ‘Donald’ , ‘Sap abap’. c) Write : ‘Donald ‘ , / ‘Sap abap’. d) Write : ‘Donald ‘ , / ‘Sap abap’ color 2. (1-7) e) Write : 30 ‘Donald ‘ , / ‘Sap abap’. f) Write : 30 ‘Donald ‘ , / 30 ‘Sap abap’. g) Write : 30 ‘Donald ‘ , / , /30 ‘Sap abap’. or Write : 30 ‘Donald ‘ . skip. write : ‘Sap abap’. a) Skip 10.
  • 3. Parameters : • To provide the input option to the user. • Ex : parameters : p_name type c. write : p_name. • Every program is having 3 screens. 1. ABAP Editor 2. Selection Screen 3. Output Screen Data: • Used to declare variables. ex : data : p3 type i. SELECT-OPTIONS : To provide the range input option to the user. Ex: select-options : p_vbeln for VBAK-vbeln.
  • 4. Data Declaration Data Type Description Length Declaration Default Value C CHAR REQUIRE VAR(10) TYPE C SPACE I INT --- VAR TYPE I 0 N NUM REQUIRE VAR(3) TYPE N 000 D DATE ----- VAR TYPE D 00000000 T TIME --------- VAR TYPE T 000000 F FLOAT (MAX 8) VAR TYPE F 0.0000000000 0E+00 P PACKED DECIMAL (MAX 16) VAR TYPE P DECIMAL 2 0.00 X XSTRING ----- VAR TYPE X 00 STRING STRING -------- VAR TYPE STRING SPACE
  • 5. Control Break Statements: 1. Do --- endo. 2. While -- endwhile. 3. If.. Endif. 4. Case … endcase. 5. If…. Elseif … elseif … endif.
  • 6. Do enddo • Ex: Data : count type I. Parameters : num type I. count = 1. Do num times. write : / count. count = count + 1. enddo.
  • 7. While .. Endwhile • Ex: DATA: COUNT TYPE I. PARAMETERS : NUM TYPE I. COUNT = 1. WHILE COUNT <= NUM . WRITE : / COUNT . COUNT = COUNT + 1. ENDWHILE.
  • 8. If … endif • Ex: PARAMETERS : SAL TYPE I. IF SAL > 25000. WRITE : 'software engineer'. ENDIF.
  • 9. If… else … endif • Ex : PARAMETERS : SAL TYPE I. IF SAL > 25000. WRITE : 'software engineer'. else. WRITE : 'Support Engineer'. ENDIF.
  • 10. Case .. endcase • Ex: PARAMETERS: color TYPE i. CASE COLOR. WHEN '1'. WRITE 'color 1' COLOR 1. WHEN '2'. WRITE 'color 2' COLOR 2. WHEN '3'. WRITE 'color 3' COLOR 3. WHEN '4'. WRITE 'color 4' COLOR 4. WHEN '5'. WRITE 'color 5' COLOR 5. WHEN OTHERS. WRITE : 'color not found'. ENDCASE.
  • 11. System Variables • SY-DATUM : System date. • SY-UZEIT : System time • SY-CPROG: Current program name • SY-REPID: Current program name • SY-UNAME: System username • SY-LANGU: System language • SY-LINNO: Current line number • SY-ULINE: Horizontal line • SY-VLINE: Vertical Line • SY-TCODE : Current Transaction code All the system variable available in structure SYST • SY-SUBRC : returns 0 if previous statement executed successfully. • SY-TABIX: Stores internal table index. • SY-INDEX : Can be used as a counter in the loops. • SY-LSIND : returns list index.
  • 12. Operation on string • Concatenate : Used to combine the character. • Ex: data: name(20) TYPE c. PARAMETERS : name1(10) TYPE c, name2(10) TYPE c. CONCATENATE name1 name2 INTO name. WRITE name.
  • 13. • Separated by : To maintain the space between 2 strings. Ex: data: name(20) TYPE c. PARAMETERS : name1(10) TYPE c, name2(10) TYPE c. CONCATENATE name1 name2 INTO name SEPARATED BY space. WRITE name.
  • 14. • Alignments • RIGHT-JUSTIFIED AND LEFT-JUSTIFIED : • By default always characters are left justified and numbers are right justified. Ex : PARAMETERS : name(10) TYPE c, num TYPE i. WRITE : name COLOR 2 RIGHT-JUSTIFIED, / num COLOR 3 LEFT-JUSTIFIED. CENTERED : PARAMETERS : name(10) TYPE c, num TYPE i. WRITE : name COLOR Centered , / num COLOR 3 LEFT-JUSTIFIED.
  • 15. • Split : Using to split. Ex: data: var1(10) TYPE c, var2(10) TYPE c. PARAMETERS : p_name(20) TYPE c. SPLIT p_name at '.' INTO var1 var2. WRITE : / var1, / var2 .
  • 16. • Replace : It replace only 1st occurrence in string. Ex: PARAMETERS : p_name(20) TYPE c. REPLACE 'A' WITH 'B' into p_name. WRITE : p_name.
  • 17. • Replace all occurrences of : To replace the all the occurrence of given string. • Ex : PARAMETERS : p_name(20) TYPE c. REPLACE ALL OCCURRENCES OF 'A' in p_name WITH 'B'. WRITE : p_name.
  • 18. • TRANSLATE : It works similar to replace all occurrences of PARAMETERS : p_text(20) TYPE c. TRANSLATE p_text USING 'AB'. WRITE : p_text.
  • 19. • Offset : Splitting based on position. Ex : DATA : p1(10) TYPE c, p2(10) TYPE c. PARAMETERS : p_text(10) TYPE c. p1 = p_text(2). p2 = p_text+2(8). WRITE : / p1 , / p2.
  • 20. • CONDENSE : Ex : PARAMETERS : k(5) TYPE c. CONDENSE k NO-GAPS. WRITE : k . • NO-GAP : Use to remove the gap. Ex: WRITE : 'jugul' , 'donald'. WRITE : / 'jugul' NO-GAP, 'donald'. • NO-ZERO : Use to remove zero’s. Ex : PARAMETERS : k(5) TYPE n. WRITE : k no-zero.
  • 21. Structures • Structures are combination of different variables or types. • Syntax : types : Begin of <structure name>, ------ ------ End of <structure name>.
  • 22. Ex : Types: Begin of ABC, name(10) type c, DOB type d, age(2) type c, End of ABC. A variable which has been declared with reference of structure is Know as Work Area. DATA: WA type ABC. • Assigning value to Work area. WA-NAME = ‘STEVE’. WA-DOB = ‘22-07-1990’. WA-AGE = ’26’. WRITE : / WA-NAME , WA-DOB, WA-AGE.
  • 23. • Clear : Clear is used to clear the content of variable. TYPES : BEGIN OF T_STD, NAME(20) TYPE C, AGE TYPE I, CLASS TYPE I, END OF T_STD. DATA : WA TYPE T_STD. WA-NAME = 'DONALD'. WA-AGE = 25. WA-CLASS = 2. WRITE : / WA-NAME , WA-AGE ,WA-CLASS. CLEAR WA. WA-NAME = 'JUGUL'. WA-CLASS = 3. WRITE : / WA-NAME , WA-AGE ,WA-CLASS.
  • 24. Internal Table • Internal table is like table which can be able to hold multiple records. • Syntax : < variable name> type table of <structure/table name >. Ex : TYPES : BEGIN OF T_STD, NAME(20) TYPE C, AGE TYPE I, CLASS TYPE I, END OF T_STD. DATA : WA TYPE T_STD, ITAB TYPE TABLE OF T_STD.
  • 25. WA-NAME = 'DONALD'. WA-AGE = 25. WA-CLASS = 2. • Append is used to append the record from work area to internal table. APPEND WA TO ITAB. CLEAR WA. WA-NAME = 'JUGUL'. WA-CLASS = 3. APPEND WA TO ITAB. CLEAR WA. • To access data from internal table . LOOP AT ITAB INTO WA. WRITE : / WA-NAME ,WA-AGE , WA-CLASS. ENDLOOP.
  • 26. To select record from Database table into work Area. • Ex: DATA : WA TYPE ZSTUD. SELECT SINGLE * FROM ZSTUD INTO WA WHERE STUDID = '124'. WRITE:/ WA-STUDID , WA-DEPARTID1, WA-STUDNAME , WA- FEES.
  • 27. Corresponding fields of • Used to place the selected fields at corresponding fields in WA/internal table. • Ex : DATA : WA TYPE ZSTUD. SELECT SINGLE DEPARTID1 STUDNAME FROM ZSTUD INTO CORRESPONDING FIELDS OF WA WHERE STUDID = '124'. WRITE:/ WA-DEPARTID1, WA-STUDNAME . • If we want to put data into work area , then we have to use single in our selection statement. • Using corresponding fields of in program reduces the performance.
  • 28. • How to avoid ? Ans : create the structure for required field. Ex : TYPES: BEGIN OF T_STD, DEPARTID1(2) TYPE C, STUDNAME(60) TYPE C, END OF T_STD. DATA: WA TYPE T_STD. SELECT SINGLE DEPARTID1 STUDNAME FROM ZSTUD INTO WA WHERE STUDID = '124'. WRITE:/ WA-DEPARTID1, WA-STUDNAME .
  • 29. • In structure instead of assigning data type and length ,we can also assign the database table and field name. Ex: TYPES: BEGIN OF T_STD, DEPARTID1 TYPE ZSTUD-DEPARTID1, STUDNAME TYPE ZSTUD-STUDNAME, END OF T_STD. DATA: WA TYPE T_STD. SELECT SINGLE DEPARTID1 STUDNAME FROM ZSTUD INTO WA WHERE STUDID = '124'. WRITE:/ WA-DEPARTID1, WA-STUDNAME .
  • 30. • Also we can do it, by assigning data element directly. • Ex: TYPES: BEGIN OF T_STD, DEPARTID1 TYPE ZDEPID, STUDNAME TYPE ZSTUDNAME1, END OF T_STD. DATA: WA TYPE T_STD. SELECT SINGLE DEPARTID1 STUDNAME FROM ZSTUD INTO WA WHERE STUDID = '124'. WRITE:/ WA-DEPARTID1, WA-STUDNAME .
  • 31. • Using parameter: Ex : TYPES: BEGIN OF T_STD, DEPARTID1 TYPE ZDEPID, STUDNAME TYPE ZSTUDNAME1, END OF T_STD. DATA: WA TYPE T_STD. PARAMETERS : STUID TYPE ZSTUD-STUDID. SELECT SINGLE DEPARTID1 STUDNAME FROM ZSTUD INTO WA WHERE STUDID = STUID. WRITE:/ WA-DEPARTID1, WA-STUDNAME .
  • 32. Select ---- EndSelect • Used to select multiple records directly from database table. Ex : DATA : WA TYPE MAKT. PARAMETERS : P_MATNR TYPE MAKT-MATNR. SELECT * FROM MAKT INTO WA WHERE MATNR = P_MATNR. WRITE : / WA-MATNR , WA-SPRAS, WA-MAKTX, WA-MAKTG. ENDSELECT. • It fetches records multiple time from database table. So it reduces the performance.
  • 33. Internal Table Ex: DATA : WA TYPE MAKT, ITAB TYPE TABLE OF MAKT. PARAMETERS : P_MATNR TYPE MAKT-MATNR. SELECT * FROM MAKT INTO TABLE ITAB WHERE MATNR = P_MATNR. LOOP AT ITAB INTO WA. WRITE : / WA-MATNR , WA-SPRAS, WA-MAKTX, WA-MAKTG. ENDLOOP. Note : if there is no composite key , then work area is sufficient to fetch data from database.
  • 34. Fetching data from 2 tables. • Ex : TYPES : BEGIN OF T_VBAP, VBELN TYPE VBAP-VBELN, POSNR TYPE VBAP-POSNR, MATNR TYPE VBAP-MATNR, END OF T_VBAP. DATA : ITAB TYPE TABLE OF T_VBAP, WA TYPE T_VBAP, WA1 TYPE MAKT. PARAMETERS : P_VBELN TYPE VBAP-VBELN. SELECT VBELN POSNR MATNR FROM VBAP INTO TABLE ITAB WHERE VBELN = P_VBELN. LOOP AT ITAB INTO WA. WRITE : / WA-VBELN , WA-POSNR , WA-MATNR. SELECT SINGLE * FROM MAKT INTO WA1 WHERE MATNR = WA-MATNR AND SPRAS = 'EN'. WRITE : WA1-MAKTX. ENDLOOP. Note: It reduces the performance . Because within the loop fetching data from database number of times.
  • 35. Inner JoinEx: TYPES : BEGIN OF T_STR, VBELN TYPE VBAP-VBELN, POSNR TYPE VBAP-POSNR, MATNR TYPE VBAP-MATNR, MAKTX TYPE MAKT-MAKTX, END OF T_STR. DATA : ITAB TYPE TABLE OF T_STR, WA TYPE T_STR. PARAMETERS : P_VBELN TYPE VBAP-VBELN. SELECT VBELN POSNR A~MATNR MAKTX INTO TABLE ITAB FROM VBAP AS A INNER JOIN MAKT AS B ON B~MATNR = A~MATNR WHERE VBELN = P_VBELN AND SPRAS = 'EN'. LOOP AT ITAB INTO WA. WRITE : / WA-VBELN , WA-POSNR , WA-MATNR , WA-MAKTX. ENDLOOP. Note : Whenever tables are less than or equal 3 go for inner join technique.
  • 36. For all entries in Ex : TYPES : BEGIN OF T_VBAP, VBELN TYPE VBAP-VBELN, POSNR TYPE VBAP-POSNR, MATNR TYPE VBAP-MATNR, END OF T_VBAP. TYPES : BEGIN OF T_MAKT, MATNR TYPE MAKT-MATNR, MAKTX TYPE MAKT-MAKTX, END OF T_MAKT. TYPES : BEGIN OF T_FINAL, VBELN TYPE VBAP-VBELN, POSNR TYPE VBAP-POSNR, MATNR TYPE VBAP-MATNR, MAKTX TYPE MAKT-MAKTX, END OF T_FINAL. DATA : WA TYPE T_VBAP, ITAB TYPE TABLE OF T_VBAP, WA1 TYPE T_MAKT, ITAB1 TYPE TABLE OF T_MAKT, WA2 TYPE T_FINAL, ITAB2 TYPE TABLE OF T_FINAL. PARAMETERS : P_VBELN TYPE VBAP-VBELN.
  • 37. START-OF-SELECTION. SELECT VBELN POSNR MATNR FROM VBAP INTO TABLE ITAB WHERE VBELN = P_VBELN . IF ITAB IS NOT INITIAL. SELECT MATNR MAKTX FROM MAKT INTO TABLE ITAB1 FOR ALL ENTRIES IN ITAB WHERE MATNR = ITAB-MATNR AND SPRAS = 'EN'. ENDIF. LOOP AT ITAB INTO WA. WA2-VBELN = WA-VBELN. WA2-POSNR = WA-POSNR. WA2-MATNR = WA-MATNR. CLEAR WA1. READ TABLE ITAB1 INTO WA1 WITH KEY MATNR = WA-MATNR. If sy-subrc = 0. WA2-MAKTX = WA1-MAKTX. Endif. APPEND WA2 TO ITAB2. ENDLOOP. LOOP AT ITAB2 INTO WA2. WRITE : / WA2-VBELN , WA2-POSNR , WA2-MATNR , WA2-MAKTX. ENDLOOP.
  • 38. • Note : 1. Check the for all entries table is not empty . 2. Write all key field in selection criteria. 3. Data type and length of for all entries matching field should be match for both the table.
  • 39. • Important : Read table. 1. Clear the work area before read the table. 2. After reading table use sy-subrc . 3. To improve the performance use Binary search in read statement. Ex : READ TABLE ITAB1 INTO WA1 WITH KEY MATNR = WA- MATNR binary search. * before the loop sort the internal table. sort itab1 by matnr.
  • 40. Different Types of Internal Table • Based on header line internal tables are classified into 2 types: • Header Line nothing but work area. 1. Internal table with header line . 2. Internal table without header line. • Internal table without header line Ex: Types : begin of stru, name(20) type c, age(2) type c, end of stru. Data: wa type stru, itab type table of stru.
  • 41. • Internal table with header line. Ex Types : begin of stru, name(20) type c, age(2) type c, end of stru. Data: itab type table of stru with header line. Itab-name = ‘Donald’. Itab-age = 25. Append itab. Loop at itab. write : / itab-name , itab-age. Endloop.
  • 42. • Based on sorting technique internal tables can divided 3 types. 1. Standard internal table. 2. Sorted internal table. 3. Hashed internal table. • By default any internal table is standard internal table. 1. Standard internal table. • This is follows linear search(one by one) algorithm. • Searching time is proportional to number of records. • Syntax: Data : <internal table > TYPE STANDARD TABLE OF <TB /STR name> WITH NON-UNIQUE KEY <key > WITH HEADER LINE. <optional>
  • 43. • Sorted internal tables : 1. This is follows binary search help. 2. It supports unique as well as no-unique key. 3. Syntax : Data : <internal table > TYPE SORTED TABLE OF <tab/str name> WITH <UNIQUE / non-unique > KEY <keyname> WITH HEADER LINE . <optional >
  • 44. • Hashed internal table. 1. There is no non-unique key. 2. Its follows index based search. 3. Syntax : Data : <internal table > TYPE HASHED TABLE OF <TB/STR NAME> WITH UNIQUE KEY <KEY> WITH HEADER LINE. <OPTIONAL>