1 of 51

SAP S/4

ABAP Programming

for non-Technical Users

Create ABAP Program with

Simple Selection Screen

a look at ABAP syntax

PARAMETERS, NEW-LINE,

and WRITE

2 of 51

  1. Results desired (SE38).
  2. Start coding new ABAP program “ZABAP002” (SE38).
  3. Create t-code ZABAP002” for the ABAP Program & Test it (SE93).
  4. Change the ABAP Editor Settings (SE38).
  5. Test the new ABAP Editor Settings (SE38).
  6. Test the Program T-code again (ZABAP002).

3 of 51

Write an ABAP program to request INPUT from User and upon F8 (execute) to return the results below

4 of 51

  • Results desired (SE38).
  • Start coding new ABAP program “ZABAP002” (SE38).
  • Create t-code ZABAP002” for the ABAP Program & Test it (SE93).
  • Change the ABAP Editor Settings (SE38).
  • Test the new ABAP Editor Settings (SE38).
  • Test the Program T-code again (ZABAP002).

5 of 51

Write ABAP code

Syntax Check

Save

Activate

Test

Change ABAP code

Write Documentation

The sequence of

  1. Syntax Check
  2. Save
  3. Activate

is important

whenever

  • Writing ABAP code
  • Change ABAP code
  • Write Documentation

6 of 51

Enter Program name and

click Create

(note, Program name should start with character

Y or Z)

7 of 51

new Package can be defined in SE80 (Object Navigator)

An ABAP package is a transportable ABAP repository object that groups development objects (reports, transactions, and function modules etc) of an ABAP system.

8 of 51

Write ABAP code

Syntax Check

Save

Activate

Test

Change ABAP code

Write Documentation

the Program is set with “Inactive” status at the beginning

2 defaulted sections:

This is the Documentation Area (not executable) and starts with *&

2 defaulted sections:

Program Name behind the word REPORT

9 of 51

Syntax

PARAMETERS variable_name TYPE [variable type].

Definition

  • PARAMETERS are components of a selection screen that are assigned a global elementary data object in the ABAP program and an input field on the selection screen.
  • The variable_name can only be maximum of 8 characters.

Full-stop is required at the END of a Statement.

10 of 51

Syntax

WRITE: ‘text string’, variable_name.

Definition

  • This statement formats the content of the data object and writes it to the current page of the current list.

11 of 51

Syntax

NEW-LINE.

Definition

  • The statement NEW-LINE is executed implicitly at the end of an event block (the statements above); it creates a line-break, that is to say that the next WRITE: results are displayed on the next line.

12 of 51

Write ABAP code

Syntax Check

Save

Activate

Test

Change ABAP code

Write Documentation

Perform

Syntax Check. (any code errors will show as RED in the bottom segment of the screen).

13 of 51

Write ABAP code

Syntax Check

Save

Activate

Test

Change ABAP code

Write Documentation

SAVE. (or Activate & SAVE).

14 of 51

Write ABAP code

Syntax Check

Save

Activate

Test

Change ABAP code

Write Documentation

ACTIVATE is necessary for any changes in the Source Code and Text Elements.

15 of 51

Write ABAP code

Syntax Check

Save

Activate

Test

Change ABAP code

Write Documentation

DIRECT PROCESSING is to Execute the Program

16 of 51

user input

Execute

17 of 51

click BACK twice to return to the Editor

Results as expected

18 of 51

at end of Line 3, press Enter to add a line

Write ABAP code

Syntax Check

Save

Activate

Test

Change ABAP code

Write Documentation

at the new line 4, enter ‘*&’

meaning comment line (which is not evaluated for syntax correctness)

19 of 51

Type whatever documentation text

20 of 51

with cursor on end of line 11,

press ENTER

5 times to insert

5 empty lines

21 of 51

note 5 lines inserted,

this is just for more documentation

22 of 51

enter the Comment lines as needed (starts with *&)

Write ABAP code

Syntax Check

Save

Activate

Test

Change ABAP code

Write Documentation

Before next segment, these 3 steps were done

23 of 51

  • Results desired (SE38).
  • Start coding new ABAP program “ZABAP002” (SE38).
  • Create t-code ZABAP002” for the ABAP Program & Test it (SE93).
  • Change the ABAP Editor Settings (SE38).
  • Test the new ABAP Editor Settings (SE38).
  • Test the Program T-code again (ZABAP002).

