write statement
--------------------
Tcode --> se38
program --> starts with z or y ex:zajay_prog.
title --> prints in output screen title
type --> most may be executable program.
example:
~~~~~~~~
REPORT ZAJAY_PROG.
write 'hello world'.
output: hello world
------
______________________________________________
chain operator [:]
----------------------
actual program
~~~~~~~~~~~~~~~
write / 'heelo'.
write / 'ajay babu'.
write / 'bye'.
using chain operator
~~~~~~~~~~~~~~~~~~~~~
write : 'hello', / 'ajay babu',/ 'bye'.
_____________________________________________________________________
write : 'heelo', / 'ajay babu',/ 'bye'.
skip 5.
write : 10 'heelo', / 'ajay babu',/ 'bye'.
/ --> indicates new line
skip 5 --> indicates skips 5 lines gap.
10 --> horizontal space line.
__________________________________________________
format color
----------------
write : 'heelo', / 'ajay babu',/ 'bye'.
skip 5.
FORMAT color 5.
write : 4 'heelo', / 'ajay babu',/ 'bye'.
format color off.
1-6 colors.
write 'hello' color 5.
__________________________________________________________
system fields
----------------
sy --> syantax for syatem fields.
example
~~~~~~~
write : 'current date is ',sy-datum.
write : 'current time ',sy-uzeit.
write : 'username ',sy-uname.
output
~~~~~~
current date is 05.07.2023
current time 05:34:23
username ABAP_EDITOR
____________________________________________________________
# variable
------------
--> use 'data 'keyword to declare variable.
example
~~~~~~~
data lv_v1 type i.
write: 'default value',lv_v1.
example 2
~~~~~~~~~
data: lv_v1 type i, lv_v2(10) type c , lv_v3 type string.
write: 'default value of integer',lv_v1,
/ 'default value of character',lv_v2,
/ 'default value of string',lv_v3.
ULINE.
lv_v1 = 10.
lv_v2 = 'ajay'.
lv_v3 = 'hello world'.
write: 'after assign value of integer',lv_v1,
/ 'after assign value of character',lv_v2,
/ 'after assign value of string',lv_v3.
ULINE.
write: / 'left assign value of integer',lv_v1 left-JUSTIFIED.
write: / 'right assign value of integer',lv_v1 right-JUSTIFIED.
write: / 'center assign value of integer',lv_v1 centered.
CONSTANTS lv_v4 type i value 100.
ULINE.
write lv_v4.
output
~~~~~~~
default value of integer 0
default value of character
default value of string
______________________________________
after assign value of integer 10
after assign value of character ajay
after assign value of string hello world
__________________________________________
left assign value of integer 10
right assign value of integer 10
center assign value of integer 10
__________________________________________
100
# taking input from user
------------------------------
example
~~~~~~~~
PARAMETERS p_val type i.
write : 'user entered value is ', p_val.
input
~~~~~
100
output
~~~~~~
user entered value is 100
# selection text
~~~~~~~~~~~~
example
----------
REPORT ZAJAY_PRACTICE.
PARAMETERS: p_number type i .
if p_number mod 2 eq 0.
write 'even number'.
else.
write 'odd number'.
ENDIF.
--> more-->text elements --> selection text -->in selection text 'enter the positive number'
output
-------
enter the positive number [ ]
__________________________________________________________
#condense
~~~~~~~~
--> It is used to remove the leading and trailing spaces from a string.
example
--------
data lv_d1 type string value 'hello , ajay babu varikallu '.
write : / 'Before condense--> ',lv_d1.
CONDENSE lv_d1.
write : / 'After condense--> ',lv_d1.
output
-------
Before condense--> hello , ajay babu varikallu
After condense--> hello , ajay babu varikallu
____________________________________________________________
# concatenate
~~~~~~~~~~~~
--> combine two or more strings.
example
--------
data lv_d1 type string value 'hello'.
data lv_d2 type string value 'ajay babu'.
data lv_d3 type string.
CONCATENATE lv_d1 lv_d2 into lv_d3 separated by ','.
write : / 'After concatenate--> ',lv_d3.
output
-------
After concatenate--> hello,ajay babu
_______________________________________________________
# split
~~~~~~
--> used to separate string into smaller sub strings.
example
-------
data lv_d1 type string value 'hello / ajay babu / varikallu'.
data lv_d2 type string.
data lv_d3 type string.
data lv_d4 type string.
write : / 'before split d1-- > ',lv_d1,
/ 'before split d2-- > ',lv_d2,
/ 'before split d3 -- > ',lv_d3,
/ 'before split d4-- > ',lv_d4.
split lv_d1 at '/' into lv_d2 lv_d3 lv_d4.
write : / 'after split d1-- > ',lv_d1,
/ 'after split d2-- > ',lv_d2,
/ 'after split d3 -- > ',lv_d3,
/ 'after split d4-- > ',lv_d4.
output
------
before split d1-- > hello / ajay babu / varikallu
before split d2-- >
before split d3 -- >
before split d4-- >
after split d1-- > hello / ajay babu / varikallu
after split d2-- > hello
after split d3 -- > ajay babu
after split d4-- > varikallu
________________________________________________________________________
# string length
~~~~~~~~~~
--> find length of string.
--> strlen.
example
-------
data lv_d1 type string value 'this is abab'.
write : / 'length of string is--> ',strlen( lv_d1 ).
output
------
length of string is--> 12
______________________________________________________________________
# Translate
~~~~~~~~~
--> convert the strings.
example
--------
data lv_d1 type string value 'this is abab'.
TRANSLATE lv_d1 to upper case.
write : / 'upper case-->' , lv_d1.
output
------
upper case--> THIS IS ABAB
________________________________________________________________________
# Find
~~~~~~
--> to find the position of sub string.
example
-------
data lv_d1 type string value 'this is abap'.
data lv_index type i.
find 'abap' in lv_d1 match offset lv_index.
write : 'index is ' , lv_index.
output
-------
index is 8
example
-------
data lv_d1 type string value 'this is abap'.
data lv_index type i.
find 'abap' in lv_d1 match offset lv_index.
if sy-subrc = 0.
write :'find is execued'.
ELSE.
write:/ 'find is not execued'.
endif.
output
-------
find is execued
_______________________________________________________________________
# Replace
~~~~~~~~~
--> replace all occurences of a sub string.
example
-------
data lv_d1 type string value 'this is abap'.
replace 'abap' in lv_d1 with 'ajay'.
write : / 'after replace--> ',lv_d1.
output
-------
after replace--> this is ajay
example
-------
data lv_d1 type string value 'this is abap welcome to abap'.
replace 'abap' in lv_d1 with 'ajay'.
write : / 'after replace--> ',lv_d1.
output
-------
after replace--> this is ajay welcome to abap
example
-------
data lv_d1 type string value 'this is abap welcome to abap'.
replace all occurrences of 'abap' in lv_d1 with 'ajay'.
write : / 'after replace--> ',lv_d1.
output
-------
after replace--> this is ajay welcome to ajay
_______________________________________________________________
# shift
~~~~~~~
--> to shift a part of string a specified number of characters to the left or right or circular.
left example
------------
data lv_num(20) type c value '123456789'.
write :/' before shift--> ',lv_num.
shift lv_num left by 3 places.
write :/' after shift--> ',lv_num.
output
-------
before shift--> 123456789
after shift--> 456789
right example
-------------
data lv_num(20) type c value '123456789'.
write :/' before shift--> ',lv_num.
shift lv_num right by 3 places.
write :/' after shift--> ',lv_num.
output
------
before shift--> 123456789
after shift--> 123456789
circular example
-----------------
data lv_num(9) type c value '123456789'.
write :/' before shift--> ',lv_num.
shift lv_num circular by 3 places.
write :/' after shift--> ',lv_num.
output
-------
before shift--> 123456789
after shift--> 456789123
_______________________________________________________________________
# increse limit of active sessions
1) se38
2) give program name --> rspfldoc
3) execute ask parameter name 'rdisp/max_alt_modes'.
4) expansion level current vale is 6.
5) top click 'change value' and give new value is '10'.
_________________________________________________________________________
# shortcut keys
~~~~~~~~~~~~~
--> create new session -- ctrl + shift '+'.
--> go back last screen -- f3.
--> go back and logoff --> shift+ f3.
--> switch between the tabs -->alt + tab.
--> information about any field --> f1.
--> to execute -- f8.
--> goto command field --ctrl + /
--> same tab open tcode -- /n<t-code>
--> open new tab tcode -- /o<t-code>
_________________________________________________________________________
# field symbol
~~~~~~~~~~~
--> stores any type of data.
example
-------
data lv_abc type i.
lv_abc = 100.
write :/ 'lv_abc value-->',lv_abc.
field-symbols <fs>. " must enclosed with < >
*<fs> = 100. " runtime error
assign lv_abc to <fs>.
write :/ 'lv_abc--> ',lv_abc.
output
------
lv_abc value--> 100
lv_abc--> 100
Comments
Post a Comment