Skip to Content

Hi ,

Thought of sharing the document creation of IDOC ( MBGMCR03 ) from Application server in case anyone needs this for their requirements:

Steps involved :

1) WE42 –> Create Inbound Process Code say “ZMATDOC”.

i) Assign FM “BAPI_IDOC_INPUT1” with ALE option as “ Processing with ALE service” and “ Processing by Function Module”

ii) Assign Standard Message type MBGMCR to Process Code.

iii) Assign Message Function as “MOD”

2) SM30 –> Maintain Entry in TBD52 for Process code ZMATDOC to a FM “ BAPI_IDOC_INPUT1” and Object type “BUS2017”.

3)  WE57 –> Assign FM to Message type and IDOC Type

                          BAPI_IDOC_INPUT1 +FM +MBGMCR03+MBGMCR+Inbound+Post goods movements with MB_CREATE_GOODS_MOVEMENT

4)  Maintain Partner profiles WE20 ( Client Dependent ) for LS XXXCLNT001 for Inbound Parameters Message type MBGMCR and assign Process Code ZMATDOC

5)  Create a custom program to read file from Application server  and append to GT_INPUT Internal table and here is the sample code for creation of IDOC .

   PERFORM upload_application_file.
*Create IDOC using File
  read table gt_input into gs_input INDEX 1.
  if sysubrc eq 0.
   else.
    exit.
  endif.
  if gt_input[] is not INITIAL.
    PERFORM create_idoc TABLES gt_input.
  endif.

   *Local data declaration
  data: l_wa_control_records type edidc,                    “#EC NEEDED
        l_i_control_records type standard table of edidc initial size 0,
        v_process_data TYPE TEDE2.

  clear: wa_edidc,
           v_process_data,
           gs_input.
  loop at gt_input into gs_input.
**Populate control data
    perform sub_pop_control_dat.
*
*Populate data record
    perform sub_poulate_data_record.
*
**Populate the master record in sequence as basic type /IRM/AGRMNTS01
*  perform sub_populate_i_edidd_seq.
    clear wa_edidcdocnum.
    CALL FUNCTION ‘IDOC_WRITE_AND_START_INBOUND’
      EXPORTING
        I_EDIDC                             = wa_edidc
       DO_COMMIT                           = ‘X’
     IMPORTING
       DOCNUM                              = wa_edidcDOCNUM
*   ERROR_BEFORE_CALL_APPLICATION       =
      TABLES
        I_EDIDD                             i_edidd
EXCEPTIONS
   IDOC_NOT_SAVED                      = 1
   OTHERS                              = 2
              .
    IF SYSUBRC <> 0.
      MESSAGE ID SYMSGID TYPE SYMSGTY NUMBER SYMSGNO
              WITH SYMSGV1 SYMSGV2 SYMSGV3 SYMSGV4.
    else.
      COMMIT WORK.
    ENDIF.

   FORM SUB_POP_CONTROL_DAT .

   * Fill Control Segment

  Data : LV_PORT(10) type c.

  CONCATENATE SYSYSID ‘CLNT’ SYMANDT into lv_port.
  CONDENSE lv_port NOGAPS.
  clear wa_edidc.
  wa_edidcmandt   = symandt.
  wa_edidcdocrel  = sysaprl.
  wa_edidcdirect  = ‘2’.
  wa_edidcrcvpor  = ‘ ‘.
  wa_edidcrcvprt  = ‘ ‘.
  wa_edidcrcvprn  = ‘ ‘.
  wa_edidctest    = ‘ ‘.
  wa_edidcsndpor  = lv_port. “‘XXXCLNT001’
  wa_edidcsndprt  = ‘LS’.
  wa_edidcSNDPFC  = ‘LS’.
  wa_edidcsndprn  = lv_port. “‘XXXCLNT001’
  wa_edidcmestyp  = ‘MBGMCR’.
  wa_edidcIDOCTP  = ‘MBGMCR03’. .
  wa_edidcmesfct  = ‘MOD’.
  wa_edidcRCVPRT  = ‘LS’.
  wa_edidcRCVPRN  = LV_PORT.

  wa_edidcRCVPRT = ‘LS’.

   ENDFORM.                    ” SUB_POP_CONTROL_DAT

   FORM SUB_POULATE_DATA_RECORD .
  clear wa_edidd.
  clear i_edidd.
  E1MBGMCRTESTRUN         = p_run.  ( Selection screen Check Box )
  wa_ediddmandt           = symandt.
  wa_ediddsegnam          = ‘E1MBGMCR’.
  wa_ediddsdata           = E1MBGMCR.
  APPEND wa_edidd          to i_edidd.

* Fill data segments
  clear stl_head.
  stl_headPSTNG_DATE      = sydatum.
  stl_headHEADER_TXT      = gs_inputBKTXT.
  stl_headDOC_DATE        = sydatum.
  wa_ediddmandt           = symandt.
  wa_ediddsegnam          = ‘E1BP2017_GM_HEAD_01’.

  wa_ediddsdata           = stl_head.
  APPEND wa_edidd          to i_edidd.

  clear stl_gmcode.
  stl_gmcodegm_code    = ’03’.
  wa_ediddmandt        symandt.
  wa_ediddsegnam       = ‘E1BP2017_GM_CODE’.
  wa_ediddsdata        stl_gmcode.
  APPEND wa_edidd       to i_edidd.

  clear stl_item.
  stl_itemMATERIAL     = gs_inputMATNR.
  stl_itemPLANT        = gs_input-WERKS.

  CALL FUNCTION ‘CONVERSION_EXIT_ALPHA_INPUT’
    EXPORTING
      INPUT  = gs_inputkostl
    IMPORTING
      OUTPUT = gs_inputkostl.

  stl_itemCOSTCENTER   = gs_inputkostl.
  stl_itemSTGE_LOC     = gs_inputLGORT.
  stl_itemBATCH        = gs_inputCHARG.
  stl_itemMOVE_TYPE    = gs_inputBWART.
  stl_itemENTRY_QNT    = gs_inputMENGE.
  wa_ediddmandt      symandt.
  wa_ediddsegnam     = ‘E1BP2017_GM_ITEM_CREATE’.“ZGM_ITEM’.
  wa_ediddsdata      stl_item.
  APPEND wa_edidd     to i_edidd.

ENDFORM.                    ” SUB_POULATE_DATA_RECORD


To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply