Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

interactive report

Former Member
0 Kudos
118

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.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
94

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

7 REPLIES 7

Former Member
0 Kudos
94

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

Former Member
0 Kudos
95

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

0 Kudos
94

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.

ferry_lianto
Active Contributor
0 Kudos
94

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

Former Member
0 Kudos
94

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

0 Kudos
94

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

Former Member
0 Kudos
94

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