Regarding Macros

Hi,
I am kumar. I got job right now i am a trainee in HR ABAP. I got a doubt.
What is Macro and what is the need of Macros in HR ABAP? Why can't we use subroutines and function modules? what is the difference between Macros, Subroutines and Function Mudules?
bye
phanikumar

hi,
Go to se38. CTRL+F8 type in define and press enter.
This is the SAP help about the subject on Macros and helps you understand how they work.
In ABAP HR however there are lots of macros used, which can be found in the table TRMAC.
A couple of these provide easier reading of the code and can help in coding.
Som HR examples are:
rp-provide-from-last, this one selects data from an infotype
RP-LOWDATE-HIGHDATE this one defines the data element low-date and high-date, also used a lot in HR abap.
If you come upon a macro in SAP standard, enter that one in TRMAC sometimes the functionality is explained in that table.
Kind regards, Rob Dielemans

Similar Messages

  • Regarding macros in abap

    DEFINE macro_split_row_define.
    ..selection-screen begin of line.
    ..selection-screen position 10.
    ..parameters: sp_s&1 as checkbox default 'X' modif id noi.
    ..selection-screen position 12.
    ..selection-screen comment (1) text-f41 for field sp_s&1.
    ..parameters: sp_p&1 like rv56_vt04-f_gestext.
    ..selection-screen comment (1) text-f41 for field sp_p&1.
    ..selection-screen pushbutton 62(4) sp&1 user-command sp&1
    modif id dsp.
    ..selection-screen end of line.
    END-OF-DEFINITION.
    Why they are using periods before selection-screen pleasee help me its urgent?

    The dots (.) before the selection-screen does not matter at all. It still works the same way as without dots before the selection-screen.
    Hope this helps.
    Thanks,
    Balaji

  • Syntax for the macro - request suggestions...

    Dear All, Good morning..
    I request your help in craking the below issue..
    <i><b>Description:</b></i>
    Calculation of a KF based on the following formula:
    <b>Dlr Inv(M01/2007)= Max( ( sp.plan(m01/2007)+Dlr Inv(M12/2006) ) ; Threshold Dlr Inv(M01/2007) )- Un constrained sales( M01/2007)</b>
    If you observe in the above calculation, for calculating current month Dlr Inv, we are using previous months Dlr Inv..OK.
    <i><b>Requiremet:</b></i> Calculation of the above , plus, the above calculation may produce a negative number...So, when there is negative number generated in the curent month calculation, i should make it to zero, display zero and carry  that zero for next months calculation...
    I wrote a macro, which is doing above calculation perfectly(as it is simple )...except carrying zero to next month's calculation...As long as the above calculation is generating positive value, there is no issue at all..
    <i><b>Issue:</b></i> In some cases , the above formula results a negative number, in that case, i am able to make it zero,  and able to carry that zero for next calculation, if the negative is generated for the first column..problem is , if there is any negative generated in between,let us say, for  June/2006,  then its making it zero, but that zero is displayed for the subsequent months from there onwards, irrespective of  the result is positive or negative..If i chage any number at that period for any KF, and execute macro, then it is working..Here i used auxiliary row...
    I have written 3  macros with diff logic...If you want i can post them again ....
    I would like to know the following things regarding macro syntax..
    <b>1)Can we go for a condition after a result in the same step...?
    </b>
    <b>Example: 
    Step:(M01/2007-M12/2007)(12 iterations)
    Row 1= Row2 -Row 3
    IF
    Row 1 < 0
    Row 1 = 0
    ENDIF</b>
    If i execute IF condition in another step,It won't serve my purpose because, it comes to second step after completing all iterations in first step...I want , <b>IF</b> condtion to be checked after the first iteration..
    In my case, macro successfully activated  but no result for that condition..It is executed only up to result for the first time when i tested in Utilities--->test Macros..in the macro builder..if i execute it for the second time, then it gives result..Surprised..!!!
    2) <b>Is it possible to write syntax in the following way..</b>
    IF
    (condition)
    ( Row  1 + Row 2) < 0
    ResulT : Row 3=0
    In my case,
    It is not accepting +, - .....
    Kindly suggest...
    I am confident that i crack this with your mighty help..
    Thanks for reading..
    regards,
    umamahesh
    Message was edited by: Uma Mahesh
            Uma Maheswar kumar
    Message was edited by:
            Uma Maheswar kumar

    HI Vinayak,
    Thanks very much for responding..
    I appreciate your reply and time spent on this...
    Your solution goes to indefinate internal loop..
    In your solution, Vi-2 is the previuos years cell ref: which again needs calculation...
    Your solution works good if i have to use current motns calculation of one  KF in another...
    say
    A= B+C;(current month)
    D=AE( current momth)...then instead of AE, better we use, D=(BC) E...Actually i am not facing any problem in taking the previous months updated value...i am facing problem with IF loop in case of negative...
    I will try your option and come back to you...

  • Script for Word 2008 to set the font for whole document.

    I just moved to Office 2008 form 2004 and am shocked to see my Macros do not work! So need to solve it with Aplescript. I spend an hour to find a way of changing the font in a whole document, to no avail.
    To select all the text is easy:
    tell application "System Events"
    tell application "Microsoft Word" to activate
    tell process "Microsoft Word" to keystroke "a" using command down
    end tell
    But how to get it to do the font?
    Any tips?

    Looks promising:
    http://www.macworld.com/reviews/product/671498/review/microsoftword_for_mac2011.html
    The bottom line is this: Microsoft Word for Mac no longer feels like a second-string word processing program in the Microsoft Office suite. It is in fact a powerful tool for creating all your personal and business documents and for collaborating with others. More importantly, Word 2011 now makes it possible to insert a Mac into nearly any business environment and offer Mac users the same set of features found in Word for Windows, without compromise.
    And regarding Macros:
    http://www.macworld.com/article/154785/2010/10/welcomebackvisualbasic.html
    In my testing so far, Excel 2011 runs older macros just fine. I opened one macro-laden worksheet I’d created back in 1992 in Excel 2011; it ran perfectly. I also opened a number of Excel 2004 worksheets, all of which used macros to some degree or another, and they also worked as expected.
    New macros I’ve recorded so far all worked as expected. The Visual Basic Editor’s work area is mostly identical to that of Excel 2004’s, but with a few nice additions. For instance, the Edit menu features some new options for viewing properties, methods, constants and parameters. In the Debug menu, you can create Watch functions, which allow you to watch an expression and to stop the macro when a value changes or a condition becomes true.
    Microsoft’s Excel 2011 team has also worked to make Mac macros compatible with those written for Excel for Windows. According to Microsoft, Excel 2011 for Mac features a full port of the Windows Office VBA environment; in most cases, the OS X and Windows versions of VBA now mirror each other. This includes updating the core VBA engine in Office 2011 to VBA version 6.5, and adding some commands (FormatCurrency, FormatNumber, Replace) that had been disabled in Excel 2004 for the Mac. When there were object-model differences between the Windows and OS X versions, Microsoft says it conformed the Mac version to Office 2010. (Macworld hasn’t had the opportunity to fully test that Windows-compatibility yet.)
    Overall, I’ve been quite happy with the macro experience in Excel 2011. Now that Tools -> Macros does something useful once again, I can finally retire Excel 2004.

  • Cannot load visual basic for applications

    I cannot load visual basic for applications on word doc

    The relevance to iTunes for Windows escapes me.
    VBA is an optional component of Microsoft Office. Unless you are an active VBA programmer any alert message regarding macros should be a red flag that something viral might be contained within the document that you are trying to open.
    tt2

  • Custom Button Outlook to Word Bookmark

    Hello,
    Based on below thread how would I need to update the macro in order to open a word document at a specific bookmark created in the document?
    custom-button-outlook-2010
    Thanks a lot for your help

    Hi FHACL,
    Please check if George's method resolves the issue. Since this forum is for general questions and feedback related to Outlook, if you need further assistance regarding macro, I'd recommend you post a question in the Outlook for Developers forum:
    https://social.msdn.microsoft.com/Forums/office/en-US/home?forum=outlookdev
    The reason why we recommend posting appropriately is you will get the most
    qualified pool
    of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.
    Steve Fan
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
    programs.

  • SAP BPC pre requisites

    Hi All
    Am working ion BI and am looking to learn SAP BPC NW7.0
    But before going to that I need to know what are the other platforms knowledge is required and what are the pre requisites are there.
    1)     Does it require SAP BO Knowledge?
    2)     Does it require SAP BCS knowledge?
    3)     Does it require MS-Excel knowledge (Like writing macros and complex formulas)
    4)     Does it require Finance knowledge?
    Please let us know if anything is required to learn it.
    Thanks in advance
    Sravani

    Hi,
    It is not easy to provide the answer without specifying in what area you would like to work.
    More into application side or more into technical side.
    Any way I will try to provide some general answer to your questions
    1.No you don't need SAP BPO knowledge
    2.No you don't need SAP BCS knowledge
    3. Yes you need Excel knowledge but not necessary to build Macro. Usually you have to be able to pass the certifcation for User Microsoft Excel (which doesn't include anything regarding Macro or VB code).
    Having good knowledge about Excel you will be able to build easier the reports with SAP BPC.
    4. Yes if you woudl like to do consolidations or any application where you have to understand financial processes.
    I hope this it will help you to start.
    Regards
    Sorin Radulescu

  • About modularization techniques

    hi,,
       can anybody send me the details about modularization techniques ?
       mainly i want differences between INCLUDES and FUNCTION MODULES.
                                                         MACROS and SUBROUTINES.

    Hi
    Purpose of modularization is: 1) Organizing your ABAP Code 2) Limit maintenance cost by coding every thing only once and making your ABAP code easier to understand.
    Modularization techniques:
    1) Organizing your ABAP code can be done by using INCLUDE reports and local MACRO's (DEFINE statement). Typical examples can be found in Module Pools and Function Groups with TOP-includes and special includes for PBO events, PAI events et cetera. You can discuss if using subroutines, functions or methods is also part of this type of modularization technique. At this moment, most ABAP programmers use subroutines partly as a means to create some sort of main line in their program, thus limiting large chunks of ABAP code. Regarding MACRO's there are some special problems, especially that they don't improve readability of ABAP coding, and you can not debug them.
    2)Here, we are talkin about ABAP PROCEDURES: a) Subroutines, b) Functions and c) Methods
    - 2a) Subroutines: can be used locally and globally (external subroutine calls). Subroutines have a formal interface ( USING, CHANGING, TABLES parameters). The interface parameters can be passed BY VALUE or BY REFERENCE. Data that is defined within a subroutine (FROM ... ENDFORM.) is local: lifetime and visibility is limited to the moment the subroutine is called. External Subroutines are subroutines that are called from another program. Typical example can be found in the way SAPscript and SMARTforms printprograms are called by RSNAST00. External Subroutines can be grouped into Subroutine Pools.
    - 2b) Functions: are part of function groups. They are designed for global use and have a unique name. Function Modules also have a formal interface using IMPORTING, EXPORTING, CHANGING and TABLES parameters. The interface parameters can be passed BY VALUE or BY REFERENCE. Specific EXCEPTIONS can be defined for error handling. A function module can also have local data.
    In theory, a function module can only use data a)from the interface parameters, b) defined locally in the function module and c) defined globally in the function group. However, it is possible to see global data from calling programs using field-symbols.
    Remote Function Modules are function modules that can be called from other SAP or NON-SAP systems. BAPI's are examples of RFC-enabled function modules.
    Function Groups and Function Modules are maintained using transaction SE37 (or SE80).
    - 2c) Methods: are part of CLASSES. Here we are talking about ABAP Objects, supporting inheritance, instantiation, encapsulation, polymorphism, events, Interfaces, visibility sections (PUBLIC, PROTECTED, PRIVATE) and lifetime options STATIC and INSTANCE.
    Classes can be defined locally or globally: a) Local Classes are classes, defined as part of an ABAP program. They can be used only within this program. b) The functionality of Global Classes is identical, but these classes are maintained using the Class Builder (SE24 or SE80).
    The name of a method is not unique; you always need the name of the object to create the unique name. As a result, several classes will have exactly the same method name.
    Methods also have a formal interface using IMPORTING, EXPORTING, CHANGING and RETURNING parameters. The interface parameters can be passed BY VALUE or BY REFERENCE. Specific EXCEPTIONS can be defined for error handling. A method can also have local data.
    In general, using classes is considered a much better alternative to using subroutines and function modules, especially with regards to maintenance costs. Actually, you do not need subroutines anymore. Function Modules are only needed is some cases, for example as RFC's because the classes don't support remote calls.
    One limitation of ABAP Classes is that they do not support dynpro's. This means that you always need a report/module pool/function group if you want to create screens.
    Within methods, several types of obsolete ABAP statements are not allowed like: ON CHANGE OF, TABLES and OCCURS.
    Consider that new tools and options like Web Dynpro, Unit Testing, Shared Objects, Exception Classes can only be understood when having the knowledge of ABAP OO. If you are debugging new SAP transactions, you'll see that they are also programmed using ABAP Objects.
    Processing blocks that are called from ABAP programs:
       1. Subroutines
       2. Function modules
       3. Methods
          Procedures
          Procedures contain a set of statements, and are called from other ABAP programs.
          The processing blocks that you call from ABAP programs are called procedures
          You define procedures in ABAP programs. When the program is generated, they remain as standalone modules. You can call procedures in the program in which they are defined, or from external programs. Procedures have an interface for passing data, and can also contain local data.
          ABAP contains the following kinds of procedures:
    Subroutines
    Subroutines are principally for local modularization, that is, they are generally called from the program in which they are defined. You can use subroutines to write functions that are used repeatedly within a program. You can define subroutines in any ABAP program.
    Function Modules
    Function modules are for global modularization, that is, they are always called from a different program. Function modules contain functions that are used in the same form by many different programs. They are important in the R/3 System for encapsulating processing logic and making it reusable. Function modules must be defined in a function group, and can be called from any program.
    Methods
    Methods describe the functions and behavior of classes and their instances in ABAP Objects. Methods must be defined in classes. When you call them, you must observe certain special rules of object-oriented programming.
    Subroutines
    Subroutines are procedures that you can define in any ABAP program and also call from any program. Subroutines are normally called internally, that is, they contain sections of code or algorithms that are used frequently locally. If you want a function to be reusable throughout the system, use a function module.
    subroutine is a block of code introduced by FORM and concluded by ENDFORM.
    FORM [USING ... [)] ... ] [CHANGING... [)] ... ].
    ENDFORM.
    subroutines cannot be nested. You should therefore place your subroutine definitions at the end of the program
    Calling Subroutines
    PERFORM... .
    Subroutines can call other subroutines (nested calls) and may also call themselves (recursive calls). Once a subroutine has finished running, the calling program carries on processing after the PERFORM statement. You can use the USING and CHANGING additions to supply values to the parameter interface of the subroutine.
    Function Modules
    Function modules are procedures that are defined in function groups (special ABAP programs with type F) and can be called from any ABAP program. Function groups act as containers for function modules that logically belong together.
    Unlike subroutines, you do not define function modules in the source code of your program. Instead, you use the Function Builder. The actual ABAP interface definition remains hidden from the programmer. You can define the input parameters of a function module as optional. You can also assign default values to them. Function modules also support exception handling. This allows you to catch certain errors while the function module is running.
    Function groups are containers for function modules. You cannot execute a function group. When you call an function module, the system loads the whole of its function group into the internal session of the calling program (if it has not already been loaded).
    This is used by the system to create the components of the group (main program and corresponding include programs). When you create a function group or function module in the Function Builder , the main program and include programs are generated automatically.
    The main program SAPL contains nothing but the INCLUDE statements for the following include programs:
    LTOP. This contains the FUNCTION-POOL statement (equivalent for a function group of the REPORT or PROGRAM statement) and global data declarations for the entire function group.
    LUXX. This contains further INCLUDE statements for the include programs
    LU01, LU02, ... These includes contain the actual function modules.
    The include programs LF01, LF02, ... can contain the coding of subroutines that can be called with internal subroutine calls from all function modules of the group.
    All of the function modules in a function group can access the global data of the group. For this reason, you should place all function modules that use the same data in a single function group.
    Function modules can have the following interface parameters:
    Import parameters. These must be supplied with data when you call the function module, unless they are flagged as optional. You cannot change them in the function module.
    Export parameters. These pass data from the function module back to the calling program. Export parameters are always optional. You do not have to receive them in your program.
    Changing parameters. These must be supplied with data when you call the function module, unless they are flagged as optional. They can be changed in the function module. The changed values are then returned to the calling program.
    Tables parameters. You use these to pass internal tables. They are treated like CHANGING parameters. However, you can also pass internal tables with other parameters if you specify the parameter type appropriately.
    You can specify the types of the interface parameters, either by referring to ABAP Dictionary types or elementary ABAP types. When you call a function module, you must ensure that the actual parameter and the interface parameters are compatible.
    Interface parameters are, by default, passed by value. However, they can also be passed by reference. Tables parameters can only be passed by reference. You can assign default values to optional importing and changing parameters. If an optional parameter is not passed in a function module call, it either has an initial value, or is set to the default value.
    Exceptions are used to handle errors that occur in function modules. The calling program checks whether any errors have occurred and then takes action accordingly.
    Calling Function Modules in ABAP
    To call a function module, use the CALL FUNCTION statement:
    CALL FUNCTION [EXCEPTIONS e1 = r 1.... e n = r n ].
    You can specify the name of the function module either as a literal or a variable. Each interface parameter is explicitly assigned to an actual parameter . You can assign a return value to each exception . The assignment always takes the form = . The equals sign is not an assignment operator in this context.
    After EXPORTING, you must supply all non-optional import parameters with values appropriate to their type. You can supply values to optional import parameters if you wish.
    After IMPORTING, you can receive the export parameters from the function module by assigning them to variables of the appropriate type.
    After CHANGING or TABLES, you must supply values to all of the non-optional changing or tables parameters. When the function module has finished running, the changed values are passed back to the actual parameters. You can supply values to optional changing or tables parameters if you wish.
    You can use the EXCEPTIONS option to handle the exceptions of the function module. If an exception is raised while the function module is running, the system terminates the function module and does not pass any values from the function module to the program, except those that were passed by reference. If is specified in the EXCEPTION option, the calling program handles the exception by assigning to SY-SUBRC. must be a numeric literal.
    If you specify of ERROR_MESSAGE in the exception list you can influence the message handling of function modules. Normally, you should only call messages in function modules using the MESSAGE ... RAISING statement. With ERROR_MESSAGE you can force the system to treat messages that are called without the RAISING option in a function module as follows:
    Messages of classes S, I, and W are ignored (but written to the log in a background job).
    Messages of classes E and A stop the function module as if the exception ERROR_MESSAGE had occurred (SY-SUBRC is set to ).
    If you specify OTHERS after EXCEPTIONS, the system assigns a single return code to all other exceptions that you have not specified explicitly in the list.
    You can use the same number for several exceptions.
    You can trigger exceptions in the function module using either the RAISE or the MESSAGE ... RAISING statement. If the calling program handles the exception, both statements return control to the program. The MESSAGE ..... RAISING statement does not display a message in this case. Instead, it sets the following system fields:
       1. Message class ® SY-MSGID
       2. Message type ® SY-MSGTY
       3. Message number ® SY-MSGNO
       4. SY-MSGV1 to SY-MSGV4 (contents of fields to , included in a message).
          You can use the system fields to trigger the message from the calling program.
    Raising Exceptions
    There are two ABAP statements for raising exceptions. They can only be used in function modules:
    RAISE .
    and
    MESSAGE..... RAISING .
    The effect of these statements depends on whether the calling program handles the exception or not. If the name of the exception or OTHERS occurs in the EXCEPTIONS addition of the CALL FUNCTION statement, the exception is handled by the calling program.
    If the calling program does not handle the exception
    The RAISE statement terminates the program and switches to debugging mode.
    The MESSAGE ..... RAISING statement display the specified message. How the processing continues depends on the message type.
    If the calling program handles the exception, both statements return control to the program. No values are transferred. The MESSAGE ..... RAISING statement does not display a message. Instead, it fills the system fields SY-MSGID, SY-MSGTY, SY-MSGNO, and SY-MSGV1 to SY-MSGV4.
    Remote Function Modules
    To implement a remote function module in ABAP, perform the following steps:
    1. Register the module as remotely callable in the RFC server system.
    In the function module Administration screen (transaction code SE37), set the field Can be called via REMOTE CALL. Registering a module as remote causes an RFC stub to be generated for it.
    Asynchronous remote function calls (aRFCs) are similar to transactional RFCs, in that the user does not have to wait for their completion before continuing the calling dialog. There are three characteristics, however, that distinguish asynchronous RFCs from transactional RFCs:
    When the caller starts an asynchronous RFC, the called server must be available to accept the request.
          The parameters of asynchronous RFCs are not logged to the database, but sent directly to the server.
    Asynchronous RFCs allow the user to carry on an interactive dialog with the remote system.
    The calling program can receive results from the asynchronous RFC.
    You can use asynchronous remote function calls whenever you need to establish communication with a remote system, but do not want to wait for the function’s result before continuing processing. Asynchronous RFCs can also be sent to the same system. In this case, the system opens a new session (or window) and allows you to switch back and forth between the calling dialog and the called session.
    To start a remote function call asynchronously, use the following syntax:
    CALL FUNCTION RemoteFunction STARTING NEW TASK taskname
    Destination ...
    EXPORTING...
    TABLES ...
    EXCEPTIONS...
    The following calling parameters are available:
    TABLES
    passes references to internal tables. All table parameters of the function module must contain values.
    EXPORTING
    passes values of fields and field strings from the calling program to the function module. In the function module, the correponding formal parameters are defined as import parameters.
    EXCEPTIONS
    see Using Pre-Defined Exceptions for RFC
    RECEIVE RESULTS FROM FUNCTION func is used within a FORM routine to receive the results of an asynchronous remote function call. The following receiving parameters are available:
       1. IMPORTING
       2. TABLES
       3. EXCEPTIONS
    The addition KEEPING TASK prevents an asynchronous connection from being closed after receiving the results of the processing. The relevant remote context (roll area) is kept for re-use until the caller terminates the connection.
    Call a transaction asynchronally and display it in an amodal window:
    DATA: MSG_TEXT(80) TYPE C. "Message text
    Asynchronous call to transaction SM59 ->
    Create a new session
    CALL FUNCTION ‘ABAP4_CALL_TRANSACTION’ STARTING NEW TASK ‘TEST’
    DESTINATION ‘NONE’
    EXPORTING
    TCODE = ‘SM59’
    EXCEPTIONS
    COMMUNICATION_FAILURE = 1 MESSAGE MSG_TEXT
    SYSTEM_FAILURE = 2 MESSAGE MSG_TEXT
    IF SY-SUBRC NE 0.
    WRITE: MSG_TEXT.
    ELSE.
    WRITE: ‘O.K.’
    ENDIF.
    You must not use IMPORTING when calling aRFCs.
    Transactional Remote Function Calls
        RfcInstallTransactionControlinstalls four functions to control transactional behaviour.
        RFC_ON_CHECK_TIDis called when a local transaction is starting.
        RfcCreateTransID Get a unique transaction-ID for calling an
        ABAP function module using the transactional RFC Interface
        RfcIndirectCall Call an ABAP function module using the
        transactional RFC Interface
        RFC_ON_COMMIT is called when a local transaction ends.
        RFC_ON_CONFIRM_TID is called when a local transaction is
        completed.
        RFC_ON_ROLLBACK is call
    ed when a local transaction ends with
    failure.
    RFC_ONCALL
    INCLUDE AND MACROS:
    When you modularize source code, you place a sequence of ABAP statements in a module. Then, instead of placing all of the statements in your main program, you just call the module.
    Include programs are global R/3 Repository objects. They are solely for modularizing source code, and have no parameter interface.
    They have the following functions:
    Library:Include programs allow you to use the same source code in different programs. For example, this can be useful if you have lengthy data declarations that you want to use in different programs. 
    Order. Include programs allow you to manage complex programs in an orderly way. Function groups and module pools use include programs to store parts of the program that belong together. The ABAP Workbench supports you extensively when you create such complex programs by creating the include programs automatically and by assigning them unique names.
    Creating Your Own Include Programs
    If you create an include program yourself, you must assign it the type I in its program attributes.
    An include program cannot run independently, but must be built into other programs. Include programs can contain other includes.
    The only restrictions for writing the source code of include programs are:
    Include programs cannot call themselves.
    Include programs must contain complete statements.
    The INCLUDE statement has the same effect as copying the source code of the include program into the program. In the syntax check, the contents of the include program are also analyzed. Include programs are not loaded at runtime, but are expanded when the program is generated. Once the program has been generated, the load version contains static versions of all of its includes. If you subsequently change an include program, the programs that use it are automatically regenerated.
    ***INCLUDE STARTTXT.
    WRITE: / 'Program started by', SY-UNAME,/ 'on host', SY-HOST, 'date:', SY-DATUM, 'time:', SY-UZEIT.ULINE.
    We can then include this program in any other ABAP program to display a standard list header.
    PROGRAM SAPMZTST.INCLUDE STARTTXT.
    This could produce the following output:
    Program started by KELLERH
    on host ds0025 date: 03/19/1998 time: 09:00:39
    Macros
    If you want to reuse the same set of statements more than once in a program, you can include them in a macro. For example, this can be useful for long calculations or complex WRITE statements. You can only use a macro within the program in which it is defined, and it can only be called in lines of the program following its definition.
    The following statement block defines a macro :
    DEFINE .
    END-OF-DEFINITION.
    Macros do not belong to the definition part of the program. This means that the DEFINE...END-OF-DEFINITION block is not interpreted before the processing blocks in the program. At the same time, however, macros are not operational statements that are executed within a processing block at runtime. When the program is generated, macro definitions are not taken into account at the point at which they are defined
    A macro definition inserts a form of shortcut at any point in a program and can be used at any subsequent point in the program. As the programmer, you must ensure that the macro definition occurs in the program before the macro itself is used. Particular care is required if you use both macros and include programs, since not all include programs are included in the syntax check (exception: TOP include).
    To use a macro, use the following form:
    When the program is generated, the system replaces by the defined statements and each placeholder &i by the parameter
    . You can use macros within macros. However, a macro cannot call itself.
    DATA: RESULT TYPE I,N1 TYPE I VALUE 5,N2 TYPE I VALUE 6.
    DEFINE OPERATION. RESULT = &1 &2 &3.OUTPUT &1 &2 &3 RESULT.END-OF-DEFINITION.
    DEFINE OUTPUT. WRITE: / 'The result of &1 &2 &3 is', &4.END-OF-DEFINITION.
    OPERATION 4 + 3.OPERATION 2 ** 7.OPERATION N2 - N1.
    The produces the following output:
    The result of 4 + 3 is 7
    The result of 2 ** 7 is 128
    The result of N2 - N1 is 1
    Inserting the macro changes nothing in the generated form of the program.
    Check this link
    http://www.sapbrainsonline.com/FAQs/TECHNICAL/SAP_ABAP_MODULARIZATION_FAQ.html
    http://help.sap.com/saphelp_40b/helpdata/en/9f/db970e35c111d1829f0000e829fbfe/content.htm
    http://help.sap.com/saphelp_40b/helpdata/en/9f/db970e35c111d1829f0000e829fbfe/content.htm
    Regards
    Pavan
    Message was edited by:
            Pavan praveen
    Message was edited by:
            Pavan praveen

  • Regarding abap Macros

    Hi Experts,
    I am wring the programming in Abap-Hr usnig Macros.
    But my clients requirement is, don't use macros when using LDB's. Is it possible for payroll results.
    By using the macro
    RP_PROVIDE_FROM_LAST P0002 SPACE LOW-DATE HIGH-DATE
    what is the alternative of this macro by retrieving the data from infotype based on PERNR.
    thanks in advance.
    Sai
    Edited by: Sai Babu on Nov 21, 2008 8:19 AM

    Hi
    You can use HR_READ_INFOTYPE function module to read latest record of an employee.
    pass system date (sy-datum) in importing parameters validbegin and validend.
    Thanks
    Vishal Kapoor

  • Help needed in Macro

    Hello Experts,
    I am creating a macro, where the requirement is; user would select few columns of a KF & hit on a macro.
    The values in the KF should get multiplied by 2.
    Any clue how should I add ( *2) functionality in operation / function ?. Any other suggestion is welcomed.
    Please help
    Regards
    Rahul Chitte

    Hi Rahul,
    You can set the macro to run for few period.
    1)  In the step of the macro, select the period you want to run
    2) Within the step, Results row (Key figure row 'XXX") = Key figure row 'XXX" * 2 (remember to maintain a space between * and 2)
    3) Check the macro for any error, which would help you for any inconsistencies
    4) activate the macro to test your requirement.
    hope this would solve your requirment.
    Regards,
    Nawanit

  • How to call HR Macros in ABAP-Webdynpro

    HI all,
    I want to extract HR data in webdynpro view.
    Where should I give Logical Database PNP?
    The ifnotypes key word is not accepting in Webdynpro coding?
    Where should I give GET PERNR event in Webdynpro?
    When I use RP_PROVIDE_FROM_LAST .... says error message
    Statement "RP_PROVIDE_FROM_LAST" is not defined. Check your spelling .
    How to use the Macros in Webdynpro (VIEW) methods.
    First time I'm working in ABAP-HR Webynpro.
    Please help me out..
    Thanks,
    Prasad

    Hi,
    How did u  solve this? pls provide the solution.
    Regards,
    Lakshmi.

  • Can I launch a Macro from an IF statement in a Bus. Rule?

    I am trying to write IF logic in a business rule to run a macro based on a Planning form-driven variable. However, my rule will not validate. For example:
    IF([variable] == 'Budget')
    %MYBUDGETMACRO(parm1, parm2, parm3);
    ELSE
    %MYOTHERMACRO (parm1, parm2, parm3);
    ENDIF
    Is it possible to do this? Thank you -

    I wrote this used-to-make-sense-but-now-just-tests-a-concept code (coming to a blog post soon, oooh, I know you can hardly wait): <--Sarcasm
    FIX("Local", [varGlblYear], [varGlblScenario], [varGlblVersion])
         /*     Call macro to do focused Aggregation     */
         "Local"
              IF(@ISMBR("Local"))
                   "Local" = #Missing ;
              ENDIF
    ENDFIX /*     FIX("Local", [varGlblYear], [varGlblScenario], [varGlblVersion])     */And it validated just fine.
    So I created a one line macro that has this code:
    "Local" = Missing ;And then called it in an IF statement:
    FIX("Local", [varGlblYear], [varGlblScenario], [varGlblVersion])
         /*     Call macro to do focused Aggregation     */
         "Local"
              IF(@ISMBR("Local"))
                   %mcrConsHBRLocalEqualsMissing()
              ENDIF
    ENDFIX /*     FIX("Local", [varGlblYear], [varGlblScenario], [varGlblVersion])     */HBR won't even let me validate it but throws an:
    Encountered " <MACRO> "%
    mcrConsHBREqualsMissing "" at line 19, column
    35
    blah
    blah
    blah
    If I get rid of the IF statement and just do this:
    FIX("Local", [varGlblYear], [varGlblScenario], [varGlblVersion])
         /*     Call macro to do focused Aggregation     */
         "Local"
              %mcrConsHBRLocalEqualsMissing()
    ENDFIX /*     FIX("Local", [varGlblYear], [varGlblScenario], [varGlblVersion])     */It still fails.
    So then I wrote this:
    FIX("Local", [varGlblYear], [varGlblScenario], [varGlblVersion])
         /*     Call macro to do focused Aggregation     */
         %mcrConsHBRLocalEqualsMissing()
    ENDFIX /*     FIX("Local", [varGlblYear], [varGlblScenario], [varGlblVersion])     */Sucess!!! Boil in bag! (That's a Network54 joke, btw.)
    So the issue isn't the IF statement, it's the calc block. You cannot insert macros into calc block statements. And since a calc block statement is required for using IF, a macro can't be used within an IF.
    Regards,
    Cameron Lackpour

  • How to upload data from excel to SAP using VB script or Macros

    Hi Guys,
    I want to make a macro enabled Excel sheet which  i can use to upload huge data on SAP . I read some discussion but didnt get anything. Please help me with a step by step document.

    Hi,
    Please refer below link.
    Need help from Excel and SAP expert! [SOLVED]
    http://visualbasic.ittoolbox.com/groups/technical-functional/vb-vba-l/call-transaction-in-sap-from-excel-vba-macro-and-download-alv-list-object-results-to-spreadsheet-3335996
    Regards,
    Rafi

  • VB Macro in Bex Analyser is taking long time to complete execution

    Hi Experts,
    In a FI query , we have a VB macro which update the excel sheets by taking values from the previous excel sheets .
    The issue is its taking long time for query execution and if we are keep on pressing 'ENTER' button . The query is running very fastly and is giving the results ,but its not a correct way to do.
    Its a critical issue in Production and can anyone help me to resolve the issue.
    Regards,
    Anju

    Hi Anju,
    I need to create a VB macro in one of my query but i not familiar how i can plug the VB code into the query.
    Please can you give me some basic procedure on how to do that?
    What i need to do exactly is to bring a KF from a query into another query. Not sure if this is possible using VB.
    Let me know.
    Thanks.
    Cesar

  • Excel spreadsheets with macro's

    Good day
    Excel spreadsheets with macro's created in Windows does not work on my Macbook (excel for mac 2011), even if I enable macro's. I do not create these spreadsheets myself. Cn anyone assist please? Thank you for your time.

    Hi,
    As far as I known, the macro/Active X control can be used well with both of the Office 2013 and Office 365.
    Would you like to share us a sample file that created in Office 2013? I'd like to test it. You can send it via Email ([email protected]).
    If you have any update, please feel free let us know.
    ===========
    Update:
    I have received your mail and
    attachment. Then, I tested it, I found the probably reason.
    You were using ActiveX controls in the sample file, and them displayed 4 tabs in Format control dialog box. Next, you created a new Form control, it displayed 7 tabs.
    You were using the two type of controls. ActiveX controls and Form controls
    are different.
    Form controls
    Form controls are the original controls that are compatible with earlier versions of Excel, starting with Excel version 5.0. Form controls are also designed for use on XLM macro sheets.
    ActiveX controls
    ActiveX controls can be used on worksheet forms, with or without the use of VBA code, and on VBA UserForms. In general, use ActiveX controls when you need more flexible design requirements than those provided by Form controls. ActiveX controls have extensive
    properties that you can use to customize their appearance, behavior, fonts, and other characteristics.
    For more detail information, please refer to the following link:
    https://support.office.microsoft.com/en-us/article/Overview-of-forms-form-controls-and-ActiveX-controls-on-a-worksheet-d101804a-0f84-43ad-8cb2-e19277b8e3fb?CorrelationId=0e7129b7-8ea2-458c-af14-a99292d300b9&ui=en-US&rs=en-US&ad=US
    Hope it's helpful.
    Regards,
    George Zhao
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
    programs.

Maybe you are looking for

  • CLOB datatype to varchar

    Hi folks I have two columns which I am querying and they are both of datatype CLOB and which I bring my sql in my development environment these two columns are being displayed as nulls eventhough my sql works fine in Toad env. So, I'm pretty sure its

  • Can not print text file.

    I have a problem since I upgrade to 10.6.7. All text file, including docx, pdf, and so on, can not be printed. Only the image file can be printed correctly. Here is a report: Process: cupstomcdufr2 [7642] Path: /Library/Printers/Canon/UFR2/Cores/cups

  • Pops and Clicks and Delays with X-Fi Fatal1ty Platinum in Windows 7 32bit

    Hi, I own an x-fi fatalty platinum sound card and I have installed the beta driver for Windows 7 32bit. When doing things in the OS, i get occasional pops and clicks. I know exactly what it comes from, it happens when there are multiple sounds being

  • What is link of Service Conditions for PO which is stored in KONV table?

    Hi Gurus, I want to fetch the details of Service Condition for a particular line item, i have found the entry in KONV table by searching on amount. Do you know how Service Conditions are stored in KONV and how they can be linked to a purchase order?

  • URGENT:Convert a Single Struts Project to Multiple Struts - 10g

    Hello, Currently, I have a single Struts config file. Can i Add more projects and convert it to a multiple struts config project. I followed the multiple struts config file in http://www.oracle.com/technology/products/jdev/howtos/10g/StrutsMultiConfi