Sie sind auf Seite 1von 27

Business Object Builder

Transaction SWO1

Business Object Builder


Transaction SWO1.
You can create a new object type You can create a Subtype of an existing object type

SWO1 (Create Subtype)

All fields are Mandatory

Assign a Package

Object Created

ZBUS2089 created
ZBUS2089 will inherit all the properties of this Super type BUS2089. Attributes, Methods and Events of super type are available in ZBUS2089. Attributes, Methods and Events added in ZBUS2089 will not be available in BUS2089.

Create a new Method

Say No

Create with function module


This will allow you to enter the Function module name and will create the code for the method for you. However, you can add your additional code to it. BAPIs can also be added to a object type with the help of this feature.

Enter Details and Continue

Select and click Program Button.

Enter The code


BEGIN_METHOD SEND_MAIL_TO_NOTES CHANGING CONTAINER. DATA: l_ln like pa0105-usrid_long, l_trip_tot(20) type c, l_msg(500) type c. DATA: OBJCONT LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE, RECLIST LIKE SOMLRECI1 OCCURS 0 WITH HEADER LINE, OBJHEAD LIKE SOLISTI1 OCCURS 0 WITH HEADER LINE, DOC_CHNG LIKE SODOCCHGI1, ENTRIES LIKE SY-TABIX, l_pernr like pa0105-pernr, l_trip_total like PTRV_SHDR-TRIP_TOTAL, l_sub(60) type c, l_body1(100) type c, l_body2(100) type c, l_body3(100) type c, l_body4(100) type c, l_body5(100) type c. swc_get_element container 'PersonnelNumber' l_pernr. swc_get_element container 'TotalCosts' l_trip_total. swc_get_element container 'Subject' l_sub. swc_get_element container 'Bodytxt1' l_body1. swc_get_element container 'Bodytxt2' l_body2. swc_get_element container 'Bodytxt3' l_body3. swc_get_element container 'Bodytxt4' l_body4. swc_get_element container 'Bodytxt5' l_body5. select usrid_long up to 1 rows into l_ln from pa0105 where pernr = l_pernr and SUBTY = '0010' and endda = '99991231'. endselect.

Contd.

Code continued
DOC_CHNG-OBJ_NAME = 'WF e-mail'. DOC_CHNG-OBJ_DESCR = l_sub. DOC_CHNG-SENSITIVTY = 'P'. concatenate l_body1 l_body2 l_body3 l_body4 l_body5 into l_msg separated by space. condense l_msg. OBJHEAD = l_sub. APPEND OBJHEAD. OBJCONT = l_msg. APPEND OBJCONT. DESCRIBE TABLE OBJCONT LINES ENTRIES. READ TABLE OBJCONT INDEX ENTRIES. DOC_CHNG-DOC_SIZE = ( ENTRIES - 1 ) * 255 + STRLEN( OBJCONT ). CLEAR RECLIST. RECLIST-RECEIVER = l_ln. RECLIST-express = 'X'. RECLIST-REC_TYPE = 'U'. APPEND RECLIST. * Send the document CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1' EXPORTING DOCUMENT_TYPE = 'RAW' DOCUMENT_DATA = DOC_CHNG PUT_IN_OUTBOX = 'X' TABLES OBJECT_HEADER = OBJHEAD OBJECT_CONTENT = OBJCONT RECEIVERS = RECLIST EXCEPTIONS TOO_MANY_RECEIVERS =1 DOCUMENT_NOT_SENT =2 OPERATION_NO_AUTHORIZATION = 4 OTHERS = 99. endif. END_METHOD.

Code for method


Check Save Generate

Go Back and Select Parameters Button

Create Parameters

Say No

Create an Import parameter without any Data type reference

Parameters created

Check and Save Object Type to release the method

Implement the method First

Then Release

Now implement the Object type

Release the Object type

The Subtype of an Object Type is created

To create a new Object Type


Select Create from Menu Object type and enter details. Keep Super type blank for a new object type. Add methods, attributes and events to the new object type. Implement method, attributes and events and then release them. Finally, implement and release the Object type.

Das könnte Ihnen auch gefallen