Skip to Content
avatar image
Former Member

Inbound Custom IDoc Processing

Hi,

I've created an Inbound Custom IDoc, Created the ABAP function module to post it to the application, configured workflow and IDoc processing. All my setup appears fine as I can create IDocs from our AS400 subsystem and trigger a successful posting via the IDoc test tool.

Having got this working I now want to automate the posting.

At present I create the IDoc's on our Legacy AS400 System and FTP them onto the SAP Application Server which runs on a Windows 2003 platform.

How do I get SAP to process each of my waiting Idoc's?

Any examples appreciated....

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    Jun 22, 2006 at 02:35 PM

    Hi Simon,

    Welcome to SDN.

    I never work with SAP for Window 2003.

    But you can try the following.

    If your IDoc is a flat file then you can run the standard

    program <b>RSEINB00</b> to upload the IDoc file and generate the IDoc.

    If you setup the partner profile to be processed by background job, then you can run standard program <b>RBDAPP01</b> to post to the application. Otherwise, the IDoc will be automatically posted. You can go to transaction <b>WE02</b> to check the IDoc status.

    At the end, you can schedule SAP job to automate the above process.

    Hope this will help.

    Regards,

    Ferry Lianto

    Please reward points if helpful as a way to say thanks.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 22, 2006 at 02:01 PM

    Hi

    For CUSTOM IDOC inbound processing

    Firstly attach your idoc to a process code.

    In the process cod you can tell the system that the specified program should be triggered whenever an idoc of that type comes to the system.

    Then you want to have a Z-function module for your idoc processing, if I understand correctly.The steps should be:

    1. Create a z function module for idoc inbound posting (copy from a function module idoc_input_*).

    2. Set Function Modules as Inbound: - Transaction BD51

    3. Assign Function Modules to Logical Messages and Idoc types:- Transaction WE57

    4. Create process codes : Transaction WE42, and link the z-function module.

    5. Create partner profile: transaction WE20 and attach the message type and process code.

    6. In the Z- function module, extract data from the idoc segments, do whatever processing you want to do, and then call BAPI_CREATE_SALES_ORDER_FROMDAT2.

    Check out this sample Function Module on the inbound system

    -


    FUNCTION Z_IDOC_INPUT_EMPREP.

    *"----


    ""Local interface:

    *" IMPORTING

    *" VALUE(INPUT_METHOD) LIKE BDWFAP_PAR-INPUTMETHD

    *" VALUE(MASS_PROCESSING) LIKE BDWFAP_PAR-MASS_PROC

    *" EXPORTING

    *" VALUE(WORKFLOW_RESULT) LIKE BDWFAP_PAR-RESULT

    *" VALUE(APPLICATION_VARIABLE) LIKE BDWFAP_PAR-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

    *"----


    ----


    • Database Tables

    ----


    TABLES: ZAK_EMPLIST.

    ----


    • Include programs

    ----


    INCLUDE MBDCONWF.

    ----


    • Data Declarations

    ----


    *--- Employee Header -IDOC

    DATA: FS_EMPHDR_DATA LIKE Z1R_SEG1.

    *--- Employee Details -IDOC

    DATA: FS_EMPDET_DATA LIKE Z1R_SEG2.

    *--- Employee Header - application data

    DATA: FS_APP_EMPHDR LIKE ZAK_EMPLIST.

    *--- Employee Details - application data

    DATA: FS_APP_EMPDET LIKE ZAK_EMPLIST.

    ----


    • Program Logic

    ----


    *---Initialize Work Flow Result

    WORKFLOW_RESULT = C_WF_RESULT_OK.

    LOOP AT IDOC_CONTRL.

    *--- Check whether the correct message was passed to us

    IF IDOC_CONTRL-MESTYP NE 'ZR_MSG'.

    RAISE WRONG_FUNCTION_CALLED.

    ENDIF.

    *--- Clear application buffers before reading a new record

    CLEAR FS_APP_EMPDET.

    CLEAR FS_APP_EMPHDR.

    • REFRESH FS_APP_EMPDET.

    • REFRESH FS_APP_EMPDET.

    *--- Process all records and pass them on to application buffers

    LOOP AT IDOC_DATA WHERE DOCNUM EQ IDOC_CONTRL-DOCNUM.

    CASE IDOC_DATA-SEGNAM.

    WHEN 'Z1R_SEG1'. " Employee Header

    FS_EMPHDR_DATA = IDOC_DATA-SDATA.

    MOVE-CORRESPONDING FS_EMPHDR_DATA TO FS_APP_EMPHDR.

    WHEN 'Z1R_SEG2'. " Employee Details

    FS_EMPDET_DATA = IDOC_DATA-SDATA.

    MOVE-CORRESPONDING FS_EMPDET_DATA TO FS_APP_EMPDET.

    ENDCASE.

    ENDLOOP.

    *--- If data is ok

    SELECT * FROM ZAK_EMPLIST WHERE ENUMBER = FS_APP_EMPHDR.

    IF SY-SUBRC NE 0.

    INSERT INTO ZAK_EMPLIST VALUES FS_APP_EMPHDR.

    INSERT INTO ZAK_EMPLIST VALUES FS_APP_EMPDET.

    ELSE.

    UPDATE ZAK_EMPLIST FROM FS_APP_EMPHDR.

    UPDATE ZAK_EMPLIST FROM FS_APP_EMPDET.

    ENDIF.

    ENDSELECT.

    IF SY-SUBRC EQ 0.

    *--- Populate Return variables for success

    RETURN_VARIABLES-WF_PARAM = 'Processed_IDOCs'.

    RETURN_VARIABLES-DOC_NUMBER = IDOC_CONTRL-DOCNUM.

    RETURN_VARIABLES-WF_PARAM = 'Appl_Objects'.

    RETURN_VARIABLES-DOC_NUMBER = FS_APP_EMPHDR-ENUMBER.

    APPEND RETURN_VARIABLES.

    *--- Add Status Reocrds indicating success

    IDOC_STATUS-DOCNUM = IDOC_CONTRL-DOCNUM.

    IDOC_STATUS-STATUS = '53'.

    IDOC_STATUS-MSGTY = 'I'.

    IDOC_STATUS-MSGID = 'ZE'.

    IDOC_STATUS-MSGNO = '006'.

    IDOC_STATUS-MSGV1 = FS_APP_EMPHDR-ENUMBER.

    APPEND IDOC_STATUS.

    ELSE.

    WORKFLOW_RESULT = C_WF_RESULT_ERROR.

    RETURN_VARIABLES-WF_PARAM = 'Error IDOCs'.

    RETURN_VARIABLES-DOC_NUMBER = IDOC_CONTRL-DOCNUM.

    APPEND RETURN_VARIABLES.

    *--- Add status record indicating failure in updating

    IDOC_STATUS-DOCNUM = IDOC_CONTRL-DOCNUM.

    IDOC_STATUS-STATUS = '51'.

    IDOC_STATUS-MSGTY = 'E'.

    IDOC_STATUS-MSGID = 'ZE'.

    IDOC_STATUS-MSGNO = '007'.

    IDOC_STATUS-MSGV1 = FS_APP_EMPHDR-ENUMBER.

    APPEND IDOC_STATUS.

    ENDIF.

    ENDLOOP.

    ENDFUNCTION.

    -


    Good Luck and reward me for the same

    Thanks

    Ashok

    Add comment
    10|10000 characters needed characters exceeded