0 umn 2011 erp terapan dialogs programming session # 11

37
1 UMN 2011 ERP Terapan Dialogs Programming Session # 11

Upload: carol-harmon

Post on 01-Jan-2016

224 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: 0 UMN 2011 ERP Terapan Dialogs Programming Session # 11

1

UMN 2011

ERP Terapan

Dialogs ProgrammingSession # 11

Page 2: 0 UMN 2011 ERP Terapan Dialogs Programming Session # 11

Overview

John Natal 2011 / UMN2

SAP AG

R

Overview

Development object Edit Goto System Help

SAP R/3SAP R/3

Flight info

Interface

Status bar

Screen objects

• All windows in user dialog have an interface and a status bar. • The screen area can contain a screen, a selection screen, or a list.• Error dialogs are another type of user dialog.

Page 3: 0 UMN 2011 ERP Terapan Dialogs Programming Session # 11

User Dialogs

John Natal 2011 / UMN3

SAP AG

R

User Dialogs

Selection screens Screens

Lists

User dialogs

3 types of screen objects:a) A Lists output datab) Selection screenc) Screens are used for both data entry and data display.

Page 4: 0 UMN 2011 ERP Terapan Dialogs Programming Session # 11

LISTS

John Natal 2011 / UMN4

Page 5: 0 UMN 2011 ERP Terapan Dialogs Programming Session # 11

LISTs

John Natal 2011 / UMN5

SAP AG

R

Lists

CA ID PRICEAA 2602 2400 AA 2602 2500 Total 7800

ScreenScreen

PrinterPrinter

Multilingual Multilingual capability capability

yes ja

quisi

List data can output in the following ways:• to the screen• to the printer• to the Internet/intranet: Automatic conversion to HTML• also can save lists in the R/3 System or output them for processing by external commercial

software applications like spreadsheet programs

Page 6: 0 UMN 2011 ERP Terapan Dialogs Programming Session # 11

List Operation

John Natal 2011 / UMN6

SAP AG

R

List Operations

Back/Exit/Cancel

Scroll

Print

Find (in List)

Save

:List:

System ...

Page 7: 0 UMN 2011 ERP Terapan Dialogs Programming Session # 11

Page Header

John Natal 2011 / UMN7

SAP AG

R

List header

Column header

Save

:List:

System ... Text elements

Title/Headers

From within a list: From the ABAP Editor:

Page Headers

A list header and column header can be created in one of the following ways: from within the Abap Editor using the text element maintenance functions from within the list itself by choosing the menu path System -> List -> List headers. The

main advantage of using this method is that the list is still displayed on the screen.

Page 8: 0 UMN 2011 ERP Terapan Dialogs Programming Session # 11

Multilingual Capability

John Natal 2011 / UMN8

SAP AG

R

REPORT bc400_list_text.:

SKIP 2.WRITE: /15 text-001, 35 sy-datum, /15 text-002, 35 sy-uname.

REPORT bc400_list_text.:

SKIP 2.WRITE: /15 text-001, 35 sy-datum, /15 text-002, 35 sy-uname.

Source code Text elements

Title/Headers

Program

Text symbols

EN Creation DateDE ErstellungsdatumFR ...

EN Creation DateDE Erstellungsdatum FR ... :EN Created by

001

002

List header

Creation date: 01/01/1998Created by: WITTMANN

Multilingual Capability

Titles and headers are part of a program’s text elements that can translate all text elements into other languages.

Text symbols are another kind of text element. These are special text literal data objects and allow to create lists independent of language.

- TEXT-<xxx> (where xxx is a character string three characters long)- 'string' (<xxx>).

Page 9: 0 UMN 2011 ERP Terapan Dialogs Programming Session # 11

Colors/Icons/Symbols in Lists

John Natal 2011 / UMN9

SAP AG

R

Colors in Lists 1

Flight from to

AA 0017 NEW YORK SAN FRANCISCO LH 0400 FRANKFURT NEW YORKLH 0402 FRANKFURT BERLIN

