Create IDOC Based on an Event Being Triggered

I have a BOR object that when changed - triggers event 'Change'
I would like to code the event linkage such that an IDoc is created everytime the event is raised.
Has anyone done this before?
The message type I am using is a standard one and is associated with the same BOR object.
Which function module should I use in the event linkage for that 'change' event?
The IDoc doesnt have an outbound function module.
Please indicate steps or point me to related weblogs/threads
Thanks

hi!!!!!!!!!!!!!!
this is the sample code which may help u,
*BAsic type ZMARA
*Extension ZMARA
*Message type ZMatmas
REPORT  zi_material_idoc
        NO STANDARD PAGE HEADING
        MESSAGE-ID b1.
TABLES: z1maram, z1mara_desc, z1marcm.
                    TYPE DECLARATION
TYPES: BEGIN OF ty_data,
        matnr TYPE matnr,
        ernam TYPE ernam,
        ersda TYPE ersda,
        mtart TYPE mtart,
        mbrsh TYPE mbrsh,
        spras TYPE spras,
        maktx TYPE maktx,
        werks TYPE werks_d,
        lgort TYPE lgort_d,
       END OF ty_data.
DATA: w_data TYPE ty_data,
      w_edidd TYPE edidd,
      i_edidd TYPE STANDARD TABLE OF edidd,
      w_edidc TYPE edidc,
      i_edidc TYPE STANDARD TABLE OF edidc.
                     SELECTION SCREEN                               *
PARAMETERS: p_matnr TYPE matnr.
                   AT SELECTION SCREEN
*Validate Material
AT SELECTION-SCREEN ON p_matnr.
  PERFORM check_matnr.
                   START-OF-SELECTION
*Start of selection
START-OF-SELECTION.
  PERFORM get_data_from_selection.
                    END-OF-SELECTION
*End of selection
END-OF-SELECTION.
  IF NOT i_edidd IS INITIAL.
    PERFORM generate_idoc.
  ENDIF.
*&      Form  check_matnr
      text
FORM check_matnr .
  DATA l_matnr TYPE matnr.
  IF NOT p_matnr IS INITIAL.
    SELECT SINGLE matnr FROM mara INTO l_matnr
                        WHERE matnr = p_matnr.
    IF sy-subrc NE 0 OR l_matnr IS INITIAL.
      MESSAGE e000 WITH text-004.
    ENDIF.
  ENDIF.
ENDFORM.                    " check_matnr
*&      Form  get_data_from_selection
      text
FORM get_data_from_selection .
  SELECT SINGLE a~matnr
                a~ernam
                a~ersda
                a~mtart
                a~mbrsh
                b~spras
                b~maktx
                c~werks
                c~lgort
                INTO w_data
                FROM mara AS a
                INNER JOIN makt AS b
                ON amatnr = bmatnr
                INNER JOIN mard AS c
                ON amatnr = cmatnr
                WHERE a~matnr = p_matnr AND
                      b~spras = 'EN'.
  IF sy-subrc = 0.
    MOVE: w_data-matnr TO z1maram-matnr,
          w_data-ernam TO z1maram-ernam,
          w_data-ersda TO z1maram-ersda,
          w_data-mtart TO z1maram-mtart,
          w_data-mbrsh TO z1maram-mbrsh,
          w_data-spras TO z1mara_desc-spras,
          w_data-maktx TO z1mara_desc-maktx,
          w_data-werks TO z1marcm-werks,
          w_data-lgort TO z1marcm-lgort.
Populate Parent Segment
    w_edidd-segnam = 'Z1MARAM'.
    w_edidd-sdata = z1maram.
    APPEND w_edidd TO i_edidd.
    CLEAR w_edidd.
Populate Extn Segment
    w_edidd-segnam = 'Z1MARCM'.
    w_edidd-sdata = z1marcm.
    APPEND w_edidd TO i_edidd.
    CLEAR w_edidd.
Populate Child Segment
    w_edidd-segnam = 'Z1MARA_DESC'.
    w_edidd-sdata = z1mara_desc.
    APPEND w_edidd TO i_edidd.
    CLEAR w_edidd.
  ENDIF.
ENDFORM.                    " get_data_from_selection
*&      Form  generate_idoc
      text
FORM generate_idoc .
Populate Control Record
  w_edidc-direct = '1'.
  w_edidc-rcvpor = 'A000000021'.
  w_edidc-rcvprt = 'LS'.
  w_edidc-rcvprn = 'ZMATMAS'.
  w_edidc-sndprt = 'LS'.
  w_edidc-sndprn = 'LOG950R3'.
  w_edidc-mestyp = 'ZMATMAS'.
  w_edidc-idoctp = 'ZMARA'.
  w_edidc-cimtyp = 'ZMARA'.
