Building Virtual Provider using Class based approach and BRF+ Integration in Real time Analytical Reporting.
SAP BW Virtual Provider Implementation Class Based Approach with BRF+ Integration
Modifying ABAP Webdynpro's Look and Feel by Changing CSS Files
This guide is for those who want to bring a modern look and feel for the ABAP Webdynpro UI's.
SAP Insider: Will You Be Ready When Opportunity Comes Knocking?
In a world of fast and furious change, companies need to be able to quickly adapt their technology to address new opportunities and surpass the competition. The SAP Custom Development team works with customers to not only address their business needs and provide custom-built solutions, but also help them extend existing solutions to accommodate new business processes.
Recently Featured Content in ABAP Development
SAP TechEd Live Interviews for ABAP Developers
- Deep Dive on SAP HANA Development: For ABAP and Mobile Developers - with SAP Mentors Thomas Jung, Thorsten Franz, and Graham Robinson
- From ABAPer to MOBILEr: The Evolution of Developers - with SAP Mentors Ivan Femia, John Astill, and DJ Adams
Get more interviews and lecture sessions from SAP TechEd Online. January 8, 2012
Optimizing ABAP for SAP HANA: SAP's 3-Step Approach
In this SAPinsider article, you'll learn SAP's three-step approach to optimize SAP NetWeaver Application Server (SAP NetWeaver AS) ABAP for the SAP HANA database. December 26, 2012
ABAP Development Tools: Now you can debug ABAP applications in Eclipse
Want to debug your ABAP applications with native Eclipse debugger directly within the ABAP Development Tools (ADT) for Eclipse? Now it's possible since the availability of the new SAP Kernel 7.21 in combination with SAP Basis 7.31 SP4 (prerequisite for using ADT). Learn the capabilities of the new ABAP debugger in Eclipse also by watching the embedded video. December 3, 2012
SAP Insider: Turbocharge Your ABAP Development with Innovation from Eclipse
With SAP NetWeaver 7.31, support package stack 4, SAP introduces ABAP development tools for SAP NetWeaver, also known as "ABAP in Eclipse," which brings Eclipse capabilities to ABAP Workbench (SE80) functionality. In this SAP Insider article, you'll learn more about ABAP in Eclipse and how it moves ABAP, which is ripe for productivity and usability improvements, into a complementary alignment with SAP's other Eclipse-based development environments. November 26, 2012
Crossing the Great Divide - Procedural vs. OO ABAP Programming
Indulge in this blog by Paul Hardy from Hanson Australia Pty Ltd, as he takes us through his journey from the “old school” (he started procedural programming at age 14) to modern programming techniques. November 6, 2012
A Call to Arms for ABAP Developers
SAP Mentor Graham Robinson shares his concerns for those who have not kept in touch with contemporary development trends including ABAP skills. Read his “call to arms.” October 26, 2012
ABAP Development Tools Tutorials - Learn how to use ABAP in Eclipse
Want to learn fast all new features and capabilities of the ABAP in Eclipse IDE? Just step through the short ABAP Development Tools video tutorials online.October 16, 2012
ABAP Technology @ SAP TechEd 2012
Are you interested in the latest ABAP technology news and visiting one of the upcoming SAP TechEd 2012 events? This blog post gives a brief overview of sessions that might be of interest for you. September 25, 2012
ABAP Test Cockpit – SAP’s new quality assurance tool
Bugs in your custom ABAP code can be quite expensive when they impact critical business processes. Thus, SAP invested in the ABAP Test Cockpit (ATC), SAP’s new quality assurance tool for ABAP. Read this document to learn more about ATC. September 21, 2012
Free Trial on SCN for ABAP in Eclipse
Want to check out ABAP in Eclipse? Simply download the SCN trial version following the ABAP Development Tools for SAP NetWeaver - Trial Version document orvisit the new space focusing on the Eclipse-based ABAP Development Tools for SAP NetWeaver. July 5, 2012
SAP NetWeaver AS ABAP for HANA
ABAP in Eclipse is Here!
ABAP in Eclipse was shipped on 25 June with SAP NetWeaver AS ABAP 7.03/7.31 SP4. Visit the new space focusing on the Eclipse-based ABAP Development Tools for SAP NetWeaver, or “ABAP in Eclipse.” Check out Get Started with ABAP Development Tools for SAP NetWeaver, Working with ABAP Development Tools, and Download and Installation Instructions (SMP login required). June 26, 2012
"Light" Tricks for Building More "Robust" ABAP Code
SAP Mentor Otto Gold shares some thoughts on ABAP coding and general development, and sparks another robust discussion following his blog. Otto offers up more useful tricks in another recent blog, All you need to know about HR-PD Qualifications from the development perspective. June 12, 2012
Modernizing ABAP Development
Questions about code modernization and skills development tend to leave a big footprint on SCN. In this blog, Brian O'Neill of IGT asks how and whether to modernize. June 12, 2012
Customer Feedback on the Pilot Version of the ABAP Development Tools for SAP NetWeaver
Also known as "ABAP in Eclipse," ABAP Development Tools for SAP NetWeaver were part of a customer engagement initiative to evaluate the pilot version. Olga Dolinskaja summarizes the results. May 3, 2012
Developer's Journal: ABAP/HANA Connectivity via Secondary Database Connection
Interested in how to access HANA from your ABAP systems? In his edition of the HANA Developer's Journal Thomas Jung expains how much can be done today when HANA runs as a secondary database for your current ABAP based systems and what development options within the ABAP environment support this scenario. April 23, 2012
The quality of an answer depends significantly on the quality of the question (or: how to ask good questions)
In his post Hermann Gahmgives some useful hints how to ask 'good' questions and especially correct questions regarding ABAP code in order to get an answer of a good quality. April 23, 2012
ABAP Objects: Performance Analysis (SAT) with ABAP Unit
Posted by Bjorn-Henrik Zink. February 2, 2012
How to Do ABAP Nugget Based Code Migration
SAPlink is a project that aims to make it easier to share ABAP developments between programmers. It provides the ability to easily distribute and package custom objects. This article covers ABAP basis versions compatible with SAPlink and how to install the latest version of SAPlink. January 26, 2012
ABAP Keyword Documentation 7.03/7.31
The ABAP Keyword Documentation for Release 7.31 aka 7.03 is online. January 14, 2012
Coding and Performance Tips for New ABAP Programmers
In this blog, SAP Technology Analyst, Nabheet Madan, offers tips for new ABAP programmers who have just developed a few objects. Nabheet looks at fundamentals including documentation and reusable code, naming conventions, maintainability and performance optimization. January 3, 2012
2011
ABAP Trilemma
The ABAP development triangle is a model that describes the trilemma of ABAP development. In this blog, Elvez describes how the ABAP development triangle - performance, security and design - can be used as an agreement between developers on how to prioritize development efforts. December 13, 2011
Featured Content for ABAP Development
ABAP Code Modularization: Lesson Learned
It can’t be all Objects all the time! In this blog, Otto Gold shares tips and best practices on how to structure program code depending on the situation. Mine through the comments section and you’ll find more nuggets of wisdom. Mr. Gold provides more nuggets in “My "light" tricks for building more "robust" ABAP code.”March 22, 2012
How to Create a Watch Point for a Field Symbol in the ABAP Debugger
You can’t create a watch point for a field symbol. You'll get an error.
Try telling that to Brian O'Neill, who said, “Even though I received an error, I do not like being told what I can't do in SAP, so I decided to find a way!” March 18, 2013
ABAP for SAP HANA Fitness Contest at DSAG Technology Days
SAP Mentor Tobias Trapp writes about the ABAP for SAP HANA Fitness Contest at DSAG Technology Days. There 20 customers and partners had the chance to get early insights into what ABAP development on SAP HANA as primary persistence means. March 4, 2013
Upload multiple Records in Select Option
Dear All,
Below code are Example to doble click on Column and Upload what ever you want to in Select Option. Below Code For MRBR. in MRBR directly upload document number which are show in Report just Double click on zreport column-document and upload all document no.
*&---------------------------------------------------------------------*
*& Report ZMRBR_REPORT
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZMRBR_REPORT.
*&---------------------------------------------------------------------*
*& Report ZALDEMO
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
TABLES: bkpf.
type-pools: slis. "ALV Declarations
*Data Declaration
*----------------
TYPES : BEGIN OF ty_final,
belnr TYPE bkpf-belnr,
budat TYPE bkpf-budat,
gjahr TYPE bkpf-gjahr,
cpudt TYPE bkpf-cpudt,
awkey TYPE bkpf-awkey,
END OF ty_final.
TYPES : BEGIN OF ty_final1,
belnr1 TYPE bkpf-belnr,
END OF ty_final1.
data : it_final TYPE STANDARD TABLE OF ty_final,
wa_final TYPE ty_final,
it_final1 TYPE STANDARD TABLE OF ty_final1,
wa_final1 TYPE ty_final1.
*
*ALV data declarations
data: fieldcatalog type slis_t_fieldcat_alv with header line,
gd_tab_group type slis_t_sp_group_alv,
gd_layout type slis_layout_alv,
gd_repid like sy-repid,
gt_events type slis_t_event,
gd_prntparams type slis_print_alv.
************************************************************************
*Start-of-selection.
START-OF-SELECTION.
BREAK 10115.
perform data_retrieval.
if it_final[] IS INITIAL.
MESSAGE 'Data is not found' TYPE 'I'.
LEAVE LIST-PROCESSING.
ENDIF.
perform build_fieldcatalog.
perform build_layout.
perform build_events.
perform build_print_params.
perform display_alv_report.
*
* SELECTION-SCREEN BEGIN OF BLOCK a1 WITH FRAME TITLE text-001 .
* SELECT-OPTIONS s_purch for ekko-ebeln. ""Purchase Document
* SELECT-OPTIONS s_code for ekpo-werks. ""Plant
* SELECT-OPTIONS s_date for ekko-bedat. "Document Date
* SELECT-OPTIONS s_vndr for ekko-lifnr. "Vendor
* SELECT-OPTIONS s_mtnr for ekpo-matkl. "Material Group
* SELECT-OPTIONS s_mat for ekpo-matnr. "Material
* SELECT-OPTIONS S_DAT FOR eket-eindt. "Posting Date
* SELECTION-SCREEN END OF BLOCK a1.
SELECTION-SCREEN BEGIN OF BLOCK a1 WITH FRAME TITLE text-001 .
SELECT-OPTIONS s_doc for bkpf-belnr.
* SELECT-OPTIONS s_year for bkpf-gjahr.
SELECT-OPTIONS s_date for bkpf-budat.
SELECT-OPTIONS s_vndr for bkpf-cpudt.
PARAMETERS s_year LIKE bkpf-gjahr DEFAULT '2012'.
SELECTION-SCREEN END OF BLOCK a1.
*&---------------------------------------------------------------------*
*& Form BUILD_FIELDCATALOG
*&---------------------------------------------------------------------*
* Build Fieldcatalog for ALV Report
*----------------------------------------------------------------------*
form build_fieldcatalog.
* There are a number of ways to create a fieldcat.
* For the purpose of this example i will build the fieldcatalog manualy
* by populating the internal table fields individually and then
* appending the rows. This method can be the most time consuming but can
* also allow you more control of the final product.
* Beware though, you need to ensure that all fields required are
* populated. When using some of functionality available via ALV, such as
* total. You may need to provide more information than if you were
* simply displaying the result
* I.e. Field type may be required in-order for
* the 'TOTAL' function to work.
DATA : RS_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
fieldcatalog-fieldname = 'BELNR'.
fieldcatalog-seltext_m = 'Document NO.'.
fieldcatalog-col_pos = 1.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'GJAHR'.
fieldcatalog-seltext_m = 'Fiscal Year'.
fieldcatalog-col_pos = 2.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'BUDAT'.
fieldcatalog-seltext_m = 'Posting Date'.
fieldcatalog-col_pos = 3.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'CPUDT'.
fieldcatalog-seltext_m = 'Entry Date'.
fieldcatalog-col_pos = 4.
fieldcatalog-outputlen = 10.
fieldcatalog-emphasize = 'X'.
fieldcatalog-key = 'X'.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
fieldcatalog-fieldname = 'AWKEY'.
fieldcatalog-seltext_m = 'Ref Key'.
fieldcatalog-col_pos = 5.
append fieldcatalog to fieldcatalog.
clear fieldcatalog.
endform. " BUILD_FIELDCATALOG
*&---------------------------------------------------------------------*
*& Form BUILD_LAYOUT
*&---------------------------------------------------------------------*
* Build layout for ALV grid report
*----------------------------------------------------------------------*
form build_layout.
gd_layout-no_input = 'X'.
gd_layout-colwidth_optimize = 'X'.
gd_layout-totals_text = 'Totals'(201).
* gd_layout-totals_only = 'X'.
* gd_layout-f2code = 'DISP'. "Sets fcode for when double
* "click(press f2)
* gd_layout-zebra = 'X'.
* gd_layout-group_change_edit = 'X'.
* gd_layout-header_text = 'helllllo'.
endform. " BUILD_LAYOUT
*&---------------------------------------------------------------------*
*& Form DISPLAY_ALV_REPORT
*&---------------------------------------------------------------------*
* Display report using ALV grid
*----------------------------------------------------------------------*
form display_alv_report.
gd_repid = sy-repid.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
i_callback_program = gd_repid
i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
i_callback_user_command = 'USER_COMMAND'
* i_grid_title = outtext
is_layout = gd_layout
it_fieldcat = fieldcatalog[]
* it_special_groups = gd_tabgroup
it_events = gt_events
is_print = gd_prntparams
i_save = 'X'
* is_variant = z_template
tables
t_outtab = it_final
exceptions
program_error = 1
others = 2.
if sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
endform. " DISPLAY_ALV_REPORT
*&---------------------------------------------------------------------*
*& Form DATA_RETRIEVAL
*&---------------------------------------------------------------------*
* Retrieve data form EKPO table and populate itab it_ekko
*----------------------------------------------------------------------*
form data_retrieval.
SELECT belnr
budat
gjahr
cpudt
awkey
FROM bkpf
INTO TABLE it_final
WHERE belnr in s_doc
AND budat in s_date
AND cpudt in s_vndr
AND gjahr = s_year.
delete adjacent duplicates FROM it_final .
BREAK 10115.
LOOP AT it_final INTO wa_final.
wa_final1-belnr1 = wa_final-belnr.
APPEND wa_final1 to it_final1.
ENDLOOP.
* delete adjacent duplicates FROM it_final COMPARING ALL FIELDS.
endform. " DATA_RETRIEVAL
*-------------------------------------------------------------------*
* Form TOP-OF-PAGE *
*-------------------------------------------------------------------*
* ALV Report Header *
*-------------------------------------------------------------------*
Form top-of-page.
*ALV Header declarations
data: t_header type slis_t_listheader,
wa_header type slis_listheader,
t_line like wa_header-info,
ld_lines type i,
ld_linesc(10) type c.
* Title
wa_header-typ = 'H'.
wa_header-info = 'MRBR R BLocke Remover Report'.
append wa_header to t_header.
clear wa_header.
* Date
wa_header-typ = 'S'.
wa_header-key = 'Date: '.
CONCATENATE sy-datum+6(2) '.'
sy-datum+4(2) '.'
sy-datum(4) INTO wa_header-info. "todays date
append wa_header to t_header.
clear: wa_header.
* Total No. of Records Selected
describe table it_final lines ld_lines.
ld_linesc = ld_lines.
concatenate 'Total No. of Records Selected: ' ld_linesc
into t_line separated by space.
wa_header-typ = 'A'.
wa_header-info = t_line.
append wa_header to t_header.
clear: wa_header, t_line.
call function 'REUSE_ALV_COMMENTARY_WRITE'
EXPORTING
it_list_commentary = t_header.
* i_logo = 'Z_LOGO'.
endform. "top-of-page
*------------------------------------------------------------------*
* FORM USER_COMMAND *
*------------------------------------------------------------------*
* --> R_UCOMM *
* --> RS_SELFIELD *
*------------------------------------------------------------------*
*************************Double click Event**************************
*********************************************************************
FORM user_command USING r_ucomm LIKE sy-ucomm
rs_selfield TYPE slis_selfield.
CASE r_ucomm.
WHEN '&IC1'.
* Check field clicked on within ALVgrid report
IF rs_selfield-fieldname = 'AWKEY'.
BREAK 10115.
data: r_belnr type range of awkey,
r_belnr_l like line of r_belnr.
*now in the code replace1 your loop by this:
loop at it_final into wa_final.
r_belnr_l-sign = 'I'.
r_belnr_l-OPTION = 'EQ'.
r_belnr_l-LOW = wa_final-awkey.
r_belnr_l-high = ' '.
append r_belnr_l to r_belnr.
endloop.
SUBMIT RM08RELEASE VIA SELECTION-SCREEN WITH SO_BELNR IN r_belnr AND RETURN.
* LOOP AT it_final INTO wa_final.
ENDIF.
ENDCASE.
ENDFORM.
** Check field clicked on within ALVgrid report
* IF rs_selfield-fieldname = 'AWKEY'.
** Read data table, using index of row user clicked on
* READ TABLE it_final INTO wa_final INDEX rs_selfield-tabindex.
* BREAK 10115.
** Set parameter ID for transaction screen field
* SET PARAMETER ID 'AWK' FIELD wa_final-AWKEY.
* SET PARAMETER ID 'AWK' FIELD wa_final-AWKEY.
** Sxecute transaction MRBR, and skip initial data entry screen
* CALL TRANSACTION 'MRBR' AND SKIP FIRST SCREEN.
* ENDIF.
"user_command
*&---------------------------------------------------------------------*
*& Form BUILD_EVENTS
*&---------------------------------------------------------------------*
* Build events table
*----------------------------------------------------------------------*
form build_events.
data: ls_event type slis_alv_event.
call function 'REUSE_ALV_EVENTS_GET'
EXPORTING
i_list_type = 0
IMPORTING
et_events = gt_events[].
read table gt_events with key name = slis_ev_end_of_page
into ls_event.
if sy-subrc = 0.
move 'END_OF_PAGE' to ls_event-form.
append ls_event to gt_events.
endif.
read table gt_events with key name = slis_ev_end_of_list
into ls_event.
if sy-subrc = 0.
move 'END_OF_LIST' to ls_event-form.
append ls_event to gt_events.
endif.
endform. " BUILD_EVENTS
*&---------------------------------------------------------------------*
*& Form BUILD_PRINT_PARAMS
*&---------------------------------------------------------------------*
* Setup print parameters
*----------------------------------------------------------------------*
form build_print_params.
gd_prntparams-reserve_lines = '3'. "Lines reserved for footer
gd_prntparams-no_coverpage = 'X'.
endform. " BUILD_PRINT_PARAMS
*&---------------------------------------------------------------------*
*& Form END_OF_PAGE
*&---------------------------------------------------------------------*
form END_OF_PAGE.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10) type c.
write: sy-uline(50).
skip.
write:/40 'Page:', sy-pagno .
endform. "END_OF_PAGE
*&---------------------------------------------------------------------*
*& Form END_OF_LIST
*&---------------------------------------------------------------------*
form END_OF_LIST.
data: listwidth type i,
ld_pagepos(10) type c,
ld_page(10) type c.
skip.
write:/40 'Page:', sy-pagno .
endform. "END_OF_LIST
Learning SHD0 with Example
Hello All ,
I would like to share a document with you all which is related to my recent work using SHD0.
This is a very familiar Tcode both used by a Technical and Functional Consultants but if its used correctly and appropriately am sure it can avoid many Enhancement and Modification developments.
And I was not able to find any related documents about this here when I needed that's why I would like to take this opportunity to provide an informative content to our own SCN so that its helpful for all others.
Lets take a very general example of CO11N ( I was to work over this only ).
This tcode is used to confirm Production Order , Production Order indeed contains all BOM related materials required for a Particular Production. Now what happens sometimes end users use to delete or alter these BOM materials and in our company the requirement was to stop this at user ID level.
Usually while using SHD0 everyone use to create a ZTcode for using it , but we can do it without creating a Ztcode which I am going to explain.
Steps :
1. Tcode SHD0
Give Tcode name and Transaction Variant name.
Transaction Variant can contain many Screen Variants inside it.
With the press of Enter it will start simulating CO11N and with each processing , system will propose for Screen Variants to be created for each screen elements such as Buttons , Tool Bars , Menu functions , Sub Screens with fields.
Which will continue as below :
By clicking on the Menu Functions button here you can also Edit functionality of Menu Functions
The above screen variant is for the Pushbuttons of CO11N and you can see that I have done some settings . We will see their effects in the last.
You can see the above proposal gives whole description about that Screen element like Program name with screen number , if you have any confusion you can simulate the same using SE51 and confirm.
We will continue like this ,
This for making Order field mandatory with Material field Output only.
Now press Goods Movement , for further processing.
with the press of enter it will again continue in the same fashion ,
Here comes the ToolBar and you can see that I have set DELETE option to Output only.
And Here I have removed the change in Quantity option.
Now press Exit and Save ( when you get your things done ) option .
2. Assigning Users
Now create a Group lets say ZSIJIN ( option available under the Variant Groups tab which is under Standard Variants tab ). Inside this Group we can collect various transaction variants along with their properties.
Here we are now going to assign Users. And for this Users Transaction variant will come into action.
Don't forget to press Assign and Set Proposal Buttons.
3. Now lets see the overall effect. I have highlighted them.
Hope this will be helpful to many and is a worthy document
Custom Graph creation from ALV
Graph can be created by many ways like standard FM’s, Standard functionality given in Menu, Classes. I opted to use classes as customization can be done using classes.
Mainly we have 2 classes to generate graphs. These classes are part of chart engine. It's very easy to use these classes and they need input in the form of XML files They are :
1. CL_IGS_CHART Internet Graphics Server: Chart
2. CL_IGS_CHART_ENGINE Internet Graphics Service: Chart Engine
Both of these classes will use another class: CL_GUI_HTML_VIEWER (HTML Control Proxy Class ) to generate the image of graph and to show it.
In order to show the graph we need to follow following steps.
1. First make sure that Chart Interpreter is installed. This can be done using method “cl_igs_data=>is_registered_type” and passing Destination as “IGS_RFC_DEST”.
2. Create a reference variable to “cl_igs_chart” as “igs_chart”.
3. If IGS is installed then generate a Screen to your program. We need to put our code in PBO and PAI modules of Screen..
4. In PBO module, we need to do the following steps:
4.1. Create hmtl control using statement “CREATE OBJECT g_html_control”.
4.2. Set RFC destination using cl_gfw=>its_rfc_dest and passing RFC destination.
4.3. Create chart object using “Create Object” statement.
4.4. Set the Group ID and Category of graph, these will be maintained as the X and Y axis of Graph.
4.5. It is assumed that we have our data in internal table. So get data from internal table keeping group ID as reference variable and populate the following parameters.
4.5.1. GROUPID : Fix reference variable
4.5.2. X : Values to be displayed against X axis
4.5.3. Y : Values to be displayed against Y axis
4.5.4. Z : Values to be displayed against Z axis
4.5.5. COLOR: Code of color to be displayed in Bar.
4.5.6. EXTENSION: Any hyperlink to be attached to bar.
4.5.7. DATALABEL: Label of bar value shown against each Bar.
4.6. Before putting our data in the final Data table we can set following properties of graph.
4.6.1. Set picture size using following parameters:
igs_chart->width = 640.
igs_chart->height = 480.
4.6.2. Select Chart type using below options:
igs_chart->type = cl_igs_chart=>CO_TYPE_COLS. “ Shows LandScape
igs_chart->type = cl_igs_chart=>CO_TYPE_BARS. “ Shows Portrait Mode
We can have other chart types as well, they could be selected through Attributes of class.
4.6.3. As I mentioned earlier that Color schema of Legend will not change as per colors of Bars, hence it does not matches. So I prefer to remove legend.. This could be done using below mentioned code.
igs_chart->legend = cl_igs_chart=>CO_LEGEND_NONE.
We can have other legend schema as well, they could be selected through Attributes of class.
4.6.4. Set the Title to be shown in Graph in a variable of String type and could be assigned to graph using below code.
igs_chart->title = l_title.
4.6.5. Pass the internal table having final data into igs_chart->data.
4.6.6. Create picture using method “igs_chart->send”.
4.6.7. Call method load_data of the class cl_gui_html_viewer, it will give us automatically generated URL.
4.6.8. Use this URL to create a HTML source code containing Title and Image source in the form of URL.
4.6.9. Get url of output data using method “g_html_control->load_data” passing HTML source code generated in previous step. It wil give us URL which we use to get our graph.
4.6.10. Load the picture by using the url generated by the data provider using METHOD“g_html_control->show_url”.
5. In PAI module do the following steps:
5.1. Activate event analysis of object-oriented Control Framework using METHOD“cl_gui_cfw=>dispatch.”
5.2. Handle other Events Like BACK or EXIT as per requirement.
Source Code:
* DATA DeclarationDATA : g_t_wc_disp2 TYPETABLEOF zcpl_rewrite_metrics_wc_disp,
wa_wc_disp2 TYPE zcpl_rewrite_metrics_wc_disp.
* global parameters to get data from calling programPARAMETERS:
p_dates TYPE string NO-DISPLAY,
p_dest TYPE char32 DEFAULT'IGS_RFC_DEST'NO-DISPLAY,
p_count TYPEiDEFAULT1NO-DISPLAY,
p_mode TYPE string NO-DISPLAY.
* global dataDATA:
g_html_control TYPEREFTO cl_gui_html_viewer,
g_html TYPE w3htmltabtype,
g_url TYPE w3url,
g_bool_result TYPEc,* dynpro data
ok_code TYPE sy-ucomm,
g_firstcall TYPEi,
g_count TYPEi.
REFRESH : g_t_wc_disp2.CLEAR : wa_wc_disp2,
g_html_control,
g_html,
g_url,
g_bool_result,
ok_code,
g_firstcall,
g_count.*****************************************************CONSTANTS c_x TYPE char1 VALUE'X'.* class importsCLASS cl_gfw DEFINITIONLOAD.
* entry point
START-OF-SELECTION.
* check existance of chart interpreter
CALLMETHOD cl_igs_data=>is_registered_type
EXPORTING
destination = p_dest
type = cl_igs_chart=>interpreter_type
RECEIVING
rval = g_bool_result
EXCEPTIONS
rfc_communication_error = 1
rfc_system_error = 2
internal_error = 3
OTHERS = 4.
IF sy-subrc NE0.
MESSAGEtext-001TYPEtext-025 . " Could not reach IGS 'I'.
EXIT.
ELSEIF g_bool_result ISINITIAL.
MESSAGEtext-002TYPEtext-025 . " No "Chart" interpreter installed on IGS 'I'
EXIT.
ENDIF.
CALLSCREEN100.
END-OF-SELECTION.*&---------------------------------------------------------------------**& Module PBO_0100 OUTPUT*&---------------------------------------------------------------------*MODULE pbo_0100 OUTPUT.
SET PF-STATUS '100'.
IF g_firstcall ISINITIAL.
* create hmtl control
CREATE OBJECT g_html_control
EXPORTING
parent = cl_gui_container=>default_screen.
* set rfc destination
cl_gfw=>its_rfc_dest = p_dest.
* create chart
g_count = p_count - 1.
DO g_count TIMES.
PERFORM create_chart USING g_html ' '.
ENDDO.
PERFORM create_chart USING g_html c_x . " 'X'.
* get url of output data
CALLMETHOD g_html_control->load_data
EXPORTING
type = text-003 "'text'
subtype = text-004 " 'html'
IMPORTING
assigned_url = g_url
CHANGING
data_table = g_html.
** Load the picture by using the url generated by the data provider.
CALLMETHOD g_html_control->show_url
EXPORTING
url = g_url.
g_firstcall = 1.
ENDIF.
ENDMODULE. " PBO_0100 OUTPUT
*&---------------------------------------------------------------------**& Module PAI_0100 INPUT*&---------------------------------------------------------------------*MODULE pai_0100 INPUT.
* activate event analysis of object-oriented Control Framework
CALLMETHOD cl_gui_cfw=>dispatch.
* handle other events
CASE ok_code.
WHENtext-005. "'BACK'.
LEAVEPROGRAM.
WHENtext-006. " 'EXIT'.
LEAVEPROGRAM.
ENDCASE.
ENDMODULE. " PAI_0100 INPUT
*&---------------------------------------------------------------------**& Form create_chart*&---------------------------------------------------------------------*FORM create_chart USING l_html TYPE w3htmltabtype l_real.
DATA:
igs_chart TYPEREFTO cl_igs_chart,
l_line TYPE igs_data,
l_data TYPE igs_data_tab,
mime TYPE w3mimetabtype,
html TYPE w3htmltabtype,
l_html_line TYPE w3html,
l_url TYPE w3url,
l_content_length TYPEi,
l_content_type TYPE w3param-cont_type,
l_content_subtype TYPE w3param-cont_type,
l_wc_count TYPEI.
clear l_wc_count.
DATA : l_title TYPE string.
* empty result table
REFRESH l_html.
* create chart object
CREATE OBJECT igs_chart.
IF P_Mode = TEXT-026.
igs_chart->type = cl_igs_chart=>CO_TYPE_BARS.
ELSEIF P_Mode = TEXT-027.
igs_chart->type = cl_igs_chart=>CO_TYPE_COLS.ENDIF.
DATA: G_IGS_LABEL_TAB TYPE IGS_LABEL_TAB,
W_IGS_LABEL TYPE IGS_LABEL.
W_IGS_LABEL-ID = TEXT-009.
APPEND W_IGS_LABEL TO G_IGS_LABEL_TAB.
igs_chart->LABELS_GROUPID = G_IGS_LABEL_TAB.
igs_chart->LABELS_CATEGORY = G_IGS_LABEL_TAB.
* set picture size
igs_chart->width = text-007. "640.
igs_chart->height = text-008. "480.
DESCRIBETABLE g_t_final LINES l_wc_count.* Change size if more than 6 WC and Landscape ModeIF l_wc_count > 6AND P_Mode = TEXT-027.* set picture size
igs_chart->width = TEXT-028. "1300.
igs_chart->height = text-008. "480.ENDIF.
LOOPAT g_t_final INTO wa_final.
l_line-groupid = text-009. " 'GREEN'.
l_line-x = wa_wc_disp2-vaplz.
l_line-y = wa_wc_disp2-g_green.
l_line-color = text-012. "18.
APPEND l_line TO l_data.
CLEAR wa_final.
ENDLOOP.
LOOPAT g_t_final INTO wa_final.
l_line-groupid = text-010. " 'YELLOW'.
l_line-x = wa_wc_disp2-vaplz.
l_line-y = wa_wc_disp2-g_yellow.
l_line-color = text-013. "10.
APPEND l_line TO l_data.
CLEAR wa_final.
ENDLOOP.
LOOPAT g_t_final INTO wa_final.
l_line-groupid = text-011. " 'RED'.
l_line-x = wa_wc_disp2-vaplz.
l_line-y = wa_wc_disp2-g_red.
l_line-color = text-014. "59.
APPEND l_line TO l_data.
CLEAR wa_final.
ENDLOOP.
igs_chart->data = l_data.
igs_chart->color_scheme = cl_igs_chart=>CO_SCHEME_REVERSE.
igs_chart->legend = cl_igs_chart=>CO_LEGEND_NONE.
* set titles
p_dates INTO l_title SEPARATEDBY space.
igs_chart->title = l_title.
* create picture
CALLMETHOD igs_chart->send
IMPORTING
content_type = l_content_type
content_length = l_content_length
content = mime
imagemap = html
EXCEPTIONS
rfc_communication_error = 1
rfc_system_error = 2
internal_error = 3
OTHERS = 4.
IF sy-subrc ISINITIALAND l_real NE space.
SPLIT l_content_type AT'/'INTO l_content_type l_content_subtype. "
CALLMETHOD g_html_control->load_data
EXPORTING
type = l_content_type
subtype = l_content_subtype
size = l_content_length
IMPORTING
assigned_url = l_url
CHANGING
data_table = mime.
CONCATENATE
'<HTML><HEAD><TITLE>SAP IGS Chart</TITLE></HEAD>'
'<BODY BGCOLOR=#DEDEC8>'
'<MAP NAME=chart>'
INTO l_html_line-line.
APPEND l_html_line TO l_html.
APPENDLINESOF html TO l_html.
CONCATENATE
'</MAP>'
'<IMG SRC="' l_url '" USEMAP=#chart BORDER=0>'
'</BODY></HTML>'
INTO l_html_line-line.
APPEND l_html_line TO l_html.
ENDIF.
ENDFORM. " create_chart
F-47 Downpayment Request Using BAPI_ACC_DOCUMENT_POST
Hello Folks,
we can use BAPI_ACC_DOCUMENT_POST for creation of down payment request using F-47.
There is a trick involved so i am providing the steps herein.
1. Dont give Business Transaction ( BUS_ACT ) in the header ( document header ), we will derive it in the following steps.
2. i used extention2 of the BADI parameter to identify this kind of transaction.
3. i implemented ACC_DOCUMENT BADI with FILTER VALUE BKPFF, which i passed in document header OBJ_TYPE and in the CHANGE method i changed the C_ACCHD-GLVOR = 'RFST' and the C_ACCIT-BSTAT = 'S' ( Noted Items ) if my extention2 value matches.
then i posted the document successfully using the BAPI.
Regards
Animesh Sundriyal
rptarqpost program giving a short dump with getwa_not_assigned
hi all,
In standard program for leave posting RPTARQPOST giving a short dump GETWA_NOT_ASSINED. The program is having 80000 records for execution but around 200 records are getting posted and giving the short dump getwa_not_assined.
Kindly help as this is very urgent requirement.
regards,
Sekhar.
Get an Employee’s Planned Work Shift START TIME and END TIME
PA30 is the transaction used for HR master data maintenance.
Below are the steps to follow at transaction level to get the Work Schedule details of an employee:
1. Enter any personnel number in the Personnel no. field.
2.Enter the infotype ID for ‘Planned Working Time’ in the Infotype field as we are now looking for the Planned work shift timings.
3.With these inputs in the initial screen, select the ‘Display’ button on the top left.
4.This screen would show the Work Schedule Rule, work timing and other details.
5.Click the ‘Work Schedule’ button on the top left (shown in above screen) and it will display the scheduled work plan for the current month.
ABAP programming:
The above steps determine the process to get Planned work time from transaction PA30.
Now, let us see how this can be achieved using ABAP programming.
A standard Function module ‘CATS_GET_TARGET_HOURS’ can be used for this.
This function module would provide us with the information below:
- Date
- Hours
- Shift Start Time
- Shift End Time
The essential inputs to this FM are:
- Personnel Number
- Start Date
- End Date
*Call the function module to get current day’s target hours
CALL FUNCTION 'CATS_GET_TARGET_HOURS'
EXPORTING
PERNR = P_V_PERNR
BEGDA = SY-DATUM
ENDDA = SY-DATUM
TABLES
TARGET_HOURS = IT_HRS_PER_DAY
EXCEPTIONS
PERNR_NOT_FOUND = 1
TOO_MANY_DAYS = 2
ERROR_IN_SAP_ENHANCEMENT = 3
OTHERS = 4.
IF SY-SUBRC EQ 0.
READ TABLE IT_HRS_PER_DAY INTO WA_HRS_PER_DAY INDEX 1.
ENDIF.
Output :
1. Date WA_HRS_PER_DAY-DATE
2. Hours WA_HRS_PER_DAY-STDAZ
3. Shift Start Time WA_HRS_PER_DAY-SOBEG
4. Shift End Time WA_HRS_PER_DAY-SOEND
If the current day is a working day according to the Planned Work Schedule ( above figure in step 5), then the output from Function module would give us all the necessary information. If the current day (sy-datum) is a day OFF for the Employee, then the FM would not return us the information.
This code will retrieve the Start and End time of a shift in all cases.
* Get plant, Personnel subarea and End date
SELECT WERKS BTRTL ENDDA INTO TABLE IT_PA0001
FROM PA0001
WHERE PERNR = P_V_PERNR.
IF SY-SUBRC EQ 0.
* Get the latest work schedule
SORT IT_PA0001 BY ENDDA DESCENDING.
READ TABLE IT_PA0001 INTO WA_PA0001 INDEX 1.
IF SY-SUBRC EQ 0.
* Get personnel subarea grouping for Work Schedules
SELECT SINGLE MOSID INTO V_MOSID
FROM T001P
WHERE WERKS = WA_PA001-WERKS
AND BTRTL = WA_PA001-BTRTL.
IF SY-SUBRC EQ 0.
* Get work schedule rule
SELECT SINGLE SCHKZ INTO V_SCHKZ
FROM PA0007
WHERE PERNR = P_V_PERNR
AND ENDDA = WA_PA001-ENDDA.
IF SY-SUBRC EQ 0.
* Get the start and end time
PERFORM GET_WORKSCHEDULE_RULE
USING V_SCHKZ V_MOSID
CHANGING V_START_TIME V_END_TIME.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
The logic in the highlighted subroutine PERFORM GET_WORKSCHEDULE_RULE:
* Get the Work Schedule Rule
SELECT * FROM T508A INTO TABLE LT_T508A
WHERE SCHKZ EQ V_SCHKZ
AND MOSID EQ V_MOSID
ORDER BY ENDDA DESCENDING.
IF SY-SUBRC EQ 0.
READ TABLE LT_T508A INTO WA_T508A INDEX 1.
* Get the Daily Work Schedule Rule
IF SY-SUBRC EQ 0.
SELECT SINGLE MOTPR
ZMODN
TPRG1
TPRG2
TPRG3
TPRG4
TPRG5
TPRG6
TPRG7
FROM T551A INTO (LV_MOTPR1, LV_ZMODN1,
LV_TPRG1,
LV_TPRG2, LV_TPRG3, LV_TPRG4,
LV_TPRG5, LV_TPRG6, LV_TPRG7)
WHERE MOTPR EQ V_MOSID
AND ZMODN EQ WA_T508A-ZMODN.
IF SY-SUBRC EQ 0.
* Check if the day is a week OFF for the given Employee
IF LV_TPRG1 <> 'OFF'.
WA_TPROG = LV_TPRG1.
ENDIF.
IF LV_TPRG2 <> 'OFF'.
WA_TPROG = LV_TPRG2.
ENDIF.
IF LV_TPRG3 <> 'OFF'.
WA_TPROG = LV_TPRG3.
ENDIF.
IF LV_TPRG4 <> 'OFF'.
WA_TPROG = LV_TPRG4.
ENDIF.
IF LV_TPRG5 <> 'OFF'.
WA_TPROG = LV_TPRG5.
ENDIF.
IF LV_TPRG6 <> 'OFF'.
WA_TPROG = LV_TPRG6.
ENDIF.
IF LV_TPRG7 <> 'OFF'.
WA_TPROG = LV_TPRG7.
ENDIF.
* Get the Planned Work Shift – Start time and End time
SELECT SINGLE SOBEG SOEND
FROM T550A INTO (LV_SOBEG, LV_SOEND)
WHERE MOTPR EQ LV_MOTPR1
AND TPROG EQ WA_TPROG
AND ENDDA EQ WA_T508A-ENDDA.
IF SY-SUBRC EQ 0.
P_V_START = LV_SOBEG.
P_V_END = LV_SOEND.
ELSE.
P_V_START = '000000'.
P_V_END = '000000'.
ENDIF.
ELSE.
P_V_START = '000000'.
P_V_END = '000000'.
ENDIF.
ENDIF.
ENDIF.
Here we go! The variable P_V_START represents the Employee’s Planned Shift Start Time and P_V_END represents the Employee’s Planned Shift End Time.
How to Easy... Create a Search Help by code and fill more than one field in screen
Sometimes we need to create a custom search help and fill more than one field in screen with a single selection.
This can be easily achieved by using FM to create this Search Help.
Here is an example to use in a screen with two fields.
Considering our screen has two fields:
VBAP-VBELN
VBAP-POSNR
We are going to set a Search help for VBAP-POSNR, but popup will show VBELN and POSNR, and will fill this two fields in our screen.
First we need to set PROCESS ON VALUE-REQUEST for VBAP-POSNR.
In screen Flow Logic, insert this code after PAI.
PROCESS ON VALUE-REQUEST.
FIELD vbap-posnr MODULE zm_sh_posnr.
Now we have to code zm_sh_posnr module.
Here it is:
MODULE zm_sh_posnr INPUT.
" Types
" Table type for SH popup
TYPES: BEGIN OF ys_sh,
vbeln TYPE vbap-vbeln,
posnr TYPE vbap-posnr,
END OF ys_sh.
" Local Vars
DATA: lt_sh TYPE TABLE OF ys_sh,
ls_sh TYPE ys_sh,
lt_map TYPE TABLE OF dselc,
ls_map TYPE dselc.
" Load data
SELECT vbeln posnr
FROM vbap
INTO TABLE lt_sh
UP TO 50 ROWS.
" Set return fields
" Order
CLEAR ls_map.
ls_map-fldname = 'F0001'. " Set that field 1 of SH table fills VBAP-VBELN
ls_map-dyfldname = 'VBAP-VBELN'.
APPEND ls_map TO lt_map.
" Item
CLEAR ls_map.
ls_map-fldname = 'F0002'. " Set that field 2 of SH table fills VBAP-VBELN
ls_map-dyfldname = 'VBAP-POSNR'.
APPEND ls_map TO lt_map.
" Call Search Help Popup Function
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'POSNR'
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'VBAP-POSNR'
value_org = 'S'
TABLES
value_tab = lt_sh
dynpfld_mapping = lt_map
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
ENDMODULE.
It's Done!
Field Symbols (how to use practically??)
When I began learning the concept of field symbols , it looked quite scary with all the brackets and new syntax. But now after using it almost on a regular basis I actually am kind of tempted to use it maximum to where I can.
Field symbols are better performance wise but I am not going down that lane. I am here explaining how to be using it practically and effectively. In simple words , a field symbol refers or points (pointers known as in C language) to something. That something can be a table , a field or even nothing. When I say nothing I mean that the structure of a field symbol can be determined dynamically.
For our purpose let us consider MARA table as the referring table and MATNR field as the referring field.
Definition :
field-symbols: <fs_tab> type standard table,<fs_wa> type mara.
Here we have defined a table <fs_tab> containing no structure and <fs_wa> with structure MARA.
Assign :
Note for field symbols just defining does not mean that we can start using it after definition. We have to assign a structure to that field symbol. i.e we have to tell the program that not <fs_tab>will be referring to table MARA.
Now we have an internal table itab_mara defined.
Data : itab_mara like mara occurs 0 with header line.
All we have to do is before using <fs_tab> we have to write
Data : itab_mara like mara occurs 0 with header line.
All we have to do is before using <fs_tab> we have to write
Assign : itab_mara[] to <fs_tab>.
You can now use <fs_tab> and whatever changes you make to <fs_tab> reflects to itab_mara.
Loop at <fs_tab> assigning <fs_wa>.
<fs_wa>-matnr = ‘NEW CHANGE MATERIAL’.
Endloop.
Now this automatically refer to <fs_tab> which will automatically modify itab_mara[].
field-symbols: <fs_tab> type standard table,
<fs_wa> type mara.
data : itab_mara like mara occurs 0 with header line.
select * from mara up to 10 rows into table itab_mara.
assign : itab_mara[] to <fs_tab>.
loop at <fs_tab> assigning <fs_wa>.
<fs_wa>-matnr = 'NEW CHANGE MATERIAL'.
endloop.
New Scenario :
1. Now in the above case you have internal table itab_mara ready. Suppose you don’t have internal table itab_mara then what?
You will need to assign <fs_tab> and <fs_wa> dynamically and also apply a select query dynamically.
Consider the same case for table MARA and field MATNR.
Defining the field symbol is same and also the looping part is same. The only change is where and how you assign the field symbols.
Consider the following scenario. You have a program with parameter field TABLE NAME. as soon as the user enters a table name he will get 10 rows selected from that table and modify the a field.
parameters : p_tab type dd03l-tabname.
field-symbols: <fs_tab> type standard table,
<fs_wa> type any,
<fs_matnr> type matnr.
data: fs_data type ref to data,
dyn_line type ref to data.
data : itab_fcat type lvc_t_fcat.
data : fcat like line of itab_fcat.
start-of-selection.
******* Assign
call function 'LVC_FIELDCATALOG_MERGE'
exporting
i_structure_name = p_tab
changing
ct_fieldcat = itab_fcat.
loop at itab_fcat into fcat.
clear: fcat-domname, fcat-ref_table.
modify itab_fcat index sy-tabix from fcat.
endloop.
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = itab_fcat
importing
ep_table = fs_data.
assign fs_data->* to <fs_tab>.
create data dyn_line like line of <fs_tab>.
assign dyn_line->* to <fs_wa>.
******* Assign
select * from (p_tab) up to 10 rows into corresponding fields of table <fs_tab>.
loop at <fs_tab> assigning <fs_wa>.
assign component 'MATNR' of structure <fs_wa> to <fs_matnr>.
<fs_matnr> = 'NEW CHANGE'.
endloop.
Here we use assign component as we do not know which fields are there in <fs_wa> before runtime.
The Sieve of Eratosthenes
Eratosthenes was the third librarian of the famous library in Alexandria and an outstanding scholar. The Sieve of Eratosthenes is an algorithm for collecting prime numbers, the invention of which he is credited with. Further details may be found at the Wikipedia link for Eratosthenes (http://en.wikipedia.org/wiki/Eratosthenes).
The Algorithm works as follows :
To collect all Prime numbers below a certain number (say N) start by first identifying all composite numbers and removing them from a predefined numerical sequence ( 1 to N ). Thus, whatever remains are all prime numbers.
The identification of Composite numbers is done by iteratively finding the multiples of all numbers from 2 (1 is not a prime number) till the maximum limit and removing the composite numbers at each step.
I.e, All multiples of 2 (excluding 2 itself) are removed. The next available number is found. In this case it is 3.
Then All multiples of 3 (excluding 3 itself) are removed. The next available number is found. In this case it is 5.
Then All multiples of 5 (excluding 5 itself) are removed. The next available number is found. In this case it is 7.
And so on till the maximum limit is reached.
I attempt here to provide an SAP implementation of the Sieve of Eratosthenes.
DATA : var type i, max type i, temp type i, count type i value 2, t_prime type table of i, wa_prime type i. SELECTION-SCREEN begin of block b1 with frame. PARAMETERS : limit type i. SELECTION-SCREEN end of block b1. DO limit times. var = var + 1. APPEND var to t_prime. ENDDO. DELETE t_prime from 1 to 1. max = var. var = 2. WHILE var <= max. DO. temp = var * count. DELETE t_prime where table_line = temp. IF sy-subrc = 0. count = count + 1. ELSEIF temp <= max. count = count + 1. ELSE. EXIT. ENDIF. ENDDO. READ TABLE t_prime into wa_prime with key table_line = var. var = sy-tabix + 1.
READ TABLE t_prime into var index var.
IF sy-subrc = 0.
count = 2.
ELSE.
EXIT.
ENDIF.
ENDWHILE.
LOOP AT t_prime into wa_prime.
write : / wa_prime.
ENDLOOP.
An execution of the above program has yielded accurate results finding all prime numbers upto 30,000.
I am sure that this may be optimized further, in terms of logic as well as implementation.
However, I have attempted to remain true to the original Algorithm of the Sieve of Eratosthenes.
How to Easy... Create a Search Help in ALV OOPS editable field
When we use an editable ALV, some fields must have a custom Search Help. Let's describe the simple way to add a custom Search Help to a specific field of an ALV using OOPS.
Assuming we have a field called BWTAR in our alv table GT_OUT.
At fieldcat, we need to set this field editable and with F4:
CLEAR ls_fcat.
ls_fcat-fieldname = 'BWTAR'.
ls_fcat-ref_field = 'BWTAR'.
ls_fcat-ref_table = 'MBEW'.
ls_fcat-edit = 'X'.
ls_fcat-f4availabl = 'X'.
APPEND ls_fcat TO gt_fcat.
After create ALV Object GO_ALV, we need to register BWTAR field for F4 and set ONF4 event handler.
DATA: lt_f4 TYPE lvc_t_f4 WITH HEADER LINE.
CLEAR lt_f4.
lt_f4-fieldname = 'BWTAR'.
lt_f4-register = 'X'.
INSERT table lt_f4.
" Register F4 for BWTAR
CALL METHOD go_alv->register_f4_for_fields
EXPORTING
it_f4 = lt_f4[].
" Set Handler
SET HANDLER lo_handler->handle_on_f4 FOR go_alv.
In our local event handler class, we need to define the ONF4 event and code it.
CLASS lcl_event_handler DEFINITION FINAL.
PUBLIC SECTION.
METHODS:
handle_on_f4
FOR EVENT onf4 OF cl_gui_alv_grid
IMPORTING e_fieldname
es_row_no
er_event_data.
ENDCLASS.
CLASS lcl_event_handler IMPLEMENTATION.
*--Handle On F4
METHOD handle_on_f4.
PERFORM handle_on_f4
USING e_fieldname
es_row_no
er_event_data.
ENDMETHOD.
ENDCLASS.
At last, let's code handle_on_f4 perform:
FORM handle_on_f4
USING e_fieldname TYPE lvc_fname
es_row_no TYPE lvc_s_roid
er_event_data TYPE REF TO cl_alv_event_data.
" Types
TYPES: BEGIN OF ys_bwtar,
bwtar TYPE mbew-bwtar,
END OF ys_bwtar.
" Local Vars
DATA: lt_bwtar TYPE TABLE OF ys_bwtar,
ls_bwtar TYPE ys_bwtar,
lt_map TYPE TABLE OF dselc,
ls_map TYPE dselc,
lt_return TYPE TABLE OF ddshretval,
ls_return TYPE ddshretval,
ls_stable TYPE lvc_s_stbl.
" Field-symbols
FIELD-SYMBOLS: <l_out> TYPE ys_out. " ALV table line
" Check which field raise f4 event
CASE e_fieldname.
WHEN 'BWTAR'.
" Read current line
READ TABLE gt_out ASSIGNING <l_out>
INDEX es_row_no-row_id.
" Load F4 Data
SELECT bwtar
FROM mbew
INTO TABLE lt_bwtar
WHERE matnr = <l_out>-matnr AND
bwkey = <l_out>-werks.
" Set return field
CLEAR ls_map.
ls_map-fldname = 'F0001'.
ls_map-dyfldname = 'BWTAR'.
APPEND ls_map TO lt_map.
" Call Search Help Popup Function
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'BWTAR'
value_org = 'S'
TABLES
value_tab = lt_bwtar
dynpfld_mapping = lt_map
return_tab = lt_return
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
" Read selected f4 value
READ TABLE lt_return INTO ls_return WITH KEY fieldname = 'F0001'.
IF ls_return IS NOT INITIAL.
" Update ALV table
<l_out>-bwtar = ls_return-fieldval.
ENDIF.
ENDCASE.
ls_stable = 'XX'. " Set stable refresh for row and column
" ALV Refresh
CALL METHOD go_alv->refresh_table_display
EXPORTING
is_stable = ls_stable
i_soft_refresh = 'X'
EXCEPTIONS
finished = 1
OTHERS = 2.
" Avoid possible standard Search Help
er_event_data->m_event_handled = 'X'.
ENDFORM.
That's it!
Integrating MS Word and MS-Excel with ABAP-OLE
OLE (Object linking and embedding) in SAP is used to integrate MS-excel and MS-word eand to achieve automation through programming interface . When called from an ABAP program, the SAPGUI acts as OLE client, and the desktop application as the OLE server.
In general there are five basic statements to achieve automation:
- CREATE OBJECT
- SET PROPERTY
- GET PROPERTY
- CALL METHOD
- FREE OBJECT
1. Creating an OLE Object
To create an OLE object, the ABAP statement “CREATE OBJECT” is used.
The syntax is CREATE OBJECT obj class.
Here, “obj” is the handle variable for the base object and “class” is the specific identifier for the corresponding application.
- e.g. CREATE OBJECT gs_word 'WORD.APPLICATION' .
If the creation is successful the value of “sy-subrc” becomes “0”, otherwise it becomes some other value (i.e. “1”, “2” or “3” with respect to the error type).
2. Calling a Method of an Object
After creating an OLE object, it is possible to call its methods to execute its functionality. This is achieved by using the ABAP statement “CALL METHOD OF”. Also the required parameters can be passed using this statement.
The syntax is:CALL METHOD OF obj m [= f] [EXPORTING p1 = f1 ... pn = fn] .
Here, “obj” is the object handle variable, “m” is the method name, “f” is the variable where the output of the method will be replaced and “pn = fn” assignments are used to pass parameters. The “EXPORTING…” part must be at the end of the statement. For the moment, parameter passing is done by giving their positions and the corresponding value.
- e.g. CALL METHOD OF gs_word 'Documents' = gs_documents .
CALL METHOD OF gs_selection 'TypeText' EXPORTING #1 = ip_text .
Successful method calls makes “sy-subrc” value “0”, and unsuccessful cases make it some other value.
3. Setting a Property of an Object
To set a property of an OLE object, the ABAP statement “SET PROPERTY OF” is used.
The syntax is: SET PROPERTY OF obj p = f .
Here, “obj” is the object handle variable, “p” is the property name and “f” is the value to be assigned.
- e.g. SET PROPERTY OF gs_word 'Visible' = 1 .
Operation result status is indicated at the system variable “sy-subrc”; “0” for successful operations and another value for erroneous cases.
4. Getting a Property of an Object
Getting the value of a property of an OLE object is obviously similar to setting it. For this, the ABAP statement “GET PROPERTY OF” is used.
The syntax is: GET PROPERTY OF obj p = f .
Here, “obj” is the object handle variable, “p” is the property name and “f” is the variable to which the value of the property is assigned.
- e.g. GET PROPERTY OF gs_view 'Type' = gv_viewtype .
Again, operation result status is indicated at the system variable “sy-subrc”; “0” for successful operations and another value for erroneous cases.
5. Freeing an Object
Generally for performance issues, it is required to free the memory allocated for OLE objects. For this, the ABAP statement “FREE OBJECT” is used.
The syntax is: FREE OBJECT obj. where “obj” is the object handle variable.
6. NO FLUSH Addition
Normally, OLE statements are buffered by the ABAP processor and executed at the frontend collectively before the first statement which is not of OLE context. Using this addition prevents this and postpones the execution till just before the first non-OLE statement coming after an OLE statement without NO FLUSH addition.
Please find below , the piece of code for downloading the data from an internal table to a excel sheet:
*&---------------------------------------------------------------------*
*& Form DOWNLOAD_SHEET
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_L_TABIX text
* -->P_L_NAME text
* -->P_P_X_JOB_STATUS_RELEASED text
* <--P_LW_EXCEL text
* <--P_LW_WORKSHEET text
*----------------------------------------------------------------------*
FORM download_sheet USING p_lw_sheet TYPE ole2_object
p_l_tabix TYPE i
p_l_name TYPE string
p_data TYPE tt_data
* p_p_x_job_status_released type tt_tbtco
CHANGING p_lw_excel TYPE ole2_object
p_lw_worksheet TYPE ole2_object.
DATA: lw_columns TYPE ole2_object,
lw_rows TYPE ole2_object,
lw_column_ent TYPE ole2_object,
lw_cell TYPE ole2_object,
lw_int TYPE ole2_object,
lw_bor TYPE ole2_object,
lw_tab TYPE ole2_object,
lw_range TYPE ole2_object,
lw_font TYPE ole2_object,
lw_select TYPE ole2_object,
lw_delete TYPE ole2_object.
* lw_int TYPE ole2_object.
DATA : "lx_display TYPE ty_product_sheet,
"lx_data TYPE ty_data ,
i_row TYPE i,
i_col TYPE i.
"lx_header TYPE ty_header.
DATA: l_cnt TYPE i VALUE 17 ,
l_rows TYPE i,
l_row TYPE i VALUE 1,
w_rc TYPE i,
l_rec(1000) TYPE c,
li_itab TYPE STANDARD TABLE OF t_data,
l_del TYPE c,
l_line TYPE i,
l_hex TYPE x,
l_pos(3) TYPE c,
l_char(3) TYPE c,
l_pos1(5) TYPE c,
l_len TYPE i,
l_col1 TYPE i,
l_len1 TYPE i,
l_pos2(5) TYPE c,
li_p_data1 TYPE tt_data.
l_col1 = 1.
l_del = w_del .
w_index = w_index + 1 .
GET PROPERTY OF p_lw_excel 'Sheets' = p_lw_worksheet .
CALL METHOD OF p_lw_worksheet 'Add' = p_lw_sheet.
SET PROPERTY OF p_lw_sheet 'Name' = p_l_name .
GET PROPERTY OF p_lw_excel 'ACTIVESHEET' = p_lw_worksheet.
CALL METHOD OF p_lw_worksheet 'TAB' = lw_tab.
SET PROPERTY OF lw_tab 'ColorIndex' = w_index.
CALL METHOD OF p_lw_excel 'Columns' = lw_columns.
SET PROPERTY OF lw_columns 'Locked' = 0.
DESCRIBE TABLE p_data LINES l_rows .
CALL METHOD cl_gui_frontend_services=>clipboard_export
IMPORTING
data = p_data[]
CHANGING
rc = w_rc
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4.
* Paste the contents in the clipboard to the worksheet
CALL METHOD OF p_lw_worksheet 'Paste'.
DESCRIBE TABLE p_data LINES l_len .
APPEND LINES OF p_data FROM 7 TO l_len TO li_p_data1 .
IF li_p_data1[] IS NOT INITIAL.
READ TABLE li_p_data1[] INTO l_rec INDEX 1.
SPLIT l_rec AT l_del INTO TABLE li_itab.
ENDIF.
DESCRIBE TABLE li_itab LINES l_line.
DO 6 TIMES .
CALL METHOD OF p_lw_excel 'Cells' = lw_cell EXPORTING #1 = sy-index #2 = 1 .
GET PROPERTY OF lw_cell 'Font' = lw_font.
IF sy-index = 1 OR sy-index = 2 .
SET PROPERTY OF lw_font 'Bold' = 1 .
SET PROPERTY OF lw_font 'Size' = 14 .
ELSE.
SET PROPERTY OF lw_font 'Bold' = 1 .
SET PROPERTY OF lw_font 'Size' = 10 .
ENDIF.
ENDDO.
CLEAR: lw_font,lw_cell .
DO l_line TIMES .
CALL METHOD OF p_lw_excel 'Cells' = lw_cell EXPORTING #1 = 7 #2 = sy-index.
GET PROPERTY OF lw_cell 'Font' = lw_font.
SET PROPERTY OF lw_font 'Bold' = 1 .
ENDDO.
l_char = l_line.
PERFORM create_address USING l_line CHANGING l_pos.
l_pos1 = l_pos.
l_len1 = STRLEN( l_pos1 ).
IF l_len1 = 3.
l_pos+2(1) = 7.
ELSE.
l_pos+1(1) = 7.
ENDIF.
CALL METHOD OF p_lw_excel 'Range' = lw_range
EXPORTING
#1 = 'A7'
#2 = l_pos.
CALL METHOD OF p_lw_excel 'Range' = lw_range
EXPORTING
#1 = 'A8'
#2 = l_pos. " + nik
CALL METHOD OF lw_range 'Autofilter'.
CALL METHOD OF lw_range 'INTERIOR' = lw_int.
SET PROPERTY OF lw_int 'ColorIndex' = 42.
SET PROPERTY OF lw_int 'Pattern' = 1.
CALL METHOD OF lw_range 'Borders' = lw_bor
EXPORTING
#1 = '7'.
SET PROPERTY OF lw_bor 'LineStyle' = 1 .
SET PROPERTY OF lw_bor 'Weight' = 2.
CALL METHOD OF lw_range 'Borders' = lw_bor
EXPORTING
#1 = '8'.
SET PROPERTY OF lw_bor 'LineStyle' = 1 .
SET PROPERTY OF lw_bor 'Weight' = 2.
CALL METHOD OF lw_range 'Borders' = lw_bor
EXPORTING
#1 = '9'.
SET PROPERTY OF lw_bor 'LineStyle' = 1 .
SET PROPERTY OF lw_bor 'Weight' = 2.
CALL METHOD OF lw_range 'Borders' = lw_bor
EXPORTING
#1 = '10'.
SET PROPERTY OF lw_bor 'LineStyle' = 1 .
SET PROPERTY OF lw_bor 'Weight' = 2.
CALL METHOD OF lw_range 'Borders' = lw_bor
EXPORTING
#1 = '11'.
SET PROPERTY OF lw_bor 'LineStyle' = 1 .
SET PROPERTY OF lw_bor 'Weight' = 2.
CALL METHOD OF lw_range 'Borders' = lw_bor
EXPORTING
#1 = '12'.
SET PROPERTY OF lw_bor 'LineStyle' = 1 .
SET PROPERTY OF lw_bor 'Weight' = 2.
* rest of the sheet
IF l_len1 = 3.
l_pos1+2(3) = l_len.
ELSE.
l_pos1+1(2) = l_len.
ENDIF.
l_pos2 = l_pos1.
* l_pos1+1(2) = l_len.
CALL METHOD OF p_lw_excel 'Range' = lw_range
EXPORTING
#1 = 'A8'
#2 = l_pos1.
CALL METHOD OF lw_range 'INTERIOR' = lw_int.
SET PROPERTY OF lw_int 'ColorIndex' = 35.
SET PROPERTY OF lw_int 'Pattern' = 1.
CALL METHOD OF lw_range 'Borders' = lw_bor
EXPORTING
#1 = '7'.
SET PROPERTY OF lw_bor 'LineStyle' = 1 .
SET PROPERTY OF lw_bor 'Weight' = 2.
CALL METHOD OF lw_range 'Borders' = lw_bor
EXPORTING
#1 = '8'.
SET PROPERTY OF lw_bor 'LineStyle' = 1 .
SET PROPERTY OF lw_bor 'Weight' = 2.
CALL METHOD OF lw_range 'Borders' = lw_bor
EXPORTING
#1 = '9'.
SET PROPERTY OF lw_bor 'LineStyle' = 1 .
SET PROPERTY OF lw_bor 'Weight' = 2.
CALL METHOD OF lw_range 'Borders' = lw_bor
EXPORTING
#1 = '10'.
SET PROPERTY OF lw_bor 'LineStyle' = 1 .
SET PROPERTY OF lw_bor 'Weight' = 2.
CALL METHOD OF lw_range 'Borders' = lw_bor
EXPORTING
#1 = '11'.
SET PROPERTY OF lw_bor 'LineStyle' = 1 .
SET PROPERTY OF lw_bor 'Weight' = 2.
CALL METHOD OF lw_range 'Borders' = lw_bor
EXPORTING
#1 = '12'.
SET PROPERTY OF lw_bor 'LineStyle' = 1 .
SET PROPERTY OF lw_bor 'Weight' = 2.
***************
*header
IF l_len1 = 3.
l_pos1+2(1) = 6.
l_pos1+3(1) = space.
CONDENSE l_pos1.
ELSE.
l_pos1+1(1) = 6.
l_pos1+2(1) = space.
CONDENSE l_pos1 NO-GAPS.
ENDIF.
* l_pos1+0(2) = 6.
CALL METHOD OF p_lw_excel 'Range' = lw_range
EXPORTING
#1 = 'A1'
#2 = l_pos1.
CALL METHOD OF lw_range 'INTERIOR' = lw_int.
SET PROPERTY OF lw_int 'ColorIndex' = 31.
SET PROPERTY OF lw_int 'Pattern' = 1.
CALL METHOD OF lw_range 'Borders' = lw_bor
EXPORTING
#1 = '5'.
SET PROPERTY OF lw_bor 'LineStyle' = 0.
* SET PROPERTY OF lw_bor 'Weight' = 2.
*
CALL METHOD OF lw_range 'Borders' = lw_bor
EXPORTING
#1 = '6'.
SET PROPERTY OF lw_bor 'LineStyle' = 0.
* SET PROPERTY OF lw_bor 'Weight' = 2.
*
CALL METHOD OF lw_range 'Borders' = lw_bor
EXPORTING
#1 = '7'.
SET PROPERTY OF lw_bor 'LineStyle' = 0.
* SET PROPERTY OF lw_bor 'Weight' = 2.
CALL METHOD OF lw_range 'Borders' = lw_bor
EXPORTING
#1 = '8'.
SET PROPERTY OF lw_bor 'LineStyle' = 0 .
* SET PROPERTY OF lw_bor 'Weight' = 2.
CALL METHOD OF lw_range 'Borders' = lw_bor
EXPORTING
#1 = '9'.
SET PROPERTY OF lw_bor 'LineStyle' = 0 .
* SET PROPERTY OF lw_bor 'Weight' = 2.
CALL METHOD OF lw_range 'Borders' = lw_bor
EXPORTING
#1 = '10'.
SET PROPERTY OF lw_bor 'LineStyle' = 0 .
* SET PROPERTY OF lw_bor 'Weight' = 2.
CALL METHOD OF lw_range 'Borders' = lw_bor
EXPORTING
#1 = '11'.
SET PROPERTY OF lw_bor 'LineStyle' = 0 .
* SET PROPERTY OF lw_bor 'Weight' = 2.
CALL METHOD OF lw_range 'Borders' = lw_bor
EXPORTING
#1 = '12'.
SET PROPERTY OF lw_bor 'LineStyle' = 0 .
* SET PROPERTY OF lw_bor 'Weight' = 2.
*****************
** Autofit the columns according to the contents
* CALL METHOD OF p_lw_excel 'Columns' = lw_columns
* EXPORTING
*
* CALL METHOD OF lw_columns 'AutoFit'.
CALL METHOD OF p_lw_excel 'Range' = lw_range
EXPORTING
#1 = 'A7'
#2 = l_pos2.
* CALL METHOD OF lw_range 'Select' .
GET PROPERTY OF lw_range 'Columns' = lw_columns.
CALL METHOD OF lw_columns 'AutoFit'.
* CALL METHOD OF p_lw_excel 'Range' = lw_range
* EXPORTING
* #1 = 'A4'.
*
* CALL METHOD OF lw_range 'Delete' = lw_delete.
*
* set property of lw_delete 'Shift' = -4162.
*
* CALL METHOD OF lw_delete 'Shift'
* EXPORTING
* #1 = -4162.
FREE OBJECT: lw_columns, lw_range,lw_cell.
* CLEAR i_data .
ENDFORM. " DOWNLOAD_SHEET
TSV_TNEW_PAGE_ALLOC_FAILED and TSV_TNEW_BLOCKS_NO_ROLL_MEMORY
Hello,
Happy New Year 2007 to all!
We are using SAP R/3 4.6C, kernel 46D_EXT Patch 2271, Oracle 9.2.0.5 and HP-UX 11.23, 16GB RAM, 17GB swap.
Lately, at the end of this year, many ABAP runtime errors <b>TSV_TNEW_PAGE_ALLOC_FAILED and TSV_TNEW_BLOCKS_NO_ROLL_MEMORY</b> ocured.
Some times there is MEMORY_NO_MORE_PAGING.
I have read some notes regarding this issue.
1. Maybe I should increase the ztta/roll_area, current is 3000000 and to change into 6500000.
2. Can you please advice me regarding the rdisp/ROLL_SHM = 16384 (32768) and rdisp/ROLL_MAXFS = 80000 (131072), should I also increase them into the values in the brackets (there is a note which has the statement 'Must be adjusted if you change ztta/roll_area')?
3. What about the ztta/roll_first = 1 and ztta/roll_extension = 2000000000, should I also change them?
4. Regarding the Paging area, what should I do?
rdisp/PG_SHM = 8192 (32768) and rdisp/PG_MAXFS = 65536 (131072) , should I change into the values in the brackets?
em/initial_size_MB = 4092
THANK YOU in advance,
Ruzica
Before changing any parameter ( if the system was working well before this bout of dumps and u havent changed anything), i would check the follwoing
Are the dumps across the board or happening only for some particular programs
The values of the memory paramters (extended , heap etc) captured by the dumps
Do the values look realastic comapred to what you have set
The swapinfo on your OS
thanks
Naushad
Yes, it seams to be the internal table IT_30 and some custome-made Z_... program
In case of <b>TSV_TNEW_BLOCKS_NO_ROLL_MEMORY</b>:
Roll area...................... 2507408
Extended memory (EM)........... 1556243755 or 2000305812 or 1037050977
Assigned memory (HEAP)......... 1928325488 or 1998593376 or 1979245248
Short area..................... 16079
Paging area.................... 49152 or 57344
Maximum address space.......... "-30553184"
In case of <b>MEMORY_NO_MORE_PAGING</b>:
Roll area...................... 16128
Extended memory (EM)........... 48170595
Assigned memory (HEAP)......... 0
Short area..................... 0
Paging area.................... 24576
Maximum address space.......... "-30553184"
At OS level the system usualy does not swap.
Thanks,
Ruzica
Hello Ruzica,
The reason for the TSV_TNEW_PAGE_ALLOC_FAILED and TSV_TNEW_BLOCKS_NO_ROLL_MEMORY dumps is normally that you are hitting limits per process or per instance for heap and extended memory.
Parameter rdisp/ROLL_SHM should remain unchanged and rdisp/ROLL_MAXFS only increased if ST02 is indicating it is close to being exhausted which I don't expect. Maybe you could post the usage of SAP paging, SAP roll, EM and Heap for this instance from the initial screen of ST02?
Use the note <a href="http://service.sap.com/sap/support/notes/146289">146289</a>(Parameter Recommendations for 64-Bit SAP Kernel) for values of ztta/roll_area and ztta/roll_first. Setting ztta/roll_area to 6500000 in itself should not mean increases in the other parameters.
What are the default (right hand side) values from SE38 -> RSPARAM for rdisp/PG_SHM, rdisp/PG_MAXFS, rdisp/ROLL_SHM and rdisp/ROLL_MAXFS?
What are the values of the following:
abap/heap_area_dia
abap/heap_area_nondia
abap/heap_area_total
em/initial_size_MB
Are there any other instances installed on this host of 16GB RAM?
The answer to these questions will help determine if parameter changes will help or if data selections of the reports causing these dumps need to be reduced to avoid these dumps.
Thanks, Mark
Hello Ruzica,
The MEMORY_NO_MORE_PAGING dumps are caused by a lack of SAP paging at the time and a seperate issue to the other dumps.
You should review the SAP paging usage history in ST02 and determine
if an increase in rdisp/PG_MAXFS is needed. This can be increased as
per note <a href="http://service.sap.com/sap/support/notes/133909">133909</a>. A 50% increase may be enough or sometimes more is
needed to avoid a similar situation where paging is exhausted.
There must be enough filesystem space for the new larger file size
for SAP paging if increasing, note <a href="http://service.sap.com/sap/support/notes/16513">16513</a> contains the following
also:
-
5. Pagefile and rollfile:
The files PAGFILnn and ROLLFLnn are normally located in the data
directory. Do not delete them while the system is online. If the
System is offline (but only then!!!), you can delete the roll and
page files. They are automatically created again during the R/3
System startup, and grow as necessary up to the allowed maximum.
Therefore, deleting them makes hardly any sense.
Exception: If the file has been enlarged beyond the normal size for
some special action (for example, client copy) the required disk
space can be retrieved by deleting the file. As mentioned above,
this may only be done when the instance is offline.
The maximum size of the roll file is given by:
(rdisp/ROLL_MAXFS - rdisp/ROLL_SHM) * 8 kBytes
A similar formula appplies to the paging file.
You can move the files to a different file system by defining other
values for R/3 parameters DIR_ROLL and DIR_PAGING.
-
General advice is as follows if you suspect that SAP paging usage
is too high for this system:
-
SAP Paging enables the roll area to be extended at ABAP runtime
when a large dataset, internal tables, for example, is handled.
SAP's memory management concept currently limits SAP Paging to
cases where the ABAP commands EXTRACT and EXPORT... TO MEMORY...
are used.
You can use SM04 -> Goto -> Memory to see a breakdown including
SAP paging usage for current times only.
The objects that continue to be stored in the SAP paging memory for
later releases can be divided into groups:
- ABAP data clusters stored temporarily with the ABAP statement
IMPORT/EXPORT FROM/TO MEMORY: This data is stored in the SAP paging
memory because it is not tied to a user context. The IMPORT/EXPORT
FROM/TO MEMORY statement exports the data from a user context via the
paging memory and then imports in another context.
- Parameters transferred when programs and transactions are called: A
new user context is created when an ABAP calls another program or
another transaction. The variables and lists transferred when the
relevant program is called or ended are likewise stored in the
SAP paging memory.
You may need to discuss this with users and ABAP programmers if
any Z-Programs are using a high amount of paging.
-
Regards, Mark
Hello Mark,
Thank you, your answers are very interesting.
Please look at the bellow parameters in our system:
Roll, extended and heap memory
ztta/roll_area 3000000
ztta/roll_first 1
ztta/short_area 1400000
rdisp/ROLL_SHM 16384
rdisp/PG_SHM 8192
rdisp/PG_LOCAL 150
em/initial_size_MB 4092
em/blocksize_KB 4096
em/address_space_MB 4092
ztta/roll_extension 2000000000
abap/heap_area_dia 2000000000
abap/heap_area_nondia 2000000000
abap/heap_area_total 2000000000
abap/heaplimit 40000000
abap/use_paging 0
System default value for (from RSPARAM):
1. rdisp/PG_SHM = 8192;
2. rdisp/PG_MAXFS = 32768;
3. rdisp/ROLL_SHM = 16384;
4. rdisp/ROLL_MAXFS = 32768.
<u>From ST02 (from one moment in time): </u>
SAP memory Current use Max. use In memory On disk
[%] [kB] [kB] [kB] [kB]
Roll area 7,45 47.672 68.856 131.072 508.928
Paging area 14,04 73.584 211.624 65.536 458.752
Extended Memory 62,82 2.629.632 4.186.112 4.186.112
Heap Memory 0 1.953.101
There is no other instance on the server.
What do you think?
Thanks in advance.
Ruzica
Hello Ruzica,
If this is the instance where the dumps happened, was it restarted recently as the low maximum values in ST02 indicate it was? If you go to the history section of ST02, what are the peak uses of SAP Paging and Extended Memory compared to now? The first screen of ST02 is giving maximum values since the last restart of the instance only but the history should contain the information of the day when the dumps happened.
I expect ST02 history to show that maximum usage of SAP paging was the buffer plus the file totalled at some point or closer to it. The main thing I notice is that em/initial_size_MB set to 4092 is very low, this is limiting the total EM for the instance to this amount, two large memory intensive reports can exhaust this alone (ztta/roll_extension of 2GB for each). With 16GB of RAM and no other instance on the host, you can increase this as needed towards the full 16GB (even above RAM is possible once you check performance and increase in increments). This change will help ensure that the EM per process can get the 2GB expected without being limited early by em/initial_size_MB. This will explain why the EM varied for the time of the dumps but heap was getting close to the 2GB of total each time which indicates that other reports were not using heap at the same time.
Regards, Mark
Hello Mark,
Yes, I should have told you, the previous day offline backup was performed on the instance, that's why the buffers are clean.
<b>Roll area sizes [kB]</b>
Used Max. used In SHM On disk
46.264 68.856 131.072 508.928 (today)
3.608 68.856 131.072 508.928
3.688 76.224 131.072 508.928
3.440 76.224 131.072 508.928
3.384 76.224 131.072 508.928
3.384 76.224 131.072 508.928
5.904 76.224 131.072 508.928
3.520 76.224 131.072 508.928
3.520 76.224 131.072 508.928
3.384 8.064 131.072 508.928
3.384 9.032 131.072 508.928
3.576 56.656 131.072 508.928
3.576 56.656 131.072 508.928
3.576 56.656 131.072 508.928
3.520 55.464 131.072 508.928
3.384 24.248 131.072 508.928
2.112 119.536 131.072 508.928
2.112 66.040 131.072 508.928
3.384 8.472 131.072 508.928
3.384 8.472 131.072 508.928
3.744 54.456 131.072 508.928
4.048 54.456 131.072 508.928
<b>Page area sizes [kB]</b>
Used Max. used In SHM On disk
69.968 211.624 65.536 458.752 (today)
56 211.624 65.536 458.752
56 524.280 65.536 458.752
56 524.280 65.536 458.752
56 524.280 65.536 458.752
56 524.280 65.536 458.752
7.632 524.280 65.536 458.752
56 524.280 65.536 458.752
56 479.912 65.536 458.752
56 16.072 65.536 458.752
56 16.552 65.536 458.752
56 278.512 65.536 458.752
56 278.512 65.536 458.752
56 278.512 65.536 458.752
56 271.592 65.536 458.752
56 118.384 65.536 458.752
32 290.640 65.536 458.752
32 256.112 65.536 458.752
56 16.096 65.536 458.752
56 16.096 65.536 458.752
56 360.872 65.536 458.752
56 360.872 65.536 458.752
<b> Extended memory sizes [kB]</b>
Used Max. used Available
2.543.616 4.186.112 4.186.112 (today)
77.824 4.186.112 4.186.112
73.728 4.186.112 4.186.112
69.632 4.186.112 4.186.112
69.632 4.186.112 4.186.112
69.632 4.186.112 4.186.112
180.224 4.186.112 4.186.112
73.728 4.186.112 4.186.112
77.824 4.186.112 4.186.112
69.632 139.264 4.186.112
69.632 126.976 4.186.112
73.728 3.178.496 4.186.112
73.728 3.178.496 4.186.112
73.728 3.178.496 4.186.112
77.824 3.178.496 4.186.112
73.728 1.245.184 4.186.112
73.728 4.186.112 4.186.112
77.824 4.186.112 4.186.112
69.632 462.848 4.186.112
69.632 462.848 4.186.112
77.824 4.186.112 4.186.112
86.016 4.186.112 4.186.112
How it looks like?
Can I shortly resume about the memory parameters?
1. em/initial_size_MB, regarding the 16GB of the RAM, should I increase to example: 8188 (the maximum value in RZ11 is 8196)?
2. ztta/roll_area to 6500000 ?
3. What about the rdisp/PG_MAXFS should it be increased for 50% = 131072 ? And the rdisp/PG_SHM to increase to 32768 ?
4. What do you think about the ztta/roll_extension = 2000000000, should I increase or to decrease the parameter?
5. And the roll area is there need to change the rdisp/ROLL_SHM = 16384 (32768) and rdisp/ROLL_MAXFS = 80000 (131072)?
Thanks in advance.
Many regards,
Ruzica
Hello Ruzica,
Not looking healthy currently without some changes
The history is indicating that the SAP paging area was exhausted at times in the past and also total of EM (The maximum in ST02 resets after each restart of the instance so it the history doesn't indicate that EM was exhausted each day of the past week, even though this is possible also).
- The value of em/initial_size_MB can be increased higher than 8GB (notes <a href="http://service.sap.com/sap/support/notes/146289">146289</a> , <a href="http://service.sap.com/sap/support/notes/835474">835474</a> and <a href="http://service.sap.com/sap/support/notes/182067">182067</a> have more information) and you can ignore the warning from RZ11. Monitoring ST02 will indicate how high you need to rise this to avoid exhuasting total EM for the instance but there should not be performance issues with increasing to towards the total of RAM if needed eventually.
- I would advise ztta/roll_area is set to 6500000.
- Parameter risp/PG_MAXFS should be increased by 50% initially, later increases may be needed also. If the SAP Paging usage is higher than you expect later then you can investigate the reason via SM04 as mentioned earlier. Parameter rdisp/PG_SHM should be set to the default value in RSPARAM unless recommended otherwise by TCC or others for performance reasons.
- I recommend that ztta/roll_extension is left at 2000000000. If a report dumps with 2GB of EM used and nearly 2GB of heap then this normally indicates that the data selection needs to be reduced or there is an issue that is specific to the that report running. (One reason to reduce ztta/roll_extension is if there was only limited RAM on the host and em/initial_size_MB could not be increased further and you wanted to avoid total EM being exhausted, a reason to increase ztta/roll_extension is if there was lots of resources to increase em/initial_size_MB and you had reports that need to use more EM than 2GB without fear of exhausting all EM).
- Usage of SAP roll is very low, the values of rdisp/ROLL_SHM and rdisp/ROLL_MAXFS don't need to be changed. The defaults according to RSPARAM should be fine.
Hope this helps.
Regards, Mark
Hello Mark,
Thanks for all your information. It's very good, helpful and understanding.
This Sunday I'll try to change the parameters in rz10 and restart the instance:
1. em/initial_size_MB = 8196,
2. ztta/roll_area = 6500000 and
3. rdisp/PG_MAXFS = 131072.
I hope everything will be good.
Many regards,
Ruzica
Hello Ruzica,
Don't forget to monitor in ST02 afterwards if further increases in em/initial_size_MB or rdisp/PG_MAXFS are needed. I expect that when these are sized as needed for the instance there will not be repeats of the various dumps unless ztta/roll_extension is itself reached in the memory used of a dump and heap total reached also as expected.
Regards, Mark
Hello Mark,
I've also inform our ABAP Developers to look in some custom developed Z_* programs which I found to be using very much of the Memory in sm04.
Maybe some changing in some reports will also be useful and will solve the problems.
But, I have to do my<b> basis</b> job, tune and change parameters.
Thanks for all your help.
Regards,
Ruzica
Hello Mark,
Just one think more.
What about the em/max_size_MB?
I need to change it also to 8196 just like em/initial_size_MB?
I read some notes saying about this warning.
Many regards,
Ruzica
Hello Ruzica,
Parameter EM/MAX_SIZE_MB doesn't need to be changed. This parameter is relevant for certain platforms only and was replaced by EM/TOTAL_SIZE_MB as of Kernel 46D Patch Level 570. Note 425207 has some more details.
Regards, Mark
Hello Ruzica,
Glad you found some suspects. The proposed change is not too severe to the SAP Paging file but if more and more increases are needed then it will become more important to investigate the reasons. Going to the file after the buffer is exhausted means performance dips especially if it is constant high usage of SAP paging.
Regards, Mark
Hello Mark,
I was planning to change the em/initial_size_MB, ztta/roll_area and rdisp/PG_MAXFS with rz10, save and activate the profile. After the offline backup which is also planned for Saturday early in the morning, the DB and the instance will be restarted and the new version of the profile will be active.
I was also planning to test the functionality in the system after the parameter changes. But, today, I've got request from our ABAPers to check and prepare the system, make security backups, for some project "Going Live" and on the weekend, starting on Saturday, we'll do import of transports and tests.
Is there a changes any problems to ocur after increasing the above profile parameters?
Because I will reschedule the profile changes for the other weekend in order to have time to test and be sure.
Thanks again,
Regards, Ruzica
Hello Ruzica,
With the amount of RAM you have and the fact that there are no other instances on the host, there should be no issues with these changes. The increase in rdisp/PG_MAXFS may mean a slight dip in performance if SAP paging usage is higher than current maximum at all times but should not be very noticable.
Regards, Mark
Hello Mark,
My problem has been solved.
I have stopped changes for the memory parameters. We implement one SAP Note regarding the problematic Z_* program which was extremely increasing the Total memory and Page, and gets many wp with PRIV.
It seems that this was the problem!
One week without any Memory dump.
But, as we mentioned in the previous posts, I have prepared new profile and after one another good week, I will increase the parameters.
Thanks for all,
Many regards,
Ruzica
Hi,
We are facing the same issue related to RSCRM_BAPI background job.
The job is cancelling with the TSV_TNEW_PAGE_ALLOC_FAILED or TSV_TNEW_BLOCKS_NO_ROLL_MEMORY.
We tried few notes but not solved. plz give details how this was resolved.
Some times the same issue is occurring for Precalculated query.
We did recently upgrade from 3.x to BI7.0. Jobs worked fine before upgrade.
Please suggest how it can be resolved.
Thanks,
Joseph
Hi Ruzica,
Could you please share the solution with us.
Even i am getting this error, while i runa Z program on batch job. It will be great if you share that thoughts here, as this issue is been dumping in production since for a while.
Thanks in advance,
Kiran
Ruzica,
Can you please share which OSS note resolved your problem? We also have a z program that is causing dump with the same error message.
Thanks,
Padma
Hi Ruzica,
Could you please post the note number as we are facing the same problem.
Thank you
Hi All,
Anyone knows what was that Note number?
Regards,
Gabor
PLEASE NO-ONE REPLY ANYMORE TO Ruzica Kalkasliev .
Ruzica: if you have the answer to one problem, you should share it with the others, as when you have a problem everyone will help you.
Please show some respect to the others who are facing the same issues.
having the same issues, anyone figured what's the note he talked about?
hi Ruzzia..
please share the note number
Thanks & Regards,
Abhilash
Note 1007749 - DataSource replication: Shrt dump TSV_TNEW_PAGE_ALLOC_FAILED
Try this one.
Mark
You seem to have a really good understanding of the details behind the memory allocation i can figure that out from your response.
Have you published any white paper or blogs to share the knowledge ? if yes please paste the link here.
If not i would request you to do so
Cheers !
Manish
Hi Mark,
I have one question regarding these memory configuration..is this extended memory resides on RAM or swap? and whats this paging memory actually mean for?
Rgds,
Bansri
该文档由下列讨论生成:TSV_TNEW_PAGE_ALLOC_FAILED and TSV_TNEW_BLOCKS_NO_ROLL_MEMORY
How to generate a graph with an X-axis and two Y-axes?
ABAP Best Coding Practices
Hi All,
Following are some of the best coding practices that an ABAPer must follow.
1. Avoid writing select query on a same table more than once
Since the retrieval of the data from the database take most of the processing time, it is better to fetch the required data from the table once and store it in a internal table for further processing
2. Refreshing the internal tables. Clearing variables & structures
In the custom program, before using the declared internal tables, work area & variables initialize them to default values. Use CLEAR statement for variables & work area. Use REFRESH statement for internal tables.
3. Clear work area at the end of every LOOP pass
In order to avoid the problems such as carryover of the values of some field of work area corresponding to the last loop pass to the next loop pass, we need to clear the work area at the end of every LOOP pass.
4. Avoid using the MOVE-CORRESPONDING
Compiler has to search & map the corresponding fields in case of MOVE-CORRESPONDING statement, hence it impact the performance. So, it is better to go for individual field assignment in case of copying the work area content to other inside the LOOP.
5. Release the memory occupied by internal tables &work area
At the end of the program uses FREE statement to release the memory occupied by the internal tables, work area& internal tables.
6. Avoid hard coding
Declare the CONSTANTS & use them in the program instead of hard coding the values.
7. Check SY-SUBRC value after SELECT , READ statements
Putting the appropriate set of code based on the value of the sy-subrc after SELECT or READ statement enhances the performance & helps in avoiding execution of the unwanted code
8. Check for internal table (it_tab) IS NOT INITIAL before using FOR ALL ENTRIES
Before using FOR ALL ENTRIES in the select statements, it is best practice to check does the table in the in the FOR ALL ENTRIES is having some records in it.
9. Remove the unused constants, variables, work area & internal tables from the program
Unused constants, variables, work area & internal tables are the dead codes in the program. So, by removing the dead codes we can make the code more readable.
10. Avoid LOOP on the same internal table more than once
Try to include the required logic inside the same LOOP in order to enhance the performance.
11. Avoid declaring the internal tables with header line
Declare separate work area to process the records of the internal table. By doing this one can avoid the chances of not clearing the header line in case of internal table with header line.
12. SORT the internal table before using BINARY SEARCH in the READ statement.
READ statement fails to read the entry from the table if you are using BINARY SEARCH on unsorted internal table. So, SORT the internal table by the key fields which you are using in the READ statement.
13. Place the most probable condition in the IF statement
This enhances the performance of the code when processing large amount of data.
Thanks & Regards,
Venugopal M N
IDOCs - Basics & Relevant Transactions
IDOCs are the intermediate documents which act as the container for the data. IDOCS are used in sending the information between SAP systems.
IDOCs are of two types
- Inbound IDOCs
- Outbound IDOCs
Inbound IDOCs
Incoming IDOCs to the SAP system are called as Inbound IDOCs.
Outbound IDOCs
IDOCs which are sending out of an SAP system are called as Outbound IDOCs.
Each IDOC will be associated with
- Unique IDOC number
- Control Record (EDIDC table)
- Data Record (EDID2 / EDID4 tables)
- Status Record (EDIDs table)
Following are the some of the important transactions which are used in IDOCs
- WE31: Used to create the segments for IDOCS
- WE30: Used to create IDOCs types (Basic/Extended)
- WE81: Used to create message type
- WE82: Used to link message type to an IDOC type
- WE57: Used to assign custom FM(Function Module) to an IDOC type & message type
- WE41: Used to create an outbound process code
- WE42: Used to create an inbound process code
- BD67: Assign function module to the process code
- WE60: Used to document the IDOCs (IDOC documentation)
- WE19: Used to test the IDOCs
- WE20: Used to create the partner profiles
- WE21: Used to create ports
- BD64: Used to define distribution module
- We05/We02: Used to display the IDOCs
Thanks & Regards,
Venugopal M N