Exporting ALV Report to PDF

There are 2 steps for exporting an ALV report to PDF file.

+ Create a custom function ‘Export to PDF’ button on function toolbar. (See this post to create a custom button: Customizing PF_STATUS – Adding custom function to ALV screen)

+ Handling button click from user.

EXAMPLE PROGRAM

*&———————————————————————*
*& Report Z01_DEMO_ALV_PDF
*&
*&———————————————————————*
*& Programer: Vy Khang Ly
*& Free SAP ABAP Tutorials
*& http://sapforbeginner.com
*&———————————————————————*

REPORT z01_demo_alv_pdf.

TYPE-POOLS: slis. ” SLIS contains all the ALV data types

*&———————————————————————*
*& Data Declaration
*&———————————————————————*

DATA: lt_sflight TYPE TABLE OF sflight.
DATA: lt_fieldcat TYPE slis_t_fieldcat_alv,
ls_fieldcat TYPE slis_fieldcat_alv.
DATA: g_repid TYPE sy-repid.

*&———————————————————————*
*& START-OF-SELECTION
*&———————————————————————*
START-OF-SELECTION.

g_repid = sy-repid.
*&—– Fetch data from the database —–*
SELECT *
UP TO 100 ROWS
FROM sflight
INTO TABLE lt_sflight.

*&—– Field Catalog —–*
ls_fieldcat-fieldname = ‘CARRID’. “Fieldname in the data table
ls_fieldcat-seltext_m = ‘Airline’. “Column description in the output
APPEND ls_fieldcat TO lt_fieldcat.

ls_fieldcat-fieldname = ‘CONNID’.
ls_fieldcat-seltext_m = ‘FLight Number’.
APPEND ls_fieldcat TO lt_fieldcat.

ls_fieldcat-fieldname = ‘FLDATE’.
ls_fieldcat-seltext_m = ‘FLight Date’.
APPEND ls_fieldcat TO lt_fieldcat.

ls_fieldcat-fieldname = ‘PAYMENTSUM’.
ls_fieldcat-seltext_m = ‘Total of current bookings’.
APPEND ls_fieldcat TO lt_fieldcat.

ls_fieldcat-fieldname = ‘CURRENCY’.
ls_fieldcat-seltext_m = ‘Currency’.
APPEND ls_fieldcat TO lt_fieldcat.

** Display ALV
DATA: alv_print TYPE slis_print_alv.
alv_print-no_print_listinfos = ‘X’. “avoid process list on SPOOL

CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
EXPORTING
i_callback_program = sy-repid
it_fieldcat = lt_fieldcat
i_callback_pf_status_set = ‘FORM_MENU’ “GU status form
i_callback_user_command = ‘USER_COMMAND’
is_print = alv_print “to set spool options
TABLES
t_outtab = lt_sflight.

*&———————————————————————*
*& Form FORM_MENU
*&———————————————————————*
* SET Screen
*———————————————————————-*
FORM form_menu USING rt_extab TYPE slis_t_extab.

SET PF-STATUS ‘STANDARD_STATUS’.

ENDFORM. “FORM_MENU
*&———————————————————————*
*& Form USER_COMMAND
*&———————————————————————*
* for to handle user command
*———————————————————————-*

FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
CASE r_ucomm.
WHEN ‘EPDF’. “Function code for export which we created in MENU
**submit the same program in background and store
TYPES: BEGIN OF ty_tsp01,
rqident TYPE tsp01-rqident, ” spool number
rq2name TYPE tsp01-rq2name, ” Spool request: Suffix 2
rqcretime TYPE tsp01-rqcretime, ” User name
END OF ty_tsp01.
DATA: lv_jobcnt TYPE tbtcjob-jobcount, ” job number
lv_jobname TYPE tbtcjob-jobname. ” job name
DATA: lv_len    TYPE i,
ls_param   TYPE rsparams, ” selection work area
ls_tsp01  TYPE ty_tsp01, ” Spool Requests work area
lt_tsp01  TYPE STANDARD TABLE OF ty_tsp01, ” Spool Requests internal table
lt_param   TYPE rsparams_tt. ” Selection table

********** Derive job counter
lv_jobname = ‘ZALV2PDF’. “Background job name
CALL FUNCTION ‘JOB_OPEN’ “open a job
EXPORTING
jobname = lv_jobname
IMPORTING
jobcount = lv_jobcnt
EXCEPTIONS
cant_create_job = 1
invalid_job_data = 2
jobname_missing = 3
OTHERS = 4.
IF sy-subrc EQ 0.

DATA : lv_rqdest TYPE tsp01-rqdest VALUE ‘LP01’,
lv_linsz TYPE sylinsz VALUE ‘9999999’.

SUBMIT (sy-repid) “submit the same program
TO SAP-SPOOL DESTINATION lv_rqdest
LINE-SIZE lv_linsz
IMMEDIATELY ‘X’
KEEP IN SPOOL ‘X’
USER sy-uname VIA JOB lv_jobname NUMBER lv_jobcnt
WITHOUT SPOOL DYNPRO
WITH SELECTION-TABLE lt_param
AND RETURN.

CALL FUNCTION ‘JOB_CLOSE’ “job close
EXPORTING
jobcount = lv_jobcnt
jobname = lv_jobname
strtimmed = ‘X’
EXCEPTIONS
cant_start_immediate = 1
invalid_startdate = 2
jobname_missing = 3
job_close_failed = 4
job_nosteps = 5
job_notex = 6
lock_failed = 7
invalid_target = 8
OTHERS = 9.
IF sy-subrc <> 0.
RAISE job_cannot_be_closed. ” Raise exception
ENDIF.
ELSE.
RAISE job_cannot_be_submitted.
ENDIF.

*********** confirm job status if finished
DATA: lv_job TYPE tbtcv-fin. ” Job status
DO 120 TIMES.
CALL FUNCTION ‘BDL_READ_JOB_STATUS’ “get job status
EXPORTING
jobname = lv_jobname
jobnumber = lv_jobcnt
IMPORTING
jobstatus = lv_job
EXCEPTIONS
job_not_found = 1
OTHERS = 2.
IF lv_job NE ‘F’. “job finished
WAIT UP TO 1 SECONDS.
CONTINUE.
ELSE.
EXIT.
ENDIF.
ENDDO.

**calculate report name in Spool table
DATA: lv_rq2name TYPE tsp01-rq2name. ” Spool request
DATA: lv_tmp(14) TYPE c, ” temp
lv_string TYPE string, ” store program name
lv_temp TYPE tsp01-rq2name, ” Spool request
lv_spool TYPE tsp01-rqident. ” spool number

IF lv_job EQ ‘F’. “job finished
lv_len = STRLEN( sy-repid ) .
IF lv_len >= 9 .
CONCATENATE sy-repid+0(9)
sy-uname+0(3) INTO lv_rq2name .
ELSE.
lv_len = 9 – lv_len.
DO lv_len TIMES .
CONCATENATE lv_temp ‘_’ INTO lv_temp .
ENDDO.
CONCATENATE sy-repid lv_temp
sy-uname INTO lv_rq2name .
ENDIF.

*Get spool request from SPOOL table TSP01
SELECT rqident rq2name rqcretime
FROM tsp01
INTO TABLE lt_tsp01
WHERE rq2name = lv_rq2name
AND rqowner = sy-uname .

*sort table to find latest spool no
SORT lt_tsp01 BY rqcretime DESCENDING .

*read table to find latest spool no
READ TABLE lt_tsp01 INTO ls_tsp01 INDEX 1.

*get user desktop
CALL METHOD cl_gui_frontend_services=>get_desktop_directory
CHANGING
desktop_directory = lv_string
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4.
IF sy-subrc <> 0.
* Implement suitable error handling here
lv_string = sy-repid.
ENDIF.
CALL METHOD cl_gui_cfw=>update_view.
CONCATENATE lv_string text-001 INTO lv_string.

*Prepare selection table for PDF download
ls_param-selname = ‘SPOOLNO’.
ls_param-sign = ‘I’.
ls_param-option = ‘EQ’.
ls_param-low = ls_tsp01-rqident.
ls_param-high = ”.
APPEND ls_param TO lt_param.

ls_param-selname = ‘P_FILE’.
ls_param-sign = ‘I’.
ls_param-option = ‘EQ’.
ls_param-low = lv_string.
ls_param-high = ”.
APPEND ls_param TO lt_param.

