SAP ABAP Central - Smartforms OOPS (Object Oriented)

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

10/20/2016

SAPABAPCentral:SmartformsOOPS(objectoriented)

More NextBlog

kumar.smith2009@gmail.com Dashboard SignOut

SAPABAPCentral
Home

SAPABAPTutorials

InterviewQ&A

Job

Certifications

Monday,17October2016

SearchThisBlog

Search

SmartformsOOPS(objectoriented)
IhavenothadthatmuchopportunitytoworkwithSmartFormstillveryrecently.Ihad
alreadyswitchedtoEclipse&ADTasmyprimaryprogrammingtoolandthoughtIcould
getawaythis,nothavingtogobacktoSAPGuibaseddevelopmentandthenI
encounterSmartForms!IcantevenusenormaldaytodayABAPEditortools,cantuse
normalbreakpoints,cantdoawhereused,severaldrillthroughsdontworkwhatdidI
justgetmyselfinto!
AfterthefirstonethatIvolunteeredmakingchangesto,werealizedIhadtodoonefrom
scratch.HereisanopportunityImovedallthecodeouttoaclassandcalledtheclass
fromwithintheSmartForm.ThiswayIhaveallthetoolsthatSAP&ABAPprovideto
workwithcode,IcanusetheADTenvironment,testthedataoutputindependentofthe
SmartForm,useeditorbasedbreakpoints,etc,etc
Hereisastepbystepsampleofapicklistprintedfromawarehousetransferorder.

BlogArchive

2016(32)
October(9)
MD5calculationviaABAPand
JavaScript
HowToUseVBARecorded
CodeinABAP
SmartformsOOPS(object
oriented)
ImageinMailbodyinABAP
PurchasingDocument
ApprovalProcesswith
ManualA...

STEP1Createclasstocollectdata

SAPscriptformsbreakdown
tool

CLASSztestclass_pick_listDEFINITION
PUBLIC
FINAL
CREATEPUBLIC.

Customfunctionmoduletoget
thedatesoflastFr...

PUBLICSECTION.
DATA:
http://sapabapcentral.blogspot.in/2016/10/smartformsoopsobjectoriented.html#more

HowtocreateacustomTABfor
MIGOItemDetails
ConvertingExcelfiledatawith
multiplesheetsto...
1/7

10/20/2016

SAPABAPCentral:SmartformsOOPS(objectoriented)

g_lgnumTYPElgnum,
g_ltakTYPEltak,
gi_ltapTYPESORTEDTABLEOFltapWITHUNIQUEDEFAULTKEY,
g_vbelnTYPEvbeln,
g_companyTYPEchar15.
METHODSconstructor
IMPORTING
lgnumTYPElgnum
tanumTYPEtanum.
PROTECTEDSECTION.
PRIVATESECTION.
ENDCLASS.

CLASSZTESTCLASS_PICK_LISTIMPLEMENTATION.

*<SIGNATURE>+
*|InstancePublicMethodZTESTCLASS_PICK_LIST>CONSTRUCTOR
*++
*|[>]LGNUMTYPELGNUM
*|[>]TANUMTYPETANUM
*+</SIGNATURE>
METHODconstructor.
"SelectTOheader
SELECTSINGLE*FROMltak
WHERElgnum=@lgnum
ANDtanum=@tanum
INTO@g_ltak.
IFsysubrc=0.
"SelectTOline
SELECT*FROMltap
WHERElgnum=@lgnum
ANDtanum=@tanum
INTOTABLE@gi_ltap.

September(19)
August(2)
July(1)
January(1)
2015(5)
2014(2)
2013(3)
2012(2)

PopularPosts

Howtocompare
thecontentsof
transport
Request?
Overview:Igotthis
requirementinmy
projecttocomparethecontentsof
eachtransport.Luckilythis2
programscameinhandyforme.
...
Howtocreatea
customTABfor
MIGOItemDetails
Ihave
implementeda
customtabin
MIGO,youcanfollowthesteps.
Myrequirementwastoaddanew
tabnamedWarrantyinMIGO.
Step1...
SelectionScreen
VariantsPartI
Whatarevariants?
InSAPABAP
reportshavea
mechanismfor
enteringvaluesfordatabase
selectionorforperforming
differentcalculati...

"Populatestandaloneattributesfromvarioussources
http://sapabapcentral.blogspot.in/2016/10/smartformsoopsobjectoriented.html#more

2/7

10/20/2016

SAPABAPCentral:SmartformsOOPS(objectoriented)

g_lgnum=lgnum.
g_vbeln=g_ltakvbeln.
g_company='ACMEWIDGETCo'.
ELSE.
"Raiseerrorhere
ENDIF.
ENDMETHOD.
ENDCLASS.
Inthisclassdeclarepublicattributesforthedatathatyouwillberetrievingfromthe
SmartForm.Inthisexample,IwillberetrievingtheTransferOrdernumber,aCompany
nameandTransferOrderItemdetails.
Step2CreatetheSmartForm
WhencreatingtheSmartForm,createthelayoutanddesignasyounormallywould.The
differenceisinthecodeanddeclarations.Firstintheforminterface,declareonlythe
variablesthatarealreadyavailabletothecallingprogram.Ifthecallingprogramdoesnot
alreadyhavethedata,dontbothercollectingthedataandpassingitinthatisthejobof
theclass.Inthiscase,Ihavethewarehouseandtransferordernumber.Fromthisthe
classcangetthedataneededforthereport.

MockingDAOs
withABAPTest
Double
Framework
IntroductionThe
samplebelowis
verybasicandnorealbusiness
logicisincludedbecauseit
focusesontheconcepts.Forthe
dependenc...
EssentialBasisfor
SAP(ABAP,BW,
Functional)
ConsultantsPartII
Thisblogis
continuationof
EssentialBasisforSAP(ABAP,
BW,Functional)ConsultantsPart
ITransportsysteminSAPisused
tomoveob...

Intheglobaldefinitions,Ihaveasinglevariable(OB_PICK_DATA)declaredwith
referencetotheclassIhavecreated.Thisisthevariablethatwillbeusedthroughoutthe
SmartFormforaccesstodata.

http://sapabapcentral.blogspot.in/2016/10/smartformsoopsobjectoriented.html#more

3/7

10/20/2016

SAPABAPCentral:SmartformsOOPS(objectoriented)

IalsohaveaFieldSymboldeclaredthatwillbeusedtogetthelineitemdetailsforthe
tableLTAP.

AndhereistheonlycodethatgoesintotheentireSmartForm!Itishardtoimaginewhy
anyonewouldwanttoputabreakpointhere!

Ifyouarewritingthisinpre7.4ABAP,youwouldwritethisas
CREATEOBJECTob_pick_data
EXPORTING
lgnum=lgnum
http://sapabapcentral.blogspot.in/2016/10/smartformsoopsobjectoriented.html#more

4/7

10/20/2016

SAPABAPCentral:SmartformsOOPS(objectoriented)

tanum=tanum.
Notethatintheoutputparameters,thereisalsothefieldsymbol<LTAP>eventhough
thereisnodatabeingset.Thisispreventsubsequenterror/warningmessagesstating
Field<ltap>matnrhasnodefinedvalue.
Intheindividualtextelements,thedatacanbeaccessedfromtheattributesoftheclass
directlyorasanelementofastructure.Inthiscase,Ihaveused
Companyname:&OB_PICK_DATA>G_COMPANY&
TransferOrderNumber:&OB_PICK_DATA>G_LTAKTANUM&
Warehousetopickfrom:&OB_PICK_DATA>G_LTAKLGNUM&
Foratabularoutputitself,youhavetoreferencetheattributeasaninternaltable.Inthis
case,OB_PICK_DATA>GI_LTAPisatableofTransferOrderLinesthatIamassigning
tothefieldsymbol<LTAP>.AnotheralternativehereistodeclareaGlobalFieldand
havethedatagoingintoitinsteadofassigning.Ifyouwanttoavoidanyvariableonthe
SmartForm,youcancreateanattributeintheclassandsendthedatatothatvariable.
Whilethisispossible,Ifeelthatafieldsymbolbeingapointeristhemostefficientway
toaccessthisdata.
Intheindividualcells,youreferencethefieldsymbolorlocalvariableinthiscaseinstead
oftheobject.
"UsingFieldSymbol
&<LTAP>TAPOS&
&<LTAP>MATNR&
"OR
"Usingavariable
&L_LTAPTAPOS&
&L_LTAPMATNR&
Andstep3thereisnostep3justtestanduse!AnotheradvantagethatIhavenot
usedyetisthatyoucouldsetupatestclasssothatyouarecoveredforimmediate
testingaswellasfutureregressiontesting.TrythatwithstandardSmartFormcode!
PostedbySabrinaPintoat00:00

+3 Recommend this on Google


http://sapabapcentral.blogspot.in/2016/10/smartformsoopsobjectoriented.html#more

5/7

10/20/2016

SAPABAPCentral:SmartformsOOPS(objectoriented)

Labels:ABAPOOP,SQL

2comments:
FelecianoBuenavista 18October2016at02:39
Thiscommenthasbeenremovedbytheauthor.
Reply

FelecianoBuenavista 18October2016at02:41
JustWOW!Bookmarkedforfuturereference.
Reply

Enteryourcomment...

Commentas:

Publish

smith(Google)

Signout

Notifyme

Preview

NewerPost

Home

OlderPost

Subscribeto:PostComments(Atom)

2016sapabapcentral.com,Allrightsreserved.Simpletemplate.PoweredbyBlogger.
http://sapabapcentral.blogspot.in/2016/10/smartformsoopsobjectoriented.html#more

6/7

10/20/2016

http://sapabapcentral.blogspot.in/2016/10/smartformsoopsobjectoriented.html#more

SAPABAPCentral:SmartformsOOPS(objectoriented)

7/7

You might also like