0% found this document useful (0 votes)
320 views

Create IDOC Using Application Server

The document describes the steps to create an IDOC (MBGMCR03) from an Application Server file in SAP. The steps include: 1) Creating an inbound process code (ZMATDOC) and assigning it a function module, message type, and message function. 2) Maintaining an entry in table TBD52 to link the process code to the function module. 3) Assigning the function module to the message type and IDOC type. 4) Maintaining partner profiles for the client to define inbound parameters. 5) Creating a program to read the file, populate internal tables for the IDOC segments, and call the function module to write and start the inbound IDOC.

Uploaded by

SOUMEN DAS
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
320 views

Create IDOC Using Application Server

The document describes the steps to create an IDOC (MBGMCR03) from an Application Server file in SAP. The steps include: 1) Creating an inbound process code (ZMATDOC) and assigning it a function module, message type, and message function. 2) Maintaining an entry in table TBD52 to link the process code to the function module. 3) Assigning the function module to the message type and IDOC type. 4) Maintaining partner profiles for the client to define inbound parameters. 5) Creating a program to read the file, populate internal tables for the IDOC segments, and call the function module to write and start the inbound IDOC.

Uploaded by

SOUMEN DAS
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Create IDOC using Application Server file

hought 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 sy–subrc 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_edidc–docnum.
    CALL FUNCTION ‘IDOC_WRITE_AND_START_INBOUND’
      EXPORTING
        I_EDIDC                             = wa_edidc
       DO_COMMIT                           = ‘X’
     IMPORTING
       DOCNUM                              = wa_edidc–DOCNUM
*   ERROR_BEFORE_CALL_APPLICATION       =
      TABLES
        I_EDIDD                             =  i_edidd
EXCEPTIONS
   IDOC_NOT_SAVED                      = 1
   OTHERS                              = 2
              .
    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.
   FORM SUB_POP_CONTROL_DAT .
   * Fill Control Segment
  Data : LV_PORT(10) type c.
  CONCATENATE SY–SYSID ‘CLNT’ SY–MANDT into lv_port.
  CONDENSE lv_port NO–GAPS.
  clear wa_edidc.
  wa_edidc–mandt   = sy–mandt.
  wa_edidc–docrel  = sy–saprl.
  wa_edidc–direct  = ‘2’.
  wa_edidc–rcvpor  = ‘ ‘.
  wa_edidc–rcvprt  = ‘ ‘.
  wa_edidc–rcvprn  = ‘ ‘.
  wa_edidc–test    = ‘ ‘.
  wa_edidc–sndpor  = lv_port. “‘XXXCLNT001’
  wa_edidc–sndprt  = ‘LS’.
  wa_edidc–SNDPFC  = ‘LS’.
  wa_edidc–sndprn  = lv_port. “‘XXXCLNT001’
  wa_edidc–mestyp  = ‘MBGMCR’.
  wa_edidc–IDOCTP  = ‘MBGMCR03’. .
  wa_edidc–mesfct  = ‘MOD’.
  wa_edidc–RCVPRT  = ‘LS’.
  wa_edidc–RCVPRN  = LV_PORT.
  wa_edidc–RCVPRT = ‘LS’.
   ENDFORM.                    ” SUB_POP_CONTROL_DAT
   FORM SUB_POULATE_DATA_RECORD .
  clear wa_edidd.
  clear i_edidd.
  E1MBGMCR–TESTRUN         = p_run.  ( Selection screen Check Box )
  wa_edidd–mandt           = sy–mandt.
  wa_edidd–segnam          = ‘E1MBGMCR’.
  wa_edidd–sdata           = E1MBGMCR.
  APPEND wa_edidd          to i_edidd.
* Fill data segments
  clear stl_head.
  stl_head–PSTNG_DATE      = sy–datum.
  stl_head–HEADER_TXT      = gs_input–BKTXT.
  stl_head–DOC_DATE        = sy–datum.
  wa_edidd–mandt           = sy–mandt.
  wa_edidd–segnam          = ‘E1BP2017_GM_HEAD_01’.
  wa_edidd–sdata           = stl_head.
  APPEND wa_edidd          to i_edidd.
  clear stl_gmcode.
  stl_gmcode–gm_code    = ’03’.
  wa_edidd–mandt        =  sy–mandt.
  wa_edidd–segnam       = ‘E1BP2017_GM_CODE’.
  wa_edidd–sdata        =  stl_gmcode.
  APPEND wa_edidd       to i_edidd.
  clear stl_item.
  stl_item–MATERIAL     = gs_input–MATNR.
  stl_item–PLANT        = gs_input-WERKS.
  CALL FUNCTION ‘CONVERSION_EXIT_ALPHA_INPUT’
    EXPORTING
      INPUT  = gs_input–kostl
    IMPORTING
      OUTPUT = gs_input–kostl.
  stl_item–COSTCENTER   = gs_input–kostl.
  stl_item–STGE_LOC     = gs_input–LGORT.
  stl_item–BATCH        = gs_input–CHARG.
  stl_item–MOVE_TYPE    = gs_input–BWART.
  stl_item–ENTRY_QNT    = gs_input–MENGE.
  wa_edidd–mandt      =  sy–mandt.
  wa_edidd–segnam     = ‘E1BP2017_GM_ITEM_CREATE’.“ZGM_ITEM’.
  wa_edidd–sdata      =  stl_item.
  APPEND wa_edidd     to i_edidd.
ENDFORM.                    ” SUB_POULATE_DATA_RECORD

You might also like