Creation data: 01/01/1998 Created by: WITTMANN

REPORT sapbc400udd_example_1a.INCLUDE <LIST>. :WRITE: / wa_spfli-carrid COLOR col_key, icon_date AS ICON,

WRITE <data object> <option> .

Colors/Icons/Symbols in Lists

At WRITE statement attribute color can be adjusted using the formatting option COLOR <n>. 0 COL_BACKGROUND Backgrounds 1 COL_HEADING Headers 2 COL_NORMAL List entries 3 COL-TOTAL Totals 4 COL_KEY Key columns 5 COL-POSITIVE Positive threshold values 6 COL_NEGATIVE Negative threshold values 7 COL_GROUP Control

levels

The addition AS ICON within a WRITE statement allows you to add icons to your list. In order to be able to use AS ICON you must, however, add the include <LIST> to your program.

Page 10: 0 UMN 2011 ERP Terapan Dialogs Programming Session # 11

Lists in Executable Programs

John Natal 2011 / UMN10

SAP AG

R

Lists in Executable Programs

Program

ABAPruntimesystem

START-OF-SELECTION.

WRITE ... SKIP. ULINE.

List buffer

Basic list

statement that generates a list are; WRITE, SKIP and ULINE. Event blocks are called in a sequence designed for list processing:

• Prior to sending the selection screen: INITIALIZATION• After leaving the selection screen: START-OF-SELECTION

Page 11: 0 UMN 2011 ERP Terapan Dialogs Programming Session # 11

Details Lists

John Natal 2011 / UMN11

SAP AG

R

Details Lists

Program

ABAPruntimesystem

START-OF-SELECTION.

WRITE ... SKIP. ULINE.

List buffer

AT LINE-SELECTION

WRITE ... SKIP. ULINE.

Basic list

Details list

Details list buffer

The event block AT LINE-SELECTION is used to create details lists. The ABAP runtime system fields:

• sy-lsind contains the value 0 at Basic List.• sy-ucomm when a corresponding user entry is made

Page 12: 0 UMN 2011 ERP Terapan Dialogs Programming Session # 11

A Simple Details List

John Natal 2011 / UMN12

SAP AG

R

Example: A Simple Details List

Basic list

Details list 1

Demonstration Program ...

Basic ListBasic List sy-lsind 0

Details ListDetails Listsy-ucomm sy-lsind

Details list 2 Details ListDetails Listsy-ucomm sy-lsind

Up to twenty details lists

PICK1

PICK2

Page 13: 0 UMN 2011 ERP Terapan Dialogs Programming Session # 11

A Simple Details List: Syntax

John Natal 2011 / UMN13

SAP AG

R

Syntax: A Simple Details List

REPORT sapbc400udd_secondary_list_a.

START-OF-SELECTION. WRITE: / text-001 COLOR col_heading, / 'sy-lsind', sy-lsind color 2.

AT LINE-SELECTION. WRITE: / text-002 COLOR col_heading. ULINE. WRITE: / 'sy-ucomm', sy-ucomm color 3, / 'sy-lsind', sy-lsind color 4.

Text symbols:

001

002

Basic list

Details list

Page 14: 0 UMN 2011 ERP Terapan Dialogs Programming Session # 11

Details List: Example

John Natal 2011 / UMN14

SAP AG

R

Details List: Example

Flight From To Departing atFlight From To Departing atLH 0400 FRA Frankfurt JFK New York 10:10:00LH 0402 FRA Frankfurt JFK New York 13:30:00...SQ 0002 SIN Singapore SFO San Francisco 09:30:00

You have chosen flight LH 0402

TimetableTimetable

Flight DetailsFlight Details

Flight date

12/19/199812/20/199812/24/1998

Max.

380380380

Occ.

240270380

Page 15: 0 UMN 2011 ERP Terapan Dialogs Programming Session # 11

R

