Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

inbound idoc details not geeting displayed in MIGO

Former Member
0 Kudos

HI EXPERTS,

I have to extract data from inbound idoc and it should be displayed in MIGO.I had written code for it in a function module.

-----------------------------------------------------------------------

my code

------------------------------------------------------------------

   FUNCTION Z_IDOC_INPUT_MBGMCR.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(INPUT_METHOD) LIKE  BDWFAP_PAR-INPUTMETHD
*"     REFERENCE(MASS_PROCESSING) LIKE  BDWFAP_PAR-MASS_PROC
*"  EXPORTING
*"     VALUE(WORKFLOW_RESULT) LIKE  BDWF_PARAM-RESULT
*"     VALUE(APPLICATION_VARIABLE) LIKE  BDWF_PARAM-APPL_VAR
*"     VALUE(IN_UPDATE_TASK) LIKE  BDWFAP_PAR-UPDATETASK
*"     VALUE(CALL_TRANSACTION_DONE) LIKE  BDWFAP_PAR-CALLTRANS
*"  TABLES
*"      IDOC_CONTRL STRUCTURE  EDIDC
*"      IDOC_DATA STRUCTURE  EDIDD
*"      IDOC_STATUS STRUCTURE  BDIDOCSTAT
*"      RETURN_VARIABLES STRUCTURE  BDWFRETVAR
*"      SERIALIZATION_INFO STRUCTURE  BDI_SER
*"  EXCEPTIONS
*"      WRONG_FUNCTION_CALLED
*"----------------------------------------------------------------------

 

Include File containing ALE constants
  INCLUDE MBDCONWF.

  TABLES : MKPF,MSEG.

  DATA : z_head type Z1BP2017_GM_HEAD_01,
         z_item type Z1BP2017_GM_ITEM_CREATE,
         z_serial type Z1BP2017_GM_SERIALNUMBER.
  DATA : wmkpf type mkpf,
        wmseg type mseg.




  WORKFLOW_RESULT = C_WF_RESULT_OK.

  LOOP AT IDOC_CONTRL.
    IF IDOC_CONTRL-MESTYP NE 'ZMBGMCR'.
      RAISE WRONG_FUNCTION_CALLED.
    ENDIF.

*  Before reading a new entry, clear application buffer
    LOOP AT IDOC_DATA WHERE DOCNUM EQ IDOC_CONTRL-DOCNUM.
      CASE IDOC_DATA-SEGNAM.
        WHEN 'Z1BP2017_GM_HEAD_01'.
          Z_HEAD = IDOC_DATA-SDATA.

          wmkpf-budat = z_head-pstng_date  .
          wmkpf-cpudt = z_head-doc_date    .
          wmkpf-frbnr = z_head-bill_of_lading .
          wmkpf-xabln = z_head-gr_gi_slip_no  .
          wmkpf-usnam = z_head-pr_uname       .
          wmkpf-bktxt = z_head-header_txt     .
          wmkpf-wever = z_head-ver_gr_gi_slip .
          wmkpf-mblnr = z_head-ref_doc_no_long+0(10).
          wmkpf-mjahr = z_head-ref_doc_no_long+10(4).

          wmseg-mblnr = z_head-ref_doc_no_long+0(10).
          wmseg-mjahr = z_head-ref_doc_no_long+10(4).
          wmseg-zeile = z_head-ref_doc_no_long+14(4).
*          INSERT INTO ZCUSTOMERS VALUES T_ZCUSTOMERS.


        WHEN 'Z1BP2017_GM_ITEM_CREATE'.
          Z_ITEM = IDOC_DATA-SDATA.

          wmseg-matnr = z_item-material.
          wmseg-werks = z_item-plant.
          wmseg-lgort = z_item-stge_loc.
          wmseg-charg = z_item-batch.
          wmseg-bwart = z_item-move_type.
          wmseg-INSMK = z_item-stck_type.
          wmseg-lifnr = z_item-vendor.
          wmseg-erfmg = z_item-entry_qnt.
          wmseg-erfme = z_item-entry_uom.
          wmseg-bpmng = z_item-po_pr_qnt.
          wmseg-bprme = z_item-orderpr_un.
          wmseg-ebeln = z_item-po_number.
          wmseg-ebelp = z_item-po_item.
          wmseg-kzbew = z_item-mvt_ind.
          wmseg-prctr  = z_item-profit_ctr.
*          wmseg-  = z_item-comm_ref_num.
*          wmseg-  = z_item-qty_sn.

*          INSERT INTO ZSOHEADERS VALUES T_ZSOHEADERS.
        WHEN 'Z1BP2017_GM_SERIALNUMBER'.
          Z_SERIAL = IDOC_DATA-SDATA.
