ABAPFunction 之 Read_Text函数的使用方法

合集下载

ABAP语法讲解二(s e l e c t语句)

ABAP语法讲解二(s e l e c t语句)

SELECTBasic formSELECT select clause [INTO clause] FROM from clause [WHERE cond1] [GROUP BY fields1] [HAVING cond2] [ORDER BY fields2].EffectReads a selection and/or a summary of data from one or more database tables and/or views (see relational database). SELECT is an OPEN SQL statement.Each SELECT statement consists of a series of clauses, each with a differen task:The SELECT clause select clause describes∙Whether the result of the selection should be a single record or a table,∙Which columns should be contained in the result,∙Whether identical lines may occur in the result.The INTO clause INTO clause determines the target area into which the selected data is read. If the target area is an internal table, the INTO clause specifies:∙Whether you want to overwrite the contents of the internal table or∙Append the results to the internal table, and∙Whether you want to place the data in the internal table in a single step, or in a series of packages.The INTO clause can also occur after the FROM clause. You may omit it if∙The SELECT clause contains a "*",∙The FROM clause does not contain a JOIN, and∙You have declared a table work area dbtab in your program using TABLES.The data, if it exists in the database, is then made available using the table work area dbtab. The statement is then processed further like the SELECT * INTO dbtab FROM dbtab statement, which has the same effect.If the result of the selection is a table, the data is normally read line by line (for further information, see INTO clause) in a processing loop, which is introduced with SELECT and concludes with ENDSELECT. The loop is processed once for each line that is read. If you want the result of the selection to be a single record, there is no concluding ENDSELECT statement.The FROM clause FROM clause specifies the source of the data (database tables or views), from which you want to select the data. It also specifies the∙Client handling,∙Behavior for buffered tables, and∙The maximum number of lines that you want to read.The WHERE clause cond1 specifies the conditions that the result of the selection must satisfy. By default, only data from the current client is selected (without you having to specify the client field specifically in the WHERE clause). If you want to select data from several clients, you must use the ... CLIENT SPECIFIED addition in the FROM clause.The GROUP BY clause fields1 combines groups of lines into single lines of the result table.A group is a set of records with the same value of each database field listed in the GROUP BY clause.The HAVING clause cond2 specifies conditions for the combined lines of the result table.The ORDER BY clause fields2 specifies how the records in the result table should be arranged.The system field SY-DBCNT contains the number of lines read so far ecah time the SELECT statement is executed. After ENDSELECT, SY-DBCNT contains the total number of records read.The return code is set as follows:SY-SUBRC = 0:The result table contains at least one record.SY-SUBRC = 4:The result table is empty.SY-SUBRC = 8:Applies only to SELECT SINGLE FOR UPDATE: You did not specify all of the primary key fields in the WHERE condition. The result table is empty.NoteThe SELECT COUNT( * ) FROM ... statement returns a result table containing a single line with the result 0 if there are no records in the database table that meet the selection criteria. In an exception to the above rule, SY-SUBRC is set to 4 in this case, and SY-DBCNTto zero.ExampleDisplaying the passenger list for Lufthansa flight 0400 on 2/28/1995:DATA: WA_SBOOK TYPE SBOOK.SELECT * FROM SBOOK INTO WA_SBOOKWHERECARRID = 'LH ' ANDCONNID = '0400' ANDFLDATE = '19950228'ORDER BY PRIMARY KEY.WRITE: / WA_SBOOK-BOOKID, WA_SBOOK-CUSTOMID,WA_SBOOK-CUSTTYPE, WA_SBOOK-SMOKER,WA_SBOOK-LUGGWEIGHT, WA_SBOOK-WUNIT,WA_SBOOK-INVOICE.ENDSELECT.NotePerformance:Storing database tables in a local buffer (see SAP buffering) can lead to considerable time savings in a client/server environment, since the access time across the network is considerably higher than that required to access a locally-buffered table.Notes1. A SELECT statement on a table for which SAP buffering has been declared in theABAP Dictionary usually reads data from the SAP buffer without accessing thedatabase. This does not apply when you use:- SELECT SINGLE FOR UPDATE or- SELECT DISTINCT in the SELECT clause,- BYPASSING BUFFER in the FROM clause,- ORDER BY f1 ... fn in the ORDER BY clause,- Aggregate functions in the SELECT clause,- When you use IS [NOT] NULL in the WHERE condition,or when the table has generic buffering and the appropriate section of the key is not specified in the WHERE condition.2. The SELECT statement does not perform its own authorization checks. You shouldwrite your own at program level.3. Proper synchronization of simultaneous access by several users to the same set ofdata cannot be assured by the database lock mechanism. In many cases, you will need to use the SAP locking mechanism.4. Changes to data in the database are not made permanent until a database commit(see LUW) occurs. Up to this point, you can undo any changes using a databserollback (see Programming Transactions). At the lowest isolation level (see lock mechanism ), the "Uncommitted Read", it can sometimes be the case that dataselected by a SELECT statement was never written to the database. While a program is selecting data, a second program could be adding data to, changing data in, or deleting data from the database at the same time. If the second program thenexecutes a rollback, the first program has selected a set of data that may onlyrepresent a temporary state from the database. If this kind of "phantom data" isunacceptable in the context of your application, you must either use the SAP locking mechanism or change the isolation level of the database system to at least"Committed Read" (see locking mechanism).5. In a SELECT - ENDSELECT loop, the CONTINUE statement terminates the currentloop pass and starts the next.6. If a SELECT - ENDSELECT loop contains a statement that triggers a databasecommit, the cursor belonging to the loop is lost and a program termination andruntime error occur. Remote Function Calls and changes of screen always lead to adatabase commit. The following statements are consequently not allowed wihtin aSELECT-ENDSELECT loop: CALL FUNCTION ... STARTING NEW TASK, CALLFUNCTION ... DESTINATION, CALL FUNCTION ... IN BACKGROUND TASK,CALL SCREEN, CALL DIALOG, CALL TRANSACTION, and MESSAGE.7. On some database systems (for example DB2/390)locking conflicts can be caused even by read access. You can prevent this problemfrom occurring using regular database commits.SELECT ClauseVariants:1. SELECT [SINGLE [FOR UPDATE] | DISTINCT] *2. SELECT [SINGLE [FOR UPDATE] | DISTINCT] s1 ... sn3. SELECT [SINGLE [FOR UPDATE] | DISTINCT] (itab)EffectThe result of a SELECT statement is itself a table. The SELECT clause, along with the database tables and/or views in the FROM clause, specifies the sequence, name, database type, and length of the columns of the result table.You can also use the optional additions SINGLE or DISTINCT to indicate that only certain lines in the result set should be visible to the program:SINGLEThe result of the selection should be a single entry. If it is not possible to identify a unique entry, the system uses the first line of the selection. If you use the FOR UPDATE addition, the selected entry is protected against parallel updates from other transactions until the next database commit (see LUW and database lock mechanism). If the database system identifies a deadlock, a runtime error occurs. DISTINCTDuplicate entries in the result set are automatically deleted.NoteTo ensure that an entry can be uniquely identified, you can specify all of the fields in the primary key using AND expressions in the WHERE condition.NotePerformance:1. The additions SINGLE FOR UPDATE and DISTINCT bypass the SAP buffering.2. The addition DISTINCT forces a sort on the database server. You should thereforeonly use it if you are really expecting duplicates in the result set.Variant 1SELECT [SINGLE [FOR UPDATE] | DISTINCT] *EffectThe columns of the result set will have exactly the same sequence, names, database type, and length as the fields of the database table or view specified in the FROM clause.ExamplesExample to display all flights from Frankfurt to New York:DATA WA_SPFLI TYPE SPFLI.SELECT * FROM SPFLI INTO WA_SPFLIWHERECITYFROM = 'FRANKFURT' ANDCITYTO = 'NEW YORK'.WRITE: / WA_SPFLI-CARRID, WA_SPFLI-CONNID.ENDSELECT.Example to display the free seats on Lufthansa flight 0400 on 02.28.1995:DATA WA_SFLIGHT TYPE SFLIGHT.DATA SEATSFREE TYPE I.SELECT SINGLE *FROM SFLIGHT INTO WA_SFLIGHTWHERECARRID = 'LH ' ANDCONNID = '0400' ANDFLDATE = '19950228'.SEATSFREE = WA_SFLIGHT-SEATSMAX - WA_SFLIGHT-SEATSOCC.WRITE: / WA_SFLIGHT-CARRID, WA_SFLIGHT-CONNID,WA_SFLIGHT-FLDATE, SEATSFREE.NoteIf you specify more than one table in the FROM clause and the INTO clause contains an internal table or work area instead of a field list, the fields are placed into the target area from left to right in the order in which they occur in the tables in the FROM clause. Gaps may occur between the table work areas for the sake of alignment. For this reason, you should define the target work area by referring to the types of database tables instead of simply listing the fields. For an example, refer to the documentation of the FROM clause.Variant 2SELECT [SINGLE [FOR UPDATE] | DISTINCT] s1 ... snEffectThe columns of the result table will have the same format as the column references s1 ... sn.If si stands for a field f, MAX( f ), MIN( f ), or SUM( f ), the corresponding column in the result set will have the same ABAP Dictionary format as f. For COUNT( f ) orCOUNT( * ) the column has the type INT4. For AVG( f ) it has the type FLTP.If you use aggregate functions with one or more database fields in the SELECT clause, you must include all of the database fields that are not used in the aggregate function in the GROUP BY clause. The result of the selection in this case is a table.If the SELECT clause only contains aggregate functions, the result of the selection will be a single entry. In this case, SELECT does not have a corresponding ENDSELECT statement.Notes1. You can only use this variant for pool and cluster tables if the SELECT clause doesnot contain any aggregate functions.2. As a rule, aggregate functions used together with the FOR ALL ENTRIES addition donot return the desired values. The result is only correct if the fields in the WHEREcondition that are linked with AND and tested for equality with the aggregated fieldscan identify the table line uniquely.3. If you use a database field with type LCHAR or LRAW in the SELECT clause, you mustspecify the corresponding length field immediately before it in the SELECT clause. NotesPerformance:1. When you use aggregate functions, the system bypasses the SAP buffer.2. Since not all database systems can store the number of lines in a table in theircatalog, and therefore retrieving them is time-consuming, the COUNT( * ) functionis not suitable for testing whether a table contains any entries at all. Instead, youshould use SELECT SINGLE f ... for any table field f.3. If you only want to select certain columns of a database table, use a field list in theSELECT clause or a view.ExamplesExample to display all destinations served by Lufthansa from Frankfurt:TABLES SPFLI.DATA TARGET LIKE SPFLI-CITYTO.SELECT DISTINCT CITYTOINTO TARGET FROM SPFLIWHERECARRID = 'LH ' ANDCITYFROM = 'FRANKFURT'.WRITE: / TARGET.ENDSELECT.Example to display the number of airlines that fly to New York:TABLES SPFLI.DATA COUNT TYPE I.SELECT COUNT( DISTINCT CARRID )INTO COUNTFROM SPFLIWHERECITYTO = 'NEW YORK'.WRITE: / COUNT.Example to find the number of passengers, the total luggage weight, and the average weight of the luggage for all Lufthansa flights on 02.28.1995:TABLES SBOOK.DATA: COUNT TYPE I, SUM TYPE P DECIMALS 2, AVG TYPE F.DATA: CONNID LIKE SBOOK-CONNID.SELECT CONNID COUNT( * ) SUM( LUGGWEIGHT ) AVG( LUGGWEIGHT ) INTO (CONNID, COUNT, SUM, AVG)FROM SBOOKWHERECARRID = 'LH ' ANDFLDATE = '19950228'GROUP BY CONNID.WRITE: / CONNID, COUNT, SUM, AVG.ENDSELECT.Variant 3SELECT [SINGLE [FOR UPDATE] | DISTINCT] (itab)EffectWorks like SELECT [SINGLE [FOR UPDATE] | DISTINCT] s1 ... sn, if the internal table itab contains the list s1 ... sn as ABAP source code, and works like SELECT [SINGLE [FOR UPDATE] | DISTINCT] *, if itab is empty. The internal table itab may only contain one field, which must have type C and not be longer than 72 characters. Youmust specify itab in parentheses. Do not include spaces between the parentheses and the table name.NoteThe same restrictions apply to this variant as to SELECT [SINGLE [FOR UPDATE] | DISTINCT] s1 ... sn.ExampleExample to display all Lufthansa routes:DATA WA_SPFLI TYPE SPFLI,WA_FTAB(72) TYPE C, FTAB LIKE TABLE OF WA_FTAB.CLEAR FTAB. FTAB = 'CITYFROM'. APPEND WA_FTAB TO FTAB. FTAB = 'CITYTO'. APPEND WA_FTAB TO FTAB. SELECT DISTINCT (FTAB) INTO CORRESPONDING FIELDS OF WA_SPFLIFROM SPFLIWHERECARRID = 'LH'. WRITE: / WA_SPFLI-CITYFROM, WA_SPFLI-CITYTO. ENDSELECT.。