Data Distribution
  CALL FUNCTION 'MASTER_IDOC_DISTRIBUTE'
    EXPORTING
      master_idoc_control            = w_edidc
    TABLES
      communication_idoc_control     = i_edidc
      master_idoc_data               = i_edidd
    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.
    CLEAR w_edidc.
    READ TABLE i_edidc INTO w_edidc INDEX 1.
    IF sy-subrc = 0.
      WRITE:/ w_edidc-docnum.
    ENDIF.
  ENDIF.
ENDFORM.                    " generate_idoc
this link may help u,
http://help.sap.com/saphelp_nw04/helpdata/en/0b/2a6702507d11d18ee90000e8366fc2/content.htm
reward if useful.

Similar Messages

  • Can xMII sense an event being triggered in SAP?

    Hi xMII Gurus,
    I have a requirement where, when some event is triggered in SAP, I have to fetch some data from SAP to xMII and do some procesing and post the data back to SAP. Is there any way by which xMII can sense the event being triggered in SAP?
    Thanks in advance,
    Prasanna

    Hi Prasanna,
    It can be done with a trick
    1. Create the  transaction in xMII
    2. Generate the webservice.
    3. Consume it in ERP
        a. from SE80 you have to consume
        b. From Lpconfig you have to create a port.
    4. Now after the event occured in ERP,Call the interface of the class you have created in SE80
    And it is done
    Thanks and regards,
    Pradip

  • Creating  idocs based on invoice number ocurrences

    Hi ,
    I want  to create idocs based on invoice numbers .
    Lets say i have a file coming in from sender system
    Invoice1 material customer value
    Invoice1 materail1 ..........
    imvoice2 material2.....
    invoice2 material1.....
    invoice1 material3..
    Invoice3. material4....
    So for Invoice1 only one Idoc should be created  similarly for invoice 2 which is ocurring twice in the file
    only 1 idoc  should be created
    Let me know how to achieve this ..  by UDF , or by split by value
    please help
    thnx
    Chirdip

    Hi,
      Change the IDOC occurance to 0-unbounded.Export the xsd change the occurance and import it to external definition.
    Map Like below:
    invoice number--removecontext--sort--splitbyvalue(valuechange)--IDOC
    other fields you need to map like below.
    invoice number--removecontext--sortbykey--SplibyValue(Each)---IDOC fields
    source field----removecontext------
    Regards,
    Prakasu.M

  • Events being triggered more than once

    HI All,
    I am using SAP Business One 2007 A SP:01 PL:07
    I have created a form using SAP Business One UI API Version 2007 A 8.0.When i open the form first time all item events and menu events are working properly..
    When i close the form and open it again all the menu and items events get fired twice.Again i close and reopen the form all Item and Menu events are triggered thrice on a single click.
    Any help to solve this problem will be highly appreciated.
    Warm Regards,
    Prerna

    Hello,
    Maybe You using a global variable for the form. Try to swicth to local variable and use sbo_application.form.GetForm(pval.formtypeex, pval.formtypeCount), or check you application really closes the window (window menü, and see the list of opened forms).
    Try to use EventSpy, which is a part of the SDN tools, you can download from /docs/DOC-8857#section6
    Regards,
    J

  • BAPI/FM to create idoc based from another(Just like WE19)...

    Hello Experts,
    Are there any BAPI to create a new idoc based on an existing one just like the functionality of WE19?
    Thank you guys!

    But looks like this function module is opening CO07 in SAPGUI...i actually need to call the function module from web application and create the add-on order. Please advise.
    Besides..i can pass the KTEXT value during the function module call itself right? can you pls tell me the reason why i need to force this in the enhancement spot?
    Regards,
    Kumar.
    Edited by: Kumar Kasavaraju on Aug 28, 2009 11:02 PM

  • Create Idocs based on Company Code change & Line Items less than 950

    Dear all,
    I am trying to create the Idocs based on the flat file in the following way.
    1) Create the Idoc per company code
    2) If company code exceeds 950 lines then create another Idoc
    I am trying to follow this BLOG and could not be able to achieve it because in the Blog explained with flat structure and my case is Idoc structure.
    /people/claus.wallacher/blog/2006/06/29/message-splitting-using-the-graphical-mapping-tool
    I changed the Idoc Occurrence and imported to External definition.
    I am able to do the both check individually but not able to put them in combining.
    Please advice..
    Regards

    Company Codes -> sort -> SplitbyVlaue(Valuechange) -> CollapseContexts -> remove contexts
    AND
    Contact(CompanyCodes, Lines) both in header context - removeContexts - SortbyKey(CompanyCodes) -
    formatbyExample(Company Codes -> sort -> SplitbyVlaue(Valuechange)) - count - greater(>950)
    Srikanth Srinivasan

  • Can I create an IDOC Based on A Change Event Being Triggered

    I have a BOR object that when changed - triggers event 'Change'
    I would like to code the event linkage such that an IDoc is created everytime the event is raised.
    Has anyone done this before?
    The message type I am using is a standard one and is associated with the same BOR object.
    Which function module should I use in the event linkage for that 'change' event?
    The IDoc doesnt have an outbound function module.
    Please indicate steps or point me to related weblogs/threads
    Thanks

    Hi Anand,
    What happens generally  is that -- Initiator are created on the basis on the main role. User submit the request for main roles and the dependent roles are added automatically. Dependent roles are added later automatically the initiator needs to be created on the main roles. So if initiator is created on the basis of dependent role ( secondary roles ) and you are not selecing the dependent role in the request ( selecting only the main roles ) the initiator's conditions will not meet.
    Kind Regards,
    Srinivasan

  • How to create Idoc based on NAST entries

    Hi Experts,
       I have a requeriement, on successful posting of receipt i  need to send an idoc ORDERS05 using objkey(PO number) of NAST table. How to proceed on this??
    Regards
    Sridevi S
    Edited by: Sridevi Sivanandam on Aug 1, 2010 4:25 PM

    hello,
    please see the segment for ORDERS05 from WE30 and after that you should have an idea what kind of data you need to pass.
    NAST-OBJKEY can contain PO number, article number based on the message / output type fired from GR...
    please have a close look at the data being entered in that field...
    after that you can relevant data from PO document for creating the IDOC.
    Thanks

  • OEM sending clear without event being triggered

    Hello,
    We have an event setup for checking the library cache hit%. The problem is even where there is no alert, it sends a alert cleared message.
    We have the event set up for about 10 databases, but it doesnt do the same with all of them ?
    When I go in the Event Log it says "Event test library cache hit% is cleared"
    Can anyone tell me please, why this is happening ?
    Thank you

    When you assign a function to be an event handler you don't use the parentheses:
    btn_advance.onPress = ScrollForward;
    Because using them means execute this function now. Of course you might actually have a function that returns a function in which case you would use them.

  • Multiple IDOCs based on multiple fields in File to IDOC mapping

    Hello Experts,
         I have a requirement to create multiple IDOCs based on multiple fields.
         Earlier my requirement is to create IDOCs based on ShipID (i.e., for every ShipID new IDOC...I achieved this).
         But now the requirement was to create IDOC based on two more fields like
    Source:
         ShipID1
         FieldA with value1 
         FieldB with value1
    Target :
         1 IDOC to create
    and If
    Source:
         ShipID1
         FiledA with Value2
         FiledB with Value2
         ShipID1
         FiledA with Value1
         FiledB with Value2
    Target:
         2 IDOCs based on FiledA
    Like wise IDOC should create for every change in FiledA and FieldB.
    If FiledA and FiledB has no changes then create IDOC based on ShipID
    please help me in achieving this as this is an urgent requirement.

    Hi Prasad -
    Just concat all the three fields - shipID1, FieldA and FieldB and
    remove contexts
    split by value (value changed)
    collapse contexts
    This way whenever there is a change in any of the above fields you'll have separate IDOC..

  • BTE 1030 - we use for AP documents, create an event that triggers a workflow

    Hello all,
    We use SAP's program RFBIBL00 to post AP documents.  We coded a function module that is called when BTE 1030 is reached.  Our FM creates an event that triggers a workflow.
    We are now doing some testing with an external vendor who is creating AP documents by doing an RFC  using function module BAPI_ACC_DOCUMENT_POST.
    It seems that this BTE, 1030, is not being triggered when the IDOC created by this function module posts the AP document.
    Has anybody else seen this issue and found a way to deal with it?
    Thanks
    Bruce

    AFAIK BAPI_ACC_DOCUMENT_POST and FI posting should trigger BTE 00001030 but BAPI_INCOMINGINVOICE_CREATE and AC interfacewould trigger BTE 00001050. (or is BAPI_ACC_DOCUMENT_POST also using AC interface, I will let you check it)
    Nevertheless call your FM triggered thru BTE 1030 also in a FM triggered thru BTE 1050. Also in the call check for update task
    function z_fi_00001050.
    call function 'TH_IN_UPDATE_TASK'
         importing
           in_update_task = in_update_task.
       if in_update_task eq 0 and i_xvbup eq 'X'.
         call function 'Z_FI_00001030' in update task
           exporting
             i_xvbup = ' '
           tables
             t_bkpf  = t_bkpf
             t_bseg  = t_bseg..
       else.
         call function 'Z_FI_00001030'
           exporting
             i_xvbup = ' '
           tables
             t_bkpf = t_bkpf
             t_bseg = t_bseg...
       endif.
    Regards,
    Raymond

  • Subtype event not triggering and supertype event triggers twice!!!!!!

    Hi,
    We have created a subtype for object bus2030 and also an event created for that. My workflow should trigger whenever an inquiry is created.
    I've maintained this as triggering event in SWDD and done type linkage is SWE2 and everything looks fine.
    When i simulate or create event the WF is triggered but when create inquiry in VA11 WF does not triggers.
    I've checked SWEL for event trace but no event is triggered at all... Am i missing something... I've done almost everything that i used to do...
    Even synchronized buffer!!! nothing paid me a solution...
    Infact the same was working with 3.1i system but after migration to ECC6 we had to create new WF template for the same Process.
    Now I also see that the supertype bus2030-created event is triggered twice but, obviously no receiver type exists. But the zbus2030 event is not being triggered at all!!!!
    Kindly help me understanding my mistake...
    Regards,
    PB

    Hope you have already set the deletegation in SWO6.
    Now, event dont get triggered automatically, jus because they are defined in object. They have to be explicitly published in thesystem.
    Check for a suitable user exit in your transaction, which makes use of function module to create the event, from that you know how to proceed.
    If you dont find user exit, try other triggering techniques such as change documents, logistics, BTEs... etc.
    regards,
    Sandeep Josyula

  • How to execute a mapping based on an event

    Hi
    I am on OWB 10.2.0.3. and Oracle 10.2.0.2. I have a mapping which is fine, deploys well, I can execute using the control manager.
    I also created a schedule module in OWB, created a schedule for a specific date and time and also an interval, configured the mapping to this schedule. The mapping gets executed successfully at the scheduled time.
    The requirement is this mapping needs to be executed by an external process (oracle but a different application in a different machine). The team owning this process is ready to insert a record in a table. Which I want to sense and execute this mapping.
    I already have created a procedure so that this mapping can also be run from pl/sql. I can create an after-insert trigger in this table so call this procedure, but that will make the whole think synchronous and the external process will have to wait for this mapping to complete to proceed further which is not acceptable by them.
    Is there a way I can check for the record in this table and exec the mapping from OWB?
    Can somebody please help and provide me pointers how I can schedule a mapping based on an event (insertion of the record) without (preferably) or with Oracle Workflow.
    Thanks a lot in advance!
    Maruthi

    Thanks Detlef,
    The problem I have is the trigger will make it actually synchronous with the process that inserts the record in the table.
    Even if I define the trigger as AUTONOMIUS_TRANSACTION, both the process will not parellel. setting this I can have commits and rollbacks in triggers but they will be synchronous. I want this mapping to run asynchronously so that the main process inserts the record and continues with the rest of the process while the mapping can be executed independently.
    For this reason I am looking for something which will allow me to do this without a trigger on the table.
    As mentioned in your refereed post, I can use CDC, but not sure how good is CDC and will this be an overkill to implement and use CDC for this purpose. Any simpler solution available?
    Any inputs please?
    Thanks once again!
    Regards,
    Maruthi

  • BACKGROUND  SCHEDULING  based on a event

    Hi,
        I need to execute my program in background ..  based on an event..for example.. here i want to execute   RBDMIDOC program  based on  when ever i change the master data ..
      i created a varient in SE38.. and i enetred into SM37  and  here  what i need to select .. for based on  an event..
    thanks
    Babu

    You can use worfklows to achieve this.
    For more infor check the faq in the Workflow forum, or ask your local workflow expert.
    basically you must first find out which event is triggered, you can find this out with the event trace (SWELS and SWEL) then you must create a workflowtemplate which is triggered by that event and which will schedule the backgournd job. Next you must link the event to the workflowtemplate, either in pftc , tab event, or transaction SWE2.
    ALternatively you can use transaction SWEINST to place a check function module on the event Business object instance. In that FM you can also schedule the job. This is a bit easier than creating a worklfow.
    Kind regards, Rob Dielemans

  • How to verify that an event is triggered

    Hi Experts,
    I am running a BW job that is based on an event (or basically a group of events using event collector). Some times, I need to debug it to find out why the job is not triggered and it is very difficult to find out which event was not there.
    Here is my quesiton:
    Is it possible to see, some where in the system, if an event is waiting for a job? or in other words, if an event has been fired?
    Also there is one other question, if an event is fired and this event is being collected by an event collector, can we see, some where, if event collector already got one event and only 2 more are left (suppose event collector need 3 events to fire the next level event that triggers a job).
    Thank you,
    Praveen

    Hi Sidhartha, Dinesh and Ravi,
    SM37 can give me only those jobs that have either finished, cancelled or waiting for an event. The question was to see those events that are not trigger from event collector, because one of the source event is not there.
    Here is one example EV3 is triggered by Event collector only if EV1 and EV2 are there. Suppose EV2 did not come, how do I know, if EV1 is there without executing any job?
    Thank you,
    Praveen
    Toronto

Maybe you are looking for