‎2007 Feb 27 3:21 PM
Hi ,
Plz anyone can give me deatils about MACROS and how to use in Reports, i know bit but still am in confusion.
Thanks in Advance,
sheethal.
‎2007 Feb 27 3:23 PM
hi,
chk out the following code
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.
This 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
‎2007 Feb 27 3:23 PM
hi,
chk out the following code
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.
This 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
‎2007 Feb 27 3:23 PM
Hi,
Macros are like a small subroutine with parameters.
They are defind in table TRMAC.
For more check this link -
<a href="http://help.sap.com/saphelp_erp2005vp/helpdata/en/9f/db972835c111d1829f0000e829fbfe/frameset.htm">Macros</a>
Regards,
Amit
‎2007 Feb 27 3:27 PM
Check this E.g.: Here, the macro returns first and last name based upon uname.
Definition of MACRO
DEFINE get_name.
select single name_first name_last into (lv_name1, lv_name2 )
from user_addr where bname = &1.
if sy-subrc eq 0.
concatenate lv_name1 lv_name2 into &2
separated by space.
else.
&2 = &1.
endif.
END-OF-DEFINITION.
Calling Macro
get_name ls_aend-uname gs_trip_lines-created_by.
Thanks,
Santosh
‎2007 Feb 27 3:39 PM
Hi,
REPORT ZMACRO.
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.
check this link for macros.
http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/db972835c111d1829f0000e829fbfe/content.htm
Regards,
Sruthi
‎2007 Feb 27 3:41 PM
hi,
Check
http://help.sap.com/saphelp_erp2005vp/helpdata/en/9f/db972835c111d1829f0000e829fbfe/frameset.htm
Here is a simple example
PROGRAM ZDATE_VALIDATE .
* Validation of Date
DEFINE VAL_DATE.
CLEAR: %_DATE1,
%_DATE2.
%_DATE1(4) = &1. "Year
%_DATE1+4(2) = &2. "Month
%_DATE1+6(2) = &3. "Date
%_DATE2 = %_DATE1 - 1.
%_DATE2 = %_DATE2 + 1.
IF %_DATE1 <> %_DATE2.
SY-SUBRC = 1.
ELSE.
SY-SUBRC = 0.
ENDIF.
END-OF-DEFINITION.
DEFINE VALDATE.
***************************************************
* Passing Parameters: &1 - Date
* &2 - Date Format
*
* Date Format:
* DDMMYYYY MMDDYYYY YYYYMMDD YYYYDDMM
*
* SY-SUBRC Return Value:
* 1 invalid date
* 0 Valid Date
* 2 Invalid Format
***************************************************
DATA: %_DATE1 LIKE SY-DATUM ,
%_DATE2 LIKE SY-DATUM ,
%_DATE3(8).
case &2.
when 'DDMMYYYY'.
val_date &1+4(4) &1+2(2) &1+0(2).
when 'MMDDYYYY'.
val_date &1+4(4) &1+0(2) &1+2(2).
when 'YYYYMMDD'.
val_date &1+0(4) &1+4(2) &1+6(2).
when 'MMYYYYDD'.
val_date &1+2(4) &1+0(2) &1+6(2).
when others.
sy-subrc = 2.
endcase.
END-OF-DEFINITION.
***********************************************
* SAMPLE USE of above MACRO *
***********************************************
DATA: V_DATE(8).
V_DATE = '30022002'.
*=>
VALDATE V_DATE 'DDMMYYYY'.
*=>
IF SY-SUBRC = 0.
WRITE:/ 'Valid Date'.
ELSEIF SY-SUBRC = 1.
WRITE:/ 'Invalid Date'.
ELSEIF SY-SUBRC = 2.
WRITE:/ 'Invalid Format'.
ENDIF.
Regards,
Santosh
Message was edited by:
Santosh Kumar Patha
‎2007 Feb 27 3:45 PM
check this too..
REPORT ZMACRO.
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.
‎2007 Feb 27 3:46 PM
Check this MACRO written in BADI. If certain condition does not satisfy, we append error message to one of the export structure ET_MESSAGES.
Definition of MACRO
DEFINE conf_acc_errors.
if &1 ne &2.
clear ls_message.
ls_message-msgty = c_error.
ls_message-msgid = c_msgid.
ls_message-item_guid = ls_item-guid.
ls_message-msgno = c_msgno. "&2.
ls_message-msgv1 = &3.
ls_message-msgv2 = &1.
append ls_message to et_messages.
endif.
END-OF-DEFINITION.
Calling MACRO
conf_acc_errors: ls_po_items-ACCTASSCAT ls_pdacc-acc_cat text-t01, "Acct type
ls_po_acct-cost_ctr ls_pdacc-cost_ctr text-t02, "Cost center
ls_po_acct-g_l_acct ls_pdacc-g_l_acct text-t03, "GL account
ls_po_acct-profit_ctr ls_pdacc-profit_ctr text-t07, "profit ctr
ls_po_acct-wbs_elem_e ls_pdacc-wbs_elem_e text-t05. "WBS element
Thanks,
Santosh
‎2007 Feb 27 3:52 PM
HI
GOD
go through this link which ll give you detail about the MACROS
http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/db972835c111d1829f0000e829fbfe/content.htm
THANKS
MRUTYUN^