sap abap 整行读取长文本 函数

sap abap 整行读取长文本 函数

SAP ABAP 整行读取长文本函数在SAP ABAP编程中,我们经常需要处理大量的文本数据。

以下是一些常用的函数,用于在ABAP中整行读取长文本。

1. GET_LINE_LENGTH( )```abapGET_LINE_LENGTH( )```这个函数无参数,调用它将会返回当前文本行的长度。

2. GET_LINE( )```abapGET_LINE( )```这个函数无参数,调用它将会读取当前文本行的内容,返回的是文本行的字符串。

3. CONCATENATE( )```abapCONCATENATE( )```此函数接受两个字符串参数,将它们连接在一起并返回结果字符串。

4. SUBSTITUTE( )```abapSUBSTITUTE( source string; search string; replace string [; occurrence [; pattern type ] ] )```此函数接受最多五个参数。

它在指定字符串(source string)中查找指定的子字符串(search string),并用指定的替换字符串(replace string)替换它。

可以选择指定替换的特定次数(occurrence),也可以选择指定使用的特定模式类型(pattern type)。

5. TRANSLATE( )```abapTRANSLATE( source string; search string; replace string [; occurrence [; pattern type ] ] )```此函数类似于SUBSTITUTE( ),但它还有一个额外的功能:删除源字符串中所有匹配的子字符串。