* Submit to PDF converted and download
SUBMIT rstxpdft4 WITH SELECTION-TABLE lt_param
AND RETURN.
IF sy-subrc <> 0.

MESSAGE ‘PDF convert not possible’ TYPE ‘I’.
ENDIF.
ELSE.
MESSAGE ‘PDF Can not be downloaded, you have selected huge data. Reduce data and try again’ TYPE ‘I’.
ENDIF.
ENDCASE.
ENDFORM. “user command

RESULT

Screen Shot 2014-09-06 at 12.13.11 am Screen Shot 2014-09-06 at 12.13.16 am Screen Shot 2014-09-06 at 12.13.33 am

//
//


(adsbygoogle = window.adsbygoogle || []).push({});

Advertisements

Customising PF-STATUS – Adding custom icon/function in ALV Report

There is two ways to create an PF-STATUS:

1. Create a new PF-STATUS for our customise need

2. Copy status from a standard program and customise it.

 

1. Create a new PF-STATUS for a program

First, go to transaction Menu Painter (SE41). Enter the Program name and the Status name, then click Create button.

Screen Shot 2014-09-05 at 9.58.57 pm

Enter the Short text and choose a Status Type (I demo a normal screen in this case).

Screen Shot 2014-09-05 at 10.01.38 pm

From that window, we can add the customise icon for the application toolbar or adding function key for the standard toolbar. In this tutorial, I will add an function key ‘Export to PDF’ and adding function key F3, F12 and F15 for standard toolbar.

Enter to custom function text ‘EPDF‘ and press Enter. From the pop-up window, choose Static Text Type and press OK.

Screen Shot 2014-09-05 at 2.55.28 pm

On the next pop-up window, enter details for the function text including Icon name (which is stand for the icon that will display in the application.

Screen Shot 2014-09-05 at 2.56.16 pm

Assign the function to a Function Key (a shortcut key). Press Ok, then your customise function icon is created.

Screen Shot 2014-09-05 at 2.56.35 pm

Next step, we assign some function key to standard toolbar.

Screen Shot 2014-09-05 at 2.57.27 pm

Now Save and Activate it, then your PF-STATUS is ready to use.

2. Copy status from a standard program and customise it.

This way is not much different with creating a new PF-STATUS. Go to transaction Menu Painter (SE41). Enter the Program name and the Status name of the standard program, then click Copy Status button on the toolbar.

Screen Shot 2014-09-05 at 9.27.47 pm

Enter our Program name and Status name that we want to create. Then press Copy.Screen Shot 2014-09-05 at 9.28.24 pm

An information, from here we can change the short texts of objects. Press Copy.

Screen Shot 2014-09-05 at 9.28.56 pm

Now we have a new PF-STATUS created from a standard/existing one. From here we can add/remove custom/standard function to our program screen.

Screen Shot 2014-09-05 at 9.38.27 pm

 

Adding PF-STATUS to ALV Report 

After create a custom screen for our program, we will call the PF-STATUS by following code:

CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
     EXPORTING
     i_callback_program = sy-repid
     it_fieldcat = lt_fieldcat
     i_callback_pf_status_set = ‘FORM_MENU’ “GU status form
     TABLES
          t_outtab = lt_sflight.

*&———————————————————————*
*& Form FORM_MENU
*&———————————————————————*
* SET PF-STATUS to ALV Report creating Export PDF Button
*———————————————————————-*
FORM form_menu USING rt_extab TYPE slis_t_extab.
*SET PF STATUS to ALV
SET PF-STATUS ‘STANDARD_STATUS’.
ENDFORM. ” SET_PF_STATUS

RESULT

A new function icon Export to PDF added to the report.Screen Shot 2014-09-05 at 10.31.16 pm

Handling double-click in ALV report

To implement code handling user command from report, we add i_callback_user_command parameter in to REUSE_ALV_GRID_DISPLAY function module. Then we implement HANDLE_USER_COMMAND form for that parameter.

Example Program

*&———————————————————————*
*& Report Z01_DEMO_ALV_DOUBLECLICK
*&
*&———————————————————————*
*& Programer: Vy Khang Ly
*& Free SAP ABAP Tutorials
*& http://sapforbeginner.com
*&———————————————————————*

REPORT Z01_DEMO_ALV_DOUBLECLICK.

TYPE-POOLS: slis. ” SLIS contains all the ALV data types

*&———————————————————————*
*& Data Declaration
*&———————————————————————*

DATA: lt_sflight TYPE TABLE OF sflight.
DATA: lt_fieldcat TYPE slis_t_fieldcat_alv,
   ls_fieldcat TYPE slis_fieldcat_alv.
DATA: lt_excluding TYPE slis_t_extab,
   ls_excluding TYPE slis_extab.
DATA: g_repid TYPE sy-repid.

*&———————————————————————*
*& START-OF-SELECTION
*&———————————————————————*
START-OF-SELECTION.

g_repid = sy-repid.
*&—– Fetch data from the database —–*
SELECT *
FROM sflight
INTO TABLE lt_sflight.

*&—– Field Catalog —–*
ls_fieldcat-fieldname = ‘CARRID’. “Fieldname in the data table
ls_fieldcat-seltext_m = ‘Airline’. “Column description in the output
APPEND ls_fieldcat TO lt_fieldcat.

ls_fieldcat-fieldname = ‘CONNID’.
ls_fieldcat-seltext_m = ‘FLight Number’.
APPEND ls_fieldcat TO lt_fieldcat.

ls_fieldcat-fieldname = ‘FLDATE’.
ls_fieldcat-seltext_m = ‘FLight Date’.
APPEND ls_fieldcat TO lt_fieldcat.

ls_fieldcat-fieldname = ‘PAYMENTSUM’.
ls_fieldcat-seltext_m = ‘Total of current bookings’.
APPEND ls_fieldcat TO lt_fieldcat.

ls_fieldcat-fieldname = ‘CURRENCY’.
ls_fieldcat-seltext_m = ‘Currency’.
APPEND ls_fieldcat TO lt_fieldcat.

CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
EXPORTING
     i_callback_program = sy-repid
     it_fieldcat = lt_fieldcat
     it_excluding = lt_excluding
 i_callback_user_command = ‘HANDLE_USER_COMMAND’
     TABLES
     t_outtab = lt_sflight.

*&———————————————————————*
*& Form HANDLE_USER_COMMAND
*&———————————————————————*
* Handle user command from ALV report
*———————————————————————-*
FORM handle_user_command USING r_ucomm LIKE sy-ucomm “User commands
rs_selfield TYPE slis_selfield. “Field selected

DATA: lv_message TYPE c LENGTH 100.
     CASE r_ucomm.
     WHEN ‘&IC1’. “Double-click command
* Handling when user double click on field.
     IF rs_selfield-fieldname = ‘CARRID’.
     CLEAR lv_message.
     CONCATENATE ‘You double-clicked on Airline:’ rs_selfield-value INTO lv_message SEPARATED BY ‘ ‘.
     MESSAGE lv_message TYPE ‘I’.

     ELSEIF rs_selfield-fieldname = ‘CONNID’.
     CLEAR lv_message.
     CONCATENATE ‘You double-clicked on Flight number:’ rs_selfield-value INTO lv_message SEPARATED BY ‘ ‘.
     MESSAGE lv_message TYPE ‘I’.
     ENDIF.
     ENDCASE.

ENDFORM. “HANDLE_USER_COMMAND

RESULT

Screen Shot 2014-09-05 at 2.07.20 pm

Disable ALV Report Toolbar Icons

To disable icons in ALV Report:

  • We create a ALV Report using Field Catalog
  •  Filling the excluding table with function codes of icons that you want to disable. Then add table to ‘REUSE_ALV_GRID_DISPLAY’.

There are number of icons in ALV report, including the standard icons. We could use the following code to determine the function codes for the current program:

DATA : LT_FUN TYPE TABLE OF RSEUL_FUN.
  CALL FUNCTION 'RS_CUA_GET_STATUS_FUNCTIONS'
    EXPORTING
      LANGUAGE  = 'E'
      PROGRAM   = 'SAPLKKBL'
      STATUS    = 'STANDARD_FULLSCREEN'
    TABLES
      FUNCTIONS = LT_FUN.

Loop in to the table, I have a table of function codes for my program:

%ML
%PC
%SC
%SC+
%SL
&ABC
&ALL
&AQW
&AUF
&AVE
&AVE
&AVR
&CDF
&CFI
&COUNT
&DATA_SAVE
&EB9
&ELP
&ERW
&ETA
&F03
&F12
&F15
&F4
Folder
ICON_EXPORT
ICON_SEARCH
ICON_SEARCH_NEXT
ICON_MAIL
ICON_ABC
ICON_SELECT_ALL
ICON_WORD_PROCESSING
Define totals drilld
ICON_ALV_VARIANT_SAV
Saving…
Mean value
Unfreeze
Freeze to column
Count
ICON_SYSTEM_SAVE
ICON_TABLE_SETTINGS
ICON_SYSTEM_HELP
Layout Management
ICON_SELECT_DETAIL
Back
ICON_CANCEL
Exit
Possible entries
&GRAPH
&IC1
&ILD
&ILT
&INFO
&MAX
&MIN
&OAD
&OAD
&ODN
&OL0
&OLX
&OPT
&OUP
&REFRESH
&RNT
&RNT_PREV
&SAL
&SUM
&UMC
&VEXCEL
&VGRID
&VLOTUS
&XINT
&XXL
ICON_GRAPHICS
ICON_SELECT_DETAIL
ICON_FILTER_UNDO
ICON_FILTER
ICON_INFORMATION
Maximum
Minimum
ICON_ALV_VARIANT_CHO
Choose…
ICON_SORT_DOWN
ICON_ALV_VARIANTS
ICON_VARIANTS
Optimize width
ICON_SORT_UP
ICON_REFRESH
ICON_PRINT
ICON_LAYOUT_CONTROL
ICON_DESELECT_ALL
ICON_INTERMEDIATE_SU
ICON_SUM
ICON_XLS
SAP List Viewer
Lotus 1-2-3
Additional Functions
ICON_XXL

Example Program – Disable ‘Filter’ and ‘Sort’ icon.

*&———————————————————————*
*& Report Z01_DEMO_ALV_FIELDCATALOG
*&

*&———————————————————————*
*&  Programmer: Vy Khang Ly

*&  SAP FREE ABAP TUTORIALS

*&  http://sapforbeginner.com
*&———————————————————————*

REPORT z01_demo_alv_fieldcatalog.

TYPE-POOLS: slis. ” SLIS contains all the ALV data types

*&———————————————————————*
*& Data Declaration
*&———————————————————————*

DATA: lt_sflight TYPE TABLE OF sflight.
DATA: lt_fieldcat TYPE slis_t_fieldcat_alv,
ls_fieldcat TYPE slis_fieldcat_alv,
lt_sort      TYPE slis_t_sortinfo_alv,
ls_sort      TYPE slis_sortinfo_alv.
DATA: lt_excluding TYPE slis_t_extab,
              ls_excluding TYPE slis_extab.
DATA: g_repid TYPE sy-repid.

*&———————————————————————*
*& START-OF-SELECTION
*&———————————————————————*
START-OF-SELECTION.

g_repid = sy-repid.
*&—– Fetch data from the database —–*
SELECT *
FROM sflight
INTO TABLE lt_sflight.

*&—– Field Catalog —–*
ls_fieldcat-fieldname = ‘CARRID’. “Fieldname in the data table
ls_fieldcat-seltext_m = ‘Airline’. “Column description in the output
APPEND ls_fieldcat TO lt_fieldcat.

ls_fieldcat-fieldname = ‘CONNID’.
ls_fieldcat-seltext_m = ‘FLight Number’.
APPEND ls_fieldcat TO lt_fieldcat.

ls_fieldcat-fieldname = ‘FLDATE’.
ls_fieldcat-seltext_m = ‘FLight Date’.
APPEND ls_fieldcat TO lt_fieldcat.

*Calculating total of bookings.
ls_fieldcat-fieldname = ‘PAYMENTSUM’.
ls_fieldcat-seltext_m = ‘Total of current bookings’.
ls_fieldcat-do_sum = ‘X’.
ls_fieldcat-cfieldname = ‘CURRENCY’.
APPEND ls_fieldcat TO lt_fieldcat.

ls_fieldcat-fieldname = ‘CURRENCY’.
ls_fieldcat-seltext_m = ‘Currency’.
APPEND ls_fieldcat TO lt_fieldcat.

*Build a sort catalog to generating sub-total
ls_sort-spos = 1.
ls_sort-fieldname = ‘FLDATE’.
ls_sort-up = ‘X’.
ls_sort-subtot = ‘X’.
APPEND ls_sort TO lt_sort.

*Generating an excluding table containing function codes of icon.
ls_excluding-fcode = ‘&ILT’. ” Function code for Filter icon
APPEND ls_excluding TO lt_excluding.

ls_excluding-fcode = ‘&ODN’. ” Function code for Sort Down icon
APPEND ls_excluding TO lt_excluding.

ls_excluding-fcode = ‘&OUP’. ” Function code for Sort Up icon
APPEND ls_excluding TO lt_excluding.

CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
EXPORTING
it_fieldcat = lt_fieldcat
it_sort = lt_sort
it_excluding = lt_excluding
TABLES
t_outtab = lt_sflight.

Now we compare the Result before and after adding code:

Screen Shot 2014-09-03 at 9.53.50 pm Screen Shot 2014-09-03 at 11.10.39 pm

SAP invests additional $60M in Victoria to support Australian industry in digital transformation

 | SAP – Customer Engagements

Opening of SAP’s innovation centre represents continued commitment to customers and job growth in Victoria through expanded facilities and state-of-the-art support centre.

Building ahead of Australian organisations’ strengthening demand for digital transformation, SAP today opened its innovation centre in Melbourne. The facilities represent an incremental investment in staff and infrastructure in Victoria of $60M over five years.

The SAP innovation centre, located at 484 St. Kilda Road, provides the physical space and technology infrastructure to accommodate the branch’s recent and planned job growth. They also house SAP’s latest mission control centre, one of five state-of-the-art customer support facilities globally. Announced in March of last year and officially launched today, the mission control centre is designed to support SAP’s growing base of customers in Victoria in executing on their digital transformation strategies.

Through its investment, SAP also aims to further contribute to the Victorian economy by building opportunity for its extensive network of local partners and ICT suppliers, who provide implementation and transformation services for organisations throughout Victoria.

Opening the new facilities, the Victorian Minister for Technology Gordon Rich-Phillips welcomed the SAP announcement as another significant international investment in Victoria’s ICT capabilities and skills and a valuable addition to the state’s world-class technology ecosystem.

SAP has grown significantly in Victoria in 2014, ramping up delivery of in-memory database solutions, cloud delivery capability and enterprise mobility, particularly in the energy and natural resource, financial services, retail and public services sectors. Year over year, the company increased revenues 117% in the State.

Investing in the talent to support Australian business

The investment behind the SAP innovation centre is designed to accommodate the branch’s growing employee base, which has increased by 20% since March 2013. According to Justin Williams, General Manager for the Southern Region of SAP Australia and New Zealand’s operations, the company is well on track to fulfilling its plan announced in March 2013 to create 120 jobs in the wider ICT industry in Victoria by October 2014.

This investment in talent is also designed to support business development for local technology and channel partners, whose contribution to SAP’s revenue has grown from 12% in 2013 to 30% in 2014. SAP expects its investment will create significant and continual job growth in Victoria over the next five years.

“More and more organisations in Victoria understand that digital transformation is the key to better serving customers and citizens,” Williams said. “Delivering experiences that surprise and delight consumers is now the benchmark of a truly customer-centric organisation. With our investments in our people, our customers, our partners and our community, SAP is helping organisations throughout Victoria to deliver these experiences and cement their leadership among an increasingly global set of competitors.”

Mission control centre supports Australia’s mission-critical systems

Opened with the innovation centre, the mission control centre in Melbourne now provides more than 85 Australian and 44 international organisations with real-time, around-the-clock access to SAP’s global network of more than 5,600 support and development experts.

Employing 20 staff locally, the mission control centre includes enhanced monitoring systems, video conferencing and telepresence installations to facilitate collaboration with customers, as well as a state-of-the-art government-secure facility to support innovation with federal and state agencies.

The mission control centre also boasts tighter integration between on-premise and cloud support to help customers as they transition to a cloud environment at a pace right for their business and industry.

The investment announcement was made as part of the SAP innovation centre opening in Melbourne. SAP hosted leaders in business, government, and the not-for-profit sector to discuss and develop solutions for the challenges and opportunities in innovation and the future of work in Victoria. Guests also included 15 students from Melbourne-area secondary schools as part of Work Inspiration, a work-experience program developed by The Smith Family, Foundation for Young Australians and NAB, designed to inspire the next generation of Australia’s workforce.

About SAP
As market leader in enterprise application software, SAP (NYSE: SAP) helps companies of all sizes and industries run better. From back office to boardroom, warehouse to storefront, desktop to mobile device – SAP empowers people and organizations to work together more efficiently and use business insight more effectively to stay ahead of the competition. SAP applications and services enable more than 261,000 customers to operate profitably, adapt continuously, and grow sustainably. For more information, visit www.sap.com.

Any statements contained in this document that are not historical facts are forward-looking statements as defined in the U.S. Private Securities Litigation Reform Act of 1995. Words such as “anticipate,” “believe,” “estimate,” “expect,” “forecast,” “intend,” “may,” “plan,” “project,” “predict,” “should” and “will” and similar expressions as they relate to SAP are intended to identify such forward-looking statements. SAP undertakes no obligation to publicly update or revise any forward-looking statements. All forward-looking statements are subject to various risks and uncertainties that could cause actual results to differ materially from expectations. The factors that could affect SAP’s future financial results are discussed more fully in SAP’s filings with the U.S. Securities and Exchange Commission (“SEC”), including SAP’s most recent Annual Report on Form 20-F filed with the SEC. Readers are cautioned not to place undue reliance on these forward-looking statements, which speak only as of their dates.

© 2014 SAP SE. All rights reserved.
SAP and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP SE in Germany and other countries. Please seehttp://www.sap.com/corporate-en/legal/copyright/index.epx#trademark for additional trademark information and notices.

Generating total and subtotal (including currency wise total) in ALV report

To add a total or sub-total to an ALV report, we create a field catalog for the report (see Field Catalog in ALV), then we set the field DO_SUM of field catalog for the field that we want to calculate.

Example Program – Adding Total in ALV

*&———————————————————————*
*& Report Z01_DEMO_ALV_FIELDCATALOG
*&
*&———————————————————————*
*&  Programmer: Vy Khang Ly

*&  SAP FREE ABAP TUTORIALS

*&  http://sapforbeginner.com
*&———————————————————————*

REPORT Z01_DEMO_ALV_FIELDCATALOG.

TYPE-POOLS: slis. ” SLIS contains all the ALV data types

*&———————————————————————*
*& Data Declaration
*&———————————————————————*

DATA: lt_sflight    TYPE TABLE OF sflight.
DATA: lt_fieldcat TYPE slis_t_fieldcat_alv,
             ls_fieldcat TYPE slis_fieldcat_alv.
DATA: g_repid    TYPE sy-repid.

*&———————————————————————*
*& START-OF-SELECTION
*&———————————————————————*
START-OF-SELECTION.

g_repid = sy-repid.
*&—– Fetch data from the database —–*
SELECT *
     FROM sflight
     INTO TABLE lt_sflight.     

*&—– Field Catalog —–*
ls_fieldcat-fieldname = ‘CARRID’. 
ls_fieldcat-seltext_m = ‘Airline’. 
APPEND ls_fieldcat TO lt_fieldcat.

ls_fieldcat-fieldname = ‘CONNID’.
ls_fieldcat-seltext_m = ‘FLight Number’.
APPEND ls_fieldcat TO lt_fieldcat.

ls_fieldcat-fieldname = ‘FLDATE’.
ls_fieldcat-seltext_m = ‘FLight Date’.
APPEND ls_fieldcat TO lt_fieldcat.

*Calculating total of bookings.
ls_fieldcat-fieldname = ‘PAYMENTSUM’.
ls_fieldcat-seltext_m = ‘Total of current bookings’.
ls_fieldcat-do_sum = ‘X’.
APPEND ls_fieldcat TO lt_fieldcat.

ls_fieldcat-fieldname = ‘CURRENCY’.
ls_fieldcat-seltext_m = ‘Currency’.
APPEND ls_fieldcat TO lt_fieldcat.

CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
     EXPORTING
          it_fieldcat = lt_fieldcat
     TABLES
          t_outtab = lt_sflight.

At the end of report, we will see the Total is calculated.

Screen Shot 2014-09-03 at 9.05.03 pm

Example Program – Adding Sub-total in ALV

To calculate subtotal in ALV, build sort catalog and set the field SUBTOT of sort catalog to ‘X’.

*&———————————————————————*
*& Report Z01_DEMO_ALV_FIELDCATALOG
*&

*&———————————————————————*
*&  Programmer: Vy Khang Ly

*&  SAP FREE ABAP TUTORIALS

*&  http://sapforbeginner.com
*&———————————————————————*

REPORT Z01_DEMO_ALV_FIELDCATALOG.

TYPE-POOLS: slis. ” SLIS contains all the ALV data types

*&———————————————————————*
*& Data Declaration
*&———————————————————————*

DATA: lt_sflight     TYPE TABLE OF sflight.
DATA:  lt_fieldcat  TYPE slis_t_fieldcat_alv,
               ls_fieldcat TYPE slis_fieldcat_alv,
               lt_sort        TYPE slis_t_sortinfo_alv,
            ls_sort       TYPE slis_sortinfo_alv.
DATA: g_repid      TYPE sy-repid.

*&———————————————————————*
*& START-OF-SELECTION
*&———————————————————————*
START-OF-SELECTION.

g_repid = sy-repid.
*&—– Fetch data from the database —–*
SELECT *
     FROM sflight
     INTO TABLE lt_sflight.

*&—– Field Catalog —–*
ls_fieldcat-fieldname = ‘CARRID’. “Fieldname in the data table
ls_fieldcat-seltext_m = ‘Airline’. “Column description in the output
APPEND ls_fieldcat TO lt_fieldcat.

ls_fieldcat-fieldname = ‘CONNID’.
ls_fieldcat-seltext_m = ‘FLight Number’.
APPEND ls_fieldcat TO lt_fieldcat.

ls_fieldcat-fieldname = ‘FLDATE’.
ls_fieldcat-seltext_m = ‘FLight Date’.
APPEND ls_fieldcat TO lt_fieldcat.

*Calculating total of bookings.
ls_fieldcat-fieldname = ‘PAYMENTSUM’.
ls_fieldcat-seltext_m = ‘Total of current bookings’.
ls_fieldcat-do_sum = ‘X’.
APPEND ls_fieldcat TO lt_fieldcat.

ls_fieldcat-fieldname = ‘CURRENCY’.
ls_fieldcat-seltext_m = ‘Currency’.
APPEND ls_fieldcat TO lt_fieldcat.

*Build a sort catalog to generating sub-total
ls_sort-spos = 1.
ls_sort-fieldname = ‘FLDATE’.
ls_sort-up = ‘X’.
ls_sort-subtot = ‘X’.
APPEND ls_sort TO lt_sort.

CALL FUNCTION ‘REUSE_ALV_GRID_DISPLAY’
     EXPORTING
          it_fieldcat = lt_fieldcat
          it_sort = lt_sort
     TABLES
          t_outtab = lt_sflight.

At the end of report, we will see the Total is calculated. And sorting by each day, there are subtotals of bookings by date. 

Screen Shot 2014-09-03 at 9.12.45 pm

** Normally, there is enough for adding total of any numeric field. But in case of Currency and Quantity, there are determined or sorted by different types of currency and quantity. As the picture above, the total of bookings added without identifying the dependent field. There is an additional code adding to field catalog in this case:

*Calculating total of bookings.
ls_fieldcat-fieldname = ‘PAYMENTSUM’.
ls_fieldcat-seltext_m = ‘Total of current bookings’.
ls_fieldcat-do_sum = ‘X’.
ls_fieldcat-cfieldname = ‘CURRENCY’.
APPEND ls_fieldcat TO lt_fieldcat.

ls_fieldcat-fieldname = ‘CURRENCY’.
ls_fieldcat-seltext_m = ‘Currency’.
APPEND ls_fieldcat TO lt_fieldcat.

And we have another result:

Screen Shot 2014-09-03 at 9.53.50 pm

Now we have a more relevant ALV Report. Applying this rule same on the Quantity fields (Kg vs Lb).