版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
1SAPABAP/4培訓賽跑網(wǎng)2012年2012年09月2ABAP開發(fā)培訓內(nèi)容大綱一.ABAP開發(fā)的全局概念和開發(fā)環(huán)境二.ABAP數(shù)據(jù)字典和基本語法三.ABAP開發(fā)的系統(tǒng)操作四.開發(fā)程序的輸出五.開發(fā)技巧六.開發(fā)流程和代碼規(guī)范3ABAP開發(fā)培訓內(nèi)容大綱一.ABAP開發(fā)的全局概念和開發(fā)環(huán)境二.ABAP數(shù)據(jù)字典和基本語法三.ABAP開發(fā)的系統(tǒng)操作四.開發(fā)程序的輸出五.開發(fā)技巧六.開發(fā)流程和代碼規(guī)范4Advanceddvanced
BusinessusinessProgrammingrogrammingApplicationpplicationABAP的含義和概念A(yù)BAP/4是一個面向?qū)ο蟮姆蟂QL標準的第四代專業(yè)開發(fā)語言。SAPR3的絕大部分是用ABAP/4開發(fā)的。SAP最初開發(fā)ABAP/4(高級商業(yè)應(yīng)用程序設(shè)計)語言僅為內(nèi)部使用,為應(yīng)用程序員提供優(yōu)化的工作環(huán)境。經(jīng)過不斷的改進和修改以滿足商業(yè)領(lǐng)域的需要。現(xiàn)在,ABAP/4已成為SAP開發(fā)所有自己的應(yīng)用程序的專用工具。SAP客戶用ABAP/4進行其自身開發(fā)。這樣的開發(fā)通常稱為SAP系統(tǒng)的二次開發(fā)。ABAP/4開發(fā)工作平臺包含所有用于創(chuàng)建和維護ABAP/4程序的工具。5ABAP開發(fā)的運行環(huán)境ApplicationPresentationDatabaseSAPSAPGUIGUISAPSAPGUIGUISAPSAPGUIGUISAPSAPGUIGUI
ABAPABAPABAPABAPRDBMSRDBMSClient/ServerArchitecture6Client-independentcustomizingABAPRepositorycustomizingBASISDBOStestingtrainingABAP資源庫與系統(tǒng)架構(gòu)FunctionModules
ProgramsTablesFIHRMMSDWMMMDevelopmentClassesMMRepositoryObjects7ABAP開發(fā)傳輸路徑RChangeRequestDevelopmentsystemProductionsystemTransportingRepositoryObjects開發(fā)/測試系統(tǒng)生產(chǎn)系統(tǒng)注意:開發(fā)的對象與集團無關(guān)8ABAP開發(fā)培訓內(nèi)容大綱一.ABAP開發(fā)的全局概念和開發(fā)環(huán)境二.ABAP數(shù)據(jù)字典和基本語法三.ABAP開發(fā)的系統(tǒng)操作四.開發(fā)程序的輸出五.開發(fā)技巧六.開發(fā)流程和代碼規(guī)范9ABAP開發(fā)培訓內(nèi)容大綱一.ABAP開發(fā)的全局概念和開發(fā)環(huán)境二.ABAP數(shù)據(jù)字典和基本語法三.ABAP開發(fā)的系統(tǒng)操作四.開發(fā)程序的輸出五.開發(fā)技巧六.開發(fā)流程和代碼規(guī)范10 數(shù)據(jù)字典對象表或結(jié)構(gòu)的類型表類型確定對應(yīng)定義在ABAP/4詞典中的邏輯表格說明的物理表是否存在。在數(shù)據(jù)庫中同時定義這種表的結(jié)構(gòu)。SAP系統(tǒng)包含下列表類型:透明表(TransparentTable)每個透明表在數(shù)據(jù)庫中有一個相應(yīng)的物理表。物理表的名稱和數(shù)據(jù)字典中的邏輯表定義的名稱一致。所有事務(wù)和應(yīng)用數(shù)據(jù)存貯在透明表中。結(jié)構(gòu)(Structure)結(jié)構(gòu)在數(shù)據(jù)庫不存在數(shù)據(jù)記錄。結(jié)構(gòu)用于在程序之間或程序與屏幕之間的接口定義。視圖(View)若干個透明表通過某些條件連接在一起的一個相應(yīng)的邏輯表。SAP系統(tǒng)的其他數(shù)據(jù)字典對象:數(shù)據(jù)元素(DataElement)
通常用于描述一個數(shù)據(jù)定義域的屬性、信息以及搜索幫助。域(Domain)
定義一個字段的技術(shù)信息,例如數(shù)據(jù)類型,數(shù)據(jù)范圍。11TableAdomainusesusesdataelementAtablefieldA數(shù)據(jù)字典對象關(guān)系TableBtablefieldBdataelementB表,字段,數(shù)據(jù)元素,域12字段數(shù)據(jù)元素13viewviewDBDBABAPDictionarytables數(shù)據(jù)字典:視圖ABAPDictionary
transparenttableAfield1field2field3field4ABAPDictionary
transparenttableBfield1field2field3field414數(shù)據(jù)瀏覽器(1)ABAP/4WorkbenchToolsOverviewDataBrowser(SE16)Tablename15數(shù)據(jù)瀏覽器(2)可以輸入查詢字段的內(nèi)容和輸出清單的寬度以及最大的命中量16基本語法:鏈式語句WRITE'XYZ'.WRITENAME.WRITECOUNTER.WRITE:'XYZ',NAME,COUNTER.ADD1TOCOUNTER1.ADD1TOCOUNTER2.ADD1TOCOUNTER3.ADD1TO:COUNTER1,COUNTER2,COUNTER3.17基本語法:數(shù)據(jù)類型和數(shù)據(jù)對象(2)DatatypesDataobjectsDATAD1TYPET1.DATAD5TYPEC.DATAD6TYPEC.DATAD2TYPET1.DATAD4TYPET1VALUE'ABC'.DATAD3TYPET1VALUE'123'.TYPEST1(3)TYPEC.TYPECUserdefinedUserdefinedPre-definedPre-defined18基本語法:數(shù)據(jù)類型Pre-defined(P,I,F,C,N,D,T,X)ElementaryStructuretypeTabletypeStructuredUserdefinedDatatype19基本語法:預(yù)定義數(shù)據(jù)類型Datatype Meaning Initialvalue Standard Allowed length lengthPackednumber 0 8 1-16Integer 0 *4 *10Floatingpointno. 0.0000…E+00 *8 *16Numerictext 00...00 1 1-max.Text(character) Blank 1 1-max.Date(YYYYMMDD) 00000000 8Time(HHMMSS) 000000 6Hexadecimal X'00' 2 1-max.*Machine-specific max.:approx.64,000Byte壓縮型整型浮點型數(shù)值型文本型日期型時間型十六進制型IPre-defined:20基本語法:用戶定義數(shù)據(jù)類型RPre-defined(P,I,F,C,N,D,T,X)ElementaryFieldstringtypeTabletypeStructuredUserdefinedDatatypeTYPES<type2>[(<length>)]TYPE<type1>[OCCURS0].TYPES<type>LIKE<dataobject>[OCCURS0].TYPES:BEGINOF<typ>,...,ENDOF<typ>.Anamemaynotconsistonlyofnumbersmendation:Alwaysusealetterasthefirstcharacter.Ifyouarecombiningwordsinthename,separatethemwithanunderscore
RulesforassigningtypenamesThemaximumlengthforanameis30characters(Letters,numbersandunderscore)Userdefined:TYPES<type>[(<length>)]TYPE<pre-defined>.21Pre-defined(P,I,F,C,N,D,T,X)ElementaryFieldstringtypeTabletypeStructuredUserdefinedDatatypeTYPES:NAME_TYPE(25)TYPEC,SUM_FIELD_TYPETYPEPDECIMALS2,DATE_TYPELIKESFLIGHT-FLDATE.TYPES<type2>[(<length>)]TYPE<type1>[DECIMALS<n>].基本語法:基礎(chǔ)數(shù)據(jù)元素定義Elementarytypes:22基本語法:用戶定義結(jié)構(gòu)類型Pre-defined(P,I,F,C,N,D,T,X)ElementaryFieldstringtypeTabletypeStructuredUserdefinedDatatypeTYPES:BEGINOFFLIGHTREC1_TYPE,FLAGTYPEC,CARRIDLIKESPFLI-CARRID,NAMETYPENAME_TYPE,SUM_FIELDTYPESUM_FIELD_TYPE,ENDOFFLIGHTREC1_TYPE,FLIGHTREC2_TYPETYPEFLIGHTREC1_TYPE.TYPES:BEGINOF<type>,...,ENDOF<type>.TYPES<type>TYPE<rectype>.Fieldstringtypes:23基本語法:用戶定義表類型Pre-defined(P,I,F,C,N,D,T,X)ElementaryFieldstringtypeTabletypeStructuredUserdefinedDatatypeTYPES<itabtype>TYPE<linetype>OCCURS0.TYPESFLIGHTINFOLIST1_TYPELIKESPFLIOCCURS0.TYPESFLIGHTINFOLIST2_TYPELIKESPFLI-CARRIDOCCURS0.Tabletypes:24TYPE-POOLZ400.TYPES:Z400_NAME_TYPE(25)TYPEC,Z400_FLIGHTTAB_TYPELIKESPFLIOCCURS0,....REPORT....TYPE-POOLSZ400.DATA:NAMETYPEZ400_NAME_TYPE,FLIGHTTABTYPEZ400_FLIGHTTAB_TYPE.....ABAP基本語法:數(shù)據(jù)字典的類型池TypesgroupsintheABAPdictionary:25基本語法:數(shù)據(jù)對象VariableLiteralConstantFixedDataobject可變的數(shù)據(jù)對象:我們通常翻譯成變量固定的數(shù)據(jù)對象:我們通常翻譯成常量26VariableLiteralConstantFixedDataobjectDATA<dataobject>TYPE<type>[VALUE<literal>].DATA<dataobject2>LIKE<dataobject1>[VALUE<literal>].DATA:BEGINOF<dataobject>,...,ENDOF<dataobject>.DATA<dataobject>TYPE<type>OCCURS<n>.RulesfornamingdataobjectsThemaximumlengthforanameis30characters(letters,digits,specialcharacters)Thefollowingspecialcharactersarenotallowed:()+.,:SPACEisapre-definedfield基本語法:變量Variabledataobjects:27DATA:COUNTERTYPEI,NAME1(25)TYPEC,START_DATETYPED,FIRST_LINETYPEIVALUE1,SUM1(5)TYPEPDECIMALS2,SUM_FIELDTYPESUM_FIELD_TYPE,NAME2LIKESCUSTOM-NAME,NAME3LIKENAME1.DATA<dataobject>TYPE<type>[VALUE<fixeddataobject>].VariableLiteralConstantFixedDataobject基本語法:基礎(chǔ)數(shù)據(jù)元素變量Elementarydataobjects:28Fieldstringsdataobjects:基本語法:結(jié)構(gòu)變量DATA:FLIGHTREC1TYPEFLIGHTREC1_TYPE.DATA:BEGINOFFLIGHTREC2,FLAGTYPEC,CARRIDLIKESPFLI-CARRID,NAMETYPENAME_TYPE,SUM_FIELDTYPESUM_FIELD_TYPE,ENDOFFLIGHTREC2.DATA:BEGINOF<fieldstring>,...,ENDOF<fieldstring>.<fieldstring>-<field>MOVE'X'TOFLIGHTREC2-FLAG.WRITEFLIGHTREC2-SUM_FIELD.VariableLiteralConstantFixedDataobject29Internaltables:基本語法:內(nèi)部表的定義DATA:FLIGHTLIST1TYPEFLIGHTREC1_TYPEOCCURS0.DATA:BEGINOFFLIGHLIST2OCCURS0,FLAGTYPEC,CARRIDLIKESPFLI-CARRID,NAMETYPENAME_TYPE,SUM_FIELDTYPESUM_FIELD_TYPE,ENDOFFLIGHTTAB2.DATA<itabobject>TYPE<linetype>OCCURS<n>.DATA<itabobject>TYPE<itabtype>.DATA:BEGINOF<itabobject>OCCURS<n>,...,ENDOF<itabobject>.manipulatetablesdynamically!!!VariableLiteralConstantFixedDataobject30基本語法:常量'abc','2.17','1.213E15','0FFF','A''B'Sequenceofcharactersenclosedininvertedcommas.Max.255charsTextliterals715,-431Wholenumber(withprecedingminussignifnegative)NumberliteralsCONSTANTS<constants>TYPE<type>VALUE<literal>.CONSTANTS:PITYPEPDECIMALS4VALUE'3.1415',BOSS(4)TYPECVALUE'Hugo'.ninedigitsorfewertenormoredigitsIPCtypeconversionifnecessaryLiteraltypeLiteraltypeVariableLiteralConstantFixedDataobjectLiteralsandconstants:31基本語法:初始化數(shù)據(jù)對象REPORT....DATA:NAME1(25)TYPEC,FIRST_LINE(4)TYPEIVALUE'4',FLIGHTRECTYPEFLIGHTREC1_TYPE.CLEAR:NAME1,FIRST_LINE,FLIGHTREC.CLEAR<dataobject>.InitializingaDataObject:Setsafieldtotheinitialvalueappropriateforitsdatatype32RDATA:NAME1(25)TYPEC,FIRST_LINE(4)TYPEN,SORT_NAMELIKENAME1,FLIGHTREC1TYPEFLIGHTREC1_TYPE,FLIGHTREC2TYPEFLIGHTREC1_TYPE,FLIGHTLIST1TYPEFLIGHTREC1_TYPEOCCURS0,FLIGHTLIST2TYPEFLIGHTREC1_TYPEOCCURS0.MOVE'SAP'TONAME1.MOVE5TOFIRST_LINE.SORT_NAME=NAME1.FLIGHTREC2=FLIGHTREC1.FLIGHTLIST2=FLIGHTLIST1.MOVE<dataobject1>TO<dataobject2>.<dataobject2>=<dataobject1>.REPORT....基本語法:賦值A(chǔ)ssigningValues33RDATA:COUNTERTYPEI,AMOUNTTYPEPVALUE1000,SUMTYPEP,RESULTTYPEP,NUMBER(2)TYPECVALUE'99',ROOTTYPEF.COUNTER=COUNTER+2.RESULT=AMOUNT*COUNTER.SUM=RESULT+NUMBER-COUNTER.RESULT=COUNTER*(AMOUNT+NUMBER).ROOT=SQRT(NUMBER+COUNTER).[COMPUTE]<field>=<arithmeticexpression>.+-/*DIVMODSQRTEXPLOGSINCOSSTRLENTAN...OperatorsFunctions基本語法:運算符34TypeLengthValueTypeLengthValue1A4A____4ABCD2AB7-47110_447110-312345-7_12345-SourcefieldSourcefieldTargetfieldTargetfieldCCCPCCPCConversionrulesexistforallallcombinationsofelementarytypes(exceptforTtoDandviceversa)基本語法:類型轉(zhuǎn)換(2)ConversionRule:ElementaryTypes35基本語法:Write語句(1)REPORT ZXX02line-size165line-count66.WRITE: '******************************'.SKIP2.WRITE: 'Date', SY-DATUM.WRITE: 'Time', SY-UZEIT.SKIP2.WRITE: '******************************'.01.01.20066TestReport 1******************************Date01.01.2006Time17:18:38******************************36REPORT ZXX02.WRITE: 5'******************************'.SKIP.WRITE: 5'Date', 20SY-DATUM,
/5'Time',20SY-UZEIT.ULINE /5(30).SKIP2.ULINE.Column20Column501.03.2006AnotherTestReport 1******************************Date01.03.2006Time12:22:06
基本語法:Write語句(2)37基本語法:Write語句(3)REPORT ZXX02.DATA: POSTYPEIVALUE5, LENTYPEIVALUE25.WRITEAT/POS(LEN)'******************************'.SKIP.WRITEAT:POS'Date',20SY-DATUM,/POS'Time',20SY-UZEIT.ULINEAT/POS(LEN).01.01.2006YetAnotherTestReport 1*************************Date01.01.2006
Time17:18:38
38REPORTZ170D035.WRITE: /'Date',SY-DATUM, /'Time',SY-UZEIT....NEW.WRITE: /'User',SY-UNAME,
/'System',SY-SYSID.
1Date 01.01.2006
Time 08:16:24
2User EverymanSystem S50SystemListPrint12基本語法:Write語句(4)39REPORTZXX01NOSTANDARDPAGEHEADING.WRITE:/'Date',SY-DATUM, /'Time',SY-UZEIT.NEW.WRITE:/'Thisispage2'.
...TOP-OF.WRITE:/20'ReportXYZ',40'PageNo:',SY-PAGNO.
ReportXYZ PageNo:1Date 01.01.2006
Time 08:16:24 ReportXYZ PageNo:2Thisispage2基本語法:Write語句(5)40REPORTZ170D037.WRITE:TEXT-001,10SY-Datum....
TEXT-002,10SY-UZEIT...TextsymbolsTextelementsProgramnameZDEMO001Lang.EText-TextSymbol+1+2+3+ABAP/4TextElements:ChangeTextSymbols001Date002TimeDate 01.01.2006Time 21:07:54 基本語法:Write語句(6)41REPORTZXX02NOSTANDARDPAGEHEADING.WRITE:/(10)'Date'Centered,(12)SY-DATUM, /(10)'Time'color2left-justified,(12)SY-UZEIT.NEW.WRITE:/'Thisispage2'color1.
...TOP-OF.
WRITE:/20'ReportXYZ',40'Page:',SY-PAGNO.
1orCOL_HEADING Headers(grayishblue)2orCOL_NORMAL Listbody(brightgray)3orCOL_TOTAL Totals(yellow)4orCOL_KEY Keycolumns(bluishgreen)5orCOL_POSITIVE Positivethresholdvalue(green)6orCOL_NEGATIVE Negativethresholdvalue(red)7orCOL_GROUP Controllevels
(violet)基本語法:Write語句(7)42基本語法:Write語句(8)uline(96).write:/(1)SY-VLINENO-GAP,40'系統(tǒng)查詢報表',96(1)SY-VLINENO-GAP.uline(96).write:/(1)SY-VLINENO-GAP,(18)'產(chǎn)品名稱'centered,(1)SY-VLINENO-GAP,(8)'產(chǎn)品類型',(1)SY-VLINENO-GAP,(8)'訂單',(1)SY-VLINENO-GAP,(15)'數(shù)量'centered,(1)SY-VLINENO-GAP,(4)'單位',(1)SY-VLINENO-GAP,(4)'總價',(1)SY-VLINENO-GAP,(10)'創(chuàng)建日期'centered,(1)SY-VLINENO-GAP,(12)'備注'centered,(1)SY-VLINENO-GAP.uline(96).43基本語法:子字段RREPORT....DATA:BEGINOFDATEREC,YEAR(4)TYPEC,MONTH(2)TYPEC,DAY(2)TYPEC,ENDOFDATEREC.DATA:YEAR(4)TYPEC,MONTH(2)TYPEC,DAY(2)TYPEC.MOVESY-DATUMTODATEREC.WRITE:/DATEREC-YEAR,DATEREC-MONTH,DATEREC-DAY.MOVE:SY-DATUM(4)TOYEAR,SY-DATUM+4(2)TOMONTH,SY-DATUM+6(2)TODAY.WRITE:/YEAR,MONTH,DAY.
2006122520061225Sub-fields44RIFENDIFCASEENDCASEDOENDDOWHILEENDWHILECONTINUECHECKEXITCasedistinctionLoopsOthercontrolstatements基本語法:內(nèi)部控制語句(1)ControlCommands:Overview45基本語法:內(nèi)部控制語句(2)LogicalExpressionsRDATA:STARTTYPED,
SUM1TYPEP,SUM2TYPEP....IFSUM2GE1000.IFSTARTISINITIAL.IFSUM1GTSUM2ANDSUM1BETWEEN0AND100.IFSUM1=1000AND(SUM2LE2000ORSTARTISINITIAL).EQ=NE<>GT>GE>=LT<LE<=ISINITIALBETWEENf1andf2EqualUnequalGreaterthanLessthanLessthanorequalInitialvalueIntervalOperatorOperatorMeaningMeaning...<logicalexpression>AND<logicalexpression>...<logicalexpression>OR<logicalexpression>...NOT<logicalexpression>......<field><literal>......<field1><field2>...<operator><operator>
<operator><operator>Greaterthanorequal46基本語法:內(nèi)部控制語句(3)IF<logicalexpression>.ENDIF.IF<logicalexpression>.ELSE.ENDIF.IF<logicalexpression>.ELSEIF<logicalexpression>.ELSEIF<logicalexpression>.ELSE.ENDIF.StatementsStatementsStatementsStatementsStatementsStatementsStatementsForexample:DATA:STARTTYPED,SUM1(3)TYPEI,SUM2LIKESUM1....IFSTARTISINITIAL....SUM1=SUM2.ENDIF.IFSUM1GTSUM2....SUM1=SUM1–SUM2.ELSEif…….
SUM1=SUM2–SUM1.Elseif…….ENDIF.IFSUM1BETWEEN0AND100....SUM2=100–SUM1.ENDIF.47CASE<dataobject1>.WHEN<dataobject2>.WHEN<dataobject3>.WHEN<dataobject4>OR<dataobject5>.WHENOTHERS.ENDCASE.StatementsStatementsStatementsStatements基本語法:內(nèi)部控制語句(4)Forexample:DATA:COUNTRY(3)TYPEC,WINNER(10)TYPEC....CASECOUNTRY.
WHEN‘USA’.
WINNER=‘USA’.
WHEN‘CHN’.WINNER=‘CHINA’.
WHEN‘JPN’.WINNER=‘JAPAN’.ENDCASE.48基本語法:內(nèi)部控制語句(5)DO <n> TIMES.ENDDO.SY-INDEXLoopindexstatementsForexample:DATA:STARTTYPED,SUM1(3)TYPEI,SUM2(6)TYPEI....DO100TIMES.SUM2=SUM2+SUM1.ENDDO.DoLoop:SUM2=SUM2+100*SUM1.49基本語法:內(nèi)部控制語句(6)WHILE<logicalexpression>.ENDWHILE.DATA:SEARCH_METYPEI,
TRIES
TYPEI,
NUMBER(3)
TYPEIVALUE2.
SEARCH_ME=64.
WHILENUMBER<>SEARCH_ME.
ADD1TOTRIES.
NUMBER=NUMBER*2.
ENDWHILE.
statementsWHILELoop:50CHECK<logicalexpression>.CHECK<condition>.statementsstatementsCHECKwithinaloopstructure.有條件終止當次循環(huán)CHECKoutsideloopstructures.WHILECOUNTERGT0. CHECKFLAGNESPACE.ENDWHILE.statementsstatements12基本語法:內(nèi)部控制語句(7)51DO... IFCOUNTERGE100.
EXIT. ENDIF.ENDDO.statementsstatementsEXITwithinaloopstructure.無條件終止所有循環(huán)EXIToutsideloopstructure.EXIT.IF....
EXIT.ENDIF.statementsstatements12基本語法:內(nèi)部控制語句(8)52DO100TIMES.IFSY-INDEXGE10ANDSY-INDEXLE20.
CONTINUE.ENDIF.ENDDO.statementsstatementsCONTINUE.無條件終止當次循環(huán)基本語法:內(nèi)部控制語句(9)53課后練習I
報表邏輯:XXX是個人的用戶名;“除數(shù)”一欄中是從1開始步長為1的序列;“余數(shù)”一欄中是”除數(shù)”除以3之后的余數(shù);當”除數(shù)”是5的奇數(shù)倍的時候,這一列不進行輸出;是5的偶數(shù)倍的時候,進行換頁;當”余數(shù)”為0的時候,進行紅色的輸出附加補充55基本語法:內(nèi)部表工作原理(1)Pre-defined(P,I,F,C,N,D,T,X)ElementaryFieldstringtypeTabletypeStructuredUserdefinedDatatypeManipulatingtablesdynamically!!!CARRIDCONNIDInternaltable<itab>AA0017LH0400LH0402LH0403UA0027SQ0005DATA<itabobject>TYPE<linetype>OCCURS<n>.DATA<itabobject>TYPE<itabtype>.DATA:BEGINOF<itabobject>OCCURS<n>,...,ENDOF<itabobject>.56基本語法:內(nèi)部表工作原理(2)REPORTZXX06.TABLES:TABNA.TYPES:BEGINOFSALES,NAME(30)TYPEC,SALES(4)TYPEPDECIMALS2,ENDOFSALES.DATA:AMOUNT(5)TYPEN,
BEGINOFADDRESS_LISTOCCURS5,FLAGTYPEC,IDLIKETABNA-ID,..AMOUNT1LIKEAMOUNT,,
ENDOFADDRESS_LIST,SALES_TABTYPESALESOCCURS10WITHHEADERLINE.
ExamplesADDRESS_LISTHeaderlineSALES_TABHeaderline10rows/lines57基本語法:內(nèi)部表工作原理(3)CARRIDCONNIDAA0017internaltable<itab>Workarea<wa>LH0400SORT<itab>BY<field1>...<fieldn>.CLEAR<itab>.REFRESH<itab>.LOOPAT<itab>...ENDLOOP.READTABLE<itab>....APPEND...<itab>.COLLECT...<itab>.INSERT...<itab>.MODIFY<itab>....DELETE<itab>....WorkingwithInternalTables:Movecorresponding<dbtb>to<wa>.AA0017LH0400CARRIDCONNIDCARRIDCONNID58CARRIDCONNIDAA0017Internaltable<itab>Workarea<wa>LH0400CARRIDCONNIDAA0017Internaltable<itab>Headerline<itab>LH0400APPEND<wa>TO<itab>.MODIFY<itab>INDEX<n>FROM<wa>.LOOPAT<itab>INTO<wa>.WRITE<wa>-<field>.ENDLOOP.READTABLE<itab>INDEX<n>INTO<wa>.WRITE<wa>-<field>.APPEND<itab>.MODIFY<itab>INDEX<n>.LOOPAT<itab>.WRITE<itab>-<field>.ENDLOOP.READTABLE<itab>INDEX<n>.WRITE<itab>-<field>.基本語法:內(nèi)部表工作原理(4)InternalTablesWithorWithoutHeaderLine:59REPORT....TABLES:SFLIGHT.DATA:FLIGHTINFO_LISTLIKESFLIGHTOCCURS0.SELECT*FROMSFLIGHT.
APPENDSFLIGHTTOFLIGHTINFO_LIST.ENDSELECT.APPEND[<wa>TO]<itab>.CARRIDCONNID...AA0017...InternaltableFLIGHTINFO_LISTTableworkareaSFLIGHTSFLIGHTSELECTAPPENDAA00260026AA基本語法:內(nèi)部表工作原理(5)FillingInternalTables:60基本語法:內(nèi)部表工作原理(6)RSELECT*FROM<table>INTOTABLE<itab>.CARRIDCONNID...AA0017...InternaltableFLIGHTINFO_LISTDatabasetableSFLIGHTAAAAAAAA0017002600260064............REPORT....TABLES:SFLIGHT.DATA:FLIGHTINFO_LISTLIKESFLIGHTOCCURS0.SELECT*FROMSFLIGHTWHERECARRID='AA'.APPENDSFLIGHTTOFLIGHTINFO_LIST.ENDSELECT.SELECT*FROMSFLIGHTINTOTABLEFLIGHTINFO_LISTWHERECARRID='AA'.ArrayFetch:61基本語法:內(nèi)部表工作原理(7)CARRIDPRICE(TYPP)456789LH100000HeaderlineAA20909381DL9333382LH176666931866669COLLECT[<wa>INTO]<itab>.REPORT....TABLES:SFLIGHT.TYPES:BEGINOFFLIGHTINFO_TYPE,CARRIDLIKESFLIGHT-CARRID,PRICELIKESFLIGHT-PRICE,ENDOFFLIGHTINFO_TYPE.DATA:FLIGHTINFO_LISTTYPEFLIGHTINFO_TYPEOCCURS0WITHHEADERLINE.SELECT*FROMSFLIGHT.MOVE-CORRESPONDINGSFLIGHTTOFLIGHTINFO_LIST.COLLECTFLIGHTINFO_LIST.ENDSELECT.FillingInternalTableswithCumulativeValues:SFLIGHTCARRID NAME PRICE00000001 WILLY 1200 00000001 1200FLIGHTINFO_LISTFLAG CARRID TIME PRICE62基本語法:內(nèi)部表工作原理(8)SORT<itab>BY<field1><field2>....REPORT....TABLES:SFLIGHT.DATA:FLIGHTINFO_LISTLIKESFLIGHTOCCURS0WITHHEADERLINE.SELECT*FROMSFLIGHTINTOTABLEFLIGHTINFO_LISTWHERE....
SORTFLIGHTINFO_LIST...SORTFLIGHTINFO_LISTBYPRICEFLDATE...SORTFLIGHTINFO_LISTBYPRICEASCENDING
FLDATEDESCENDINGCARRIDASCENDINGASTEXT.SortinganInternalTable:63基本語法:內(nèi)部表工作原理(9)LOOPAT<itab>[INTO<wa>]....ENDLOOP.REPORT....TABLES:SFLIGHT.DATA:FLIGHTINFO_LISTLIKESFLIGHTOCCURS0WITHHEADERLINE.SELECT*FROMSFLIGHTINTOTABLEFLIGHTINFO_LISTWHERE....LOOPATFLIGHTINFO_LIST.WRITE:/FLIGHTINFO_LIST-CARRID,FLIGHTINFO_LIST-CONNID...ENDLOOP....LOOPATFLIGHTINFO_LISTWHERECARRID='LH'.
WRITE:/FLIGHTINFO_LIST-CARRID,FLIGHTINFO_LIST-CONNID...ENDLOOP.IFSY-SUBRCNE0...ENDIF.UsingLoopswithanInternalTable:64基本語法:內(nèi)部表工作原理(10)READTABLE<itab>[INTO<wa>]WITHKEY...REPORT....TABLES:SFLIGHT.DATA:FLIGHTINFO_LISTLIKESFLIGHTOCCURS0WITHHEADERLINE,TAB_INDEXTYPEI.SELECT*FROMSFLIGHTINTOTABLEFLIGHTINFO_LISTWHERE....READTABLEFLIGHTINFO_LISTWITHKEYCARRID='LH'CONNID='0400'.IFSY-SUBRCNE0ENDIF.TAB_INDEX=SY-TABIX+1.READTABLEFLIGHTINFO_LISTINDEXTAB_INDEX.IFSY-SUBRCNE0ENDIF.ReadinganEntryfromanInternalTable:65基本語法:內(nèi)部表工作原理(11)REPORT....TABLES:SFLIGHT.DATA:FLIGHTINFO_LISTLIKESFLIGHTOCCURS0WITHHEADERLINE.SELECT*FROMSFLIGHTINTOTABLEFLIGHTINFO_LISTWHERE....READTABLEFLIGHTINFO_LISTWITHKEYCARRID='LH'CONNID='0400'.MOVE'345.89'TOFLIGHTINFO_LIST-PRICE.MODIFYFLIGHTINFO_LISTINDEXSY-TABIX.IFSY-SUBRCNE0....ENDIF...INSERTFLIGHTINFO_LISTINDEX5....DELETEFLIGHTINFO_LISTINDEX5.IFSY-SUBRCNE0....ENDIF.INSERT[<wa>INTO]<itab>INDEX<i>.MODIFY<itab>INDEX<i>[FROM<wa>].DELETE<itab>INDEX<i>.ChanginganInternalTableI:66基本語法:內(nèi)部表工作原理(12)LOOPAT<itab>[INTO<wa>].INSERT[<wa>INTO]<itab>.MODIFY<itab>[FROM<wa>].DELETE<itab>.ENDLOOP.ChanginganInternalTableII:REPORT.......LOOPATFLIGHTINFO_LIST.INSERTFLIGHTINFO_LIST....MODIFYFLIGHTINFO_LIST....DELETEFLIGHTINFO_LIST.ENDLOOP.DELETEFLIGHTINFO_LISTWHERE<Condition>.67基本語法:內(nèi)部表工作原理(13)RCARRIDCONNIDAA0017Internaltable<itab>Workarea<wa>LH0400CARRIDCONNIDAA0017Internaltable<itab>Headerline<itab>LH0400CLEAR<wa>.REFRESH<itab>.CLEAR<itab>.withheaderlinewithoutheaderline
REFRESH<itab>.DeletinganInternalTable:68基本語法:內(nèi)部表工作原理(14)REPORT....TABLES:SFLIGHT.DATA:FLIGHTINFO_LISTLIKEBCAXXOCCURS10.SELECT*FROMSFLIGHTINTOTABLEFLIGHTINFO_LIST.DESCRIBETABLEFLIGHTINFO_LISTLINESLINE_COUNT.DESCRIBETABLE<itab>....CARRIDCONNID...AA0017...InternaltableFLIGHTINFO_LISTAAAAAA001700260026.........LINE_COUNT4InformationaboutanInternalTable:69基本語法:ABAPOPENSQL(1)Whichcolumns?Whichcolumns?Whichtables?Whichtables?Whereto?Whereto?Whichentries?Whichentries?Howaretheygrouped?Howaretheygrouped?Howaretheyarranged?Howaretheyarranged?SELECT<result>FROM<table>INTO<target>WHERE<condition>GROUPBY<fields>ORDERBY<fields>.Particularcolumn}Severallines}SinglelineSelectoverview:70基本語法:ABAPOPENSQL(2)REPORT....TABLES:SPFLI.SELECT*FROMSPFLIWHERECARRID='LH'.SELECTSINGLE*FROMSPFLIWHERECARRID='LH'.SELECT<result>FROM<table>....ENDSELECT.SELECTSINGLE<result>FROM<table>.SingleorMultipleEntryProcessing:NoENDSELECTrequiredENDSELECT.71基本語法:ABAPOPENSQL(3)REPORT....TABLES:SPFLI.DATA:MAXFIELDLIKESFLIGHT-DISTANCE,COUNTERTYPEI.SELECTCITYFROMCITYTOINTO(SPFLI-CITYFROM,SPFLI-CITYTO)FROMSPFLI.WRITE:/SPFLI-CITYFROM,SPFLI-CITYTO.ENDSELECT.SELECTMAX(DISTANCE)COUNT(*)
FROMSPFLIINTO(MAXFIELD,COUNTER).SELECT*.......ENDSELECT.SELECT<field1>...<fieldn>....[...ENDSELECT].WRITE:'Longestflightconnection',MAXFIELD,/'Numberofflightconnections',COUNTER.SELECTClause:72基本語法:ABAPOPENSQL(4)REPORTB170D068.TABLES:TABNA.DATA:W_COUNTRYLIKETABNA-COUNTRY.SELECTDISTINCTCOUNTRYINTO(W_COUNTRY)FROMTABNA.ENDSELECT.statementsREPORTB170D069.TABLES:TABNA.DATA:W_IDLIKETABNA-ID,W_COUNTRYLIKETABNA-COUNTRYSELECTDISTINCTIDCOUNTRYINTO(W_ID,W_COUNTRY)FROMTABNA.ENDSELECT.statementsTABNACountryIDAU 12345678AU 22009520USA 10034766USA 22009520USA 999857631stpass2ndpassTABNACountryIDAU 12345678AU 22009520USA 10034766USA 22009520USA 999857632ndpass1stpassSELECTdistinct:73RSELECT<result>FROM<table>INTO<wa>....ENDSELECT.SELECT<result>FROM<table>INTO(<field1>,...,<fieldn>)....ENDSELECT.SELECT<result>FROM<table>INTOTABLE<itab>.REPORT....TYPES:BEGINOFFLIGHTINFO_TYPE,CARRIDLIKESPFLI-CARRID,CONNIDLIKESPFLI-CONNID,ENDOFFLIGHTINFO_TYPE.DATA:WATYPEFLIGHTINFO_TYPE,FLIGHTINFO_LISTTYPEFLIGHTINFO_TYPEOCCURS0.SELECTCARRIDCONNIDFROMSPFLIINTOWA.APPENDWATOFLIGHTINFO_LIST.ENDSELECT.SELECTCARRIDCONNIDFROMSPFLIINTO(SPFLI-CARRID,SPFLI-CONNID).
WRITE:SPFLI-CARRID,SPFLI-CONNID.ENDSELECT.SELECTCARRIDCONNIDFROMSPFLIINTOTABLEFLIGHTINFO_LIST.基本語法:ABAPOPENSQL(5)IntoClause:74基本語法:ABAPOPENSQL(6)SELECT<result>FROM<table>......WHERE<tablefield><operator><value>....WHERE<tablefield>BETWEEN<value1>AND<value2>....WHERE<tablefield>LIKE<pattern>....WHERE<tablefield>IN(<value1,value2,...)....WHERE<tablefield>IN<seltab>.ENDSELECT.WhereClauseoverview:EQ,= LE,<=NE,<> GT,>LT,< GE,>=Equalto LessthanorequalNotequalto GreaterthanLessthan GreaterthanorequalAllowablecomparisonoperatorsforWHEREconditions:75基本語法:ABAPOPENSQL(7)REPORT....TABLES:SPFLI.SELECT*FROMSPFLIWHERECITYFROMLIKE'_R%'.WRITE:/SPFLI-CARRID,SPFLI-CONNID,SPFLI-CITYFROM,....ENDSELECT.SELECT<result>FROM<table>WHERE<tablefield>LIKE<pattern>.WhereClause:like76基本語法:ABAPOPENSQL(8)REPORT....TABLES:SFLIGHT.SELECT*FROMSFLIGHTWHEREPRICEIN(123,1000).WRITE:/SFLIGHT-CARRID,SFLIGHT-CONNID,SFLIGHT-PRICE,....ENDSELECT.SELECT<result>FROM<table>WHERE<tablefield>IN(<value1>,<value2>,...).WhereClause:in77基本語法:ABAPOPENSQL(9)RSELECT<result>...FROM<table>GROUPBY<field1>...<fieldn>.REPORT....TABLES:SFLIGHT.DATA:CARRIDLIKESFLIGHT-CARRID,MINIMUMTYPEPDECIMALS2,MAXIMUMTYPEPDECIMALS2.SELECTCARRIDMIN(PRICE)MAX(PRICE)INTO(CARRID,MINIMUM,MAXIMUM)FROMSFLIGHTGROUPBYCARRID.WRITE:/CARRID,MINIMUM,MAXIMUM.ENDSELECT.IFSY-SUBRCNE0.WRITE:/TEXT-001.ENDIF.Groupbyclause:78基本語法:ABAPOPENSQL(10)REPORT....TABLES:SPFLI.SELECTCARRIDCONNIDCITYFROMFROMSPFLIINTO(SPFLI-CARRID,SPFLI-CONNID,SPFLI-CITYFROM)ORDERBYCITYFROM.
WRITE:/SPFLI-CARRID,SPFLI-CONNID,
SPFLI-CITYFROM.ENDSELECT.IFSY-SUBRCNE0.WRITE:/TEXT-001.ENDIF.SELECT<result>FROM<table>ORDERBY<field1><field2>...PRIMARYKEY.Orderbyclause:79基本語法:功能函數(shù)(1)PROGRAM...TABLES...CALLFUNCTION'FM_02'EXPORTING...IMPORTING...UsingfunctionmodulesMaintainingfunctionmodulesFM_02InterfaceImportExportTablesExceptionsProgramDocumentationAdministrationFMgroup:FIBUFM_01...FM_02...FM_03...FM_04...FMgroup:ZIBUFunctionLibraryFunctionLibrary80基本語法:功能函數(shù)(2)81基本語法:功能函數(shù)(3)REPORT....TABLES:SFLIGHT.DATA:losslikesflight-paymentsum,revenuelike...CALLFU
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 吉林師范大學《數(shù)值分析》2023-2024學年第一學期期末試卷
- 吉林師范大學《歷史哲學》2021-2022學年第一學期期末試卷
- 中學在線學習優(yōu)化方案
- 男方凈身出戶協(xié)議書的法律效力
- 2024滅火器維修充粉合同
- 吉林大學《信號與系統(tǒng)B》2021-2022學年第一學期期末試卷
- 吉林師范大學《分鏡頭腳本設(shè)計》2021-2022學年第一學期期末試卷
- 2024船只租賃合同樣本
- 2024常用合同范本范文
- 2024貨物進口合同貿(mào)易合同
- 建筑工程技術(shù)專業(yè)《裝配式建筑》課程標準
- 好的六堡茶知識講座
- 火車站物流園區(qū)建設(shè)項目物有所值評價報告
- 《養(yǎng)老護理員》-課件為老年人布置睡眠環(huán)境
- 職業(yè)生涯規(guī)劃醫(yī)學生
- 醫(yī)學課件指骨骨折
- 拜占庭歷史與文化智慧樹知到期末考試答案2024年
- 反應(yīng)釜驗證方案樣本
- S2-旋挖樁機安裝拆卸專項方案
- 二年級下冊語文課件-作文指導:13-通知(23張PPT) 部編版
- 普通高中物理課程標準解讀
評論
0/150
提交評論