6. GET_TRANSLATION( )```abapGET_TRANSLATION( source string; search string; replace string [; occurrence [; pattern type ] ] )```此函数类似于SUBSTITUTE( )和TRANSLATE( ),但它返回一个新字符串,其中所有匹配的子字符串都被替换为指定的替换字符串,并且所有其他字符都被删除。

abap长文本

abap长文本

TE XT长文本的编写大家在编程过程中,一定经常用到RE AD_TEXT这个函数来读取长文本,下面我介绍的是如果自己定义一个长文本object和ID,自己储存长文本。

在项目中,做了很多功能性开发,用户要写一些备注或者是审批意见和建议,自定义表里面储存字段的长度是有限的,这个时候能自定义长文本就很实用了。

第一步:建长文本的OBJECT,TCODE SE75,选择‘文本对象和识别码’,点击change,这个时候就会看到S AP 系统中存在的所有长文本OBJECT,点‘新建’,输入文本对象,描述,选择保存状态是更新,选择编辑器应用格式是T A,行宽选一下,回车,搞定第二步:建长文本的ID,双击刚刚创建的OBJECT,点新建,就可以创建ID了第三步:先RE AD_TE XT,如果sy-subrc = 0,说明可以读到,如果不等于0,就说明还没有写长文本,那就可以用INIT_TE XT函数先初始化一下,再E DIT_TE XT编辑一下,最后S AVE_TE XT保存一下就OK了.长文本的编辑能做到:第二次编辑的时候,第一次编辑的内容都是灰色的,这样就可以用来写审批意见。

