2009 Dec 13 1:03 PM
I have searched the sdn about the macro ,but i have found nothing valuable information. so i have to post a message for help again. the situation is :
DEFINE assign_comp.
fld = &2.
translate fld to upper case.
assign component fld of structure &1 to &3.
END-OF-DEFINITION.
FIELD-SYMBOLS:<zmst_rec> TYPE any,
<int_table> TYPE SORTED TABLE,
<tmp_table> TYPE SORTED TABLE.
FIELD-SYMBOLS:<fs>,<fs_1>.
SELECT * FROM ( ) INTO TABLE <tmp_table> .
LOOP AT <tmp_table> INTO <zmst_rec>.
assign_comp <zmst_rec>:dateto <fs_1>,datefrom <fs_2>.
ENDLOOP.
My doubt is the macro defined 3 parameters ,but the way which is assigned ....i can't understand. why use a colon,and does it mean pass dateto to datefrom ? and anybody can tell me the reason, thanks much.
Hi junchuan,
my first recommendation is not to use macros. Yo can not debug them and they decrease heavily the readability of code. Macros replace the source code at compile-time.
The second ist: Please post code using the above <_> code markup to enhance readability.
And then the colon: This is SAP BASICS. Using a colon after a statement will repeat the statement for all elements in the comma-separeated list behind.
assign_comp <zmst_rec>:dateto <fs_1>,datefrom <fs_2>.is equal to
assign_comp <zmst_rec> dateto <fs_1>.
assign_comp <zmst_rec> datefrom <fs_2>.A necessary precondition is that datefrom and dateto are char variables containing the strings 'DATEFROM' and 'DATETO'. Otherwise this will not work.
The macro
DEFINE assign_comp.
fld = &2.
translate fld to upper case.
assign component fld of structure &1 to &3.
END-OF-DEFINITION.going through the compile-time macro substitution will create
translate dateto to upper case."which makes no sense at all in your case
assign component dateto of structure <zmst_rec> to <fs_1>.
translate datefrom to upper case."which makes no sense at all in your case
assign component datefrom of structure <zmst_rec> to <fs_2>.Just to have maximum transparency, I would probably write
ASSIGN COMPONENT:
'DATETO' OF STRUCTURE <zmst_rec> to <fs_1>,
'DATEFROM' OF STRUCTURE <zmst_rec> to <fs_2>.Less is more.
Regards,
Clemens
2009 Dec 13 1:55 PM
Hi junchuan,
my first recommendation is not to use macros. Yo can not debug them and they decrease heavily the readability of code. Macros replace the source code at compile-time.
The second ist: Please post code using the above <_> code markup to enhance readability.
And then the colon: This is SAP BASICS. Using a colon after a statement will repeat the statement for all elements in the comma-separeated list behind.
assign_comp <zmst_rec>:dateto <fs_1>,datefrom <fs_2>.is equal to
assign_comp <zmst_rec> dateto <fs_1>.
assign_comp <zmst_rec> datefrom <fs_2>.A necessary precondition is that datefrom and dateto are char variables containing the strings 'DATEFROM' and 'DATETO'. Otherwise this will not work.
The macro
DEFINE assign_comp.
fld = &2.
translate fld to upper case.
assign component fld of structure &1 to &3.
END-OF-DEFINITION.going through the compile-time macro substitution will create
translate dateto to upper case."which makes no sense at all in your case
assign component dateto of structure <zmst_rec> to <fs_1>.
translate datefrom to upper case."which makes no sense at all in your case
assign component datefrom of structure <zmst_rec> to <fs_2>.Just to have maximum transparency, I would probably write
ASSIGN COMPONENT:
'DATETO' OF STRUCTURE <zmst_rec> to <fs_1>,
'DATEFROM' OF STRUCTURE <zmst_rec> to <fs_2>.Less is more.
Regards,
Clemens
2009 Dec 14 2:12 AM
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |