在CMOD上写ABAP取长文本
2016-07-18 17:10
429 查看
HowTo extract Order long text
由 MartinGrob 于 2013-8-23 下午3:45 创建,由 Martin
Grob 于 2013-8-25 上午10:37 执行最后修改
版本
4
inShare
Tweet
Extracting Order number and Description
is pretty straight forward when you use the standard datasource 0COORDER_TEXT
provided by the content.
What
if you need to include the “long text” which sits behind the document icon?
For that we make use of the functionmodul
READ_TEXT in CMOD.
You have two options either you extend the standard datasource 0COORDER_ATTR
or opt for an additional datasource. In this
example we use ZBW_COORDER_ATTR as additional datasource.
Create the datasource ZBW_COORDER_ATTR which basically has only
AUFNR and TXTLG as fields.
Next we need a CMOD entry reading through READ_TEXT the desired additional
text. You can modify the code that it transfers the language code.
We only needed english and if it doesn't exist try german. In
the end we map it to our txtlg. Unfortunately you will be restricted to 60 CHAR.
Detail
on READ_TEXT
For Order
Description we need LTXT and
the Object AUFK.
CALL
FUNCTION 'READ_TEXT'
EXPORTING
CLIENT = '100'
ID = 'LTXT'
LANGUAGE = l_text_langu
NAME = l_object_name
OBJECT = 'AUFK'
In
the end we fill l_object_name with the order number.
1278c
( l_object_name = <fs_zbw_coorder_attr>-AUFNR.)
Submitting those parameters delivers you the "Additional TEXT"
Putting it all in CMOD:
-----------------------------------------------------------------------------------
WHEN 'ZBW_COORDER_ATTR'.
LOOP AT i_t_data ASSIGNING <fs_zbw_coorder_attr>.
** derive order description, max 560 chars, if LTEXT = X we
take always the first line only, the others are history
IF <fs_zbw_coorder_attr>-LTEXT = RS_C_TRUE.
* call function module to read the order text
CLEAR lt_text_lines.
l_text_langu = 'E'.
" English default
l_object_name = <fs_zbw_coorder_attr>-AUFNR.
DO 2 TIMES. "first
english, then german
CALL FUNCTION 'READ_TEXT'
EXPORTING
CLIENT = '100'
ID = 'LTXT'
LANGUAGE = l_text_langu
NAME = l_object_name
OBJECT = 'AUFK'
* IMPORTING
* HEADER = HTEXT
TABLES
LINES = lt_text_lines
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.
EXIT.
ENDIF.
l_text_langu = 'D'. "
set language to german for second try
ENDDO.
IF NOT lt_text_lines IS INITIAL.
READ TABLE lt_text_lines INTO lr_text_lines INDEX 1.
<fs_zbw_coorder_attr>-txtlg = lr_text_lines-TDLINE(60).
ENDIF.
ENDIF.
ENDCASE.
-----------------------------------------------------------------------------------
That's it map your datasource to 0coorder with
an additonal infoobject with holds the long text and you are done..
相关文章推荐
- 杭电 Problem 1715 大菲波数
- ARM9 mini2451裸机学习——UART驱动学习和整理
- c语言指针之排序两数大小
- 99乘法表
- 解决DevExpress控件在工具箱不显示的问题
- Linux(17)查看用户登陆历史的几个命令
- 【杭电oj】1222 - Wolf and Rabbit(GCD)
- android service
- 图像局部特征(十四)--MSER特征
- Another app is currently holding the yum lock; waiting for it to exit... 怎么解决
- 图像操作相关 With Quartz 2D
- jQuery实现滚动公告练习
- 我的日常学习计划与安排
- jedis学习笔记【1】
- springMVC本地实现动静分离
- LeetCode—375. Guess Number Higher or Lower II
- 远程连接linux数据库,连接不上,反馈慢,navicat报1065错误.
- 1k行代码的编辑器-kilo源码分析
- live555—VS2010/VS2013 下live555编译、使用及测试
- Fiddler中session的请求/响应类型与图标对照表