abap slides set1

38
ABAP Workshop 2009 - Part1

Upload: mkpatil

Post on 07-Nov-2014

1.935 views

Category:

Technology


3 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Abap slides set1

ABAP Workshop2009 - Part1

Page 2: Abap slides set1

2

Topics• Program Types• Dialog Program and DYNPROs• Program Flow and Flow Events• DYNPRO data elements Vs. ABAP data elements• FIELD Command and Conditional Module Calls• CHAIN Command• TAB controls• Field, Data Element and Domains• Input Help (List of Values) –demo/coding• Field Help (F1 Help) –demo/coding• Understanding Menu Bar, Application Toolbar and Function keys• Menu Control and Function Keys• Context Menu• Title Bar• Demo• Hands-on Practice

Page 3: Abap slides set1

3

Program Types

NoAll except event blocks for reporting events

N/AIncludes (I)

NoNone TYPE-POOLType group or Type pool (T)

NoEvent block LOAD-OF-PROGRAM, subroutines, methods

PROGRAM Subroutine pool (S)

YesEvent block LOAD-OF-PROGRAM, subroutines, methods

PROGRAMModule pool (M)

NoNone INTERFACE-POOLInterface pool (J)

YesAll except event blocks for reporting events

FUNCTION-POOLFunction group (or function pool) (F)

NoMethods onlyCLASS-POOLClass pool (K)

YesAll - except function modules

REPORT (or PROGRAM)

Executable (1)

Can this have or support its own

DYNPROS

Processing blocks supported

First statement in program (After the

include statements are resolved)

Program type

Page 4: Abap slides set1

4

Dialog Programs and DYNPRO• DYNPRO is a basic component (screen and flow logic) of Dialog programs• DYNPRO (DYNamic PROgram’s) are also called Transactions• Sometimes the terms DYNPRO and Dialog Program are used

interchangingly• The procedure for creating dialog programs is different to that for reports• A Dialog Program consists of one or more screens• Screen consists of a Layout (buttons, frames, labels, edit fields etc) and its

Flow Logic – code to handle user events• Collectively, a screen, its layout and flow logic is called a DYNPRO• When a dialog program is run, screens are the objects called, not programs

or subroutines• In Dialog programs the system displays a screen for the user to enter or

request information and it responds to user input or request by 1) Branching to next screen 2) Displaying an output 3) Running a report 4) Updating the database

Page 5: Abap slides set1

5

Passing Control Between Layers

Database Layer

Page 6: Abap slides set1

6

Explain Dialog Programming• In Dialog programming, control of the program is continually passed

backwards and forwards between the presentation layer (SAP GUI) and application layer (application Server)

• When we start the screen is ready for input (presentation layer is active and application layer is not active)

• Once the user has entered data on the screen, program control passes back to the application layer

• Now, the presentation layer is inactive (the SAP GUI is still visible, but it cannot accept user input)

• The SAP GUI does not become active again until the application program has called a new screen and sent it to the presentation server.

• Basically, in Dialog programming we divide programs into dialog steps, with each of these steps comprising of the programming logic between two successive screens.

Page 7: Abap slides set1

7

Flow Events

• PROCESS BEFORE OUTPUT (PBO) – Fires before a screen is displayed. Can be used to

initialize fields• PROCESS AFTER INPUT (PAI)

– Fires on an user action (menu/buttons/function-keys)• PROCESS ON VALUE REQUEST (POV)

– Fires when a set of possible values is requested (F4)• PROCESS ON HELP REQUEST (POH)

– Fires when general help is requested (F1)

Page 8: Abap slides set1

8

Program Flow

Page 9: Abap slides set1

9

Dialog Processor• Dialog processor controls the display of the

screen and execution of the ABAP program. The Dialog processor processes screen after the screen, thereby triggering the appropriate flow events of each screen

• After each screen is displayed, it waits for the appropriate user input and then executes the flow logic

• The controls passes from screen flow logic to ABAP code and back along with the values of the program elements

Page 10: Abap slides set1

10

Program Flow Design

Page 11: Abap slides set1

11

Dynpro (screen) Logic

