Idoc学习笔记----获取查询Idoc信息
2014-06-10 13:52
429 查看
过年前写了一篇如何查询idoc信息,在后面的学习实践中了解了下面一些知识点,记录如下:
一,通过IDOC_READ_COMPLETELY这个Function module可以获取idoc的数据信息。该function module以iodc number为参数返回一个 int_edidd的table。在该table中,每一个segment最为一行信息输出,segment下所有field的值都存储在sdata这一字段中,前面学习中提到可以根据每个segement下field的长度以及起始位置到sdata中获取相应的数据信息。其实还有一种更简单的方法:每一个segment对应了SE11中的一个Structure,而每个segment下的field同样也对应到了该Structure中;因此可以定义一个类型为segment的对象,然后将sdate直接赋值给该对象,最后通过该对象来获取field的数据。示例代码如下:
DATA: ZE1EDK01 LIKE E1EDK01.
if int_edidd-segnam = 'E1EDK01'.
ZE1EDK01 = int_edidd-sdata.
IT_output-BELNR = ZE1EDK01-BELNR. //fill the internal table with field data.
ENDIF.
二,如何获取Idoc的status信息。Idoc的Status信息存储在EDIDS这个Table中,可以根据idoc number获取所有该idoc下的status信息。在EDIDS这个表中存储了STAMID以及STAMNO这两列信息。其中STAMID表示Status
message ID,STAMNO表示Status message number,因此可以根据这两个条件到T100中获取相应的status message信息。值得注意的是,在根据STAMID以及STAMNO到T100中获取message信息时要先进行一下转换,代码如下(具体为什么还没有想清楚):
loop at int_edids. "根据idoc number到edids表中获取的所有记录
if int_edids-stacod ne space and int_edids-stamqu eq space.
int_edids-stamqu = int_edids-stacod(3).
int_edids-stamid = int_edids-stacod+3(2).
int_edids-stamno = int_edids-stacod+5(3).
modify int_edids.
endif.
endloop.
此外,在Message中可能存在&以及$这样的符号,这表示需要用其他值来替换。具体用什么值呢?在edids中有STAPA1、STAPA2、STAPA3、STAPA4这样4个filed,分别代表了Parameter
1、Parameter 2、Parameter 3、Parameter 4.可以将这些Parameter代替Message中的特殊符号。如下代码:
LOOP AT int_edids WHERE DOCNUM = int_edidc-DOCNUM AND STATUS = int_edidc-STATUS.
select single * from t100
where sprsl = sy-langu
and arbgb = int_edids-stamid
and msgnr = int_edids-stamno.
if sy-subrc ne 0.
clear buffer.
exit.
endif.
buffer = t100-text.
if t100-text ca '$1'.
replace '$1' with int_edids-stapa1 into buffer.
endif.
if t100-text ca '$2'.
replace '$2' with int_edids-stapa2 into buffer.
endif.
if t100-text ca '$3'.
replace '$3' with int_edids-stapa3 into buffer.
endif.
if t100-text ca '$4'.
replace '$4' with int_edids-stapa4 into buffer.
endif.
if t100-text ca '&1'.
replace '&1' with int_edids-stapa1 into buffer.
endif.
if t100-text ca '&2'.
replace '&2' with int_edids-stapa2 into buffer.
endif.
if t100-text ca '&3'.
replace '&3' with int_edids-stapa3 into buffer.
endif.
if t100-text ca '&4'.
replace '&4' with int_edids-stapa4 into buffer.
endif.
if t100-text ca '$'.
replace '$' with int_edids-stapa1 into buffer.
replace '$' with int_edids-stapa2 into buffer.
replace '$' with int_edids-stapa3 into buffer.
replace '$' with int_edids-stapa4 into buffer.
endif.
if t100-text ca '&'.
replace '&' with int_edids-stapa1 into buffer.
replace '&' with int_edids-stapa2 into buffer.
replace '&' with int_edids-stapa3 into buffer.
replace '&' with int_edids-stapa4 into buffer.
endif.
condense buffer.
IF int_edids-STATXT CA '&'.
REPLACE '&' WITH int_edids-stapa1 INTO buffer.
REPLACE '&' WITH int_edids-stapa2 INTO buffer.
REPLACE '&' WITH int_edids-stapa3 INTO buffer.
REPLACE '&' WITH int_edids-stapa4 INTO buffer.
CONDENSE buffer. "Condense 用于删除字符字段中多余的空格
ENDIF.
CONCATENATE IT_output-Message buffer INTO IT_output-Message.
ENDLOOP.
OK.先补充如上。
一,通过IDOC_READ_COMPLETELY这个Function module可以获取idoc的数据信息。该function module以iodc number为参数返回一个 int_edidd的table。在该table中,每一个segment最为一行信息输出,segment下所有field的值都存储在sdata这一字段中,前面学习中提到可以根据每个segement下field的长度以及起始位置到sdata中获取相应的数据信息。其实还有一种更简单的方法:每一个segment对应了SE11中的一个Structure,而每个segment下的field同样也对应到了该Structure中;因此可以定义一个类型为segment的对象,然后将sdate直接赋值给该对象,最后通过该对象来获取field的数据。示例代码如下:
DATA: ZE1EDK01 LIKE E1EDK01.
if int_edidd-segnam = 'E1EDK01'.
ZE1EDK01 = int_edidd-sdata.
IT_output-BELNR = ZE1EDK01-BELNR. //fill the internal table with field data.
ENDIF.
二,如何获取Idoc的status信息。Idoc的Status信息存储在EDIDS这个Table中,可以根据idoc number获取所有该idoc下的status信息。在EDIDS这个表中存储了STAMID以及STAMNO这两列信息。其中STAMID表示Status
message ID,STAMNO表示Status message number,因此可以根据这两个条件到T100中获取相应的status message信息。值得注意的是,在根据STAMID以及STAMNO到T100中获取message信息时要先进行一下转换,代码如下(具体为什么还没有想清楚):
loop at int_edids. "根据idoc number到edids表中获取的所有记录
if int_edids-stacod ne space and int_edids-stamqu eq space.
int_edids-stamqu = int_edids-stacod(3).
int_edids-stamid = int_edids-stacod+3(2).
int_edids-stamno = int_edids-stacod+5(3).
modify int_edids.
endif.
endloop.
此外,在Message中可能存在&以及$这样的符号,这表示需要用其他值来替换。具体用什么值呢?在edids中有STAPA1、STAPA2、STAPA3、STAPA4这样4个filed,分别代表了Parameter
1、Parameter 2、Parameter 3、Parameter 4.可以将这些Parameter代替Message中的特殊符号。如下代码:
LOOP AT int_edids WHERE DOCNUM = int_edidc-DOCNUM AND STATUS = int_edidc-STATUS.
select single * from t100
where sprsl = sy-langu
and arbgb = int_edids-stamid
and msgnr = int_edids-stamno.
if sy-subrc ne 0.
clear buffer.
exit.
endif.
buffer = t100-text.
if t100-text ca '$1'.
replace '$1' with int_edids-stapa1 into buffer.
endif.
if t100-text ca '$2'.
replace '$2' with int_edids-stapa2 into buffer.
endif.
if t100-text ca '$3'.
replace '$3' with int_edids-stapa3 into buffer.
endif.
if t100-text ca '$4'.
replace '$4' with int_edids-stapa4 into buffer.
endif.
if t100-text ca '&1'.
replace '&1' with int_edids-stapa1 into buffer.
endif.
if t100-text ca '&2'.
replace '&2' with int_edids-stapa2 into buffer.
endif.
if t100-text ca '&3'.
replace '&3' with int_edids-stapa3 into buffer.
endif.
if t100-text ca '&4'.
replace '&4' with int_edids-stapa4 into buffer.
endif.
if t100-text ca '$'.
replace '$' with int_edids-stapa1 into buffer.
replace '$' with int_edids-stapa2 into buffer.
replace '$' with int_edids-stapa3 into buffer.
replace '$' with int_edids-stapa4 into buffer.
endif.
if t100-text ca '&'.
replace '&' with int_edids-stapa1 into buffer.
replace '&' with int_edids-stapa2 into buffer.
replace '&' with int_edids-stapa3 into buffer.
replace '&' with int_edids-stapa4 into buffer.
endif.
condense buffer.
IF int_edids-STATXT CA '&'.
REPLACE '&' WITH int_edids-stapa1 INTO buffer.
REPLACE '&' WITH int_edids-stapa2 INTO buffer.
REPLACE '&' WITH int_edids-stapa3 INTO buffer.
REPLACE '&' WITH int_edids-stapa4 INTO buffer.
CONDENSE buffer. "Condense 用于删除字符字段中多余的空格
ENDIF.
CONCATENATE IT_output-Message buffer INTO IT_output-Message.
ENDLOOP.
OK.先补充如上。
相关文章推荐
- Idoc学习笔记----获取查询Idoc信息
- Idoc学习笔记----获取查询Idoc信息
- Idoc学习笔记----获取查询Idoc信息
- 学习笔记_Java get和post区别(转载_GET一般用于获取/查询资源信息,而POST一般用于更新资源信息)
- WinApi学习笔记-获取电脑中磁盘信息
- 【ext js 学习笔记】获取后台返回的自定义错误信息
- PHP学习笔记——目录,文件,磁盘信息获取
- linux学习笔记---putty乱码,查询软件包信息
- Android 学习笔记 短信备份 获取系统安装程序信息等等
- IOS学习笔记(十三)——获取手机信息(UIDevice、NSBundle、NSLocale)
- iOS学习笔记(十三)——获取手机信息(UIDevice、NSBundle、NSLocale)
- JPA学习笔记---JPA数据的操作:增加,删除,修改,获取,使用JPQL进行查询
- iOS学习笔记 获取手机信息(UIDevice、NSBundle、NSLocal)
- Ubuntu_查询计算机信息学习笔记
- j2me学习笔记【2】——利用Display类的isColor()方法获取设备是否支持彩色的信息
- opengl学习笔记(一)---获取opengl版本等信息
- java 数字证书信息的获取实例-java学习笔记(2)
- JavaScript学习笔记2:通过user-Agent获取浏览器和操作系统信息
- Windows安全机制学习笔记(三)--获取当前账户信息