Beruflich Dokumente
Kultur Dokumente
1.
>
>
<
<
>
<
>
<
>
<
Karte >
>
<
>
<
< ziehen
>
>
<
<
>
>
>
<
<
<
>
>
<>
<
<
2. Kontrolle der Schnittstelle im Class builder
>
<
>
<
>Kontrolle<
3. Legen Sie das Testprogramm an
>
<
>
<
> <
>
>
<
<
tables: spfli.
data: wa_spfli type spfli,
it_spfli type table of spfli with key carrid connid.
*Initialise the object of the interface.
selection-screen begin of block b1.
select-options: s_carr for spfli-carrid.
selection-screen end of block b1.
start-of-selection.
select * from spfli into corresponding fields of table it_spfli
>
>
<
<
>
>
<
<
<
>
<
>
>
>
<x2
<
Methoden ABAP-Code
data : wa_flights type sflight,
it_flights type table of sflight.
format color col_heading.
write:/ 'Flight info of:', i_carrid, i_connid.
format color col_normal.
select * from sflight
into corresponding fields of table it_flights
where carrid = i_carrid
and connid = i_connid.
loop at it_flights into wa_flights.
write:/ wa_flights-fldate,
wa_flights-planetype,
wa_flights-price currency wa_flights-currency,
wa_flights-seatsmax,
wa_flights-seatsocc.
endloop.
10
>aktivieren<
>Programm testen<
>
<
11
>
<
>
Markieren
- Persistente Klasse
- Final
>sichern<
<
12
>
<
>
>
>
<
<
<
13
>
<
>
>
<
<
14
>
<
- Sichtbarkeit Public
>
<
==================
write: /
'Daten der Fluggesellschaft',
me->carrid,
icon_ws_plane as icon,
me->carrname,
me->currcode,
me->url.
======================
15
>
<
>Typgruppe zufhren und aktivieren<
7. Beispielprogramm setzen der Persistenz
>
<
at selection-screen.
select single carrid from scarr
into carrid
where carrid = pa_carr.
if sy-subrc = 0.
message e210(bc401) with carrid.
endif.
start-of-selection.
* get agent instance:
ref_carrier_agent = zca_00_pers_scarr=>agent.
16
17
18
9. Definieren Sie eine Ausnahmeklasse die reagiert wenn der SCARR-Eintrag in der
Methode Display_Attributes keine EmailAdresse aufweist und integrieren Sie den
Ablauf in ihr Persistenzen setzendes Programm
>
<
19
>
<
-
enter
>
<
>
<
20
>sichern<
>
>
<
>aktivieren<
<
<
21
>
22
<
<
if me->url eq space.
raise exception type zcx_emailfeld_leer
exporting
*
textid =
*
previous =
carrid = me->carrid.
endif.
23
>
data: oref type ref to zcx_emailfeld_leer.
data: text type string.
try.
* "work" with instance:
call method ref_carrier->display_attributes.
uline.
catch zcx_emailfeld_leer into oref.
text = oref->get_text( ).
message text type 'E'.
endtry.
24
<
25
11. Freunde
*&---------------------------------------------------------------------*
*& Report Z_FRIENDS
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT Z_FRIENDS.
*
* Mit dem Zusatz FRIENDS macht die Klasse class die Klassen class1 class2 .
..
26
>
<
>
<
>
<
27
>
<
28
29
<
>
<
>
<
>lokales Objekt<
type-pool zch20 .
types: begin of zch20_ty_message,
date type sydatum,
time type syuzeit,
user type syuname,
text type string,
end of zch20_ty_message.
types: zch20_ty_message_t type sorted table of
with non-unique key date time.
Im 1.Modus
><
>
<
zch20_ty_message
30
>
<
^
>sichern<
><
><
report z_chat_20 no standard page heading.
*&------------------------------------------------------*
*& Report Z640_011
*&------------------------------------------------------*
include <ICON>.
data: area
type ref to zl_chat_area_20,
messages
type ref to zcl_chat_messages_20,
error
type ref to object,
error_msg
type ref to if_message,
errtext
type string,
field_name type char72,
message_text type text80.
start-of-selection.
try.
area = zl_chat_area_20=>attach_for_read( ).
catch cx_shm_attach_error.
try.
area = zl_chat_area_20=>attach_for_write( ).
create object messages area handle area.
area->set_root( messages ).
area->detach_commit( ).
area = zl_chat_area_20=>attach_for_read( ).
catch cx_shm_attach_error into error.
perform error.
endtry.
endtry.
try.
area->root->list_messages( ).
area->detach( ).
catch cx_shm_attach_error.
perform error.
endtry.
perform input.
at line-selection.
get cursor field field_name.
case field_name.
when 'ICON_CREATE_TEXT'.
message_text = sy-lisel+33(80).
check not message_text is initial.
try.
area = zl_chat_area_20=>attach_for_update( ).
area->root->add_message( message_text ).
clear message_text.
area->root->list_messages( ).
area->detach_commit( ).
catch cx_shm_attach_error into error.
perform error.
endtry.
perform input.
when 'ICON_REFRESH'.
try.
area = zl_chat_area_20=>attach_for_read( ).
area->root->list_messages( ).
area->detach( ).
catch cx_shm_attach_error into error.
perform error.
endtry.
perform input.
endcase.
*&------------------------------------------------------*
*&
Form error
*&------------------------------------------------------*
form error.
error_msg ?= error.
errtext = error_msg->get_text( ).
write: / errtext.
stop.
31
32
" error
*&------------------------------------------------------*
*&
Form input
*&------------------------------------------------------*
form input .
get time.
write: / sy-datum,
sy-uzeit,
sy-uname,
message_text input,
icon_create_text as icon hotspot,
icon_refresh as icon hotspot.
endform
Behandelte Themen
- Verschachtelte Interfaces
- Persistente Objekte
- neue Technologie zur Workflowabwicklung
13. Betrachten Sie das Workflow-Interface
>
>
<
<
>
33
<
>
<
>
<
Die Methode BI_PERSISTENT~FIND_BY_LPOR wird von der SAP WebFlow Engine
aufgerufen, wenn eine persistent gespeicherte Darstellung eines Objektes in eine Instanz der
entsprechenden ABAP-Klasse umgewandelt werden soll.
Die Methode BI_PERSISTENT~LPOR ist das Gegenstck zur Methode
BI_PERSISTENT~FIND_BY_LPOR. Sie liefert die persistente Darstellung zu einer
vorhandenen Instanz eines ABAP-Objektes.
34
Die Methode BI_PERSISTENT~REFRESH wird von der SAP WebFlow Engine aufgerufen,
wenn das System sicherstellen muss, dass alle Werte des Objektes gltig sind bzw. genau mit
der persistenten Abbildung des Objektes bereinstimmen.
Die Methode BI_OBJECT~DEFAULT_ATTRIBUTE_VALUE liefert den Anzeigename des
Objektes.Wenn Sie die Methode in Ihrer Klasse nicht bentigen, sollten Sie eine leere
Implementierung (ohne weiteres Coding) vornehmen, um Programmfehler beim Systemaufruf
der Methode zu vermeiden.
Die Methode BI_OBJECT~EXECUTE_DEFAULT_METHOD ist die Standardmethode des
Objektes. Diese Methode wird ausgefhrt, wenn z. B. im Business Workplace das Objekt
aufgerufen wird.
Mit Hilfe der Methode BI_OBJECT~RELEASE signalisiert das System, dass die Referenz
auf die Instanz nicht mehr bentigt wird. Die Referenz kann folglich aus der
Instanzverwaltung gelscht werden. Nachdem die letzte Referenz aus der Instanzverwaltung
gelscht wurde, kann der GARBAGE COLLECTOR den entsprechenden Speicherbereich
freigeben.
>
<
==================================================================
35
>
>
>
<
<
<
36
>
<
>
>
<
<
<
Materialnummer
37
>
>
>
<
<
<
38
**********************************************************************
* Das Schlsselfeld des Objekts mit dem Importparameter fllen
matnr = im_matnr.
* Unsere Implementierung eines Existenz-Checks
select single * from mara into m_mara
where matnr = me->matnr.
if sy-subrc ne 0.
* Hier muss die Behandlung erfolgen, wenn das Material nicht auf der
* Datenbank vorhanden ist!
endif.
====================
>
>
>
Besonderheit
- Anpassen auf eigene Klasse
<
<
<
39
types:
begin of t_instance,
matnr type mara-matnr,
instance type ref to zcl_00_mara,
end of t_instance .
types:
t_instances type standard table of t_instance .
====================
MATNR
Instance Attribute
Public Type MARA-MATNR
Materialnummer
MST_INSTANCES Static Attribute
Private Type T_INSTANCES
Tabellen
Instanzen
M_POR
Instance Attribute
Private Type SIBFLPOR Lokale Persistente
Objektreferenz
M_MARA
Instance Attribute
Private Type MARA
Allgemeine Materialdaten
Augenmerk
- static Attribute
- Private
- Typverwendung
- Besonderheit um eine Instanzverwaltung zu bercksichtigen muss ein das
Attribut M_POR vom Typ SIBLPOR angelegt werden.
=======================
class-data MST_INSTANCES type T_INSTANCES .
=====================
=========================
**********************************************************************
* Datendeklaration
**********************************************************************
data: l_instance type ref to zcl_00_mara. "Referenz des eigenen Objekts
data: l_matnr type mara-matnr. "Materialnummer / Schlssel
data: ls_instance type t_instance. "Verwaltung der Instanzen
**********************************************************************
* Programmlogik
**********************************************************************
* berprfung, ob bereits eine Lokale Persistente Objektrefererenz
* existiert
check lpor-instid is not initial.
* instid of import parameter LPOR is object key
l_matnr = lpor-instid.
* Gibt es bereits eine Instanz?
read table mst_instances with key matnr = l_matnr
into ls_instance.
* Wenn es noch keine Instanz gibt
if sy-subrc ne 0.
* Erzeugen des Objekts fr die Instanzverwaltung
try.
create object l_instance
exporting
im_matnr = l_matnr.
catch cx_bo_error .
exit.
endtry.
40
>
<
========================
**********************************************************************
* Programmlogik
**********************************************************************
* Erstellen der lokalen Persistenten Objektreferenz
m_por-catid = 'CL'.
m_por-typeid = 'ZCL_00_MARA'.
m_por-instid = me->matnr.
* Laden der Instanz in den Rckgabewert vom Typ SIBFLPOR
result = m_por.
==============================
41
42
>
>
<
<
43
==============================
MATKL
Instance Attribute
Private Type
MTART
Instance Attribute
Public Type
SPART
Instance Attribute
Public Type
BISMT
Instance Attribute
Public Type
ERNAM
Instance Attribute
Public Type
DESCRIPTION
Instance Attribute
Public
EMAIL_ERNAM
Instance Attribute
Public
================================
MARA-MATKL
MARA-MTART
MARA-SPART
MARA-BISMT
MARA-ERNAM
Type SYST-TITLE
Type AD_SMTPADR
=============================
**********************************************************************
* Programmlogik
**********************************************************************
* Ermitteln der Daten aus der MARA
select single * from mara into m_mara
where matnr = me->matnr.
* Zuweisen der Daten aus der Struktur in die Attribute
me->matkl = me->m_mara-matkl.
me->mtart = me->m_mara-mtart.
me->spart = me->m_mara-spart.
me->bismt = me->m_mara-bismt.
me->ernam = me->m_mara-ernam.
===================================
44
45
======================
**********************************************************************
* Datendeklaration
**********************************************************************
data: l_matnr type mara-matnr, "Materialnummer
l_maktx type makt-maktx. "Materialkurztext
**********************************************************************
* Programmlogik
**********************************************************************
* Materialkurztext zum Material in lokale Variable schreiben
select single maktx from makt into l_maktx
where matnr = matnr
and spras = sy-langu.
* Fhrende Nullen bei interner Nummernvergabe lschen
l_matnr = matnr.
shift l_matnr left deleting leading '0'.
* Beschreibenden Text zusammensetzen
concatenate 'Material:'(001) l_matnr '-'(002) l_maktx into
description separated by space.
==========================
46
====================
me->read_attributes( ).
me->set_description( ).
=========================
>aktivieren + test<
47
============================
48
**********************************************************************
* Datendeklaration
**********************************************************************
data: lt_return type table of bapiret2,
lt_addsmtp type table of bapiadsmtp,
wa_addsmtp type bapiadsmtp.
**********************************************************************
* Programmlogik
**********************************************************************
* Ermitteln der E-Mail Adressen zum Erfasser
call function 'BAPI_USER_GET_DETAIL'
exporting
username = me->ernam
tables
return
= lt_return
addsmtp = lt_addsmtp.
* Lesen der ersten E-Mail Adresse
read table lt_addsmtp index 1 into wa_addsmtp.
* Attribut ausgeben, wenn E-Mail Adresse gepflegt
if sy-subrc = 0.
me->email_ernam = wa_addsmtp-e_mail.
endif.
=============================
>aktivieren + testen<
49
50
51
================
**********************************************************************
* Das Schlsselfeld des Objekts mit dem Importparameter fllen
matnr = im_matnr.
* Existenzcheck Methode aufrufen, Fehler abfangen
try.
call method me->existencecheck.
catch cx_bo_error.
exit.
endtry.
me->read_attributes( ).
me->set_description( ).
=====================
52
========================
**********************************************************************
* Programmlogik
**********************************************************************
call function 'BAPI_MATERIAL_DISPLAY'
exporting
material = matnr
* MATERIAL_EVG =
importing
return = ex_return
.
============================
>aktivieren und test<
53
>
===================
54
<
**********************************************************************
* Programmlogik
**********************************************************************
try.
display( ).
catch cx_root.
endtry.
======================
>
<
************************************************************************
* Programmlogik *
************************************************************************
set parameter id 'MAT' field matnr.
set parameter id 'MXX' field im_statm.
call transaction 'MM03' and skip first screen.
**********************************************************************
* Programmlogik
**********************************************************************
set parameter id 'MAT' field matnr.
call transaction 'MM02' and skip first screen.
>
<
55
56
>
<
>
<
57
========================
**********************************************************************
* Programmlogik
**********************************************************************
call function 'BAPI_STANDARDMATERIAL_CREATE'
* EXPORTING
* NEWMATERIAL = ' '
* NEWMATERIAL_EVG =
importing
material = ex_matnr
* NEWMATERIAL =
return = ex_return
* MATERIAL_EVG =
* NEWMATERIAL_EVG =
.
============================
>
<
><
58
<
<
>
<
<
>
<
59
>
>
60
<
<
61
<
<
>
<
>
3 x zurck
>
<
Zurck x 2
Aktivieren
62
<
<
63
<
64
65
>
<
>
<
=============
*********************************************************************
* Programmlogik
**********************************************************************
call function 'BAPI_MATERIAL_DISPLAY'
exporting
material = matnr
* MATERIAL_EVG =
importing
return = ex_return
.
case ex_return-number.
when '000'. "Material wurde angezeigt
when '262'.
66
=====================
**********************************************************************
* Datendeklaration
**********************************************************************
data: l_event_container type ref to if_swf_ifs_parameter_container.
**********************************************************************
* Programmlogik
**********************************************************************
67
68
>
<
>
>
<
>
<
69
<
70
>
>
>
<
<
<
71
>
>
<
<
72
>
<
>Doppelklick<
>
Die Methode Create muss ein Ereignis erzeugen
Testen der Methode Create + Display und Kontrolle ber SWEL
<
73
>
<
>Doppelklick<
<
>Sichern
>Synchrone Objektmethode
>Sichern
74
75
>
<
>Bearbeiterzuordnung pflegen
>
<
>anlegen<
>
<
>Benutzer<
>
Ihr Benutzer
<
>
>zurck
>
<
>Auslsende Ereignisse
76
<
77
>
<
>Aktivieren des Ereginisses und test<
>
>
<
<
<
78
form.
" input
79