cancel
Showing results for 
Search instead for 
Did you mean: 

Subtotal with Table Node in smartforms

Former Member
0 Kudos

Hi All

I am working with 4.6 C Smartform Table node , How do i print the subtotal value of itab-lfimg just beginng of new Carton No printing (another field in itab) (similar to AT END OF cartno. ENDAT.) .

Please throw some light on this .

Thanks

Jaman

Accepted Solutions (1)

Accepted Solutions (1)

jayanthi_jayaraman
Active Contributor
0 Kudos

Hi,

You need to use calculation tab in table.

In table,create sort of begin and sort of end based on the field.This should be done in data tab.

In calculations

operation total

fieldname workarea-field

targetfieldname variable holding subtotal

time afterloop

reset sortcriterion

for fieldname pernr

In event on sort end,display the variable using text eleemnt.

Kindly reward points by clicking the star on the left of reply,if it helps.

Former Member
0 Kudos

Hi Jayanthi

But i am into 4.6 C version where we dont have Calculation tab.

Regards

Jaman

Message was edited by:

ABAP SD/CRM

Former Member
0 Kudos

Hi,

jayanthi jayaraman is talking about the fied tabs that are available in the table .

jst check them its simple and they logic provided by her is absolutely right.

Former Member
0 Kudos

How can i achieve this following peice of code below with my TABLE node in Smartform ....

At end of each diff carton no ,,i want to print the subtotal of few fields as part of my final internal table being looped thru in the Table node .....

At the end of all records printed ,i need to print Grand total of those few feilds also ........Please guid..as i dont have CALCULATION tab with 4.6C version....

Below is the <b>SAPscript</b> code to be converted to Smartforms

LOOP AT restab.

AT NEW cartno.

ws-crt = ws-crt + 1.

ws-stotnw = 0.

ws-stotgw = 0.

READ TABLE icawn INTO cawn_wa WITH KEY

atwrt = restab-pck_code BINARY SEARCH.

IF sy-subrc = 0.

READ TABLE icawnt INTO cawnt_wa WITH KEY

atzhl = cawn_wa-atzhl BINARY SEARCH.

ENDIF.

ENDAT.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

element = 'ITEMS'

  • 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

OTHERS = 9

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

ws-stotnw = ws-stotnw + restab-kcntgew.

ws-stotgw = ws-stotgw + restab-kcbrgew.

ws-totlfi = ws-totlfi + restab-lfimg.

AT END OF cartno.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

element = 'STOTAL'

  • 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

OTHERS = 9

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

ws-gtotnw = ws-gtotnw + ws-stotnw.

ws-gtotgw = ws-gtotgw + ws-stotgw.

ENDAT.

ENDLOOP.

CALL FUNCTION 'WRITE_FORM'

EXPORTING

element = 'GTOTAL'

  • 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

OTHERS = 9

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

*&----


Message was edited by:

ABAP SD/CRM

Message was edited by:

ABAP SD/CRM

Message was edited by:

ABAP SD/CRM

Message was edited by:

ABAP Techie<b></b>

Message was edited by:

ABAP Techie

Message was edited by:

ABAP Techie

Former Member
0 Kudos

Hi,

i havent gone thru the code but i wonderd as to y there is write_form in the logic.

u dont require any of there here .its a simple logic which says keep adding a variable till the end of a page and print it.

and at the start of new page page clear that variable explicitly and add with new values.

this is a quite simple logic and is applied everty where

hope u understand this.

Former Member
0 Kudos

Hi Abaper,

I'll give you simple solution but this is not optimal.. why iam telling this is i think u r facing dificulty id the logic told by jayanthi..

do as follow s Cteratemparary table.. move the output data into it. then clear the Out put table..

loop at the temparary table..

appent the temparaary table recorrd by record.

at end of the "fiied you reuire"

Sum.

append the onyt the the field witch you want to output table clear the restof the field.

end loop.

now you have the out put table with all the records and as well as the records with Total..

Print the new output table as it is.. it will display the REcords and the totals.

<b>Close this thread if when u r problem ise solved

Regards

Naresh Reddy K</b>

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Just add a programming lines node in the table node where u put the text node of that particular field finally u print it in the footer. U just need to write the logic in the programming lines.

sub = sub + <field>.

regards,

Aravind

Former Member
0 Kudos

HI ,

Check

Suggest you to <b>Search in SDN with key - Subtotal in Smartforms</b>

Will get few more useful related Posts.

Reward points if this Helps.

Manish