REPORT sapbc400udd_example_2. ... START-OF-SELECTION. SELECT * FROM spfli INTO wa_spfli. WRITE:/ wa_spfli-carrid, wa_spfli-connid, wa_spfli-airpfrom, wa_spfli-airpto, wa_spfli-deptime. HIDE: wa_spfli-carrid, wa_spfli-connid. ENDSELECT.

HIDE area

HIDE <data object> .

Basic list buffer

LH 0400 FRA JFK 10:10:00 LH 0402 FRA JFK 13:30:00 ... SQ 0002 SIN SFO 09:30:00

Line

... 5 6

... 11

Line

... 5 6

... 11

wa_spfli- carrid

... LH LH ...

SQ

wa_spfli- connid

... 0400 0402

... 0002

HIDE Areas

John Natal 2011 / UMN15

The HIDE area to store certain data from the line that you have selected and then automatically insert where you need it in the corresponding data object for a details list.

Page 16: 0 UMN 2011 ERP Terapan Dialogs Programming Session # 11

Line Selection

John Natal 2011 / UMN16

SAP AG

R

Line Selection

REPORT sapbc400udd_example_2.

AT LINE-SELECTION. WRITE: text-001, wa_spfli-carrid, wa_spfli-connid.

Flight From To Departing at LH 0400 FRA JFK 10:10:00LH 0402 FRA JFK 13:30:00...SQ 0002 SIN SFO 09:30:00

HIDE area

Line

...56

...11

wa_spfli-carrid

...LHLH...

SQ

wa_spfli-connid

...04000402

...0002

wa_spfliLH 0402 ?? ?? ????

Text symbols:

001 Flights for connection

Page 17: 0 UMN 2011 ERP Terapan Dialogs Programming Session # 11

Line Selection: Syntax

John Natal 2011 / UMN17

SAP AG

R

Line Selection: Syntax

REPORT sapbc400udd_example_2....

AT LINE-SELECTION. WRITE: text-001, wa_spfli-carrid, wa_spfli-connid.

SELECT fldate seatsmax seatsocc FROM sflight INTO CORRESPONDING FIELDS OF wa_sflight WHERE carrid = wa_spfli-carrid AND connid = wa_spfli-connid.

WRITE:/ wa_sflight-fldate, wa_sflight-seatsmax, wa_sflight-seatsocc. ENDSELECT.

Text symbols:

001 Flights for connection

Page 18: 0 UMN 2011 ERP Terapan Dialogs Programming Session # 11

Selection Screen

John Natal 2011 / UMN18

Page 19: 0 UMN 2011 ERP Terapan Dialogs Programming Session # 11

Selection Screens

John Natal 2011 / UMN19

SAP AG

R

L* U*

Get all records from database table where airline name is between L* and U* (inclusive)

Selection Screens

Selection screens allow users to enter selection criteria required by the program.For example, if you create a list containing data from a very large database table, you can use a selection screen to restrict the amount of that data that is selected. At runtime, the user can enter intervals for one of the key fields, and only data in this interval is read from the database and displayed in the list. This considerably reduces the load on the network

Page 20: 0 UMN 2011 ERP Terapan Dialogs Programming Session # 11

The Selection Screen

John Natal 2011 / UMN20

SAP AG

R

Selection rangesSelection ranges

The Selection Screen

MultilingualMultilingual

yes ja

quisi

......

VariantsVariants

Search helpsSearch helps

Type checksType checks

Page 21: 0 UMN 2011 ERP Terapan Dialogs Programming Session # 11

Entering Selection

John Natal 2011 / UMN21

SAP AG

R

Entering Selections

SELECT-OPTIONS ...

PARAMETERS ... Departing from

Airline carrier LH to

SIGNI

OPTIONGE

LOWLH

Fluggesellschaft

Single valueGreater than or equal

Greater thanLess thanNot equal

Select

Exclude from selection

Maintain Selection OptionsMaintain Selection Options

Airline carrier

