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: 

sapscript

Former Member
0 Kudos

Hi folks,

I need help to define the the following logic:

I have designed the sapscript form to calculate remittance amounts on a monthly basis. At the end of the form I need to display the total amount getting remitted. I have calculated it in the print program. I have defined that field at the FOOTER window on the LAST page.

I believe this works, if the number of records coming from the print program goes beyond the first page, what logic should I need to incorporate if the number of records does not go beyond the first page ? what should i do to display the total amount in the first page itself in such case? How should i take care of it?

Do I need to modify the form or the print program for it?

Any thoughts or ideas shall be very helpful.

Thanks,

SK

1 ACCEPTED SOLUTION

former_member378318
Contributor
0 Kudos

Why do you need a LAST page in this case?

At the end of your first page (or MAIN) have a text element where you check if the page is the last page, if yes then print the total.

16 REPLIES 16

former_member378318
Contributor
0 Kudos

Why do you need a LAST page in this case?

At the end of your first page (or MAIN) have a text element where you check if the page is the last page, if yes then print the total.

0 Kudos

Thanks for the quick reply,

How do you check that? Do you check that in the form or the program?

The components of the page are HEADER and MAIN windows in the FIRST page. Should I need to create an additional text element in the MAIN window itself, I have the table defined in the main window with a table heading.

Could you please elaborate on that?

Thanks,

SK

0 Kudos

I have defined the table in the MAIN within PROTECT and ENDPROTECT tag. Should I declare that text element outside that tag?

Thanks,

SK

0 Kudos

You can check for last page using the following:

/: IF &PAGE& EQ &SAPSCRIPT-FORMPAGES&

/ (print your total here)

/: ENDIF

If you define a window at the bottom of your Main page and insert the above code the total should appear at the end of the last page (even if its the first page).

Hope it helps

0 Kudos

Hi,

Thanks for the reply, I used the same piece of code, but did not work, I believe should be missing something.

Let me explain what I have done, declared another window in the FIRST page called 'FOOTER' then defined an text element within the window, then I entered the piece of code given above,

/E AMT

/: IF &PAGE& EQ &SAPSCRIPT-FORMPAGES&

/H Total Amount Remitted: &out1-total_amt&

/: ENDIF

In the debugger mode, I checked the condition '&PAGE& EQ &SAPSCRIPT-FORMPAGES&' is working after that I do not know what happenned, also i checked the variable out1-total_amt it has amount value in it.

I do not know what am I mssing here? The element is not displaying on the form.

Any help is really appreciated,

Thanks,

SK

0 Kudos

the issue might be window is assigning to page.

so please assign window to next page and see the results.

and also check the amt text element whether it is trigger correct place or not.

Thanks

Seshu

0 Kudos

Here is the funcion module I used to call that window.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

ELEMENT = 'AMT'

  • FUNCTION = 'SET'

  • TYPE = ' '

WINDOW = 'FOOTER'

  • 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.

Am I calling the FOOETR window incorrectly? If so, can anyone help me?

Thanks,

SK

0 Kudos

Okay ,now i got it.

do not use text element in footer window and also comment write_form -> footer.

Now you should get the total in footer window.

Thanks

Seshu

0 Kudos

thanks for the reply,

Here is the issue: The data I populate in the MAIN window, comes from a different internal table. I get the total amount collected stored in a different internal table in the print program. Here is what I do..

perform open_form.

loop at out.

      • populates the records into the table items of the MAIN window

perform write_body.

endloop.

loop at out2.

        • populates the total amt collected and the subroutine total_amt has the FM module declared above for the FOOTER window.

perform total_amt.

endloop.

perform close_form.

I hope you understood my logic, hecne I had to write another FM for it, if this is an incorrect way how can I do it? It is just one value in a separate window, that I am trying to call.

Any inputs is really appreciated.

Thanks,

SK

perform close_form.

0 Kudos

Hello SK,

if you use text element(write_form) for footer window -> you will have to perform complicate logic

best thing would be ..

keep the total amount in one global variable ..

now

use below following logic

/: IF &PAGE& = &SAPSCRIPT-FORMPAGE&

P1 &TOT_AMT&

/: ENDIF.

Here P1 is the paragraph format .&TOT_AMT& - Variable,please keep uppercase in se71

Thanks

Seshu

0 Kudos

Thanks for your continued help here Seshu. I have taken off the text element and now in the FOOTER window, just declared the three lines of code, now I am reading the data in the variable.

How do you call this single variable in the print program?

Thanks

SK

0 Kudos

Okay ,now keep the total amount in one global varaible, you are using open_form or start_form ,here you are mentioning the form name.

so no need to use any write_form here for single variable.

use that variable in footer window directly and you should get it now.

Remember that no need to use write_form here ,there is communication between form and program using open_form or start_form.

Thanks

Seshu

0 Kudos

Sorry for getting back to this a bit late, it did not work. Here is the piece of code I have written in the FOOTER window,

/: IF &PAGE& EQ &SAPSCRIPT-FORMPAGES&

H1 Total Amount Remitted: &V_TOTALAMT&

/: ENDIF

While in the debug mode for the sapscript I found

&PAGE& = 1

&SAPSCRIPT-FORMPAGES& = spacespace1

it did not go through the condition, is the number spacing making the condition false here?

Also checked the value in variable it is coming through fine,

Can anyone tell me what is the mistake am I doing here?

Thanks,

SK

0 Kudos

Code looks good ,did you set page mode ?

if not then set it properly.

if you go pages option at Se71 ,here when you define pages like first page ,next page...

first page - what is mode ? Start mode --

next page - What is mode ? should be INC Mode..

in pages - page - first

next page - should be next page.. ( do it like this )

can you try like this ?

/: IF &PAGE& EQ &<b>SAPSCRIPT-JOBPAGES</b>&

H1 Total Amount Remitted: &V_TOTALAMT&

/: ENDIF

Thanks

Seshu

0 Kudos

The code needed a small tweak,

&PAGE(C)& EQ &SAPSCRIPT-FORMPAGES(C)& in the condition statement, it worked.

Thanks a lot for the help.

SK

Former Member
0 Kudos

HI.

dont take a footer window. instead put it in your main window... it will print at the last.

Thanks

Mahesh