SAP ABAP培训资料

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

SAPABAP/4IntroductionJohnnyJiangABAP字典(一)表、数据元素、域TableCTableBTableADataElement1DataElement2Domain事务代码:/nse11ABAP字典(二)表在程序中的使用Tables:KNA1.……Select*fromKNA1…..….….ABAP字典(三)外键ForeignKey表的类型ABAP字典(四)TransparentTable(TRANSP)Structure(INTTAB)PoolTableClusterTableViewABAP字典(五)创建一个透明表(1)事务代码:/nse11ABAP字典(五)创建一个透明表(2)ABAP字典(五)创建一个透明表(3)ABAP字典(五)创建一个透明表(4)ABAP字典(五)创建一个透明表(5)功能模块(函数)组成部分.ATTRIBUTES.IMPORTING.EXPORTING.CHANGING.TABLES.EXCEPTIONS.SOURCECODE功能模块(函数)函数调用(1)功能模块(函数)函数调用(2)功能模块(函数)函数调用(3)功能模块(函数)函数调用(3)语法/语句–数据类型C:CharacterTextI:IntegerP:Packed#N:NumericTextD:DateT:Time语法/语句–变量定义.TYPEDATA:WG_KUNNR(10)TYPED.DATA:WG_COUNT(10,2)TYPEPDECIMALS2..LIKEDATA:WG_KUNNRLIKEKNA1-KUNNR.语法/语句–变量赋值.‘=‘DATA:wg_kunnr(10)TYPEc.wg_kunnr=‘A100001’..MOVEDATA:wg_kunnrLIKEkna1-kunnr.MOVE‘A100001TOwg_kunnr.语法/语句–运算符.数字运算符:+-*/.字串运算符:COCSCA….逻辑运算符:===…语法/语句–SHIFT&CONCATENATESHIFT…LEFT/RIGHTDATA:WG_NAME(10)TYPECVALUE‘ABCDEFGHIJ’.SHIFTWG_NAMELEFTBY3PLACES.*WG_NAME=‘DEFGHIJ‘CONCATENATEv1v2INTOv2SEPARATEDBY‘’DATA:WG_NAME(20)TYPEC.DATA:WG_FNAM(10)TYPECVALUE‘Johnny’.DATA:WG_LNAM(20)TYPECVALUE‘Jiang’.CONCATENATEWG_FNAMWG_LNAMINTOWG_NAMESEPARATEDBY‘‘.*WG_NAME=‘JohnnyJiang’.语法/语句–SPLIT&OFFSETSPLITv1AT‘’INTOv2v3…DATA:WG_NAME(20)TYPECVALUE‘JohnnyJiang’.DATA:WG_FNAM(10)TYPEC.DATA:WG_LNAM(20)TYPEC.SPLITWG_NAMEAT‘‘INTOWG_FNAMWG_LNAM.*WG_FNAM=‘Johnny’.*WG_LNAM=‘Jiang’.OFFSETDATA:WG_NAME(20)TYPECVALUE‘ABCDEFGHIJKLMN’.DATA:WG_CHAR(2)TYPEC.WG_CHAR=WG_NAME+10(2).*WG_CHAR=‘KL’.语法/语句-SELECTSELECT语句SELECTFIELDLISTINTOTARGETLIST[/INTO[/APPENDING](CORREPONDINGFIELDSOF)TABLEINTERNALTABLE]FROMTABLE1[INNERJOINTABLE2ONTABLE2-FIELD1=TABLE1-FIELD1ANDTABLE2-FIELD2=TABLE1-FIELD2](FORALLENTRIESININTERNALTABLE)WHERECONDITIONS.[ENDSELECT.]语法/语句-IFIF语句IFcondition.…ELSEIFcondition.…ELSE.…ENDIF.语法/语句-CASECASE语句CASEvariant.WHENvalue1.…WHENvalue2.…WHENOTHES.…ENDCASE.语法/语句-LOOPLOOP语句LOOPATinternaltable[INTOworkarea][WHEREconditions].…ENDLOOP.语法/语句-DODO语句DO[nTIMES].…ENDDO.语法/语句-WRITEWRITE语句WRITEformatvalueoptions./p(I)/=LineFeedp=ColumnPositionI=OutputLengthformatProgramFieldorTextLiteralvalueFormatOptionsoptions语法/语句-WRITEeg:WRITE:/1(40)WG_FIELDS...NO-ZERO...NO-SIGN...NOGROUPING...DD/MM/YY...MM/DD/YY...DD/MM/YYYY...MM/DD/YYYY...DDMMYY...MMDDYY...YYMMDD...CURRENCYw...DECIMALSd内部表和结构定义内部表DATA:BEGINOFITABOCCURS0,KUNNRLIKEKNA1-KUNNR,NAME1LIKEKNA1-KUNNR,TELF(20)TYPEC,ENDOFITAB.结构DATA:BEGINOFS1,KUNNRLIKEKNA1-KUNNR,NAME1LIKEKNA1-KUNNR,TELF(20)TYPEC,ENDOFS1.DATA:S2LIKEITAB.内部表使用.LOOPATinternaltable[INTOworkarea][WHEREconditions].…ENDLOOP..READTABLEinternaltable[INTOworkarea]…WITHKEYfield=condition[BINARYSEARCH].…INDEXindex.….APPENDworkareaTOinternaltable..COLLECTworkareaTOinternaltable..APPENDLINESOFinternaltable1TOinternaltable2..i-table1[]=i-table2[].选择屏幕–参数PARAMETERSPARAMETERSp_para…DEFAULTf…TYPEtype[DECIMALSdec]…LIKEg…NO-DISPLAY…LOWERCASE…OBLIGATORY…ASCHECKBOX…RADIOBUTTONGROUPradi…MATCHCODEOBJECTmobj选择屏幕–参数SELECT-OPTIONSSELECT-OPTIONSs_seleFORfield…DEFAULTv1[TOv2]…MATCHCODEOBJECTmobj…NO-DISPLAY…LOWERCASE…OBLIGATORY…NO-EXTENSION…NO-INTERVALS选择屏幕–设计.SELECTION-SCREENBEGINOFBLOCKblkWITHFRAME[TITLEtext-000].SELECTION-SCREENENDOFBLOCKblk..SELECTION-SCREENBEGINOFLINE.SELECTION-SCREENENDOFLINE..SELECTION-SCREENPOSTIONposi..SELECTION-SCREENCOMMENTfmtname..SELECTION-SCREENSKIPn.消息创建事务代码:/nse91MESSAGE-IDMESSAGEnum创建消息调用.PROGRAMprognameMESSAGE-IDmsg-idMESSAGExnnnWITHf1…fn[INTOvariant].MESSAGExnnn(msg-id)WITHf1…fn[INTOvariant]事件驱动INITIALIZATION.ATSELECTION-SCREEN.START-OF-SELECTION.END-OF-SELECTION.TOP-OF-PAGEEND-OF-PAGE事件驱动ATNEWfield.ATENDOFfield.ONCHANGEOFfield.NEW-PAGE.SUM.Group操作文件文件在应用服务器上OPENDATASETdsnFORINPUT[/OUTPUT]INTEXTMODE[/INBINARYMODE]READDATASETdsnINTOworkarea/field.[TRANSFERworkarea/fieldTOdsn]CLOSEDATASETdsn.操作文件文件在本地机器上下载FUNCTION‘WS_DOWNLOAD’IMPORTINGVALUE(FILENAME)LIKERLGRAP-FILENAMEDEFAULTSPACEVALUE(FILETYPE)LIKERLGRAP-FILETYPEDEFAULT'ASC'TABLESDATA_TABEXCEPTIONS。。。操作文件文件在本地机器上上传FUNCTION‘WS_UPLOAD’IMPORTINGVALUE(FILENAME)LIKERLGRAP-FILENAMEDEFAULTSPACEVALUE(FILETYPE)LIKERLGRAP-FILETYPEDEFAULT'ASC'TABLESDATA_TABEXCEPTIONS。。。BatchInput(BDC)程序BDC程序的目的SAPDB外部数据外部数据SAP事务BatchInput(BDC)程序BDC事务记录器/nSHDBBatchInput(BDC)程序BDC程序用结构BDCDATABDCtableBatchInput(BDC)程序BDC程序用结构BDCMSGCOLLMSGtableBatchInput(BDC)程序BDC内部表定义ig_bdclikestandardtableofBDCDATAwithheaderline.ig_msglikestandardtableofBDCMSGCOLLwithheaderline.BatchInput(BDC)程序BDC内部表赋值If是屏幕数据.Ig_bdc-program=‘SAPxxxxx’.Ig_bdc-dynpro=‘nnnn’.Ig_bdc-dynbegin=‘X’.Else是字段数据.Ig_bdc-fnam=‘XXXX-YYYY’.Ig_bdc-fval=‘mmmm’.Endif.APPENDBatchInput(BDC)程序BDC程序调用语句Calltransaction‘XXXX’usingbdctablemodemodemessagesintomsgtable.A所有步骤E出错停止N忽略信息SAPScript格式事务代码/nSE71SAPScript格式-attributesSAPScript格式-pagesSAPScript格式-windowsSAPScript格式–pagewindowsSAPScript格式–textitemSAPScript格式–paragraphformatsSAPScript格式–characterformatsSAPScript格式–调用Callfuntion‘OPEN_FORM’ExportingFORM=…Callfunction‘WRITE_FORM’.E

1 / 63
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功