Page 12: Abap slides set1

12

ABAP code (include file)

Page 13: Abap slides set1

13

Function Definition

Page 14: Abap slides set1

14

Dynpro data elements Vs. ABAP data elements and Data Transport

Page 15: Abap slides set1

15

FIELD Command and Conditional Module Calls

• FIELD NAME– Value Transported

• FIELD NAME MODULE ChangesDetectModuleon REQUEST.– Value changed

• FIELD NAME MODULE ChangesDetectModuleon INPUT.– Non blank value

• FIELD NAME MODULE ChangesDetectModule. – Custom check for format, etc

Page 16: Abap slides set1

16

CHAIN Command

CHAINFIELD: Name1, Name2MODULE ChangesDetectModule on CHAIN-REQUEST. "Value changed?

ENDCHAIN.

Page 17: Abap slides set1

17

TAB controls

1) Scrolling at application server Only one subscreen area with two subscreens. (see

program 5)

2) Scrolling at Local SAPGUITwo subscreens areas/Two subscreens. (see program 5A)

Page 18: Abap slides set1

18

Data Element & Domains of Fields• Domain depicts the technical attributes of a

field – its data type, field length, no. of decimal places,

appearance on the screen • Data Element denotes the semantic attributes

– short description, label names for a field that uses this.

• Data Elements are directly attached to the Fields

• Data Element has an underlying Domain (optional)

• Domains are not directly attached to the fields• A single Domain can be under many Data

Elements.• Within Domain - value range of a field can be

described. Whereas within the Data Element parameter id and search help for a particular field can be assigned.

Domain

Data Element

Field

Data Element

Field

Page 19: Abap slides set1

19

Input Help (List of Values)1) Fixed Value (DOMAIN LEVEL) - Hard coded list in Data Dictionary

– Using domain (of the Data Element) of the field2) Check Tables (FIELD LEVEL)

– Specifying the Check table on the Field level3) Assigning the "Search Help" repository object (DATA ELEMENT

LEVEL)– Create a "Search Help" Object [as an independent step] and then

assign it to data element of the field.4) Assigning the "Search Help" repository object (SCREEN ELEMENT

LEVEL)– Create a "Search Help" Object [as an independent step] and then

assign it to dynpro screen element in screen painter.5) Self defined Dropdown List Boxes (SCREEN ELEMENT LEVEL)

– Most flexible but requires simple SQL to populate the list.

Page 20: Abap slides set1

20

(1) Fixed Value (Domain Level)

Domain of the Data Element

Data Element of a Field

Page 21: Abap slides set1

21

(2) Check Tables (Field Level)

Click on the Foreign Keys Icon

Page 22: Abap slides set1

22

(3 & 4) Search Help (Object)Create ‘Srch Helps’Object(s)

And attach to the Data Element

Or attach directly to the Dynprofield

LPos:Field Order

SPos:Search Order

Page 23: Abap slides set1

23

Search Help Field OrderLPos: Field OrderSPos: Search Order

Page 24: Abap slides set1

24

(5) Self defined DropdownMODULE create_dropdown_box INPUT.

dynpro_utilities1=>value_help( ).

ENDMODULE.

… DATA city_list TYPE STANDARD TABLE OF city_line.SELECT distinct ZCITY ZCITYDESCR from ZCITY_TBL into corresponding fields of table city_list where ZCITY like '%O%' order by ZCITY.

CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'EXPORTINGretfield = 'ZCITY'value_org = 'S'

TABLESvalue_tab = city_list

EXCEPTIONS…

Select ListboxorListboxwith key

Page 25: Abap slides set1

25

Field Help (F1 Help)1) Documentation - (only one) can be attached to the

Data Element of the Field needing help documentation.2) Additional Documentation - (multiple can be attached

to the Data Element of the Field needing help ‘additional documentation’), Dynpro screen field can call just one -the one relevant to its context using ‘PROCESS ON HELP-REQUEST’ Flow Logic.

• PROCESS ON HELP-REQUEST. (assuming 0001 and 0002 are ‘additional documentation’ help is entered/exists)

