IDoc Outbound Triggers - EDI and ALE ... printer to IDoc/EDI or ALE. ISBN 3528 05 ... IDoc Outbound Triggers Sending IDocs Via RSNASTED 57 Chap 9

  • View
    239

  • Download
    9

Embed Size (px)

Text of IDoc Outbound Triggers - EDI and ALE ... printer to IDoc/EDI or ALE. ISBN 3528 05 ... IDoc...

  • ISBN

    3528

    0572

    97 ht

    tp://id

    ocs.d

    e

    F o r e xa mp l e s a n d u p d a t e s c h e c k o u t h t t p : / / i d o c s . d e

    519

    IDoc Outbound Triggers

    IDocs should be sent out at certain events. Therefore youhave to define a trigger. A lot of consideration is required todetermine the correct moment when to send out the IDoc.The IDoc can be triggered at a certain time or when anevent is raised. R/3 uses several completely differentmethods to determine the trigger point. There aremessages to tell the system that there is an IDoc waiting fordispatching, there are log files which may be evaluated tosee if IDocs are due to send and there can be a workflowchain triggered, which includes the sending of the IDoc.

    htt

  • ISBN

    3528

    0572

    97 ht

    tp://id

    ocs.d

    e

    1999,2000 Axel Angeli et al. - SAP R/3 Guide to EDI http://idocs.de cook.doc Total pages 177; Printed: 2000-Mar-26-23:16; Page

    52 Individual ABAP IDoc Outbound TriggersChap 9

    9.1 Individual ABAP

    The simplest way to create IDocs, is to write an ABAP which simply does it.

    The individual ABAP can either be a triggering ABAPwhich runs at certain events, e.g. every night, or itcan be an ABAP which does the complete IDoccreation from scratch.

    Triggering ABAP A triggering ABAP would simply try to determinewhich IDocs need sending and call the appropriateIDoc creation routines.

    ABAP creates the whole IDoc You may also imagine the ABAP to do all the job. Asthis is mostly reinventing the wheel, it is not reallyrecommended and should be reserved to situation,where the other solution do not provide anappropriate mean.

    1999,2000 Axel Angeli et al. - SAP R/3 Guide to EDI http://idocs.de cook.doc Total pages 177; Printed: 2000-Mar-26-23:16; Page

    IDoc Outbound Triggers Individual ABAP 53Chap 9

    http:/

    /idoc

    s.de

    Illustration 9: General Process logic of IDoc outbound

  • ISBN

    3528

    0572

    97 ht

    tp://id

    ocs.d

    e

    1999,2000 Axel Angeli et al. - SAP R/3 Guide to EDI http://idocs.de cook.doc Total pages 177; Printed: 2000-Mar-26-23:16; Page

    54 NAST Messages Based Outbound IDocs IDoc Outbound TriggersChap 9

    9.2 NAST Messages Based Outbound IDocs

    You can use the R/3 message concept to trigger IDocs the same way asyou trigger SapScript printing.

    One of the key tables in R/3 is the table NAST. This tablerecords reminders written by applications. Those remindersare called messages.

    Applications writemessages to NAST,which will beprocessed by amessage handler

    Every time when an applications sees the necessity to passinformation to a third party. a message is written to NAST. Amessage handler will eventually check the entries in thetable and cause an appropriate action.

    EDI uses the samemechanism as printing

    The concept of NAST messages has originally been designedfor triggering SapScript printing. The very same mechanism isused for IDocs, where the IDoc processor replaces the printtask, as an IDoc is only the paperless form of a printeddocument.

    Condition techniquecan mostly be used

    The messages are usually be created using the conditiontechnique, a mechanism available to all major R/3applications.

    Printing, EDI and ALEuse the same trigger

    The conditions are set up the same way for any outputmedia. So you may define a condition for printing adocument and then just change the output media fromprinter to IDoc/EDI or ALE.

    ISBN

    3528

    05Illustration 10: Communicating with message via table NAST

    1999,2000 Axel Angeli et al. - SAP R/3 Guide to EDI http://idocs.de cook.doc Total pages 177; Printed: 2000-Mar-26-23:16; Page

    IDoc Outbound Triggers NAST Messages Based Outbound IDocs 55Chap 9

    NAST messages arecreated byapplication by callingfunction moduleMESSAGING

    Creating NAST messages is a standard functionality in mostof the SAP core applications. Those applications - e.g. VA01,ME21 - perform calls to the central function moduleMESSAGING of group V61B. The function module usescustomizing entries, mainly those of the tables T681* to T685*.

    NAST contains objectkey, sender andreceiver

    A NAST output message is stored as a single record in thetable NAST. The record stores all information that is necessaryto create an IDoc. This includes mainly an object key toidentify the processed object and application to themessage handler and the sender and receiver information.

    Programs RSNAST00and RSNASTED provideversatile subroutinesfor NAST processing

    The messages are typically processed byFORM ENTRY in PROGRAM RSNAST00.If we are dealing with printing or faxing andFORM EDI_PROCESSING in PROGRAM RSNASTED.If we are dealing with IDocsFORM ALE_PROCESSING in PROGRAM RSNASTED.If we are dealing with ALE.The following piece of code does principally the same thingas RSNAST00 does and makes full use of all customizingsettings for message handling.

    FORM einzelnachrichtIN PROGRAMRSNAST00

    TABLES: NAST.SELECT * FROM NAST ...PERFORM einzelnachricht IN PROGRAM RSNAST00

    Programs arecustomized in tableTNAPR

    The processing routine for the respective media andmessage is customized in the table TNAPR. This table recordsthe name of a FORM routine, which processes the messagefor the chosen media and the name of an ABAP where thisFORM is found.

  • ISBN

    3528

    0572

    97 ht

    tp://id

    ocs.d

    e

    1999,2000 Axel Angeli et al. - SAP R/3 Guide to EDI http://idocs.de cook.doc Total pages 177; Printed: 2000-Mar-26-23:16; Page

    56 The RSNAST00 ABAP IDoc Outbound TriggersChap 9

    9.3 The RSNAST00 ABAP

    The ABAP RSNAST00 is the standard ABAP, which is used to collectunprocessed NAST message and to execute the assigned action.

    RSNAST00 is the standardbatch collector for messages

    RSNAST00 can be executed as a collector batch run,that eventually looks for unprocessed IDocs. The usualway of doing that is to define a batch-run job withtransaction SM37. This job has to be set for periodicprocessing and start a program that triggers the IDocre-sending.

    RSNAST00 processes onlymessages of a certain status

    Cave! RSNAST00 will only look for IDocs which are setto NAST-VSZTP = '1' or '2' (Time of processing).VSZPT = '3' or '4' is ignored by RSNAST00.

    For batch execution aselection variant is required

    Start RSNAST00 in the foreground first and find theparameters that match your required selectioncriteria. Save them as a VARIANT and then define theperiodic batch job using the variant.If RSNAST00 does not meet 100% your needs you cancreate an own program similar to RSNAST00. The onlyrequirement for this program are two steps:* Read the NAST entry to process into structureNASTtables nast.data: subrc like sy-subrc.....select from NAST where .......* then call FORM einzelnachricht(rsnast00) toprocess the recordPERFORM einzelnachricht(rsnast00) USING subrc.

    1999,2000 Axel Angeli et al. - SAP R/3 Guide to EDI http://idocs.de cook.doc Total pages 177; Printed: 2000-Mar-26-23:16; Page

    IDoc Outbound Triggers Sending IDocs Via RSNASTED 57Chap 9

    9.4 Sending IDocs Via RSNASTED

    Standard R/3 provides you with powerful routines, to trigger, prepare andsend out IDocs in a controlled way. There are only a few rare cases, whereyou do not want to send IDocs the standard way.

    The ABAP RSNAST00 is the standard routine to sendIDocs from entries in the message control. Thisprogram can be called directly, from a batch routinewith variant or you can call the FORMeinzelnachricht_screen(RSNAST00) from any otherprogram, while having the structure NAST correctlyfilled with all necessary information.

    RSNAST00 determines if it isIDoc or SapScript etc.

    If there is an entry in table NAST, RSNAST00 looks upthe associated processing routine in table TNAPR. If itis to send an IDoc with standard means, this willusually be the routine RSNASTED(EDI_PROCESSING) orRSNASTED(ALE_PROCESSING) in the case of ALEdistribution.

    RSNASTED processes IDocs RSNASTED itself determines the associated IDocoutbound function module, executes it to fill theEDIDx tables and passes the prepared IDoc to theport.You can call the standard processing routines fromany ABAP, by executing the following call to theroutine. You only have to make sure that the structureNAST is declared with the tables statement in thecalling routine and that you fill at least the key partand the routine (TNAPR) information before.TABLES NAST.NAST-MANDT = SY-MANDT.NAST-KSCHL = 'ZEDIK'.NAST-KAPPL = 'V1'.NAST-OBJKY = '0012345678'.NAST-PARNR = 'D012345678'.PERFORM einzelnachricht_screen(RSNAST00).

    Calling einzelnachricht_screen determines how themessage is processed. If you want to force the IDoc-processing you can call it directly:TNAPR-PROGN = ''.TNAPR-ROUTN = 'ENTRY'.PERFORM edi_processing(RSNASTED).

  • ISBN

    3528

    0572

    97 ht

    tp://id

    ocs.d

    e

    1999,2000 Axel Angeli et al. - SAP R/3 Guide to EDI http://idocs.de cook.doc Total pages 177; Printed: 2000-Mar-26-23:16; Page

    58 Sending IDocs Via RSNAST00 IDoc Outbound TriggersChap 9

    9.5 Sending IDocs Via RSNAST00

    Here is the principle flow how RSNAST00 processes messages for IDocs.

    ISBN

    3528

    05

    Illustration 11: Process logic of RSNAST00 ABAP

    1999,2000 Axel Angeli et al. - SAP R/3 Guide to EDI http://idocs.de cook.doc Total pages 177; Printed: 2000-Mar-26-23:16; Page

    IDoc Outbound Triggers Workflow Based Outbound IDocs 59Chap 9

    9.6 Workflow Based Outbound IDocs

    Unfortunately, there are application that do not create messages. This isespecially true for master data applications. However, most applicationsfire a workflow event d