*          MOVE-CORRESPONDING W_ZRZSEG3 TO T_ZSOITEMS.
*          INSERT INTO ZSOITEMS VALUES T_ZSOITEMS.
      ENDCASE.
    ENDLOOP.
*

    SELECT *
    FROM mkpf where mblnr = wmkpf-mblnr.
    ENDSELECT.
    IF sy-subrc NE 0.
      INSERT INTO MKPF VALUES WMKPF.
    ELSE.
      UPDATE MKPF FROM WMKPF.
    ENDIF.

      IF SY-SUBRC EQ 0.
        IDOC_STATUS-DOCNUM = IDOC_CONTRL-DOCNUM.
        IDOC_STATUS-STATUS = '53'.
        IDOC_STATUS-MSGTY = 'I'.
        IDOC_STATUS-MSGID = 'YM'.
        IDOC_STATUS-MSGNO = '004'.
*      IDOC_STATUS-MSGV1 = T_ZCUSTOMERS-KUNNR.
        APPEND IDOC_STATUS.
        CLEAR IDOC_STATUS.
      ELSE.
        IDOC_STATUS-DOCNUM = IDOC_CONTRL-DOCNUM.
        IDOC_STATUS-STATUS = '51'.
        IDOC_STATUS-MSGTY = 'E'.
        IDOC_STATUS-MSGID = 'YM'.
        IDOC_STATUS-MSGNO = '005'.
*      IDOC_STATUS-MSGV1 = T_ZCUSTOMERS-KUNNR.
        APPEND IDOC_STATUS.
        CLEAR IDOC_STATUS.
        WORKFLOW_RESULT = C_WF_RESULT_ERROR.
        RETURN_VARIABLES-WF_PARAM = 'Error_Idocs'.
        RETURN_VARIABLES-DOC_NUMBER = IDOC_CONTRL-DOCNUM.
        APPEND RETURN_VARIABLES.
        CLEAR RETURN_VARIABLES.
      ENDIF.

*
    SELECT SINGLE *
    FROM mseg WHERE mblnr = wmseg-mblnr.

    IF sy-subrc NE 0.
      INSERT INTO MSEG VALUES WMSEG.
    ELSE.
      UPDATE MSEG FROM WMSEG.
    ENDIF.
    IF SY-SUBRC EQ 0.
      IDOC_STATUS-DOCNUM = IDOC_CONTRL-DOCNUM.
      IDOC_STATUS-STATUS = '53'.
      IDOC_STATUS-MSGTY = 'I'.
      IDOC_STATUS-MSGID = 'YM'.
      IDOC_STATUS-MSGNO = '004'.
*      IDOC_STATUS-MSGV1 = T_ZSOHEADERS-VBELN.
      APPEND IDOC_STATUS.
      CLEAR IDOC_STATUS.
    ELSE.
      IDOC_STATUS-DOCNUM = IDOC_CONTRL-DOCNUM.
      IDOC_STATUS-STATUS = '51'.
      IDOC_STATUS-MSGTY = 'E'.
      IDOC_STATUS-MSGID = 'YM'.
      IDOC_STATUS-MSGNO = '005'.
*      IDOC_STATUS-MSGV1 = T_ZSOHEADERS-VBELN.
      APPEND IDOC_STATUS.
      CLEAR IDOC_STATUS.
      WORKFLOW_RESULT = C_WF_RESULT_ERROR.
      RETURN_VARIABLES-WF_PARAM = 'Error_Idocs'.
      RETURN_VARIABLES-DOC_NUMBER = IDOC_CONTRL-DOCNUM.
      APPEND RETURN_VARIABLES.
      CLEAR RETURN_VARIABLES.
    ENDIF.

thanks,

charu

  

5 REPLIES 5

former_member209722
Participant
0 Kudos

Hi ,

First why r u updating standrd tables MKPF & MSEG directly...That is not at all correct & suggestable.

Always try to use BAPI or BDC to update Standrad tables

Thanks,

Chandra

0 Kudos

hi, i no more need to update data... also i'll use bapi or bdc to update database in future

Former Member
0 Kudos

Are you sure you really just want to display the data in MIGO? Do you not want to post a document into SAP using the data on the IDOC?

Either way, direct updates of standard SAP tables are wrong. This shows a lack of understanding of what you are doing and can have serious consequences for the system. I would suggest you ask someone with better knowledge in your team to handle this work or help you with it, before you get into serious issues.

In the meantime, try reading more ABAP learning materials and content here on SCN.

Gareth.

0 Kudos

hi gareth, please tell me if i need to insert an entry to database...which FM am i supposed to use.

thanks in advance

0 Kudos

Charu,

I would suggest you try searching the forums for other information on MIGO and BAPI, or maybe the document you are trying to post (goods movement or similar?)  Not surprisingly, you aren't the first person to need to do something like this so I'm sure you will find lots of examples.

Just please don't write code that updates standard SAP tables.

Gareth.