38Day2YourFirstABAP/4ProgramBeforeProceedingExploringtheDevelopmentEnvironmentDiscoveringProgramTypesoDefiningReportsoDefiningDialogProgramsDiscoveringReportComponentsoDiscoveringtheProgramRuntimeObjectoIntroducingProgramNamingConventionsCreatingYourFirstProgramExploringtheSourceCodeEditoroUsingtheEditor:InitialScreenoExploringtheFunctionalityoftheSourceCodeEditorGettingHelpoObtainingF1HelpoObtainingR3LibraryHelpFindingYourDevelopmentObjectsIntroducingtheR/3DataDictionaryoExploringTablesandStructuresoDisplayingaTableorStructureDefinitionoDisplayingDataintheTableoDeterminingDisplayedFieldsUnderstandingABAP/4SyntaxoIntroducingtheselectStatementoUnderstandingTableWorkAreasoIntroducingthewhereClauseoWorkingwithSystemVariablesoUsingtheChainOperatoroUsingtheselectsingleStatementoCommentingCodeandFormalDocumentationSummaryQ&AWorkshopoQuizoEditorExercisesoProgrammingExercisesAfteryoucompletethischapter,youshouldbeableto:CreateandmodifysimpleABAP/4programs.UsestandardfunctionsintheABAP/4editor.UseF1andR/3Libraryhelpfunctions.FindyourprogramsusingtheObjectBrowserandtheeditor.DisplayatableanditscontentsusingtheDataDictionary.39Usethetablesandselectstatements.Chainstatementstogetherusingthechainoperator.Addcommentsanddocumentationtoyourprograms.BeforeProceedingBeforeproceeding,youshould:BecomfortablewithaprogramminglanguagesuchasC,COBOL,orVisualBasic.Toobtainthefullbenefitfromthisandallfollowingchapters,youshouldalsohavetwoormoreyearsofpreviousdevelopmentexperience.SetupyourinterfaceasrecommendedinDay1inthesectionTheInterfaceMenu,ifyouhavenotdonesoalready.PerformtheinstallprocedurefortheScreenCamsontheCD-ROM.Theinstallprocedureisdescribedinthereadme.txtfilefoundintherootdirectoryoftheCD-ROM.ManyoftheproceduresinthisbookaredemonstratedusingScreenCams.ScreenCamsarelikemovies;theyshowaseriesofscreens,includingkeystrokesandmousemovements,withadescriptivevoiceover.TheycanbefoundontheCD-ROMthatcomeswiththisbook.Seethereadme.txtfilefoundintherootdirectoryoftheCD-ROMformoreinformation.ExploringtheDevelopmentEnvironmentAdevelopmentobjectisanythingcreatedbyadeveloper.Examplesofdevelopmentobjectsareprograms,screens,tables,views,structures,datamodels,messages,andincludes.TheR/3systemcontainstoolsforcreatingandtestingdevelopmentobjects.ThesetoolsarelocatedintheR/3DevelopmentWorkbench.Toaccessanydevelopmenttool,yougototheworkbench.Theworkbenchcontainsthesetoolstohelpyoucreatedevelopmentobjects:TheABAP/4programeditorwhereyoucancreateandmodifyABAP/4sourcecodeandotherprogramcomponentsTheDataDictionarywhereyoucancreatetables,structures,andviewsTheDatamodelerwhereyoucandocumenttherelationshipsbetweentablesTheFunctionlibrarywhereyoucancreateglobalABAP/4functionmodulesThescreenandmenupainterswhereyoucancreateauserinterfaceforyourprogramsThefollowingtestingandsearchtoolsarealsoavailable:theABAP/4DebuggertheSQLtracetoolusedtotuneSQLstatementstheruntimeanalyzerforoptimizingyourprogram'sperformanceawhere-usedtoolforimpactanalysisacomputer-aidedtesttoolforregressiontesting40arepositorysearchtoolforfindingdevelopmentobjectstheWorkbenchOrganizerforrecordingchangestoobjectsandpromotingthemintoproductionAlldevelopmentobjectsareportable,meaningthatyoucancopythemfromoneR/3systemtoanother.Thisisusuallydonetomoveyourdevelopmentobjectsfromthedevelopmentsystemtotheproductionsystem.Ifthesourceandtargetsystemsareondifferentoperatingsystemsorusedifferentdatabasesystems,yourdevelopmentobjectswillrunas-isandwithoutanymodification.ThisistrueforallplatformssupportedbyR/3.(Foralistofsupportedhardwareandoperatingsystems,refertoTable1.1.)DiscoveringProgramTypesTherearetwomaintypesofABAP/4programs:reportsdialogprogramsDefiningReportsThepurposeofareportistoreaddatafromthedatabaseandwriteitout.Itconsistsofonlytwoscreens(seeFigure2.1).Figure2.1:Theselectionscreenandtheoutputscreen.Thefirstscreeniscalledtheselectionscreen.Itcontainsinputfieldsallowingtheusertoentercriteriaforthereport.Forexample,thereportmayproducealistofsalesforagivendaterange,sothedaterangeinputfieldswouldappearonthereport'sselectionscreen.Thesecondscreenistheoutputscreen.Itcontainsthelist.Thelististheoutputfromthereport,andusuallydoesnothaveanyinputfields.Inourexample,itwouldcontainalistofthesalesthatoccurredwithinthespecifieddaterange.Theselectionscreenisoptional.Notallreportshaveone.However,allreportsgeneratealist.Inthisbook,youwilllearnhowtocreatereportprograms.DefiningDialogProgramsDialogprogramsaremoreflexiblethanreports,andsoaremorecomplexattheprogramlevel.Theycancontainanynumberofscreens,andthescreensequencecanbechangeddynamicallyatruntime.Oneachscreen,youcanhaveinputfields,outputfields,pushbuttons,andmorethanonescrollablearea.DiscoveringReportComponentsABAP/4reportsconsistoffivecomponents(showninFigure2.2):41Figure2.2.ThecomponentsofanABAP/4program.SourcecodeAttributesTextelementsDocumentationVariantsOnlythesourcecodeandprogramattributecomponentsarerequired.Therestofthecomponentsareoptional.AlldevelopmentobjectsandtheircomponentsarestoredintheR/3dat