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: 

Script: Sub totals & Grand Totals.(Urgent)

Former Member
0 Kudos

Hi Gurus

im developing a invoice billing. for this i need hw to get sub totals and grand totals at the last page in my main window . what should be given in the text elements and in the SE 38 part.please help me with this its very urgent.

correct answers are fully rewarded.

thanks in advance.

thanks & regards.

sirish.

1 ACCEPTED SOLUTION

naimesh_patel
Active Contributor
0 Kudos

To Dispaly window on the last page, you need to do this:

1. Create a Window type VAR.

Create Text as

/E LAST
*  SUM,,W_SUM

2. To get the SUM of you need to write a code in your program.

LOOP AT ITAB.
  W_SUM = W_SUM + ITAB-NETWR.
  CALL WRITE_FORM FOR MAIN WINDOW
ENDLOOP.

3. Call the LAST window.

CALL WRITE_FORM FOR LAST WINDOW LAST ELEMENT

Regards,

Naimesh Patel

5 REPLIES 5

naimesh_patel
Active Contributor
0 Kudos

To Dispaly window on the last page, you need to do this:

1. Create a Window type VAR.

Create Text as

/E LAST
*  SUM,,W_SUM

2. To get the SUM of you need to write a code in your program.

LOOP AT ITAB.
  W_SUM = W_SUM + ITAB-NETWR.
  CALL WRITE_FORM FOR MAIN WINDOW
ENDLOOP.

3. Call the LAST window.

CALL WRITE_FORM FOR LAST WINDOW LAST ELEMENT

Regards,

Naimesh Patel

0 Kudos

Hi Naimesh,

Thanks for your Quick reply. Can you be more clear about the call function in the program.if any example please put it.And do i need to create another window for the sub total and grand total?

Thanks & Regards

sirish.

0 Kudos

If you want your totals in fixed place than you need to create a new window and element inside it.

If you want just after the finishing of the main data than you can create a element in MAIN window and call it with the call FM WRITE_FORM.

Here is the small example:

DATA: W_SUM TYPE VBRP-NETWR.


START-OF-SELECTION.
  CALL FUNCTION 'OPEN_FORM'
    EXPORTING
      APPLICATION = 'TX'
      DEVICE      = 'PRINTER'
      DIALOG      = 'X'
      FORM        = 'ZTEST_NP'
      LANGUAGE    = SY-LANGU.

  DO 3 TIMES.
    W_SUM = W_SUM + SY-INDEX.  " << sum
    CALL FUNCTION 'WRITE_FORM'
      EXPORTING
        ELEMENT = 'MAIN'
        WINDOW  = 'MAIN'.
  ENDDO.

* Fixed window for SUM
  CALL FUNCTION 'WRITE_FORM'
    EXPORTING
      ELEMENT = 'LAST'
      WINDOW  = 'LAST'.
  IF SY-SUBRC <> 0.
  ENDIF.

  CALL FUNCTION 'CLOSE_FORM'

Regards,

Naimesh Patel

0 Kudos

Hi Naimesh,

Thanks for your very Quick reply again. i hope my problem will b solved

im giving you 10points.But here in the code u said do 3 times . and how to calculate the Grand total.?

Thanks very much Naimesh.

Regards.

sirish

0 Kudos

I just used as a LOOP for my own program.

You have to use your Internal table instead of that DO 3 TIMES.

Hope it is clear now.

Regards,

Naimesh Patel