You are on page 1of 4

11/23/2016

SAPTechnical.COMWorkingwithBusinessObjects

Search

Home Trai ni ngs Qui z Ti ps Tutori al s Functi onal Cert Q's I ntervi ew Q's Jobs Testi moni al s Adverti se Contact Us

SAP Virtual/Onsite
Trainings
Document Categories:
ABAPTM
AdobeForms
ABAPHR
ALE&IDocs
ALV
BAPI
BASIS
BSP
BusinessObjects
BusinessWorkflow
CRMNEW
LSMW
SAPScript/SmartForms
BI/BW
eXchangeInfrastructure(XI)
EnterprisePortals(EP)
eCATT
ObjectOrientedProgramming
SAPQuery
Userexits/BADIs
WebDynproforJava/ABAPTM
Others

Working with Business Objects in SAP


...Previous
SavethemethodandthenClickontheProgrambuttontoimplementthemethod.Inthemethodjustreadall
ebeln(Purchaselineitems)correspondingtoPOnumberintointernaltableITEMandpassitontocontainer
inthemethod.Checkthesnapshotbelow.

What's New?
ABAPTestCockpitHOT
SAPABAPPragmas
UnderstandingSE32(ABAPText
ElementMaintenance)
CreatinganIDocFileonSAP
ApplicationServer
UnderstandingAdvancewith
dialogoptionofSAPWorkflow
SAPWorkflowScenario:
MaintenanceNotification
Approval
Enhancementstoastandard
class
WorkingwithFloatingFieldin
AdobeForms
InsertingdatafromInternalTable
intothestepSendMail
DisplayGLAccountlongtext
usingenhancementframework
Differencesbetween
polymorphisminJAVAand
ABAP
Passingmultilineparameters
fromanABAPClasseventtoa
Workflowcontainer
ConceptofReevaluateagents
foractiveworkitemsinSAP
Workflow
Dynamiccreationofcomponent
usageinABAPWebDynpro
AdobeForms:Displaysymbols
likecopyrightandothers
DeactivateHoldfunctionalityin
Purchaseorder(ME21N)
QuizonOOABAP
AddfieldsinFBL5NusingBADIs
TutorialonWidecasting
DefiningaRangeinModulePool
Program
Copyfieldsfromone
structure/tableintoanother
structure/table
SidePanelUsageinNWBC

Contribute?
Sample Specs
What's Hot?
WebDynproforABAPTutorials

JointheMailingList
Enternameandemailaddressbelow:

CheckthewholecodeoftheBOprogramhere.
*****ImplementationofobjecttypeZSWE1*****
INCLUDE<OBJECT>.
BEGIN_DATAOBJECT."Donotchange..DATAisgenerated
*onlyprivatemembersmaybeinsertedintostructureprivate
DATA:
"beginofprivate,
"todeclareprivateattributesremovecommentsand
"insertprivateattributeshere...
"endofprivate,
BEGINOFKEY,
PURCHASINGDOCUMENTLIKEEKKOEBELN,
ENDOFKEY.
END_DATAOBJECT."Donotchange..DATAisgenerated
BEGIN_METHODREADCHANGINGCONTAINER.
DATA:
PURCHASINGDOCUMENTTYPEEKKOEBELN,
ITEMTYPEEKPOEBELPOCCURS0.
SWC_GET_ELEMENTCONTAINER'PurchasingDocument'PURCHASINGDOCUMENT.
selectebelpintotableitemfromekpo
whereebeln=PURCHASINGDOCUMENT.
SWC_SET_TABLECONTAINER'Item'ITEM.
END_METHOD.

Step1:SavethechangesandmakethestatusoftheBOtoimplementedfortestingpurpose.Alsogenerate
theBO.
Step2:NowletstesttheBO.ForthisputabreakpointinthemethodREADattheselectquery.Alsotake
anyPOnumberwhichwillhavemultiplelineitems.YoucancheckEKKOandEKPOtables.InmycaseIam
takingPO4200000017.InmyR3systemthisparticularPOcontains4lineitemsinEKPOtable.Letsput a
breakpointandcheckthemethod.

http://saptechnical.com/Tutorials/Workflow/BusinessObjects/Page2.htm

1/4

11/23/2016

SAPTechnical.COMWorkingwithBusinessObjects
Name:
Email:
Subscribe

Unsubscribe

GO

Step3:ExecutetheBOwithkey4200000017

Executethemethodwithimportparameteras420000017

Itwilltakeyoutodebuggingmode.Nowcheckthecontainer.
IndebugmodebeforetheselectstatementtheCONTAINERwillholdonlyimportvariable

NowexecutethelaststatementinthemethodandseethecontentsofCONTAINER(justbeforeexitingthe
method.

http://saptechnical.com/Tutorials/Workflow/BusinessObjects/Page2.htm

2/4

11/23/2016

SAPTechnical.COMWorkingwithBusinessObjects

SowehaveseenhowtheCONTAINERholdsvalueswhileweareworkingwithBusinessObjectsatruntime.

1.2.2Some common macros defined in include <CNTN01> for working with Containers

Functionality

Macro

TowriteasinglelinevariableinContainer

SWC_SET_ELEMENT

ToreadasinglelinevariablefromContainer

SWC_GET_ELEMENT

TowriteamultilinevariableorinternaltableinContainer

SWC_SET_TABLE

ToreadamultilinevariableorinternaltablefromContainer

SWC_GET_TABLE

Toclearthecontainer

SWC_CLEAR_CONTAINER

Further you can check the include <CNTN01> for more macros. Also check the macros. These macros call
somespecificfunctionmodulesthatyoucanusedirectlyinyourcode.

1.3Calling a BO Method/Attribute in report programs


WecancreateainstanceofBOmethodusingFM'SWO_CREATE'ormacroSWC_CREATE_OBJECT.
FirstofallletsconsideraBO'BUS1001006'(StandardMaterial).WewillcallthemethodDISPLAY.Forthis
wewillinstantiatetheBOwithkeyZSHUKSWE20(materialnumber).
TocallamethodorattributeofanyBOwecanusetheFM'SWO_INVOKE'.Wehavetotakecarewhilewe
call this FM. Suppose if we want to call an attribute defined in the method, then we need to populate the
importparameterACCESSwithG.IfweneedtocallthemethodoftheBOthenweneedtopopulatethe
importparameterACCESSwithC.
Letscreateareportprogramandcheckstep by step. We will fetch details of attribute MATERIALTYPE of
BO'BUS1001006'
*&*
*&ReportZSWET_BO1
*&
*&*
*&TogetattributesofBOinstanceinreport
*&
*&*
REPORTzswet_bo1.
PARAMETERS:p_busobj(10)TYPEcDEFAULT'BUS1001006',
p_key(70)TYPEcDEFAULT'ZSHUKSWE20',
p_attr(32)TYPEcDEFAULT'MATERIALTYPE',
p_accessTYPEcDEFAULT'G'."Tocallmethodput'C'
DATA:
i_objtypeTYPEswo_objtyp,
i_objkeyTYPEswo_typeid,
i_elementTYPEswo_verb.
DATAobjectTYPEswo_objhnd.
DATAverbTYPEswo_verb.
DATAreturnTYPEswotreturn.
DATAlt_containerTYPESTANDARDTABLEOFswcont.
DATAlineTYPEswcont.
i_objtype=p_busobj.
i_element=p_attr.
i_objkey=p_key.
*Instantiatethebusinessobject.i.egiveitakeyandcreateit.
CALLFUNCTION'SWO_CREATE'
EXPORTING
objtype=i_objtype
objkey=i_objkey

http://saptechnical.com/Tutorials/Workflow/BusinessObjects/Page2.htm

3/4

11/23/2016

SAPTechnical.COMWorkingwithBusinessObjects
IMPORTING
object=object.
*Returnattribute.
CALLFUNCTION'SWO_INVOKE'
EXPORTING
access=p_access
object=object
verb=i_element
IMPORTING
return=return
verb=verb
TABLES
container=lt_container.
*TheattributevalueisinthecontainerreturnedfromFM.
IFreturncode=0.
LOOPATlt_containerINTOline.
WRITE:/'AttributeMATERIALTYPEis:',
linevalue.
ENDLOOP.
ENDIF.

Letsexecutethereportandseetheoutput:

Clickheretocontinue...

Retirement
Planning
AreYouPreparedFor
Retirement?EstimateYour
RetirementCorpus.
bigdecisions.com

Pleasesendusyourfeedback/suggestionsatwebmaster@SAPTechnical.COM
HomeContributeAboutUsPrivacyTermsOfUseDisclaimerSafeCompanies:AdvertiseonSAPTechnical.COM|PostJobContactUs
20062007SAPTechnical.COM.Allrightsreserved.
Allproductnamesaretrademarksoftheirrespectivecompanies.SAPTechnical.COMisinnowayaffiliatedwithSAPAG.
SAP,SAPR/3,R/3software,mySAP,ABAP,BAPI,xApps,SAPNetWeaver,andandanyotherSAPtrademarksareregisteredtrademarksofSAPAGinGermanyandinseveralothercountries.
Everyeffortismadetoensurecontentintegrity.Useinformationonthissiteatyourownrisk.

GraphicDesignbyRoundtheBendWizards

http://saptechnical.com/Tutorials/Workflow/BusinessObjects/Page2.htm

4/4

You might also like