也可以做到,第二次编辑的时候,第一次的编辑也可以修改,这由几个参数决定。

SAP的标准例子:SDTE XTE,可以参考--------------------------------------------------------------------------------------在屏幕上加一个custom control name ZCBOXP BO事件显示长文本编辑框module mod_custom_control output.data: lv_dmode type xfeld. "Display mode.** Get display mode.if t340-trtyp = 'H'.lv_dmode = space.elseif t340-trtyp = 'V'.lv_dmode = space.elseif t340-trtyp = 'A'.lv_dmode = 'X'.endif.** Get w hat input in the textedit.perform frm_read_text.** Text editor set.call function 'RH_EDITOR_SET'exportingrepid = sy-repiddynnr = sy-dynnrcontrolname = 'ZCBOX'max_cols = 79show_tool = 'X'show_status = 'X'display_mode = lv_dmodetableslines = gt_linesexceptionscreate_error = 1internal_error = 2others = 3.endmodule. " MOD_CUSTOM_CONTROL OUTPUTform frm_read_text .data: lv_name like thead-tdname. "Name.** Object name.clear: lv_name.lv_name = mgef-stoff.** Read text.if gv_enter_flg eq 'X'.clear gt_lines.call function 'RH_EDITOR_GET'exportingcontrolname = 'ZCBOX'tableslines = gt_linesexceptionsinternal_error = 1others = 2.clear gv_enter_flg.else.call function 'RE AD_TE XT'exportingid = 'ZHAZ'language = 'E'name = lv_nameobject = 'ZHAZARDMAT'tableslines = gt_textexceptionsid = 1language = 2name = 3not_found = 4object = 5reference_check = 6wrong_access_to_archive = 7others = 8.if sy-subrc eq 0.** Transfer text.loop at gt_text into gs_text.gs_lines = gs_text-tdline.append gs_lines to gt_lines.clear: gs_text, gs_lines.endloop.endif.endif.endform. " FRM_RE AD_TE XTP AI事件输入后进行保存module mod_save_text input.perform frm_save_text using gv_action_mode.endmodule. " MOD_SAVE_TE XT INPUT"gv_action_mode 是状态V H A tcode的类型代表新建修改或者显示form frm_save_text using i v_mode type c.clear gt_lines.call function 'RH_EDITOR_GE T'exportingcontrolname = 'ZCBOX'tableslines = gt_linesexceptionsinternal_error = 1others = 2.data: lv_name like thead-tdname. "Name.data: gs_header like thead. "SAP script: Text Header.** Transfer data to header.clear: gs_header, l v_name.lv_name = viqmel-qmnum.gs_header-tdobject = 'Z T2O'.gs_header-tdname = lv_name.gs_header-tdid = 'ZTOO'.gs_header-tdspras = 'E'.if iv_mode = 'H'. "Create.gs_header-tdfuser = sy-uname.gs_header-tdfdate = sy-datum.gs_header-tdftime = sy-uzeit.gs_header-tdospras = 'E'.else.gs_header-tdluser = sy-uname.gs_header-tdldate = sy-datum.gs_header-tdltime = sy-uzeit.endif.** Transfer data.clear: gt_text.loop at gt_lines into gs_lines.gs_text-tdformat = '/'.gs_text-tdline = gs_lines.append gs_text to gt_text.clear: gs_text, gs_lines.endloop.** Save text.call function 'SAVE_TE XT'exportingclient = sy-mandtheader = gs_headerinsert = ' 'savemode_direct = ' 'ow ner_speci f ied = ' 'local_cat = ' 'tableslines = gt_textexceptionsid = 1language = 2name = 3object = 4others = 5.** Check save status.if sy-subrc ne 0.call function 'SAP SCRIPT_ME SSAGE'exportingtyp = 'W' "#E C NOTE XTexceptionsothers = 1.else.call function 'COMMIT_TEXT'.endif.endform.教你如何用WORD文档(2012-06-27 192246)转载▼标签:杂谈1. 问:WORD 里边怎样设置每页不同的页眉?如何使不同的章节显示的页眉不同?答:分节,每节可以设置不同的页眉。

Read_Text函数的使用方法

Read_Text函数的使用方法

Read_Text函数的使用方法在SAP系统中,有时候会有大段文本内容需要保存,例如:销售发货(VL03N),在单据的概览中,有一个[文本]项,在此处可以填写单据的大段文本描述,那么该内容保存在哪里呢?第一反应是找对应表的字段,那么你可能要失望了。

在SAP系统中,可以供我们使用的数据库字段最大长度是255个文本字符(注:此处可能不正确),对于很长的文本肯定是不能直接保存到某个表的字段中的(注:至于具体保存在何处,还需要请教)。

因此我们要使用系统函数Read_Text来进行读取,以下是该函数的调用方法:DATA: il_tline LIKE tline OCCURS 0 WITH HEADER LINE.vl_tdname LIKE thead-tdname.CALL FUNCTION 'READ_TEXT'EXPORTINGclient = sy-mandtid = 'Z001'language = '1'name = vl_tdnameobject = 'VBBK'* ARCHIVE_HANDLE = 0* LOCAL_CAT = ' '* IMPORTING* HEADER =TABLESlines = il_tlineEXCEPTIONSid = 1language = 2name = 3not_found = 4object = 5reference_check = 6wrong_access_to_archive = 7OTHERS = 8.IF sy-subrc <> 0.* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.ENDIF.在上面的示例代码中,红色字体部分是需要输入以及输出的参数,调用这个函数的关键就是在于如何找到各输入参数应该填写的内容,下面就以销售发货/外向交货(VL03N)为例,介绍读取[计划员备注]文本是如何查找对应参数的。

abap 内外码转换新语法

abap 内外码转换新语法

abap 内外码转换新语法ABAP内外码转换新语法ABAP是一种面向SAP系统开发的编程语言,用于处理企业应用程序。

在ABAP编程中,内外码转换是一项常见的任务,通常用于将不同字符集编码之间的数据进行转换。

近年来,ABAP引入了一种新的语法来简化内外码转换的过程,本文将介绍这种新语法以及其使用方法。

一、背景在跨国企业的应用系统中,经常会涉及到不同字符集编码之间的数据交换和转换。

比如,在SAP系统中,往往需要将外部系统传入的数据从其它字符集编码(如UTF-8、GBK等)转换为SAP系统所用的内码(如SAP官方编码UTF-16);或者将SAP系统中的数据转换为外部系统所需的字符集编码。

在过去的ABAP编程中,内外码转换通常需要使用一系列函数来完成,如CONVERT_TO_UNICODE、CONVERT_TO_CODEPAGE等。

这些函数的使用相对繁琐,而且容易出错。

为了简化内外码转换的过程,ABAP引入了一种新的语法。

二、新语法介绍新的内外码转换语法是通过使用关键字CONVERT来实现的。

具体用法如下:1. 将外部编码转换为内码:DATA(lv_text) = '外部编码文本'.DATA(lv_utf16) = CONVERT string( lv_text ) TO utf-16.2. 将内码转换为外部编码:DATA(lv_utf16) = '内码文本'.DATA(lv_text) = CONVERT string( lv_utf16 ) FROM utf-16.通过这种新的语法,我们可以用更简洁的方式实现内外码转换,提高开发效率。

三、使用示例下面我们通过一个实际的示例来演示如何使用新的内外码转换语法。

假设我们需要将一个外部系统传入的GBK编码的文本转换为SAP系统使用的内码(UTF-16)。

使用新的语法,我们可以这样实现:DATA(lv_gbk) = '外部系统传入的文本'.DATA(lv_utf16) = CONVERT string( lv_gbk ) TO utf-16.通过以上代码,我们就把外部系统传入的文本从GBK编码转换为了SAP系统使用的UTF-16编码。

ABAP 长文本读取

ABAP 长文本读取

ABAP 长文本读取用途:常常会用到类似于说明或者备注这样的信息,这些信息就是长文本信息。

