SAP培训-ABAP语法(二)【朗泽SAP培训】
- 格式:pdf
- 大小:12.88 MB
- 文档页数:100
SAP ABAP语法实例调试1 调试键F8跳过后面所有断点,程序执行完2 外部、会话、调试断点调试断点-debug时打的断点,程序远程完后就会消失会话断点-程序运行前通过会话断点按钮打的断点,在同一登录会话不同窗口都有效,用户注销后消失外部断点-程序运行前通过外部断点按钮打的断点,用户注销后再登录还是有效,但只针对同一用户有效SelectSELECT <result> FROM <source> INTO <target> [WHERE <condition>] [GROUP BY <fields>] [HAVING <cond>] [ORDER BY <fields>].GROUP BY:用于将一组数据条目压缩为一个单行作为选择最终结果;HAVING:用于限定ORDER BY子句子数据目组的选择条件;ORDER BY:用于限定行排序;SELECT整体语法结构。
示例:以上示例查询的是:20170503至20170510期间销售订单为JR01,且销售量大于50的单据的订单号、创建日期、创建者、类型以及合计销量,并按销售订单升序排序。
这里需要强调的是,如果要使用函数(如SUM、MAX、MIN),则需要将其他字段通过GROUP BY 进行分组。
如果需要继续对使用函数进行条件筛选,则可以使用关键字HAVING。
关键字ORDER BY 决定查询结果的排序方法,ASCENDING为升序,DESCENDING为降序。
1 SELECT SINGLE单行数据:SELECT SINGLE <RESULT> INTO <target> FROM <source> ...如果系统找到一个完全符合指定条件的行,SY-SUBRC返回0,否则返回4。
一般不需要指明所有字段,而是在SELECT后用"*"符号, 若指定多个数据对象,则需要将这些对象放在括号中,并用逗号隔开,而且其顺序需要与SELECT子句中指明的表字段顺序一致。
第二章ABAP/4 程序语法和格式概览内容语法元素............................................................................................................................. 1语句............................................................................................................................... 1关键字 ........................................................................................................................... 2注释............................................................................................................................... 2语法结构............................................................................................................................. 3语句结构........................................................................................................................ 4注释结构........................................................................................................................ 4连接相似语句............................................................................................................... 5ABAP/4 程序格式.............................................................................................................. 6缩排语句块.................................................................................................................... 6使用模块化工具........................................................................................................... 6正确插入程序注释 ....................................................................................................... 6整齐打印程序............................................................................................................... 6插入已有结构.................................................................................................................... 7插入已有关键字结构.................................................................................................... 7插入已有注释行........................................................................................................... 8本节说明ABAP/4 语法,并且提供关于如何在ABAP/4 中编程的建议。
SAPABAP基础语法培训教程SAP ABAP(Advanced Business Application Programming)是一种基于ERP平台的开发语言,ABAP基础语法是程序员学习和掌握ABAP语言的基础。
本教程将为大家介绍ABAP语言的基本概念和语法规则。
1.ABAP程序结构ABAP程序由模块(MODULE)、函数(FUNCTION)和方法(METHOD)组成。
每个程序都由声明、定义和执行部分构成。
声明部分包括程序名称、输入输出参数和局部变量的声明。
定义部分包括逻辑处理和函数实现。
执行部分包括调用其他程序或函数的操作。
2.数据类型ABAP支持多种数据类型,包括整数、小数、字符串、日期和时间等。
声明和定义变量时需要指定数据类型,如:DATA num TYPE I.(整数类型的变量)ABAP还支持结构体和表格类型的数据。
在声明变量时,可以使用LIKE关键字指定一个已有变量的数据类型。
3.控制语句ABAP的控制语句包括条件语句和循环语句。
条件语句包括IF、CASE和WHEN等关键字。
例如:IF condition.statement.ELSEIF condition.statement.ELSE.statement.ENDIF.循环语句包括DO、WHILE和LOOP等关键字。
例如:DOnTIMES.statement.ENDDO.WHILE condition.statement.ENDWHILE.LOOP AT itab.statement.ENDLOOP.4.函数和方法ABAP可以定义自己的函数和方法,以供其他程序或函数调用。
函数由FUNCTION关键字定义,例如:FUNCTION function_name.statement.ENDFUNCTION.方法由METHOD关键字定义,例如:METHOD method_name.statement.ENDMETHOD.在函数和方法中可以通过EXPORTING关键字指定输出参数,通过IMPORTING关键字指定输入参数。
*SAP ABAP 语法实例调试1调试键R10巨4亘F5 F6 F7F8*巧为单袖执拧・按F5键程序将逹軒扌丸行.苦代屑中包含子程序或函数・则会辖人 该函數中单帧谓试。
•區只在本强序中单柄执行,遇到子樨序或翡數时会直蛭执疔°*F7会一丈牲执行毛労前代码所在的过程.如子桂序和函數*苦屈主程序中+则直 接执行芜廡桎序。
并返E®」上一层谓用竝F8跳过后面所有断点,程序执行完2外部、会话、调试断点调试断点-debug 时打的断点,程序远程完后就会消失 会话断点-程序运行前通过 会话断点按钮打的断点,在同一登录会话不同窗口都有效,用户注销后消失外部断点-程序运行前通过 二,外部断点按钮打的断点,用户注销后再登录还是有效,但只针对同一用户有效ABAP Ec«tor: Change Report Z3ZJ_TEXT_EDITOR2□田|函固画HI1圖 ®DH.PatteSELECT • INTO TABLE it ZSpJli 7R0M upfli.HEAT TJiSLEWITH 住丫 caixid - cclt_Z3p±ll-di5tfinGe = 2 j J 2 ・MODIFY zsptll FROM it_Z3ptli + FFReportZJZJ」EXT E0ITQR2Active三二己三.39r专4;* SelectSELECT <result> FROM <source> INTO <target> [WHERE <condition>] [GROUP BY <fields>] [HAVING <cond>] [ORDER BY <fields>].GROUP BY:用于将一组数据条目压缩为一个单行作为选择最终结果;HAVING :用于限定ORDER BY子句子数据目组的选择条件;ORDER BY :用于限定行排序;SELECT整体语法结构。
1. ABAP/4 IntroductionIntroductionABAP/4(Advanced Business Application Programming)是SAP/R3目前唯一的系统发展工具, 属4GL, 语法比较近似Visual Basic或JAVA, 和传统third-generation 语言, 如C,PASCAL 有很大不同, 在程序模块(Program Structure Module)可分以下三个部分:1.Sequential coding within processing block与一般语言语法近似, 如IF,WHILE等, 但并没有GOTO叙述2.Reports呼叫一个独立的事件(Depending Event), 读取database 产生数据列表3.Dialog屏幕参数输入的对话框, 专门处理database 读取或异动的tranaction processBasic Languange Overview1.data element 宣告方式, 如数值, 字符数据变量宣告2.操作数(operate)使用, 如+ - * /3.Control element使用, 如Boolean 值4.特殊数据格式, 如日期与时间5.字符串字料处理function, 如部分字符串的截取6.子程序或自定函数的呼叫7.SQL语法使用8.数据结构的使用, 如process internal table的宣告与使用Reports Overview1.Reports Task, 如报表屏幕预览或打印机打印的选择2.Reports 模块是一个Stand-along 程序,3.database读取方式, 如可定义logical database(与磁盘的physical storage对映)4.报表数据的计算与产生5.报表的输出Dialog Overview1.专处理database 的读取与异动, 如使用SQL 指令2.Dialog 不是一个Stand-Along Progarm, 使用transaction code来产生屏幕对话框3.由flow logic 控制, flow logic分成PBO(Process Before Output)与PAI(Process After Input) 2.Begin To Programming2.1 ABAP/4 EditorCreating ABAP/4 Program使用ABAP Workbench撰写程序(Choose Tools->ABAP/4 Workbench, Transaction Code: S001), 萤幕如下:可分成:1.ABAP/4 Editor :针对简单的报表或程序, 仅使用几个组件或不使用2.Obiect Browser :针对复杂的报表或程序, 如Dialog Transaction Module 撰写使用ABAP/4 Editor 撰写程序1.ABAP/4 Editor 画面如下(Transaction Code:SE38):2.输入程序名称, 如果是新程序, 按下”Create”, 如果修改已存在程序, 则按下”Change”或F6键在命名规则上, Reports程序为Yaxxxxxx或Zaxxxxxx, a表application module简称, 如s表SD Dialog程序为SAPMYxxx或SAPMZxxx3.输入程序Attribute(1).Title:程序描述或功能说明(2).Type:Execute mode: 1: Stand-along Program 如ReportsI: Include ProgramM: Module PoolF: Function GroupS: Subroutine Pool(3).Status:Program development status: P: SAP standard production programK: Customer production programS: System programT: Test program(4).Application: 程序所属的application module, 如F表Financeial acounting(5).Development class: 用于同一系统中各个program, 如果不属任一class, 可使用$TMP4.撰写Source CodeProgram 之后接的是程序名称, Write 是显示的意思, 会将所接的字符串在屏幕上显示, 注意每一行最后要有一个. (点), 表示叙述的结束, 储存后回ABAP/4 Editor画面5. 执行程序按”Execute”或F8键, 屏幕可见执行所得的结果重要的编辑键2.2 ABAP/4 Data ElementData TypeABAP/4 的数据型态可分成:Type Length Range Initial Value DescriptionC 1 1-65535Byte Space 字符串数据, 如‟Program‟D 8 8Byte …00000000‟ 日期数据, 格式为YYYYMMDDF 8 8Byte 0 浮点数I 4 -2^31至2^31-1 0 整数N 1 1-65535Byte …00…0‟ 数值所组成的字符串P 8 1-16Byte 0 Packed 数, 用在小数点数T 6 6Byte …000000‟ 时间数据, 格式为HHMMSSX 1 1-65535Byte X‟00‟ 16进位数变量宣告变量宣告包含name, type, length 和structure四个部分, 使用DATA 指令, 如DATA: S1 TYPE I,SUM TYPE I.常数宣告常数宣告使用CONSTANTS 指令, 如宣告PI 是一个小数点5位的值3.14159, CONSTANTS PI TYPE P DECIMALS 5 VALUE …3.14159‟.系统所定义数据这是由系统所定义的专有名辞, 如SPACE 空白字符串SY-SUBRC 系统执行传回值, 0 表示成功SY-UNAME logon 账号SY-DATUM 系统日期SY-UZEIT 系统时间SY-TCODE 目前的transaction codeTYPE 叙述用来指定数据型态或宣告自定数据型态Example:TYPES: BEGIN OF MYLIST,NAME(10) TYPE C,NUMBER TYPE I,END OF MYLIST.DATA LIST TYPE MYLIST.LIKE 叙述跟TYPE叙述使用格式相同, 如DATA TRANSCODE LIKE SY-TCODE.不同的是LIKE 用在已有值的数据项, 如系统变量, 而TYPE叙述则是用在指定数据型态。
BGCOLOR=#e0e0e0>SELECT-OPTIONSBasic formSELECT-OPTIONS sel FOR f.Additions1. ... DEFAULT g2. ... DEFAULT g ... OPTION xx ... SIGN s3. ... DEFAULT g TO h4. ... DEFAULT g TO h ... OPTION xx ... SIGN s5. ... MEMORY ID pid6. ... MATCHCODE OBJECT mobj7. ... MODIF ID key8. ... NO-DISPLAY9. ... LOWER CASE10. ... OBLIGATORY11. ... NO-EXTENSION12. ... NO INTERVALS13. ... NO DATABASE SELECTION14. ... VALUE-REQUEST15. ... VALUE-REQUEST FOR LOW/HIGH16. ... HELP-REQUEST17. ... HELP-REQUEST FOR LOW/HIGHEffectDeclares a variable selection option.This statement only makes sense in reports, i.e. in programs defined as type 1 in the attributes. You can execute reports with the SUBMIT statement. The statements SELECT-OPTIONS and PARAMETERSSUBMIT without the addition VIA SELECTION-SCREEN .sel must be 1 - 8 characters long.Noteq This statement defines an internal table sel with a fixed structure which consists of the fields sel-SIGN , sel-OPTION , sel-LOW and sel-HIGH .q A report can (by means of an entry in the attributes) be assigned to a logical database ldb . Thismeans that both the logical database ldb and the report can define selection options (andparameters). You define the (database-specific) selection options in an ABAP/4 include program DBldbSEL (in logical database maintenance). The system then imports this include program into the actual logical database access program SAPDBldb and (partially) into the report. As a result, the database-specific selection options (and parameters) relevant to the report are available both to the database program SAPDBldb and to the report.The 'report-specific' selection options are known only in the report (not in SAPDBldb ).Some SELECT-OPTIONS additions are allowed only in DBldbSEL . The addition 'NODATABASE SELECTION' can only be used in the report.q Each line of the internal table sel formulates a condition. If you require precise details about how to formulate these conditions, see the section on the IN operator under Logical expressions .q If the user enters a value set on the selection screen, the internal table sel is automatically filled.You can use normal ABAP/4 statements to read and manipulate the internal table sel .q The values you enter for the database-specific selection options are passed directly to the database for data selection (i.e. no unwanted records are read). This also applies to report-specific SELECT-OPTIONS that refer to a field in a logical database table defined for dynamic selections (see also the addition " NO DATABASE SELECTION ").You must check report-specific selections that refer to other fields with the CHECK statement (i.e.unwanted records must first be read from the database and discarded afterwards). This process is therefore not as efficient as the process described above.q Under "Text elements/selection texts", you should enter a description for each selection criterion sel . This description is displayed on the selection screen. If no such text exists, the name sel of theselection option is displayed instead.q The LOW and HIGH fields of a selection option are displayed in a length up to 18 bytes long(scrollable up to 45 bytes). If you define a length longer than 45, fields are truncated on theselection screen after the 45th character. This affects the first line of the SELECT-OPTIONS table.are then truncated whenever the selection screen is processed in the background (SUBMIT without VIA SELECTION-SCREEN ).ExampleSELECT-OPTIONS PROGRAM FOR SY-REPID.&ABAP-EFFECT& Suppose you create an internal table PROGRAM with the header line fields PROGRAM-SIGN , PROGRAM-OPTION , PROGRAM-LOW and PROGRAM-HIGH . PROGRAM-LOW and PROGRAM-HIGH have the same field attributes as SY-REPID . When the report is executed, a line on the selection screen contains the text 'PROGRAM' or the associated selection text as well as input fields for PROGRAM-LOW and PROGRAM-HIGH . At the end of the line, there is a pushbutton with an arrow. When you press this button, you branch to the 'Complex Selections' screen where you can enter more selection lines for sel . Here, you can formulate very complicated selection conditions. For further information about how these entries determine the result set, see Logical expressions or select Utilities -> Help sel. screen on the 'Complex Selections' screen.Noteq Field attributes on the selection screen.The input/output fields displayed on the selection screen for entry of upper and lower limits have the same attributes for type, length or conversion exits as the field f specified after FOR .If f is a Dictionary field, the selection screen is regenerated automatically after most changes to its attributes. The attributes 'Check table' and 'Fixed values' are exceptions to this rule. If these arechanged, you have to generate the program in the ABAP/4 Editor. This also generates the selection screen.Addition 1... DEFAULT gEffectProposes the single value g as the default selection when the report is called.q For each SELECT-OPTION , you can only specify one DEFAULT .q You must specify the default value g in its internal format, e.g. " SELECT-OPTIONS DATE FOR SY-DATUM DEFAULT '19931224' ", not " ... DEFAULT '24.12.1993' ".q The default value g should normally be a literal because, at runtime, it is transferred to the selection options table sel so early that no value can be assigned to the field g . System fields are an exception here because the system usually assigns values to them as soon as the report processing starts.ExampleSELECT-OPTIONS DATE FOR SY-DATUM DEFAULT SY-DATUM.Addition 2... DEFAULT g ... OPTION xx ... SIGN s( xx is OPTION , i.e. one of the values EQ,NE,CP,NP,GE,LT,LE,GT ); s is SIGN , i.e. one of the values I or E )EffectSimilar to " ... DEFAULT g ", except that the system also proposes the specified selection option and SIGN .You can specify the additions OPTION and SIGN in any order or omit them. The standard OPTION is EQ , the standard SIGN is I .ExampleDATA CITY(20).SELECT-OPTIONS SO_CITY FOR CITY DEFAULT 'SAN*'OPTION CP SIGN E.On the selection screen, this results in an entry specifying that cities not beginning with " SAN " are selected.Notesq For each SELECT-OPTION , you can only specify one DEFAULT .q The option xx and SIGN s must be specified without quotation marks.Addition 3... DEFAULT g TO hEffectProposes the range from g to h when the report is called.NoteFor each SELECT-OPTION , you can only specify one DEFAULT .Addition 4... DEFAULT g TO h ... OPTION xx ... SIGN s( xx is OPTION , i.e. one of the values EQ,NE,CP,NP,GE,LT,LE,GT ); s is SIGN , i.e. one of the values I or E )EffectSimilar to " DEFAULT g TO h ", except that the system proposes the specified selection option and SIGN .You can specify the additions OPTION and SIGN in any order or omit them. The default OPTION is BT , the default SIGN is I .ExampleDATA WORD(20).SELECT-OPTIONS SO_WORD FOR WORD DEFAULT 'SPRING' TO 'SUMMER'OPTION NB SIGN I.On the selection screen, this results in an entry specifying that the words between " SPRING " and " SUMMER " are excluded.q For each SELECT-OPTION , you can only specify one DEFAULT .q The option xx and SIGN s must be specified without quotation marks.Addition 5... MEMORY ID pidEffectOn the selection screen, the SET/GET ID pid is assigned to the left range limit of the selection criterion. NoteYou must specify the memory ID without quotation marks. It can be up to 3 characters long. Addition 6... MATCHCODE OBJECT mobjEffectOn the selection screen, the matchcode object mobj is assigned to the left range limit of the selection criterion.NoteYou must specify the name of the matchcode object without quotation marks. It can be up to 4 characters long.Addition 7... MODIF ID keyEffectThe specified modification group ( SCREEN-GROUP1 ), which can be used for screen modifications, is assigned to the screen fields.NoteYou must specify the name of the modification group without quotation marks. It can be up to 3 characters long.ExampleTABLES SAPLANE....SELECT-OPTIONS S_PTYPE FOR SAPLANE-PLANETYPE MODIF ID ABC....AT SELECTION-SCREEN OUTPUT.LOOP AT SCREEN.IF SCREEN-GROUP1 = 'ABC'.SCREEN-INTENSIFIED = '1'.MODIFY SCREEN.ENDIF.ENDLOOP.Addition 8... NO-DISPLAYEffectDoes not display the selection on the selection screen. Creates the internal table sel as with 'normal' selection options and you can then transfer the selection option with SUBMIT .These selection options represent a part of the interface which the user does not see on the selection screen. You can set the values either internally (through the routine INIT in SAPDBldb or INITIALIZATION in the report) or with SUBMIT . These selection options are also stored for variants.Sometimes, (e.g. when the user has entered particular values for other selection options or parameters ), you may want to display these undisplayed selection options on the screen so that the user can enter values.module (see CALL FUNCTION ) or your own screen (CALL SCREEN .Addition 9... LOWER CASEEffectThe selection is not case-sensitive (i.e. allows upper and lower case letters).Addition 10... OBLIGATORYEffectThe user must enter a value for this selection (in the LOW field).Addition 11... NO-EXTENSIONEffectThe user can only make an entry on one line. Calling the additional "Multiple Selection" screen is not supported and no pushbutton for this appears on the selection screen.Addition 12... NO INTERVALSEffectThe selection option is displayed on the selection screen without a 'to' field. The pushbutton for calling the "Multiple Selection" screen appears immediately after the 'from' field.This addition thus allows you to generate a simplified display on the selection screen. This is particularly useful if you are not making any range selections for this selection option.q On the "Multiple Selection" screen, you can also enter ranges for selection options with " NOINTERVALS ".q By combining this addition with " NO-EXTENSION ", you can restrict the user to entry of a single value for the selection option, but with the possibility of also choosing single value options like'Greater than' or 'Less than or equal'.q By using the addition " NO INTERVALS " with SELECTION-SCREEN BEGIN OF BLOCK , you can activate the simplified display for all selection options in a block.q The function module SELECT_OPTIONS_RESTRICT allows you to restrict the set of selectionoptions available for a SELECT-OPTION (for example, only single values and patterns, i.e. 'EQ' and 'CP' are allowed). You can also forbid the leading sign 'E' (= 'Exclude from selection'). Thismeans that you can considerably restrict the selections which can be entered on the selection screen. Addition 13... NO DATABASE SELECTIONEffectThis addition is allowed only for report-specific SELECT-OPTIONS which refer to a field f belonging to a table dbtab of the logical database. Here, the selections entered by the user are not passed directly to the logical database unless the logical database supports dynamic selections for dbtab (if dynamic selections for dbtab are not supported, the addition has no effect.This addition can be useful if you only want the selections entered by the user for this SELECT-OPTION to be effective under certain conditions. However, you should be careful when using it: Since the selections have to be checked with CHECK after the records have been read, this has a considerable effect on performance.Addition 14... VALUE-REQUESTAddition 15... VALUE-REQUEST FOR LOW/HIGHThis addition is allowed only for database-specific SELECT-OPTIONS in the include program DBxyzSEL (where xyz = logical database name). It allows you to implement self-programmed value help. (To implement self-programmed value help for report-specific SELECT-OPTIONS , you can use the event key word AT SELECTION-SCREEN ON VALUE-REQUEST FOR ... .) If you specify only VALUE-REQUEST (without FOR ... ), the value help refers to both input/output fields of the SELECT-OPTION (i.e. to sel-LOW and sel-HIGH). Otherwise, it refers only to the specified field. The addition has two effects:The affected input/output fields are displayed on the selection screen with the pushbutton for F4 (possible entries).When the user presses this button or F4 , this triggers the FORM routine sel-LOW_VAL or sel-HIGH_VAL in the database access program SAPDBxyz (if it exists). If this addition is specified - and even if the SELECT-OPTION with FOR points to a Dictionary field - this FORM routine is executed when the user presses F4 and the check table or the fixed values of the Dictionary field are not displayed. You can, for example, branch from the routine sel-LOW_VAL or sel-HIGH_VAL to a function module which offers a selection list of possible values. At the end of this FORM routine, the contents of the field sel-LOW or sel-HIGH are copied to the appropriate input/output field.Example* INCLUDE DBXYZSEL...SELECT-OPTIONS S_PTYPE FOR SAPLANE-PLANETYPE VALUE-REQUEST FOR LOW....REPORT SAPDBXYZ DEFINING DATABASE XYZ....TABLES SAPLANE....FORM S_PTYPE-LOW_VAL....CALL FUNCTION '...'....ENDFORM.Addition 16... HELP-REQUEST... HELP-REQUEST FOR LOW/HIGHEffectLike VALUE-REQUEST , this addition is allowed only for database-specific SELECT-OPTIONS in the include program DBxyzSEL (where xyz = logical database name). It allows you to implement self-programmed value help. (To implement self-programmed value help for report-specific SELECT-OPTIONS , you can use the event key word AT SELECTION-SCREEN ON HELP-REQUEST FOR ... .) If you specify only HELP-REQUEST (without FOR ... ), the help refers to both input/output fields of the SELECT-OPTION (i.e. to sel-LOW and sel-HIGH). Otherwise, it refers only to the specified field. When the user presses F1 , this triggers the FORM routine sel-LOW_HLP or sel-HIGH_HLP in the database access program SAPDBxyz (if it exists). If this addition is specified - and even if the SELECT-OPTION with FOR points to a Dictionary field - this FORM routine is executed when the user presses F1 and the documentation of the Dictionary field is not displayed. You can, for example, branch from the routine sel-LOW_HLP or sel-HIGH_HLP to a function module which displays its own documentation.Example* INCLUDE DBXYZSEL...SELECT-OPTIONS S_PTYPE FOR SAPLANE-PLANETYPE HELP-REQUEST....REPORT SAPDBXYZ DEFINING DATABASE XYZ...TABLES SAPLANE....FORM S_PTYPE-LOW_HLP....CALL FUNCTION '...'....ENDFORM.FORM S_PTYPE-HIGH_HLP....CALL FUNCTION '...'....ENDFORM.Index© SAP AG 1996BGCOLOR=#e0e0e0>SUBMITBasic formSUBMIT rep.Additions1. ... LINE-SIZE col2. ... LINE-COUNT lin3. ... TO SAP-SPOOL4. ... VIA SELECTION-SCREEN5. ... AND RETURN6. ... EXPORTING LIST TO MEMORY7. ... USER user VIA JOB job NUMBER n8. ... Various additions for parameter transfer to rep9. ... USING SELECTION-SETS OF PROGRAM progEffectCalls the report rep . Leaves the active program and starts the new report rep . Addition 1... LINE-SIZE colEffectPrints the report with the line width col .Addition 2... LINE-COUNT linEffectPrints the report with lin lines (per page).Addition 4... VIA SELECTION-SCREENEffectDisplays the selection screen for the user. In this case, the selection screen is redisplayed after return from the report list display - the user's entries are retained.Addition 5... AND RETURNEffectReturns to the calling transaction or program after the called program has been executed. SUBMIT ... AND RETURN creates a new internal mode .Addition 6... EXPORTING LIST TO MEMORYEffectDoes not display the output list of the called report, but saves it in SAP memory and leaves the called report immediately. Since the calling program can read the list from memory and process it further, you need to use the addition ... AND RETURN . Also, since the called report cannot be requested for printing, the addition ... TO SAP-SPOOL is not allowed here. You can read the saved list from SAP memory with the function module 'LIST_FROM_MEMORY' and then (for example) store it in the database with EXPORT . You can process this list further with the function modules 'WRITE_LIST' ,'DISPLAY_LIST' ... of the function group "SLST" .Addition 7... USER user VIA JOB job NUMBER nEffectSchedules the specified report in the job specified by the job name job and the job number n . The job runs under the user name user and you can omit the addition USER user . The assignment of the job number occurs via the function module JOB_OPEN (see also the documentation for the function modules JOB_CLOSE and JOB_SUBMIT . This addition can only be used with the addition ...AND RETURN .NoteWhen scheduling a report with the SUBMIT ... VIA JOB job NUMBER n statement, you should always use the addition ...TO SAP-SPOOL to pass print and/or archive parameters. Otherwise, default values are used to generate the list and this disturbs operations in a production environment.Addition 9... USING SELECTION-SETS OF PROGRAM progEffectUses variants of the program prog when executing the program rep .NoteImportantThe programs prog and rep must have the same SELECT-OPTIONS and PARAMETER s. Otherwise, variants of the program prog may be destroyed.NoteWhen using this addition, the specified variant vari of the program prog is taken in USING SELECTION-SET vari . On the other hand, all variant-related actions on the selection screen of rep (Get , Save as variant , Display , Delete ) refer to the variants of prog .ExampleSUBMIT REPORT01VIA SELECTION-SCREENUSING SELECTION-SET 'VARIANT1'USING SELECTION-SETS OF PROGRAM 'REPORT00'AND RETURN.EffectExecutes the program REPORT01 with the variant VARIANT1 of the program REPORT00 .NoteRuntime errorsq LOAD_PROGRAM_NOT_FOUND : The specified program was not found.q SUBMIT_WRONG_TYPE : The specified program is not a report.q SUBMIT_IMPORT_ONLY_PARAMETER : Only one value passed to a report parameter.q SUBMIT_WRONG_SIGN : Invalid value passed to a selection with the addition SIGN .q SUBMIT_IN_ITAB_ILL_STRUCTURE : Table passed to a selection with WITH sel IN itab had an unexpected structure.Index© SAP AG 1996BGCOLOR=#e0e0e0>SUBMIT TO SAP-SPOOLBasic formSUBMIT rep ... TO SAP-SPOOL.Additions1. ... DESTINATION dest... COPIES cop... LIST NAME name... LIST DATASET dsn... COVER TEXT text... LIST AUTHORITY auth... IMMEDIATELY flag... KEEP IN SPOOL flag... NEW LIST IDENTIFICATION flag... DATASET EXPIRATION days... LINE-COUNT lin... LINE-SIZE col... LAYOUT layout... SAP COVER PAGE mode... COVER PAGE flag... RECEIVER rec... DEPARTMENT dep... ARCHIVE MODE armode... ARCHIVE PARAMETERS arparams... WITHOUT SPOOL DYNPRO2. ... SPOOL PARAMETERS params... ARCHIVE PARAMETERS arparams... WITHOUT SPOOL DYNPROEffectCalls the report rep with list output to the SAP spool database. Additions... DESTINATION dest (output device)... COPIES cop (number of copies)... LIST NAME name (name of list)... LIST DATASET dsn (name of spool dataset)... COVER TEXT text (title of spool request)... LIST AUTHORITY auth (authorization for display)... IMMEDIATELY flag (print immediately ?)... KEEP IN SPOOL flag (keep list after print ?)... NEW LIST IDENTIFICATION flag (new spool request ?) ... DATASET EXPIRATION days (number of days list retained) ... LINE-COUNT lin ( lin lines per page)... LINE-SIZE col ( col columns per line)... LAYOUT layout (print format)... SAP COVER PAGE mode ( SAP cover sheet ?)... COVER PAGE flag (selection cover sheet ?)... RECEIVER rec ( SAP user name ofrecipient)... DEPARTMENT dep (name of department)... ARCHIVE MODE armode (archiving mode)... ARCHIVE PARAMETERS arparams (structure with archiving parameters)... WITHOUT SPOOL DYNPRO (skip print control screen)With the parameters IMMEDIATELY , KEEP IN SPOOL , NEW LIST IDENTIFICATION and COVER TEXT , flag must be a literal or character field with the length 1. If flag is blank, the parameter is switched off, but any other character switches the parameter on. You can also omit any of the sub-options of PRINT ON . mode with SAP COVER PAGE can accept the values ' ' , 'X' and 'D' . These values have the following meaning:' ' : Do not output cover sheet'X' : Output cover sheet'D' : Cover sheet output according to printer settingarmode with ARCHIVE MODE can accept the values '1' , '2' and '3' . These values have the following meaning:'1' : Print only'2' : Archive only'3' : Print and archivearparams with ARCHIVE PARAMETERS must have the same structure as ARC_PARAMS . This parameter should only be processed with the function module GET_PRINT_PARAMETERS .EffectOutput is to the SAP spool database with the specified parameters. If you omit one of the parameters, the system uses a default value. Before output to the spool, you normally see a screen where you can enter and/or modify the spool parameters. However, you can suppress this screen with the following statement:... TO SAP-SPOOL WITHOUT SPOOL DYNPROThis you could use this option if all the spool parameters have already been set!NoteWhen specifying the LINE-SIZE , you should not give any value > 132 because most printers cannot print wider lists.Addition 2... SPOOL PARAMETERS params (structure with printparameters)... ARCHIVE PARAMETERS arparams (Structure with archiveparameters)... WITHOUT SPOOL DYNPRO (skip print parametersscreen)EffectOutput is to the SAP spool database with the specified parameters. The print parameters are passed by the field string params which must have the structure of PRI_PARAMS . The field string can be filled anf modified with the function module GET_PRINT_PARAMETERS . The specification arparams with ARCHIVE PARAMETERS must have the structure of ARC_PARAMS . This parameter should only be processed with the function module GET_PRINT_PARAMETERS . Before output to the spool, you normally see a screen where you can enter and/or modify the spool parameters. However, you can suppress this screen with the following statement:... WITHOUT SPOOL DYNPROExample* Without archivingDATA: PARAMS LIKE PRI_PARAMS,DAYS(1) TYPE N VALUE 2,COUNT(3) TYPE N VALUE 1,VALID TYPE C.CALL FUNCTION 'GET_PRINT_PARAMETERS'EXPORTING DESTINATION = 'LT50'COPIES = COUNTLIST_NAME = 'TEST'LIST_TEXT = 'SUBMIT ... TO SAP-SPOOL'IMMEDIATELY = 'X'RELEASE = 'X'NEW_LIST_ID = 'X'EXPIRATION = DAYSLINE_SIZE = 79LINE_COUNT = 23LAYOUT = 'X_PAPER'SAP_COVER_PAGE = 'X'COVER_PAGE = 'X'RECEIVER = 'SAP*'DEPARTMENT = 'System'NO_DIALOG = ' 'IMPORTING OUT_PARAMETERS = PARAMSVALID = VALID.IF VALID <> SPACE.SUBMIT RSTEST00 TO SAP-SPOOLSPOOL PARAMETERS PARAMSWITHOUT SPOOL DYNPRO.ENDIF.Example* With archivingDATA: PARAMS LIKE PRI_PARAMS,ARPARAMS LIKE ARC_PARAMS,DAYS(1) TYPE N VALUE 2,COUNT(3) TYPE N VALUE 1,VALID TYPE C.CALL FUNCTION 'GET_PRINT_PARAMETERS'EXPORTING DESTINATION = 'LT50'COPIES = COUNTLIST_NAME = 'TEST'LIST_TEXT = 'SUBMIT ... TO SAP-SPOOL' IMMEDIATELY = 'X'RELEASE = 'X'NEW_LIST_ID = 'X'EXPIRATION = DAYSLINE_SIZE = 79LINE_COUNT = 23LAYOUT = 'X_PAPER'SAP_COVER_PAGE = 'X'COVER_PAGE = 'X'RECEIVER = 'SAP*'DEPARTMENT = 'System'SAP_OBJECT = 'RS'AR_OBJECT = 'TEST'ARCHIVE_ID = 'XX'ARCHIVE_INFO = 'III'ARCHIVE_TEXT = 'Description' NO_DIALOG = ' 'IMPORTING OUT_PARAMETERS = PARAMSOUT_ARCHIVE_PARAMETERS = ARPARAMSVALID = VALID.IF VALID <> SPACE.SUBMIT RSTEST00 TO SAP-SPOOLSPOOL PARAMETERS PARAMSARCHIVE PARAMETERS ARPARAMSWITHOUT SPOOL DYNPRO.ENDIF.Index© SAP AG 1996BGCOLOR=#e0e0e0>Passing parameters with SUBMITVariants1. ... USING SELECTION-SET vari2. ... WITH p op f SIGN s3. ... WITH p BETWEEN f1 AND f2 SIGN s4. ... WITH p NOT BETWEEN f1 AND f2 SIGN s5. ... WITH p IN sel6. ... WITH SELECTION-TABLE seltab7. ... WITH FREE SELECTIONS texprEffectPasses values to the SELECT-OPTIONS and PARAMETERS of the program rep (these can also be defined in the database program SAPDBldb of the relevant logical database ldb ). p is the name of a parameter or selection criterion .Variant 1... USING SELECTION-SET variEffectThe variable vari contains the name of a variant used to start the report.Variant 2... WITH p op f SIGN sEffectop is one of the operations EQ, NE, CP, NP, GE, LT, LE, GT . s is a variable which must contain one of the values 'I' or 'E' (any other values result in a runtime error). The addition SIGN is optional and thedefault is 'I' . If p is a selection criterion (SELECT-OPTIONS ), an entry with LOW = f , OPTION = op and SIGN = s is generated in the relevant internal table.If p is a parameter (PARAMETERS ), the system treats all options like EQ , i.e. it always transfers a single value. The field f is passed to the parameter p or to the field p-LOW of the selection criterion (xxx in the above list) in internal format. If p is not the same type as f , a type conversion is performed in the target report when data is passed.Variant 3... WITH p BETWEEN f1 AND f2 SIGN sEffectPasses the range with the lower limit f1 and the upper limit f2 to the selection criterion p . As with variant 2, f1 and f2 are passed in internal format and the handling of SIGN is also the same. The system thus generates an entry with LOW = f1 , HIGH = f2 , OPTION = BT and SIGN = s . When data is passed, a type conversion is performed.Variant 4... WITH p NOT BETWEEN f1 AND f2 SIGN sEffectSimilar to 3, except that OPTION NB is generated instead of OPTION BT .Variant 5... WITH p IN selEffectp is a selection criterion and sel is an internal table which is compatible with p and contains the transfer values. You are recommended to define sel with RANGES . The lines of sel must have exactly the same structure as the lines of a sdlection table (see SELECT-OPTIONS ).Variant 6... WITH SELECTION-TABLE seltab。