Code: Alles auswählen.
<% " Copy this page into your BSP application, and change line below.
" This page should always used be as entry point into application.
DATA: target_page TYPE STRING VALUE 'session_test.htm'.
Code: Alles auswählen.
<% " Copy this page into your BSP application, and change line below.
" This page should always used be as entry point into application.
DATA: target_page TYPE STRING VALUE 'usercreate.htm'.
Code: Alles auswählen.
<%@page language="abap"%>
<%@extension name="htmlb" prefix="htmlb"%>
<htmlb:content design="design2003">
<htmlb:page title = "Einstiegsseite ">
<htmlb:form id="createuser">
<htmlb:label text = "Benutzer"
for = "userid" />
<htmlb:inputField id = "userid"
type = "string"
size = "8"
value = "<%=userid%>"
design = "STANDARD" />
</br>
<htmlb:label text = "Passwort"
for = "pw" />
<htmlb:inputField id = "pw"
type = "string"
size = "8"
value = "<%=pw%>"
design = "STANDARD" />
</br>
<htmlb:label text = "Vorname"
for = "forename" />
<htmlb:inputField id = "forename"
type = "string"
size = "30"
value = "<%=forename%>"
design = "STANDARD" />
</br>
<htmlb:label text = "Nachname"
for = "lastname" />
<htmlb:inputField id = "lastname"
type = "string"
size = "30"
value = "<%=lastname%>"
design = "STANDARD" />
</br>
<htmlb:button id = "createbutton"
text = "Submit"
onClick = "createuser" />
</htmlb:form>
</htmlb:page>
</htmlb:content>
Code: Alles auswählen.
DATA: event_data TYPE REF TO cl_htmlb_event,
var_action TYPE string,
lv_username TYPE username,
lv_password TYPE bapipwd,
ls_address TYPE bapiaddr3,
lt_return TYPE STANDARD TABLE OF bapiret2,
lt_bapiagr TYPE STANDARD TABLE OF bapiagr,
ls_bapiagr TYPE bapiagr,
ls_logondata TYPE bapilogond.
* Seitenattribute in lokale Variablen
lv_username = userid.
ls_address-firstname = forename.
ls_address-lastname = lastname.
lv_password = pw.
* Event auswerten
CLASS cl_htmlb_manager DEFINITION LOAD.
IF cl_htmlb_manager=>event_id EQ 'htmlb'. "equals htmlb
event_data = cl_htmlb_manager=>get_event( request ).
IF event_data->event_type EQ 'click'.
var_action = event_data->server_event.
IF var_action EQ 'createuser'.
* Anlegen Benutzer (SU01)
CALL FUNCTION 'BAPI_USER_CREATE'
EXPORTING
username = lv_username
logondata = ls_logondata
password = lv_password
address = ls_address
TABLES
return = lt_return.
* Zuordnung Rolle
ls_bapiagr-agr_name = 'SAP_BC_DWB_ABAPDEVELOPER'.
append ls_bapiagr to lt_bapiagr.
CALL FUNCTION 'BAPI_USER_ACTGROUPS_ASSIGN'
EXPORTING
username = lv_username
TABLES
activitygroups = lt_bapiagr
return = lt_return.
COMMIT WORK.
ENDIF.
ENDIF.
ENDIF.
Code: Alles auswählen.
<%@page language="ABAP"%>
<!-- Start Error Msg-->
<table align="center" cellpadding="0" cellspacing="0" width="99%" border="0">
<tr>
<td width="100%" class="TX_ERROR_XSB">
<img src="layout/error.gif" border="0" /><%=otr(Z_TESTAPP/ERRORS_OCCURED_MSG)%>:
</td>
</tr>
<%
data: condition type string,
message type string,
severity type i,
ind type i.
ind = page->messages->num_messages( ).
do ind times.
call method page->messages->Get_message
exporting index = sy-index
importing condition = condition
message = message
severity = severity. %>
<tr>
<td class="TX_ERROR_XSB">- <%= message %> </td>
</tr>
<% enddo. %>
</table>
<!-- End Error Msg -->
Code: Alles auswählen.
<% if page->messages->num_messages( ) > 0. %>
<%@ include file="error.htm"%>
<% endif.
Code: Alles auswählen.
* check for messages
DATA: lv_lines TYPE i.
DESCRIBE TABLE lt_return LINES lv_lines.
IF lv_lines > 0.
READ TABLE lt_return INDEX 1 INTO ls_return.
IF ls_return-type = 'S' AND ls_return-id = '01'
AND ls_return-number = '102'.
ELSE.
LOOP AT lt_return INTO ls_return.
CALL METHOD page->messages->add_message_from_t100
EXPORTING
condition = errormessage
msgid = ls_return-id
msgno = ls_return-number
msgty = ls_return-type.
ENDLOOP.
EXIT.
ENDIF.
ENDIF.