long text.查看:比如销售订单中(SO)的表单头和表单行项目都可以进行长文本的备注。

查看途径:VA02-->输入订单号-->goto--->header--->texts-->show detail (一个放大镜的图标)-->goto --->header.到texts这一步就可以看到备注信息,在最后一步可以看到备注的头信息。

Item的备注页可以通过类似的途径来查看,不再赘述。

那么这些长文本信息存在什么地方呢?通过对表的查看,发现SO对应的表VBAP,VBAK,不管是header 信息还是Item信息里面都没有存储相关的数据。

事实上,SAP系统把所有的长文本信息都存在了STXH 和 STXL 这两张表里面。

STXH :STXD SAPscript text file header,长文本的头数据STXL :STXD SAPscript text file lines,长文本的明细数据。

是一张簇表。

通过上面的信息查看,我们在表里面也可以找到数据的数据库存储信息。

对于STXH ,我们可以发现他的关键字有:TDOBJECT 对象很多情况下是表名,但不全是。

TDNAME 名称很多情况下是表单编号&明细号TDID ID 这个就是ID,TDSPRAS 语言。

而这些信息都可以在查看的时候看到。

也就是说通过这些信息我们就可以定位到我们所需要的长文本信息。

那在程序中,我们怎么来取这些数呢?直接取么?我们可以看到STXL-CLUSTD是类似乱码的东西。

怎么成这样的,不清楚,簇表的长字段都是这个鸟样子。

那如果我们来解析,完了。

在程序中,对于长字段,可能的操作大多数是读取。

