2007 Jan 05 8:37 PM
Hello friends,
I am writing a interactive report and am using at first,
i am writing a perform statement with in a loop...endloop. and i am using my at first in the perform statement.
It comes with an error saying that at first should be within a loop ...endloop.
LOOP AT IT_OUT.
PERFORM REPORT_OUTPUT.
ENDLOOP.
FORM REPORT_OUTPUT .
MOVE IT_OUT TO WA_OUT.
AT FIRST.
FORMAT COLOR 5 ON.
WRITE:/1 'Invoice #',15 'Principal #',30 'SAP Customer #',
40 'Customer Name',65 'Material #', 80 'Quantity',
100'Net Amount', 120'Promo / Non-Promo'.
FORMAT COLOR 5 OFF.
SKIP 1.
ENDAT.
ENDFORM. " F2010_WRITE_REPORT_OUTPUT
aNY SUGGESTIONS.
2007 Jan 05 8:39 PM
Hi,
You cannot use AT FIRST in subroutines..
INstead try this logic..Marked in bold..
LOOP AT IT_OUT.
PERFORM REPORT_OUTPUT.
ENDLOOP.
FORM REPORT_OUTPUT .
<b>STATICS: LV_FLAG TYPE XFELD.</b>
MOVE IT_OUT TO WA_OUT.
<b>IF LV_FLAG IS INITIAL.</b>
FORMAT COLOR 5 ON.
WRITE:/1 'Invoice #',15 'Principal #',30 'SAP Customer #',
40 'Customer Name',65 'Material #', 80 'Quantity',
100'Net Amount', 120'Promo / Non-Promo'.
FORMAT COLOR 5 OFF.
SKIP 1.
<b>ENDIF.
set the flag to not display the above code.
LV_FLAG = 'X'.
</b>
ENDFORM. " F2010_WRITE_REPORT_OUTPUT
Thanks,
Naren
2007 Jan 05 8:39 PM
Hi Madhu,
AT FIRST, AT LAST and AT NEW are control commands. They will work only within LOOP...ENDLOOP.
You need to SORT the intenral table before performing the control command operations.
Declare internal table as global to avoid errors.
Control commands does not work in subroutines.
Thanks,
Vinay
2007 Jan 05 8:39 PM
Hi,
You cannot use AT FIRST in subroutines..
INstead try this logic..Marked in bold..
LOOP AT IT_OUT.
PERFORM REPORT_OUTPUT.
ENDLOOP.
FORM REPORT_OUTPUT .
<b>STATICS: LV_FLAG TYPE XFELD.</b>
MOVE IT_OUT TO WA_OUT.
<b>IF LV_FLAG IS INITIAL.</b>
FORMAT COLOR 5 ON.
WRITE:/1 'Invoice #',15 'Principal #',30 'SAP Customer #',
40 'Customer Name',65 'Material #', 80 'Quantity',
100'Net Amount', 120'Promo / Non-Promo'.
FORMAT COLOR 5 OFF.
SKIP 1.
<b>ENDIF.
set the flag to not display the above code.
LV_FLAG = 'X'.
</b>
ENDFORM. " F2010_WRITE_REPORT_OUTPUT
Thanks,
Naren
2007 Jan 05 8:42 PM
Naren,
In my report I will be using At first, At new, at last all the control statements.
I guess your logic would only work for At first. IS it?
MAdhu.
2007 Jan 05 8:42 PM
Hi Madhu,
I don't think you can do perform for at statement.
Try to eliminate perform.
LOOP AT IT_OUT.
MOVE IT_OUT TO WA_OUT.
AT FIRST.
FORMAT COLOR 5 ON.
WRITE:/1 'Invoice #',15 'Principal #',30 'SAP Customer #',
40 'Customer Name',65 'Material #', 80 'Quantity',
100'Net Amount', 120'Promo / Non-Promo'.
FORMAT COLOR 5 OFF.
SKIP 1.
ENDAT.
ENDLOOP.
Regards,
Ferry Lianto
2007 Jan 05 8:48 PM
Hi,
Yes..My logic will work only for AT FIRST..
But if want it to work for AT NEW ..as well..I would suggest don't use subroutine....otherwise you need to little more logic in my previous post to make it work..
LOOP AT IT_OUT.
MOVE IT_OUT TO WA_OUT.
AT FIRST.
FORMAT COLOR 5 ON.
WRITE:/1 'Invoice #',15 'Principal #',30 'SAP Customer #',
40 'Customer Name',65 'Material #', 80 'Quantity',
100'Net Amount', 120'Promo / Non-Promo'.
FORMAT COLOR 5 OFF.
SKIP 1.
ENDAT.
ENDLOOP.
Thanks,
Naren
2007 Jan 05 8:53 PM
You can still modularize your coder and use the AT statements, you must need to make sure that the AT statements are in the LOOP and outside the FORMS. Like so....
LOOP AT IT_OUT.
AT FIRST.
PERFORM REPORT_OUTPUT.
ENDAT.
ENDLOOP.
FORM REPORT_OUTPUT .
MOVE IT_OUT TO WA_OUT.
FORMAT COLOR 5 ON.
WRITE:/1 'Invoice #',15 'Principal #',30 'SAP Customer #',
40 'Customer Name',65 'Material #', 80 'Quantity',
100'Net Amount', 120'Promo / Non-Promo'.
FORMAT COLOR 5 OFF.
SKIP 1.
ENDFORM. " F2010_WRITE_REPORT_OUTPUT
Regards,
Rich Heilman
2007 Jan 05 8:51 PM
Can't you do something like this?
LOOP AT IT_OUT.
AT FIRST.
PERFORM REPORT_OUTPUT.
ENDAT.
ENDLOOP.
FORM REPORT_OUTPUT .
MOVE IT_OUT TO WA_OUT.
FORMAT COLOR 5 ON.
WRITE:/1 'Invoice #',15 'Principal #',30 'SAP Customer #',
40 'Customer Name',65 'Material #', 80 'Quantity',
100'Net Amount', 120'Promo / Non-Promo'.
FORMAT COLOR 5 OFF.
SKIP 1.
ENDFORM. " F2010_WRITE_REPORT_OUTPUT