Less than or equalLess than or equal

Multiple single values,Intervals,Single value exclusion,Interval exclusion

...

Selection screens allow to enter complex selections as well as single-value selections. Functions of selection options programming include:

• Setting selection options• Entering multiple values or intervals• Defining a set of exclusionary criteria for data selection • Every selection screen contains an information icon.

Page 22: 0 UMN 2011 ERP Terapan Dialogs Programming Session # 11

Search Help

John Natal 2011 / UMN22

SAP AG

R

Search Help

Airline carrier

SuchhilfeSuchhilfe

ABAP Dictionary

Search help

Flight no. to

DATA: wa LIKE spfli.PARAMETERS pa_carr LIKE spfli-carrid.SELECT-OPTIONS so_conn FOR wa-connid.

No.

0400

0402

Depart.airportFRA

FRA

Arriv.airportJFK

JFK

Depart.time10:10:00

13:30:00

ID

LH

LH

Check table

Data element

Table fieldStructure field

If refer an input field to an ABAP Dictionary object to which a search help is assigned, the system automatically provides the corresponding possible values help.

The possible values help can adapt by defining a search help in the ABAP Dictionary.

Page 23: 0 UMN 2011 ERP Terapan Dialogs Programming Session # 11

Variants

John Natal 2011 / UMN23

SAP AG

R

Variants

Departing from

...

Departing from

Airline carrier D* L* to

Variant carrier_d_to_l:Airlines D* to L*Hide input field

Define and store variants for any selection screen by starting the program and choosing Variants -> Save as variant.

Variants allow you to make selection screens easier to use by end users by: Pre-assigning values to input fields Hiding input fields Saving these settings for reuse A single variant can refer to more than one selection screen. Variants are client specific.

Page 24: 0 UMN 2011 ERP Terapan Dialogs Programming Session # 11

Selection Texts

John Natal 2011 / UMN24

SAP AG

R

Source code Text elements

Title/Headers

Program

Text symbols

SO_CARR

PA_CITY

Selection texts

EN Airline carrier DE Fluggesellschaft

EN Departing from DE Abflugort...

Departing from

Airline carrier LH to

MultilingualMultilingual

yes ja

quisi

REPORT bc400td_selection_screen. :SELECT-OPTIONS so_carr FOR ...PARAMETERS pa_city LIKE ...

Selection Texts

Page 25: 0 UMN 2011 ERP Terapan Dialogs Programming Session # 11

Recap: PARAMETERS

John Natal 2011 / UMN25

SAP AG

R

PA_CARR

Defines a dialog

ABAP Dictionaryreference

Declares an internal data object in programpa_carr

PARAMETERS pa_carr LIKE sdyn_conn-carrid.

pa_carr

LH

LH

Recap: PARAMETERS

A single PARAMETERS statement is sufficient to generate a standard selection screen. The PARAMETERS <name> TYPE <type> statement generates a simple input field on the selection screen, and a

data object <name> with the type you have specified. If the user enters a value and chooses 'Execute', that value is placed in the internal data object <name> in the

program. The system will only permit entries with the appropriate type.

Page 26: 0 UMN 2011 ERP Terapan Dialogs Programming Session # 11

USING Parameters in the SELECT Statement

John Natal 2011 / UMN26

SAP AG

R

Using Parameters in the SELECT Statement

REPORT ...DATA wa_spfli LIKE spfli.PARAMETERS pa_carr LIKE spfli-carrid....SELECT carrid connid cityfrom cityto ... FROM spfli INTO CORRESPONDING FIELDS OF wa_spfli WHERE carrid = pa_carr.

WRITE: / wa_spfli-carrid, wa_spfli-connid,wa_spfli-fldate, ... .

ENDSELECT.

DATA <data object> LIKE <table field>.PARAMETERS <parameter name> LIKE <table field>....SELECT ... FROM <table> INTO ... WHERE <table field> = <parameter name>.

If you have used the PARAMETERS statement to program an input field as a key field for a database table, you can use a WHERE clause at the SELECT statement to limit data selection to this value.

Page 27: 0 UMN 2011 ERP Terapan Dialogs Programming Session # 11

SELECT-OPTIONS

John Natal 2011 / UMN27

SAP AG

R

SELECT-OPTIONS

SO_CARR

ABAP Dictionaryreference

DATA: wa_spfli like spfli.SELECT-OPTIONS so_carr FOR wa_spfli-carrid.

to

so_conn

wa_spfli

signoption low highDeclares aninternaldata object(internal table) inprogram so_carrfor data objectwa_spfli-carrid

Page 28: 0 UMN 2011 ERP Terapan Dialogs Programming Session # 11

Using Select-Options in the SELECT Statement

John Natal 2011 / UMN28

SAP AG

R

Using Select-Options in the SELECT Statement

REPORT ...DATA WA_SPFLI LIKE SPFLI.SELECT-OPTIONS so_carr FOR wa_spfli-carrid....SELECT carrid connid cityfrom cityto ... FROM spfli INTO CORRESPONDING FIELDS OF wa_spfli WHERE carrid IN so_carr.

WRITE: / wa_spfli-carrid, wa_spfli-connid,wa_spfli-cityfrom, wa_spfli-cityto, ... .

ENDSELECT.

DATA <data object> LIKE <table>.SELECT-OPTIONS <selname> FOR <data object>....SELECT table field FROM <table> INTO ... WHERE <table field> IN <selname>.

Page 29: 0 UMN 2011 ERP Terapan Dialogs Programming Session # 11

Standard Selection Screens in Executable Programs

John Natal 2011 / UMN29

SAP AG

R

Standard Selection Screens inExecutable Programs

Program

ABAPruntimesystem

START-OF-SELECTION.

WRITE ... SKIP. ULINE.

INITIALIZATION.

List buffer

AT SELECTION-SCREEN.

StatementsSELECT-OPTIONS: ...PARAMETERS: ...

In an executable program, the ABAP runtime system generates a standard selection screen as long as you have written at least one PARAMETERS or SELECT-OPTIONS statement.

The selection screen is displayed after the event block INITIALIZATION. The event block AT SELECTION-SCREEN (see following slides) belongs to the selection

screen. As soon as the user chooses 'Execute' to leave the selection screen, the runtime system calls the START-OF-SELECTION event block.

Page 30: 0 UMN 2011 ERP Terapan Dialogs Programming Session # 11

Standard Selection Screen Processing

John Natal 2011 / UMN30

SAP AG

R

DeclarationsSELECT-OPTIONS: ...PARAMETERS: ...

START-OF-SELECTION

WRITE ...AT SELECTION-SCREEN....

1

2

'Execute'

1

2

All user actions other than'Execute'

Standard Selection Screen Processing

Page 31: 0 UMN 2011 ERP Terapan Dialogs Programming Session # 11

Additional Input Checks

John Natal 2011 / UMN31

SAP AG

R

START-OF-SELECTION

WRITE ...

DeclarationsSELECT-OPTIONS: ...PARAMETERS: ...

ErrorAT SELECTION-SCREEN....MESSAGE e038.

1

2 All user actionsother than'Execute'

'Execute'

1

2

Additional Input Checks

Page 32: 0 UMN 2011 ERP Terapan Dialogs Programming Session # 11

AT SELECTION-SCREEN

John Natal 2011 / UMN32

SAP AG

R

AT SELECTION-SCREEN

AT SELECTION-SCREEN. IF operator = '/' and pa_val2 = 0. MESSAGE e050(bctrain). " Division by zero ENDIF.

* end of event AT SELECTION-SCREEN.

START-OF-SELECTION. : :

REPORT sapbc400udd_at_selection_scr.PARAMETERS: pa_val1 type I, operator type C, pa_val2 type I.

Page 33: 0 UMN 2011 ERP Terapan Dialogs Programming Session # 11