`在这个时候我们就用: FUNCTION: READ_TEXT。

CALL FUNCTION 'READ_TEXT'EXPORTINGCLIENT = SY-MANDTid = ATlanguage = DEname = 5300000035object = EINA* ARCHIVE_HANDLE = 0* LOCAL_CAT = ' '* IMPORTING* HEADER = HEADERtableslines = LINESEXCEPTIONSID = 1LANGUAGE = 2NAME = 3NOT_FOUND = 4OBJECT = 5REFERENCE_CHECK = 6WRONG_ACCESS_TO_ARCHIVE = 7OTHERS = 8.上面的几个传入的参数都是上面讲过的。

text函数的使用方法年月日

text函数的使用方法年月日

【主题】text函数的使用方法【内容】一、text函数的概述text函数是一种用于在编程中处理文本的函数。

它可以用于字符串的匹配、替换、连接等操作,是编程中常用的文本处理工具之一。

二、text函数的基本语法text函数的基本语法如下:text(文本内容, 参数1, 参数2, ...)其中,文本内容是需要进行处理的字符串,参数1、参数2等是用于指定具体操作的参数。

三、text函数的常用操作1. 字符串匹配text函数可以用于字符串的匹配操作。

可以使用它来查找某个字符串在文本内容中出现的位置,或者判断某个字符串是否包含在文本中等操作。

2. 字符串替换text函数还可以用于字符串的替换操作。

通过指定替换的规则和内容,可以实现对文本内容中特定字符串的替换操作。

3. 字符串连接text函数可以将多个字符串连接起来,形成一个新的字符串。

这对于需要动态生成字符串的场景非常有用。

4. 字符串分割text函数也可以用于字符串的分割操作。

通过指定分割的规则,可以将文本内容分割成多个部分,方便后续的处理。

四、text函数的示例代码下面是一些使用text函数的示例代码:1. 字符串匹配示例:text("Hello, world", "world") // 返回6,表示"world"在文本中的起始位置2. 字符串替换示例:text("Hello, name", "name", "John") // 返回"Hello, John",将"Hello, name"中的"name"替换为"John"3. 字符串连接示例:text("Hello, " + "world") // 返回"Hello, world",将"Hello, "和"world"连接起来形成新的字符串4. 字符串分割示例:text("apple,orange,banana", ",") // 返回["apple", "orange", "banana"],将文本内容按逗号分割成多个部分五、text函数的注意事项在使用text函数时,需要注意以下几点:1. 参数的顺序和类型需要符合要求,否则会导致函数执行出错。

abap 语法手册

abap 语法手册

abap 语法手册ABAP语法手册ABAP(Advanced Business Application Programming)是一种用于SAP软件开发的编程语言。

这份手册将介绍ABAP语言的基本语法和常用用法,为开发人员提供一个参考指南。

1. 数据类型和变量声明:ABAP支持多种数据类型,例如整数(INT),浮点数(FLOAT),字符串(STRING)和日期(DATE)。

变量声明可以通过关键字DATA进行,例如:DATA: my_integer TYPE i.DATA: my_string TYPE string.2. 控制结构:ABAP支持常见的控制结构,如条件语句(IF...ELSE...ENDIF)和循环语句(DO...ENDDO,WHILE...ENDWHILE)。

例如:IF my_integer > 10.WRITE: 'The value is greater than 10'.ELSE.WRITE: 'The value is less than or equal to 10'.ENDIF.3. 函数和方法:ABAP允许定义函数和方法来实现特定的功能。

函数可以通过关键字FUNCTION和ENDFUNCTION来定义,而方法可以通过关键字METHOD和ENDMETHOD来定义。

例如:FUNCTION my_function.WRITE: 'Hello, world!'.ENDFUNCTION.4. 数据表和内表:ABAP中的数据表可以通过关键字DATA和TABLE来声明,内表可以通过关键字INTERNAL TABLE和TYPES来声明。

例如:DATA: my_table TYPE TABLE OF my_structure.DATA: my_internal_table TYPE TABLE OF my_structure.5. 数据访问:ABAP提供了方便的数据访问方法,例如通过SELECT语句从数据库中检索数据,或者通过READ TABLE语句从内表中检索数据。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

ABAP:Function 之Read_Text函数的使用方法
在SAP系统中,有时候会有大段文本内容需要保存,例如:销售发货(VL03N),在单据的概览中,有一个[文本]项,在此处可以填写单据的大段文本描述,那么该内容保存在哪里呢?
第一反应是找对应表的字段,那么你可能要失望了。

在SAP系统中,可以供我们使用的数据库字段最大长度是255个文本字符(注:此处可能不正确),对于很长的文本肯定是不能直接保存到某个表的字段中的(注:至于具体保存在何处,还需要请教)。

因此我们要使用系统函数Read_Text来进行读取,以下是该函数的调用方法:
DATA: il_tline LIKE tline OCCURS 0 WITH HEADER LINE.
vl_tdname LIKE thead-tdname.
CALL FUNCTION 'READ_TEXT'
EXPORTING
client = sy-mandt
id = 'Z001'
language = '1'
name = vl_tdname
object = 'VBBK'
* ARCHIVE_HANDLE = 0
* LOCAL_CAT = ' '
* IMPORTING
* HEADER =
TABLES
lines = il_tline
EXCEPTIONS
id = 1
language = 2
name = 3
not_found = 4
object = 5
reference_check = 6
wrong_access_to_archive = 7
OTHERS = 8
.
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
在上面的示例代码中,红色字体部分是需要输入以及输出的参数,调用这个函数的关键就是在于如何找到各输入参数应该填写的内容,下面就以销售发货/外向交货(VL03N)为例,介绍读取[计划员备注]文本是如何查找对应参数的。

1、输入TCODE:VL03N,显示一个凭证
2、在[概览]的[文本]处,进入修改状态,输入相应的段落文字,双击文本内容。

3、进入文本内容行编辑器界面,点击菜单[转到]-->[表头]
4、见下图,上面的四行就是需要输入的参数,其中:
文本名:’011000218’,为凭证号,对应name参数
语言:ZH,但是此处参数类型为C(1),不能直接使用SY-LANGU变量,根据系统配置不同,在我的系统中使用1,对应language参数,
标识:Z001,该标识由SAP系统配置而来,对应ID参数
文本对象:VBBK,对应object参数
相对于Read_Text函数,有一个Save_Text正好是用来往系统中写文本字段,具体用户和Read_Text基本相似.。

相关文档
最新文档