Database Trigger in ABAP Program

Hi experts,
Is it possible to define a database trigger in an ABAP program, to be triggered when the data from a database table is modified?
Thanks,
Nuno Afonso

I doubt it, but if it's possible, I would NOT use it. Remember the application server assumes the role of the DBMS sometimes, and you will never be absolutely sure if your trigger will be used or not.
You can also define a TRIGGER for your Z-tables using the DBMS, but I will only recommend it if you are using ONLY z-tables. For standard tables, I would look for an alternate method, ie EXITs.
And if it's a Z-Table, you can just control its inputs by permissions (don't allow users to maintain it, just make a dialog to do it, and the dialog program would be the "trigger" guy)

Similar Messages

  • How-to trigger an ABAP program after a user logs on?

    Does anybody know if it is possible to trigger an ABAP program just after a users logs into the system?
    Thanks
    Ioan

    The function module is EXIT_SAPLSUSF_001.  The include program is ZXUSRU01. 
    Just put your SUBMIT statement in this include program.
    Regards,
    Rich Heilman

  • Re: Trigger an ABAP program in R/3 by a process chain in BW

    This is regarding a previous thread of mine. The basic idea is to trigger an ABAP program in R/3 by a process chain in BW.
    1. I created an ABAP program ( lets say P1)  in BW ( using SE38 ), and included the code:
    CALL FUNCTION 'BP_EVENT_RAISE'
    EXPORTING
    eventid = 'Y21608_CCNA3PVAR_START'.
    There is no variant for the ABAP program.
    2. Now, I dragged the process type ABAP code in my process chain, created a variant and gave this program P1 there.
    3. I have already created an event in R/3 with the name 'Y21608_CCNA3PVAR_START' ( using SM62 ) and created a job with schedule 'after event', which starts the ABAP programin R/3.
    Question: In the process chain, the process is going to the ABAP program but nothing is happening. What more do i include in the ABAP program? And how does this program trigger an event in R/3? Can i use BP_EVENT_RAISE or RSSM_EVENT_RAISE??
    Please advise.

    Edwin, are we calling a FM which exists in BW or are we calling an FM which exists in R/3 ?
    I thought, that the FM used should be in BW but it will trigger an event which has been created in R/3. Is this right? And where in the ABAP prgram can i specify the destination? How do i write this?
    Sorry if iam asking u to do the entire job for me:-)

  • How to trigger an ABAP program in a Process chain

    Hello Forum,
    1. In a process chain, if a program fails, how can we re-run it?
    2. If the process preceeding the ABAP program fails, how can we start the program?
    3. If an Infospoke fails in a process chain, how can we trigger that?
    Thank you,
    Its my pleasure to assign points,
    raj

    Hi,
    1. U have to first check whats the reason for the failure. check in the monitor screen details button, the error message will be displayed, check the error, correct it. and to proceed with further right click on the subsequent process use Repeat option , the loads will get continue.
    2. same here, if it fails check the reason, sometimes if two parallel process trying to access the same program Lock may occur, stop one process, once its done start the second process, use the transaction code SA38>select ur ABAP program, the corresponding variant->this is for running the ABAP program in the backgroud..if u want to run direct means Select the Process types Under the general services u find an ABAP program
    3. same here too u should find the reason why it fails, and rectify the error, and use the repaet option to proceed with further.

  • Trigger an ABAP program through a Process Chain

    Hi,
    I have an ABAP program as part of my Process Chain that updates the BW Hierarchy OREGH. 
    However I can't get the program to execute through the chain, even the though chains goes all green. without any REDS anywhere along the chain. 
    When I check if the program has made the desired changes in the tables it hasn't.
    If I run the program using SE38 it works fine and in seconds.
    Is there a parameter setting I have to set in the process chain or within the program itself.Tthe program is active.
    Ive checked many of the  posts about this issue but couldn't find a someone experiencing a similar problem.
    Please Help
    Thanks
    Amir

    Remove that ABAP program from the Process Chain and activate. Leave RSPC screen.
    Re-enter to RSPC, and add that program by creating a new variant with following options:
    Call Mode : Synchronous
    Call From : Local
    Check and Activate process chain.

  • ABAP program created in one system want to trigger from other system

    Hello,
    I have created ABAP program in ECC server internally it is using function module to update table.This ABAP program has 2 variants.
    I wnat to trigger this ABAP program from BW . How to idenfied an abap program which is return in system1 into other system2.So that it can be executed from BI.
    Thanks.

    There are ways to do this.
    Create an RFC in R/3 system (Tcode: se37 or read forums for sample). Create an event in sm62 (choose customer event) - then schedule your R/3 program (with whatever variant you want) in R/3 to trigger it when the event raised.
    Within the RFC (R/3), you need to trigger the event -
    Raise event to execute background jobs running under this event id
    w_eventid type btceventid value 'ZCUSTOMEVENT'.
        call function 'BP_EVENT_RAISE'
          exporting
            eventid                = w_eventid
          exceptions
            bad_eventid            = 1
            eventid_does_not_exist = 2
            eventid_missing        = 3
            raise_failed           = 4
            others                 = 5.
        if sy-subrc <> 0.
        endif.
    in BW - Create a program - Call the RFC (created in R/3). You can even add this to your process chains.
    CALL FUNCTION 'Z_RFC_IN_R3'
          DESTINATION p_dest
          IMPORTING
          XYZ = XYZ
          TABLES
          IT_X = IT_X
    p_dest being your R3 destination (this is RFC maintained in sm59 for your R3 client)....
    Good luck. Quite a bit of work but works perfect.

  • Trigger ABAP program using UNIX script

    Hi All,
    I want to trigger an Abap program whenever a unix file comes to SAP.
    Can any1 please tellme how to write a unix script to trigger the ABAP program.
    Thanks in advance.

    you will need to create a batch job in SM37 for the ABAP program, and use an event for the start criteria.
    The event can be created in SM62
    Then in unix, you will need to call an executable SAPEVT.
    This will be in the directory /usr/sap/<SAPSID>/SYS/exe/run
    you will need to use the appropriate profile for the SAP system to run the sapevt utility.
    example :-
    sapevt abap_event -t pf=/usr/sap/<SID>/SYS/profile/<SID>_DVEBMGS00_<SYSNAME> nr=00

  • LOGICAL DATABASE IN HR ABAP PRPGRAMMING

    Hi Friends,
    what is use of LOGICAL DATABASE IN HR ABAP PROGRAMMING
    AND END-OF-SELECTION EVENT IN HR PROGRAMMING PROGRAMMING???
    regards,
    vijay.

    hi
    HR Logical Databases
    In Human Resources (HR), the following logical databases can be used as a data source for HR InfoSets:
    PNP (PNPCE)
    PAP
    PCH
    By selecting a logical database, you determine the HR data that can be reported on using an InfoSet.
    Logical Database PCH
    This logical database generally enables you to report on all HR infotypes. However, you are advised not to use this logical database unless you want to report on Personnel Planning data.
    Logical Database PNP (or PNPCE)
    Use logical database PNP to report on HR master data. It is possible to use logical database PCH to access this data, but PNP meets such reporting requirements more quickly because it is best suited to the task of selecting persons.
    Logical database PNP enables you to access HR master data and infotypes from Personnel Planning. For example, you have the following options:
    Reporting on the costs, number of attendees booked, and instructor for a business event on which an employee is booked
    Reporting on working time and planned compensation for a position that an employee occupies
    Reporting on the validity and proficiency of a qualification that an employee fulfils
    From a technical perspective, this means you can use PNP to report on all of the infotypes that exist for objects (infotype 1000) that have a direct relationship (infotype 1001) with the Person object.
    The ability to access infotypes from Personnel Planning using logical database PNP is a special feature that you can only use in the context of SAP Query and Ad Hoc Query. You cannot use this functionality for ABAP reports you programmed yourself.
    You can also use logical database PNP to report on data from Personnel Time Management (infotypes 2000 to 2999) and Payroll (special payroll infotypes for the USA and customer infotypes; for more information, access Customizing for the Human Resources Information System and see Payroll Results).
    Logical Database PAP
    Logical database PAP enables you to access data from Recruitment.
    regards
    navjot
    reward if helpfull

  • Is Logical Database used in ABAP?????

    Hi All,
    I m very confused whether LDB's are used in ABAP or not.
    i have undergone a small training in ABAP-HR (HCM).
    In that training i was told that there is an advantage in HCM that LDB's are used here
    which were not used in ABAP.
    And i have read somewhere that LDB's are used in ABAP.
    can plz sumone give a light on this.
    Thanks,
    Sonali

    hi,
    The use of a logical database provides you with an alternative to having to program database accesses individually. Logical databases retrieve data records and make them available to ABAP programs.
    The same logical database can be the data source for several Quick Views, queries, and programs. In the Quick View, the LDB can be specified directly as a data source. A query works with the logical database when the functional area that generated the query is defined with a logical database. In the case of type 1 programs, the LDB is entered in the attributes or called using function module LDB_PROCESS. See appendix for information on how to use the function module.
    Logical databases offer several advantages:
    The system generates a selection screen. The use of selection screen versions or variants provides the required flexibility.
    The user does not have to know the exact structure of the tables involved (especially the foreign key dependencies); the data is made available in the correct order at GET events.
    Performance improvements within logical databases directly affect all programs linked to the logical database, without having to change the programs themselves.
    Maintenance can be performed at a central location.
    Authorization checks can also be performed centrally.
    A logical database is an ABAP program that reads predefined data from the database and makes it available to other programs.
    A hierarchical structure determines the order in which the data is supplied to the programs. A logical database also provides a selection screen that checks user entries and conducts error dialogs. These can be extended in programs.
    SAP provides some 200 logical databases in Release 4.6. The names of logical databases have been extended to 20 places in Release 4.0 (namespace prefix max. 10 characters).
    In the case of executable programs, you can enter a logical database in the attributes.
    Use the NODES statement to specify the nodes of the logical database that You want to use in the program. NODES allocates the appropriate storage space for the node - that is, a work area or a table area depending on the node type.
    The logical database makes the data records available for the corresponding GET events.
    The sequence in which these events are processed is determined by the structure of the logical database.
    Logical databases are made up of several sub-objects. The structure determines the hierarchy, and thus the read sequence of the data records.
    Hope this helps, Do reward

  • Migration influence in ABAP program

    hi guys,
    We are going for migration from 4.6C (Op.sys - HP-Unix, DB-Oracle 8.0) to 4.6C(Op.sys-Solaris,DB-Oracle 9.0).
    We need to analyse what are the changes required to be considered before migration.
    I guess below things are basic things
    1-External command.
    2-OS level application execution command.
    3-OPEN file path(logical path,physical path)
    other than this is there any thing i have to considered for OS and Database difference inside ABAP programs.
    appreciate if you Can give me check list...if possible
    Pls suggest me.
    thanks.
    Ambi.

    MESSAGE  ext TYPE mtype ... .
    This variant sends a character string contained in text as a message of the message type specified in mtype. You can enter a character-type data object text, which will be used as a short text for the message. Only the first 300 characters in text are taken into account. No long text can be defined for a message of this type.
    For mtype, a character-type data object is expected, which must contain the message type in capital letters. Invalid message types generate an untreatable exception.
    Notes
    : In this variant, the additions WITH and INTO are not allowed in message_options.
    If field symbols or formal parameters of the type any or data are specified for text, these must be of character type when the statement is executed. The syntactically identical variant MESSAGE oref cannot be executed with generically typed field symbols or formal parameters.
    Because the system fields sy-msgid and sy-msgno are filled unspecifically when a character string is entered, this variant should only be used on rare occasions if the content of the system fields is not required for identification of the message. Otherwise, in all cases in which messages are transferred (for example, from function modules) or logged (for example, in batch input) using these system fields, language-independent access to the message text would be lost.
    Example
    : Output of an exception text as an information message.
    DATA: oref TYPE REF TO cx_sy_arithmetic_error,
          text TYPE string.
    TRY.
      CATCH cx_sy_arithmetic_error INTO oref.
        text = oref->get_text( ).
        MESSAGE text TYPE 'I'.
    ENDTRY.

  • Urgent: call ABAP program from BSP

    hi BSP experts,
    We just want to trigger an ABAP program to say "Hello World" in BSP and see the wording "Hello World" on web browser when running it from BSP.  One BSP expert Raj gave the answer by using the following in BSP:
    oninitialization:
    submit ('z_program_name') and return exporting list to memory.
      call function 'LIST_FROM_MEMORY'
           tables
                listobject = listobject.
      call function 'WWW_HTML_FROM_LISTOBJECT'
           exporting
                report_name = 'z_program_name'
           tables
                html        = html
                listobject  = listobject.
      clear output_str.
      loop at html into html_wa.
        concatenate output_str html_wa into output_str.
      endloop.
    layout code:
    <htmlb:content design="design2003">
    <htmlb:page title = " ">
    <htmlb:form>
    <%= output_str %>
    </htmlb:form>
    </htmlb:page>
    </htmlb:content>
    We put the above in our BSP and then activate them, but get the following error:
    Field "LISTOBJECT" is unknown. It's neither in one of the specified tables nor defined by a "DATA" statement. "DATA" statement."DATA" statement.
    And the error stopps here:
    submit ('z_program_name') and return exporting list to memory.
    call function 'LIST_FROM_MEMORY'
    tables
    listobject = listobject.
    Any idea? 
    We will give you reward points!

    hi Tanguy,
    Eventually, I have figured it out on how to make the code works by showing "Hello World!" on web browser. But actually we would like to run another ABAP program which open a new container on users' machines, download an Excel template stored on server to the opened container on users' machinese, and then dump SAP table data to the opened excel template. This program works very well through SAP GUI, but users would like to run it on web that we tried to run this program in BSP, but it doesn't work with your code! Any idea?
    Thanks alot!

  • How to use FTI_TR_CASH_FLOWS ldb in abap programming.

    I want to use FTI_TR_CASH_FLOWS  logical database in existing ABAP program but i am not able to use this logical data base in the program.Please suggest how to use this logical database in the program.

    I have developed a customized report and i want to use  logical database "FTI_TR_CASH_FLOWS" into my program . i don't know how to use SAPDBFTI_TR_CASH_FLOWS  into my report. how i pass data from my report to this LDB report. plz suggest.

  • Where does ABAP programs , BAPI's etc., get saved?

    Hi friends
    We have an ERP server (ECC) and have created lots of database tables, functions, Abap programs etc.,
    For some reason our ERP software is corrupted. However, the SQL database looks ok.
    So here is what we want to do.
    Since the SQL database is good, So we would like to backup the SQL database first.
    We have a ghost image of the server that was done some 2 months back. So we would like to install the ghost image of the server from 2 months back. This will bring the server back to working condition but without data.
    Then recover the SQL database which we backed up before installing the ghost.
    By doing this, will we be able to get back all the tables, data elements, BAPIs, functions, ABAP programs etc.,
    Please let us know.
    I will really appreciate it.
    Thanks
    Ram

    (subfolders COFILE and DATA of DIR_TRANS contain the transport requests once they are released, and they must exist in your system, check via AL11 to get the actual name on server, e.g. /usr/sap/trans/cofiles.)
    Program sources are stored in a cluster like (comrpessed) table (tables REPOSRC and REPOTEXT and for older versions tables D010S, D010SINF, D010T, D010TINF) and so not easily downloadable.
    You can create a report that read thru the abap program header table (TRDIR or via TADIR ) and execute the [READ REPORT|http://help.sap.com/abapdocu_70/en/ABAPREAD_REPORT.htm] statement to load source into an internal table, then you can download it
    Check sample at wiki like [Download given set of programs into a folder on presentation server|http://wiki.sdn.sap.com/wiki/display/Snippets/Downloadgivensetofprogramsintoafolderonpresentationserver]
    Regards,
    Raymond

  • Triggering ABAP Program upon file drop

    Hi Gurus,
    I would like to trigger an ABAP program as and when a file is dropped in a drive. Please let me know what is the best way to do this.
    Also please let me know how to handle in the program if 2 or more files are dropped at a time.
    Appreciate it. thanks.

    Hello,
    You can create a Z program and schedule a job for the time what you need.
    Sample code:
    "......... definitions .......
    START-OF-SELECTION.
         PERFORM read_files_in_dir_on_server USING p_wfile
                                          CHANGING gt_files.
    LOOP AT gt_files INTO gv_filepath.
         gv_progress = sy-tabix / lines( gt_files ).
         PERFORM read_server_file USING gv_filepath
                               CHANGING gt_file_content
                                        gv_filelenght.
         "do what you need here!  
         CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
           EXPORTING
             percentage = gv_progress
             text       = 'Processing the files'(003).
       ENDLOOP.
    *&      Form  READ_FILES_IN_DIR_ON_SERVER
    *       Read all files in a directory (server)
    *      -->IV_DIR     Directory
    *      <--CT_FILES   Files in Directory
    FORM read_files_in_dir_on_server  USING     iv_dir     TYPE string
                                       CHANGING ct_files   LIKE gt_files.
       DATA: lv_dir_name TYPE ocs_file-name,
             lt_filelist TYPE STANDARD TABLE OF ocs_file,
             ls_filelist LIKE LINE OF lt_filelist,
             ls_file     LIKE LINE OF ct_files,
             lv_offset   TYPE i,
             lv_dummy    TYPE i,
             lv_error    TYPE boolean.
       lv_dir_name = iv_dir.
       CALL FUNCTION 'OCS_GET_FILE_INFO'
         EXPORTING
           dir_name                  = lv_dir_name
         TABLES
           dir_list                  = lt_filelist
         EXCEPTIONS
           no_authority              = 1
           activity_unknown          = 2
           not_a_directory           = 3
           no_media_in_drive         = 4
           too_many_errors           = 5
           too_many_files            = 6
           bracket_error_in_filename = 7
           no_such_parameter         = 8
           OTHERS                    = 9.
       IF sy-subrc <> 0.
         MESSAGE 'Error on directory selected' TYPE 'E'.
       ENDIF.
       LOOP AT lt_filelist INTO ls_filelist.
         lv_error = abap_false.
              "check a specific prefix
         IF ls_filelist-name(4) NE 'out_'.
           lv_error = abap_true.
         ENDIF.
               "check a specific extension
         FIND '.xml' IN ls_filelist-name MATCH OFFSET lv_offset.
         IF sy-subrc IS NOT INITIAL.
           lv_error = abap_true.
         ENDIF.
              "needs to end with a number (not chars allowed)
         lv_offset = lv_offset - 1.
         TRY .
             lv_dummy = ls_filelist-name+lv_offset(1).
           CATCH cx_root.
             lv_error = abap_true.
         ENDTRY.
              "check if the dir is complete filled (end with \ )
         lv_offset = strlen( iv_dir ) - 1.
         IF iv_dir+lv_offset EQ '\'.
           CONCATENATE iv_dir
                       ls_filelist-name
                  INTO ls_file.
         ELSE.
           CONCATENATE iv_dir '\'
                       ls_filelist-name
                  INTO ls_file.
         ENDIF.
         IF lv_error NE abap_true.
           APPEND ls_file TO ct_files.
           CLEAR ls_file.
         ENDIF.
       ENDLOOP.
    ENDFORM.                    " READ_FILES_IN_DIR_ON_SERVER
    *&      Form  READ_SERVER_FILE
    *       Read server file
    *      -->IV_FILEPATH  text
    *      <--CT_FILE_CONTENT  text
    *      <--CV_FILELENGHT  text
    FORM read_server_file  USING iv_filepath     TYPE string
                         CHANGING ct_file_content TYPE table_of_strings
                                  cv_filelenght   TYPE i.
       DATA: lv_content LIKE LINE OF ct_file_content,
             lv_msg     TYPE string.
       REFRESH ct_file_content.
       CLEAR cv_filelenght.
       OPEN DATASET iv_filepath FOR INPUT
                                IN TEXT MODE
                                ENCODING UTF-8
                                MESSAGE lv_msg.
       DO.
         READ DATASET iv_filepath INTO lv_content.
         IF sy-subrc IS NOT INITIAL.
           EXIT.
         ENDIF.
         APPEND lv_content TO ct_file_content.
         gv_filelenght = gv_filelenght + strlen( lv_content ).
       ENDDO.
    ENDFORM.                    " READ_SERVER_FILE

  • ALE triggering ABAP program instead of iDoc

    Is it possible to have ALE trigger an ABAP program instead of an iDoc?
    We need to send changes in Master Data to a system that can't handle iDoc, but does know what to do with SOAP.

    We're talking about an All-in-One system on NetWeaver 700 and ECC 6.0. My company has developed an Add-On for Business One and now they want to develop a similar Add-On for All-in-One. That Add-On should integrate an Open Source system into an SAP system, or at least make the flow of data seem seamless.
    I should be very careful with my comments, as I'm not really understanding enough about your requirements. I must admit key words changes in master data and ALE triggered my initial comment.
    On second thought it might actually be worthwhile to think about other alternatives. E.g. you could look at the technique SAP uses for BW extractors, which might also be suitable.
    I might just be able to hook into the Change Doc system by defining new Change Doc and Change Pointer Types.
    Well, per my comment above, maybe you don't even need change pointers. However, if you do, you can mostly rely on existing change documents unless you're dealing with some odd or custom object.
    Am I right if I think that IDocs handle those Change Pointers from some kind of scheduled background job?
    Part of the setup for change pointers for a specific message type is to define which function module is used for evaluating the change pointers. All change pointers are then evaluated via transaction BD21, program RBDMIDOC, which can also be scheduled in the background.
    but we only need less than 5% of the information contained in an iDoc
    Well, in theory SAP offers some options: You can filter segments via ALE, use reduced message types or define IDoc views. However, depending on the technique this sometimes requires that the actual application (function module creating the IDocs) has to support it (because it's additional API calls that have to be present).
    Defining new IDoc types isn't that attractive to us.
    Though I do understand such statement in specific cases, it's hard to relate to it on a general level. I.e. in the latter case it's often more driven by strange company policies than by good design choices.
    Anyhow, in the end I'm tempted to think that change pointers with IDocs are one option among many. In your specific case however it sounds as if there's possibly other techniques that might be more suitable. So I'll stop for now before I tell you too much crap pushing you in a wrong direction...

Maybe you are looking for

  • Does airplay mirroring work on MacBook Pro late 2011 ( Mac OS X Lion 10.7.5)?

    Hi guys, I would like to use airplay mirroring on apple tv (3rd generation) with my macbook pro late 2011, unfortunately the airplay option does not appear in the display preferences (see screenshot below). Did someone have this problem before? Pleas

  • Using Java oracle.spatial.util.SampleShapefileToJGeomFeature : ESRI SHP

    Hi, I am trying to import an ESRI shapefile using the Java class oracle.spatial.util. I have to add a remark, that I have set the classpath with the command set classpath=.;%ORACLE_HOME%\jdbc\lib\ojdbc14.jar I am using Oracle 11g and I don't have thi

  • S6000 external keyboard keys repeating

    I have the S6000 with the external keyboard and the keys tend to repeat most of the time, even with a single tap. Is there a setting that I am missing? The virtual keyboard works fine.

  • Why my labview 7.0 shut off automaticlly?

    Hellw,i have a question: my labview7.0 running in WinXp system,but recently,almost every time when i open labview,it will shut off automaticlly.especially,when i use mouse to right click on the VI,it will shut off. it is so wierd,any one can give me

  • Oracle VDI 3.3 Directory access with Windows2008 Active Directory

    Hi can some body help me to solve this issue? I install oracle VDI 3.3 and I configure Windows2008 Active Directory for authentification. I made some test in command line kinit -v user and I received the message "Authenticated to Kerberos v5" but whe