Idoc学习笔记----获取查询Idoc信息

来源:互联网 发布:火锅店收银软件 编辑:程序博客网 时间:2024/05/21 01:42
过年前写了一篇如何查询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 IDSTAMNO表示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中有STAPA1STAPA2STAPA3STAPA4这样4个filed,分别代表了Parameter 1Parameter 2Parameter 3Parameter 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.先补充如上。

1 0
原创粉丝点击