24 of 51

new

T-code

with input/selection screen

T-code

Text

25 of 51

the new Program name

SAVE

SAP GUI for the HTML, Java, and Windows Environment where this Program can be executed.

26 of 51

Add the new t-code to the Favorite via Right click and select “Insert Transaction”.

27 of 51

28 of 51

  • Results desired (SE38).
  • Start coding new ABAP program “ZABAP002” (SE38).
  • Create t-code ZABAP002” for the ABAP Program & Test it (SE93).
  • Change the ABAP Editor Settings (SE38).
  • Test the new ABAP Editor Settings (SE38).
  • Test the Program T-code again (ZABAP002).

29 of 51

Perform some settings in the ABAP Editor for coding assistance …

30 of 51

click this to made changes in the Settings

just click on line 1 (note the color of the current line cursor on is white)

31 of 51

In the “Fonts and Colors” Options, note in the Display Items “Current line” “Item Background” is now WHITE as check in the previous screen. (note this is not the text but the SPACE of the line).

32 of 51

change it

to GREEN

33 of 51

change the FONT size from 10 to 12

34 of 51

preview of the Background Color of “Current line” and Size is 12

35 of 51

example of Non-Keywords are like the field z_age

36 of 51

Switch on “Suggest Non-Keywords (example are like variables) from the Text”,

eg: when entering new code like example the character “z_”; the system will suggest “z_age” and any other words in the program that contain “z_”....

37 of 51

when entering up to 2 characteristics, system will show hints eg: keywords entered

system will hide the Key word after 3000 msec

38 of 51

When type keywords of 5 or less character, the system will show HINT of a possible keyword in the dictionary but remain 9000 msec before it is hidden

39 of 51

  • Results desired (SE38).
  • Start coding new ABAP program “ZABAP002” (SE38).
  • Create t-code ZABAP002” for the ABAP Program & Test it (SE93).
  • Change the ABAP Editor Settings (SE38).
  • Test the new ABAP Editor Settings (SE38).
  • Test the Program T-code again (ZABAP002).

40 of 51

note the cursor is now on Line 26, the Background color of the “Current line” is now GREEN

Font size is now 12 instead of 10

41 of 51

when typing 5 or below characters, the system will suggest ABAP syntax keyword (note yellow above ‘para’ shows the PARAMETERS syntax suggestion) and remain for 9000 ms until it is hidden… user can press TAB and system will append the entire keyword

Write ABAP code

Syntax Check

Save

Activate

Test

Change ABAP code

Write Documentation

note yellow above ‘para’ as the word ‘para’ is typed, user can just TAB to fill up the suggested keyword automatically.

42 of 51

current version S/4 2022, field character max size is 8 for PARAMETER syntax

z_country is 9 characters

Write ABAP code

Syntax Check

Save

Activate

Test

Change ABAP code

Write Documentation

SYNTAX check

43 of 51

change

z_from to

z_city

change

z_country to z_from

change

z_from to

z_city

Close

Write ABAP code

Syntax Check

Save

Activate

Test

Change ABAP code

Write Documentation

44 of 51

note as z_ is typed (current line GREEN), system suggest z_from (which is a non-keyword), user can click TAB to auto fill the variable z_from

45 of 51

also amended some documentation)

system will OUTPUT

the z_from value entered

and follow up with a dot.

Write ABAP code

Syntax Check

Save

Activate

Test

Change ABAP code

Write Documentation

46 of 51

Syntax

Write ABAP code

Syntax Check

Save

Activate

Test

Change ABAP code

Write Documentation

47 of 51

Save

Write ABAP code

Syntax Check

Save

Activate

Test

Change ABAP code

Write Documentation

48 of 51

Activate

Write ABAP code

Syntax Check

Save

Activate

Test

Change ABAP code

Write Documentation

49 of 51

  • Results desired (SE38).
  • Start coding new ABAP program “ZABAP002” (SE38).
  • Create t-code ZABAP002” for the ABAP Program & Test it (SE93).
  • Change the ABAP Editor Settings (SE38).
  • Test the new ABAP Editor Settings (SE38).
  • Test the Program T-code again (ZABAP002).

50 of 51

You can test run in SE38 as well

Write ABAP code

Syntax Check

Save

Activate

Test

Change ABAP code

Write Documentation

51 of 51