1. Enter the table name and press Create
2. Enter the description, Delivery class and check on table maintenance allowed. Then click on the tab Fields.
8. Then press Definition tab and enter the domain.
9. Double click on that zchar_d to create domain, then it will ask for save before going next screen.
11. Now it will ask for domain creation. Press Yes.
12. Give short description for that domain which you are creating. And mention the data type in data type field and length in no. characters field an press ENTER.
14. Press Enter.
18. Create one more field ZNUM and give data element name as ZNUM_DE. And double click on
19. Save it by pressing Yes.
21. Give short description of the data element. And give the lengths and field labels accordingly in Field label tab.
23. It will ask for save. Press Yes.
25. Now it asks for Domain creation. Press Yes.
26. Give short description in short text field. Enter the data type and no. characters, Press Enter.
33. Now we created two fields. And Data elements and Domain for these two fields.
34. Give the data class and size category of the table as per the requirement.
36. Press enter.
41. Enter the data for the second entry into the table. 42. Save it and press reset.
44. Again enter the data for the third entry.
Now enjoy by creating tables on your own.
Creating a Structure in ABAP Dictionary
Go to transaction SE11 and select the radio button “Data type”. Enter a structure name starting with Y or
Press create button.
A pop-up screen appears with 3 different options. Select the radio buttonstructure.
The screen will be displayed like this.
Then pressSAVE,CHECKandACTIVATE.
Structure Created Successfully.
Creating Search Helps (Elementary and Secondary)
By Vikram Chellappa, Mouri Tech Solutions
Go To SE11 T-code.
Select ELEMENTARY search help.
Press Enter.
Provide the short description, the selection method.
Save it, Check It & Activate it.
Then press F4 View the output like this.
This is the output for elementary search help.
Provide name. Select collective search help button.
Press enter.
Select include search help.
Then provide search help name, which is already define by the same fields.
1) Elementary search helps describe a search path. The elementary search help must define where the data of the hit list should be read from (selection method), how the exchange of values between the screen template and selection method is implemented (interface of the search help) and how the online input help should be defined (online behavior of the search help).
2) Collective search helps combine several elementary search helps. Collective search help thus can offer several alternative search paths.
3) An elementary search help defines the standard flow of an input help.
4) A collective search help combines several elementary search helps. The user can thus choose one of several alternative search paths with collective search help.
5) A collective search help comprises several elementary search helps. It combines all the search paths that are meaningful for a field.
6) Both elementary search helps and other search helps can be included in a collective search help. If other collective search helps are contained in collective search help, they are expanded to the level of the elementary search helps when the input help is called.
Creating a secondary index
There are two types of indexes: Primary index and secondary index. Primary index is automatically created using the primary keys defined.
Secondary index could be created as per the user requirement. This article discusses about creating a secondary index.
For our demo purpose, we have considered the table ZAUTHOR.
To know if there are any secondary indexes available, click on GotoIndexes
From the above screenshot, it is evident that there are no secondary indexes already created.
Click on CreateCreate Index
Enter the name of the index.
Save and activate.
Maximum number of secondary indexes we can have are 9.
How to make SELECT statement to make use of any particular secondary index?
Secondary Indexes
Consider the following example: SELECT * FROM SPFLI
%_HINTS ORACLE 'INDEX("SPFLI" "SPFLI~001")' ...
ENDSELECT.
In the above example, 001 is the secondary index of the table SPFLI. It's a well-known fact that the efficient way of retrieving data from the database tables is by using secondary indexes. Many database vendors provide
the optimizer hints for the same. From SAP® v4.5, optimizer hints can be provided by the %_HINTS parameter.
This is dependent on the database systems that support optimizer hints. The point to be noted here is these optimizer hints are not standardized by the SQL standards. Each database vendor is free to provide the optimizer hints.
Now to know which index to use for our table: 1. Go to SE11 and there specify the table name 2. Now from the menu, goto --> indexes
3. select the required index.
Now suppose that the identifier 001 represents a non-unique secondary index comprising of the columns CITYFROM and CITYTO. The index name should be defined as:
<tablename>~<Index Identifier> like SPFLI~001 in the above example.
The sequence of fields in the WHERE condition is of no relevance in using this optimizers index. If you specify hints incorrectly, ABAPTMignores them but doesn't return a syntax error or runtime error.
The code was written in R/3 4.6C.
Code
Consider the following example:
REPORT Suresh_test.
TABLES: spfli.
DATA : t_spfli LIKE spfli OCCURS 0 WITH HEADER LINE.
SELECT * FROM spfli INTO TABLE t_spfli
%_HINTS ORACLE 'INDEX("SPFLI" "SPFLI~001")'.
LOOP AT t_spfli. WRITE :/ t_spfli. ENDLOOP.
Go to SE11 and enter the Z table name for which the table maintenance generator has to be generated. Click on Change.
Enter Authorization group (For e.g. &NC&)
Function group (go to SE80 for creating function group)
You can select either one step or two step. Assign Screen numbers (To assign Screen numbers click on the button 'Find Scr no'. It will propose screen no's)
Then Create. Save
Single step: Only overview screen is created i.e. the Table Maintenance Program will have only one screen where you can add, delete or edit records.
Two step: Two screens namely the overview screen and Single screen are created. The user can see the key fields in the first screen and can further go on to edit further details.
You can now create TCode for the table maintenance generator. Enter the TCode to be created and click on Create.
Creation of a Logical Database
Enter the logical database name as shown above .
If we are using Logical Database for HR purpose, we should check the check Box “Info types (HR only).
Press CREATE Button as shown above.
On pressing Save button, following screen appears, prompting for the details of the root node.
Now enter the details of all the tables under LFA1 (as shown below).
Click on create Button.
The above screen displays the LDB structure as per our requirements.
Click on save.
Now you can create the table entries through the transaction created above.
Here by using above marked statement we can create Dynamic selection screen for different tables as per the requirements.
Creation of a Logical Database
Database program (with some includes) are automatically created upon the creation of logical database:
Go back to the main screen.
Creation of a View cluster
By T.N.Swapna View Cluster
A view cluster is the set of objects, such as views, reports or tables, which belong to one business function. The data can be arranged either hierarchically or non-hierarchically in view cluster. A view-cluster transaction edits the complex cross-table data in a view view-cluster. The transaction navigation box shows the complex business object with its components or sub objects.
Example:
Let us create a View Cluster on Material Details. The view cluster would include three tables namely, MARA, MARC and MARD. We need to create maintenance views for each of these tables.
By default all the key fields would be added. We can add more fields by clicking on the button Table fields.
Now Save and activate the view.
Maintenance view for Table MARC
Follow the same procedure as above. In the Tab View fields, give „S‟ in the column „P‟ for the fields
This is because the fields MANDT and MATNR would be filled in the view for MARA and thus they act as subsets and appear as header data when we create entries in view cluster.
Maintenance view for Table MARD
Follow the same procedure as above. In the Tab View fields, give „S‟ in the column „P‟ for the fields
The table maintenance screen appears. Here give the details as in the screen shot below. This table maintenance is for the view ZMM_V_ MARA.
Before creating a table maintenance generator, create a function group say ZFG_MATERIAL from the transaction SE80. After the function group is successfully created, enter the function group name as
Similarly, create the Table maintenance Generators for the views ZMM_V_MARC and ZMM_V_MARD. The screen shots for these views would be as follows:
Note that the Overview screen numbers would change for each view. It would be „2‟ for the view
ZMM_V_MARC and it would be „3‟ for the view ZMM_V_MARD.
Creating view cluster
The pre-requisites for creating the View Cluster are now ready. Go to transaction SE54 and select the
button „Edit View Cluster‟. Enter the view cluster name as say „ZMM_VC_MATERIAL‟ and click on „Create‟.
An information message would pop up saying
Continue by pressing „Enter‟. The following screen appears. Give a short description and click on „Object Structure‟ as shown in the screen shot below:
On Clicking the „Object Structure‟ the following screen appears. Select the „New Entries‟ button to enter
the maintenance views created to form a cluster.
Enter the values as shown below:
The entries would be entered in a hierarchical manner. The short text is the description of the view. The
„Predecess‟ column specifies the predecessor of that view. So in this case, the predecessor of
ZMM_V_MARA is ZMM_V_MARA itself. The predecessor of ZMM_V_MARC is ZMM_V_MARA and the predecessor of ZMM_V_ MARD is ZMM_V_MARC. The „DEP‟ column explains whether the entry is a Header entry or a Dependent entry. It is „R‟ for the view ZMM_V_MARA, because it is a header entry and
does not depend on any other view. Whereas, it is „S‟ for ZMM_V_MARC and ZMM_V_MARD, because
ZMM_V_MARC is dependent on ZMM_V_MARA and ZMM_V_MARD is dependent on ZMM_V_MARC.
The column „POS‟ specifies the sequence of the views. In the column „Start‟ select the radio button
against the entry for ZMM_V_MARA as it comes first in the hierarchy.
After entering the above entries, press „Enter‟. Three pop-ups for each view would appear as shown
Now select each line and click on „Field-dependence‟ button. A pop-up appears saying „Field
dependencies successfully generated‟.
Generate the field dependence for the views ZMM_V_MARC and ZMM_V_MARD in the same way. Now,
The view cluster is now created successfully.
Note:
1. The view cluster can be created on the tables whose data has to be stored in a hierarchical
manner.
2. One has to check whether proper foreign key relationships are maintained between the tables
appearing in the cluster. Sometimes while generating the Field-dependencies, errors may occur if the foreign keys are not maintained properly.
Testing the View Cluster
From the initial screen of the transaction „SE54‟ give the view cluster name and click on „Test‟.
Since we have created the view cluster on standard tables MARA, MARC and MARD we observe that all the existing entries would appear. The screen shot below shows all the existing entries of the table MARA. In order to see the corresponding Plant details for the material, just select an entry and double click on Plant details as shown below.
The plant details would appear. In the same way for the corresponding storage location details, select an entry and double click on Storage details as shown below.
In the above screen shot the material selected in the Material details view would appear as a header entry. The storage location details are as follows:
Row level locking of database table
By Swetabh Shukla, Infosys Technologies
Normally if a person opens table maintenance generator and tries to maintain the table, no one else can maintain the same table at the same time. This is because of table level lock by default in SAP. Only one user can maintain any table at a time through SM30 or any transaction that calls table maintenance generator. In the tutorial below we will see how to remove table level lock and apply row level lock. This way any number of users can modify the table at same time. But any particular row can be modified by only one user at a time. We will create a transaction for this purpose. The transaction will call our custom report. This custom report will call the table maintenance generator of the table after deleting table level lock.
In current example let‟s create following:
Report: ZREP_SHUKS3
Transaction: ZTEST_SHUKS3
Table: ZTEST_SHUKS3 with table maintenance generator.
Using transaction ZTEST_SHUKS3 we will delete the table level lock and put row level lock so that multiple users can maintain table at same time. Rows locked by one user will not be editable by other user.
1. Create table ZTEST_SHUKS3.
We will make single screen maintenance for this table. Save it. So finally we have table maintenance code automatically generated in function group ZTEST_SHUKS3.
Now save and activate the Lock object. SAP creates two function modules corresponding to lock object for enqueue and dequeue of the table.
4. Now create a report ZREP_SHUKS3 and transaction code ZTEST_SHUKS3 to call this report. This
user can maintain any table at a time. In report ZREP_SHUKS3 we will delete the table level lock and put row level lock so that multiple users can maintain table at same time. Rows locked by one user will not be editable by other user. Check the report and comments given below.
*&---* *& Report ZREP_SHUKS3
*&
*&---*& Author : Swetabh Shukla
*& Date : 05/22/2009
*& Description : To delete table level lock from table. *&---* REPORT zrep_shuks3.
**Selection range for view maintenance DATA:
BEGIN OF selekttab OCCURS 1. "Selektionsbereich INCLUDE STRUCTURE vimsellist.
DATA: END OF selekttab,
**Table of inactive CUA functions for view maintenance
BEGIN OF excl_cua_funct OCCURS 1. "inaktive CUA-Fkt bei View-Pflege INCLUDE STRUCTURE vimexclfun.
DATA: END OF excl_cua_funct.
DATA: lt_enq_del TYPE STANDARD TABLE OF seqg3, lt_enq_read TYPE STANDARD TABLE OF seqg7, lw_enq_read TYPE seqg7,
lw_enq_del TYPE seqg3, lv_subrc TYPE sy-subrc.
*Read all the lock details in system CALL FUNCTION 'ENQUE_READ2'
EXPORTING gclient = sy-mandt gname = ' ' guname = '*' TABLES enq = lt_enq_read.
*We will search entry for table level lock for our table LOOP AT lt_enq_read INTO lw_enq_read
WHERE gname EQ 'RSTABLE' AND garg CS 'ZTEST_SHUKS3'.
MOVE-CORRESPONDING lw_enq_read TO lw_enq_del. APPEND lw_enq_del TO lt_enq_del.
TABLES
enq = lt_enq_del.
*Now call the table maintenace generator.
CALL FUNCTION 'VIEW_MAINTENANCE_CALL' EXPORTING action = 'U' view_name = 'ZTEST_SHUKS3' show_selection_popup = 'X' TABLES dba_sellist = selekttab excl_cua_funct = excl_cua_funct.
6. Just one more change in table maintenance screen. Now open table maintenance function
group(ZTEST_SHUKS3) in SE80.We know for table maintenance SAP automatically creates code in the function group. Now we will make some modification in that existing code to change the behavior. Open the screen you created through table maintenance and add one module.
Check the code below to be added in the module m_change_locking.
MODULE m_change_locking OUTPUT.
*Call the function module corresponding to the lock object we created CALL FUNCTION 'ENQUEUE_EZTEST_SHUKS3'
EXPORTINGmatnr = ztest_shuks3-matnr werks = ztest_shuks3-werks EXCEPTIONS foreign_lock = 1 system_failure = 2 OTHERS = 3. IF sy-subrc NE 0.
* row is locked..hence gray.. LOOP AT SCREEN.
screen-input = 0. MODIFY SCREEN. ENDLOOP.
ENDIF.
ENDMODULE. " m_change_locking OUTPUT
Save data.
Let‟s call two sessions of the transaction ZTEST_SHUKS3.
Session 1
In first session we will call the transaction ZTEST_SHUKS3 and try to open some existing values for table maintenance.
So the entry opens in change mode.
Now open a second session of the transaction and see. Now the same material and plant combination can not be changed by any other user or session.
Session 2
So we can see that our transaction is able to achieve a row level locking and has removed table level locking.
Creation of a table pool and pool table
By Kiran Kumar Kandakatla, Intelligroup
In this Tutorial, we create a Table pool first and then create/ (add a table to Table pool) a Pooled Table.
Step 1:
Select Radio button Table pool/Cluster Give table Pool Name: ZTBL_POOL.
Then press F5 or choose Create.
Step 3:
Step 4:
Then you go to maintain Poll Screen there give Short Description.
Step 5:
Step 6:
Go to SE11 ABAP Dictionary: Initial Screen.
Create a Z table.
Step 8:
Add fields to the Z table.
Maintain Technical settings and Enhancement Category.
Step 10:
Choose Table type.
In our Example it is Pooled table.
Step 11:
We have successfully created Table pool and Pooled table.
PDF Viewer
By Sai Kumar B, Enteg
This Program helps you to view any output in PDF viewer as shown below.It‟s very simple to understand.
Just convert OFT data into PDF as below.
*&---* *& Report ZSAP_PDF_VIEWER_DEMO_2
*&
*&---*
REPORT ZSAP_PDF_VIEWER.
DATA: LT_PDF TYPE TABLE OF TLINE, LS_PDF LIKE LINE OF LT_PDF, LV_URL TYPE CHAR255,
PDF_FSIZE TYPE I,
LV_CONTENT TYPE XSTRING,
LT_DATA TYPE STANDARD TABLE OF X255.
DATA : L_JOB_OUTPUT_INFO TYPE SSFCRESCL. DATA : LS_CONTROL_PARAM TYPE SSFCTRLOP.
INITIALIZATION. LS_CONTROL_PARAM-GETOTF = 'X'. LS_CONTROL_PARAM-NO_DIALOG = 'X'. START-OF-SELECTION. CALL FUNCTION '/1BCDWB/SF00000034' EXPORTING * ARCHIVE_INDEX = * ARCHIVE_INDEX_TAB = * ARCHIVE_PARAMETERS = CONTROL_PARAMETERS = LS_CONTROL_PARAM P_VBELN = P_VBELN * MAIL_APPL_OBJ = * MAIL_RECIPIENT = * MAIL_SENDER = * OUTPUT_OPTIONS = * USER_SETTINGS = 'X' IMPORTING * DOCUMENT_OUTPUT_INFO = L_DOCUMENT_OUTPUT_INFO JOB_OUTPUT_INFO = L_JOB_OUTPUT_INFO * JOB_OUTPUT_OPTIONS = L_JOB_ OUTPUT_OPTIONS
EXCEPTIONS FORMATTING_ERROR = 1 INTERNAL_ERROR = 2 SEND_ERROR = 3 USER_CANCELED = 4 OTHERS = 5 . IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CALL FUNCTION 'CONVERT_OTF' EXPORTING FORMAT = 'PDF' IMPORTING BIN_FILESIZE = PDF_FSIZE TABLES OTF = L_JOB_OUTPUT_INFO-OTFDATA LINES = LT_PDF EXCEPTIONS ERR_MAX_LINEWIDTH = 1 ERR_FORMAT = 2 ERR_CONV_NOT_POSSIBLE = 3 OTHERS = 4.
* convert pdf to xstring string LOOP AT LT_PDF INTO LS_PDF.
ASSIGN LS_PDF TO <FS_X> CASTING.
CONCATENATE LV_CONTENT <FS_X> INTO LV_CONTENT IN BYTE MODE. ENDLOOP.
*&---* * text
*---* MODULE STATUS_0100 OUTPUT.
* SET PF-STATUS 'xxxxxxxx'. * SET TITLEBAR 'xxx'.
CREATE OBJECT G_HTML_CONTAINER EXPORTING
CONTAINER_NAME = 'PDF'.
CREATE OBJECT G_HTML_CONTROL EXPORTING
PARENT = G_HTML_CONTAINER.
* Convert xstring to binary table to pass to the LOAD_DATA method CALL FUNCTION 'SCMS_XSTRING_TO_BINARY'
EXPORTING
BUFFER = LV_CONTENT TABLES
BINARY_TAB = LT_DATA.
* Load the HTML
CALL METHOD G_HTML_CONTROL->LOAD_DATA( EXPORTING TYPE = 'application' SUBTYPE = 'pdf' IMPORTING ASSIGNED_URL = LV_URL CHANGING DATA_TABLE = LT_DATA EXCEPTIONSDP_INVALID_PARAMETER = 1 DP_ERROR_GENERAL = 2 CNTL_ERROR = 3 OTHERS = 4 ). * Show it
CALL METHOD G_HTML_CONTROL->SHOW_URL( URL = LV_URL IN_PLACE = 'X' ).
ENDMODULE. " STATUS_0100 OUTPUT
*&---* *& Module USER_COMMAND_0100 INPUT
*&---* * text
*---* MODULE USER_COMMAND_0100 INPUT.
Convert internal table data into HTML format without using Function
Modules
By Suman Kumar Chinnam
The output of this Tutorial is same as previous one but in this we are not using any function modules to convert internal table data to HTML table.
*&---* *& Report YTEST_TABLE_HTML1
*---* * D A T A D E C L A R A T I O N
*---* *-HTML Table
DATA:
t_html TYPE STANDARD TABLE OF w3html WITH HEADER LINE, " Html Table *- Declare Internal table and Fieldcatalog
it_flight TYPE STANDARD TABLE OF sflight WITH HEADER LINE, " Flights Details it_fcat TYPE lvc_t_fcat WITH HEADER LINE.
" Fieldcatalog *-Variables DATA: v_lines TYPE i, v_field(40). *-Fieldsymbols
FIELD-SYMBOLS: <fs> TYPE ANY.
*---* * S T A R T - O F - S E L E C T I O N *---* START-OF-SELECTION. SELECT * FROM sflight
INTO TABLE it_flight UP TO 20 ROWS.
*---* * E N D - O F - S E L E C T I O N
*---* END-OF-SELECTION.
*-Fill the Column headings and Properties
* Field catalog is used to populate the Headings and Values of * The table cells dynamically
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE' EXPORTING i_structure_name = 'SFLIGHT' CHANGING ct_fieldcat = it_fcat[] EXCEPTIONS inconsistent_interface = 1 program_error = 2.
DELETE it_fcat WHERE fieldname = 'MANDT'. t_html-line = '<html>'. APPEND t_html. CLEAR t_html. t_html-line = '<thead>'. APPEND t_html. CLEAR t_html.
APPEND t_html. CLEAR t_html.
t_html-line = '</thead>'. APPEND t_html.
CLEAR t_html.
t_html-line = '<table border = "1">'. APPEND t_html.
CLEAR t_html.
t_html-line = '<tr>'. APPEND t_html.
CLEAR t_html.
*-Populate HTML columns from Filedcatalog LOOP AT it_fcat.
CONCATENATE '<th bgcolor = "green" fgcolor = "black">' it_fcat-scrtext_l '</th>' INTO t_html-line. APPEND t_html. CLEAR t_html. ENDLOOP. t_html-line = '</tr>'. APPEND t_html. CLEAR t_html.
DESCRIBE TABLE it_fcat LINES v_lines.
*-Populate HTML table from Internal table data LOOP AT it_flight.
t_html-line = '<tr>'. APPEND t_html.
CLEAR t_html.
*-Populate entire row of HTML table Dynamically *-With the Help of Fieldcatalog.
DO v_lines TIMES.
READ TABLE it_fcat INDEX sy-index.
CONCATENATE 'IT_FLIGHT-' it_fcat-fieldname INTO v_field. ASSIGN (v_field) TO <fs>. t_html-line = '<td>'. APPEND t_html. CLEAR t_html. t_html-line = <fs>. APPEND t_html. CLEAR t_html. t_html-line = '</td>'. APPEND t_html. CLEAR t_html. CLEAR v_field. UNASSIGN <fs>. ENDDO. t_html-line = '</tr>'. APPEND t_html. CLEAR t_html. ENDLOOP. t_html-line = '</table>'. APPEND t_html. CLEAR t_html.
*-Download the HTML into frontend CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
EXCEPTIONS file_write_error = 1 no_batch = 2 gui_refuse_filetransfer = 3 invalid_type = 4 no_authority = 5 unknown_error = 6 header_not_allowed = 7 separator_not_allowed = 8 filesize_not_allowed = 9 header_too_long = 10 dp_error_create = 11 dp_error_send = 12 dp_error_write = 13 unknown_dp_error = 14 access_denied = 15 dp_out_of_memory = 16 disk_full = 17 dp_timeout = 18 file_not_found = 19 dataprovider_exception = 20 control_flush_error = 21 OTHERS = 22. IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*-Display the HTML file
CALL METHOD cl_gui_frontend_services=>execute EXPORTING document = 'C:\Flights.htm' operation = 'OPEN' EXCEPTIONS cntl_error = 1 error_no_gui = 2 bad_parameter = 3 file_not_found = 4 path_not_found = 5 file_extension_unknown = 6 error_execute_failed = 7 synchronous_failed = 8 not_supported_by_gui = 9 OTHERS = 10. IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
Convert internal table data into HTML format using Function Modules
By Suman Kumar Chinnam
Following Function Modules are used to convert internal table data to HTML Table.
1. WWW_ITAB_TO_HTML_HEADERS is used to populate column headings. 2. WWW_ITAB_TO_HTML_LAYOUT is used to populate column cell properties. 3. WWW_ITAB_TO_HTML is used to convert internal table data to HTML.
*&---* *& Report YTEST_TABLE_HTML
*---* * T Y P E S D E C L A R A T I O N
*---* TYPES:BEGIN OF ty_sflight,
carrid TYPE s_carr_id, " Airline Code connid TYPE s_conn_id, " Connection Number fldate TYPE s_date, " Flight Date
price TYPE s_price, " AirFare currency TYPE s_currcode, " Currency END OF ty_sflight.
*-ALL related Declarations DATA:
t_header TYPE STANDARD TABLE OF w3head WITH HEADER LINE, "Header t_fields TYPE STANDARD TABLE OF w3fields WITH HEADER LINE, "Fields t_html TYPE STANDARD TABLE OF w3html, "Html wa_header TYPE w3head,
w_head TYPE w3head. DATA:
it_sflight TYPE TABLE OF ty_sflight, " Flights Details it_fcat TYPE lvc_t_fcat WITH HEADER LINE. " Fieldcatalog
*---* * S T A R T - O F - S E L E C T I O N *---* START-OF-SELECTION. SELECT * FROM sflight
INTO CORRESPONDING FIELDS OF TABLE it_sflight UP TO 20 ROWS. *---* * E N D - O F - S E L E C T I O N *---* END-OF-SELECTION. *-Populate Fieldcatalog
it_fcat-coltext = 'Airline Code'. APPEND it_fcat.
it_fcat-coltext = 'Connection Number'. APPEND it_fcat.
it_fcat-coltext = 'Flight date'. APPEND it_fcat.
it_fcat-coltext = 'Airfare'. APPEND it_fcat.
it_fcat-coltext = 'Currency'. APPEND it_fcat.
*-Fill the Column headings and Properties LOOP AT it_fcat.
w_head-text = it_fcat-coltext. *-Populate the Column Headings
*-Populate Column Properties
CALL FUNCTION 'WWW_ITAB_TO_HTML_LAYOUT' EXPORTING field_nr = sy-tabix fgcolor = 'black' size = '3' TABLES fields = t_fields. ENDLOOP.
*-Title of the Display
wa_header-text = 'Flights Details' . wa_header-font = 'Arial'.
wa_header-size = '2'.
*-Preparing the HTML from Intenal Table REFRESH t_html.
CALL FUNCTION 'WWW_ITAB_TO_HTML' EXPORTING table_header = wa_header TABLES html = t_html fields = t_fields row_header = t_header itable = it_sflight. *-Download the HTML into frontend
CALL FUNCTION 'GUI_DOWNLOAD' EXPORTING filename = 'C:\Flights.htm' TABLES data_tab = t_html EXCEPTIONS file_write_error = 1 no_batch = 2 gui_refuse_filetransfer = 3 invalid_type = 4 no_authority = 5 unknown_error = 6 header_not_allowed = 7 separator_not_allowed = 8 filesize_not_allowed = 9 header_too_long = 10 dp_error_create = 11 dp_error_send = 12 dp_error_write = 13 unknown_dp_error = 14 access_denied = 15 dp_out_of_memory = 16 disk_full = 17 dp_timeout = 18 file_not_found = 19 dataprovider_exception = 20 control_flush_error = 21 OTHERS = 22. IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
document = 'C:\Flights.htm' operation = 'OPEN' EXCEPTIONS cntl_error = 1 error_no_gui = 2 bad_parameter = 3 file_not_found = 4 path_not_found = 5 file_extension_unknown = 6 error_execute_failed = 7 synchronous_failed = 8 not_supported_by_gui = 9 OTHERS = 10. IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
By Joyjit Ghosh, IBM India
*&---* *& Report Z_CONTEXT_MENU_DEMO
*&
*&---* *& published at SAPTechnical.COM
*&
*&---* REPORT z_context_menu_demo.
* Table declaration
DATA: i_vbak TYPE STANDARD TABLE OF vbak INITIAL SIZE 0, i_vbap TYPE STANDARD TABLE OF vbap INITIAL SIZE 0. * Workarea declaration
DATA: w_vbak TYPE vbak, w_vbap TYPE vbap. START-OF-SELECTION. * Set custom status
SET PF-STATUS 'BASIC'. * Fetch header data
SELECT * FROM vbak INTO TABLE i_vbak UP TO 50 ROWS. IF sy-subrc = 0.
* Fetch line item data SELECT * FROM vbap INTO TABLE i_vbap
FOR ALL ENTRIES IN i_vbap WHERE vbeln = i_vbap-vbeln. CHECK sy-subrc = 0.
* Display basic list
LOOP AT i_vbak INTO w_vbak. FORMAT COLOR COL_HEADING. WRITE : /10 w_vbak-vbeln,20 w_vbak-erdat, 35 w_vbak-erzet, 55 w_vbak-ernam. HIDE: w_vbak-vbeln. ENDLOOP. ENDIF. AT USER-COMMAND. * Handle user command
CASE sy-ucomm. WHEN 'DETAIL'.
CHECK NOT w_vbak IS INITIAL. * Display detail list
LOOP AT i_vbap INTO w_vbap WHERE vbeln = w_vbak-vbeln. FORMAT COLOR COL_HEADING.
WRITE : /10 w_vbap-vbeln, 25 w_vbap-posnr, 35 w_vbap-matnr, 55 w_vbap-matwa. ENDLOOP. WINDOW STARTING AT 20 20 ENDING AT 120 110. ENDCASE.
*&---* * Creation of custom context menu- It is called dynamically * by ABAP runtime
*---* * -->L_MENU Handle for context menu
*---* FORM on_ctmenu_request USING l_menu TYPE REF TO cl_ctmenu.
DATA lin TYPE i. GET CURSOR LINE lin.
IF lin > 2 AND sy-lsind = 0. * Add menu
CALL METHOD l_menu->add_function EXPORTING
fcode = 'DETAIL' text = text-001. ENDIF.
* Add menu
CALL METHOD l_menu->add_function EXPORTING
fcode = 'BACK' text = text-002.
ENDFORM. "on_ctmenu_request
How SAP calls the routine ON_CTMENU_REQUEST:
Whenever user presses right mouse button or shift + F10 key combinations sap triggers system event and calls the method DISPATCH_SYSTEM_EVENTS of class CL_GUI_CFW. Within it, it calls the method DISPATCH of class LCL_DYNPRO_PROXY (defined within the class pool of CL_GUI_CFW).
From this method (DISPATCH) it calls the routine ON_CTMENU_REQUEST which is defined in our program.
Output:
Dynamic Selection Screen (Drop downs, pushbuttons, radio buttons,
icons)
By Swarna S, Tata Consultancy Services
Following is the code in which the selection screen changes based on the user's click on the radio buttons. The entire selection screen is changed. The F8 button is disabled and selection screen push-button which changes dynamically based on radio button and does the functionality of the F8 button.
*&---*
*& Report Z_sscr *
* Published at SAPTechnical.COM
*& *
*&---* *&DYNAMIC Selection screen based on user clicks on the radiobutton*
*& *
*&---* REPORT zsscr.
*TYPE POOLS DECLARATIONS FOR VALUE REQUEST MANAGER AND ICONS TYPE-POOLS : vrm,
icon.
*SELECTION SCREEN FIELDS TABLES : sscrfields. *GLOBAL DECLARATIONS DATA : flag TYPE c,
tablename(10),
mmtable LIKE dd02l-tabname, sdtable LIKE dd02l-tabname, hrtable LIKE dd02l-tabname.
*DECLARATIONS FOR SELECTION SCREEN STATUS DATA it_ucomm TYPE TABLE OF sy-ucomm.
***********SELECTION-SCREENS********************** SELECTION-SCREEN BEGIN OF BLOCK blk1 WITH FRAME.
SELECTION-SCREEN COMMENT 2(6) text_001. *DYNAMIC LIST BOX BASED ON USER SELECTIONS
PARAMETERS one AS LISTBOX VISIBLE LENGTH 20 MODIF ID mod. PARAMETERS two AS LISTBOX VISIBLE LENGTH 20 MODIF ID rad. PARAMETERS three AS LISTBOX VISIBLE LENGTH 20 MODIF ID cad. SELECTION-SCREEN END OF BLOCK blk1.
*DISPLAY DYNAMIC PUSHBUTTON ON APP TOOLBAR ON USER CLICKS SELECTION-SCREEN: FUNCTION KEY 1,
FUNCTION KEY 2, FUNCTION KEY 3.
**EVENT ON SELECTION SCREEN FOR OUTPUT DISPLAY AT SELECTION-SCREEN OUTPUT.
*CLICK OF FIRST RADIO BUTTON IF pa = 'X'.
sscrfields-functxt_01 = 'Materials Management'. WRITE icon_plant AS ICON TO text_001.
*CODE TO GET DYNAMICS BASED ON THE SELECTED RADIO LOOP AT SCREEN. IF screen-group1 = 'MOD'. screen-intensified = '1'. screen-active = 1. screen-display_3d = '1'. MODIFY SCREEN. ENDIF. IF screen-group1 = 'RAD'. screen-intensified = '0'. screen-active = 0. screen-display_3d = '0'. MODIFY SCREEN. ENDIF. IF screen-group1 = 'CAD'. screen-intensified = '0'. screen-active = 0. screen-display_3d = '0'. MODIFY SCREEN. ENDIF. ENDLOOP. ENDIF.
*CLICK OF SECOND RADIO IF pb = 'X'.
sscrfields-functxt_02 = 'Sales And Distribution'. WRITE icon_ws_ship AS ICON TO text_001.
LOOP AT SCREEN. IF screen-group1 = 'RAD'. screen-intensified = '1'. screen-active = 1. screen-display_3d = '1'. MODIFY SCREEN. ENDIF. IF screen-group1 = 'MOD'. screen-intensified = '0'. screen-active = 0. screen-display_3d = '0'. MODIFY SCREEN. ENDIF. IF screen-group1 = 'CAD'. screen-intensified = '0'.
MODIFY SCREEN. ENDIF.
ENDLOOP. ENDIF.
*CLICK OF THIRD RADIO IF pc = 'X'.
sscrfields-functxt_03 = 'Human Resources'. WRITE icon_new_employee AS ICON TO text_001. LOOP AT SCREEN. IF screen-group1 = 'RAD'. screen-intensified = '0'. screen-active = 0. screen-display_3d = '0'. MODIFY SCREEN. ENDIF. IF screen-group1 = 'MOD'. screen-intensified = '0'. screen-active = 0. screen-display_3d = '0'. MODIFY SCREEN. ENDIF. IF screen-group1 = 'CAD'. screen-intensified = '1'. screen-active = 1. screen-display_3d = '1'. MODIFY SCREEN. ENDIF. ENDLOOP. ENDIF.
*CUSTOMISING THE TOOLBARS OF THE SELECTION SCREEN *WITH F8 BUTTON DISABLED
APPEND : 'PRIN' TO it_ucomm,'SPOS' TO it_ucomm, 'ONLI' TO it_ucomm.
CALL FUNCTION 'RS_SET_SELSCREEN_STATUS' EXPORTING
p_status = sy-pfkey TABLES
p_exclude = it_ucomm. **EVENT ON THE SELECTION AT SELECTION-SCREEN. * LIST BOX ONE VALUES
CASE one. WHEN '1'. mmtable = 'MARC'. WHEN '2'. mmtable = 'MARA'. WHEN '3'.
sdtable = 'VBAK'. WHEN '2'. sdtable = 'VBAP'. WHEN '3'. sdtable = 'VBUK'. WHEN '4'. sdtable = 'VBUP'. ENDCASE.
* LIST BOX THREE VALUES CASE three. WHEN '1'. hrtable = 'PA0001'. WHEN '2'. hrtable = 'PA0006'. WHEN '3'. hrtable = 'PA0022'. WHEN '4'. hrtable = 'PA0008'. ENDCASE.
*VALUES FOR CLICK OF THE PUSHBUTTON ON APP TOOLBAR *AND ENABLING THE BUTTONS TO PERFORM F8
CASE sscrfields-ucomm. WHEN 'FC01'. tablename = mmtable. sscrfields-ucomm = 'ONLI'. WHEN 'FC02'. tablename = sdtable. sscrfields-ucomm = 'ONLI'. WHEN 'FC03'. tablename = hrtable. sscrfields-ucomm = 'ONLI'. ENDCASE. *INITIALIZATION EVENT INITIALIZATION.
*VALUES ASSIGNED TO DROPDOWNLISTS IN THE SUBROUTINES PERFORM f4_value_request_pa.
PERFORM f4_value_request_pb. PERFORM f4_value_request_pc. *START OF SELECTION EVENT START-OF-SELECTION.
*SUBROUTINE FOR OUTPUT PERFORM output.
*&---* *& Form f4_value_request_PA
*&---* * text
*---* *SUBROUTINE TO PROVIDE DROPDOWN VALUES TO LIST1
FORM f4_value_request_pa. DATA: l_name TYPE vrm_id,
li_list TYPE vrm_values, l_value LIKE LINE OF li_list. l_value-key = '1'.
l_value-text = 'Plant Data for Material'. APPEND l_value TO li_list.
CLEAR l_value. l_value-key = '2'.
CLEAR l_value. l_value-key = '3'.
l_value-text = 'Storage Location Data for Material'. APPEND l_value TO li_list.
CLEAR l_value. l_value-key = '4'.
l_value-text = 'Units of Measure for Material'. APPEND l_value TO li_list.
CLEAR l_value. l_name = 'ONE'.
CALL FUNCTION 'VRM_SET_VALUES' EXPORTING id = l_name values = li_list EXCEPTIONS id_illegal_name = 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. " f4_value_request_tabname
*&---* *& Form f4_value_request_PB
*&---* * text
*---* *SUBROUTINE TO PROVIDE DROPDOWN VALUES TO LIST2
FORM f4_value_request_pb. DATA: l_name TYPE vrm_id,
li_list TYPE vrm_values, l_value LIKE LINE OF li_list. l_value-key = '1'.
l_value-text = 'Sales Document: Header Data'. APPEND l_value TO li_list.
CLEAR l_value. l_value-key = '2'.
l_value-text = 'Sales Document: Item Data'. APPEND l_value TO li_list.
CLEAR l_value. l_value-key = '3'.
l_value-text = 'Sales Document:Header Status'. APPEND l_value TO li_list.
CLEAR l_value. l_value-key = '4'.
l_value-text = 'Sales Document: Item Status'. APPEND l_value TO li_list.
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. " f4_value_request_PB
*&---* *& Form f4_value_request_PC
*&---* * text
*---* *SUBROUTINE TO PROVIDE DROPDOWN VALUES TO LIST3
FORM f4_value_request_pc. DATA: l_name TYPE vrm_id,
li_list TYPE vrm_values, l_value LIKE LINE OF li_list. l_value-key = '1'.
l_value-text = 'HR Master :Infotype 0001 (Org. Assignment)'. APPEND l_value TO li_list.
CLEAR l_value. l_value-key = '2'.
l_value-text = 'Address Infotype 0006'. APPEND l_value TO li_list.
CLEAR l_value. l_value-key = '3'.
l_value-text = 'Education Infotype 0022'. APPEND l_value TO li_list.
CLEAR l_value. l_value-key = '4'.
l_value-text = 'Basic Pay Infotype 0008'. APPEND l_value TO li_list.
CLEAR l_value. l_name = 'THREE'.
CALL FUNCTION 'VRM_SET_VALUES'EXPORTING
id = l_name values = li_list EXCEPTIONS id_illegal_name = 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. " f4_value_request_PC
*&---* *& Form OUTPUT
*&---* * text *---* * -->P_TABLENAME text *---* *fINAL OUTPUT FORM output. DATA p_table(10). p_table = tablename.
EXPORTING
titel = 'User Selections ' textline1 = p_table
textline2 = 'is the Selected table' start_column = 25
start_row = 6.
*assigning the table value in p_table to the * Table in SE16 transaction by explicitly calling
SET PARAMETER ID 'DTB' FIELD p_table. CALL TRANSACTION 'SE16'.
ENDFORM. "OUTPUT
Initial screen
On click of the Button in the Application toolbar, here „Sales and Distribution‟, we get
By Joyjit Ghosh, IBM India
Let us say for the given selection screen we need to create a dynamic variant.
Step 1. First maintain a variable with values in table TVARV. This can be done from transaction STVARV. Later this variable needs to be assigned to the variant.
Step 2. Next create the dynamic variant by pressing the SAVE button on the selection screen.
In the next screen check that green traffic light is on under column T (T: Table variable from TVARV). Then click on the button.
It will populate „Airline‟ select-option with the values maintained in TVARV table against variable
ZAIRLINE_CODE.
Display images (like company logo) on the selection-screen
By Gaurab Banerji, Capgemini India
Select Binary Data
Select the Find Button
Press
Press the Create button
Assign a package (must)
Write the following report
Code:
REPORT zgb_prog06.
* START OF DO NOT CHANGE*********************************** DATA: docking TYPE REF TO cl_gui_docking_container,
picture_control_1 TYPE REF TO cl_gui_picture, url(256) TYPE c .
DATA: query_table LIKE w3query OCCURS 1 WITH HEADER LINE, html_table LIKE w3html OCCURS 1,
return_code LIKE w3param-ret_code, content_type LIKE w3param-cont_type, content_length LIKE w3param-cont_len, pic_data LIKE w3mime OCCURS 0,
pic_size TYPE i.
* END OF DO NOT CHANGE************************************* DATA : sum(4) , num1(4) , num2(4).
PARAMETERS: p_dummy(4) DEFAULT '4' . PARAMETERS: p_dummy1(4) DEFAULT '5' . AT SELECTION-SCREEN OUTPUT.
PERFORM show_pic. START-OF-SELECTION.
*&---*& Form show_pic
*&---FORM show_pic.
DATA: repid LIKE sy-repid. repid = sy-repid.
CREATE OBJECT picture_control_1 EXPORTING parent = docking. CHECK sy-subrc = 0.
CALL METHOD picture_control_1->set_3d_border EXPORTING
border = 5.
CALL METHOD picture_control_1->set_display_mode EXPORTING
display_mode = cl_gui_picture=>display_mode_stretch. CALL METHOD picture_control_1->set_position
REFRESH query_table.
query_table-name = '_OBJECT_ID'.
*CHANGE IMAGE NAME BELOW UPLOADED IN SWO0****************** query_table-value = 'BIKER'.
APPEND query_table.
CALL FUNCTION 'WWW_GET_MIME_OBJECT' TABLES query_string = query_table html = html_table mime = pic_data CHANGING return_code = return_code content_type = content_type content_length = content_length EXCEPTIONS object_not_found = 1 parameter_not_found = 2 OTHERS = 3. IF sy-subrc <> 0.
* MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno * WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
CALL FUNCTION 'DP_CREATE_URL' EXPORTING type = 'image' subtype = cndp_sap_tab_unknown size = pic_size lifetime = cndp_lifetime_transaction TABLES data = pic_data CHANGING url = url EXCEPTIONS OTHERS = 1. ENDIF.
CALL METHOD picture_control_1->load_picture_from_url EXPORTING
url = url. *Syntax for URL
*url = 'file://D:\corp-gbanerji\pickut\cartoon_184.gif'. *url = 'http://l.yimg.com/a/i/ww/beta/y3.gif'.
ENDFORM. "show_pic
Given below is the desired output
Custom Parameter-id Creation
By Abhijit Daptary, Capgemini India
Step1: Creation of parameter ID.
Parameter ID can be created in the table TPARA. Just enter the name of the parameter id in the table and that parameter ID will be created.
Go to the table maintenance generator of the table TPARA and go to the Maintain button through the transaction SM30.
Enter the table view name TPARA.
Click on the maintain button. The following information will appear. Click on the Tick button or the ENTER button to go to the next screen.
Enter the Set/Get parameter id as the parameter ID you want to create. Here, I will be creating the parameter Id as ZNAME_DATA1. Click on ENTER button.
It will ask for the text of the parameter Id. Enter the text of the parameter ID and click on the Save button.
Enter the Package and the transport number.
Step2: Using the parameter Id that you have created.
Now go to the SE11 transaction for creating a data element and enter the parameter id at the Further Characteristics tab at the parameter Id section.
Activate the data element and use it with the program. It will act the same good as a standard one.
Create Dynamic Patterns
By Joyjit Ghosh, IBM India
Now insert the following code block in the include program and activate it.
*&---*
*& Include ZXSEUU26 *
*&---* DATA: w_buffer TYPE string.
CASE keyword.
WHEN 'DYNAMIC_PATTERN'. w_buffer =
'*********************************************************************'. APPEND w_buffer TO buffer.
w_buffer = '*& Program :'. APPEND w_buffer TO buffer.
w_buffer = '*& Module :'. APPEND w_buffer TO buffer.
w_buffer = '*& Sub-Module :'. APPEND w_buffer TO buffer.
w_buffer = '*& Functional Contact:'. APPEND w_buffer TO buffer.
w_buffer = '*& Funct. Spec. Ref. :'. APPEND w_buffer TO buffer.
w_buffer = '*& Developer(Company):'. APPEND w_buffer TO buffer.
w_buffer = '*& Create Date :'. APPEND w_buffer TO buffer.
APPEND w_buffer TO buffer. WHEN OTHERS.
* Do nothing ENDCASE.
Lastly activate the project
*& Report Z_TRIGGER_EVENT * *& * *&---* *& * *& * *&---* REPORT Z_TRIGGER_EVENT .
CALL FUNCTION 'BP_EVENT_RAISE' EXPORTING eventid = 'Z_TRIGGER_JOB' EXCEPTIONS BAD_EVENTID = 1 EVENTID_DOES_NOT_EXIST = 2 EVENTID_MISSING = 3 RAISE_FAILED = 4 OTHERS = 5 . IF sy-subrc <> 0.
Write: 'Event failed to trigger'. else.
Write: 'Event triggered'. ENDIF.
Step3: Configure the background job from transaction SM36.
In the popup screen press “After event” button and give the event name and then press save
button.
Step4: Now execute the program to trigger the event and as well check the background job.
Run transaction SM37
Check the status of job defined above
Performance Tuning using Parallel Cursor
By Suresh Kumar Parvathaneni, YASH Technologies
Nested Loops – This is one of the fear factors for all the ABAP developers as this consumes lot of program execution time. If the number of entries in the internal tables is huge, then the situation would be too worse. The solution for this is to use parallel cursor method whenever there is a need for Nested Loop.
Data:
t_likp type table of likp, t_lips type TABLE OF lips.
data: W_RUNTIME1 TYPE I, W_RUNTIME2 TYPE I. START-OF-SELECTION. select * from likp
into table t_likp.
select * from lips
into table t_lips.
get RUN TIME FIELD w_runtime1.
loop at t_likp into likp.
loop at t_lips into lips where vbeln eq likp-vbeln. endloop.
endloop.
get RUN TIME FIELD w_runtime2.
w_runtime2 = w_runtime2 - w_runtime1.
write w_runtime2.
Nested Loop using Parallel Cursor:
REPORT zparallel_cursor2.
TABLES: likp, lips.
DATA:
t_likp TYPE TABLE OF likp, t_lips TYPE TABLE OF lips.
DATA:
w_runtime1 TYPE i, w_runtime2 TYPE i, w_index LIKE sy-index.
START-OF-SELECTION. SELECT *
FROM likp
INTO TABLE t_likp.
SELECT * FROM lips
SORT t_lips BY vbeln.
LOOP AT t_likp INTO likp.
LOOP AT t_lips INTO lips FROM w_index. IF likp-vbeln NE lips-vbeln. w_index = sy-tabix. EXIT. ENDIF. ENDLOOP. ENDLOOP.
GET RUN TIME FIELD w_runtime2.
w_runtime2 = w_runtime2 - w_runtime1.
WRITE w_runtime2.
Analysis report: Runtime in microseconds:
Iteration No Normal Nested Loop Using Parallel Cursor
1 34,796,147 63,829
2 38,534,583 56,894
3 34,103,426 50,510
Creating a Transaction Variant
By Smita Singh
In this tutorial, we would discuss about creating a transaction variant for the transaction MM01. Our transaction variant should default to a value for Industry sector and material type and should not allow the end user to change those values (output only).
Enter the transaction code MM01. Now click on button CREATE.
Following information message would appear:
Click Enter to proceed.
Select the required Industry sector and Material Type and press ENTER. Following popup would appear:
Click on “Exit and Save”.
Following popup would appear:
Save your entries and go back to the main screen.
Now enter the transaction variant name and click on Change button as shown below:
Now click on GotoCreate Variant Transaction
The name of the Transaction Variant is automatically proposed. Save your entries.
Now go to Transaction ZMM01 and check your transaction variant:
This tutorial deals about the procedure in automatic e-mailing of the background jobs. The output of the background job is sent to the recipient as an email.
Consider the following simple program:
REPORT zbackground_test.
WRITE: 'hello SAPTechnical.com team'.
We would schedule the above program as a background job and send the output of the same as an email.
Go to Transaction SM36.
Enter the job name.
Enter your program name as shown above and click on SAVE.
Click on the button “Spool list recipient” as shown above.
Enter the name of the recipient to which the output to be sent.
Now come back to the main screen and click on “Start Condition”.
Save your job. Only after you save, the job would be set to status Released.
You can go to transaction SM37 to monitor the background job.
Now go to SAP inbox (transaction SBWP/SO01) to check the status of the background job:
In the above screenshot, you can observe an email related to the job we created earlier. Open the attachment to see the output of the background job:
ABAP Programming / Naming Standards
By Supriya Joshi
Following are the performance standards need to be following in writing ABAP programs:
For all ABAP Programs / Transaction Codes
Add the below header at the beginning of Every ABAP program
************************************************************************ * OBJECT ID : * PROGRAM TITLE : * MODULE : * PROGRAM TYPE : * INPUT : * OUTPUT : * CREATED BY : * CREATION DATE : *--- ---* DESCRIPTION : * * * ************************************************************************
---* DATE |User ID |TS Ver | Transport Request | Description
* ---
---*
************************************************************************
Naming conventions to be followed :
Application area corresponds to the application area you are working like
B - Basis
C - CO
F- FI
W - PM
S – SD / SAM
M – MM/Supply
ABAP Performance Standards
By Aveek Ghose, IBM India
measure/compare program performance/runtime if program has multiple inefficient databases selects or complicated internal table
operations
Use transaction ST05 (SQL Trace) to see what indices your database accesses are using. Check these indices against your
“where” clause to assure they are significant. Check other indices
for this table and where you have to change your “where” clauseto use it. Create new indices if necessary, but do not forget to
check the impact by consulting onsite coordinator. TYPE (data element) command is used while declaring the fields whenever feasible instead of LIKE. Remember not always the data
element name matches with the table field name
Internal Table is defined with “TYPE STANDARD TABLE OF” &
Work-Areas is used instead of header lines
Global variables are minimized by declaring local variables or by passing variables through parameters & arguments while creating
internal subroutine(s)
In SELECT statement, only the required fields are selected in the same order as they reside on the database table/structure/view
For selecting single row from a database table, “SELECT UP to 1Rows” is used. “Select Single” is used only when full primary key
combination is known No SELECT * is used
Use “SELECT INTO TABLE” rather than “SELECT INTO
CORRESPONDING FIELDS OF TABLE”
Always specify as many primary keys as possible in WHERE clause to make the Select efficient
Always select into an internal table, except when the table will be very large (i.e., when the internal table will be greater than
500,000 records). Use “Up to N Rows” when the number of
records needed is known
Select statement within a GET event is not used
Wild cards like „A%‟ is avoided as much as possible
Nested Select is notused instead “Inner Join” and/or “For all Entries” is used. “For all Entries” is to be used over “Loop at ITAB /
Select / ENDLOOP” (FOR ALL ENTRIES retrieves a unique result
set so ensure you retrieve the full key from the database) When creating joins over database tables there should be an index at least on the inner table for the fields in the join condition
else use “ FOR ALL ENTRIES” select statement
Usage of JOIN is limited to a maximum of 2 i.e. not more than 3 database tables are joined at one time
CHECK that the internal table used in FOR ALL ENTRIES is NOT empty as this will retrieve all entries from the table Delete adjacent duplicate entries from internal table before
selection from database table using “ FOR ALL ENTRIES”
statement
For copying internal tables use „=‟ operator instead of Looping &
Appending
SORT inside a LOOP is not used
Sort internal table by fields in the correct order, which are used in a READ TABLE statement using BINARY SEARCH. If the order of
sorting is invalid the BINARY SEARCH will never work For large internal tables where only some rows are to be
used to set index to first relevant row before looping from that index. Use CHECK or IF…EXIT…ENDIF as appropriate to exit
from the loop
Sort fields and Sort Order on the SORT statement should be mentioned explicitly (e.g. SORT ITAB BY FLD1 FLD2
ASCENDING)
Hashed table is used for processing large amount of data (provided that you access single records only, and all with a fully
specified key)
DELETE or SORT is not used on a hashed table since it increases memory consumption
Sorted table is used for range accesses involving table key or index accesses
Fields specified in the WHERE condition with the critical operators NOT and <> (negative SQL statements) cannot be used for a search using database indexes. Whenever possible formulate
SQL statements positively
When coding IF or CASE, testing conditions are nested so that the most frequently true conditions are processed first. Also CASE isused instead of IF when testing multiple fields “equal to”
something
LOOP AT ITAB INTO WORKAREA WHERE K = „XXX‟ should be
used instead of LOOP AT ITAB INTO WORKAREA / CHECK ITAB-K = „XXX‟.
Also READ TABLE INTO WORKAREA should be used instead of only READ TABLE.
After the APPEND statement inside a loop, the work area that has been appended is cleared
Internal tables, Work areas & Global Variables are freed when no longer needed (e.g. using the FREE / REFRESH command), especially when the tables are large or the program is a batch
program
Do not delete the records of internal table inside the Loop –End loop.
Do not use: LOOP AT ITAB WHERE EQUNR = „00001011‟.
DELETE ITAB.
ENDLOOP.
Use: DELETE ITAB WHERE EQUNR = „00001011‟. Use the MODIFY ITAB ... TRANSPORTING f1 f2 ... for single line, and MODIFY ITAB ... TRANSPORTING f1 f2 ... WHERE condition
Release the locks set at the beginning
Try to avoid logical databases. If your program uses a logical database, but does not require all fields belonging to a certain GET event, always use the FIELDS addition to reduce the amount
of data selected by the logical database
Avoid the aggregate (Count, Max, Min) functions in the database selection
Use Parallel Cursor methods for nested loop into the internal tables if second internal table contains considerable number of
records
In Smartform/ Sapscript do not make redundant data retrieval where data is available in interface
Understanding SQL Trace
By Aveek Ghose, IBM India
Performing an SQL Trace:
1.
Access
transaction ST05. From the initial screen, click the check box for SQL trace, under the
trace requests, click Trace on.
2.
Run
the
program containing the SQL query that needs to be analyzed in the SE38 editor.
3.
Come back to
ST05 screen, under Trace requests, click Trace off .
4. Click List trace to view the trace of the current statement.
The basic list trace shows the sequence of database operations that are taking place while a query is processed, it includes prepare, fetch, open, reopen, execute. In addition the basic list trace also gives the duration execution for each of the operations with color legend.
Summarizing the basic trace list (menu path: Goto à Summary)
A basic trace list can be summarized to see the summation of execution times of similar database operations. Use menu path: GotoSummary. The above screen shot depicts the summed up execution time. The summary option lists the summed up execution time of all the queries that the SQL trace has captured at its runtime, but the identification of a particular query can be done using the PID – Process ID which is displayed as the first column of the above screen shot. For example, 896 is the process ID for
To get the total execution time, specifically for a particular SQL Statement, select all the PID corresponding to it and click summarize in the application toolbar. This leads to a compressed data of SQL trace as above.
Color legends indicating the processes in a trace 1
Use the menu path: Goto -> Show color legend to know about the color specification in the trace.
The above screen shot indicates that the query execution time has exceeded its threshold with the link pink color. A change in object name is indicated with the change in color to yellow. These colors thereby indicate whether the query is well written and also the current status of the database server.
Extended list
named resource available to a program and can be used specifically for the parsing of SQL statements embedded within the application.
Identical select statements
Use the menu path: GotoIdentical Selects to view a comprehensive list of identical select statements executed during the trace and the number of times they were executed. Identical select statements are grouped based on the where clause.
Note that identical select statements have similar execution plan used for their processing thereby saving time of execution and provide increased performance, too.