您的位置:首页 > 其它

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.先补充如上。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: