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: 

scripts

Former Member
0 Kudos

Hi,

Can anyone go thr the SAPhelp for scripts -summing -summing and carrying forward is incorrect.

In that i am not getting the point of defining the var ie where to define.

Regards,

Siri

1 ACCEPTED SOLUTION

kiran_k8
Active Contributor
0 Kudos

Siri,

Please post your question in crystal clear manner

K.Kiran.

10 REPLIES 10

kiran_k8
Active Contributor
0 Kudos

Siri,

Please post your question in crystal clear manner

K.Kiran.

Former Member
0 Kudos

Hi Kiran,

This am not able to understand.

At the beginning of the form main text (before printing the first text element), <u><i>"THIS IS SIRI'S DBT B4 PRNT FIRST TE MEANS IN MY MAIN WINDOW I AM NOT HAVING ANY TE. SO WHERE SHD I NEED TO DEFINE"</i></u>define the amount variable and the total variable (both must be program symbols or Dictionary amount fields).

In the example below, we use the SUMMING command to determine that for each output of &SUMTAB-AMOUNT& the system automatically sums up the amount in the total variable &SUMTAB-TOTAL&. At the end of the page, &SUMTAB-TOTAL& contains the carry forward amount of the current page or the grand total, respectively.

In this example, we also define a local symbol &LASTPAGE& to print the grand total on the last page.

/: SUMMING &SUMTAB-AMOUNT& INTO &SUMTAB-TOTAL&

/: DEFINE &LASTPAGE& = ‘ ‘

At the end of the form main text (when printing the last text element of the main window), set the local textsymbol &LASTPAGE& to a different value, such as ‘X’:

/: DEFINE &LASTPAGE& = ‘X’

To print the carry forward amount in the TOP area of the subsequent page including the pre-text 'Carry forward' and a tab, we use the local text symbol &CARRY. The corresponding text element is also defined in the main window:

/E CARRY

  • &’Carry forward:,,’CARRY&

(CALL FUNCTION WRITE_FORM EXPORTING ELEMENT = ‘CARRY’

TYPE = ‘TOP’)

Define the carry forward window on the current page as type VAR and position it at the end of the main window of the page. Print the carry forward amount there and define the local text symbol &CARRY& to print the amount again in the TOP area of the subsequent page. Use the local text symbol &LASTPAGE& to print the grand total on the last page. The carry forward window then contains the following text (define it as paragraph T1 with tab):

/: IF &LASTPAGE& = ‘X’

T1 <H>Grand total:,,&SUMTAB-TOTAL&</>

/: ELSE

T1 <H>Carry forward:,,&SUMTAB-TOTAL&</>

/: DEFINE &CARRY& = &SUMTAB-TOTAL&

/: ENDIF

kiran_k8
Active Contributor
0 Kudos

K.Kiran.

Message was edited by:

Kiran K

Former Member
0 Kudos

Hi Siri,

You need to define the variable at the begin of the main window, before any of the text-elements.

later use the command /: SUMMING &SUMTAB-AMOUNT& INTO &SUMTAB-TOTAL& at the place where the text element will be fired for the line items printing.

Regards,

Satya

Former Member
0 Kudos

Hi Satya,

In my main window i have given the commands for creating a box where i will display num,name,dob,doj and salary. I didnt created any text ele just printed the data by calling &itab-sno& likewise.

What my requirement is to calculate the total salary for the respective pages and carry forward the total salary of previous page to next and so on and finally to calculate the grand total at the last page.

Now my question is where to define the var as that was explained by u all and which var do i need to define ie in the syntax given

/: summing &sumtab-amount& into &sumtab-total&

is that i have to define sumtab-amount as a var in main window b4 te or any other var.

And one more where do i define the var in main window as i am not having te.

Pls clarify .

Regards,

Siri

Former Member
0 Kudos

Hi,

Please help me out in solving this.

Regards,

Siri

Former Member
0 Kudos

Hi Siri..

In program..

LOOP AT T_EMPLOYEE INTO wa.

ADD 1 TO W_CTR.

W_PTOT = W_PTOT + wa-SALARY. * page total

  • W_GTOT = W_GTOT + wa-SALARY.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'EMPDETAILS'

FUNCTION = 'SET'

TYPE = 'BODY'

WINDOW = 'MAIN'

  • IMPORTING

  • PENDING_LINES =

EXCEPTIONS

ELEMENT = 1

FUNCTION = 2

TYPE = 3

UNOPENED = 4

UNSTARTED = 5

WINDOW = 6

BAD_PAGEFORMAT_FOR_PRINT = 7

SPOOL_ERROR = 8

CODEPAGE = 9

OTHERS = 10

.

IF SY-SUBRC <> 0.

MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

W_CTOT = W_CTOT + wa-SALARY.

ENDLOOP. " LOOP AT T_EMPLOYEE

<b>In form:

Main window:</b>

first statement...must be...

<b> SUMMING &wa-SALARY& INTO &W_GTOT&</b>

and at last in MAin window..

declare element.

/E EMPDETAILS

Former Member
0 Kudos

:SUMMING &NETPR& INTO V_TOTAL

loop

write form for main window

endloop.

For every time(loop pass) the value will be added to v_total ,this will be defined in script.

0 Kudos

Hi,

Can u b clear means where do we need to define that

summing &netpr& into t_val.

in driver prog or form window

Regards,

Siri

0 Kudos

Siri,

summing &netpr& into t_val.

In the window of the script.

K.Kiran.