此博客为原创博客,都是个人工作经历所得,转载请注明出处

创建IDOC

 

第一步:WE31 创建IDOC所包含的字段.
第二步:WE30 创建IDOC 把Segment分配给IDOC
第三步:WE81 创建信息类型
第四步:WE82 把IDOC类型与信息类型对应.
第五步:WE57 Assign Message & Idoc Type to a Function Module for Data Process
第六步:SM59 Define a RFC connection for Idoc transfer
第七步:WE21 Define a Port ( Assign a RFC destination which created in SM59 )
第八步:WE41/42 Creat Process Code
第九步:WE20 Define a Partner Profiles( Also creat a Outbound parameters with Port, or Inbound
parameters with Process code )
管理IDOC:
WE02 显示IDOC,可以根据时间,IDOC类型查找IDOC,查看成功,出错信息。
WE46 IDOC管理(出\入)
WE60 IDOC类型文档(可以查看IDOC结构,和每个字段的描述.
WE19 根据IDOC号进行IDOC处理,可以修改IDOC值进行补发动作,处理分为内向和外向。
消息配置:
WE20 配置伙伴消息进和出IDOC类型
WE21 配置伙伴

*&---------------------------------------------------------------------*
*& Report YCX_IDOC
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT YCX_IDOC.

DATA: G_IDOC_CTL LIKE EDIDC,
      G_E1MARAM LIKE E1MARAM,
      G_E1MAKTM LIKE E1MAKTM.
DATA: GI_RET_CTL LIKE EDIDC OCCURS 0,
      GI_IDOC_DATA LIKE EDIDD OCCURS 0 WITH HEADER LINE.

* BUILD IDOC_CTL RECORD
  PERFORM BUILD_IDOC_CTL.

* BUILD ICOC_SEGMENT DATA
  PERFORM BUILD_IDOC_SEG.

* CALL FUNCTION AND CREATE IDOC
  PERFORM CREATE_IDOC.

*&---------------------------------------------------*
*&      Form  CREATE_IDOC
*&---------------------------------------------------*
*       text
*----------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------*
FORM CREATE_IDOC.

  CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
    EXPORTING
      MASTER_IDOC_CONTROL                  = G_IDOC_CTL
*     OBJ_TYPE                             = ''
*     CHNUM                                = ''
    TABLES
      COMMUNICATION_IDOC_CONTROL           = GI_RET_CTL
      MASTER_IDOC_DATA                     = GI_IDOC_DATA
*   EXCEPTIONS
*     ERROR_IN_IDOC_CONTROL                = 1
*     ERROR_WRITING_IDOC_STATUS            = 2
*     ERROR_IN_IDOC_DATA                   = 3
*     SENDING_LOGICAL_SYSTEM_UNKNOWN       = 4
*     OTHERS                               = 5
            .
  IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ELSE.
    COMMIT WORK.
  ENDIF.
ENDFORM.                    " CREATE_IDOC

*&---------------------------------------------------*
*&      Form  BUILD_IDOC_CTL
*&--------------------------------------------------*
*       text
*----------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------*
FORM BUILD_IDOC_CTL.

* TYPE
  G_IDOC_CTL-IDOCTP = 'ZMMIDOC'.    "IDOC TYPE
  G_IDOC_CTL-MESTYP = 'ZMMCRT'.      "MESSAGE TYPE

* RECEIVER
  G_IDOC_CTL-RCVPRT = 'LS'.          "PARTNER TYPE
  G_IDOC_CTL-RCVPRN = 'MMRECV800'.   "PARTNER NO

* SENDER
  G_IDOC_CTL-SNDPRT = 'LS'.          "PARTNER TYPE
  G_IDOC_CTL-SNDPRN = 'T90CLNT090'.  "PARTNER NO
  G_IDOC_CTL-SNDPOR = 'SAPC11'.      "PORT
ENDFORM.                    " BUILD_IDOC_CTL

*&---------------------------------------------------*
*&      Form  BUILD_IDOC_SEG
*&---------------------------------------------------*
*       text
*----------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------*
FORM BUILD_IDOC_SEG.

* HEAD DATA
  GI_IDOC_DATA-SEGNAM = 'E1MARAM'. "SEGMENT NAME
  GI_IDOC_DATA-SEGNUM = 1.         "SEGMENT NO

  G_E1MARAM-MATNR = 'IDOCTEST15'.   "MM NO
  G_E1MARAM-MEINS = '10'.          "BASE UOM
  G_E1MARAM-MBRSH = 'M'.           "INDUSTRY
  G_E1MARAM-MTART = 'DIEN'.        "MM TYPE

  MOVE G_E1MARAM TO GI_IDOC_DATA-SDATA.
  APPEND GI_IDOC_DATA.

* DESCRIPTION
  GI_IDOC_DATA-SEGNAM = 'E1MAKTM'. "SEGMENT NAME
  GI_IDOC_DATA-SEGNUM = 2.         "SEGMENT NO

  G_E1MAKTM-SPRAS = SY-LANGU.      "LANGUAGE
  G_E1MAKTM-MAKTX = 'IDOC TEST'.   "DESCRIPTION

  MOVE G_E1MAKTM TO GI_IDOC_DATA-SDATA.
  APPEND GI_IDOC_DATA.
ENDFORM.                    " BUILD_IDOC_SEG

 

posted @ 2019-09-22 10:17  Rainystuday  阅读(196)  评论(0编辑  收藏  举报