Example: User-defined Selection Screens

John Natal 2011 / UMN33

SAP AG

R

Example: User-defined Selection Screens

Flight From To Departing atFlight From To Departing atLH 0400 FRA Frankfurt JFK New York 10:10:00LH 0402 FRA Frankfurt JFK New York 13:30:00...SQ 0002 SIN Singapore SFO San Francisco 09:30:00

Timetable

You have chosen LH 0402Flight date

12/19/199812/20/199812/24/1998

Max.

380380380

Occ.

240270380

Flight details

Flight date

Selection screen

Page 34: 0 UMN 2011 ERP Terapan Dialogs Programming Session # 11

User-defined Selection Screen

John Natal 2011 / UMN34

SAP AG

R

Error

User-defined Selection Screens

1

2

'Execute'

. . .CALL SELECTION-SCREEN 1200.CHECK sy-subrc = 0.

AT SELECTION-SCREEN....MESSAGE e038.

DeclarationsSELECTION-SCREEN BEGIN OF SCREEN 1200. PARAMETERS ... SELECT-OPTIONS ...SELECTION-SCREEN END OF SCREEN 1200.

1

2

All user actionsother than'Execute'

Screen 1000 is reserved for the standard selection screen call the selection screen from any ABAP processing block using the statement

CALL SELECTION-SCREEN nnnn.

Page 35: 0 UMN 2011 ERP Terapan Dialogs Programming Session # 11

Defining and Calling Selection Screen: Syntax

John Natal 2011 / UMN35

SAP AG

R

Syntax: Defining and Calling Selection Screens

SELECTION-SCREEN BEGIN OF SCREEN <nnnn> ....SELECTION-SCREEN END OF SCREEN <nnnn>.

SELECTION-SCREEN BEGIN OF SCREEN 1200. SELECT-OPTIONS so_date FOR wa_sflight-fldate.SELECTION-SCREEN END OF SCREEN 1200....AT LINE-SELECTION. CALL SELECTION-SCREEN 1200. CHECK sy-subrc eq 0. SELECT seatsocc seatsmax FROM sflight INTO CORRESPONDING FIELDS OF wa_sflight WHERE carrid = wa_spfli-carrid AND connid = wa_spfli-connid AND fldate IN so_date.

CALL SELECTION-SCREEN <nnnn> .

Page 36: 0 UMN 2011 ERP Terapan Dialogs Programming Session # 11

User-Defines Selection Screens

John Natal 2011 / UMN36

SAP AG

R

Error

User-defined Selection Screens

1

2

'Execute'

. . .CALL SELECTION-SCREEN 1200.CHECK sy-subrc = 0.

AT SELECTION-SCREEN....MESSAGE e038.

DeclarationsSELECTION-SCREEN BEGIN OF SCREEN 1200. PARAMETERS ... SELECT-OPTIONS ...SELECTION-SCREEN END OF SCREEN 1200.

1

2

All user actionsother than'Execute'

Page 37: 0 UMN 2011 ERP Terapan Dialogs Programming Session # 11

Defining and Calling Selection Screens: Syntax

John Natal 2011 / UMN37

SAP AG

R

Syntax: Defining and Calling Selection Screens

SELECTION-SCREEN BEGIN OF SCREEN <nnnn> ....SELECTION-SCREEN END OF SCREEN <nnnn>.

SELECTION-SCREEN BEGIN OF SCREEN 1200. SELECT-OPTIONS so_date FOR wa_sflight-fldate.SELECTION-SCREEN END OF SCREEN 1200....AT LINE-SELECTION. CALL SELECTION-SCREEN 1200. CHECK sy-subrc eq 0. SELECT seatsocc seatsmax FROM sflight INTO CORRESPONDING FIELDS OF wa_sflight WHERE carrid = wa_spfli-carrid AND connid = wa_spfli-connid AND fldate IN so_date.

CALL SELECTION-SCREEN <nnnn> .