– FIELD ZBC400_S_HDR_CURR-CITYTO WITH '0001'.» Or

– FIELD ZBC400_S_HDR_CURR-CITYTO WITH '0002'. etc

3) Uses the Process on Help Request (POH) event.

Page 26: Abap slides set1

26

Field Help - DocumentationClick here in Change Mode to modify (display mode shown)

Data Element

Page 27: Abap slides set1

27

Field Help - Additional Documentation

PROCESS ON HELP-REQUEST.FIELD field1 WITH '0001'.Or FIELD field1 WITH '0002'.

Click here. Add as many as you wish

Data Element

Call any oneAdditional help

Page 28: Abap slides set1

28

Menu Control• Create GUI Status object (Interface Component)• Command: SET PF-STATUS 'ZTEST1'.• Each screen can have same or different menu

(set this in PROCESS BEFORE OUTPUT)• Various menus are: Menu Bar, Standard Tool

Bar, Application Toolbar• Function Keys are generally related to Menu• Context Menu is inherited from Function Keys,so

is same for all fields on screen by default, but…• Context Menu – each field can be made different(program 10 and 10A)

Page 29: Abap slides set1

29

Bars in the SAP GUI

Menu Bar

Standard Tool Bar

Title Bar

Application ToolbarRelated ItemFunction Keys F1, F2…

Page 30: Abap slides set1

30

Menu Painter

Page 31: Abap slides set1

31

Menu Painter

GUI Status -> ZTEST1

Note: Standard tool bar is shown at the top of the Function Keys Setup!

Screen 1/2

Screen 2/2

Page 32: Abap slides set1

32

Function KeysThe following Function Keys are reserved and are

handled at run time• F1 (field help), • F4 (Input Help)• F10 (positions the cursor in the (top) menu bar)

Double Click automatically gets the functionality of whatever F2 is setup to do – applies to all fields by default. (see subsequent slides)

F2 or Double Click can be setup so that different logic can be mapped to individual fields (see program 10C & subsequent slides)

Page 33: Abap slides set1

33

Double Click (all fields)• When we map a/any functionality to F2, the same

functionality is automatically executed when we Double Click the object.

• Example: If we set the F2 to say “BACK1” (also the Function code), the F2 as well as the Double Click get the functionality from the usual ABAP CASE statement logic.

….CASE ok_code.When 'BACK' or

'BACK1'.SET SCREEN

100.….

Page 34: Abap slides set1

34

Double Click (individual fields)• The Function Code for F2 is set to CS (CURSOR-

SELECTION) and TYPE to S (System Function). In PAI use the FIELD statement to call a module.

• …PROCESS AFTER INPUT.FIELD Field1 MODULE C1 AT CURSOR-SELECTION.FIELD Field2 MODULE C2 AT CURSOR-SELECTION.

Actual module defn: MODULE C1 INPUT.CALL TRANSACTION 'SE13'.ENDMODULE.

Page 35: Abap slides set1

35

Context Menu

The Context Menu for a SCREEN is ‘automatically’ defaulted from the ‘function keys’ MENU setup done using menu designer – i.e., GUI STATUS

The Context Menu for individual fields is done using the ON_CTMENU_ field as explained in the subsequent slide.

Page 36: Abap slides set1

36

Context Menu (of field)Using the ON_CTMENU_ field of

screen ElementsFORM on_ctmenu_my_input2 USING

l_menu TYPE REF TO cl_ctmenu.CALL METHOD l_menu->add_functionEXPORTING fcode = 'MY_CONTEXT_MENU7’

text = 'My Context Menu 7'. …CASE save_ok.…WHEN 'MY_CONTEXT_MENU7'.CALL TRANSACTION 'SE92'.

…ENDCASE.

Page 37: Abap slides set1

37

Title Bar

• THE GUI TITLE is Interface Component• SET TITLEBAR title. >> Command

Create HereUse/Call Here

Page 38: Abap slides set1

38

Upcoming Topics

• Character Sets/Unicode Format [UTF-8,etc]

• Data Clusters• File Access• Authorization Checks• Lock Concept and Enqueue