Creation of Transparent Table

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.

3.

Enter the ZCHAR in fields tab and ZCHAR_DE in field type tab.

4.

Double click on ZCHAR_DE. Then it will ask for Save. Press „YES”.

5.

Save it as a local object on pressing Local object button

6.

Now it will ask for the creation of the data element. Press Yes.

7.

Click on the Field label tab and enter the lengths and descriptions accordingly.

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.

Press Yes.

10. Save it as a local object.

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.

13. Then press Ctrl+F3. It will ask for save before activation. Save it as a local Object.

14. Press Enter.

15. Then the following screen appears. Press on back button.

You will get the following screen. Press Ctrl+F3. . 17. You will get the following screen. Press Back button.16.

And double click on „ZNUM_DE‟ .18. Create one more field ZNUM and give data element name as ZNUM_DE.

Now it will ask for the data element creation. 20. Press Yes. Save it by pressing Yes. .19.

Give short description of the data element. 22. . Press on Definition tab and give the domain name in Domain field. Double click on ZNUM_D.21. And give the lengths and field labels accordingly in Field label tab.

23. Press Yes. It will ask for save. . 24. Save it as a local Object.

26. characters. Press Yes. . Now it asks for Domain creation. Press Enter.25. Give short description in short text field. Then Press on Activate button or Press Ctrl+F3. Enter the data type and no.

. Save this as a local object.27.

.28. Press enter.

29. . Now you will get the following screen. Press Back button.

30. Activate the data element By pressing Activate button or Pressing Ctrl+F3. .

Press enter. .31.

Press Back button. .32.

. And Data elements and Domain for these two fields. Press on Technical settings button. Now we created two fields. Now we have to maintain the technical settings.33.

. And press the back button.34. Give the data class and size category of the table as per the requirement.

35. . Now activate the table by pressing the activate button or CTRL+F3.

37.36. Press enter. Now you will get the following screen. .

38. . Now enter the data into table. Go to Utilities Table contents  Create Entries.

. Now enter the data in the fields and Save it.39.

40. . You will get the following screen after clicking the Reset Button.

41. Enter the data for the second entry into the table. 42. . Save it and press reset.

. You will get the following screen.43.

44. Press save. Reset (Optional) and Back button. . Again enter the data for the third entry. 45.

.46. Now you will get the following screen.

. Or press Ctrl+Shift+F10. To see the table contents go to Utilities  Table contents  Display.47.

48. . You will get the following screen.

. Press on run button or press F8.49. Now it will display the table contents.

Enter a structure name starting with Y or Z. .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”.

The screen will be displayed like this.Press create button. A pop-up screen appears with 3 different options. Provide the description and also components. . Select the radio button structure.

CHECK and ACTIVATE. Select the create button. Mouri Tech Solutions Go To SE11 T-code.Then press SAVE. Select the radio button of search help. Structure Created Successfully. Provide the search help name. Creating Search Helps (Elementary and Secondary) By Vikram Chellappa. .

Press Enter. . Provide the fields. Provide the short description.Select ELEMENTARY search help. the selection method.

Then execute it. . Check It & Activate it. and then press F4 in this page.Save it. We can see the screen like this.

.Then press F4 View the output like this. This is the output for elementary search help. The Collective Search Help is like this.

Provide name. Provide the Values . Press enter. Select collective search help button.Goto T-Code Se11.

Then save it. Then provide search help name. activate it & execute it. . which is already define by the same fields.Select include search help.

Press F4 we can see the output like this. Diff Between Elementary search helps & Collective search helps .

This article discusses about creating a secondary index. It combines all the search paths that are meaningful for a field. . they are expanded to the level of the elementary search helps when the input help is called. Collective search help thus can offer several alternative search paths. Creating a secondary index There are two types of indexes: Primary index and secondary index. The user can thus choose one of several alternative search paths with collective search help. Secondary index could be created as per the user requirement. Go to transaction SE11. 5) A collective search help comprises several elementary search helps. 3) An elementary search help defines the standard flow of an input help.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). Primary index is automatically created using the primary keys defined. If other collective search helps are contained in collective search help. 4) A collective search help combines several elementary search helps. 2) Collective search helps combine several elementary search helps. 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). 6) Both elementary search helps and other search helps can be included in a collective search help.

click on Goto  Indexes Following popup appears: . we have considered the table ZAUTHOR. To know if there are any secondary indexes available.For our demo purpose.

Fill in the details – Short description and the fields in the index. Click on Create  Create Index Enter the name of the index. .From the above screenshot. it is evident that there are no secondary indexes already created.

Now you can observe the index created above in the list now: .Save and activate.

The code was written in R/3 4. WRITE :/ t_spfli. If you specify hints incorrectly. SELECT * FROM spfli INTO TABLE t_spfli %_HINTS ORACLE 'INDEX("SPFLI" "SPFLI~001")'. ENDSELECT. From SAP® v4. Code Consider the following example: REPORT Suresh_test.5. In the above example.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")' . Go to SE11 and there specify the table name 2. DATA : t_spfli LIKE spfli OCCURS 0 WITH HEADER LINE.. This is dependent on the database systems that support optimizer hints. Now from the menu. optimizer hints can be provided by the %_HINTS parameter... goto --> indexes 3. LOOP AT t_spfli. It's a well-known fact that the efficient way of retrieving data from the database tables is by using secondary indexes. select the required index. Many database vendors provide the optimizer hints for the same.. The index name should be defined as: <tablename>~<Index Identifier> like SPFLI~001 in the above example. Working with Table Maintenance Generator . ENDLOOP. The sequence of fields in the WHERE condition is of no relevance in using this optimizers index. Now to know which index to use for our table: 1. Each database vendor is free to provide the optimizer hints. ABAPTM ignores them but doesn't return a syntax error or runtime error. The point to be noted here is these optimizer hints are not standardized by the SQL standards... TABLES: spfli. Now suppose that the identifier 001 represents a non-unique secondary index comprising of the columns CITYFROM and CITYTO. 001 is the secondary index of the table SPFLI.6C.

Click on Change.Go to SE11 and enter the Z table name for which the table maintenance generator has to be generated. Click on Utilities  Table Maintenance Generator .

Save Single step: Only overview screen is created i. You can now create TCode for the table maintenance generator. Two step: Two screens namely the overview screen and Single screen are created. It will propose screen no's) Then Create. delete or edit records. Enter the TCode to be created and click on Create.e. the Table Maintenance Program will have only one screen where you can add.Enter Authorization group (For e. . Assign Screen numbers (To assign Screen numbers click on the button 'Find Scr no'. &NC&) Function group (go to SE80 for creating function group) You can select either one step or two step. The user can see the key fields in the first screen and can further go on to edit further details. Creation of a Logical Database Go to transaction 'SE36' or 'SLDB'.g.

It would prompt for package name and workbench request . we should check the check Box “Info types (HR only).Enter the logical database name as shown above . Press CREATE Button as shown above. If we are using Logical Database for HR purpose. .

Click on create button.On pressing Save button. Following screen appears: . 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.

. Now create a Node with hierarchically under LFB1.Click on create Button.

.The above screen displays the LDB structure as per our requirements. We can maintain search help for the fields for the tables defined in structure.

Select “Transaction with parameters (Parameter transaction)” .

.

.Click on save. For our demo purposes. let us provide search help for MATNR and WERKS. Now you can create the table entries through the transaction created above.

.Let us use the standard search help available for MATNR and WERKS.

.The currency and quantity fields are automatically maintained here.

Go back to the main screen .

Here we can design our own selection screen as per the requirements. .

Here by using above marked statement we can create Dynamic selection screen for different tables as per the requirements.Automatically created include with naming convention..Previous .. Creation of a Logical Database .

Here we can maintain texts for select-options and parameters. .Database program (with some includes) are automatically created upon the creation of logical database: Go back to the main screen.

Navigate to the main screen: .

.Here we can maintain documentation for our created Z logical database.

.

.Click on Display.

Give a short description. Example: Let us create a View Cluster on Material Details. A viewcluster transaction edits the complex cross-table data in a view cluster. such as views. reports or tables. The data can be arranged either hierarchically or non-hierarchically in view cluster. MARC and MARD. Go to transaction SE11. which belong to one business function. MARA. Maintenance view for Table MARA To create maintenance view for the table MARA follow the procedure below. The view cluster would include three tables namely.Creation of a View cluster By T. Give a view name say ZMM_V_MARA and click on „Create‟. The transaction navigation box shows the complex business object with its components or sub objects. .N. We need to create maintenance views for each of these tables. enter the table name as MARA and click on the tab View fields.Swapna View Cluster A view cluster is the set of objects.

Now Save and activate the view. give „S‟ in the column „P‟ for the fields MANDT and MATNR as shown in the screen shot below: .By default all the key fields would be added. Maintenance view for Table MARC Follow the same procedure as above. In the Tab View fields. We can add more fields by clicking on the button Table fields.

Maintenance view for Table MARD Follow the same procedure as above. for each view we need to create a table maintenance generator. which has to be done as follows: . In the Tab View fields. MATNR and WERKS would be filled in the view for MARC and thus they act as subsets and appear as header data when we create entries in view cluster. give „S‟ in the column „P‟ for the fields MANDT. MATNR and WERKS as shown in the screen shot below: This is because the fields MANDT.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. Table Maintenance Generator for ZMM_V_MARA Now.

enter the function group name as . Before creating a table maintenance generator.The table maintenance screen appears. After the function group is successfully created. This table maintenance is for the view ZMM_V_ MARA. Here give the details as in the screen shot below. create a function group say ZFG_MATERIAL from the transaction SE80.

Similarly. as „1‟ in the Overview screen and click on the button „Create‟. Also select Maintenance type as „One Step‟ and give the Maintenance Screen no.shown in the screen shot. The screen shots for these views would be as follows: Table Maintenance Generators for ZMM_V_MARC and ZMM_V_MARD . create the Table maintenance Generators for the views ZMM_V_MARC and ZMM_V_MARD.

Enter the view cluster name as say „ZMM_VC_MATERIAL‟ and click on „Create‟. . Go to transaction SE54 and select the button „Edit View Cluster‟. Creating view cluster The pre-requisites for creating the View Cluster are now ready.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.

The following screen appears. Give a short description and click on „Object Structure‟ as shown in the screen shot below: .An information message would pop up saying Continue by pressing „Enter‟.

So in this case. In the column „Start‟ select the radio button against the entry for ZMM_V_MARA as it comes first in the hierarchy. Three pop-ups for each view would appear as shown below. Enter the values as shown below: The entries would be entered in a hierarchical manner. because it is a header entry and does not depend on any other view. Whereas. The „DEP‟ column explains whether the entry is a Header entry or a Dependent entry. press „Enter‟. It is „R‟ for the view ZMM_V_MARA. . The „Predecess‟ column specifies the predecessor of that view. After entering the above entries. The predecessor of ZMM_V_MARC is ZMM_V_MARA and the predecessor of ZMM_V_MARD is ZMM_V_MARC. 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 short text is the description of the view. Select the „New Entries‟ button to enter the maintenance views created to form a cluster.On Clicking the „Object Structure‟ the following screen appears. the predecessor of ZMM_V_MARA is ZMM_V_MARA itself. Proceed further by clicking on „Enter‟ key. The column „POS‟ specifies the sequence of the views.

Now select each line and click on „Field-dependence‟ button. Activate the view cluster. Now. save the entries and go back to „Header Entry‟ folder. A pop-up appears saying „Field dependencies successfully generated‟. . A pop-up appears as shown below. Generate the field dependence for the views ZMM_V_MARC and ZMM_V_MARD in the same way. Click on „Yes‟.

just select an entry and double click on Plant details as shown below. 2. The view cluster can be created on the tables whose data has to be stored in a hierarchical manner. 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. . One has to check whether proper foreign key relationships are maintained between the tables appearing in the cluster. Note: 1. errors may occur if the foreign keys are not maintained properly. In order to see the corresponding Plant details for the material.The view cluster is now created successfully. Sometimes while generating the Field-dependencies. 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.

The storage location details are as follows: In the above screen shot the material selected in the Material details view and the plant selected in the Plant details view would appear as header entry. .The plant details would appear. In the above screen shot the material selected in the Material details view would appear as a header entry. In the same way for the corresponding storage location details. select an entry and double click on Storage details as shown below.

1.Row level locking of database table By Swetabh Shukla. Create table maintenance generator for the table. Infosys Technologies Normally if a person opens table maintenance generator and tries to maintain the table. 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. In the tutorial below we will see how to remove table level lock and apply row level lock. 2. We will create a transaction for this purpose. no one else can maintain the same table at the same time. The transaction will call our custom report. Rows locked by one user will not be editable by other user. Only one user can maintain any table at a time through SM30 or any transaction that calls table maintenance generator. This custom report will call the table maintenance generator of the table after deleting table level lock. This way any number of users can modify the table at same time. This is because of table level lock by default in SAP. . But any particular row can be modified by only one user at a time. In current example let‟s create following: Report: ZREP_SHUKS3 Transaction: ZTEST_SHUKS3 Table: ZTEST_SHUKS3 with table maintenance generator. Create table ZTEST_SHUKS3.

So finally we have table maintenance code automatically generated in function group ZTEST_SHUKS3. 3. Create lock object EYTSS_E433SH in SE11.We will make single screen maintenance for this table. . Save it. Give it name as EZTEST_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 tcode will call table maintenance generator of table ZTEST_SHUKS3 .

lw_enq_del TYPE seqg3. ENDLOOP. APPEND lw_enq_del TO lt_enq_del. Check the report and comments given below. This is because of table level lock by default in SAP. no one else can maintain table at the same time. DATA: END OF selekttab. lw_enq_read TYPE seqg7. Rows locked by one user will not be editable by other user. DATA: lt_enq_del TYPE STANDARD TABLE OF seqg3. Only one user can maintain any table at a time. *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'. lv_subrc TYPE sy-subrc. DATA: END OF excl_cua_funct. lt_enq_read TYPE STANDARD TABLE OF seqg7. Normally if a person opens table maintenance generator and tries to maintain the table. "inaktive CUA-Fkt bei View-Pflege INCLUDE STRUCTURE vimexclfun. *&---------------------------------------------------------------------* REPORT zrep_shuks3. **Selection range for view maintenance DATA: BEGIN OF selekttab OCCURS 1. MOVE-CORRESPONDING lw_enq_read TO lw_enq_del. *&---------------------------------------------------------------------* *& Report ZREP_SHUKS3 *& *&--------------------------------------------------------------------*& Author : Swetabh Shukla *& Date : 05/22/2009 *& Description : To delete table level lock from table. **Table of inactive CUA functions for view maintenance BEGIN OF excl_cua_funct OCCURS 1. "Selektionsbereich INCLUDE STRUCTURE vimsellist. *Delete table level lock entry for our table CALL FUNCTION 'ENQUE_DELETE' EXPORTING check_upd_requests = 1 IMPORTING subrc = lv_subrc .5. 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. *Read all the lock details in system CALL FUNCTION 'ENQUE_READ2' EXPORTING gclient = sy-mandt gname = ' ' guname = '*' TABLES enq = lt_enq_read.

*Now call the table maintenace generator.TABLES enq = lt_enq_del. Open the screen you created through table maintenance and add one module.We know for table maintenance SAP automatically creates code in the function group. Just one more change in table maintenance screen. 6. Open the screen 0001 and add one module in PBO of the screen as shown in figure below. Now open table maintenance function group(ZTEST_SHUKS3) in SE80. 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. Now we will make some modification in that existing code to change the behavior. .

so values may be invalid. MODIFY SCREEN. Call the transaction once and make some entries in table. *Call the function module corresponding to the lock object we created CALL FUNCTION 'ENQUEUE_EZTEST_SHUKS3' EXPORTING matnr = ztest_shuks3-matnr werks = ztest_shuks3-werks EXCEPTIONS foreign_lock = 1 system_failure = 2 OTHERS = 3.. screen-input = 0. In below screenshot I have entered some random values. . That can be taken care in real scenario.Check the code below to be added in the module m_change_locking. ENDMODULE. Now we are ready for testing. " m_change_locking OUTPUT 7. MODULE m_change_locking OUTPUT. LOOP AT SCREEN. ENDIF. ENDLOOP. * row is locked. Since we have not maintained any check tables etc.hence gray.. IF sy-subrc NE 0.

Save data. Let‟s open an existing value material = MAT1 and Plant = 0678. Session 1 In first session we will call the transaction ZTEST_SHUKS3 and try to open some existing values for table maintenance. Let‟s call two sessions of the transaction ZTEST_SHUKS3. .

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.So the entry opens in change mode. Session 2 Open transaction ZTEST_SHUKS3 .

So we can see that our transaction is able to achieve a row level locking and has removed table level locking. Intelligroup In this Tutorial. Go to Utilities  Other Dictionary Objects . Creation of a table pool and pool table By Kiran Kumar Kandakatla. we create a Table pool first and then create/ (add a table to Table pool) a Pooled Table. Step 1: Go to transaction SE11.

Step 3: Then Select Radio button Table Pool.Step 2: Select Radio button Table pool/Cluster Give table Pool Name: ZTBL_POOL. Then press F5 or choose Create. . Press Enter.

Step 4: Then you go to maintain Poll Screen there give Short Description. . Step 5: Then go to Technical settings.

Save and activate the table Pool. Step 7: . Go back to SE11.Step 6: In the “Maintain technical Settings” screen Provide Size category.

Create a Z table. .Go to SE11 ABAP Dictionary: Initial Screen. Step 8: Maintain Delivery and Maintenance attributes for the Z table.

Maintain Technical settings and Enhancement Category. Step 9: Then Go to Extras Change table category .Add fields to the Z table.

In our Example it is Pooled table. Step 11: Go back to Delivery and Maintenance tab and provide Pool/Cluster value.Step 10: Choose Table type. .

LV_CONTENT TYPE XSTRING. *&---------------------------------------------------------------------* *& Report ZSAP_PDF_VIEWER_DEMO_2 *& *&---------------------------------------------------------------------* REPORT ZSAP_PDF_VIEWER. DATA : G_HTML_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER. DATA : LS_CONTROL_PARAM TYPE SSFCTRLOP. LV_URL TYPE CHAR255. LT_DATA TYPE STANDARD TABLE OF X255. DATA: LT_PDF TYPE TABLE OF TLINE. G_HTML_CONTROL TYPE REF TO CL_GUI_HTML_VIEWER. Just convert OFT data into PDF as below. It‟s very simple to understand. DATA : P_VBELN TYPE VBELN_VL. DATA : L_JOB_OUTPUT_INFO TYPE SSFCRESCL. Enteg This Program helps you to view any output in PDF viewer as shown below. FIELD-SYMBOLS <FS_X> TYPE X.We have successfully created Table pool and Pooled table. . LS_PDF LIKE LINE OF LT_PDF. PDF_FSIZE TYPE I. PDF Viewer By Sai Kumar B.

ENDIF. LS_CONTROL_PARAM-NO_DIALOG = 'X'. START-OF-SELECTION. CALL SCREEN 100. 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 . ENDLOOP.INITIALIZATION. LS_CONTROL_PARAM-GETOTF = 'X'. * convert pdf to xstring string LOOP AT LT_PDF INTO LS_PDF. CONCATENATE LV_CONTENT <FS_X> INTO LV_CONTENT IN BYTE MODE. IF SY-SUBRC <> 0. CALL FUNCTION 'CONVERT_OTF' EXPORTING FORMAT = IMPORTING BIN_FILESIZE = TABLES OTF = LINES = EXCEPTIONS ERR_MAX_LINEWIDTH = ERR_FORMAT = ERR_CONV_NOT_POSSIBLE = OTHERS = 'PDF' PDF_FSIZE L_JOB_OUTPUT_INFO-OTFDATA LT_PDF 1 2 3 4. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ASSIGN LS_PDF TO <FS_X> CASTING. .

" STATUS_0100 OUTPUT *&---------------------------------------------------------------------* *& Module USER_COMMAND_0100 INPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE USER_COMMAND_0100 INPUT. * Show it CALL METHOD G_HTML_CONTROL->SHOW_URL( URL = LV_URL IN_PLACE = 'X' ). " USER_COMMAND_0100 INPUT . * SET TITLEBAR 'xxx'. ENDMODULE.*&---------------------------------------------------------------------* *& Module STATUS_0100 OUTPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE STATUS_0100 OUTPUT. * 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 EXCEPTIONS DP_INVALID_PARAMETER = 1 DP_ERROR_GENERAL = 2 CNTL_ERROR = 3 OTHERS = 4 ). ENDMODULE. 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. * SET PF-STATUS 'xxxxxxxx'.

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 *& .

*-Fieldsymbols FIELD-SYMBOLS: <fs> TYPE ANY. CLEAR t_html.S E L E C T I O N *----------------------------------------------------------------* START-OF-SELECTION. CLEAR t_html. APPEND t_html.S E L E C T I O N *----------------------------------------------------------------* END-OF-SELECTION.O F . SELECT * FROM sflight INTO TABLE it_flight UP TO 20 ROWS. v_field(40). APPEND t_html. CLEAR t_html.*&----------------------------------------------------------------* REPORT ytest_table_html1. " Flights Details it_fcat TYPE lvc_t_fcat WITH HEADER LINE. t_html-line = '<html>'. APPEND t_html.O F . t_html-line = '<thead>'. *----------------------------------------------------------------* * S T A R T . t_html-line = '<tr>'. *----------------------------------------------------------------* * E N D . .Declare Internal table and Fieldcatalog it_flight TYPE STANDARD TABLE OF sflight WITH HEADER LINE. DELETE it_fcat WHERE fieldname = 'MANDT'. *----------------------------------------------------------------* * 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. *-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. t_html-line = '</tr>'. " Html Table *. " Fieldcatalog *-Variables DATA: v_lines TYPE i. APPEND t_html. CLEAR t_html. t_html-line = '<td><h1>Flights Details</h1></td>'.

ENDLOOP. CLEAR t_html. APPEND t_html. DESCRIBE TABLE it_fcat LINES v_lines. APPEND t_html. CLEAR t_html. READ TABLE it_fcat INDEX sy-index. t_html-line = '<tr>'. CLEAR t_html. APPEND t_html. CLEAR t_html. APPEND t_html.htm' . t_html-line = '</thead>'. APPEND t_html. ENDDO. CLEAR t_html. t_html-line = '<table border = "1">'. t_html-line = '<tr>'. t_html-line = <fs>. CONCATENATE '<th bgcolor = "green" fgcolor = "black">' it_fcat-scrtext_l '</th>' INTO t_html-line. CLEAR t_html. t_html-line = '</tr>'. APPEND t_html.APPEND t_html. *-Download the HTML into frontend CALL FUNCTION 'GUI_DOWNLOAD' EXPORTING filename = 'C:\Flights. ASSIGN (v_field) TO <fs>. t_html-line = '</tr>'. DO v_lines TIMES. *-Populate HTML table from Internal table data LOOP AT it_flight. CLEAR v_field. CONCATENATE 'IT_FLIGHT-' it_fcat-fieldname INTO v_field. *-Populate entire row of HTML table Dynamically *-With the Help of Fieldcatalog. CLEAR t_html. CLEAR t_html. CLEAR t_html. APPEND t_html. t_html-line = '<td>'. APPEND t_html. APPEND t_html. t_html-line = '</td>'. t_html-line = '</table>'. UNASSIGN <fs>. APPEND t_html. CLEAR t_html. *-Populate HTML columns from Filedcatalog LOOP AT it_fcat. APPEND t_html. ENDLOOP. CLEAR t_html. CLEAR t_html.

ENDIF. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. IF sy-subrc <> 0. ENDIF.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. *-Display the HTML file CALL METHOD cl_gui_frontend_services=>execute EXPORTING document = 'C:\Flights. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.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. Result: .

WWW_ITAB_TO_HTML_HEADERS is used to populate column headings. 3.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. *&---------------------------------------------------------------------* *& Report YTEST_TABLE_HTML *& . 2. WWW_ITAB_TO_HTML_LAYOUT is used to populate column cell properties. WWW_ITAB_TO_HTML is used to convert internal table data to HTML.

" AirFare currency TYPE s_currcode. it_fcat-coltext = 'Connection Number'. APPEND it_fcat. *-Populate Fieldcatalog it_fcat-coltext = 'Airline Code'. it_fcat-coltext = 'Currency'. "Fields t_html TYPE STANDARD TABLE OF w3html. DATA: it_sflight TYPE TABLE OF ty_sflight. " Fieldcatalog *---------------------------------------------------------------------* * S T A R T . carrid TYPE s_carr_id. w_head-text = it_fcat-coltext. " Flight Date price TYPE s_price. " Connection Number fldate TYPE s_date. APPEND it_fcat. APPEND it_fcat. " Flights Details it_fcat TYPE lvc_t_fcat WITH HEADER LINE. *-ALL related Declarations DATA: t_header TYPE STANDARD TABLE OF w3head WITH HEADER LINE.O F .*&---------------------------------------------------------------------* 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. w_head TYPE w3head. *-Fill the Column headings and Properties LOOP AT it_fcat.O F . " Currency END OF ty_sflight. APPEND it_fcat. " Airline Code connid TYPE s_conn_id. SELECT * FROM sflight INTO CORRESPONDING FIELDS OF TABLE it_sflight UP TO 20 ROWS. *-Populate the Column Headings CALL FUNCTION 'WWW_ITAB_TO_HTML_HEADERS' EXPORTING field_nr = sy-tabix text = w_head-text fgcolor = 'black' bgcolor = 'green' TABLES header = t_header. . *---------------------------------------------------------------------* * E N D . "Header t_fields TYPE STANDARD TABLE OF w3fields WITH HEADER LINE.S E L E C T I O N *---------------------------------------------------------------------* END-OF-SELECTION. APPEND it_fcat. it_fcat-coltext = 'Airfare'.S E L E C T I O N *---------------------------------------------------------------------* START-OF-SELECTION. "Html wa_header TYPE w3head. it_fcat-coltext = 'Flight date'.

*-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. *-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. ENDIF.

Result:

Adding custom context menu in classical list

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.

*&---------------------------------------------------------------* *& Form on_ctmenu_request *&---------------------------------------------------------------* * 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: Basic list:

Detail list:

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. *FOR DYNAMIC DISPLAY OF MODULES PARAMETERS : pa RADIOBUTTON GROUP rad USER-COMMAND com MODIF ID mod, pb RADIOBUTTON GROUP rad MODIF ID rad, pc RADIOBUTTON GROUP rad MODIF ID cad. SELECTION-SCREEN SKIP. **TO INCLUDE DYNAMIC ICONS

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

screen-active = 0. screen-display_3d = '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'. mmtable = 'MARD'. WHEN '4'. mmtable = 'MARM'. ENDCASE. * LIST BOX TWO VALUES CASE two. WHEN '1'.

*VALUES FOR CLICK OF THE PUSHBUTTON ON APP TOOLBAR *AND ENABLING THE BUTTONS TO PERFORM F8 CASE sscrfields-ucomm. APPEND l_value TO li_list. WHEN 'FC03'. l_value-text = 'Plant Data for Material'. ENDCASE. PERFORM f4_value_request_pc. sscrfields-ucomm = 'ONLI'. *SUBROUTINE FOR OUTPUT PERFORM output. hrtable = 'PA0022'. DATA: l_name TYPE vrm_id. hrtable = 'PA0006'. CLEAR l_value. PERFORM f4_value_request_pb. sdtable = 'VBUK'. tablename = sdtable. hrtable = 'PA0008'. WHEN '4'. *START OF SELECTION EVENT START-OF-SELECTION. li_list TYPE vrm_values. ENDCASE. sdtable = 'VBAP'. WHEN 'FC01'. WHEN '1'. WHEN '3'. *VALUES ASSIGNED TO DROPDOWNLISTS IN THE SUBROUTINES PERFORM f4_value_request_pa. * LIST BOX THREE VALUES CASE three. l_value-key = '2'. ENDCASE. . sdtable = 'VBUP'. WHEN '2'. l_value LIKE LINE OF li_list. WHEN '2'. tablename = hrtable. WHEN 'FC02'. hrtable = 'PA0001'. sscrfields-ucomm = 'ONLI'. WHEN '3'. WHEN '4'. *&----------------------------------------------------------------* *& Form f4_value_request_PA *&----------------------------------------------------------------* * text *-----------------------------------------------------------------* *SUBROUTINE TO PROVIDE DROPDOWN VALUES TO LIST1 FORM f4_value_request_pa. tablename = mmtable. sscrfields-ucomm = 'ONLI'. l_value-key = '1'.sdtable = 'VBAK'. *INITIALIZATION EVENT INITIALIZATION.

l_value-key = '3'. CLEAR l_value. l_value-text = 'Sales Document: Item Data'. l_value-text = 'Sales Document: Item Status'.l_value-text = 'General Material Data'. CLEAR l_value. li_list TYPE vrm_values. IF sy-subrc <> 0. l_value-key = '3'. CLEAR l_value. l_value-key = '2'. ENDFORM. APPEND l_value TO li_list. l_value-key = '4'. l_value LIKE LINE OF li_list. l_value-text = 'Sales Document:Header Status'. l_value-text = 'Storage Location Data for Material'. CLEAR l_value. l_value-key = '4'. l_value-key = '1'. CLEAR l_value. CLEAR l_value. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. APPEND l_value TO li_list. l_name = 'TWO'. CALL FUNCTION 'VRM_SET_VALUES' EXPORTING id = l_name values = li_list EXCEPTIONS id_illegal_name = 1 . APPEND l_value TO li_list. l_name = 'ONE'. APPEND l_value TO li_list. DATA: l_name TYPE vrm_id. CALL FUNCTION 'VRM_SET_VALUES' EXPORTING id = l_name values = li_list EXCEPTIONS id_illegal_name = 1 OTHERS = 2. APPEND l_value TO li_list. ENDIF. l_value-text = 'Units of Measure for Material'. APPEND l_value TO li_list. " f4_value_request_tabname *&----------------------------------------------------------------* *& Form f4_value_request_PB *&----------------------------------------------------------------* * text *-----------------------------------------------------------------* *SUBROUTINE TO PROVIDE DROPDOWN VALUES TO LIST2 FORM f4_value_request_pb. CLEAR l_value. l_value-text = 'Sales Document: Header Data'. APPEND l_value TO li_list.

APPEND l_value TO li_list. CLEAR l_value. ENDFORM. APPEND l_value TO li_list. CLEAR l_value. CALL FUNCTION 'VRM_SET_VALUES' EXPORTING id = l_name values = li_list EXCEPTIONS id_illegal_name = 1 OTHERS = 2. l_value-text = 'Address Infotype 0006'. l_name = 'THREE'. " f4_value_request_PC *&----------------------------------------------------------------* *& Form OUTPUT *&----------------------------------------------------------------* * text *-----------------------------------------------------------------* * -->P_TABLENAME text *-----------------------------------------------------------------* *fINAL OUTPUT FORM output. l_value-text = 'Basic Pay Infotype 0008'. CLEAR l_value. Assignment)'. APPEND l_value TO li_list. IF sy-subrc <> 0. " f4_value_request_PB *&----------------------------------------------------------------* *& Form f4_value_request_PC *&----------------------------------------------------------------* * text *-----------------------------------------------------------------* *SUBROUTINE TO PROVIDE DROPDOWN VALUES TO LIST3 FORM f4_value_request_pc. ENDIF. DATA p_table(10). ENDIF. APPEND l_value TO li_list. CLEAR l_value. l_value-key = '1'. DATA: l_name TYPE vrm_id. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. l_value LIKE LINE OF li_list. *popup to display teh selected table and . MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. l_value-text = 'HR Master :Infotype 0001 (Org.OTHERS = 2. IF sy-subrc <> 0. ENDFORM. l_value-key = '2'. l_value-key = '4'. p_table = tablename. l_value-key = '3'. li_list TYPE vrm_values. l_value-text = 'Education Infotype 0022'.

*Continue button is clicked CALL FUNCTION 'POPUP_TO_DISPLAY_TEXT' 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

Dynamic selection screens based on selection of the radio buttons

On click of the Button in the Application toolbar, here „Sales and Distribution‟, we get

On clicking Continue, it proceeds to SE16.

Dynamic Variant using the table TVARV
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 (ABAP: Save as Variant) enter Variant name, description, set the „Selection variable‟ (L) radio button and press „Selection variable‟ push button.

In the next screen check that green traffic light is on under column T (T: Table variable from TVARV). Then click on the button.

Now from the popup select the variable name created in Step1 and save the variant.

Step 3. Select the variant from Variant catalog.

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

Go to SMW0 and for uploading the image.

Select Binary Data

Select the Find Button

Press Press the Create button

Enter name and description

Select the image to upload

Assign a package (must)

Press Save and OK

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 EXPORTING height = 200 left = 100 top = 20 width = 400. *CHANGE POSITION AND SIZE ABOVE*************************** IF url IS INITIAL.

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 Make changes in the report accordingly.

Capgemini India Step1: Creation of parameter ID.Given below is the desired output Custom Parameter-id Creation By Abhijit Daptary. 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 Set/Get parameter id as the parameter ID you want to create. I will be creating the parameter Id as ZNAME_DATA1. Click on the maintain button. Click on ENTER button. Enter the table view name TPARA. Click on the Tick button or the ENTER button to go to the next screen. The following information will appear. Here. .

The parameter id can be seen in the table TPARA. Enter the text of the parameter ID and click on the Save button.It will ask for the text of the parameter Id. Enter the Package and the transport number. .

It will act the same good as a standard one. 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. IBM India Step1. Create Dynamic Patterns By Joyjit Ghosh.Step2: Using the parameter Id that you have created. Create a pattern with only one line that contains *$&$EXIT. .

Step2. .Put this above expression and press save button. Now from CMOD create a project and include enhancement SEUED001 in it.

.Now select the user exit EXIT_SAPLLOCAL_EDT1_001 and create the include program in it.

APPEND w_buffer TO buffer. w_buffer = '*& Module :'. APPEND w_buffer TO buffer. APPEND w_buffer TO buffer. w_buffer = '*& Create Date :'. w_buffer = '*********************************************************************'. w_buffer = '*& Funct. . *&---------------------------------------------------------------------* *& Include ZXSEUU26 * *&---------------------------------------------------------------------* DATA: w_buffer TYPE string. APPEND w_buffer TO buffer. w_buffer = '*& Functional Contact:'. w_buffer = '*& Program :'. w_buffer = '*& Project Phase :'. w_buffer = '*& Description :'. Ref. APPEND w_buffer TO buffer. w_buffer = '*& Program Type :'. APPEND w_buffer TO buffer.Now insert the following code block in the include program and activate it. WHEN 'DYNAMIC_PATTERN'. w_buffer = '*********************************************************************'. APPEND w_buffer TO buffer. w_buffer = '*& Sub-Module :'. w_buffer = '*& Developer(Company):'. :'. APPEND w_buffer TO buffer. CASE keyword. APPEND w_buffer TO buffer. Spec. APPEND w_buffer TO buffer. APPEND w_buffer TO buffer.

WHEN OTHERS.APPEND w_buffer TO buffer. Lastly activate the project Scheduling background jobs by triggering events . * Do nothing ENDCASE.

Step1: Create event from transaction SM62. Give event name and description and press save button Step2: Create a program that triggers this event by calling the FM „BP_EVENT_RAISE’. *&---------------------------------------------------------------------* .

Write: 'Event triggered'. Write: 'Event failed to trigger'. In the initial screen give job name and job class and press “Start condition” button. 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 .*& Report Z_TRIGGER_EVENT * *& * *&---------------------------------------------------------------------* *& * *& * *&---------------------------------------------------------------------* REPORT Z_TRIGGER_EVENT . IF sy-subrc <> 0. Step3: Configure the background job from transaction SM36. else. ENDIF. .

In the popup screen press “After event” button and give the event name and then press save button. .

.

.Now go back to the initial screen and press “Step” button Provide program and variant name and after providing all the values press save button.

In the initial screen 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 Now check the spool to see the generated list .

Program using Normal Nested Loop: REPORT TABLES: likp. .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. lips. then the situation would be too worse. If the number of entries in the internal tables is huge. The solution for this is to use parallel cursor method whenever there is a need for Nested Loop. ZNORMAL_NESTEDLOOP.

. select * from lips into table t_lips. endloop. START-OF-SELECTION. SELECT * FROM lips INTO TABLE t_lips. w_index LIKE sy-index. w_runtime2 TYPE i. data: W_RUNTIME1 TYPE I. loop at t_likp into likp. zparallel_cursor2. endloop. DATA: w_runtime1 TYPE i. write w_runtime2. SELECT * FROM likp INTO TABLE t_likp. lips. w_runtime2 = w_runtime2 . loop at t_lips into lips where vbeln eq likp-vbeln. START-OF-SELECTION. TYPE TABLE OF lips. type TABLE OF lips. DATA: t_likp t_lips TYPE TABLE OF likp. get RUN TIME FIELD w_runtime2. get RUN TIME FIELD w_runtime1. W_RUNTIME2 TYPE I.Data: t_likp t_lips type table of likp.w_runtime1. select * from likp into table t_likp. Nested Loop using Parallel Cursor: REPORT TABLES: likp.

103.w_runtime1. w_runtime2 = w_runtime2 .583 34.894 50. LOOP AT t_likp INTO likp. ENDLOOP. we would discuss about creating a transaction variant for the transaction MM01. IF likp-vbeln NE lips-vbeln. SORT t_lips BY vbeln. w_index = sy-tabix. ENDIF. . SORT t_likp BY vbeln. LOOP AT t_lips INTO lips FROM w_index. WRITE w_runtime2.534. Go to transaction SHD0. GET RUN TIME FIELD w_runtime2.829 56. EXIT.510 Creating a Transaction Variant By Smita Singh In this tutorial.426 Using Parallel Cursor 63.GET RUN TIME FIELD w_runtime1.147 38. ENDLOOP. Analysis report: Runtime in microseconds: Iteration No 1 2 3 Normal Nested Loop 34. 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).796.

Following information message would appear: Click Enter to proceed. Now click on button CREATE. Now the MM01 transaction would appear.Enter the transaction code MM01. .

Following popup would appear: Now make the modifications as shown below: .Select the required Industry sector and Material Type and press ENTER.

Click on “Exit and Save”. Following popup would appear: Click Enter to proceed. Following screen would appear: .

Enter the name of the screen variant created earlier or use F4 help to select the value: . Now enter the transaction variant name and click on Change button as shown below: Now click on Insert Row.Save your entries and go back to the main screen.

Now click on Goto  Create Variant Transaction Enter the values as shown above. Click on Enter. The following SE93 transaction would appear: .

Save your entries. E-Mailing the background jobs By Harini . Now go to Transaction ZMM01 and check your transaction variant: You can observe that the field Industry sector and Material type default to the value we have given earlier and are output enabled only.The name of the Transaction Variant is automatically proposed.

The output of the background job is sent to the recipient as an email. Consider the following simple program: REPORT zbackground_test. We would schedule the above program as a background job and send the output of the same as an email. Go to Transaction SM36. Following popup screen appears: .com team'. Enter the job name. WRITE: 'hello SAPTechnical.This tutorial deals about the procedure in automatic e-mailing of the background jobs. Press Enter.

Click on Back button to navigate to the main screen. .Enter your program name as shown above and click on SAVE.

Click on the button “Spool list recipient” as shown above. . Now come back to the main screen and click on “Start Condition”. Enter the name of the recipient to which the output to be sent. Select Immediate and click on save.

the job would be set to status Released. Now go to SAP inbox (transaction SBWP/SO01) to check the status of the background job: In the above screenshot. Only after you save.Save your job. Open the attachment to see the output of the background job: . You can go to transaction SM37 to monitor the background job. you can observe an email related to the job we created earlier.

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 : * * * ************************************************************************ .

* Modification history: * --------------------------------------------------------------------------------------------------------* DATE |User ID |TS Ver | Transport Request | Description * --------------------------------------------------------------------------------------------------------* ************************************************************************ Naming conventions to be followed: Other Objects .

.

CO F.PM S – SD / SAM M – MM/Supply ABAP Performance Standards By Aveek Ghose.g.Application area corresponds to the application area you are working like B .FI W . N or N/A) Comments . Use the results of the above checks to remove all variables/constants etc that are declared but are not used) Transaction SE30 (ABAP Runtime Analysis) must be checked to Result (Y.Basis C . IBM India Description Run Extended syntax checks with character literals checkbox switched on & Code Inspector to rectify all relevant errors and warning (e.

when the internal table will be greater than 500. Create new indices if necessary. 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. Check other indices for this table and where you have to change your “where” clause to use it. but do not forget to check the impact by consulting onsite coordinator.000 records).. “SELECT UP to 1 Rows” 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. If the order of sorting is invalid the BINARY SEARCH will never work For large internal tables where only some rows are to be . which are used in a READ TABLE statement using BINARY SEARCH. “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. 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 not used instead “Inner Join” and/or “For all Entries” is used. except when the table will be very large (i. 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. Check these indices against your “where” clause to assure they are significant. 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.e.e. TYPE (data element) command is used while declaring the fields whenever feasible instead of LIKE.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.

ENDLOOP. 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. the work area that has been appended is cleared Internal tables. 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..g. to accelerate the updating of internal table If possible.. use SORT and then the READ TABLE command is used to set index to first relevant row before looping from that index. for single line. Do not use: LOOP AT ITAB WHERE EQUNR = „00001011‟. and MODIFY ITAB .. WHERE condition for a set of line. Work areas & Global Variables are freed when no longer needed (e. Use: DELETE ITAB WHERE EQUNR = „00001011‟. using the FREE / REFRESH command). 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. TRANSPORTING f1 f2 . 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... TRANSPORTING f1 f2 .processed.. Also READ TABLE INTO WORKAREA should be used instead of only READ TABLE. Update/Insert statement is used instead of Modify Is the following steps ensured during database updates?  Lock data to be edited Read current data from the database Process data and write it to the database   . After the APPEND statement inside a loop. Also CASE is used 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‟... DELETE ITAB. Use the MODIFY ITAB . SORT ITAB BY FLD1 FLD2 ASCENDING) Hashed table is used for processing large amount of data (provided that you access single records only.

Max. under Trace requests. If your program uses a logical database. Release the locks set at the beginning Try to avoid logical databases. but does not require all fields belonging to a certain GET event. 4. click Trace on. click Trace off. Click List trace to view the trace of the current statement. always use the FIELDS addition to reduce the amount of data selected by the logical database Avoid the aggregate (Count. click the check box for SQL trace. 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. 2. Run the program containing the SQL query that needs to be analyzed in the SE38 editor. From the initial screen. Access transaction ST05. Come back to ST05 screen. under the trace requests. IBM India Performing an SQL Trace: 1. 3. Screen shot of the initial ST05 screen .

After clicking list trace .

Basic List Trace .

Summary of a particular trace . Use menu path: GotoSummary.The basic list trace shows the sequence of database operations that are taking place while a query is processed. In addition the basic list trace also gives the duration execution for each of the operations with color legend. execute. The summary option lists the summed up execution time of all the queries that the SQL trace has captured at its runtime. The above screen shot depicts the summed up execution time. it includes prepare. fetch. 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. 896 is the process ID for one of the SQL statements. 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. open. reopen. For example.

select all the PID corresponding to it and click summarize in the application toolbar. 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. This leads to a compressed data of SQL trace as above.To get the total execution time. specifically for a particular SQL Statement. Color legends indicating the processes in a trace 2 .

A change in object name is indicated with the change in color to yellow. Although most Oracle users rely on the automatic cursor handling of the Oracle utilities. In application development. such an area is also called a private SQL area. Cursors: A cursor is a handle or name for an area in memory in which a parsed statement and other information for processing the statement are kept. the programmatic interfaces offer application designers more control over cursors. The extended list shows the cursor id declared for the SQL statement. the connection type also. a cursor is a .The above screen shot indicates that the query execution time has exceeded its threshold with the link pink color. Extended list (From basic trace list: click extended list button in application toolbar to view the extended list). These colors thereby indicate whether the query is well written and also the current status of the database server.

Identical select statements are grouped based on the where clause. too. Note that identical select statements have similar execution plan used for their processing thereby saving time of execution and provide increased performance. Identical select statements Use the menu path: Goto Identical Selects to view a comprehensive list of identical select statements executed during the trace and the number of times they were executed.named resource available to a program and can be used specifically for the parsing of SQL statements embedded within the application. Identical select statements displayed .

and executes the statements that change data in the database (such as UPDATE. 3) OPEN: This operation opens the declared cursor and passes the parameters for database access. VA03 Transactions. or INSERT). 5) REOPEN: Once a new select statement is brought in then this operation opens the cursor previously declared for previous select statement and performs new parameter passing to the database. 4) FETCH: This operation passes one or more data records fetched to the database interface of the R/3 system. 2) PREPARE: This operation converts the SQL statement into native SQL and frames out an execution plan for that statement. DELETE. VA02. VA02 and VA03 By Vikram Chellappa. Go to transaction VA01 . Mouri Tech Solutions Scenario: The below steps to be followed for Changing the text Sales Order to Billing Request in VA01.The above screen shot shows the list of identical select statements and the number of time they got executed. Database Operations Measured by SQL Trace The SQL Trace analysis helps in measuring the execution time of the following data base operations that are performed when executing an SQL statement. Changing the text "Sales Order" to "Billing Request" in the transactions VA01. 6) EXEC: Passes the parameters for the database statement. 1) DECLARE: This operation declares a new cursor and assigns the SQL statement to that cursor created.

In Menu bar Go to System > Status Double click on the Screen number 101 .

.Double click on MODULE CUA_SETZEN Double Click on PERFORM CUA_SETZEN.

Click on Enhance (Shift+F4) Click on Edit > Enhancement Operations > Show Implicit Enhancement Options .

Here we need to create an Enhancement. .Scroll down up to the line 1425.

Right Click on the page Go to Enhancement Implementation > Create

The below screen will appear Mark the check box

Click on create enhancement Implementation (F8)

Enter the Enhancement Implementation, Short text and Click on Create Composite Implementation.

The Below screen will appear

Enter the name for Composite enhancement implementation and Short Text. Then Click on Creation of Enhancement (Enter)

Click on Save and Assign it in corresponding Package.

By scrolling down select the already created Enhancement Implementation, Click on continue.

Go to SE80 create a new zprogram named ztitle.

Click on Yes.

Enter the Program name and continue.

Enter the Title of the created program and Assign Type as Module Pool. Click on Save.

Save it in Package.

Right Click on ztitle > Create >GUI Titles

Enter the Title Code And Title.

Click on Transfer or (Enter)

Create another Title code.

Assign the Title code and title.

Repeat the above same procedure.

Right Click on Ztitle and Click on Activate.

The created GUI title will display under GUI Title.

.Type SAPMV45A in Program > Go to Subroutines. Scroll down in CUA_SETZEN.

. Type the Below Code IF sy-tcode = 'VA01'.The Below screen will display.

SET TITLEBAR 'Z03' OF PROGRAM 'ZTITLE' WITH <TFS>. SET TITLEBAR 'Z02' OF PROGRAM 'ZTITLE' WITH <TFS>. ENDIF. ELSEIF sy-tcode = 'VA03'.SET TITLEBAR 'Z01' OF PROGRAM 'ZTITLE' WITH <TFS>. ELSEIF sy-tcode = 'VA02'. Click on save and Click on activate Enhancements (Ctrl+F3) .

Go to Program and Click on Generate. .

Go to VA02. Go to VA01. .Now you can go and view the transaction screen. Go to VA03.

Open the function Module : ME_GET_CURRENT_USER_ID Choose Utilities -> More Utilities -> Creating a Web Service -> From Function Module. Mouri Tech Solutions “In this Scenario.Creation of a web service in SAP By Raghava Vakada.” Creating a Web Service In the function library (SE37). . display the function module. I would like to explain about creating a Web Service with a simple scenario.

Enter the name of the Web Service Definition .In the Web Service Creation Wizard. choose Continue.

In the following screen. enter the required data and select the checkbox Name Mapping. If the checkbox Name Mapping is ticked. enter the required data and select the checkbox Release Service for runtime. . In the following screen. Choose Continue. the wizard accepts the existing names for the end point.

Choose Continue. . Choose Complete.

Select the Web service definition you have created under SOAP Application for RFC-Compliant FMs Select and expand the “ZWEB_GET_CURRENT_USER” and select the Web Service as shown in screen. Prerequisites Open the transaction WSADMIN. Testing a Web Service.Save as local object. .

Check the J2EE Server and check in your server.You have entered the address of the application server on which the J2EE Engine is running in transaction WSADMIN under Goto -> Administration Settings. . Choose Web Service Homepage (Execute Button ).

Select the “Document Style” under Style definition in WSDL. The Web service requires authentication. Enter the user and password .

. Select the “Operations”.Click on the “Test”.

The Web service has not been tested successfully. Choose Send. . The required values are displayed under the Response heading.Fill in values for the method parameters underneath the heading Request if required.

DATA: w_string TYPE string . CLEAR w_string . For more details regarding this web service.Calling a web service in ABAP that validates an email id By Teja In this tutorial.asmx/IsValidEmail?Email=' p_mail INTO w_string . START-OF-SELECTION .net/ValidateEmail.webservicex. DATA: result_tab TYPE TABLE OF string. w_result TYPE string . CONCATENATE 'http://www. Create a program and use the following code: REPORT zvalidate_email. CALL METHOD cl_http_client=>create_by_url EXPORTING url = w_string IMPORTING . PARAMETERS: p_mail(100) LOWER CASE. we would use a free web service in an ABAP program which validates an emailid. click here. " E-Mail id to be verified DATA: http_client TYPE REF TO if_http_client . r_str TYPE string .

CLEAR w_result . READ TABLE result_tab INTO r_str INDEX 2. WRITE:/ 'Valid email address'.client = http_client EXCEPTIONS argument_not_found = 1 plugin_not_active = 2 internal_error = 3 OTHERS = 4. IF r_str+44(1) = 't'. w_result = http_client->response->get_cdata( ). ELSE. CALL METHOD http_client->send EXCEPTIONS http_communication_failure = 1 http_invalid_state = 2. Output: Handling favorites in ABAP Workbench By Sunitha . ENDIF. REFRESH result_tab . SPLIT w_result AT cl_abap_char_utilities=>cr_lf INTO TABLE result_tab . WRITE:/ 'Invalid email address'. CALL METHOD http_client->receive EXCEPTIONS http_communication_failure = 1 http_invalid_state = 2 http_processing_failed = 3.

I would always want to add my frequently used objects in the favorites. Enter the package name SWDP_DEMO_TUTORIALS as shown below: Now open the list box “Favorites” and click on Add: The following message appears: Now verify the same by opening the favorites: . Go to Transaction SE80 and select “Package” from the list box. For our learning purpose.This document details the procedure in handling the favorites in the ABAP Workbench. let us add the package SWDP_DEMO_TUTORIALS (Demo tutorials for Web Dynpro ABAP) to the favorite list.

we can add the recently used objects in the favorites list. click on Edit as shown below: Following screen appears: . To download/Upload favorites from one system to another: In the favorites.This way.

we can either download/upload the favorites from one system to another. Events in Table Maintenance Scenario: We have a following custom table which contains the fields “Date on which record was created” and “Name of the person who created the object”. We would like to have these to be filled up with SY-DATUM and SY-UNAME respectively.Using the Download/Upload buttons. Go to Table Maintenance Generator: .

Enter the details as shown below: .

Now click on Environment -> Modification -> Events Following screen is displayed. .

after saving the data. before deleting. Following entries are displayed: Here you can observe that there are different types of events available like before saving the data. Let us go with “Creating a new entry”. .Click on F4. after deleting and others.

Click on the button in the Editor column and enter the following code: (Please note that you should also code FORM and ENDFORM as well). . Save and activate the table. Do not enter the values for “Created on” and “Created by”. Testing the scenario: Go to SM30 and try creating new entries.

Check your entries in the database table. * Internal table declaration DATA: T_MARA TYPE STANDARD TABLE OF TY_MARA. . * Table workarea definition DATA: WA_MARA TYPE TY_MARA. MTART LIKE MARA-MTART. W_TABIX LIKE SY-TABIX. T_MARA1[] = T_MARA[].. * Variable declaration DATA: W_COUNTER TYPE I. You can observe that the date and user name are automatically filled-in. W_RUNTIME2 TYPE I. MATNR LIKE MARA-MATNR. T_MARA1 TYPE SORTED TABLE OF TY_MARA WITH NON-UNIQUE KEY MTART. Standard internal table processing using WHERE condition Second Method: Same as above. This article is intended to demonstrate the comparison between three different methods in handling this situation. SELECT MATNR " Material Number MTART " Material Type FROM MARA INTO TABLE T_MARA. First Method: The normal method used by most of us. * CASE 1: Processing internal table using LOOP. END OF TY_MARA. See the screenshot below: Using Sorted table and Index while processing Internal tables By Suresh Kumar Parvathaneni There would have been many instances where we would have to process large entries in an internal table with a WHERE condition.WHERE Condition GET RUN TIME FIELD W_RUNTIME1. W_RUNTIME1 TYPE I. * Program to find the best method in reading the internal tables * Author: Suresh Kumar Parvathaneni * Type declaration TYPES: BEGIN OF TY_MARA. but here we would be using the Sorted table Third Method: Sorted table and using the Index Following is the demo program illustrating the above three methods: REPORT ZINTERNAL_TABLE_OPERATIONS.

IF SY-SUBRC EQ 0. WRITE W_RUNTIME2. ENDIF. ENDIF. * Calculate Runtime W_RUNTIME2 = W_RUNTIME2 . ENDLOOP. READ TABLE T_MARA1 INTO WA_MARA WITH KEY MTART = 'FHMI'. ADD 1 TO W_COUNTER. GET RUN TIME FIELD W_RUNTIME2. ADD 1 TO W_COUNTER. GET RUN TIME FIELD W_RUNTIME2. WRITE W_RUNTIME2. * CASE 3: Using INDEX on a sorted table GET RUN TIME FIELD W_RUNTIME1.LOOP AT T_MARA INTO WA_MARA WHERE MTART EQ 'FHMI'.W_RUNTIME1. Following is the analysis report in microseconds. CLEAR W_COUNTER. * Calculate Runtime W_RUNTIME2 = W_RUNTIME2 .W_RUNTIME1. ENDLOOP. ADD 1 TO W_COUNTER. ENDLOOP. ADD 1 TO W_COUNTER. GET RUN TIME FIELD W_RUNTIME2. IF WA_MARA-MTART NE 'FHMI'. as per the data volume: Records: 21. LOOP AT T_MARA1 INTO WA_MARA FROM W_TABIX. W_TABIX = SY-TABIX + 1. * Calculate Runtime W_RUNTIME2 = W_RUNTIME2 . * CASE 2: Using a Sorted table GET RUN TIME FIELD W_RUNTIME1. CLEAR W_COUNTER. EXIT.W_RUNTIME1. WRITE W_RUNTIME2.390 Iteration No 1 2 3 4 5 Using Normal LOOP & WHERE 897 839 839 834 842 Using Sorted table LOOP & WHERE 887 879 877 880 837 Using INDEX on Sorted table 11 10 10 9 10 Records: 132. LOOP AT T_MARA1 INTO WA_MARA WHERE MTART EQ 'FHMI'.693 Iteration No 1 2 Using Normal LOOP & WHERE 34239 34271 Using Sorted table LOOP & WHERE 35774 38250 Using INDEX on Sorted table 3567 3592 .

APPEND TAB. 12 TO TAB-VAL1. CLASS(5) TYPE C. C(20). 10 TO TAB-VAL2. APPEND OPTTAB. 20 TO TAB-VAL3. "// Background Color CALL FUNCTION 'GRAPH_MATRIX_3D' EXPORTING COL1 = '1997' COL2 = '1998' COL3 = '1999' DIM2 = 'Products' . APPEND TAB. 15 TO TAB-VAL1. MOVE: 'DA' TO TAB-CLASS. 8 TO TAB-VAL2. OPTTAB = 'FIFRST = 3D'. 17 TO TAB-VAL1. "// Farben der Objekte OPTTAB = 'TISIZE = 2'. However. The SAP Graphics can be used for various business purposes”. DATA: BEGIN OF TAB OCCURS 5. *&---------------------------------------------------------------------* *& Report ZGRAPH_TEST *& *&---------------------------------------------------------------------* REPORT ZGRAPH_TEST. APPEND OPTTAB. we can say that method 3 is better than the other 2 methods. "// Objektart OPTTAB = 'P3CTYP = RO'. 11 TO TAB-VAL2. VAL2(2) TYPE I. Displaying Graphics using an ABAP Program By Raghava Vakada. VAL3(2) TYPE I. APPEND TAB. Mouri Tech Solutions “I would like to explain about a simple report program to display graphics. "// Grafik-Typ OPTTAB = 'P3TYPE = TO'. "// Haupttitelgröße OPTTAB = 'CLBACK = X'. END OF OPTTAB. CLEAR TAB. APPEND OPTTAB. In production environment. 15 TO TAB-VAL3. CLEAR TAB.3 4 34492 34198 36534 35695 3554 3584 Sorted table might have given a better performance here if the field in the WHERE condition is the first field in the internal table. MOVE: 'cool' TO TAB-CLASS. the data would be huge and the performance could be much improved with this simple technique. APPEND OPTTAB. END OF TAB. VAL1(2) TYPE I. 18 TO TAB-VAL3. In this article I am explaining about a simple Sales analysis on a yearly basis. APPEND OPTTAB. from the above statistics. DATA: BEGIN OF OPTTAB OCCURS 1. MOVE: 'fan' TO TAB-CLASS. CLEAR TAB.

Crores' = TAB = OPTTAB = 1. . Results : = 'Years' = 'Sales In Rs.DIM1 TITL TABLES DATA OPTS EXCEPTIONS OTHERS LEAVE PROGRAM. Execute the report program for an output shown below. To display more detailed view. Click on Overview for detailed view.

The ABAP New Editor TM By Suresh Kumar Parvathaneni This article. the first part of a two-article series. Shifting to ABAP TM New Editor Start any of the following transaction codes to access the ABAP TM workbench:     SE38 SE37 SE24 SE37 We would use SE38 for our demo purposes. takes you on a brief tour of the features available in the new ABAPTM editor (step by step with screenshots) Pre-requisites The new ABAPTM editor is available with SAP® GUI for windows 6. However this new editor is supported from the SAP® Version SAP® Netweaver 2004s.40 patch level 10 or higher. Procedure to shift between Old ABAPTM Editor and New ABAPTM Editor:   Go to Utilities à Settings Click on Front-end Editor (New) as shown below .

TM Features in ABAP First Look: New Editor View of the new ABAPTM Editor (from SE38): Display Features Following are some of the features that could be observed while writing the code: . Click for changes to effect.

For example. These indicators would vanish once you come out of the program. right click on the Indicative Margin. click on Bookmarks --> Bookmark 0 (Bookmarks are numbered 0 to 9). . Bookmarks could be accessed by the right click of the mouse in the Indicator Margin (The complete left portion of the ABAPTM editor). Code Hints Code hints appear as you type in ABAPTM editor. To navigate to any bookmark marked earlier. When typed PA. the new ABAPTM editor displays the line numbers for easy navigation through the code. A Blue flag with the bookmark number would appear on the Indicative Margin. To set a bookmark. following occurs:   When typed P. if you start typing for Parameters. nothing appears.Line Numbers As observed in the above screenshot. Changed line indicators The changed lines in the current session are marked with . code hint PACK appears. Bookmarks Bookmarks allow in navigating and code editing. There are 9 numbered bookmarks provided by SAP® and unlimited unnumbered bookmarks. Go to Bookmark --> Bookmark 0. right click on the Indicative Margin.

Press TAB to choose the given code hint. When typed PAR. we can set different colors and fonts for different elements on the editor. code hint PARAMETERS appears. Changing the Font and Colors of coding environment Click on . available at the right side bottom of the editor. The split screen is seen as below: . The window could be set to splitter mode by double clicking the splitter line above the vertical scrollbar (shown below). From here. Window Splitter The window splitter allows you to work on different parts of the code simultaneously. Click on “Fonts and Colors” on the left side of the window that is appeared after clicking.

Also visit Features of ABAP New Editor Part 2 The Features of ABAP New Editor Part 2 By Suresh Kumar Parvathaneni Working with Colors and Fonts: Switch to the new editor (if the default editor shown is the old editor). In the New ABAP editor. as shown in the below screen shot: . click on the button “options” available at the bottom of the right hand side.

.Following pop-up appears: Now select “Fonts and Colors” available on the left side.

Select “Comments” from the list box: . foreground color and background color). For example. you can design how the screen should look like. you can dictate how the comments should appear (like Font. Comments are currently displayed as shown below: Now click on the options button and select “Fonts and Colors”.Using this. size. Let us take the same “comments” section for our scenario here.

Now change the way you would like the options to appear in this section: Save and check how the way comments appear now. .

. Click on “Options” as shown earlier. Click on any code template to understand further. Now click on “Code Templates” option available on the left side. You would observe the code templates available for use with the editor.Working with Code Templates: To view the Code Templates currently available.

Select -> Format -> Surround by template -> Do () (as shown in the following screenshot) . Now select your program code and click the right button of the mouse. We would use this for our demo purpose to better understand the code template. Write some sample code in your editor.Above screenshot is for “DO”.

As observed in the earlier screenshots. Let us create a code template for the same.Now observe your code: Your code is now surrounded by the code template “DO”. . there is no code template available for subroutine. Creating custom code template: Now we would work on creating our own code template for our future use.

Select Format -> Extract template Enter the name for your code template. .Select your code and click on right button. Click on OK.

Click on the empty line between “form” and “endform” and click on “Insert tag” Select Surrounded Text from the given options. .Now we need to define the position where the selected text (surrounded text) to appear.

To test our code template.Save and exit. Right click and select our code template. . write a sample code in our program.

Our code template is displayed as below: Now just enter the form name to complete your subroutine definition. Setting Break-points: Open the new ABAP editor and write some sample code in it. .

please visit SAP.Activate your program.Code. Mouri Tech Solutions For theoretical concepts on Menu Painter.help. . (See the screenshot below): Break-point in set now. To set the break-point.com Create a program in SE38 T. Working with Menu Painter By Raghava Vakada. click on indicator margin. available on the left side of the line numbers.

Save it in a Relevant Package.Enter the Title of the Program And Select the Type as Executable Program. Go to T-code SE41 Enter the Program name and Status name. . And click on save.

.Click on create Enter the Short text for Status.

Specify a Menu Name file Double click on File. .Click on Menu Bar.

Click on save. Press Execute or F8. . check and Activate.Enter the Code and text Values.

Created Menu is displayed here.Click on Continue and Enter. .

. Click on Title List. Click on create. Click on continue.To create a Title. Enter the Title Code and Title.

Click on enter and Click on Test. . Enter the created Title Code in Title. Click on Continue. Click on execute.

EXIT TYPE C. *&---------------------------------------------------------------------* . ERNAM TYPE MARA-ERNAM. DELETE TYPE C.Created Title Displayed. DATA: MATNR TYPE MARA-MATNR. CLEAR TYPE C. Click on Save. TABLES: MARA. SAVE TYPE C. *&---------------------------------------------------------------------* *& Report ZMENU_PAINTER *& *&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* REPORT ZMENU_PAINTER. ERSDA TYPE MARA-ERSDA. DISPLAY TYPE C. CALL SCREEN 101. OK_CODE LIKE SY-UCOMM.

ENDMODULE.*& Module STATUS_0101 OUTPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE STATUS_0101 OUTPUT. " USER_COMMAND_0101 INPUT Click on middle Icon . LEAVE PROGRAM. WHEN 'DISPLAY'. ENDCASE. WHEN 'BACK'. MARA-ERNAM) WHERE MATNR = MARA-MATNR. WHEN 'EXIT'. ENDMODULE. LEAVE PROGRAM. SET PF-STATUS 'ZMENU'. CASE SY-UCOMM. SET TITLEBAR 'ZMENU_PAINTER'. CLEAR MARA. WHEN 'CLEAR'. " STATUS_0101 OUTPUT *&---------------------------------------------------------------------* *& Module USER_COMMAND_0101 INPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE USER_COMMAND_0101 INPUT. . SELECT SINGLE ERSDA ERNAM FROM MARA INTO (MARA-ERSDA.

Enter MARA in the Table/Fieldname Text Box Then click on Get From Dictionary. .

Select the require fields and click on continue. . Insert these boxes on the screen.

You can view like this after placing the boxes. .

.Create require Push buttons from toolbox.

Create require check box from toolbox. . Give the required Name . Check and Activate. Text and Function Code Name . Click on Save.

. Click on Display.Output: Enter the Material number and Press Display.

Clear – It will clear all the displayed contents. .Values are displayed as shown below. Similarly You Can View Clear And Exit.

It will return to code.    F5 Clear F6 Display F7 Exit. .Exit . We can Use the same operation in Function Keys..

which needs to be dynamic. it would be possible to retrieve all those records which are past 15 days entries from now.Enter the Material and Press F6 . For example: On the selection screen of a report. take a Date field. From Date should be „Current date – 15‟ and To Date should be „Current Date‟. The same functionality F5 to Clear and F7 to Exit. In this way the report when run with this variant. Let us understand „What is Dynamic Variant?‟ Dynamic Variant consists of selection variable for a selection screen item where in a formula can be defined. Dynamic Variant in a report By Suraj Kumar Pabbathi. YASH Technologies Scenario: This blog is to explain the creation of Dynamic Variant for report selection screen. Please find below the procedure to define DYNAMIC Variant. .

Step2: Specify all those values which are static on the selection screen in this step. Then click „Variant Attributes‟ to define selection variable for „Date Created‟ on the selection screen. .Step 1: Go to transaction SE38 to specify the Program name and select „Variant‟ radio button and „Display‟. Then it will lead you to next screen „ABAP:Variants –Initial Screen‟ as shown below: Specify the variant which needs to be created or changed.

check the box under L as shown in the selection screen below: . provide suitable meaning for the variant. As we need to define selection variable for „Date created‟ item on selection screen.Step 3: In this step.

Step 4: In the previous step. select „Selection Variables‟ on the menu. in this screen you get to see the variable as „Date created‟. T: Table variable from TVARV D: Dynamic Date Calculation B: User defined Variables. Now click the black arrow as shown in the screenshot below and you will be prompted with search help of different formulas for the selection variable. This can be done by clicking the Traffic lights under „D‟as shown below to know that the particular option is selected. As we have decided to create selection variable for „Date created‟ item only. Here you are provided with three options. From the provided options as per our requirement select „D‟ option. It leads to the next screen as shown below. .

So. This variant can also be used in the background jobs. provide values as 15 for xxx and 0 for yyy. current date + yyy‟ and select it.Step 5: Find the suitable formula as „Current date – xxx. This will lead you to the next screen to enter the values for xxx and yyy. Save the variant and this will conclude the creation of dynamic variant with the help of selection variable. .

I have modified an existing program for showing F1 help. Now Displaying the F1 Help. See below *&---------------------------------------------------------------------* *& Report ZGB_TEST_SEARCH_HELP *& * * .    Select General Text from Document Class Select Language Type Name and press create Type in what you want to see in output U1 is for the Bold Text you see in the heading of the F1 Help. Save the Text.Creating F1 helps in ease By Gaurab Banerji Go to SE61 and create a general text TX like the one shown below. If you don‟t want to specify a bold text you can just type it in the DOKTITLE in the function module called.

*THE TABLE FOR RETURNING THE NAME OF THE SELECTED ITEM DATA : return_tab LIKE ddshretval OCCURS 0 WITH HEADER LINE. CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST' EXPORTING * DDIC_STRUCTURE = ' ' retfield = field_tab-fieldname * PVALKEY = ' ' * DYNPPROG = ' ' * DYNPNR = ' ' * DYNPROFIELD = ' ' * STEPL = 0 WINDOW_TITLE = 'Select name' * VALUE = ' ' * VALUE_ORG = 'C' * MULTIPLE_CHOICE = ' ' * DISPLAY = ' ' * CALLBACK_PROGRAM = ' ' * CALLBACK_FORM = ' ' * MARK_TAB = * IMPORTING * USER_RESET = tables value_tab = t_itab FIELD_TAB = field_tab * * . parameters: p_name1(10) type c. field_tab-tabname = 'VBAK'. *&---------------------------------------------------------------------* *& * *& F4 Help for p_name1 * *&---------------------------------------------------------------------* at selection-screen on value-request for p_name1. append t_itab. t_itab-name = 'Jennie'. *CLEAR ALL EXISTING DATA *TO BE DONE EVERYTIME F4 HELP IS REQUESTED REFRESH t_itab.*&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------* REPORT ZGB_TEST_SEARCH_HELP . APPEND field_tab. field_tab-fieldname = 'ERNAM'. selection-screen end of block ss1. append t_itab. name(10) type c. *START THE SELECTION SCREEN BLOCK selection-screen begin of block ss1 with frame. end of t_itab. REFRESH field_tab. * INTERNAL TABLE FOR STORING NAMES IN SELECTION LIST data: begin of t_itab occurs 0. *FIELDNAME AND TAB NAME FOR THE SELECTION DATA :field_tab LIKE dfies OCCURS 0 WITH HEADER LINE. t_itab-name = 'Andrews'.

* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. 2. * Apart from the FM DSYS_SHOW_FOR_F1HELP.RETURN_TAB = return_tab DYNPFLD_MAPPING = EXCEPTIONS PARAMETER_ERROR = 1 NO_VALUES_FOUND = 2 OTHERS = 3 . IF sy-subrc <> 0. HELP_OBJECT_SHOW_FOR_FIELD HELP_OBJECT_SHOW Here is the output . MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. p_name1 = return_tab-fieldval. *&---------------------------------------------------------------------* *& * *& F1 Help for p_name1 * *&---------------------------------------------------------------------* at selection-screen on help-request for p_name1. ENDIF. else. IF sy-subrc <> 0. CALL FUNCTION 'DSYS_SHOW_FOR_F1HELP' EXPORTING * APPLICATION = 'SO70' dokclass = 'TX' DOKLANGU = SY-LANGU dokname = 'Z_GAURAB_DEMO' * DOKTITLE = 'This appears as bold title' * HOMETEXT = ' ' * OUTLINE = ' ' * VIEWNAME = 'STANDARD' * Z_ORIGINAL_OUTLINE = ' ' * CALLED_FROM_SO70 = ' ' * SHORT_TEXT = ' ' * APPENDIX = ' ' * IMPORTING * APPL = * PF03 = * PF15 = * PF12 = EXCEPTIONS CLASS_UNKNOWN = 1 OBJECT_NOT_FOUND = 2 OTHERS = 3 . ENDIF.following FM‟s can also be used: 1.

)  IMPORTING AMOUNT TYPE DMBTR  RETURNING NEW_BALANCE TYPE DMBTR  EXCEPTIONS INSUFFICIENT_FUNDS  Activate all elements of your class. Then write a program to use this class. where xx is the last two digits of your logon ID.Object oriented programming (OOP) explained with an example By Gaurab Banerji Create a class that keeps track of a bank account balance. "Extra Credit": If you have extra time. (Use the exception to detect this. printing the new balance each time. Create the following PUBLIC methods: o SET_BALANCE (Sets the balance to a new value)  IMPORTING NEW_BALANCE TYPE DMBTR o DEPOSIT (Adds a deposit amount to the balance and returns the new balance)  IMPORTING AMOUNT TYPE DMBTR  RETURNING NEW_BALANCE TYPE DMBTR o WITHDRAW (Subtracts a deposit amount from the balance and returns the new balance. try any of the following: . Do not allow the balance to become less than zero. where xx is the last two digits of your logon ID. This program should do the following: o Instantiate an instance of the Account class. Create a class called ZACCOUNTxx.)  Test and debug your program. Declare a PRIVATE attribute BALANCE of type DMBTR to store the account balance. o Set the account balance to some initial value. Steps involved:     Run the class builder utility (SE24). o Make several deposits and withdrawals.  Write a program called Z_USE_ACCOUNT_xx.

Step-by-step approach with screen-shots Go to SE24 (Class builder) Type in ZACCOUNTAA as the name of the class and press Create. Place the mouse cursor in DEPOSIT and hit the Parameters button. Similarly for SET_BALANCE . SET_BALANCE and WITHDRAW. Create a static attribute and methods to set and get the name of the bank that holds the accounts. Pass the opening balance when you instantiate the account object. Write the parameters imported / exported for DEPOSIT method.  Replace the SET_BALANCE method with a constructor. Define 3 methods DEPOSIT.

Now we IMPLEMENT the 3 methods. Double click the method DEPOSIT. We can see the attributes and methods by pressing “Display object list” button on top. .And WITHDRAW For withdraw we define an exception.

Write the required code. Similarly for SET_BALANCE Similarly for WITHDRAW. .

Now click DEPOSIT.Now we are almost done creating the object. Click SET_BALANCE. . Write the NEW_BALANCE and press ENTER. We will see this in the status Now we are done building the global class we can test it. We see the return Values now. Press CTRL + F3 to activate or hit the Matchstick. Press F8. We come back to Initial Screen.

. We get an exception.Now let‟s WITHDRAW 4000 Now the BALANCE is 2000 Lets try withdrawing 3000 now.

REPORT ZGB_OOPS_BANK DATA: acct1 type ref to zaccountaa. DATA: bal type i. start-of-selection. acct1->set_balance( p_amnt ). p_wdrw ).Given below is an example code for using the global class we defined. dmbtr. This is the output. bal. p_dpst . create object: acct1. . selection-screen parameters: begin p_amnt p_dpst p_wdrw of type type type block a. Calling an RFC function module from one system to another By Gaurab Banerji Following are the participant system for our demo purpose: D05 – System where RFC function module exists DS3 – Calling system (an RFC call is made from this system to D05) Scenario: . p_dpst ).' bucks making balance to '. bal = acct1->deposit( write:/ 'Deposited '.' bucks making balance to '. call method write:/ 'Set balance to '. bal = acct1->withdraw( write:/ 'Withdrew '. p_wdrw . selection-screen end of block a. dmbtr. dmbtr. p_amnt. bal.

if doesn‟t exists. We would pass two variables from DS3 to D05 and get back the sum of those two variables back to DS3. Under Utilities > Create Function Group (say ZGB_FUNC). define the following variables Under EXPORT Tab . which would add two variables. Activities to be performed in the system D05 Go to SE37. Now create a New Function Module ZGB_FUNC01 Under IMPORT Tab.We would develop a small RFC function module in D05 system.

In the Source Code Now set the function module as “Remote-enabled module” in the attributes tab. .

enter the system details In The Logon/Security Tab. Click on Save. Enter the RFC Destination name: D05-205-TEST Connection Type: 3 In Description: Test Connection to D05 In The Technical Settings Tab. Press Create.Activities to be performed in the System DS3 Create an RFC destination from DS3 to D05. enter the logon details. A Popup will imply that connection has been created Now Press the TEST CONNECTION to check the connection. . Go to SM59.

Press the REMOTE LOGON button If we can see this And this Then our connection was successful. For that we have to test REMOTE LOGON. However if we see the screen as shown below then there is an authentication failure (user-id or password is wrong).This means the connection to the remote system was successful. If the connection fails we get an error like this However establishing a connection will not ensure logging on to the target system. .

which would trigger the RFC in D05 system.The new connection will become visible in the SM59 list like this. let us create a program. Go to SE38 and create a program ZGB_RFC Write the following code . After establishing the connection.

Activate (Ctrl+F3) and Execute (F8) Type any two numbers. Press (F8) Again. . We have the desired output.

Following is the screenshot from the transaction MM02. We can achieve this functionality by using the Function Module „CREATE_TEXT‟.. Please note that if the long text already exists. then it is overwritten in this case. T_LINE LIKE TLINE OCCURS 0 WITH HEADER DATA: Material number Identification Long text LINE. MATNR LIKE MARA-MATNR.. *Internal table to hold long text. inspection text. Inspection text.. REPORT ZMM_INSERT_LONGTEXT. *Internal table to hold long text. " END OF T_UPLOAD.. DATA: BEGIN OF T_UPLOAD OCCURS 0. internal comment). .Uploading Material Master Long Text (Basic data text. Internal comment) By Teja This program could be used to upload the material master long text (Basic data text. " ID(2) TYPE C.. " LTEXT LIKE TLINE-TDLINE.

" create_text *&---------------------------------------------------------------------* *& Form upload_file *&---------------------------------------------------------------------* * This routine is used to upload file *----------------------------------------------------------------------* * No interface parameters are passed *----------------------------------------------------------------------* FORM UPLOAD_FILE . MOVE : P_C_GRUN TO L_ID. " To hold object id LV_VALUE(70). L_NAME(70). IF SY-SUBRC <> 0. P_LV_VALUE TO L_NAME. DATA: L_ID LIKE THEAD-TDID. CALL FUNCTION 'UPLOAD' EXPORTING * CODEPAGE = ' ' * FILENAME = ' ' . CALL FUNCTION 'CREATE_TEXT' EXPORTING FID = L_ID FLANGUAGE = SY-LANGU FNAME = L_NAME FOBJECT = W_OBJECT * SAVE_DIRECT = 'X' * FFORMAT = '*' TABLES FLINES = T_LINE EXCEPTIONS NO_INIT = 1 NO_SAVE = 2 OTHERS = 3 . " To hold id W_OBJECT LIKE THEAD-TDOBJECT VALUE 'MATERIAL'. ENDIF.W_GRUN LIKE THEAD-TDID . CLEAR LV_VALUE. *&---------------------------------------------------------------------* *& Form create_text *&---------------------------------------------------------------------* * This routine used to create text in MM02 transaction *----------------------------------------------------------------------* * Passed the parameter w_grun to P_C_GRUN * and lv_value to P_LV_VALUE *----------------------------------------------------------------------* FORM CREATE_TEXT USING P_C_GRUN P_LV_VALUE. * This perform is used to upload the file PERFORM UPLOAD_FILE. * This perform is used to place the text in MM02 transaction PERFORM PLACE_LONGTEXT. " Value to hold material number START-OF-SELECTION. ENDFORM. ELSE. DELETE T_LINE INDEX 1.

ENDIF. APPEND T_LINE. MOVE 'PRUE' TO W_GRUN. T_LINE-TDFORMAT = 'ST'. IF T_UPLOAD-ID EQ 'BT'. MOVE 'GRUN' TO W_GRUN. "Test ID for Inspection text PERFORM CREATE_TEXT USING W_GRUN LV_VALUE. T_LINE-TDLINE = T_UPLOAD-LTEXT. SORT T_UPLOAD BY MATNR ID. MOVE T_UPLOAD-MATNR TO LV_VALUE. * * * * * * * * * * * * * * * . "Test ID for Basic data text PERFORM CREATE_TEXT USING W_GRUN LV_VALUE. IF T_UPLOAD-ID EQ 'IT'. ENDIF. CLEAR W_GRUN. ENDIF. ENDFORM.FILETYPE = 'DAT' ITEM = ' ' FILEMASK_MASK = ' ' FILEMASK_TEXT = ' ' FILETYPE_NO_CHANGE = ' ' FILEMASK_ALL = ' ' FILETYPE_NO_SHOW = ' ' LINE_EXIT = ' ' USER_FORM = ' ' USER_PROG = ' ' SILENT = 'S' IMPORTING FILESIZE = CANCEL = ACT_FILENAME = ACT_FILETYPE = TABLES DATA_TAB = T_UPLOAD EXCEPTIONS CONVERSION_ERROR = 1 INVALID_TABLE_WIDTH = 2 INVALID_TYPE = 3 NO_BATCH = 4 UNKNOWN_ERROR = 5 GUI_REFUSE_FILETRANSFER = 6 OTHERS = 7 . LOOP AT T_UPLOAD. MOVE T_UPLOAD-MATNR TO LV_VALUE. " upload_file *&---------------------------------------------------------------------* *& Form place_longtext *&---------------------------------------------------------------------* * This routine places the text in MM02 transaction *----------------------------------------------------------------------* * No interface parameters are passed *----------------------------------------------------------------------* FORM PLACE_LONGTEXT . IF SY-SUBRC <> 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

" place_longtext ID for Internal System Debugging By Selvamani Consider the following program. ENDLOOP. CLEAR W_GRUN. Set a breakpoint at the CALL FUNCTION statement and now execute the program. 'IVER' TO W_GRUN. which contains a simple call to the function module ICON_SHOW. ENDIF. . ENDFORM.IF T_UPLOAD-ID EQ 'IC'. MOVE : T_UPLOAD-MATNR TO LV_VALUE. "Test comment PERFORM CREATE_TEXT USING W_GRUN LV_VALUE.

by selecting Settings  system debugging.Ensure that the system debugging is switched off. the function module is executed and the following pop-up is shown: . instead of going into the code of the function module. On pressing F5.

Now again select Goto  Attributes . Reason? Now go to the function module ICON_SHOW.Select a record and press CONTINUE. the program is executed without going into the debug mode of the function module. Select Goto  Main Program.

it is understood that the program status is „S‟ (System program).From the above screenshot. we should be able to debug the function module. Now repeat the above debugging by setting system debugging ON. . This time. In order to debug the system program. we need to set the system debugging ON.

This time. Set the debug point at the CALL FUNCTION statement. the debug point will not even reach the CALL FUNCTION statement.Can we set the custom programs as system programs? Go to our program which has a call to the function module ICON_SHOW. Once you turn the system debugging ON. Now try debugging the program with system debugging off. . Go to program attributes and set the status to System Program. both our program and the standard function module could be debugged.

exceptions in a function module are handled by means of RAISE EXCEPTION. For eg. a material is moved from one plant to another. .. except for:  If the call to the function module does not handle EXCEPTIONS. But the calling program would never know the material number that caused this error. So in our case. because of this mismatch the PO would not be created. The calling program would have the message details in the standard message variables SY-MSGID. Now during the PO creation. the calling program would have the information about the material and plant combination that triggered the exception. we would use the following statement: MESSAGE E309(06) with „xxx‟ Raising XXXX. The import parameter for this function module is Purchase Requisition number and the export parameter is the Purchase Order number created here.MESSAGE xxxx RAISING xxxx By Suresh Kumar Parvathaneni In general. which would create a purchase order with reference to a Purchase Requisition. we generally use RAISE EXCEPTION XXXX. instead of raising the exception using RAISE EXCEPTION. This sets a return code which is passed back to the calling program. if there is any mismatch. Now. This would stop the function module from further processing and returns to the calling program with just the return code. then no message is issued. Using the above statement is similar to the usage of RAISE EXCEPTION. In a normal case. let us consider an example of a function module SXXXX. Assume that after a PR is created. then the message is issued (in this case the error message is issued)  If the calling program handles the exception. SY-MSGV1 and others.

The transaction is then started using this internal table as the input and executed in the background. Typically the input comes in the form of a flat file. In Call Transaction. For this reason. But the only difference is. DI programs are not available for all application areas. LSMW mapping is done by SAP while in BDC we have to do it explicitly . BDC works on the principle of simulating user input for transactional screen. scheduled and processed (using Transaction SM35) at a later time. DI programs are much faster (RMDATIND . . LSMW offers different techinque for migrating data: Direct input . LSMW is an encapsulated data transfer tool. It can provide the same functionality as BDC infact much more but when coming to techinical perspective most the parameters are encapulated. It can also be used for real-time interfaces and custom error handling & logging features.Differences between LSMW and BDC Batch Data Communication (BDC) is the oldest batch interfacing technique that SAP provided since the early versions of R/3. While bdc basically uses recording. Batch Input (BI) programs still use the classical BDC approach but doesnt require an ABAP program to be written to format the BDCDATA. The ABAP program reads this file and formats the input data screen by screen into an internal table (BDCDATA). The latter technique has a built-in error processing mechanism too. Direct Input (DI) programs work exactly similar to BI programs. the transactions are triggered at the time of processing itself and so the ABAP program must do the error handling. Whereas in Batch Input Sessions. BDC is not a typical integration tool. To listout some of the differences :    LSMW is basicaly designed for a fuctional consultant who do not do much coding but need to explore the fuctionality while BDC is designed for a technical consultant.Material Master DI program works at least 5 times faster) than the BDC counterpart and so ideally suited for loading large volume data.BAPI. it can be only be used for uploading data into R/3 and so it is not bi-directional. via an ABAP program. the ABAP program creates a session with all the transactional data.Batch input recording. The user has to format the data using predefined structures and store it in a flat file. and this session can be viewed.Idoc. in the sense that. The BI program then reads this and invokes the transaction mentioned in the header record of the file. instead of processing screens they validate fields and directly load the data into tables using standard function modules.

ENDFORM. which are not used statically... ENDFORM. ENDIF. Use program --> check --> extended program to check for the variables. FORM sub1. Usage of IF statements When coding IF tests. ENDIF. 3. For example: This is better: IF f1 NE 0. nest the testing conditions so that the outer conditions are .  LSMW is basically for standard SAP application while bdc basically for customized application. 2. Either comment out or delete the unused situation... IF f1 NE 0. FORM sub1. the decision of whether or not to execute a subroutine should be made before the subroutine is called. Than this: PERFORM sub1. Unused/Dead code Avoid leaving unused code in the program. . Coding can be done flexibly in BDC when compared to LSMW ABAP Performance Standards Following are the performance standards need to be following in writing ABAP programs: 1. . Subroutine Usage For good modularization. PERFORM sub1.

ENDIF. place the mostly likely false first and for the OR.. Example . one can use either the nested IF or the CASE statement..AND: IF (least likely to be true) AND (most likely to be true). The CASE is better for two reasons. CASE vs.IF. it is more efficient to MOVE a TO b than to MOVE-CORRESPONDING a TO b. ELSEIF (less likely to be true).ENDIF : IF (most likely to be true).those which are most likely to fail. ENDIF. ENDIF.. 5. IF (most likely to be true). For logical expressions with AND . ENDIF. . ELSEIF (least likely to be true).nested IF's: IF (least likely to be true). nested Ifs When testing fields "equal to" something.OR: IF (most likely to be true) OR (least likely to be true). place the mostly likely true first. Example ..ELSEIF. Example . 4. ENDIF. Example . IF (less likely to be true). It is easier to read and after about five nested IFs the performance of the CASE is more efficient. MOVE statements When records a and b have the exact same structure.

. BINARY SEARCH in place of the SELECT SINGLE command. study the key and always provide as much of the leftmost part of the key as possible. you should: o SORT the table . 7. is better than MOVE-CORRESPONDING BSEG TO *BSEG. While it may be convenient to declare an internal table using the LIKE command. you should do the following to improve performance: o o o Use the SELECT into <itab> to buffer the necessary rows in an internal table. 6. complete internal tables In general it is better to minimize the number of fields declared in an internal table. code a SELECT SINGLE not just a SELECT. READing single records of internal tables When reading a single record in an internal table. Use this: data: begin of t_mara occurs 0. the READ TABLE WITH KEY is not a direct READ. If the entire key can be qualified. Small internal tables vs. using SELECT SINGLE can increase performance by up to three times. Note that this only make sense when the table you are buffering is not too large (this decision must be made on a case by case basis). programs will not use all fields in the SAP standard table. in most cases. 8... SELECT and SELECT SINGLE When using the SELECT statement. when calling multiple SELECTSINGLE commands on a non-buffered table (check Data Dictionary -> Technical Info). For example: Instead of this: data: t_mara like mara occurs 0 with header line. 9.MOVE BSEG TO *BSEG. If you are only interested in the first row or there is only one row to be returned. then sort the rows by the key fields. then use a READ TABLE WITH KEY . Row-level processing and SELECT SINGLE Similar to the processing of a SELECT-ENDSELECT loop. This means that if the data is not sorted according to the key. . Therefore. matnr like mara-matnr. end of t_mara.. the system must sequentially read the table.

Number of entries in an internal table To find out how many entries are in an internal table use DESCRIBE. specify the fields to SORTed. then the following example of using an internal table in a nested SELECT can also improve performance by a factor of 5x: Use this: form select_good. is more efficient than LOOP AT ITAB. 12. Performance diagnosis To diagnose performance problems. If nested SELECTs must be used As mentioned previously. data: t_vbap like vbap occurs 0 with header line. 10. Hence. it is recommended to use the SAP transaction SE30. select * from vbak into table t_vbak up to 200 rows. if this is not possible. . ENDLOOP. 11. ABAP/4 Runtime Analysis. performance can be dramatically improved by using views instead of nested SELECTs. A nested SELECT loop may be used to accomplish the same concept. SORT ITAB BY FLD1 FLD2.. or code the select using a join. 13. CNTLNS = CNTLNS + 1. 14. is more efficient than SORT ITAB. select * from vbap for all entries in t_vbak where vbeln = t_vbak-vbeln. data: t_vbak like vbak occurs 0 with header line. however. endselect. . OPEN SQL allows both inner and outer table joins.o use READ TABLE WITH KEY BINARY SEARCH for better performance.. you should either create a view in the data dictionary then use this view to select data. SORTing internal tables When SORTing internal tables. The utility allows statistical analysis of transactions and programs. to improve performance by a factor of 25x and reduce network load.0. the performance of nested SELECT loops is very poor in comparison to a join. However. DESCRIBE TABLE ITAB LINES CNTLNS. Nested SELECTs versus table views Since releASE 4.

select * from vbak up to 200 rows. use a SELECT statement specifying a list of fields instead of a SELECT * to reduce network traffic and improve performance. endform. the field list of the inner SELECT must be designed to ensure the retrieved records will contain no duplicates (normally. FROM <database table> FOR ALL ENTRIES IN TABLE <itab>" and the internal table <itab> is empty. Instead of using: select * from vbak where . if you were able to code "SELECT .... if the internal table supplying the selection criteria (i.FOR ALL ENTRIES IN. select * from vbap where vbeln = vbak-vbeln. but many SAP tables contain more than 50 fields when the program needs only a few. you should be aware of the three pitfalls of using it: Firstly.e. SELECT * versus SELECTing individual fields In general." is generally very fast. endselect... 16. For tables with only a few fields the improvements may be minor. .. Thirdly.. this would mean including in the list of retrieved fields all of those fields that comprise that table's primary key).. endselect. Instead of: <tab> = <tab_wa>. vbak-vbtyp) where . then all rows from <database table> will be retrieved. . internal table <itab> in the example ". For example: Use: append <tab_wa> to <tab>.. 15.. Instead of this: form select_bad. Therefore. if you wish to ensure that no qualifying records are discarded.. SAP automatically removes any duplicates from the rest of the retrieved records. vbak-auart. For example: Use: select vbeln auart vbtyp from table vbak into (vbak-vbeln.FOR ALL ENTRIES IN TABLE <itab> ") contains a large number of entries. Secondly. In the latter case. performance degradation may occur. the performace gains can be substantial..endform.. Although using "SELECT.. Avoid unnecessary statements There are a few cases where one command is better than two.

This file must contain header with fields names corresponding to the DDIC (fields names must be comma separated too).append <tab> (modify <tab>). Create/Modify/Delete records in any table from CSV file By Pavan Allows to create. Copying or appending internal tables Use this: <tab2>[] = <tab1>[]. No other format than CSV is allowed. (if <tab2> is empty) Instead of this: loop at <tab1>. then use: append lines of <tab1> [from index1] [to index2] to <tab2>. modify or delete records based on data coming from a CSV file. is_dd03p TYPE dd03p. if <line_counter> > 0. DATA: it_file TYPE REF TO data. Some system fields can be updated too. append <tab1> to <tab2>. 17. is_rdata TYPE text1024. However. endloop. Test run uses a true MODIFY / DELETE statement but is followed by a Rollback. concatenate 'Error: table' p_table . if <tab2> is not empty and should not be overwritten. And also. DATA: w_error TYPE text132. DATA: it_fields TYPE TABLE OF fieldname. A check is done on field names to be sure every key field is present in source file. * Data DATA: it_dd03p TYPE TABLE OF dd03p. DATA: it_rdata TYPE TABLE OF text1024. Instead of: describe table <tab> lines <line_counter>. use: if not <tab>[] is initial. is_file TYPE REF TO data. * Macros DEFINE write_error. REPORT csv_upload LINE-SIZE 255.

* At selection screen AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.' OBLIGATORY. p_save RADIOBUTTON GROUP g1. SELECTION-SCREEN: SKIP. IF sy-ucomm = 'RG1'. PARAMETERS: p_table TYPE tabname OBLIGATORY MEMORY ID dtb MATCHCODE OBJECT dd_dbtb_16. END-OF-DEFINITION. condense w_error. p_separ TYPE c DEFAULT '. SKIP. SELECTION-SCREEN: END OF BLOCK b03. p_dele RADIOBUTTON GROUP g1. <data> TYPE ANY. PARAMETERS: p_create TYPE c AS CHECKBOX. p_list TYPE c AS CHECKBOX DEFAULT 'X'. SELECTION-SCREEN: BEGIN OF BLOCK b04 WITH FRAME TITLE text-b04. ENDIF. * Selection screen SELECTION-SCREEN: BEGIN OF BLOCK b01 WITH FRAME TITLE text-b01. <fs> TYPE ANY. IF p_nodb IS INITIAL. PARAMETERS: p_test TYPE c AS CHECKBOX. * At selection screen AT SELECTION-SCREEN. PARAMETERS: p_file TYPE localfile DEFAULT 'C:\temp\' OBLIGATORY. SELECTION-SCREEN: BEGIN OF BLOCK b02 WITH FRAME TITLE text-b02. stop.&1 &2 into w_error separated by space. PARAMETERS: p_nodb RADIOBUTTON GROUP g1 DEFAULT 'X' USER-COMMAND rg1. * Field symbols FIELD-SYMBOLS: <table> TYPE STANDARD TABLE. SELECTION-SCREEN: BEGIN OF BLOCK b03 WITH FRAME TITLE text-b03. SELECTION-SCREEN: END OF BLOCK b01. SELECTION-SCREEN: END OF BLOCK b04. CALL FUNCTION 'F4_FILENAME' EXPORTING field_name = 'P_FILE' . write: / w_error. SELECTION-SCREEN: END OF BLOCK b02. ENDIF. p_test = 'X'.

IF p_nodb IS INITIAL. PERFORM f_upload_data USING p_file. * Start of selection START-OF-SELECTION. DATA: l_tname TYPE tabname. PERFORM f_table_definition USING p_table. * End of selection END-OF-SELECTION. IF l_state NE 'A'. CALL FUNCTION 'DDIF_TABL_GET' EXPORTING name = l_tname IMPORTING gotstate = l_state dd02v_wa = l_dd02v TABLES dd03p_tab = it_dd03p EXCEPTIONS illegal_input = 1 OTHERS = 2. PERFORM f_process_data. ENDFORM. ENDIF. l_dd02v TYPE dd02v. . ENDIF. *---------------------------------------------------------------------* * FORM f_table_definition * *---------------------------------------------------------------------* * --> VALUE(IN_TABLE) * *---------------------------------------------------------------------* FORM f_table_definition USING value(in_table). IF p_list = 'X'. write_error 'does not exist or is not active' space.IMPORTING file_name = p_file. PERFORM f_modify_table. PERFORM f_list_records. l_state TYPE ddgotstate. write_error 'is type' l_dd02v-tabclass. ENDIF. ENDIF. IF l_dd02v-tabclass NE 'TRANSP' AND l_dd02v-tabclass NE 'CLUSTER'. l_tname = in_table. PERFORM f_prepare_table USING p_table.

ASSIGN it_file->* TO <table>. DATA: l_missk TYPE c. DATA: l_lengt TYPE i. DATA: l_file TYPE string. CALL FUNCTION 'GUI_UPLOAD' . CALL FUNCTION 'LVC_FIELDCATALOG_MERGE' EXPORTING i_structure_name = l_tname CHANGING ct_fieldcat = lt_ftab EXCEPTIONS OTHERS = 1. lt_ftab TYPE lvc_t_fcat. ENDFORM. WRITE: / 'Error while building field catalog'.*---------------------------------------------------------------------* * FORM f_prepare_table * *---------------------------------------------------------------------* * --> VALUE(IN_TABLE) * *---------------------------------------------------------------------* FORM f_prepare_table USING value(in_table). l_ltext TYPE string. l_file = in_file. CALL METHOD cl_alv_table_create=>create_dynamic_table EXPORTING it_fieldcatalog = lt_ftab IMPORTING ep_table = it_file. l_lengt = strlen( in_file ). WRITE: / 'Reading file'. l_field TYPE fieldname. STOP. FORMAT INTENSIFIED ON. ENDIF. ASSIGN is_file->* TO <data>. CREATE DATA is_file LIKE LINE OF <table>. *---------------------------------------------------------------------* * FORM f_upload_data * *---------------------------------------------------------------------* * --> VALUE(IN_FILE) * *---------------------------------------------------------------------* FORM f_upload_data USING value(in_file). IF sy-subrc NE 0. in_file(l_lengt). DATA: l_tname TYPE tabname. l_tname = in_table.

* Log other fields SKIP. * File not empty DESCRIBE TABLE it_rdata LINES sy-tmaxl. SPLIT l_ltext AT p_separ INTO l_field l_ltext. IF sy-subrc = 0. l_ltext = is_rdata. l_file. 'is empty'. WRITE: /3 'File'. FORMAT RESET. ENDIF. IF sy-subrc = 0. * Check all key fields are present SKIP. l_file. FORMAT COLOR COL_NEGATIVE. WRITE: 'error'. ENDIF. WHILE l_ltext CS p_separ. ENDIF. APPEND l_field TO it_fields. WRITE: /3 'Key fields'. l_missk = 'X'. FORMAT COLOR COL_POSITIVE. READ TABLE it_fields WITH KEY table_line = is_dd03p-fieldname TRANSPORTING NO FIELDS. ELSE. ENDIF. WRITE: /3 is_dd03p-fieldname. FORMAT RESET. FORMAT RESET. WRITE: '-'. IF sy-subrc <> 0. sy-tmaxl. WRITE: /3 'Error uploading'. STOP. ENDLOOP. ELSEIF is_dd03p-datatype NE 'CLNT'. . * File header on first row READ TABLE it_rdata INTO is_rdata INDEX 1. FORMAT COLOR COL_HEADING. LOOP AT it_dd03p INTO is_dd03p WHERE NOT keyflag IS initial. FORMAT RESET. WRITE: 'ok'. 'rows read'. l_field = l_ltext. ENDWHILE. IF sy-tmaxl = 0. STOP.EXPORTING filename = l_file filetype = 'ASC' TABLES data_tab = it_rdata EXCEPTIONS OTHERS = 1. APPEND l_field TO it_fields.

l_ltext = is_rdata.'.FORMAT COLOR COL_HEADING. * Missing key field IF l_missk = 'X'. STOP. ENDIF. IF sy-subrc = 0. * Field value comes from file. SPLIT l_ltext AT p_separ INTO l_stext l_ltext. WRITE l_stext TO <fs> RIGHT-JUSTIFIED. LOOP AT it_rdata INTO is_rdata FROM 2. LOOP AT it_fields INTO l_field. LOOP AT it_dd03p INTO is_dd03p WHERE keyflag IS initial. WRITE: /3 'Other fields'. CASE l_datat. TRANSLATE l_stext USING '. OVERLAY <fs> WITH '0000000000000000'. *---------------------------------------------------------------------* * FORM f_process_data * *---------------------------------------------------------------------* FORM f_process_data. l_datat TYPE c. SPLIT l_ltext AT p_separ INTO l_stext l_ltext. SPLIT l_ltext AT p_separ INTO l_stext l_ltext. DATA: l_ltext TYPE string. ENDLOOP. l_stext TYPE text40. ENDFORM. WRITE: 'X'. FORMAT RESET. <fs> = l_stext. CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL' EXPORTING date_external = l_stext .. <fs> = l_stext. TRANSLATE l_stext USING '/. WRITE: /3 'Missing key fields . ASSIGN COMPONENT l_field OF STRUCTURE <data> TO <fs>. ENDIF. WHEN 'F'. determine conversion DESCRIBE FIELD <fs> TYPE l_datat. TRANSLATE l_stext USING '.-.'. SPLIT l_ltext AT p_separ INTO l_stext l_ltext. IF sy-subrc = 0. "max 16 WHEN 'P'. READ TABLE it_fields WITH KEY table_line = is_dd03p-fieldname TRANSPORTING NO FIELDS. l_field TYPE fieldname..no further processing'. WRITE: /3 is_dd03p-fieldname.'. WHEN 'N'. WHEN 'D'. SKIP.

IF is_dd03p-rollname = 'AEDAT'. ASSIGN COMPONENT is_dd03p-fieldname OF STRUCTURE <data> TO <fs>. ASSIGN COMPONENT is_dd03p-fieldname OF STRUCTURE <data> TO <fs>. ELSE. SHIFT l_ltext. ASSIGN COMPONENT is_dd03p-fieldname OF STRUCTURE <data> TO <fs>. ASSIGN COMPONENT is_dd03p-fieldname OF STRUCTURE <data> TO <fs>. ENDLOOP. ENDIF. ENDIF. SPLIT l_ltext AT p_separ INTO <fs> l_ltext. <fs> = sy-mandt. IF is_dd03p-rollname = 'ERZET'. WHEN OTHERS. ENDLOOP. . LOOP AT it_dd03p INTO is_dd03p WHERE datatype = 'CLNT'.IMPORTING date_internal = <fs> EXCEPTIONS OTHERS = 1. CALL FUNCTION 'CONVERT_TIME_INPUT' EXPORTING input = l_stext IMPORTING output = <fs> EXCEPTIONS OTHERS = 1. ASSIGN COMPONENT is_dd03p-fieldname OF STRUCTURE <data> TO <fs>. ENDIF. ENDIF. ENDIF. ENDIF. IF NOT <data> IS INITIAL. <fs> = sy-uzeit. IF is_dd03p-rollname = 'AETIM'. <fs> = sy-uzeit. IF is_dd03p-rollname = 'AENAM'. <fs> = sy-uname. SHIFT l_ltext UP TO p_separ. ENDCASE. <fs> = sy-datum. ENDIF. WHEN 'T'. <fs> = sy-datum. ASSIGN COMPONENT is_dd03p-fieldname OF STRUCTURE <data> TO <fs>. IF p_create = 'X'. IF is_dd03p-rollname = 'ERNAM'. * This field is mandant ASSIGN COMPONENT is_dd03p-fieldname OF STRUCTURE <data> TO <fs>. IF is_dd03p-rollname = 'ERDAT'.

ENDIF. WRITE: '. IF sy-subrc EQ 0. DELETE (p_table) FROM TABLE <table>. *---------------------------------------------------------------------* * FORM f_modify_table * *---------------------------------------------------------------------* FORM f_modify_table. l_lasti TYPE i. ENDIF. ENDIF. l_offst TYPE i. MODIFY (p_table) FROM TABLE <table>. ENDIF. IF l_tleng LT sy-linsz. ROLLBACK WORK. ENDFORM. ELSE. SKIP. FORMAT COLOR COL_NEGATIVE. ENDLOOP. ENDFORM. IF p_test IS INITIAL. APPEND <data> TO <table>. ENDIF.test only. IF p_save = 'X'.<fs> = sy-uname. WRITE: /3 'Error while modifying table'. FORMAT COLOR COL_POSITIVE. DATA: l_tleng TYPE i. . ELSE. l_tleng = l_tleng + is_dd03p-outputlen. COMMIT WORK. ELSE. *---------------------------------------------------------------------* * FORM f_list_records * *---------------------------------------------------------------------* FORM f_list_records. IF p_save = 'X'. * Output width l_tleng = 1. WRITE: /3 'Modify table OK'. WRITE: /3 'Delete table OK'. ELSE. no update'. ENDIF. l_lasti = sy-tabix. FORMAT RESET. FORMAT RESET. EXIT. ELSEIF p_dele = 'X'. LOOP AT it_dd03p INTO is_dd03p.

ENDFORM. IF is_dd03p-decimals LE 2. Go to transaction SNRO (Simple way to remember is SapNumberRangeObject). ENDLOOP. ENDLOOP. ASSIGN COMPONENT is_dd03p-fieldname OF STRUCTURE <data> TO <fs>. l_offst = 3. EXIT. l_tleng = l_tleng . WRITE: AT l_offst sy-vline. WRITE: /3 'Contents'. l_offst = l_offst + 1. * Output records LOOP AT <table> ASSIGNING <data>. IF is_dd03p-position = 1. WRITE: AT l_offst <fs>. * Output header SKIP. ENDLOOP. ELSE.l_tleng = l_tleng + 1. ENDIF. * Output end ULINE AT /3(l_tleng). l_offst = l_offst + is_dd03p-outputlen. . WRITE: AT l_offst <fs> DECIMALS 3. WRITE: /3 sy-vline. ENDIF. LOOP AT it_dd03p INTO is_dd03p FROM 1 TO l_lasti.is_dd03p-outputlen. FORMAT COLOR COL_HEADING. ULINE AT /3(l_tleng). FORMAT RESET. ENDIF. ELSE. Number Range Object By Suresh Kumar Parvathaneni Creation of a Number range object: 1.

Long text and Number Length domain andWarning % as shown below: . Enter the number range object name and press CREATE. 3.2. Enter the description.

enter 10 (%) here.Warning%  Assume that an interval is defined from 1 to 1000. 4. Press SAVE. If you want to issue a warning at the number 900. You would get a prompt as shown below: .

7.5. . Click on “Change Intervals”. Press YES and assign the object to a local class. 6. Now click on “Number Ranges” button on the application toolbar.

9. Click on “Insert Interval”.8. Enter the values as shown below: .

DATA: NUMBER TYPE I.10. NUMBER_GET_NEXT. Testing the Number Range Object: We can use the function module. Following is a test program to get the next available number of the object created above: REPORT zsnro_test. The number range object is generated. CALL FUNCTION 'NUMBER_GET_NEXT' EXPORTING nr_range_nr = '01' object = 'ZDEMO' IMPORTING NUMBER = NUMBER EXCEPTIONS INTERVAL_NOT_FOUND = 1 NUMBER_RANGE_NOT_INTERN = 2 OBJECT_NOT_FOUND = 3 QUANTITY_IS_0 = 4 QUANTITY_IS_NOT_1 = 5 INTERVAL_OVERFLOW = 6 BUFFER_OVERFLOW = 7 OTHERS = 8 . Click “Insert” and then SAVE. to get the next number of any number range object. MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO . IF sy-subrc <> 0.

w_grid TYPE REF TO cl_gui_alv_grid. In technical terms Internal table is a dynamic sequential dataset in which all records have the same data structure and a key.WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. Creating Dynamic internal table PARAMETERS : p_table(10) TYPE C. . CREATE DATA w_dref TYPE TABLE OF (w_tabname). used when the number of fields is not known at the design time or until the compile time. w_tabname = p_table. entire database table or view into an internal table. ABAPTM Open SQL allows single field. w_dref TYPE REF TO data. Write :/ 'Next available number is: '. when the structure of the internal table is fixed and known to the user. FIELD-SYMBOLS: <t_itab> TYPE ANY TABLE. Dynamic internal table is an extension to internal table concept. Dynamic Internal Table By Vijayanand Poreddy This Tutorial details about creation of dynamic internal table with different scenarios Internal Tables are local tables within a program containing a series of lines having same data type. DATA: w_tabname TYPE w_tabname. A static internal table can be declared in an ABAPTM program initially. ASSIGN w_dref->* TO <t_itab>. Number. Scenario 1: Display the table of contents in grid format using the dynamic internal table. ENDIF. range of fields.

t_newline TYPE REF TO data.Populating Dynamic internal table SELECT * FROM (w_tabname) UP TO 20 ROWS INTO TABLE <t_itab>. Displaying dynamic internal table using Grid. CREATE OBJECT w_grid EXPORTING i_parent = cl_gui_container=>screen0. Scenario 2: Create a dynamic internal table with the specified number of columns. CALL SCREEN 100. Creating Dynamic internal table TYPE-POOLS: slis. <fs_fldval> type any. FIELD-SYMBOLS: <t_dyntable> TYPE STANDARD TABLE. DATA: t_newtable TYPE REF TO data. “ Field symbol to create work area “ Field symbol to assign values “ Input number of columns . “ Dynamic internal table name <fs_dyntable>. CALL METHOD w_grid->set_table_for_first_display EXPORTING i_structure_name = w_tabname CHANGING it_outtab = <t_itab>. PARAMETERS: p_cols(5) TYPE c.

t_fldcat TYPE lvc_t_fcat. DO p_cols TIMES. . wa_it_fldcat-datatype = 'CHAR'. wa_it_fldcat TYPE lvc_s_fcat. * Create dynamic internal table and assign to FS CALL METHOD cl_alv_table_create=>create_dynamic_table EXPORTING it_fieldcatalog = t_fldcat IMPORTING ep_table = t_newtable. ENDDO. APPEND wa_it_fldcat TO t_fldcat. move sy-index to wa_colno. wa_it_fldcat-fieldname = wa_flname. wa_flname(5) TYPE c.t_fldcat TYPE slis_t_fldcat_alv. * Create fields . wa_colno(2) TYPE n. wa_it_fldcat-intlen = 10. concatenate 'COL' wa_colno into wa_flname. CLEAR wa_it_fldcat.

ASSIGN COMPONENT wa_flname OF STRUCTURE <fs_dyntable> TO <fs_fldval>. CONDENSE fieldvalue NO-GAPS. index = sy-index. * Append to the dynamic internal table . Populating Dynamic internal table DATA: fieldname(20) TYPE c. ASSIGN t_newline->* TO <fs_dyntable>.ASSIGN t_newtable->* TO <t_dyntable>. DATA: fieldvalue(10) TYPE c. MOVE sy-index TO wa_colno. CONCATENATE 'COL' wa_colno INTO wa_flname. DATA: index(3) TYPE c. * Create dynamic work area and assign to FS CREATE DATA t_newline LIKE LINE OF <t_dyntable>. DO p_cols TIMES. ENDDO. * Set up fieldvalue CONCATENATE 'VALUE' index INTO fieldvalue. <fs_fldval> = fieldvalue.

Infotype creation Custom Infotype can be created by following these steps: 1. ENDDO. Avoid providing the Infotype number that already exists. DO p_cols TIMES. wa_cat-fieldname = wa_flname.APPEND <fs_dyntable> TO <t_dyntable>. Provide the Infotype number. CLEAR wa_cat. APPEND wa_cat TO fs_fldcat. wa_cat-seltext_s = wa_flname. CONCATENATE 'COL' wa_colno INTO wa_flname. Displaying dynamic internal table using Grid. MOVE sy-index TO wa_colno. * Call ABAP List Viewer (ALV) CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING it_fieldcat = fs_fldcat TABLES t_outtab = <t_dyntable>. Go to transaction PM01. . 2. The number should be from 9000 to 9999. wa_cat-outputlen = '10'. DATA: wa_cat LIKE LINE OF fs_fldcat.

10. Maintain the structure (Provide fields) which will be included in our current custom Infotype. The below shown figure is displayed. This step is useful when we come through the step 11 (Subtype maintenance). Infotype characteristics Push button Technical Attributes Push button 7. See to it that the Employee Infotype and PS structure radio buttons have been selected. 5. Also provide the Time constraint based on the requirement. The PAKEY/PBKEY and PSHD1 structures are not required to be provided while creating the custom Infotype.This step can be skipped if we don‟t want the subtype for an Infotype. 2000 as the single screen and 3000 as the list screen. The below shown screen is displayed. The following below shown screen is displayed.3. All Push button 4. The „Subtype Obligatory‟ check box needs to be selected if we intend to make the subtype as mandatory field.The below shown figure is displayed. The below screen is displayed. They are included in the custom Infotype by default. 9. Save the Infotype details and go back to the initial screen of PM01 transaction. Subtype table as T591A and Subty. Select the change button on application tool bar. Save and go back to the initial PM01 screen. 14. 13. Select the Technical attributes (Figure shown in step 6) from the initial screen of PM01 transaction .text table as T591S. . The dialog module in the above screen then becomes editable. Additional steps If a subtype needs to be maintained for the Infotype then some additional steps also needs to be performed before providing Infotype characteristics (step number 7). Go to the initial screen of PM01 transaction. 11. 12. Select the „Infotype characteristics‟ push button shown in the above figure. 6. 16. Select the „New Entries‟ push button shown in the above figure. Provide the Current custom Infotype number (9002) and description for the Infotype. Display/Change button Details 15. Provide the Subtype field of the Infotype. Save and activate the structure. Select the „All‟ Push button as shown in above figure. New Entries Push button 8. Select the Infotype 9002 and select the details button as shown in the above figure (In change mode).

VBELN TYPE VBAK-VBELN. POSNR TYPE VBAP-POSNR. "Standard header and footer *----------------------------------------------------------------------* * TYPES DECLARATION *----------------------------------------------------------------------* TYPES: BEGIN OF T_CRMEMO. Continue with step 7 as required. BSTNK TYPE VBAK-BSTNK.17. TRDYSE01CM. Automatic Vendor Debit Posting Submitted by Vikram Please note that there are some custom fields added in the VBAP table. ADR6. VKORG TYPE VBAK-VKORG. The subtypes for an Infotype can be entered via the maintenance view V_T591A. WAERK TYPE VBAK-WAERK. VTWEG TYPE VBAK-VTWEG. *---------------------------------------------------------------------* * INCLUDE *---------------------------------------------------------------------* INCLUDE ZZUTI_STD_HEADER_FOOTER. BSARK TYPE VBAK-BSARK. SPART TYPE VBAK-SPART. REPORT ZAUTO_DEBIT_VENDOR NO STANDARD PAGE HEADING LINE-SIZE 250 LINE-COUNT 65(2) MESSAGE-ID ZSCM. ************************************************************************ * Program name : ZAUTO_DEBIT_VENDOR * Type : Report * Description : Automatic Vendor Dedit Postings ************************************************************************ *---------------------------------------------------------------------* * TABLES *---------------------------------------------------------------------* TABLES: VBAK. VDATU TYPE VBAK-VDATU. Unfortunately. ERDAT TYPE VBAK-ERDAT. AUGRU TYPE VBAK-AUGRU. the contributor couldn't provide us with the functional/technical specifications for this program. AUART TYPE VBAK-AUART. . custom message class and custom include program used in this program. 18.

ZIEME TYPE VBAP-ZIEME. VKORG TYPE MVKE-VKORG. BEGIN OF T_EKPO. TXJCD TYPE EKPO-TXJCD. WAERK TYPE VBAK-WAERK. EBELP TYPE EKPO-EBELP. VTWEG TYPE MVKE-VTWEG. BSARK TYPE VBAK-BSARK. MATNR TYPE VBAP-MATNR. END OF T_MVKE. MEINS TYPE EKPO-MEINS. mwskz TYPE EKPO-mwskz. BEGIN OF T_EKBE. BEGIN OF T_MVKE. AUART TYPE VBAK-AUART. SPART TYPE VBAK-SPART. VKORG TYPE VBAK-VKORG. END OF T_EKPO. ZMENG TYPE VBAP-ZMENG. END OF T_CRMEMO_CHANGE. BSTDK TYPE VBAK-BSTDK. BUKRS_VF TYPE VBAK-BUKRS_VF. AEDAT TYPE VBAK-AEDAT. END OF T_ORDERS. BEGIN OF T_ORDERS. BEGIN OF T_CRMEMO_CHANGE. END OF T_CRMEMO. VBELN(90) TYPE C. NETPR TYPE EKPO-NETPR. ZIEME TYPE VBAP-ZIEME. . AUGRU TYPE VBAK-AUGRU. ERDAT TYPE VBAK-ERDAT. EBELN TYPE EKKO-EBELN. VDATU TYPE VBAK-VDATU. PEINH TYPE EKPO-PEINH. MENGE TYPE EKPO-MENGE. VBTYP_N TYPE VBFA-VBTYP_N. ZMENG TYPE VBAP-ZMENG. POSNN TYPE VBFA-POSNN. VBELN TYPE VBFA-VBELN.BSTDK TYPE VBAK-BSTDK. AEDAT TYPE VBAK-AEDAT. VTWEG TYPE VBAK-VTWEG. MATNR TYPE MVKE-MATNR. VBELV TYPE VBFA-VBELV. POSNR TYPE VBAP-POSNR. MTPOS TYPE MVKE-MTPOS. WAERS TYPE EKKO-WAERS. POSNV TYPE VBFA-POSNV. BUKRS_VF TYPE VBAK-BUKRS_VF. BSTNK TYPE VBAK-BSTNK. MATNR TYPE VBAP-MATNR.

GJAHR TYPE RBKP-GJAHR. CDHDR-UDATE. BEGIN OF T_CDPOS. EKBE-EBELP. EKBE-BUZEI. BLDAT TYPE RBKP-BLDAT. OBJECTCLAS TYPE CDHDR-OBJECTCLAS. END OF T_RBKP. XRECH TYPE RBKP-XRECH. BEGIN OF T_RBKP. CDPOS-TABKEY. RMWWR TYPE RBKP-RMWWR. CDHDR-OBJECTID. UTIME TYPE CDHDR-UTIME.EBELN TYPE EBELP TYPE ZEKKN TYPE VGABE TYPE GJAHR TYPE BELNR TYPE BUZEI TYPE END OF T_EKBE. CDHDR-OBJECTCLAS. CDPOS-VALUE_NEW. OBJECTID TYPE CDHDR-OBJECTID. EKBE-ZEKKN. OBJECTCLAS TYPE OBJECTID TYPE CHANGENR TYPE UDATE TYPE UTIME TYPE END OF T_CDHDR. OBJECTCLAS TYPE OBJECTID TYPE CHANGENR TYPE TABNAME TYPE TABKEY TYPE FNAME TYPE CHNGIND TYPE VALUE_NEW TYPE VALUE_OLD TYPE END OF T_CDPOS. . BEGIN OF T_CHANGE_DOCS. CDPOS-CHNGIND. CDPOS-FNAME. CDPOS-TABNAME. CHANGENR TYPE CDHDR-CHANGENR. CDHDR-OBJECTID. FNAME TYPE CDPOS-FNAME. TABKEY TYPE CDPOS-TABKEY. UDATE TYPE CDHDR-UDATE. CDHDR-OBJECTCLAS. CDHDR-UTIME. WMWST1 TYPE RBKP-WMWST1. END OF T_CHANGE_DOCS. BEGIN OF T_CDHDR. BEGIN OF T_SUCCESS. BELNR TYPE RBKP-BELNR. TABNAME TYPE CDPOS-TABNAME. EKBE-EBELN. CDHDR-CHANGENR. XBLNR TYPE RBKP-XBLNR. STBLG TYPE RBKP-STBLG. EKBE-GJAHR. VALUE_OLD TYPE CDPOS-VALUE_OLD. VALUE_NEW TYPE CDPOS-VALUE_NEW. CHNGIND TYPE CDPOS-CHNGIND. EKBE-BELNR. LIFNR TYPE RBKP-LIFNR. CDHDR-CHANGENR. BUDAT TYPE RBKP-BUDAT. EKBE-VGABE. CDPOS-VALUE_OLD.

WA_CMEMO TYPE T_ORDERS. WA_SUCCESS TYPE T_SUCCESS. miro_no TYPE VBAK-vbeln. WA_EKBE TYPE T_EKBE. WA_OBJTXT TYPE SOLISTI1. po TYPE VBAK-vbeln. po TYPE VBAK-vbeln. cmemo TYPE VBAK-vbeln. END OF T_SUCCESS. WA_RECLIST TYPE SOMLRECI1 . WA_CHANGE_DOCS TYPE T_CHANGE_DOCS. orders TYPE VBAK-vbeln. WA_EKBE_TEMP TYPE T_EKBE. WA_MVKE TYPE T_MVKE. WA_ERROR_MR8M TYPE T_ERROR. WA_ORDERS TYPE T_ORDERS.Structure to hold Invoice Header Data x_docheader LIKE bapi_incinv_create_header. *----------------------------------------------------------------------* * WORKAREA DECLARATION *----------------------------------------------------------------------* DATA: WA_CRMEMO TYPE T_CRMEMO. DATA: *-. WA_OBJBIN TYPE SOLISTI1. WA_EKPO TYPE T_EKPO. orders TYPE VBAK-vbeln. miro_no TYPE VBAK-vbeln. WA_CDPOS TYPE T_CDPOS. WA_RBKP_TMP TYPE T_RBKP.Structure to hold Reversal Posting Data x_rev_post LIKE BAPI_INCINV_FLD.crmemo TYPE VBAK-vbeln. *-. WA_CRMEMO_CHANGE TYPE T_CRMEMO_CHANGE. WA_CDHDR TYPE T_CDHDR. WA_RBKP TYPE T_RBKP. cmemo TYPE VBAK-vbeln. WA_ERROR TYPE T_ERROR. END OF T_ERROR. *--Work area for all the internal tables used for Sending Mail DATA : WA_OBJPACK TYPE SOPCKLSTI1. BEGIN OF T_ERROR. crmemo TYPE VBAK-vbeln. WA_PO TYPE T_ORDERS. text(20) TYPE C. WA_CRMEMO_MR8M TYPE T_CRMEMO. WA_OBJHEAD TYPE SOLISTI1. WA_SUCCESS_MR8M TYPE T_SUCCESS. *----------------------------------------------------------------------* * INTERNAL TAABLE DECLARATION . text(100) TYPE C.

DATA:END OF it_accountingdata. " document attributes IT_OBJPACK TYPE STANDARD TABLE OF SOPCKLSTI1. IT_CRMEMO_MR8M TYPE STANDARD TABLE OF T_CRMEMO WITH HEADER LINE. IT_ORDERS TYPE STANDARD TABLE OF T_ORDERS WITH HEADER LINE. DATA:END OF it_itemdata. INCLUDE STRUCTURE bapiret2. IT_EKPO TYPE STANDARD TABLE OF T_EKPO WITH HEADER LINE.Internal table for storing data . IT_ERROR_MR8M TYPE STANDARD TABLE OF T_ERROR WITH HEADER LINE. " binary table IT_OBJTXT TYPE STANDARD TABLE OF SOLISTI1. it_pdf_list TYPE STANDARD TABLE OF TLINE. " mail recipients it_compressed_list TYPE STANDARD TABLE OF SOLI. " object header table IT_OBJBIN TYPE STANDARD TABLE OF SOLISTI1.Internal table to hold BAPI return data DATA: BEGIN OF it_return OCCURS 0. IT_EKBE_TEMP TYPE STANDARD TABLE OF T_EKBE WITH HEADER LINE. *--MAIL related Internal tables DATA: X_DOC_CHNG TYPE SODOCCHGI1. IT_CMEMO TYPE STANDARD TABLE OF T_ORDERS WITH HEADER LINE. " attachment table IT_OBJHEAD TYPE STANDARD TABLE OF SOLISTI1. *-. IT_CRMEMO_CHANGE TYPE STANDARD TABLE OF T_CRMEMO_CHANGE WITH HEADER LINE.Internal table for MIME data (in CHAR format) it_temp TYPE bapiqcmime OCCURS 10 WITH HEADER LINE. DATA: END OF it_return_mr8m. *-. IT_CDHDR TYPE STANDARD TABLE OF T_CDHDR WITH HEADER LINE.Internal table to hold Invoice Acct Assignment Data DATA:BEGIN OF it_ACCOUNTingdata OCCURS 0. " object text IT_RECLIST TYPE STANDARD TABLE OF SOMLRECI1. IT_RBKP TYPE STANDARD TABLE OF T_RBKP WITH HEADER LINE.Internal table to hold BAPI return data DATA: BEGIN OF it_return_mr8m OCCURS 0. IT_CRMEMO_MIRO TYPE STANDARD TABLE OF T_CRMEMO WITH HEADER LINE. IT_MVKE TYPE STANDARD TABLE OF T_MVKE WITH HEADER LINE. IT_CHANGE_DOCS TYPE STANDARD TABLE OF T_CHANGE_DOCS WITH HEADER LINE.Internal table to hold Invoice Item Data DATA:BEGIN OF it_itemdata OCCURS 0. DATA: END OF it_return. IT_EKBE TYPE STANDARD TABLE OF T_EKBE WITH HEADER LINE. *-. IT_ERROR TYPE STANDARD TABLE OF T_ERROR WITH HEADER LINE. IT_SUCCESS TYPE STANDARD TABLE OF T_SUCCESS WITH HEADER LINE. INCLUDE STRUCTURE bapiret2. *-. INCLUDE STRUCTURE bapi_incinv_create_item. IT_PO TYPE STANDARD TABLE OF T_ORDERS WITH HEADER LINE. *-. INCLUDE STRUCTURE BAPI_INCINV_CREATE_ACCOUNT. *-. "Return Parameter. "Return Parameter. IT_CDPOS TYPE STANDARD TABLE OF T_CDPOS WITH HEADER LINE.*----------------------------------------------------------------------* DATA: IT_CRMEMO TYPE STANDARD TABLE OF T_CRMEMO WITH HEADER LINE. it_pdf TYPE tline OCCURS 10 WITH HEADER LINE. IT_SUCCESS_MR8M TYPE STANDARD TABLE OF T_SUCCESS WITH HEADER LINE. it_html TYPE solisti1 OCCURS 10 WITH HEADER LINE.

" Payment Terms v_text(75) TYPE c. " For MIRO Fiscal year v_spono type TSP01-RQIDENT. " For Spool Type V_CRMEMO_QTY TYPE VBAP-ZMENG. V_GROSSAMT TYPE EKPO-NETPR. " To Increment Item No. " For EMail Id text v_lines TYPE i. " For EMail Time V_INFO(100) TYPE C. " To Increment Email Count V_TEXT2 TYPE STRING . " For MR8M Success Records v_tot_e_mr8m TYPE i. " To Convert to 255 char format v_mimelen TYPE i. " To Convert to 255 char format *----------------------------------------------------------------------* * CONSTANTS * *----------------------------------------------------------------------* CONSTANTS: C_X(1) TYPE C VALUE 'X'. v_type type SOODK-OBJTP. " For EMail Body Text V_TABLE_LINES TYPE SY-TABIX. " For MR8M Error Records V_DATE TYPE SY-DATUM. " For EMail Date V_TIME(10) TYPE C. for BAPI v_docnr LIKE bapi_incinv_fld-inv_doc_no. " For Sel. " To Convert to 255 char format v_tabix type sy-tabix. " Flag to process fruther v_tot_s_mr8m TYPE i. " For CR Memo Tax amount v_flag(1) type c. " To Convert to 255 char format v_offset TYPE p. *----------------------------------------------------------------------* * GLOBAL VARIABLES * *----------------------------------------------------------------------* DATA: V_PGM_ID TYPE SY-REPID. " To Convert to 255 char format v_lineslen TYPE i.it_mime(255) TYPE c OCCURS 10 WITH HEADER LINE. " For CR Memo Qty. " Constant X or Flag C_E(1) TYPE C VALUE 'E'. " For MIRO document number v_year1 LIKE bapi_incinv_fld-fisc_year. " Program id v_zterm TYPE lfb1-zterm. " For CR Memo Item Qty. " For Spool No. Screen Date V_DATE2(10) TYPE C. " To Store PDF Lines v_temp(500) TYPE c. " For Error check c_v(1) TYPE C VALUE 'V'. V_LINE_AMOUNT TYPE EKPO-NETPR. " For PO Docs . " For EMail Time V_TIME2(10) TYPE C. v_tax_per(3) type n. " For CR Memo Tax amount % v_tax_amt TYPE EKPO-NETPR. " To store error or success text v_itemno(6) TYPE n. " For CR Memo Grand Qty.

" For Order Docs " For Credit Memo Docs " For CR Memo Docs " For Change tables VALUE 'ALI'. * SELECT-OPTIONS: S_EMAIL FOR TRDYSE01CM-USERNAME * NO INTERVALS MODIF ID US2. " For Change docs table VALUE '01'. *----------------------------------------------------------------------* * WORK AREA for SELECT-OPTIONS *----------------------------------------------------------------------* DATA : X_EMAIL LIKE S_EMAIL. PARAMETERS : P_MODE TYPE SO_ESCAPE default 'U' MODIF ID US1. " Sales Document Type S_AUGRU FOR VBAK-AUGRU OBLIGATORY NO INTERVALS. SELECT-OPTIONS: S_AUART FOR VBAK-AUART OBLIGATORY NO INTERVALS. "Work area for EMAIL select-options *----------------------------------------------------------------------* * INITIALIZATION . " For Reversal Reason 'RE'.c_o(1) c_c(1) c_k(1) c_u(1) Update c_ali(3) c_vbak(4) C_01(2) Reversal Reason C_02(2) c_blart C_MTPOS C_AUGRU(5) C_0000500205(10) C_VERKBELEG(9) TYPE C TYPE C TYPE C TYPE C TYPE C TYPE C TYPE C TYPE TYPE TYPE TYPE TYPE TYPE C bkpf-blart MVKE-MTPOS C C C VALUE 'O'.Horizontal tab & line feed constants CLASS CL_ABAP_CHAR_UTILITIES DEFINITION LOAD. " For Serial No. PARAMETERS:P_EMAIL AS CHECKBOX DEFAULT SPACE USER-COMMAND V_COM . SELECTION-SCREEN: END OF LINE. *----------------------------------------------------------------------* * SELECTION SCREEN *----------------------------------------------------------------------* *-. " Item Category group 'AUGRU'. SELECTION-SCREEN: BEGIN OF LINE. & VALUE VALUE VALUE VALUE VALUE VALUE '02'. " GL Account # 'VERKBELEG'. " Order reason S_ERDAT FOR VBAK-ERDAT OBLIGATORY. C_CR_LF TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF .Select Optons SELECTION-SCREEN: BEGIN OF BLOCK B01 WITH FRAME TITLE TEXT-001.Mail Sending Options SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-004. *-. SELECTION-SCREEN END OF BLOCK B2. " Document type 'BANS'. VALUE 'C'. CONSTANTS: C_TAB TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB. " For Object Class *-. " For ALI Format VALUE 'VBAK'. " Reason Code '0000500205'. VALUE 'K'. SELECTION-SCREEN: COMMENT 55(40) TEXT-019 MODIF ID US2. " Date on which the record was created SELECTION-SCREEN: END OF BLOCK B01. SELECT-OPTIONS: S_EMAIL FOR ADR6-SMTP_ADDR NO INTERVALS MODIF ID US2. VALUE 'U'.

*-.Fetch Sales Order documents.For modifying the selection screen layout AT SELECTION-SCREEN OUTPUT. S_ERDAT-HIGH = SY-DATUM.Default values for Sales Document Type CLEAR S_AUART[]. *-.Fetch Item Category Group PERFORM F_GET_MVKE_DOCS. * *----------------------------------------------------------------------* AT SELECTION-SCREEN.If Credit memo request internal table have an change records then .1 ). PERFORM std_top_of_page USING sy-title.Default values for Date on which the record was created V_DATE = ( SY-DATUM . *----------------------------------------------------------------------* * A T S E L E C T I O N S C R E E N O U T P U T *----------------------------------------------------------------------* *-. *----------------------------------------------------------------------* * TOP OF PAGE * *----------------------------------------------------------------------* TOP-OF-PAGE. PO Documents and Credit Memos PERFORM F_GET_SO_PO_DOCS. CLEAR S_AUART.Subroutine to Validate selection screen fields PERFORM f_validate. *-. *----------------------------------------------------------------------* * START-OF-SELECTION * *----------------------------------------------------------------------* START-OF-SELECTION. CLEAR S_ERDAT.Displaying standard header. *-. *----------------------------------------------------------------------* * AT SELECTION SCREEN. *-. S_ERDAT-LOW = SY-DATUM. S_AUART-OPTION = 'EQ'. ENDIF. APPEND S_AUART.*----------------------------------------------------------------------* INITIALIZATION. S_AUART-LOW = 'CR'. *-.Fetch the Credit Memo Requests documents PERFORM F_GET_CREDIT_MEMO_REQUEST. *-. S_ERDAT-OPTION = 'EQ'. S_AUART-SIGN = 'I'. *-. IF NOT IT_CRMEMO[] IS INITIAL. APPEND S_ERDAT. S_ERDAT-SIGN = 'I'. PERFORM F_MODIFY_SCREEN. CLEAR S_ERDAT[].

IF P_EMAIL = C_X. *----------------------------------------------------------------------* * END-OF-SELECTION * *----------------------------------------------------------------------* if v_flag is initial.Process Reversal Postings of Vendor Automatic Debits using TCODE MR8M PERFORM F_PROCESS_MR8M. *-.EMail Logic PERFORM F_MAIL_LOGIC.Fetch Purchasing Document Item Details IF NOT IT_PO[] IS INITIAL. ENDIF. ENDIF. ENDIF.To Modify Mail Sending Options LOOP AT SCREEN. *-. SCREEN-INVISIBLE = 0. else. *-. *-. *-. *-.Send mail. PERFORM F_GET_VENDOR. PERFORM F_GET_EKPO. *&---------------------------------------------------------------------* *& Form F_MODIFY_SCREEN *&---------------------------------------------------------------------* * A Form routine to modify the screen *----------------------------------------------------------------------* FORM F_MODIFY_SCREEN . IF SCREEN-GROUP1 = 'US1' . *-. ENDIF.display the EMail RSCONN01 and Sussess and Error records of MIRO and MR8M perform f_display_report. endif.Else exit the process exit. *-.* fetch the change documents from CDHDR and CDPOS IF NOT IT_CRMEMO_CHANGE[] IS INITIAL. *-.Fetch MIRO Vendor based on the PO Details IF NOT IT_EKPO[] IS INITIAL.Get spool id perform f_spool_id.if user enters Email id's and Email Mode is not initial IF P_EMAIL = C_X AND P_MODE IS NOT INITIAL AND S_EMAIL[] IS NOT INITIAL. *-.Process Vendor Debit Postings PERFORM F_PROCESS_MIRO.Fetch Change Documents for CR Memos from CDHDR and CDPOS tables PERFORM F_GET_CHANGED_DOCS. SCREEN-ACTIVE = 1. . *-.

*-. ELSEIF P_EMAIL = SPACE. endselect. MODIFY SCREEN. SCREEN-INVISIBLE = 1.Validate Sales Document Type if not s_AUART[] is initial. ENDIF. MODIFY SCREEN. if sy-subrc <> 0. message E000 with 'Invalid Order reason'(e02) . ENDIF. if sy-subrc <> 0. IF SCREEN-GROUP2 = 'US2' . ENDIF. endif. IF SCREEN-GROUP1 = 'US1' . ENDFORM. SCREEN-INVISIBLE = 0. SCREEN-ACTIVE = 1. message E000 with 'Invalid Sales Document Type'(e01) . endif. " F_MODIFY_SCREEN *&---------------------------------------------------------------------* *& Form f_validate *&---------------------------------------------------------------------* * Validation of Selection-Screen Inputs *----------------------------------------------------------------------* FORM f_validate .SCREEN-INPUT = 0. endif. ENDIF. select AUGRU into s_AUGRU-low from TVAU up to 1 rows where AUGRU in s_AUGRU. *-. IF SCREEN-GROUP1 = 'US2' . select AUART into s_AUART-low from TVAK up to 1 rows where AUART in s_AUART. endselect. ENDIF. MODIFY SCREEN. ENDFORM. SCREEN-ACTIVE = 0. SCREEN-INVISIBLE = 1. ENDIF. MODIFY SCREEN. " f_validate *&---------------------------------------------------------------------* .Validate Order reason (reason for the business transaction) if not s_AUGRU[] is initial. SCREEN-ACTIVE = 0. ENDLOOP.

SELECT A~VBELN B~POSNR A~ERDAT A~AUART A~AUGRU A~WAERK A~VKORG A~VTWEG A~SPART A~VDATU A~BSTNK A~BSARK A~BSTDK A~AEDAT A~BUKRS_VF B~MATNR B~ZMENG B~ZIEME INTO TABLE IT_CRMEMO FROM ( VBAK AS A INNER JOIN VBAP AS B ON A~VBELN = B~VBELN ) WHERE ( A~ERDAT IN S_ERDAT OR A~AEDAT IN S_ERDAT ) AND A~AUART IN S_AUART. IF SY-SUBRC = 0. ENDFORM. *-. DATA: LV_TABIX TYPE SY-TABIX. " F_GET_CREDIT_MEMO_REQUEST *&---------------------------------------------------------------------* *& Form F_GET_MVKE_DOCS *&---------------------------------------------------------------------* * Fetch Sales Data for Material *----------------------------------------------------------------------* FORM F_GET_MVKE_DOCS . v_flag = C_X.*& Form F_GET_CREDIT_MEMO_REQUEST *&---------------------------------------------------------------------* * Fetch Credit memo requests from VBAK & VBAP *----------------------------------------------------------------------* FORM F_GET_CREDIT_MEMO_REQUEST . stop. SORT IT_CRMEMO BY VBELN POSNR. ENDIF.Fetch Sales Data for Material SELECT MATNR " Material Number VKORG " Sales Organization VTWEG " Distribution Channel MTPOS " Item category group from material master FROM MVKE " Sales Data for Material INTO TABLE IT_MVKE FOR ALL ENTRIES IN IT_CRMEMO . ELSE. MESSAGE I000 WITH 'No Credit Memo Request selected'(002).

LV_TABIX = SY-TABIX. READ TABLE IT_MVKE INTO WA_MVKE WITH KEY MATNR = WA_CRMEMO-MATNR VKORG = WA_CRMEMO-VKORG VTWEG = WA_CRMEMO-VTWEG MTPOS = C_MTPOS BINARY SEARCH. WA_CRMEMO_CHANGE-SPART = WA_CRMEMO-SPART. WA_CRMEMO_CHANGE-ZMENG = WA_CRMEMO-ZMENG. WA_CRMEMO_CHANGE-POSNR = WA_CRMEMO-POSNR. WA_CRMEMO_CHANGE-VKORG = WA_CRMEMO-VKORG.Fetch Preceding sales orders based on the credit memo request . *-. APPEND WA_CRMEMO_CHANGE TO IT_CRMEMO_CHANGE. WA_CRMEMO_CHANGE-BSARK = WA_CRMEMO-BSARK. WA_CRMEMO_CHANGE-AUART = WA_CRMEMO-AUART. " Delete CR memo records ELSE. WA_CRMEMO_CHANGE-VTWEG = WA_CRMEMO-VTWEG. WA_CRMEMO_CHANGE-ERDAT = WA_CRMEMO-ERDAT. and * append those records to IT_CRMEMO_CHANGE internal table to retrive * change documents IF NOT WA_CRMEMO-AEDAT IS INITIAL. WA_CRMEMO_CHANGE-VDATU = WA_CRMEMO-VDATU. WA_CRMEMO_CHANGE-AEDAT = WA_CRMEMO-AEDAT. *-. " F_GET_MVKE_DOCS *&---------------------------------------------------------------------* *& Form F_GET_SO_PO_DOCS *&---------------------------------------------------------------------* * Fetch the Sales Order documents. DELETE IT_CRMEMO INDEX LV_TABIX. WA_CRMEMO_CHANGE-MATNR = WA_CRMEMO-MATNR. WA_CRMEMO_CHANGE-VBELN = WA_CRMEMO-VBELN. WA_CRMEMO_CHANGE-BSTNK = WA_CRMEMO-BSTNK. WA_CRMEMO_CHANGE-WAERK = WA_CRMEMO-WAERK. WA_CRMEMO_CHANGE-BSTDK = WA_CRMEMO-BSTDK. ENDIF.Else check for credit memo request change date is not initial. WA_CRMEMO_CHANGE-BUKRS_VF = WA_CRMEMO-BUKRS_VF. IF SY-SUBRC = 0. SORT IT_MVKE BY MATNR VKORG VTWEG MTPOS.Validate Item category group if MVKE-MTOPS <> 'BANS' then ignore CM Request line item LOOP AT IT_CRMEMO INTO WA_CRMEMO. ENDLOOP. ENDFORM. PO documents. *-. & Credit Memo *----------------------------------------------------------------------* FORM F_GET_SO_PO_DOCS.WHERE MATNR = IT_CRMEMO-MATNR AND VKORG = IT_CRMEMO-VKORG AND VTWEG = IT_CRMEMO-VTWEG. ENDIF. WA_CRMEMO_CHANGE-AUGRU = WA_CRMEMO-AUGRU. IF SY-SUBRC <> 0. CLEAR WA_CRMEMO_CHANGE. ENDIF. WA_CRMEMO_CHANGE-ZIEME = WA_CRMEMO-ZIEME.

Delete PO documents from IT_CMEMO internal table DELETE IT_CMEMO WHERE VBTYP_N = C_V.C_O) AND VBTYP_V = C_C. * stop. IF SY-SUBRC = 0. IF IT_CMEMO[] IS INITIAL.SELECT VBELV POSNV VBELN POSNN VBTYP_N FROM VBFA INTO TABLE IT_ORDERS FOR ALL ENTRIES IN IT_CRMEMO WHERE VBELN = IT_CRMEMO-VBELN AND POSNN = IT_CRMEMO-POSNR AND VBTYP_N = C_K AND VBTYP_V = C_C. *-.Copy the IT_PO internal table contents to IT_CMEMO internal table IT_CMEMO[] = IT_PO[]. IF SY-SUBRC = 0. *-. SORT IT_PO BY VBELN POSNN. MESSAGE I000 WITH 'No Credit Memo are available for CM Request'(003).Fetch Subsequent PO documents & Credit Memo based on the sales orders SELECT VBELV POSNV VBELN POSNN VBTYP_N FROM VBFA INTO TABLE IT_PO FOR ALL ENTRIES IN IT_ORDERS WHERE VBELV = IT_ORDERS-VBELV AND POSNV = IT_ORDERS-POSNV AND VBTYP_N IN (C_V. SORT IT_PO BY VBTYP_N. SORT IT_ORDERS BY VBELV POSNV. ENDFORM.Delete Credit Memo documents from IT_PO internal table DELETE IT_PO WHERE VBTYP_N = C_O. SORT IT_CMEMO BY VBELN POSNN. *-. ENDIF. * v_flag = c_x. ENDIF. " F_GET_SO_PO_DOCS *&---------------------------------------------------------------------* *& Form F_GET_CHANGED_DOCS *&---------------------------------------------------------------------* * Fetch Change Documents for CR Memos from CDHDR and CDPOS tables *----------------------------------------------------------------------* . ENDIF. *-.

*-. IF SY-SUBRC = 0. IF SY-SUBRC = 0.Fetch Change Documents for CR Memos from CDHDR SELECT OBJECTCLAS OBJECTID CHANGENR UDATE UTIME FROM CDHDR INTO TABLE IT_CDHDR FOR ALL ENTRIES IN IT_CRMEMO_CHANGE WHERE OBJECTCLAS = C_VERKBELEG AND OBJECTID = IT_CRMEMO_CHANGE-VBELN * AND UDATE = IT_CRMEMO_CHANGE-AEDAT . ENDIF. SORT IT_CDHDR BY OBJECTCLAS OBJECTID CHANGENR. SORT IT_CDPOS BY OBJECTCLAS OBJECTID CHANGENR. ENDFORM.Fetch Purchasing Document Item Details SELECT A~EBELN B~EBELP A~WAERS B~MENGE B~MEINS . " F_GET_CHANGED_DOCS *&---------------------------------------------------------------------* *& Form F_GET_EKPO *&---------------------------------------------------------------------* * Fetch Purchasing Document Item Details *----------------------------------------------------------------------* FORM F_GET_EKPO . *-. ENDIF.Fetch Change Documents for CR Memos from CDPOS SELECT OBJECTCLAS OBJECTID CHANGENR TABNAME TABKEY FNAME CHNGIND VALUE_NEW VALUE_OLD FROM CDPOS INTO TABLE IT_CDPOS FOR ALL ENTRIES IN IT_CDHDR WHERE OBJECTCLAS = C_VERKBELEG AND OBJECTID = IT_CDHDR-OBJECTID AND CHANGENR = IT_CDHDR-CHANGENR AND TABNAME = C_VBAK AND FNAME = C_AUGRU AND CHNGIND = C_U. *-.FORM F_GET_CHANGED_DOCS .

*-. *-. ENDIF. SORT IT_EKPO BY EBELN EBELP. ENDFORM. IF SY-SUBRC = 0. * and STBLG = space.Fetch the vendor details based on table IT_EKBE internal table SELECT BELNR GJAHR BLDAT BUDAT XBLNR LIFNR RMWWR WMWST1 XRECH STBLG FROM RBKP INTO TABLE IT_RBKP FOR ALL ENTRIES IN IT_EKBE . DATA: LV_TABIX TYPE SY-TABIX.B~NETPR B~PEINH B~mwskz B~TXJCD INTO TABLE IT_EKPO FROM ( EKKO AS A INNER JOIN EKPO AS B ON A~EBELN = B~EBELN ) FOR ALL ENTRIES IN IT_PO WHERE A~EBELN = IT_PO-VBELN AND B~EBELP = IT_PO-POSNN+1(5). SORT IT_EKBE BY BELNR GJAHR. IF SY-SUBRC = 0. " F_GET_EKPO *&---------------------------------------------------------------------* *& Form F_GET_VENDOR *&---------------------------------------------------------------------* * Fetch MIRO Vendor details based on the PO Details *----------------------------------------------------------------------* FORM F_GET_VENDOR .Fetch History per Purchasing Document records for all the PO records SELECT EBELN EBELP ZEKKN VGABE GJAHR BELNR BUZEI FROM EKBE INTO TABLE IT_EKBE FOR ALL ENTRIES IN IT_EKPO WHERE EBELN = IT_EKPO-EBELN AND EBELP = IT_EKPO-EBELP AND VGABE = '2'.

ENDIF. LV_TABIX = SY-TABIX. *-.Copy all the CR Memo Docs and delete order reason not in S_AUGRU IT_CRMEMO_MR8M[] = IT_CRMEMO[]. IT_CRMEMO_MR8M. DELETE IT_EKBE_TEMP INDEX LV_TABIX. *-.Copy the PO History documents into IT_EKBE_TEMP internal table IT_EKBE_TEMP[] = IT_EKBE[]. it_accountingdata.Delete PO History documents from IT_EKBE_TEMP internal table * comparing with IT_RBKP where (STBLG) Reversal document number * is initial LOOP AT IT_EKBE_TEMP INTO WA_EKBE_TEMP.Sort PO History documents based on PO # and PO Item SORT IT_EKBE BY EBELN EBELP. DATA: lv_itemno TYPE i. SORT IT_RBKP BY BELNR GJAHR. refresh : it_itemdata. WA_RBKP. lc_check(1) TYPE c VALUE 'X'.Delete order reason which are not in S_AUGRU . ENDFORM. *-. IF SY-SUBRC <> 0. lv_rbkp_bldat type sy-datum.WHERE BELNR = IT_EKBE-BELNR AND GJAHR = IT_EKBE-GJAHR. IF SY-SUBRC = 0. CLEAR: WA_EKBE_TEMP. ENDIF. READ TABLE IT_RBKP INTO WA_RBKP WITH KEY BELNR = WA_EKBE_TEMP-BELNR GJAHR = WA_EKBE_TEMP-GJAHR * XRECH = SPACE STBLG = SPACE. " F_GET_VENDOR *&---------------------------------------------------------------------* *& Form F_PROCESS_MIRO *&---------------------------------------------------------------------* * Process MIRO *----------------------------------------------------------------------* FORM F_PROCESS_MIRO . *-. *-. IT_CRMEMO_MR8M. ENDLOOP. *-. V_FILL_ITEM. *-. clear : it_itemdata. lv_tabix type sy-index. ENDIF. IT_CRMEMO_MIRO.Delete Reversal postings which are not in S_AUGRU DELETE IT_CRMEMO_MR8M WHERE AUGRU IN S_AUGRU.Delete Reversal postings where AEDAT is initial DELETE IT_CRMEMO_MR8M where aedat is initial. IT_CRMEMO_MIRO. it_accountingdata.

If credit memo request change date is initial then * send create date (ERDAT) to lv_rbkp_bldat lv_rbkp_bldat = WA_CRMEMO-erdat. ELSE.If credit memo request change date is not initial then * send change date (AEDAT) to lv_rbkp_bldat if not WA_CRMEMO-aedat is initial. IF SY-SUBRC = 0. *-. .Read IT_RBKP internal table with XRECH (Indicator: post invoice) = SPACE.Read IT_EKBE_TEMP internal table which contains records which are not reversed READ TABLE IT_EKBE_TEMP INTO WA_EKBE_TEMP WITH KEY EBELN = WA_EKPOEBELN EBELP = WA_EKPOEBELP.DELETE IT_CRMEMO WHERE AUGRU NOT IN S_AUGRU. IF SY-SUBRC = 0.Read IT_RBKP internal table with XRECH (Indicator: post invoice) = 'X' . IF SY-SUBRC = 0. endif. lv_tabix = sy-tabix. *-. IF SY-SUBRC = 0. * check for invoice records for the correspnding CR Memo records READ TABLE IT_RBKP INTO WA_RBKP WITH KEY BELNR = WA_EKBE_TEMPBELNR GJAHR = WA_EKBE_TEMPGJAHR XRECH = C_X.Loop through the credit memo request records LOOP AT IT_CRMEMO INTO WA_CRMEMO. *-. READ TABLE IT_EKPO INTO WA_EKPO WITH KEY EBELN = WA_PO-VBELN EBELP = WA_PO-POSNN. * STBLG = SPACE. *-. IF SY-SUBRC = 0. READ TABLE IT_PO INTO WA_PO WITH KEY VBELV = WA_ORDERS-VBELV POSNV = WA_ORDERS-POSNV. *-. CONTINUE. READ TABLE IT_ORDERS INTO WA_ORDERS WITH KEY VBELN = WA_CRMEMO-VBELN POSNN = WA_CRMEMO-POSNR. IF SY-SUBRC = 0. *-. else. * and document date = CR Memo creation date * and reference document number = PO number READ TABLE IT_RBKP INTO WA_RBKP_TMP WITH KEY BELNR = WA_EKBE_TEMP-BELNR GJAHR = WA_EKBE_TEMP-GJAHR BLDAT = WA_CRMEMOERDAT XRECH = ' ' XBLNR+0(10) = WA_EKBE_TEMP-ebeln. lv_rbkp_bldat = WA_CRMEMO-aedat.

*-. v_itemno = lv_itemno.At end of each credit memo request fill the header details of BAPI FM and *-. ENDIF. ENDIF. CLEAR it_itemdata.Populate the document Header *-. ENDIF. x_docheader-doc_type = c_blart. IT_ACCOUNTINGDATA-SERIAL_NO = C_01. = WA_EKPO-MEINS. WA_EKPO-EBELP.Populate Account Assignment data IT_ACCOUNTINGDATA-INVOICE_DOC_ITEM = v_itemno. IT_ACCOUNTINGDATA-PO_UNIT = it_itemdata-po_unit. *-. *-. IT_ACCOUNTINGDATA-TAX_CODE = it_itemdata-tax_code. it_itemdata-quantity V_CRMEMO_QTY ). *-. IT_ACCOUNTINGDATA-XUNPL = space. = ( WA_CRMEMO-ZMENG * *-. it_itemdata-invoice_doc_item it_itemdata-po_number it_itemdata-po_item it_itemdata-tax_code it_itemdata-TAXJURCODE = = = = = v_itemno. read table it_crmemo into wa_crmemo index lv_tabix.post the BAPI AT END OF VBELN. *-. clear IT_ACCOUNTINGDATA. endif. it_itemdata-po_unit APPEND it_itemdata. IT_ACCOUNTINGDATA-GL_ACCOUNT = C_0000500205. IT_ACCOUNTINGDATA-TAXJURCODE = it_itemdata-TAXJURCODE. IT_ACCOUNTINGDATA-QUANTITY = it_itemdata-quantity.Incrementing the item no lv_itemno = lv_itemno + 1. append IT_ACCOUNTINGDATA. ENDIF. WA_ekPO-ebeln. endif. IT_ACCOUNTINGDATA-ITEM_AMOUNT = it_itemdata-item_amount.Converting SAP amount to BAPI format by passing line item amount and currency PERFORM f_currency_amount_sap_to_bapi USING WA_EKPO-waers V_LINE_AMOUNT CHANGING it_itemdataitem_amount . WA_ekpo-mwskz. WA_ekpo-TXJCD.Quantity Conversion (Get the Credit Memo Quantity by passing CMR unit per one PO unit) perform f_quantity_conv.Getting the header data for invoice x_docheader-invoice_ind = space.Filling the Line items data *-. .

WA_CRMEMO-WAERK.x_docheader-doc_date x_docheader-pstng_date x_docheader-ref_doc_no x_docheader-comp_code x_docheader-CURRENCY x_docheader-calc_tax_ind = = = = = = lv_rbkp_bldat. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = 'X'. wa_success-text = 'MIRO is Posted'. *-*-. * If message type is error then roll back the work IF it_return-type = C_E. CLEAR it_return. v_tax_amt = ( V_GROSSAMT * v_tax_per ) / 100. V_GROSSAMT = ( V_GROSSAMT + v_tax_amt ). *-. x_docheader-gross_amount = V_GROSSAMT. Read the values in the table IT_RETURN. v_year1.Logic to find the Tax % v_tax_per = ( WA_RBKP-WMWST1 / ( WA_RBKP-RMWWR .Move the data to Error Internal Table wa_error-crmemo = wa_crmemo-vbeln. wa_success-cmemo = wa_cmemo-vbeln. lc_check. *-. wa_success-miro_no = v_docnr. WA_CRMEMO-BUKRS_VF. *-. lv_rbkp_bldat. *-.Move the data to Success Internal Table wa_success-crmemo = wa_crmemo-vbeln.Calling BAPI to create PO invoice document CHECK NOT IT_ITEMDATA[] IS INITIAL. wa_success-po = wa_po-vbeln. clear wa_success.WA_RBKP-WMWST1 ) ) * 100.Commit work IF NOT v_docnr IS INITIAL. ENDIF. append wa_success TO it_success. wa_success-orders = wa_orders-vbelv. READ TABLE it_return INDEX 1. . WA_RBKP-XBLNR. *-.Roll back CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. CLEAR:v_docnr. CALL FUNCTION 'BAPI_INCOMINGINVOICE_CREATE' EXPORTING headerdata = x_docheader IMPORTING invoicedocnumber = v_docnr fiscalyear = v_year1 TABLES itemdata = it_itemdata[] ACCOUNTingDATA = it_ACCOUNTingDATA[] * GLACCOUNTDATA = * taxdata = return = it_return.

it_accountingdata. wa_po. *-. ENDFORM. V_CRMEMO_QTY. V_FILL_ITEM.wa_error-cmemo wa_error-orders wa_error-po wa_error-text append wa_error clear wa_error. v_tax_per.Quantity Conversion (Get the Credit Memo Quantity by passing CMR unit per one PO unit) CLEAR: V_LINE_AMOUNT. it_return. WA_SUCCESS. " F_PROCESS_MIRO *&---------------------------------------------------------------------* *& Form f_quantity_conv *&---------------------------------------------------------------------* * Quantity Conversion *----------------------------------------------------------------------* FORM f_quantity_conv . wa_rbkp. wa_orders. v_year1. = wa_orders-vbelv. lv_rbkp_bldat. V_LINE_AMOUNT = ( V_CRMEMO_QTY * WA_CRMEMO-ZMENG WA_EKPO-NETPR ). ENDFORM. v_docnr. call function 'MC_UNIT_CONVERSION' EXPORTING MATNR = WA_CRMEMO-MATNR nach_meins = WA_EKPO-MEINS von_meins = WA_CRMEMO-ZIEME IMPORTING UMREF = V_CRMEMO_QTY EXCEPTIONS CONVERSION_NOT_FOUND = 1 MATERIAL_NOT_FOUND = 2 NACH_MEINS_MISSING = 3 OVERFLOW = 4 VON_MEINS_MISSING = 5 OTHERS = 6. wa_ekpo. clear: V_GROSSAMT. ENDAT. wa_rbkp_tmp. it_accountingdata. = wa_po-vbeln. ENDIF. = it_return-MESSAGE. ENDIF. wa_crmemo. " f_quantity_conv * WA_EKPO-peinh * *&---------------------------------------------------------------------* . MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. = wa_cmemo-vbeln. WA_EKBE_TEMP. it_itemdata. ELSE. V_GROSSAMT = V_GROSSAMT + V_LINE_AMOUNT. TO it_error. WA_ERROR. if sy-subrc <> 0. it_itemdata. refresh: it_return. ENDLOOP. v_tax_amt.

DATA : lv_waers LIKE tcurc-waers. lv_sapamount LIKE bapicurr-bapicurr. 59 sy-vline.*& Form f_currency_amount_sap_to_bapi *&---------------------------------------------------------------------* * SAP Amount to BAPI Amount *----------------------------------------------------------------------* FORM f_currency_amount_sap_to_bapi USING p_waers p_kbetr CHANGING p_amt_doccur. ULINE AT /1(129). 129 sy-vline. wa_success-text. wa_success-cmemo. CALL FUNCTION 'CURRENCY_AMOUNT_SAP_TO_BAPI' EXPORTING currency = lv_waers sap_amount = lv_sapamount IMPORTING bapi_amount = lv_bapi_amount. wa_success-crmemo. 59 sy-vline. 'Sales Order'. 129 sy-vline. 'Credit Memo'. 99 sy-vline. WRITE:/1 sy-vline. wa_success-miro_no.Success Report IF NOT IT_SUCCESS[] IS INITIAL. 39 sy-vline. ULINE AT /1(129). 'CR Memo'. 99 sy-vline. LOOP AT it_success into wa_success. 'Text'. lv_bapi_amount LIKE bapicurr-bapicurr. 19 sy-vline. *-. lv_sapamount = p_kbetr. 19 sy-vline. WRITE:/1 sy-vline. wa_success-po. 79 sy-vline. " f_currency_amount_sap_to_bapi *&---------------------------------------------------------------------* *& Form f_display_report *&---------------------------------------------------------------------* * Display Report *----------------------------------------------------------------------* FORM f_display_report . 79 sy-vline. wa_success-orders. 39 sy-vline. 'MIRO Number'. ENDFORM. lv_waers = p_waers. ULINE AT /1(129). ENDLOOP. p_amt_doccur = lv_bapi_amount. 'Purchase Order'. .

wa_success_mr8m-crmemo. WRITE:/1 sy-vline. 59 sy-vline. LOOP AT IT_ERROR into WA_ERROR. wa_success_mr8m-miro_no. WRITE:/1 sy-vline. 39 sy-vline. 59 sy-vline. 39 sy-vline. 179 sy-vline. 'Reversal Posting No. wa_success_mr8m-po. wa_success_mr8m-orders. ENDIF. 129 sy-vline.'. WA_ERROR-cmemo. WA_ERROR-text. 19 sy-vline. ULINE AT /1(129). 179 sy-vline. ENDLOOP. 79 sy-vline. 129 sy-vline. ENDLOOP. *-. 79 sy-vline. 'Error Text'. 79 sy-vline. 'Credit Memo'. ENDIF.Error Report IF NOT IT_ERROR[] IS INITIAL. SKIP 2. 79 sy-vline. 'Purchase Order'. 19 sy-vline. WRITE:/1 sy-vline. 59 sy-vline. 'Sales Order'. ULINE AT /1(129).Error Report IF NOT IT_ERROR_MR8M[] IS INITIAL. 'Purchase Order'. WRITE:/1 sy-vline. 99 sy-vline. WA_ERROR-orders. IF NOT IT_SUCCESS_MR8M[] IS INITIAL. WA_ERROR-crmemo. 'Credit Memo'. wa_success_mr8m-text. ULINE AT /1(179). 'Text'. 'Sales Order'. LOOP AT it_success_mr8m into wa_success_mr8m. 39 sy-vline. 'CR Memo'. *-. ULINE AT /1(179). 99 sy-vline. WA_ERROR-po. 39 sy-vline.SKIP 2. wa_success_mr8m-cmemo. 'CR Memo'. 19 sy-vline. . ENDIF. 19 sy-vline. 59 sy-vline. ULINE AT /1(179). ULINE AT /1(129).

* READ TABLE IT_CMEMO INTO WA_CMEMO WITH KEY VBELV = WA_ORDERS-VBELV * POSNV = WA_ORDERS-POSNV. 'CR Memo'.ULINE AT /1(179). * IF SY-SUBRC = 0. WA_ERROR_MR8M-text. LOOP AT IT_EKBE into WA_EKBE WHERE EBELN = WA_EKPO-EBELN . ULINE AT /1(179). LOOP AT IT_CRMEMO_MR8M read table it_cdpos VBELN. WA_ERROR_MR8M-cmemo. " f_display_report *&---------------------------------------------------------------------* *& Form F_PROCESS_MR8M *&---------------------------------------------------------------------* * Process Reversal postings *----------------------------------------------------------------------* FORM F_PROCESS_MR8M . IF SY-SUBRC = 0. clear: wa_CRMEMO_MR8M. ENDLOOP. 39 sy-vline. if wa_cdpos-value_old READ TABLE IT_ORDERS into WA_CRMEMO_MR8M. 'Purchase Order'. 19 sy-vline. ULINE AT /1(179). WRITE:/1 sy-vline. 39 sy-vline. WA_ERROR_MR8M-orders. 'Sales Order'. WA_ERROR_MR8M-po. 179 sy-vline. * READ TABLE IT_EKBE INTO WA_EKBE WITH KEY EBELN = WA_EKPO-EBELN * EBELP = WA_EKPO-EBELP. READ TABLE IT_PO INTO WA_PO WITH KEY VBELV = WA_ORDERS-VBELV POSNV = WA_ORDERS-POSNV. INTO WA_ORDERS WITH KEY VBELN = wa_CRMEMO_MR8M-VBELN POSNN = wa_CRMEMO_MR8M- POSNR. ELSE. if sy-subrc <> 0. ENDFORM. * IF SY-SUBRC = 0. 79 sy-vline. IF SY-SUBRC = 0. 59 sy-vline. LOOP AT IT_ERROR_MR8M into WA_ERROR_MR8M. 'Credit Memo'. CONTINUE. 179 sy-vline. 59 sy-vline. READ TABLE IT_EKPO INTO WA_EKPO WITH KEY EBELN = WA_PO-VBELN EBELP = WA_PO-POSNN. IF SY-SUBRC = 0. 'Error Text'. 79 sy-vline. into wa_cdpos with key OBJECTID = WA_CRMEMO_MR8M- in s_augru. WA_ERROR_MR8M-crmemo. ENDIF. WRITE:/1 sy-vline. 19 sy-vline.

Commit work IF NOT X_REV_POST-INV_DOC_NO IS INITIAL. Read the values in the table IT_RETURN. clear wa_success_mr8m. WA_RBKP-GJAHR TO X_REV_POST-FISC_YEAR. IF WA_RBKP-BUDAT+4(2) = SY-DATUM+4(2). Call the FM for MIRO reversal CALL FUNCTION 'BAPI_INCOMINGINVOICE_CANCEL' EXPORTING INVOICEDOCNUMBER = X_REV_POST-INV_DOC_NO FISCALYEAR = X_REV_POST-FISC_YEAR REASONREVERSAL = X_REV_POST-REASON_REV POSTINGDATE = X_REV_POST-PSTNG_DATE IMPORTING INVOICEDOCNUMBER_REVERSAL = X_REV_POST-INV_DOC_NO FISCALYEAR_REVERSAL = X_REV_POST-FISC_YEAR TABLES RETURN = it_return_mr8m. append wa_success_mr8m TO it_success_mr8m. wa_error_mr8m-cmemo = wa_cmemo-vbeln. Roll back CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. READ TABLE it_return_mr8m INDEX 1. ENDIF. wa_success_mr8m-orders = wa_orders-vbelv.* AEDAT EBELN AND EBELP = WA_EKPO-EBELP. X_REV_POST-REASON_REV = C_02. *-- *-- *-- *-*-*-*-- IF SY-SUBRC = 0. ENDIF. wa_success_mr8m-po = wa_po-vbeln. READ TABLE IT_RBKP INTO WA_RBKP WITH KEY BELNR = WA_EKBE-BELNR GJAHR = WA_EKBE-GJAHR BLDAT = WA_CRMEMO_MR8MXBLNR+0(10) = WA_EKBEXRECH = SPACE STBLG = SPACE. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' EXPORTING wait = 'X'. If message type is error then roll back the work IF it_return_mr8m-type = 'E' . CLEAR it_return_mr8m. Move the data to Success Internal Table wa_success_mr8m-crmemo = wa_crmemo-vbeln. . wa_success_mr8m-text = 'MR8M Done'. ELSE. WA_RBKP-BUDAT TO X_REV_POST-PSTNG_DATE. move: WA_RBKP-BELNR TO X_REV_POST-INV_DOC_NO. wa_success_mr8m-cmemo = wa_cmemo-vbeln. ENDIF. X_REV_POST-REASON_REV = C_01. Move the data to Error Internal Table wa_error_mr8m-crmemo = wa_crmemo-vbeln. ENDLOOP.

receiver 'TJOSVOB' cover text 'Spool title'(p20) " <<== Title or Spool req. wa_ekpo.wa_error_mr8m-orders wa_error_mr8m-po wa_error_mr8m-text append wa_error_mr8m clear wa_error_mr8m.Create a new spool from the data in data_tab *-.new-page line-size sy-linsz print on new-page line-size 255 print on destination 'LOCL'(p19) "<<== my printer *-. ENDIF. ENDIF. *-. = it_return_mr8m-MESSAGE. ENDIF. ENDIF. ENDFORM. REFRESH: IT_RETURN_MR8M. ENDIF. *-. TO it_error_mr8m. " F_spool_id *&---------------------------------------------------------------------* *& Form F_MAIL_LOGIC *&---------------------------------------------------------------------* * Logic to send a mail for the given Email ID's *----------------------------------------------------------------------* . wa_rbkp. = wa_po-vbeln. ENDFORM. wa_SUCCESS_mr8m. endloop. ENDIF. wa_orders. wa_po. wa_CRMEMO_MR8M. *-. ENDIF. " F_PROCESS_MR8M *&---------------------------------------------------------------------* *& Form F_spool_id *&---------------------------------------------------------------------* * Create a new spool ID *----------------------------------------------------------------------* FORM F_spool_id . ENDIF.In this perform you will write the code for displaying the list perform f_display_report. name list name 'List name'(p21) list dataset 'List Dataset'(p22) immediately ' ' " X means print now keep in spool c_x " X means keep spool new list identification c_x no dialog . CLEAR: wa_error_mr8m. X_REV_POST.Writing Report *-. wa_cmemo. ENDIF. * * * = wa_orders-vbelv.new-page print off new-page print off. wa_ekbe.

it_pdf_list. *-. data : wa_tsp01sys type tsp01sys.Convert the Spool ID into PDF format perform f_pdf_conversion tables it_compressed_list it_pdf_list using v_spono.Call the FM "RSPO_RETURN_SPOOLJOB" to read the spool by passing the spool number call function 'RSPO_RETURN_SPOOLJOB' exporting rqident = lv_spooln desired_type = v_type importing real_type = v_type tables buffer = it_compressed_list buffer_pdf = it_pdf_list exceptions no_such_job = 1 job_contains_no_data = 2 selection_empty = 3 no_permission = 4 can_not_access = 5 read_error = 6 type_no_match = 7 others = 8. it_pdf_list. . refresh: it_compressed_list. endif. *-.Send the Mail in PDF Format perform f_send_mail. * v_attach_desc = sy-title. " F_MAIL_LOGIC *&---------------------------------------------------------------------* *& Form f_pdf_conversion *&---------------------------------------------------------------------* * Read the spool and convert into PDF format *----------------------------------------------------------------------* * -->P_ITAB_COMPRESSED_LIST text * -->P_ITAB_PDF_LIST text * -->P_V_SPONO text *----------------------------------------------------------------------* FORM f_pdf_conversion TABLES it_compressed_list structure soli it_pdf_list structure tline using lv_spooln type tsp01-rqident. clear: it_compressed_list. v_spono = sy-spono.FORM F_MAIL_LOGIC . ENDFORM. message I000 with 'Error in spool reading'(017). clear v_spono. *-. if sy-subrc <> 0.

ENDIF. APPEND it_temp. LOOP AT it_pdf. *-. ENDIF. CLEAR it_temp. CLEAR it_temp. if sy-subrc <> 0. IF v_offset GE v_mimelen. it_temp = v_temp(v_offset). " for List it is ALI call function 'CONVERT_ABAPSPOOLJOB_2_PDF' exporting src_spoolid = lv_spooln tables pdf = it_pdf exceptions err_no_abap_spooljob = 1 err_no_spooljob = 2 err_no_permission = 3 err_conv_not_possible = 4 err_bad_destdevice = 5 user_cancelled = 6 err_spoolerror = 7 err_temseerror = 8 err_btcjob_open_failed = 9 err_btcjob_submit_failed = 10 err_btcjob_close_failed = 11 others = 12. describe field it_pdf length v_lineslen IN character MODE. SHIFT v_temp BY v_mimelen PLACES. MOVE it_pdf TO v_temp+v_offset.v_mimelen. message e000 with'Error in convertion of list into PDF format'(018). . v_offset = v_offset . LOOP AT it_temp.Logic to convert the given format into 255 character format in IT_PDF describe table it_pdf lines v_lines. it_temp = v_temp(v_mimelen). describe field it_temp length v_mimelen IN character MODE.If the List type is ALI call the FM "CONVERT_ABAPSPOOLJOB_2_PDF" * to convert list into PDF Format if v_type = c_ali. IF v_tabix = v_lines. v_offset = v_offset + v_lineslen. ENDIF. v_tabix = sy-tabix. IF v_offset GT 0.*-. APPEND it_temp. ENDLOOP. endif. v_lineslen = strlen( it_pdf ). IF v_tabix = v_lines. ENDIF.

MOVE 'File is generated on'(007) TO V_INFO.Populate Mail Id's WA_RECLIST-REC_TYPE = P_MODE. *--To check Mail ID's internal table should not be Empty. CONCATENATE V_TIME+0(2) V_TIME+2(2) V_TIME+4(2) INTO V_TIME2 SEPARATED BY ':'.Append Date and Time into Body of email. *-. *-.Loop through the Emial select options LOOP AT S_EMAIL INTO X_EMAIL. APPEND WA_OBJTXT TO IT_OBJTXT. *--populate document attributes *-. " f_pdf_conversion *&---------------------------------------------------------------------* *& Form f_send_mail *&---------------------------------------------------------------------* * Send EMail Logic *----------------------------------------------------------------------* FORM f_send_mail . data : wa_tsp01sys type tsp01sys.Mail body CONCATENATE 'Automatic Vendor Dedit Postings'(005) ' is attached. ENDFORM. ENDLOOP. .Final Data to send to EMail it_html[] = it_mime[]. *-.append receiver table APPEND WA_RECLIST TO IT_RECLIST. APPEND it_mime. ENDLOOP. CONCATENATE 'Automatic Vendor Dedit Postings'(005) SY-DATUM INTO X_DOC_CHNG-OBJ_DESCR SEPARATED BY SPACE.it_mime(255) = it_temp-line. *-.'(006) INTO WA_OBJTXT SEPARATED BY SPACE.Mail subject line CLEAR: X_DOC_CHNG. WA_RECLIST-RECEIVER = X_EMAIL-LOW.If receiver table is not initial CHECK IT_RECLIST[] IS NOT INITIAL. WA_RECLIST-EXPRESS = C_X. *-. endif. *-. V_TIME = SY-UZEIT. *-. X_DOC_CHNG-OBJ_NAME = 'HEADING'.

Populate object header(attachment name) WA_OBJHEAD = 'Automatic Vendor Dedit Postings log'(014). CONCATENATE V_INFO V_DATE2 'At' V_TIME2 INTO V_INFO SEPARATED BY SPACE.of lines of Object table(attachment) CLEAR : V_TABLE_LINES. loop at it_html. v_type = 'PDF'. APPEND WA_OBJHEAD TO IT_OBJHEAD. WA_OBJPACK-HEAD_START = 1. X_DOC_CHNG-DOC_SIZE = ( V_TABLE_LINES . WA_OBJPACK-DOC_TYPE = 'RAW'. *-. WA_OBJPACK-BODY_START = 1.CONCATENATE SY-DATUM+4(2) '/' SY-DATUM+6(2) '/' SY-DATUM+0(4) INTO V_DATE2. CLEAR WA_OBJPACK. WA_OBJPACK-DOC_TYPE = v_type .Get total no. APPEND WA_OBJBIN TO IT_OBJBIN.Packing list for attachment WA_OBJPACK-TRANSF_BIN = C_X. DESCRIBE TABLE IT_OBJBIN LINES V_TABLE_LINES. APPEND WA_OBJPACK TO IT_OBJPACK. WA_OBJPACK-BODY_NUM = V_TABLE_LINES . READ TABLE IT_OBJTXT INTO WA_OBJTXT INDEX V_TABLE_LINES . APPEND WA_OBJTXT TO IT_OBJTXT. WA_OBJPACK-HEAD_NUM = 1.Document size CLEAR : V_TABLE_LINES. CLEAR WA_OBJBIN. WA_OBJPACK-BODY_START = 1. WA_OBJTXT = V_INFO. *-. DESCRIBE TABLE IT_OBJTXT LINES V_TABLE_LINES.1 ) * 255 + STRLEN( WA_OBJTXT ). .Populate packing list for body text WA_OBJPACK-HEAD_START = 1. WA_OBJPACK-BODY_NUM = V_TABLE_LINES. *-. wa_objbin-line = it_html-line. CLEAR WA_OBJHEAD. *-. WA_OBJPACK-HEAD_NUM = 0. if v_type = c_ali. *-. endloop. endif.

ENDFORM. APPEND WA_OBJPACK TO IT_OBJPACK.Call the RSCONN01 (SAPconnect: Start Send Process) SUBMIT RSCONN01 WITH MODE = 'INT' * WITH output = 'X' AND RETURN. WA_OBJPACK-DOC_SIZE = V_TABLE_LINES * 255. CLEAR WA_OBJPACK. ELSE.WA_OBJPACK-OBJ_NAME = 'Auto_Debit'. call function 'RSPO_IDELETE_SPOOLREQ' exporting spoolreq = wa_tsp01sys. PERFORM F_DISPLAY_SENT_MAIL_STATUS. endif. *-. if sy-subrc <> 0.Sending the EMail document in given format CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1' EXPORTING DOCUMENT_DATA = X_DOC_CHNG PUT_IN_OUTBOX = C_X COMMIT_WORK = C_X TABLES PACKING_LIST = IT_OBJPACK OBJECT_HEADER = IT_OBJHEAD CONTENTS_BIN = IT_OBJBIN CONTENTS_TXT = IT_OBJTXT RECEIVERS = IT_RECLIST EXCEPTIONS TOO_MANY_RECEIVERS = 1 DOCUMENT_NOT_SENT = 2 DOCUMENT_TYPE_NOT_EXIST = 3 OPERATION_NO_AUTHORIZATION = 4 PARAMETER_ERROR = 5 X_ERROR = 6 ENQUEUE_ERROR = 7 OTHERS = 8. WA_OBJPACK-OBJ_DESCR = 'attachment'. ENDIF. IF SY-SUBRC <> 0.Wait upto 2 secounds wait up to 2 seconds. *-. * To delete the spool request wa_tsp01sys-rqident = sy-spono. *-. " f_send_mail *&---------------------------------------------------------------------* *& Form F_DISPLAY_SENT_MAIL_STATUS *&---------------------------------------------------------------------* * Display Mail Sent status to the user *----------------------------------------------------------------------* . MESSAGE E000 WITH 'Error occurred in sending mail'(015).

TYPES : BEGIN OF str_makt. V_TABLE_LINES = STRLEN( X_EMAIL-LOW ). 60 SY-VLINE. WRITE :/ SY-VLINE.” Following is a sample interactive report developed for our demo purpose: REPORT zintractive . the corresponding material information on the secondary list. WRITE :/ SY-VLINE. ersda TYPE mara-ersda. ENDFORM. TYPES : BEGIN OF str_mard. . Once you click on require “material no” on the basic list. ULINE AT /1(60). maktg TYPE makt-maktg. ENDLOOP. matnr TYPE mard-matnr. ernam TYPE mara-ernam. TYPES : BEGIN OF str_mara. 2 SY-TABIX LEFT-JUSTIFIED. END OF str_mard. DATA : wa_mard TYPE str_mard. 60 SY-VLINE. matnr TYPE mara-matnr. DATA : wa_makt TYPE str_makt. V_TEXT2. matnr TYPE makt-matnr. END OF str_makt.FORM F_DISPLAY_SENT_MAIL_STATUS . ULINE AT /1(60). 5 ')'. laeda TYPE mara-laeda. lgort TYPE mard-lgort. Mouri Tech Solutions “In this scenario. it_mard TYPE TABLE OF str_mard. " F_DISPLAY_SENT_MAIL_STATUS Developing simple interactive report By Vakada Raghava. werks TYPE mard-werks. 'Mail sent Successfully to'(016) COLOR 5 INTENSIFIED ON. it_makt TYPE TABLE OF str_makt. we would take an example of a material and develop an interactive report. MOVE X_EMAIL-LOW+0(V_TABLE_LINES) TO V_TEXT2. LOOP AT S_EMAIL INTO X_EMAIL.

65 'MATERIALTYPE'. DATA : wa_mara TYPE str_mara. SELECT matnr maktg FROM makt INTO TABLE it_makt FOR ALL ENTRIES IN it_mard WHERE matnr = it_mard-matnr AND spras = 'E'. matkl TYPE mara-matkl. CLEAR wa_mard-matnr. PARAMETERS : plant TYPE mard-werks. TYPES : BEGIN OF str_final. stor LIKE mard-lgort. ULINE. HIDE wa_makt-matnr. 110 'STORLOCATION' COLOR 4. IF sy-lsind = 1. ernam TYPE mara-ernam. LOOP AT it_makt INTO wa_makt. . matnr TYPE mara-matnr. END OF str_mara. . 20 'CREATION DATE' COLOR 3. 130 'PLANT' COLOR 5. LOOP AT it_mara INTO wa_mara WHERE matnr = wa_makt-matnr. WRITE : /1 wa_makt-matnr COLOR 1. ersda TYPE mara-ersda. ULINE. 80 'MATGROUP' . 50 'DATE OF LIST' . meins TYPE mara-meins. it_final TYPE TABLE OF str_final. DATA: wa_final TYPE str_final. CLEAR wa_final. 40 wa_makt-maktg COLOR 2. matkl TYPE mara-matkl. meins TYPE mara-meins. REFRESH it_final. ENDIF.mtart TYPE mara-mtart. SELECT matnr lgort werks FROM mard INTO TABLE it_mard WHERE lgort = stor AND werks = plant. werks TYPE mard-werks. ENDLOOP. END OF str_final. laeda TYPE mara-laeda. AT LINE-SELECTION. WRITE : /1 'MATERIAL NO' COLOR 2. mtart TYPE mara-mtart. lgort TYPE mard-lgort. it_mara TYPE TABLE OF str_mara. 32 'PERSON CREATED'. SELECT matnr ersda ernam laeda mtart matkl meins FROM mara INTO TABLE it_mara FOR ALL ENTRIES IN it_makt WHERE matnr = it_makt-matnr. 90 'UNITOFMEASURE'.

wa_final-matnr = wa_mara-matnr. WRITE : /1 wa_final-matnr COLOR 2. wa_final-werks = wa_mard-werks. 40 'DISCRIPTION' COLOR 2. 130 wa_final-werks COLOR 5. wa_final-lgort = wa_mard-lgort. wa_final-ernam = wa_mara-ernam. LOOP AT it_final INTO wa_final. 85 wa_final-matkl . TOP-OF-PAGE. ENDLOOP. ENDLOOP. READ TABLE it_mard INTO wa_mard WITH KEY matnr = wa_makt-matnr. wa_final-meins = wa_mara-meins. ULINE . 115 wa_final-lgort COLOR 4. 50 wa_final-laeda . 95 wa_final-meins. WRITE : /1 'MATERIAL NO' COLOR 1. 20 wa_final-ersda COLOR 3. wa_final-ersda = wa_mara-ersda. wa_final-matkl = wa_mara-matkl. wa_final-laeda = wa_mara-laeda. APPEND wa_final TO it_final. wa_final-mtart = wa_mara-mtart. 70 wa_final-mtart . Result Enter the “Plant” and “Storage Location” Press the Execute Button. 37 wa_final-ernam. .

When the material number in the report is selected the material description and other complete details are displayed in a new screen using interactive report. STEPS FOLLOWED TO ACHIEVE THE GOAL: Go to SE38 ABAP Editor create a new program. The result shown below Developing simple interactive report By Vikram Chellappa. Mouri Tech Solutions REQUIREMENT: Get the Plant and storage location from the user and to get the available materials in the particular storage location and display in a report.Double Click on require “Material No” which displays secondary list to corresponding material information. .

Check –Activate. Type in the Required Parameters or select a value from F4 Help Screen. .Code the logic in the ABAP Editor.and Execute the code.

Execute the project The Report is displayed in the output Screen. .

TYPES : BEGIN OF TY_MARD. MATNR TYPE MARD-MATNR.Select a record using the mouse double click. . *&----------------------------------------------------------------* *& Report ZVikram_interactive * *& * *&----------------------------------------------------------------* *& Published at SAPTechnical.COM * *& * *&----------------------------------------------------------------* REPORT ZVikram_interactive NO STANDARD PAGE HEADING LINE-SIZE 255. WERKS TYPE MARD-WERKS. ********** THE INITIALIZATION PART CREATING STRUCTURES************* INITIALIZATION. A new screen shows the output based on the selected record achieving the interactive reporting.

LGORT TYPE MARD-LGORT. W_FINAL TYPE TY_FINAL. ELSE. MAKTX TYPE MAKT-MAKTX.************************** START-OF-SELECTION. **************************START-OF-SELECTION. MTART TYPE MARA-MTART. I_MARD TYPE TABLE OF TY_MARD. ***** THE INITIALIZATION PART CREATING WORKAREA AND INTERNAL TABLE***** DATA : W_MARD TYPE TY_MARD. ****SELECT DATA FROM DATABASE INTO INTERNAL TABLES********************* **SELECT FROM MARD THE REQUIRED FIELDS FOR THE GIVEN INPUT************* SELECT MATNR WERKS LGORT FROM MARD INTO TABLE I_MARD WHERE WERKS = PLANT AND LGORT = STLOC. MATNR TYPE MARA-MATNR. *****CHECK IF RECORDS ARE FETCHED IF NO EXIT OUT OF THE PROGRAM******** IF SY-SUBRC <> 0. END OF TY_MARA. BEGIN OF TY_FINAL. WRITE 'NO RECORDS'. MATNR TYPE MARA-MATNR. MATNR TYPE MAKT-MATNR. WERKS TYPE MARD-WERKS.LGORT TYPE MARD-LGORT. ERSDA TYPE MARA-ERSDA. I_FINAL TYPE TABLE OF TY_FINAL. ERSDA TYPE MARA-ERSDA. ***IF RECORDS ARE FETCHED FROM FRIST TABLE***************************** ****FETCH RELATED RECORDS FROM NEXT TABLE****************************** SELECT MATNR ERSDA ERNAM MTART MATKL FROM MARA INTO TABLE I_MARA FOR ALL ENTRIES IN I_MARD WHERE MATNR = I_MARD-MATNR. ERNAM TYPE MARA-ERNAM. MATKL TYPE MARA-MATKL. ERNAM TYPE MARA-ERNAM. SPRAS TYPE MAKT-SPRAS. I_MAKT TYPE TABLE OF TY_MAKT. END OF TY_MARD. . BEGIN OF TY_MAKT. W_MARA TYPE TY_MARA. EXIT. END OF TY_FINAL. MTART TYPE MARA-MTART. BEGIN OF TY_MARA. MAKTX TYPE MAKT-MAKTX. STLOC TYPE MARD-LGORT. I_MARA TYPE TABLE OF TY_MARA. MATKL TYPE MARA-MATKL. *************************GET INPUT FROM USER*************************** PARAMETER : PLANT TYPE MARD-WERKS. SPRAS TYPE MAKT-SPRAS. END OF TY_MAKT. W_MAKT TYPE TY_MAKT.

AT FIRST. HIDE W_MARA-MATNR. 62 W_MARA-MTART. 80 SY-VLINE. 100 SY-VLINE. 60 SY-VLINE. 42 'USER NAME'. 82 W_MARA-MATKL.IF SY-SUBRC <> 0. 60 SY-VLINE. *****************END-OF-SELECTION. WRITE: / SY-ULINE(100). 20 SY-VLINE. 22 W_MARA-ERSDA. READ TABLE I_MAKT INTO W_MAKT WITH KEY MATNR = W_MARA-MATNR. . 80 SY-VLINE. / SY-ULINE(100). ON CHANGE OF W_MARA-MATNR. 82 'MATERIAL GROUP'. ON CHANGE OF W_MARA-MATNR. ELSE. ENDON. 2 'MATERIAL NUMBER' . ENDLOOP. 20 SY-VLINE. 25 'EXAMPLE INTERACTIVE REPORT'. /1 SY-VLINE. READ TABLE I_MARD INTO W_MARD WITH KEY MATNR = W_MARA-MATNR. 22 'CREATION DATE'. WRITE 'NO MASTER DATA'. / SY-ULINE(100). *****READ FROM INTERNAL TABLE FOR OUTPUT ****************************** LOOP AT I_MARA INTO W_MARA.************************************* END-OF-SELECTION. CLEAR W_MARA-MATNR. STOP. 100 SY-VLINE. WRITE : SY-ULINE(100). READ TABLE I_MARD INTO W_MARD WITH KEY MATNR = W_MARA-MATNR. 40 SY-VLINE. /1 SY-VLINE. ENDIF. 2 W_MARA-MATNR . SELECT MATNR SPRAS MAKTX FROM MAKT INTO TABLE I_MAKT FOR ALL ENTRIES IN I_MARA WHERE MATNR = I_MARA-MATNR AND SPRAS = 'E'. ENDIF. WRITE :/1 SY-VLINE. ****MOVING VALUES IN TO FINAL INTERNAL TABLE ************************** LOOP AT I_MARA INTO W_MARA. 40 SY-VLINE. ENDAT. 42 W_MARA-ERNAM. 62 'MATERIAL TYPE'. 100 SY-VLINE.

WRITE : /1 SY-VLINE. W_MARD-WERKS. W_MARA-MTART. 60 SY-VLINE. 82 W_FINAL-MATKL. ENDLOOP. / SY-ULINE(200). CASE SY-LSIND. W_MARA-ERNAM.ENDON. 142 'LANGUAGE'. W_MARD-LGORT. W_MARA-ERSDA. 80 SY-VLINE. 160 SY-VLINE. 2 'MATERIAL NUMBER' . 2 W_FINAL-MATNR . 20 SY-VLINE. SY-ULINE(200). 200 SY-VLINE. 100 SY-VLINE. 140 SY-VLINE. 100 SY-VLINE. W_FINAL-MATNR = W_FINAL-ERSDA = W_FINAL-ERNAM = W_FINAL-MTART = W_FINAL-MATKL = W_FINAL-WERKS = W_FINAL-LGORT = W_FINAL-SPRAS = W_FINAL-MAKTX = APPEND W_FINAL W_MARA-MATNR. 162 'DESCRIPTION'. . 102 W_FINAL-WERKS. WHEN 1. ULINE 1(200). 200 SY-VLINE. WRITE :/1 SY-VLINE. W_MAKT-SPRAS. 120 SY-VLINE. W_MAKT-MAKTX. 62 W_FINAL-MTART. 62 'MATERIAL TYPE'. 60 SY-VLINE. 120 SY-VLINE. 42 W_FINAL-ERNAM. 22 'CREATION DATE'. ********AT LINE-SELECTION EVENT TRIGERING INTERACTIVE REPORTING.******* AT LINE-SELECTION. 42 'USER NAME'. /1 SY-VLINE. **DISPLAY OUTPUT IN NEW SCREEN AT LINE SELECTION BY USER MOUSE CLICK ** WRITE: / W_MARA-MATNR COLOR 2. 40 SY-VLINE. 20 SY-VLINE. 82 'MATERIAL GROUP'. 122 'STORAG LOCATION'. TO I_FINAL. 80 SY-VLINE. 75 'EXAMPLE INTERACTIVE REPORT'. W_MARA-MATKL. 22 W_FINAL-ERSDA. 40 SY-VLINE. READ TABLE I_FINAL INTO W_FINAL WITH KEY MATNR = W_MARA-MATNR SPRAS = 'EN'. 102 'PLANT NUMBER'.

Mouri Tech Solutions Description This is a demo application to download the data from the internal table of the application to a file in the application server. ENDCASE. 142 W_FINAL-SPRAS. Downloading files onto the Application Server By Vikram Chellappa. 140 SY-VLINE. 160 SY-VLINE. Here we have used “ZDOWNLOAD_APPL_DEMO” as the program name. / SY-ULINE(200). 200 SY-VLINE. Go to transaction SE38 to open ABAP editor and Type in the program name click the create button. CLEAR W_MARA-MATNR. Step by Step Guidance.122 W_FINAL-LGORT. Enter the Short Description for the program Select the Program type to be “Executable program” . 162 W_FINAL-MAKTX.

.Click on SAVE CHECK and ACTIVATE.

Give the path of the file which has to be uploaded Here we have the file in location “\USR\SAP\SRI\SYS\SRC\DOWN. Go to Transaction AL11 to see the SAP installation directories Find our directory double click .TXT file in the Presentation server and out put displayed on the list screen shows the data in the internal table.TXT” The drive name is taken as the default SAP installation drive. OUTPUT LIST SCREEN The data from the internal table is moved in to DOWN. Output File in the Application server.

Find our downloaded file in the directory and double click it .

WA_DEMO-REG_NO = '100001'. PARAMETERS: P_FNAME(128) TYPE C DEFAULT OBLIGATORY. IT_DEMO TYPE TABLE OF ST_DEMO. L_FNAME TYPE STRING .The Downloaded data is displayed SOURCE CODE REPORT ZDOWNLOAD_APPL_DEMO. ADDR(20) TYPE C.TXT' . WA_DEMO-NAME = 'ANAND'. L_FNAME = P_FNAME. '\usr\sap\SRI\SYS\src\DOWN. REG_NO(10) TYPE C. END OF ST_DEMO. DATA : WA_DEMO TYPE ST_DEMO. TYPES : BEGIN OF ST_DEMO. NAME(20) TYPE C.

And click on Save. . TRANSFER WA_DEMO TO L_FNAME. WRITE :5 'REG NUM'.37 'ADDRESS' .16 'NAME'. Step-by-Step approach in creating a Function Module By Sasidhar Reddy Matli. WRITE :/5 WA_DEMO-REG_NO.37 WA_DEMO-ADDR. ROBERT BOSCH 1. Give the function group name and short text. IF SY-SUBRC = 0. Open SE37 transaction. APPEND WA_DEMO TO IT_DEMO. APPEND WA_DEMO TO IT_DEMO. Save this function group as local object. WA_DEMO-REG_NO = '100002'. WA_DEMO-ADDR = 'CHENNAI'. 2. LOOP AT IT_DEMO INTO WA_DEMO. Go to Goto  Function groups  Create group. WA_DEMO-NAME = 'VIKRAM'. OPEN DATASET L_FNAME FOR OUTPUT IN TEXT MODE ENCODING DEFAULT. ENDIF.16 WA_DEMO-NAME. 3.WA_DEMO-ADDR = 'NAGARKOVIL'. ENDLOOP.

Press Enter. Then open the transaction se80 and select the „Function group‟ from the drop down list.4. Enter the function group name. . Right click on ZSSR and press activate. 5.

.6. Then you will get the following screen. 7. Press Enter. Go to the transaction se37 again and click on create.

Click on the Attributes tab and give the short text. 10. Now it will ask for the function group. 9. Enter the function group and give the short text. Type and Reference type of variables A and B. Click on the Import tab and enter the Parameter name. Press Save.8. .

Click on Exceptions tab and enter the Exception and short text for that exception. 12. Type and reference type of RES. .11. Click on Export tab and enter the Parameter name.

.13. Press syntax check button or Ctrl+F2. 14. Now click on the Source code tab and write the following lines as shown bellow.

15. 16. Press Enter. . Now press on Activate button or press Ctrl+F3.

Enter values for A and B. 18. . Now Press on Test button or Press F8. And press Execute or F8.17.

. 20. If you enter A value as 5.19. it will throw exception. The following screen will be displayed with result.

*structure declaration for performance measurement . Output with Exception.21. Displaying 3D Graphs in ABAP By Swarna S. Now create and enjoy more Function Modules. 22.S. REPORT Z_3DGRAPH. Tata Consultancy Services *Simple report to create graph in ABAP *using GRAPH_MATRIX_3D function module *The graph shows the performance of 3 companies for the Four *quarters of a single year *AUTHOR : Swarna.

wa_performance-q3 = 69. wa_opttable-options = 'P2TYPE = VB'. wa_performance-q1 = 78. APPEND wa_opttable TO it_opttable. wa_performance-q1 = 78. *appending values into the performance internal table wa_performance-company = 'Company A'. END OF ty_performance. append wa_performance to it_performance. q1 TYPE i. options(30) TYPE c. *calling the graph function module CALL FUNCTION 'GRAPH_MATRIX_3D' EXPORTING col1 = 'Quarter 1' col2 = 'Quarter 2' col3 = 'Quarter 3' col4 = 'Quarter 4' dim1 = 'In Percentage%' . wa_performance-q4 = 85. END OF ty_opttable. *Internal table and work area declarations DATA: it_performance TYPE STANDARD TABLE OF ty_performance. wa_opttable-options = 'TISIZE = 1'. q3 type i. wa_performance-q1 = 48. wa_performance TYPE ty_performance. q4 type i.TYPES: BEGIN OF ty_performance. wa_performance-q2 = 68. q2 TYPE i. CLEAR wa_opttable. APPEND wa_opttable TO it_opttable. wa_performance-company = 'Company B'. append wa_performance to it_performance. wa_performance-company = 'Company C'. append wa_performance to it_performance. *clearing the work areas CLEAR WA_PERFORMANCE. wa_performance-q4 = 70. wa_performance-q3 = 79. wa_performance-q4 = 80. company(15) TYPE c. *structure declaration for options table types : BEGIN OF ty_opttable. DATA : it_opttable type standard table of ty_opttable. wa_performance-q2 = 68. *appending values into the options internal table wa_opttable-options = 'P3TYPE = TO'. wa_performance-q3 = 79. *initialization event INITIALIZATION. APPEND wa_opttable TO it_opttable. wa_opttable type ty_opttable. *start of selection event START-OF-SELECTION. wa_performance-q2 = 48.

Capgemini Report ZTEST. q2(20) TYPE c . * SUBSCREEN 2 SELECTION-SCREEN BEGIN OF SCREEN 200 AS SELECTION-SCREEN BEGIN OF BLOCK b2 WITH PARAMETERS: q1(20) TYPE c . SELECTION-SCREEN END OF BLOCK b1. SUBSCREEN. * SUBSCREEN 1 SELECTION-SCREEN BEGIN OF SCREEN 100 AS SELECTION-SCREEN BEGIN OF BLOCK b1 WITH PARAMETERS: Field1(20) TYPE c. SUBSCREEN. . FRAME. Field2(20) TYPE c.set_focus titl TABLES data opts EXCEPTIONS others = 'X' = 'Company Performances' = it_performance = it_opttable = 1. Field3(20) TYPE c. Tabstrips on the Selection Screen By Sandipan Ghosh. FRAME. DATA flag(1) TYPE c. SELECTION-SCREEN END OF SCREEN 100.

q3(20) TYPE c . IF flag = ' '. mytab-activetab = 'BUTTON1'. IF screen-group1 = 'MOD'. ENDCASE. CASE sy-dynnr. MODULE init_0100 OUTPUT. mytab-activetab = 'BUTTON2'. LOOP AT SCREEN. ENDMODULE. ENDIF. ENDLOOP. MESSAGE s888(sabapdocu) WITH text-050 sy-dynnr. WHEN 'TOGGLE'. mytab-dynnr = 200. CASE flag. WHEN 1000. WRITE: / 'Field1:'. WHEN 100. WHEN 200. AT SELECTION-SCREEN. ENDCASE. WHEN 'PUSH1'. INITIALIZATION. END OF BLOCK mytab. ELSEIF flag = 'X'. mytab-activetab = 'BUTTON1'. MESSAGE s888(sabapdocu) WITH text-050 sy-dynnr. screen-input = '0'. WHEN ' '. mytab-prog = sy-repid. button1 = 'TAB1'. SELECTION-SCREEN END OF SCREEN 200.'Q1:'. ENDMODULE. mytab-dynnr = 100. ENDCASE. TAB (20) button1 USER-COMMAND push1. . * STANDARD SELECTION SCREEN SELECTION-SCREEN: BEGIN OF TABBED BLOCK mytab FOR 10 LINES. CASE sy-ucomm. / 'Field2:'. MODIFY SCREEN. flag = ' '. Field1. MESSAGE s888(sabapdocu) WITH text-040 sy-dynnr. MODULE user_command_0100 INPUT. mytab-dynnr = 100. WHEN 'X'. button2 = 'TAB2'. WHEN 'PUSH2'. SELECTION-SCREEN END OF BLOCK b2. screen-input = '1'. ENDCASE. CASE sy-ucomm. START-OF-SELECTION. flag = 'X'. TAB (20) button2 USER-COMMAND push2.'Q2:'. Field2. q1. q2. ENDIF.

Field3.'Q3:'. q3. Output: TAB1 TAB2 ./ 'Field3:'.

Capgemini Introduction: The purpose of this document is to briefly describe a development. Along with the report. even which will be the restricting criteria. which will dynamically retrieve data from database tables. there can be two ways of checking data from standard table / Custom table. based upon user input. Step2: Choose the fields which will be the selection criteria for data selection from settings > Fields for selection . The output will be displayed in simple report format. table name can be specified by the use or which field needs to be displayed can be put into selection screen. Conventional Method: The following section will briefly describe what are the steps followed to check data using Conventional method: Step1: Run transaction SE16 & put table name as selection criteria. it will also notify the user whether Primary / Secondary index is being used or not during data selection. also can be specified. Dynamitic select statements (Describe in this document).   Conventional Method (Using transaction SE16). Here.Dynamic SELECT Statement (Enhanced functionality of Transaction SE16 and Index Identifier) By Arnab Ganguly. In production system.

Put the selection criteria: Step3: Report will be displayed in the following format: .

Choose the desired output fields from Settings > Format list > Choose Fields. .

Step5: .The final report will be displayed: Step4: Number of entries in the table can also be checked using SE16 Transaction.

. Dynamitic select statements In this method we have written a program. filter criteria. which will take selection criteria dynamically (Table name. Run the report ZDYN_ALV (for source code.Whether the data selection is done using primary / secondary index can also be checked using transaction SE11 / ST05. display fields) and produce a report with single user intervention. click here). It will also display whether primary / secondary index is being used or not during data selection.

. Provide the selection criteria as below.Provide the field names for the selection criteria.

the server must be registered with SAP. Downloading report output to Excel using OLE By Lokesh Tripathi. EXCEL) from ABAP. ABAP keywords . This program will display data in a single step execution. Infosys Introduction In the following document we will be discussing how to download our report output into excel in the same format as in the SAP report output by using OLE concept.The output will be shown in the below format. When we are trying to access live system from remote location each step execution (Dialog step) is very time expensive. This program will reduce the steps taken to display desired data. Also it will analyze the particular select statement is optimized or not by specifying the Index.g. To address an OLE Automation Server (e.

p2. Basic form: CALL METHOD OF obj m. Basic form: CREATE OBJECT obj class. English is the default. The . Addition: LANGUAGE langu .ABAP keywords allow us to control the applications in the form of an OLE2 Automation Server from an ABAP program: The following ABAP key words control the applications: 1) CREATE OBJECT This command generates an object of the class “class”. The object obj must be of type OLE2_OBJECT.. = f Stores the return value of the method in the variable f. Addition: NO FLUSH 4) CALL METHOD The ABAP key word CALL METHOD calls the method m of the object obj... pn = fn It passes values of fields to the parameters of the method. 2.. EXPORTING p1 = f1. Addition: NO FLUSH. 3) GET PROPERTY This command copies the property p of the object obj to the field f.. If no specification is made.The addition NO FLUSH continues the collection process.Thus we can set series of properties in a single transport operation. p1. Basic form: GET PROPERTY OF obj p = f. even if the next command is not an OLE statement. the field fld. m can be a literal or a variable. This creates the instance for the automation object at the automation interface. followed bythe position number of the parameter. Additions: 1. must begin with "#".determines the language chosen for method and attribute names of the object class. If assignment of parameters is by sequence. Basic form: SET PROPERTY OF obj prop = fld. 2) SET PROPERTY This command sets the property prop of the object obj according to the contents of object obj must be of type OLE2_OBJECT.

STEP 1: First step is to create OLE object for excel application. Now let understand the concept of OLE by taking one example.APPLICATION'. gh_excel is the object of type ole2_object. CREATE OBJECT gh_excel 'EXCEL. 3. . The object can then no longer be processed. The type-pool “ole2” defines the handle variable data of the type ole2_object. 5) FREE OBJECT This will releases the storage space required for the object obj. Before starting with OLE. NO FLUSH.The exporting parameters always come at the end of the statement. Suppose we want exactly this type of output in excels.For all the OLE automation programs “OLE2INCL” include should be used. Note that for each OLE object there has to be a variable holding handle data for that object. include type pool ole2 in your program.

It will print “Monthly_Bill” in the 7 column of the 1 row of excel. The excel sheet is not visible to the user while data transfer. Similarly you can create many number of sheets in excel. “Transferring data to row = i and “For handling automation error. PERFORM err_handle. Now create active sheets of excel. gh_mapl is the object of type ole2_object. SET PROPERTY OF sheet 'Name' = 'sheet_name'.STEP 2: Now different properties of the excel object is to be set as per our requirement. CALL METHOD OF sheet 'Activate'. Sheet is the object of type ole2_object. th st CALL METHOD OF gh_excel „CELLS‟= gh_zl NO FLUSH EXPORTING #1 = i #2 = j. FORM fill_cell USING i j bold val. STEP 3: Now fill the data part into excel. Here we had used the form “FILL_CELL” for filling the data into the cells. We will first fill the header part in excel. . SET PROPERTY OF gh_excel „visible‟ = 0. “For filling data in excel. column = j. “Activate the sheet. It will create a new workbook. CALL METHOD OF application 'Worksheets' = sheet EXPORTING #1 = 1. CALL METHOD OF gh_excel 'Workbooks'= gh_mapl. This will call the method of excel „Workbooks‟ to get the control to object gh_mapl. PERFORM fill_cell USING 1 7 1 „MONTHLY_BILL‟. CALL METHOD OF gh_mapl 'Add'= gh_map.

Val = text you want to print . 0 then normal text will be printed in excel. “Transferring data to 4th row and 3rd column.. PERFORM fill_cell USING 4 4 1 „Cost‟. Similarly fill all the header details in excel. “Transferring data to 3rd row and 2nd column.e. No‟. “Transferring data to 4 row and 1st column. “Transferring data to 4th row and 2nd column.SET PROPERTY OF gh_zl „VALUE‟ = val no flush. Here " fill_cell i = excel row number.) .e. Bold = 1 then text will print in Bold. i. column from B1 to E1. SET PROPERTY OF gh_f „BOLD‟ = bold no flush. PERFORM fill_cell USING 4 5 1 „Bill‟. etc. PERFORM fill_cell USING 4 1 1 „S. “Transferring data to 4th row and 4th column. PERFORM fill_cell USING 3 2 1 WA_OUTPUT-PEIOD. STEP 4: In this scenario we want some columns to be merged in our excel output. th PERFORM fill_cell USING 4 2 1 „Customer Name‟. row and 2 nd st “Transferring data to 2 nd column. i. PERFORM fill_cell USING 2 2 1 „COMPANY‟. J = excel column number. PERFORM fill_cell USING 4 3 1 „Duration‟. PERFORM fill_cell USING 2 1 1 „VODAPHONE‟. GET PROPERTY OF gh_zl „FONT‟ = gh_f no flush. ENDFORM. “Transferring data to 4th row and 5th column. “Transferring data to 2 nd row and 1 column. After filling the header part fill all the line item details in excel. (column from A1 to E1.

And then merge the range of cells. To delete some line from the excel. this will set last 1st row 4 column CALL METHOD OF gh_excel 'Cells' = wf_cell_from1 EXPORTING #1 =1 #2 = 4.  To set the width of the column according to the text.  To change the format of some cells in excels. CALL METHOD OF application 'COLUMNS' = COLUMN. CALL METHOD OF gh_excel 'ROWS' = row Exporting #1 = 1. Set last 3 row 4 column. CALL METHOD OF row 'DELETE'. for this first we select the range of cells. CALL METHOD OF gh_excel „RANGE‟ = gh_rang NO FLUSH EXPORTING #1 = „A1‟ #2 = „E1‟ CALL METHOD OF gh_range „SELECT‟ NO FLUSH. then can call this method.Now. For doing this first set the ranges of the cell we want to format and then change the format of these cells. CALL METHOD OF COLUMN 'AUTOFIT'. SET PROPERTY OF gh_range „MERGE‟ = 1 no flush. Free object row. For e. rd th th . STEP 5: Now format the excel according to the requirement.g. CALL METHOD OF gh_excel 'Cells' = wf_cell_to1 EXPORTING #1 = 3 #2 = 4.

SET PROPERTY OF gh_borders 'LineStyle'= 1. export with 11. For right edge border. For bottom edge border. For Left edge border. CALL METHOD OF gh_excel „RANGE‟ = gh_range NO FLUSH EXPORTING #1 = „A1‟ #2 = „M‟. This will set the grid lines in excel like this.  To have grid lines in our excel output. export with 8. set the line style to 1. Similarly we can call this method for other positions. For this first set the ranges of the column. For inside horizontal border. export with 9. range here. Now set the style of all the border position. For inside vertical border. export with 12. ”Here we are setting to this format.Set the CALL METHOD OF wf_excel 'Range' = wf_cell1 EXPORTING #1 = wf_cell_from1 #2 = wf_cell_to1. Now Format the range of cells SET PROPERTY OF wf_cell1 'NumberFormat' = ‟@‟. export with 10. CALL METHOD OF gh_range „Borders‟ = gh_borders EXPORTING #1 = 7. For top edge border. NO FLUSH “starting from column A “up to column M here .

SET PROPERTY OF e_color 'ColorIndex' = 35. CALL METHOD OF gh_excel „Cells‟ = e_cell EXPORTING #1 = 1 #2 = 3 GET PROPERTY OF e_cell 'Interior' = e_color.Suppose we want to change the color and width of any particular column. Now Save excel spreadsheet to particular filename and quit the excel application. Free object column.xls' "name of excel #2 = 1. CALL METHOD OF sheet 'SaveAs' EXPORTING #1 = 'c:\your_excel. SET PROPERTY OF e_cell 'ColumnWidth' = 20. i. STEP 6: At last free all the reserved OLE objects. Free object gh_excel. Codes for different colors.e. "file format .

This closes the Excel document SET PROPERTY OF application 'visible' = 0. Inside the local class the necessary method from the global class can be called for testing. ABAP Unit is a tool for unit testing of ABAP programs. How to write these tests: ABAP unit is based on ABAP objects. function modules or classes for bugs then we can do it using ABAP Unit. These test classes can be written inside the program for which the test is to be done. ENDCLASS. Ex: CLASS mytest DEFINITION FOR TESTING. METHODS mytest FOR TESTING.CALL METHOD OF sheet 'QUIT'. Methods in CL_AUNIT_ASSERT for Testing:       ASSERT_EQUALS ASSERT_DIFFERS ASSERT_BOUND ASSERT_NOT_BOUND ASSERT_INITIAL ASSERT_NOT_INITIAL . The global class CL_AUNIT_ASSERT contains methods which can be used for testing . If we want to check one particular module like subroutines. YASH Technologies Introduction: It is a best practice to modularize our programs as much as we can for better programming. Now our data get saved into excel naming „your_excel‟. It will close visible excel window and data is lost if not saved. Difference between Ordinary class and Test class: Both the test class and test method should have FOR TESTING addition.Tests are implemented in local classes. Understanding "ABAP Unit" By Nithya Murugesan. It will not affect our production code in anyways. PRIVATE SECTION.

Actual result .checks for the specific value of SY-SUBRC.Tolerance level for F 0 .     ASSERT_CHAR_CP ASSERT_CHAR_NP ASSERT_EQUALS_F FAIL ABORT ASSERT_EQUALS .Expected Result . The parameters of the method: ACT EXP MSG LEVEL QUIT .Fatal Quit: .Checks the equality of two data objects.checks for the validity of the reference of a reference variable.Message to be displayed in the result . flow level is controlled using this (NO/METHOD/CLASS/PROGRAM) TOL Levels:    .Critical 2 . ASSERT_NOT_INITIAL .If the test fails.checks whether the data object is not having its initial value.checks whether the reference of a reference variable is invalid.Checks for the difference of two data objects. ASSERT_DIFFERS .Error level (Tolerable/Critical/fatal) . ASSERT_BOUND . ASSERT_INITIAL . ASSERT_SUBRC . This method can be used for checking equality of two data objects.Tolerable 1 . ASSERT_EQUALS: ASSERT_EQUALS is one of the methods in the class CL_AUNIT_ASSERT.

Difference = Expected Result . "math DEFINITION *----------------------------------------------------------------------* * CLASS math IMPLEMENTATION *----------------------------------------------------------------------* * *----------------------------------------------------------------------* .Actual result. In the test method implementation we have called the factorial method and so the data object RESULT is populated. In this program. We want to test the factorial method. *----------------------------------------------------------------------* * CLASS math DEFINITION *----------------------------------------------------------------------* * *----------------------------------------------------------------------* CLASS math DEFINITION.9999. > tolerance. For that we are calling the ASSERT_EQUALS from the global class passing the expected result. ENDCLASS. Ex: Actual result – 24. we have two methods divide and factorial in a local class MATH. = 1 Therefore displays an error. Example Program: Let us consider an example for ABAP unit test using the method ASSERT_EQUALS to check the equality of two data objects. Program ( 3 ) – abandon execution of all test classes for the tested program. PUBLIC SECTION. Tolerance – 0. Now we are going to compare the actual data object (RESULT) with the expected result. Tolerance: If the tolerance limit specified is exceeded then error is shown. Method ( 1 ) – It will interrupt the current test method Class ( 2 ) – It will interrupt the current test class. METHODS divide IMPORTING opr1 TYPE i opr2 TYPE i EXPORTING result TYPE f RAISING cx_sy_arithmetic_error. Expected Result – 25.    No ( 0 ) – It will continue the current test Method. METHODS factorial IMPORTING n TYPE i RETURNING value(fact) TYPE i. So we have created one class and one method MYTEST for testing.

fact = 1. result = w_obj->factorial( 4 ). IF n = 0. DO n TIMES. CREATE OBJECT w_obj. ENDMETHOD. "mytest DEFINITION *----------------------------------------------------------------------* * CLASS mytest IMPLEMENTATION *----------------------------------------------------------------------* * *----------------------------------------------------------------------* CLASS mytest IMPLEMENTATION. fact = fact * sy-index. CREATE OBJECT w_obj. RETURN. ELSE. DATA w_obj TYPE REF TO math. text = res. "factorial ENDCLASS. WRITE :/ 'The result for factorial is:'. ENDIF. ENDTRY. cl_aunit_assert=>assert_equals( act = result exp = '24' msg = 'Factorial Not calculated Correctly' . METHODS mytest FOR TESTING. DATA result TYPE i. DATA res TYPE f. COMPUTE result = w_obj->factorial( 4 ). text = exc->get_text( ). CATCH cx_sy_arithmetic_error INTO exc. TRY. ENDDO. DATA exc TYPE REF TO cx_sy_arithmetic_error. ENDCLASS. MESSAGE text TYPE 'I'. result = opr2 / opr1. METHOD divide. "math IMPLEMENTATION START-OF-SELECTION. *----------------------------------------------------------------------* * CLASS mytest DEFINITION *----------------------------------------------------------------------* * *----------------------------------------------------------------------* CLASS mytest DEFINITION "#AU Risk_Level Harmless FOR TESTING. w_obj->divide( EXPORTING opr1 = 32 opr2 = 4 IMPORTING result = res ). WRITE : res. DATA text TYPE string. ENDMETHOD.result. METHOD mytest. "divide METHOD factorial. CREATE OBJECT w_obj.CLASS math IMPLEMENTATION. "#AU Duration Short PRIVATE SECTION.

then Unit test does not find any errors.999' ).ENDMETHOD. Program -> Test -> Unit Test. Class -> Unit Test. Function Module -> Test -> Unit Test. For Function Module. In that case one message will be displayed on status bar like. level = '0' quit = '2' tol = '0. Result of Unit Test: If both the actual and the expected result is same. "mytest "mytest IMPLEMENTATION Executing Unit Tests: For program. If it finds errors then a result will be displayed as follows: . For class. ENDCLASS.

. While creating the variant. ABAP Unit results in Code Inspector: We can see the ABAP unit results in code inspector.The task is displayed in a tree structure with a Program name. Also in the stack it will be displaying the line number where the error occurred. By double clicking the line number we can enter into the source code. Class name and method name. check for the ABAP unit in Dynamic check. Both the expected and the actual results can be seen in the Unit test results.

.In the Code inspector results we can check for the ABAP unit errors. warnings and informations.

This improves the quality of software written in ABAP. Assertions Break-points The one which actually does not checks the errors but is used to log the data that u want is LOG-POINT. Assertions syntax as per the SAP Library that is to be used in the coding is as below: ASSERT [[ID [FIELDS field1 CONDITION] log_exp. Assertions are invoked at run time.20 that is totally dedicated to ensuring program correctness and maintainability. Yash Technologies The checkpoints are the type of statements introduced in the SAP Web Application Server (SAP WebAS) 6. Assertions can be left in code when promoted to production with no impact to the code. group field2 [SUBKEY table1 subkey]] table2. They are only invoked if the checkpoint group is activated..Understanding "Checkpoint Group" By Richa Tripathi.] Assertions are used as a high quality means of problem determination in the case of code failure. 2. These checks are transportable and can be transported . . The checkpoint groups can be activated through the transaction SAAB and that is referred by ID in the programs with assert statements. This is the transaction below SAAB where in the checkpoint group we can create the group ID.. They can be made active or inactive.The transaction that takes care of these checkpoints and the place where they are maintained is SAAB. The Checkpoints now can be created for break-points and checkpoints and the two statements for this are 1. To start with step by step explanation of the checkpoints we start first with the Assertions.

The User when clicked there you can define the Specific users for it as this… And similarly it can be done for specific Servers on clicking on the add Sign as below: . Personal Activation User Level activation Server Level Activation. 2.Clicking on the create button below the Name we get to the below screen. 3. In the personal level activation that checkgroup will be active for the current user only and for the User the Checkgroup will be active for that user that has been defined and same is for the Server. Now the checkgroup activation can be done with three levels 1.

Without the addition ID. The log text is the text which you can specify for the system log which is seen in the logs getting created. Inactive then that particular statement will be ignored and if break then in the program wherever the statement occurs the program gets into debugging. During background processing the program execution is not interrupted. An inactive breakpoint is ignored. the entry "Breakpoint reached" is written to the system protocol under which the program name and the location of the breakpoint in the program are recorded. If the program reaches a breakpoint. The Statement as per the SAP Library that goes with this in the Program is as below… BREAK-POINT | [log text] }. Now taking for the assertions… Following are the ways the assertion can be used:   Inactive (default): statement is ignored Log: occurrence is logged Abort: program terminates with runtime error ASSERTION_FAILED { [ID groupID] The below two options come with a pop-up having options as:- .As for the screen below:- There are three things that can be controlled with the checkgroups. The breakpoints can be made active or inactive. the breakpoint is always active. Ex. BREAK-POINT ID YH_check.

2. *data : max type i. DO NOT use an assertion in the place of exceptions. ** Parameters Declarations PARAMETERS: p_carrid LIKE sflight-carrid. When an assertion is invoked. Here is a sample program where the LOG-Points and ASSERTIONS are used. max TYPE i. The Assertion RULES: 1. 3.. END OF type_s_sflight. it should create a log entry unless and until there is a compelling reason to terminate with a run time error. .. REPORT yh1316_test_checkgrp. Assertions should only be used on custom code rather than on standard codes. below two options come as this. Break/Abort: program is interrupted and starts the debugger / like ABORT mode in background. price TYPE sflight-price. fldate TYPE sflight-fldate. *Types Declarations of sflight TYPES : BEGIN OF type_s_sflight. carrid TYPE sflight-carrid.  Break/Log: program is interrupted and starts the debugger / like LOG mode in background. batch etc.. connid TYPE sflight-connid. Exception handling should always be used to trap and handle failures. batch etc.

IF p_carrid IS INITIAL. IF sy-dbcnt < 4. ASSERT ID yh1316_check SUBKEY 'YH1316_parameter_if_initial' FIELDS p_carrid t_sflight fs_sflight-carrid fs_sflight-connid fs_sflight-fldate fs_sflight-price condition p_carrid eq 'LH' . WRITE: fs_sflight-connid. fs_sflight-fldate.*Field String Declarations for sflight DATA: fs_sflight TYPE type_s_sflight. fs_sflight-price. . ASSERT ID yh1316_check SUBKEY FIELDS p_carrid t_sflight CONDITION p_carrid EQ ‟LH‟. EXIT. SELECT carrid connid fldate price FROM sflight INTO fs_sflight. DATA yh1316_subkey TYPE char200. 'YH1316_2' / fs_sflight-carrid. APPEND fs_sflight TO t_sflight. ELSE. ASSERT ID yh1316_check SUBKEY 'YH1316_1' FIELDS p_carrid t_sflight CONDITION p_carrid EQ 'LH' . SELECT carrid connid fldate MAX( price ) AS max INTO CORRESPONDING FIELDS OF fs_sflight FROM sflight WHERE carrid EQ p_carrid GROUP BY carrid connid fldate ORDER BY carrid max DESCENDING. *Internal table for Sflight Data DATA : t_sflight LIKE STANDARD TABLE OF fs_sflight. ENDSELECT. APPEND fs_sflight TO t_sflight.

Variant can be created as a Local as well as at a user level. WRITE: / fs_sflight-carrid. fs_sflight-fldate. . ENDIF. ENDIF. A variant is created for the Particular Checkgroup created. ENDSELECT. fs_sflight-max.LOG-POINT ID yh1316_check SUBKEY 'LOG_POINT' FIELDS p_carrid t_sflight fs_sflight-connid fs_sflight-fldate fs_sflight-max. Click on create and enter the following entries. Here it is created at the User Level. fs_sflight-connid.

3. 2. Don‟t forget to activate the variant.There are four kind of object type for which a variant can be created as 1. Logpoint and Assert. . 4. Check Group Program Class Function Group And for particular Object type the Different options can be given for Breakpoint. Now save the variant and then go back to the checkgroup for which we have created the variant. The Options for them are same as stated before in the Personal Activation screen for check group.

The log will also be created for the LOG-POINT statement and the SUBKEY there defines the Key to distinguish that the log has been created for which Assertion and checkpoint.As above it is seen the Local variant is visible in the Variants tab the same way we can create a Global variant also. 2. . Gropu/Subkey/Program/Procedure Group/Program/Procedure/Subkey The log seen is like this. In the Log the data is segregated according to the two Hierarchies:1. Now run the Program. If the assertion condition is violated the listed logs are created for the assertion as we have selected the log for assertion in the SAAB transaction in the Check Group.

.Double clicking on the Line where the Include line number is seen we can see the description of the log as below.

As we have logged the table entries also double clicking on the table we can see the table entries too. .

.

Coverage Analyzer is a function for monitoring the system-wide execution of ABAP programs.Understanding "Coverage Analyzer" By Tanveer Zahaque. Developer can use this tool to trace programs for development purpose and Quality Manager can use this tool to check system performance for quality assurance. In a nut-shell. Moreover it helps get summarized information of number of program executions. function-modules and methods. number of program . subroutines. It helps carry out a range of Administration Settings and the Monitoring Activity. It enables the success of test activities to be assessed for quality checks. users and functional areas. Powerful filtering system in Coverage Analyzer facilitates developer to enter the number of calls separately according to periods. It also provides an overview of the use of programs for development purposes. YASH Technologies Coverage Analyzer is a very powerful runtime analysis tool provided by SAP that enables an ABAP developer to monitor processing blocks such as reports. number of runtime errors.

To check user authorization. Display   Global. user has to have an appropriate role. Call up transaction SUIM (User Information System). rather simply going through documentation. Broadly. Detail. functions of Coverage Analyzer are classified into two. Settings. Reset. Fascinatingly.resets. Administration Settings        2. A simple exercise will help us easily understand Coverage Analyzer. Registrations. 1. Test Groups. On/Off. each user-group can contain any number of users under one test key. In order to make use of Coverage Analyzer. Monitor. . Consistency Checks. Expand Authorizations node. the results can be formatted separately according to user-group. Choose By Object and execute it (press F8).

Confirm the where-used list for profiles using icon or Ctrl+Shift+F11. Let‟s start up with a simple example to understand Coverage Analyzer in a better way: STEP 1: Call up the transaction SCOV or navigate through SAP Easy Access->SAP Menu->Tools>ABAP Workbench->Test->SCOV (Coverage Analyzer). user can proceed further. Once user authorization is checked to have absolute access to SCOV (Coverage Analyzer) transaction. Basis consultant has to be consulted in this regards. a tip to be remembered is that Coverage Analyzer tool should be used on weekends or in the evening.Check the presence of authorization object S_COV_ADM in the system. If a role is not assigned to a user. system needs all packages and users to be in the passive mode. In fact. . Since backup server collects data from all the servers including local and remote. when all users and packages are on loose ends.

. Coverage Analyzer administration includes all of the functions required for carrying out settings and checks.General Status of the system is shown on the right hand pane of the window.

Count1 Absolute Value > Count2 Absolute Value > 0. Having not made settings for backup server. In order to make settings.Administration and Display nodes are shown on the left pane of the window. Tip to remember: A program is regarded as tested if the following conditions are fulfilled. STEP 2: Before the Coverage Analyzer being switched on. and to filter the programs to be checked via the package. Expand Administration node. Settings function is used to set the parameters for the Global and Detail views. if Coverage Analyzer is started. . it simply throws out an information message to maintain background server for data collection. So. settings have to be maintained for backup server and filters are to be set. Administration settings are to be done before starting up the Coverage Analyzer. switch settings to Change Mode (Cntrl+F1). select Settings. 0.

If this restriction is not applied. 0. Count1 and RABAX1 indicate the number of programs executed and runtime errors since the Coverage Analyzer was started.RABAX2 Absolute Value Unicode Check = = 1. which can be set according to developer‟s way of analysis. lights provide a visual means of representing the status of the results for the degree of coverage in the Global and Detail views. Checking Unicode is to mark it as „X‟. RED YELLOW 0 LT 33 % 33 LT 66 % GREEN 66 LE 100% . Count2 and RABAX2 indicate the number of programs executed and runtime errors since the last reset. Lights are set by default. If ABAP programs with a set Unicode flag are only to be traced by the Coverage Analyzer. then select Unicode checkbox. else leave it unattended. all of the programs are included together with those from local packages ($*) and programs generated locally without packages ( ). the evaluation for the Global view is only performed for this package. When a package is pre-selected. assign package to be used during analysis. Further. It‟s optional to set the lights.

the higher the trace level. which can be modified based on developer‟s way of analysis. Summarization function facilitates checking the same processing blocks in several systems simultaneously. Local Degree of coverage Summarized degree of coverage LE LE 100%. The defaulted value for Data Collection: Period (Min) is 30 mins. the more information is drawn for debugging. There are 4 different trace levels (1-4). 100%. Tip to remember: The results from the individual systems are local and those from the remote systems are summarized. Monitor Settings have to be done. To determine RFC connection with current server. call up transaction SM59->RFC Destinations->R/3 Connections->E6SCLNT900. Tip: The values for Maximum Entries Log and Maximum Entries Data Monitor limit the lines displayed for the General Log and Monitor Data Volumes in the monitor function. Moreover. In this case. which includes setting Trace Level and Maximum Entries Log and Maximum Entries Data Monitor.Further. Background server has to be specified. . current server is specified as Background server. where precisely data is to be collected. The defaulted lines for log file are 100 and for data volume are 200. Further. Local Degree of coverage GE Summarized degree of coverage. the period for which background job has to be repeated is also to be specified.

moreover period and start time for summarize data can also be specified. . Finally. GREEN signifies server to be in switched-on mode and YELLOW represents either RFC problem or database and shared memory inconsistency. Switch Coverage Analyzer On/Off: This displays the number of programs that have been initialized.Desired RFC connections in Summarize coverage results can be specified. Switch Data Aggregations from Different Remote Systems: This displays background server and all of the other systems whose results are used for Data-aggregation. save the Settings. Status in the Administration node and start up the Coverage Analyzer. If the server is in switched-off mode exception shows RED signal. STEP 3: Choose On/Off. In this case. we‟ll proceed without switching on Switch Automatic Recording On/Off. Switch Automatic Recordings On/Off: This displays the automatic recording period and the version number for the Global view.

COND – Coverage results on the local system as well as remote system. . STEP 4: Create Test-Groups. In this case. Two pre-defined Test-groups are always available. only users assigned a role with the authorization object S_COV_ADM are allowed to define group. Tip to remember: Test-groups should not be created more than 10. click Append Row icon provided in the application tool-bar. then save it. Define a Test-group following Y/Z naming convention. To create a test-group. Test-Groups are made to summarize and display the results of the Coverage Analyzer for a particular set of users under one generic key/heading. Moreover. switch on the Change Mode. we create a test-group.The servers which are actually running are shown as flagged up. ALL – Coverage results summarized for all test groups on the local system.

comparison of performance of test-groups can be done in Global view. explicitly this function is intended for situations in which the results of the previous analyses are no longer required. click Append Row icon provided in the application tool-bar. for example. STEP 6: An optional function to be done is Reset. To assign Users to a test-group. Tip: A test-group can contain any number of users. switch on the Change Mode. That makes filtering pretty easy.STEP 5: Next step is to assign users to the just-made test-group. Select desired test-group for which users have to be assigned. all HR developers in one group. Moreover. It resets all the counters of the Coverage Analyzer to 0 for all the programs of a selected group. in this case we assign SAPDEV02 as user to test-group ZTST. .

implicit reset is carried out automatically as soon as the flow or the data of a program changes. . before proceeding to actual analysis. STEP 7: Consistency check has to be done for all the servers including remote ones. If this is not the case. Check Status of Background Jobs checks whether all the batch jobs of the Coverage Analyzer are activated. Check Status of All Servers checks whether the status in the shared memory matches the status in the database. an information message is popped-up. After successful reset.Further more. the batch jobs are all rescheduled by means of the Repair function.

GREEN indicates Information message. Tip: Every time inconsistencies are checked. which will going to turn yellow signal to green signal. In the present case. there arise any warning or error messages. General Log should be refreshed. Repair function also bridges the gap between activating and generating a program. . in order to check inconsistencies. check the types of inconsistencies accordingly and Execute Checks. General Log gives general information. In case. So. no inconsistencies have been found while starting All Servers. YELLOW indicates Warning message and RED indicates Error message. keep Cntrl key pressed.Check Table Consistency (Long Runtime) may become inconsistent if the Coverage Analyzer fails on an application server due to system error. and then choose monitor to check for the inconsistency messages. while Monitor Volume gives detailed information of started server. select the row and hit Completed. Once the warning is attended. those problems are to be fixed and then select particular row of the warning/error message and click Completed. To select more than 1 message.

percentage-based progress display over time cannot be seen for selected SAPDEV02 author. If ‘Other view’ is selected as Package. the following way. Views can be based on Author or Package.STEP 8: Display. then selection is done accordingly. Note: Since Automatic Recordings were not switched on. . Display gives high-level view. gives coverage results at author or package level according to criteria you select under Settings. Normally. ALL signifies all the authors on local system based on view given and the COND (y/z test groups) signifies all the authors on both local and remote systems based on view given. Display view gives Quality Managers to view the system.

26% have been executed since start of the coverage analyzer. In the example above you can see that currently 98% of the processing blocks in the system belong to a program that has the Unicode flag set.Unicode: This value indicates how many percent of the processing blocks have the Unicode flag set (the flag itself is set per program) Capacity Utilization: This value is computed as the ratio of used processing blocks to loaded processing blocks to loaded processing blocks. 9% have been executed in the active version without errors and the capacity utilization is 29%. Accumulated Executions (Percent) This value indicates in percent how many processing blocks have been executed since the start of the Coverage Analyzer. . Tested processing blocks (Percent) This value indicates in percent how many processing blocks have been executed in the actual version without runtime errors.

STEP 9: Exact Value Table can be viewed for author SAPDEV02. which displays number processing blocks for author SAPDEV02 on timely manner. Graphical view of the selected row can be seen using individual date and all dates when no row is selected. that displays graphical view of the Individual selection for graphical analysis. icon. . All rows selected for graphical analysis.

Details give low-level view. . Strong filtering options allow user to select on what conditions results are to be displayed.Tip: Moreover. STEP 10: Details view. previous saved history can also be viewed for the specific user. gives summarized and detailed results.

Defaulted access-via is Program Object. packages and authors pertaining to those test-groups. test-group ZTST and Author SAPDEV02 is taken as single-value selection. which gives results pertaining to specified criteria. In the present example. Package and Author. other filters can also be set and settings should be done defining access via Package Object.Conditions can be set for range of test-groups. Moreover. .

double-clicking the object name will navigate to the particular program or executing block where exactly error has been found. hit execute button. number of processing blocks. . including number of calls made to that particular object. Once settings are done.Hitting Standard Settings is going to reset all the values. that is going to get detailed information. Besides all the information given. load size in Kilo byte.

Code sample for developing FTP programs can be got from report program a) b) RSFTP002 RSFTP007 . runtime errors and program resets can be easily traced using this powerful ABAP runtime analysis tool . FTP file transfer in Background By Joffy John. many such program executions. of Program units currently used / Loaded Program units. The RFC destinations SAPFTP and SAPFTPA will be created automatically.Note: Current Executions = Program units currently used / Total no. of Program units. Run program: RSFTP005. Collabera 1) Creating RFC Destination for FTP. a) b) 2) SAPFTP (for local system) SAPFTPA (for running in Application server)(This is used for file transfer in background. Capacity Utilization = No. Conclusion: Likewise.Coverage Analyzer.

regio(50) TYPE c. TABLES: kna1. "Post Code / ZIP wrk_delim8 TYPE x .knb1. name2(80) TYPE c. name1(80) TYPE c. telf1 TYPE kna1-telf1. stras(80) TYPE c. ledgerkey(50) TYPE c. *&---------------------------------------------------------------------* *& Report ZCUSTOMER *& *&---------------------------------------------------------------------* *&-Customer -All new/changed customer records created during the period. kunnr(50) TYPE c. ort01 TYPE kna1-ort01. kunnr TYPE kna1-kunnr. pstlz TYPE kna1-pstlz. " Town wrk_delim6 TYPE x . *&---------------------------------------------------------------------* *LedgerKey-------------Char(50) *AccountName-----------Char(80) *AccountReference -----Char(50) *Address1 -------------Char(80) *Address2 -------------Char(80) *Town -----------------Char(50) *County / State -------Char(50) *Post Code / ZIP ------Char(20) *Country---------------Char(2) *AccountCurrencyCode --Char(3) *ContactTelephone -----Char(20) REPORT zcustomer. land1(2) TYPE c. END OF st_customer. "Country wrk_delim9 TYPE x . regio TYPE kna1-regio. ort01(50) TYPE c. name2 TYPE kna1-name2. TYPES: BEGIN OF st_customer. TYPES : BEGIN OF st_cus. " Address2 wrk_delim5 TYPE x . " County / State wrk_delim7 TYPE x . "Address1 wrk_delim4 TYPE x . waers(3) TYPE c. pstlz(10) TYPE c.c) 3) RSFTP008 Sample code for getting customer details as tab delimited . "AccountName wrk_delim2 TYPE x . stras TYPE kna1-stras. ledgerkey TYPE char50.TXT file in background. land1 TYPE kna1-land1. waers TYPE knvv-waers. "AccountReference wrk_delim3 TYPE x . "LedgerKey wrk_delim1 TYPE x . "AccountCurrencyCode . name1 TYPE kna1-name1.

IF creat_on-high IS INITIAL. wa_dat LIKE LINE OF it_dat. SELECT a~name1 a~name2 a~kunnr a~stras a~ort01 a~regio a~pstlz a~land1 a~telf1 "Details of the Customer based on KNA1. *&---------------------------------------------------------------------* *& Form CUSTOMER_DATA_SELECT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-. DATA: it_customer TYPE STANDARD TABLE OF st_customer. FROM kna1 AS a INNER JOIN knb1 AS b ON a~kunnr = b~kunnr INTO CORRESPONDING FIELDS OF TABLE it_customer WHERE a~kunnr IN cust_no AND ( ( a~erdat IN creat_on OR a~updat IN creat_on ) OR ( b~erdat IN creat_on OR b~updat IN creat_on ) ) AND a~land1 IN country AND b~bukrs IN com_code.p2 text *----------------------------------------------------------------------* FORM customer_data_select . IF sy-subrc = 0. ENDIF.wrk_delim10 TYPE x . START-OF-SELECTION. LOOP AT it_customer INTO wa_customer. ENDIF."customer no com_code FOR knb1-bukrs. ENDFORM. ENDLOOP. PERFORM ftp_file_customer.txt' INTO wrk_file. SELECT-OPTIONS:cust_no FOR kna1-kunnr. DATA: wrk_file TYPE char200. wa_customer LIKE LINE OF it_customer. CONCATENATE sy-mandt '_1_' creat_on-low '_' creat_on-high '_Cust. " CUSTOMER_DATA_SELECT *&---------------------------------------------------------------------* *& Form BUILD_TEMPLATE_DATA *&---------------------------------------------------------------------* * text ."company code country FOR kna1-land1. "country creat_on FOR kna1-erdat default sy-datum. creat_on-high = creat_on-low. SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-001. SELECT SINGLE waers FROM knvv INTO wa_customer-waers WHERE kunnr = wa_customer-kunnr. PERFORM customer_data_select. DATA: it_dat TYPE STANDARD TABLE OF st_cus. "Customer Data File PERFORM build_template_data. wa_customer-ledgerkey = '12345'.. MODIFY it_customer FROM wa_customer. "ContactTelephone END OF st_cus . "created or changed on SELECTION-SCREEN END OF BLOCK b2. telf1(20) TYPE c.

"ip address of FTP server l_dest LIKE rfcdes-rfcdest VALUE 'SAPFTPA'.*----------------------------------------------------------------------* * --> p1 text * <-. *HTTP_SCRAMBLE: used to scramble the password provided in a format recognized by SAP. APPEND wa_dat TO it_dat. SET EXTENDED CHECK OFF. l_slen = STRLEN( l_pwd ). wa_dat-wrk_delim6 = '09'. l_slen TYPE i. MOVE-CORRESPONDING wa_customer TO wa_dat. wa_dat-wrk_delim8 = '09'.1.p2 text *----------------------------------------------------------------------* FORM ftp_file_customer . ENDFORM."Background RFC destination DATA: w_hdl TYPE i.198'. "for adding tab after each field wa_dat-wrk_delim2 = '09'. "user name of ftp server l_pwd(30) TYPE c VALUE '1234'. wa_dat-wrk_delim7 = '09'. CALL FUNCTION 'HTTP_SCRAMBLE' EXPORTING SOURCE = l_pwd sourcelen = l_slen key = c_key IMPORTING destination = l_pwd.p2 text *----------------------------------------------------------------------* FORM build_template_data . c_key TYPE i VALUE 26101957. wa_dat-wrk_delim9 = '09'. * To Connect to the Server using FTP CALL FUNCTION 'FTP_CONNECT' EXPORTING user = l_user password = l_pwd host = l_host rfc_destination = l_dest IMPORTING handle = w_hdl . wa_dat-wrk_delim10 = '09'. LOOP AT it_customer INTO wa_customer. ENDLOOP. " BUILD_TEMPLATE_DATA *&---------------------------------------------------------------------* *& Form FTP_FILE_CUSTOMER *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * --> p1 text * <-. wa_dat-wrk_delim1 = '09'. "password of ftp server l_host(64) TYPE c VALUE '111. wa_dat-wrk_delim4 = '09'. wa_dat-wrk_delim3 = '09'.2. DATA: l_user(30) TYPE c VALUE 'ZTEST'. wa_dat-wrk_delim5 = '09'.

EXCEPTIONS OTHERS = 1. * To disconnect the FTP CALL FUNCTION 'FTP_DISCONNECT' EXPORTING handle = w_hdl. *RFC_CONNECTION_CLOSE:This is used to disconnect the RFC connection between SAP and other system. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 RAISING invalid_output_file.0" encoding="UTF-8" ?> <ZEU_MATMAS03> <IDOC BEGIN="1"> <EDI_DC40 SEGMENT="1"> <DOCNUM>0000000000038491</DOCNUM> <MESTYP>ZEU_MATMAS</MESTYP> . ENDFORM. CALL FUNCTION 'FTP_R3_TO_SERVER' EXPORTING handle = w_hdl fname = wrk_file "file path of destination system character_mode = 'X' TABLES text = it_dat EXCEPTIONS tcpip_error = 1 command_error = 2 data_error = 3 OTHERS = 4. " FTP_FILE_CUSTOMER On running this report in background a file will be created in ftp server location. CALL FUNCTION 'RFC_CONNECTION_CLOSE' EXPORTING destination = l_dest EXCEPTIONS OTHERS = 1.xml file. ENDIF. Converting an XML file with many hierarchy levels to ABAP format By Subhashini Kolluri. Save the XML file which in desktop or some other path <?xml version="1. IF sy-subrc <> 0. *FTP_DISCONNECT: This is used to disconnect the connection between SAP and other system. *FTP_R3_TO_SERVER:used to transfer the internal table data as a file to other system in the character mode. . IBM India This example shows how we can convert an XML file with many hierarchy levels to ABAP format. Copy and paste the following code in notepad and save it as test.

EDI_DC40 contains DOCNUM and MESTYP fields. E1MARAM contains E1MAKTM structure and MSGFN and MATNR fields.The main structure contains many deep structures. ZIDOC_TEST structure contains ZE1MARAM_TEST1 and ZEDIDC40 structures within.. ZEDIDC40 contains DOCNUM and MESTYP fields. In SAP we have to create corresponding structures to store this data from XML to ABAP. It contains IDOC structure which in turn contains E1MARAM and EDI_DC40 structures within.Control record with fields DOCNUM and MESTYP. . So in ABAP dictionary we first create the structure ZIDOC_TEST which contains Structures ZEDIDC40 and Z1EMARAM_TEST1. ZE1MARAM_TEST1 contains E1MAKTM structure and MSGFN and MATNR fields. This is the structure of ZEDIDC40 . The structures Z1EMARAM_TEST1 and ZEDIDC40 are also created as shown in the below slides.</EDI_DC40> <E1MARAM SEGMENT="1"> <MSGFN>004</MSGFN> <MATNR>000000000000010003</MATNR> <E1MAKTM SEGMENT="1"> <MSGFN>005</MSGFN> <SPRAS>E</SPRAS> <MAKTX>promo pack normal</MAKTX> <SPRAS_ISO>EN</SPRAS_ISO> </E1MAKTM> </E1MARAM> </IDOC> </ZEU_MATMAS03> Here we can see that the root node is ZEU_MATMAS03 which is the main structure containing all other structures.

SPRAS.Also a deep structure E1MAKTM.The structure ZE1MARAM_TEST1 contains the following fields MSGFN and MATNR. TYPE-POOLS abap.MAKTX and SPRAS_ISO. E1MAKTM Structure is a standard dictionary structure we are using directly with the fields MSGFN. The following ABAP program converts the given input XML file to ABAP format. .

. * For error handling DATA: gs_rif_ex TYPE REF TO cx_root. “ZIDOC_TEST END OF ts_zeu_matmas03. * Table for storing the XML content DATA: gt_itab TYPE STANDARD TABLE OF char2048. idoc TYPE ZIDOC_TEST. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. gs_var_text TYPE string. gs_zeu_matmas03 TYPE ts_zeu_matmas03. *Here it is saved in desktop. *Input file CONSTANTS gs_file TYPE string with path as constant VALUE 'C:\Documents and Settings\Administrator\Desktop\test1. for the data from the XML file structure we created in SE11 *This is the structure type TYPES: BEGIN OF ts_zeu_matmas03. from file * Table and work areas for the data from the XML file DATA: gt_zeu_matmas03 TYPE STANDARD TABLE OF ts_zeu_matmas03. * Get the XML file from your client CALL METHOD cl_gui_frontend_services=>gui_upload EXPORTING filename = gs_file CHANGING data_tab = gt_itab EXCEPTIONS file_open_error =1 file_read_error =2 no_batch =3 gui_refuse_filetransfer = 4 invalid_type =5 no_authority =6 unknown_error =7 bad_data_format =8 header_not_allowed =9 separator_not_allowed = 10 header_too_long = 11 unknown_dp_error = 12 access_denied = 13 dp_out_of_memory = 14 disk_full = 15 dp_timeout = 16 not_supported_by_gui = 17 error_no_gui = 18 OTHERS = 19. * Result table that contains references * of the internal tables to be filled DATA: gt_result_xml TYPE abap_trans_resbind_tab.XML file path where we saved the file.*Input file contents as string. gs_result_xml TYPE abap_trans_resbind.xml'.

0"> <xsl:output encoding="iso-8859-1" indent="yes" method="xml" version="1.Create it and after copying this code activate it.w3. Copy paste the following code in XSLT editor :Some rules which were applied for conversion to XSLT are:IDOC_GET is used to get the data from IDOC. the data table can be accessed with GET REFERENCE OF gt_zeu_matmas03 INTO gs_result_xml-value. * Perform the XSLT stylesheet TRY.sap.Use the corresponding path to access the values. <xsl:transform xmlns:xsl="http://www. The same type of structure which is used in our program needs to be filled. * Within the XSLT style * "IDOC_GET".In the XML file the main node is IDOC which has E1MARAM and EDIDC_40 which in turn contains MSGFN. CALL TRANSFORMATION z_xml_idoc SOURCE XML gt_itab RESULT (gt_result_xml).ENDIF. gs_result_xml-name = 'IDOC_GET'. After transformation the gt_zeu_matmas03 is filled which can be used for displaying. * Fill the result table with a reference to the data table.We should use the tags to be filled in the hierarchy structure as we declared it in the program. We use IDOC_GET to use the IDOC data. XSLT is a language is used to convert XML from one format to another format. sheet.org/1999/XSL/Transform" version="1.MATNR and E1MAKTM and EDIDC_40 contains MSGFN and DOCNUM respectively.To use the values we need to use the structures in the XML file.0"> <asx:values> <IDOC_GET> . APPEND gs_result_xml TO gt_result_xml.com/abapxml" version="1.0"/> <xsl:strip-space elements="*"/> <xsl:template match="/"> <asx:abap xmlns:asx="http://www. The basic template is already filled when we enter the XSLT editor.In our program EDIDC_40 is used as ZEDIDC40 and E1MARAM is used as ZE1MARAM_TEST1. In this part of the code Z_XML_IDOC should be created in XSLT Editor and write code for that as follows:We can go there by double clicking on Z_XML_IDOC.

<xsl:apply-templates select="//IDOC"/> </IDOC_GET> </asx:values> </asx:abap> </xsl:template> <xsl:template match="IDOC"> <item> <IDOC> <ZEDIDC40> <MESTYP><xsl:value-of select="EDI_DC40/MESTYP"/></MESTYP> <DOCNUM><xsl:value-of select="EDI_DC40/DOCNUM"/></DOCNUM> </ZEDIDC40> <ZE1MARAM_TEST1> <MSGFN><xsl:value-of select="E1MARAM/MSGFN"/></MSGFN> <MATNR><xsl:value-of select="E1MARAM/MATNR"/></MATNR> <E1MAKTM> <MSGFN><xsl:value-of select="E1MARAM/E1MAKTM/MSGFN"/></MSGFN> <SPRAS><xsl:value-of select="E1MARAM/E1MAKTM/SPRAS"/></SPRAS> <MAKTX><xsl:value-of select="E1MARAM/E1MAKTM/MAKTX"/></MAKTX> <SPRAS_ISO><xsl:value-of select="E1MARAM/E1MAKTM/SPRAS_ISO"/></SPRAS_ISO> </E1MAKTM> </ZE1MARAM_TEST1> </IDOC> </item> </xsl:template> </xsl:transform> *Come back to ABAP editor and copy this code for error handling. .

LOOP at gt_zeu_matmas03 INTO gs_zeu_matmas03. ENDTRY.So we have converted the given XML File to a structure and display the contents. / gs_zeu_matmas03-idoc-ze1maram_test1-e1maktm-spras. no type function fields of E1MAKTM / gs_zeu_matmas03-idoc-ze1maram_test1-e1maktm-msgfn.”material no *all on “document “message screen. ENDIF. ENDLOOP. WRITE: gs_zeu_matmas03-idoc-zedidc40-docnum.”message / gs_zeu_matmas03-idoc-ze1maram_test1-matnr.CATCH cx_root INTO gs_rif_ex. *Display the file contents IF sy-subrc = 0. gs_var_text = gs_rif_ex->get_text( ). MESSAGE gs_var_text TYPE 'E'. / gs_zeu_matmas03-idoc-ze1maram_test1-msgfn. / gs_zeu_matmas03-idoc-ze1maram_test1-e1maktm-maktx. . / gs_zeu_matmas03-idoc-ze1maram_test1-e1maktm-spras_iso. / gs_zeu_matmas03-idoc-zedidc40-mestyp. We can see the values filled in the heirarchy structure of IDOC as follows:- segment Execute the ABAP program and we get the file contents displayed as below.

6. Insertion Deletion Scrolling First Last Next Previous Select Select all Deselect Deselect all Step 1: Create an internal table and work area. 8. 10. 1. 9. 7. 4. Purpose of this tutorial: This is to demonstrate the step by step tutorial of how to make use of table control with wizard. which we are going to deploy in table control. IBM Pre-requisites: The readers must be able to create a module pool program and they should be familiar with screen programming. in which the users are not needed to code separately for table control operations. 2. where the developer‟s effort to write code with table control without wizard is avoided. 11. Introduction: Table control with wizard is the control provided by SAP. It generates automatically system generated code for the following table control operations. . 5.Final output of the program is:- Dialog Programming Table Control using Wizard in Module Pool Programming By Venkatraman N. 3.

Input the screen number as 9000. Fill up the screen attribute values. .Step 2: Create a screen called „9000‟.

where you can find the table control with wizard. Once you drag and drop the control a popup will appear. Drag and drop the table control with wizard to the layout of the screen. .Step 3: Go to the layout of the screen.

. In the next screen enter the table control name as „TBC_9000‟ or your own name. Then only this table control screen will take its properties.Press Continue. in which you have declared the internal table and work area. In the next screen you input the internal table and work area which has been created earlier. you must activate the page. Note: Before it is done.

that should not be selected in this screen. We have to select those fields. Select the input/output attributes as „Input control‟ and give the field for selection of table control rows. Select the multiple line selection. If you have declared any character field for table control line selection. which and all should be displayed in table control.The next screen will automatically retrieve the fields available in the internal table and show. .

Click on Continue. The table control with auto generated code will automatically be created. .

This will automatically create PBO & PAI modules for table control operations. .

The expected output will be like .Step 4: For testing this tutorial. write a simple query to populate the internal table of table control and test the input controls associated with it.

*&----------------------------------------------------------------- . 6. 4.Summary : As a result of this tutorial. Tata Consultancy Services Use table control with wizard in module pool programming and Create table control operations with system generated code. 3. 5. the user will be able to 1. Splitter Controls and Graphs By Swarna S. 2.

types : end of ty_col1_texts. data :CUSTOM_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER. types : end of ty_col2_texts.COM 10. types : begin of ty_col2_texts. INITIALIZATION. 49. 34. grvalwa1 type ty_grvalwa1. 29. 58. 28. MODULE PBO_0600 OUTPUT. *Call screen for the container for output 57. types : begin of ty_grvalwa1. 12.(Tata Consultancy Services) 9. *structure declaration for graph 2 values 35. START-OF-SELECTION. 15. * Published at SAPTechnical. 24. *Initialisation event 53. *& The sample code also describes creating graphs in ABAP. 36. COL1_TEXTS TYPE standard TABLE OF ty_col1_texts. 45. include structure gprval. *structure declaration for graph 1 values 22. 56. *&----------------------------------------------------------------* 62. data : grval2 TYPE standard TABLE OF ty_grvalwa2.7. 42. *structure declaration for graph 1 column names 26. 54. 27. *data declarations for graph 1 30. *PBO module for the output display 59. CONT2 type ref to cl_gui_container. include structure gprtxt. DATA: OK_CODE TYPE SY-UCOMM. 33. 31. 46. *OK code declaration 20. types : end of ty_grvalwa1. col2_wa type ty_col2_texts. include structure gprtxt. 21. SPLITTER TYPE REF TO CL_GUI_SPLITTER_CONTAINER. 14. data : grval1 TYPE standard TABLE OF ty_grvalwa1. 40. 17. *& Module PBO_0600 OUTPUT 61. *& Report Z_SPLIT_GRAPH 8. *structure declaration for graph 2 column names 39.S. *data declarations for graph2 43. COL2_TEXTS TYPE standard TABLE OF ty_col2_texts. 50. REPORT z_split_graph . CALL SCREEN 600. types : begin of ty_col1_texts. col1_wa type ty_col1_texts.and custom container 48. 38. 37. 51. 32. include structure gprval. *type pool declarations for graphical frame work 18. *& Author: Swarna. types : begin of ty_grvalwa2. CONT1 type ref to cl_gui_container. 23. *& AS : Sample code for creating a splitter screen and graph. 19.splitters. *& The screen is divided into two by splitter control and can be resized 13. *start of selection event 55. 47. TYPE-POOLS: GFW. 44. 52. *data declarations for containers. grvalwa2 type ty_grvalwa2. 25. 41. *&----------------------------------------------------------------11. *& Two graphs are drawn on the two splitter containers. . *&----------------------------------------------------------------* 60. types : end of ty_grvalwa2. *&----------------------------------------------------------------16.

grvalwa1-VAL2 = 6000. *Creating custom container CREATE OBJECT CUSTOM_CONTAINER EXPORTING CONTAINER_NAME = 'CONTAINER'. grvalwa1-VAL1 = 6000. 87. 104. 66. 81. 106. APPEND grvalwa1 to grval1. APPEND col1_wa to COL1_TEXTS. grvalwa1-val1 = 1100. 82. 89. 78. APPEND col1_wa to COL1_TEXTS. 90. 97. grvalwa1-val2 = 7000.63. 96. 70. 86. 68. grvalwa1-ROWTXT = 'Coffee'. 100. 80.Col1_texts. grvalwa1-VAL1 = 2000. 117. 88. grvalwa1-ROWTXT = 'Tea'. 99. 69. 105. grvalwa1-ROWTXT = 'Cereals'. 65. *Setting the GUI status for the splitter screen(EXIT button) SET PF-STATUS 'SPLITGRAPH'. 114. 64. 77. *calling the container method of the splitter class *for the second graphic CALL METHOD SPLITTER->GET_CONTAINER EXPORTING ROW = 1 COLUMN = 2 RECEIVING CONTAINER = CONT2. *Setting the title for the splitter control SET titlebar 'SPLITGRAPH'. 91. grvalwa1-rowtxt = 'Rice'. *Graphic 1 display REFRESH : grval1. 94. 84. 74. 93. 102. 108. 111. grvalwa1-VAL2 = 7000. 118. 76. 119. col1_wa-coltxt = '2005'. 67. 83. COL1_wa-COLTXT = '2006'. 112. 110. 116. 107. 71. 115. 95. 73. 101. *Function module to display graph (Graph 1) CALL FUNCTION 'GFW_PRES_SHOW_MULT' EXPORTING PARENT = CONT1 . grvalwa1-VAL2 = 4500. 113. APPEND grvalwa1 to grval1. 109. 75. 79. 92. 72. 85. APPEND grvalwa1 to grval1. *calling the container method of the splitter class *for the first graphic CALL METHOD SPLITTER->GET_CONTAINER EXPORTING ROW = 1 COLUMN = 1 RECEIVING CONTAINER = CONT1. APPEND grvalwa1 to grval1. 103. 98. *creating the splitter control CREATE OBJECT splitter EXPORTING PARENT = CUSTOM_CONTAINER ROWS = 1 COLUMNS = 2 ALIGN = 15. grvalwa1-VAL1 = 3500.

grvalwa2-ROWTXT = 'Wheat'. 164. grvalwa2-VAL1 = 6500. 168. 154. 147. 133. 139. LEAVE PROGRAM. 159. ENDMODULE. 152. 160.action is performed *EXIT called to leave program when user clicks it *&----------------------------------------------------------------* *& Module PAI_0600 INPUT *&----------------------------------------------------------------* MODULE PAI_0600 INPUT. 138. grvalwa2-VAL2 = 8000. APPEND grvalwa2 to grval2. grvalwa2-VAL2 = 5500. 172. 148. 167. 150. APPEND grvalwa2 to grval2.120. 169. 153. ENDIF. grvalwa2-VAL1 = 3250. 158. 163. 165. grvalwa2-VAL2 = 9000. grvalwa2-ROWTXT = 'Barley'. . 131. 155. grvalwa2-VAL2 = 5000. 149. 134. 142.col2_texts. COL2_wa-COLTXT = '2006'. *Graphic 2 display REFRESH : grval2. grvalwa2-VAL1 = 2700. 124. 123. ENDMODULE. PRESENTATION_TYPE = GFW_PRESTYPE_LINES SHOW = GFW_FALSE TABLES VALUES = grval1 COLUMN_TEXTS = COL1_TEXTS EXCEPTIONS ERROR_OCCURRED = 1. 161. grvalwa2-ROWTXT = 'Corn'. APPEND grvalwa2 to grval2. 141. 171. 130. IF OK_CODE EQ 'EXIT'. COL2_wa-COLTXT = '2005'. APPEND col2_wa to COL2_TEXTS. 126. 146. APPEND grvalwa2 to grval2. 136. 128. 137. 151. APPEND col2_wa to COL2_TEXTS. 129. 135. *Function module to display Graph 2 CALL FUNCTION 'GFW_PRES_SHOW_MULT' EXPORTING PARENT = CONT2 PRESENTATION_TYPE = GFW_PRESTYPE_LINES SHOW = GFW_TRUE TABLES VALUES = grval2 COLUMN_TEXTS = COL2_TEXTS EXCEPTIONS ERROR_OCCURRED = 1. OK_CODE = SY-UCOMM. 144. grvalwa2-VAL1 = 3000. 145. 127. 170. 125. 166. 121. " PBO_0600 OUTPUT *PAI module : Based on user input. 132. 157. " PAI_0600 INPUT Screen shots of the output. 156. 143. 122. 140. grvalwa2-ROWTXT = 'Maize'. 162.

Screen shot of the splitter containers can be resized as shown below: . 174.173.

.175.

we all know that if we drop a field of type char and length 255 in to the conventional screen painter it will be displayed in a single line. TEXT_EDITOR TYPE REF TO CL_GUI_TEXTEDIT. And text editor control is implemented using class CL_GUI_TEXTEDIT. Our declaration part contains DATA: LINE_LENGTH EDITOR_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER. The following is our attempt to explain how to implement the text editor control on classic dynpros. TEXT TYPE STRING.Usage and Demo By Saikumar Bonakurthi. So we need a container for the custom control. Enteg Infotech As an ABAP developer. Text editor is displayed on screen using custom control. . Then call the screen (can be any number) TYPE I VALUE 254. It will not be good interface unless we provide a multi-line input field in the screen. This can be achieved by text editor control.Text Edit control .

Define and implement both the modules in the main program itself. Go to screen 100 by double clicking on '100'. MODULE USER_COMMAND_0100. CREATE OBJECT EDITOR_CONTAINER EXPORTING CONTAINER_NAME = 'TEXTEDITOR' EXCEPTIONS CNTL_ERROR =1 CNTL_SYSTEM_ERROR =2 CREATE_ERROR =3 LIFETIME_ERROR =4 LIFETIME_DYNPRO_DYNPRO_LINK = 5. Create a custom control on screen with name TEXTEDIT. Uncomment both PBO and PAI modules in flow logic screen PROCESS BEFORE OUTPUT.START-OF-SELECTION. * PROCESS AFTER INPUT. MODULE STATUS_0100. CALL SCREEN '100'. In PBO create object container EDITOR_CONTAINER. Then create text editor object by exporting the container EDITOR_CONTAINER. CREATE OBJECT TEXT_EDITOR .

CALL METHOD TEXT_EDITOR->SET_TOOLBAR_MODE EXPORTING TOOLBAR_MODE = CL_GUI_TEXTEDIT=>FALSE. IF SY-SUBRC <> 0. WHEN 'EXIT'. . Define and create a GUI Status in the PBO. LEAVE PROGRAM.EXPORTING PARENT = EDITOR_CONTAINER WORDWRAP_MODE = CL_GUI_TEXTEDIT=>WORDWRAP_AT_FIXED_POSITION WORDWRAP_POSITION = LINE_LENGTH WORDWRAP_TO_LINEBREAK_MODE = CL_GUI_TEXTEDIT=>TRUE. Very minimum set of tool bar buttons defined in this example In PAI of the screen 100. WHEN 'SAVE'. SET PF-STATUS 'STATUS_0100'. CASE SY-UCOMM. CALL METHOD TEXT_EDITOR->GET_TEXTSTREAM * EXPORTING * ONLY_WHEN_MODIFIED = CL_GUI_TEXTEDIT=>TRUE IMPORTING TEXT = TEXT * IS_MODIFIED = EXCEPTIONS ERROR_CNTL_CALL_METHOD = 1 NOT_SUPPORTED_BY_GUI = 2 OTHERS = 3. You can hide the toolbar and as well as status bar for the text editor control. CALL METHOD TEXT_EDITOR->SET_STATUSBAR_MODE EXPORTING STATUSBAR_MODE = CL_GUI_TEXTEDIT=>FALSE. handle the save and other user commands.

IF TEXT_EDITOR IS INITIAL. CALL METHOD CL_GUI_CFW=>FLUSH EXCEPTIONS CNTL_SYSTEM_ERROR = 1 CNTL_ERROR =2 OTHERS = 3. To read the text that is typed in the editor we need to call the method GET_TEXTSTREAM of the editor instance. TEXT TYPE STRING. ENDCASE. CALL SCREEN '100'. START-OF-SELECTION. SET PF-STATUS 'STATUS_0100'. the same can be inserted / updated into a database table also. The complete coding of the executable program is given below.. MESSAGE TEXT TYPE 'I'. EDITOR_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER. ENDIF. DATA: LINE_LENGTH TYPE I VALUE 254. REPORT ZTEXT_EDITOR. **&---------------------------------------------------------------------* **& Module STATUS_0100 OUTPUT **&---------------------------------------------------------------------* ** text **----------------------------------------------------------------------* MODULE STATUS_0100 OUTPUT. TEXT_EDITOR TYPE REF TO CL_GUI_TEXTEDIT. CREATE OBJECT TEXT_EDITOR EXPORTING PARENT = EDITOR_CONTAINER WORDWRAP_MODE = CL_GUI_TEXTEDIT=>WORDWRAP_AT_FIXED_POSITION . CREATE OBJECT EDITOR_CONTAINER EXPORTING CONTAINER_NAME = 'TEXTEDITOR' EXCEPTIONS CNTL_ERROR =1 CNTL_SYSTEM_ERROR =2 CREATE_ERROR =3 LIFETIME_ERROR =4 LIFETIME_DYNPRO_DYNPRO_LINK = 5.MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. We are just displaying the text typed in the editor in an informative message.

WHEN 'SAVE'. " USER_COMMAND_0100 INPUT The final Screen shot of the editor: . CALL METHOD TEXT_EDITOR->GET_TEXTSTREAM * EXPORTING * ONLY_WHEN_MODIFIED = CL_GUI_TEXTEDIT=>TRUE IMPORTING TEXT = TEXT * IS_MODIFIED = EXCEPTIONS ERROR_CNTL_CALL_METHOD = 1 NOT_SUPPORTED_BY_GUI = 2 OTHERS = 3. CASE SY-UCOMM. ENDMODULE. *3)HIDE TOOLBAR AND STATUSBAR CALL METHOD TEXT_EDITOR->SET_TOOLBAR_MODE EXPORTING TOOLBAR_MODE = CL_GUI_TEXTEDIT=>FALSE. " STATUS_0100 OUTPUT *&---------------------------------------------------------------------* *& Module USER_COMMAND_0100 INPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE USER_COMMAND_0100 INPUT. LEAVE PROGRAM. IF SY-SUBRC <> 0. CALL METHOD TEXT_EDITOR->SET_STATUSBAR_MODE EXPORTING STATUSBAR_MODE = CL_GUI_TEXTEDIT=>FALSE. ENDIF. WHEN 'EXIT'. ENDCASE.WORDWRAP_POSITION = LINE_LENGTH WORDWRAP_TO_LINEBREAK_MODE = CL_GUI_TEXTEDIT=>TRUE. MESSAGE TEXT TYPE 'I'. MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. CALL METHOD CL_GUI_CFW=>FLUSH EXCEPTIONS CNTL_SYSTEM_ERROR = 1 CNTL_ERROR =2 OTHERS = 3. ENDMODULE. ENDIF.

Test picture.Display images on the screen By Aditya Niyogi. L&T Infotech Step 1: Upload picture into SAP using the transaction SE78. .

Please note that the object name is „winny‟. . EDITOR TYPE REF TO CL_GUI_TEXTEDIT. TYPES PICT_LINE(256) TYPE C. DATA: L_GRAPHIC_XSTR TYPE XSTRING.Step 2: Create a custom screen section in the screen. Step 3: In the PBO module of the screen. please pass your own object name to the method: *&---------------------------------------------------------------------* *& Module STATUS_9000 OUTPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE STATUS_9000 OUTPUT. DATA : CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER. DATA: W_LINES TYPE I. DATA: L_GRAPHIC_CONV TYPE I. PICT_TAB TYPE TABLE OF PICT_LINE. URL(255) TYPE C. attach the following code. LINE(255) TYPE X. DATA: GRAPHIC_SIZE TYPE I. DATA: BEGIN OF GRAPHIC_TABLE OCCURS 0. DATA: L_GRAPHIC_OFFS TYPE I. END OF GRAPHIC_TABLE. DATA: GRAPHIC_URL(255). PICTURE TYPE REF TO CL_GUI_PICTURE.

GRAPHIC_TABLE-LINE = L_GRAPHIC_XSTR+L_GRAPHIC_OFFS(L_GRAPHIC_CONV). GRAPHIC_SIZE = XSTRLEN( L_GRAPHIC_XSTR ). CALL FUNCTION 'DP_CREATE_URL' EXPORTING TYPE = 'IMAGE' SUBTYPE = 'X-UNKNOWN' SIZE = GRAPHIC_SIZE LIFETIME = 'T' TABLES DATA = GRAPHIC_TABLE CHANGING URL = URL.. ENDWHILE. L_GRAPHIC_CONV = GRAPHIC_SIZE. L_GRAPHIC_OFFS = L_GRAPHIC_OFFS + 255. PICTURE EXPORTING PARENT = CONTAINER. CALL METHOD PICTURE->LOAD_PICTURE_FROM_URL EXPORTING URL = URL. CALL METHOD PICTURE->SET_DISPLAY_MODE EXPORTING DISPLAY_MODE = PICTURE->DISPLAY_MODE_FIT_CENTER. L_GRAPHIC_OFFS = 0. WHILE L_GRAPHIC_CONV > 255. CREATE OBJECT: CONTAINER EXPORTING CONTAINER_NAME = 'PICTURE_CONTAINER'. " STATUS_9000 OUTPUT Output: . APPEND GRAPHIC_TABLE. APPEND GRAPHIC_TABLE. ENDMODULE. CALL METHOD CL_SSF_XSF_UTILITIES=>GET_BDS_GRAPHIC_AS_BMP EXPORTING P_OBJECT = 'GRAPHICS' P_NAME = 'WINNY' P_ID = 'BMAP' P_BTYPE = 'BCOL' RECEIVING P_BMP = L_GRAPHIC_XSTR * EXCEPTIONS * NOT_FOUND = 1 * INTERNAL_ERROR = 2 * others = 3 . L_GRAPHIC_CONV = L_GRAPHIC_CONV . * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. CALL METHOD CL_GUI_CFW=>FLUSH. IF SY-SUBRC <> 0. GRAPHIC_TABLE-LINE = L_GRAPHIC_XSTR+L_GRAPHIC_OFFS(255).255. ENDIF.

Group Boxes 6. Pushbuttons with No Fixed Position and others STEP-BY-STEP DEMO FOR SCREEN PAINTER. you can define the following interface elements with their associated attributes. Checkboxes 4. Field Names 3.Working with Screen Painter By Vikram Chellappa. Radio Buttons 5. 1. In the screen painter. 7. . Sub screens. Mouri Tech Solutions SCREEN PAINTER:Screen painter is a tool in ABAP dev workbench used to create the screens using the T-code SE51. Input/Output Fields 2.

Create a Z program in SE38. We will write the code later in this. Go to transaction SE51. Enter the created program name and screen number. . Click on Save.

. Click on flowlogic tab.Enter the short description and click on save.

Click on yes.” The below screen will be displayed. Double click the “ status_0100.Uncomment the statement “ MODULE STATUS_0100 “. .

Click on yes. Select the “zdemo_screen_painter” “main program” and click on continue. .Following pop-up screen appears.

Click in layout.Screen would be displayed as follows: Now come back to the transaction SE51. Select flow logic. .

Here we will design the required screen fields.Screen painter window will be displayed like this. Following screen appears: . Click on the middle icon dictionary / program fields window. Or F6.

Enter the table name in the table field name. Select the required fields from MARA table from dictionary. Click on OK or continue. . Click on get from dictionary.

After placing the required fields. you can view the below screen. .

drag and drop the button onto the screen. Select the pushbutton. .Create the push button from the toolbox.

. text. After creating the screen click on save check and activate.Create the other required buttons in the same procedure mentioned above and assign the name. press flow logic button. and function code for each one. .

. *&-------------------------------------------------------------------* REPORT ZDEMO_SCREEN_PAINTER. Paste the below Code in created z program created earlier: *&-------------------------------------------------------------------* *& Report ZDEMO_SCREEN_PAINTER *& *&-------------------------------------------------------------------* *& Demo for Screen Painter. *& By Vikramchellappa.Click on tab Element List enter OK_CODE.

Click on Display. SELECT SINGLE ERSDA ERNAM MTART MATKL FROM MARA INTO (MARA-ERSDA. ENDMODULE. ***************************************************************** * CALLING SCREEN. WHEN 'CLEAR'. CLEAR MARA. MARA-MATKL) WHERE MATNR = MARA-MATNR. OK_CODE LIKE SY-UCOMM. LEAVE PROGRAM. ERNAM TYPE MARA-ERNAM. ****************************************************************** TABLES: MARA. DISPLAY TYPE C. MTART TYPE MARA-MTART. ERSDA TYPE MARA-ERSDA. CASE SY-UCOMM. CLEAR TYPE C. ****************************************************************** * DATA DECLARATIONS. WHEN 'DISPLAY'. LEAVE PROGRAM. * SET PF-STATUS 'ZMENU'. ***************************************************************** CALL SCREEN 100. * SET TITLEBAR 'ZMENU_PAINTER'. MARA-ERNAM. SAVE TYPE C. . MARA-MTART. ***************************************************************** DATA: MATNR TYPE MARA-MATNR. ENDCASE. *&--------------------------------------------------------------* *& Module STATUS_0100 OUTPUT *&--------------------------------------------------------------* * text *--------------------------------------------------------------* MODULE STATUS_0100 OUTPUT. EXIT TYPE C. MATKL TYPE MARA-MATKL. WHEN 'BACK'. WHEN 'EXIT'. DELETE TYPE C.****************************************************************** * TABLE DECLARATIONS. " STATUS_0100 OUTPUT Output:Enter Material number On Material Field.

. Go to SE38 T-code. we would work on creating a simple screen with a tabstrip on it.Material Information is displayed as shown below: Demo on Tabstrips By Vikram Chellappa. Mouri Tech Solutions In this document. Create a Z program.

CALL SCREEN 110. N1 TYPE I. REPORT ZTABSTRIP. OK_CODE LIKE SY-UCOMM. NUMBER2 TYPE I. ************************************************************************ * DATA DECLARATIONS * ************************************************************************ DATA : NUMBER1 TYPE I. RESULT TYPE I. " STATUS_0100 OUTPUT *&---------------------------------------------------------------------* *& Module USER_COMMAND_0100 INPUT *&---------------------------------------------------------------------* text *----------------------------------------------------------------------* MODULE USER_COMMAND_0100 INPUT. CALL SCREEN 130. CALL SCREEN 100. SET PF-STATUS 'BACK'.Paste the below code in the source code. CONTROLS TABSTRIP TYPE TABSTRIP. ENDMODULE. *&---------------------------------------------------------------------* *& Module STATUS_0100 OUTPUT *&---------------------------------------------------------------------* text *----------------------------------------------------------------------* MODULE STATUS_0100 OUTPUT. N2 TYPE I. .

SET PF-STATUS 'xxxxxxxx'. RESULT = NUMBER1 + NUMBER2. RESULT = NUMBER1 + NUMBER2. LEAVE PROGRAM. ENDCASE. WHEN 'TAB1'. TABSTRIP-ACTIVETAB = 'TAB1'. ENDMODULE. TABSTRIP-ACTIVETAB = 'TAB2'. ENDMODULE. " STATUS_0110 OUTPUT *&---------------------------------------------------------------------* *& Module STATUS_0130 OUTPUT *&---------------------------------------------------------------------* text *----------------------------------------------------------------------* MODULE STATUS_0130 OUTPUT. N1 = NUMBER1. N2 = NUMBER2. ENDMODULE. SET TITLEBAR 'xxx'. WHEN 'BACK'. " USER_COMMAND_0100 INPUT *&---------------------------------------------------------------------* *& Module USER_COMMAND_0130 INPUT *&---------------------------------------------------------------------* text *----------------------------------------------------------------------* MODULE USER_COMMAND_0130 INPUT.CASE OK_CODE. SET PF-STATUS 'xxxxxxxx'. . " USER_COMMAND_0110 INPUT *&---------------------------------------------------------------------* *& Module STATUS_0110 OUTPUT *&---------------------------------------------------------------------* text *----------------------------------------------------------------------* MODULE STATUS_0110 OUTPUT. ENDMODULE. ENDMODULE. WHEN 'TAB2'. " STATUS_0130 OUTPUT Double Click on "call screen 100". RESULT = NUMBER1 + NUMBER2. SET TITLEBAR 'xxx'. " USER_COMMAND_0130 INPUT *&---------------------------------------------------------------------* *& Module USER_COMMAND_0110 INPUT *&---------------------------------------------------------------------* text *----------------------------------------------------------------------* MODULE USER_COMMAND_0110 INPUT.

Enter Short descriptions. Come to Flow logic. .

Click on Layout Button. Create A Tab Strip and Sub screens and place Sub screen in the appropriate tab strip. . or Press Ctrl+F7.

Enter the name of the created TABSTRIP and sub SCREEN. Enter the required Name. . Text. Function code.

.Enter the OK_CODE.

ACTIVATE . Enter the name description and Format..Previous .Double click on CALL SCREEN 110. Create 2 Input fields. Give the short description. CHECK. Click on Flow logic and come to layout. Click on SAVE .. ..

ACTIVATE .Click on SAVE . . CHECK. Double click on CALL SCREEN 130.

Create a text for Result. Click on LAYOUT .Give the SHORT DESCRIPTION. .

ACTIVATE . CHECK. . Result:- . CHECK. ACTIVATE . Click on SAVE And EXECUTE.Click on SAVE . Come Back To Source Code.

View the Result on Tab2. .Enter the Value on A = 50 and B = 50.

MouriTech Solutions *&---------------------------------------------------------------------* *& Report Z_DB_TABLECONTROL * *& * *&---------------------------------------------------------------------* *& * *& * *&---------------------------------------------------------------------* REPORT Z_DB_TABLECONTROL. OK_CODE LIKE SY-UCOMM. MATNR TYPE MARA-MATNR. CALL SCREEN 130. WA_ST TYPE ST_MARA. DATA: IT_ST TYPE TABLE OF ST_MARA.Demo on using Table Control By Raghav Vakada. WA_MARA TYPE MARA. IT_MARA TYPE MARA. ERSDA TYPE MARA-ERSDA. TABLES: MARA. *&---------------------------------------------------------------------* *& Module V1 INPUT *&---------------------------------------------------------------------* * text . LAEDA TYPE MARA-LAEDA. ERNAM TYPE MARA-ERNAM. CONTROLS MATERIAL TYPE TABLEVIEW USING SCREEN 130. END OF ST_MARA. TYPES: BEGIN OF ST_MARA.

DELETE MARA FROM WA_MARA. INSERT INTO MARA VALUES WA_MARA. ENDCASE. LEAVE PROGRAM. MOVE-CORRESPONDING WA_ST TO WA_MARA. WA_ST-LAEDA = MARA-LAEDA. " V1 INPUT *&---------------------------------------------------------------------* *& Module EXIT INPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE EXIT INPUT. WA_ST-ERNAM = MARA-ERNAM. WA_ST-LAEDA = MARA-LAEDA. WA_ST-ERSDA = MARA-ERSDA. WA_ST-LAEDA = MARA-LAEDA. WA_ST-MATNR = MARA-MATNR. WA_ST-MATNR = MARA-MATNR. WA_ST-ERNAM = MARA-ERNAM. WHEN 'MODIFY'. WA_ST-ERSDA = MARA-ERSDA. " EXIT INPUT Create a screen by number 130 and provide the following attributes: . MOVE-CORRESPONDING WA_ST TO WA_MARA. WA_ST-MATNR = MARA-MATNR. ENDMODULE. IF OK_CODE = 'EXIT'. MODIFY MARA FROM WA_MARA. WA_ST-ERSDA = MARA-ERSDA. WA_ST-ERNAM = MARA-ERNAM.*----------------------------------------------------------------------* MODULE V1 INPUT. WHEN 'SAVE'. ENDMODULE. WHEN 'DELETE'. CASE OK_CODE. ENDIF. MOVE-CORRESPONDING WA_ST TO WA_MARA.

LAYOUT: ELEMENT LIST: .

EXECUTE: .FLOW LOGIC.

.. To link a custom control to a container control..... created using the screen painter. * Type declarations... The following is a sample program to demonstrate the logo display using the custom control..6C.. It has the following flow logic: PROCESS MODULE * PROCESS MODULE BEFORE OUTPUT.. This program was written in SAP4... . pass the custom control name to the CONTAINER_NAME parameter of the container control constructor when you instantiate it. Design a screen with the custom control. EXIT. TYPES pict_line(256) TYPE c. Container controls are instances of special global classes from the SAP Control Framework.... The global class for custom controls is called CL_GUI_CUSTOM_CONTAINER... STATUS_0100... Code REPORT ZSURESH_TEST .. by name PICTURE_CONTAINER.. EXIT-COMMAND.. A custom control is an area on the screen.... DATA :init.... AFTER CANCEL AT The GUI status SCREEN100 has the functions BACK. Custom controls are used to embed controls... INPUT.Display Logo on Screen By Suresh Kumar Parvathaneni You can display logo(s) on your screen using the custom control function. and CANCEL (all with type E)........... * data declarations.

editor TYPE REF TO cl_gui_textedit. * Dialog modules... CALL FUNCTION 'DP_CREATE_URL' EXPORTING type = 'IMAGE' EXPORTING parent = container. subtype = 'GIF' TABLES data = pict_tab CHANGING url = url.. MODULE status_0100 OUTPUT.. IMPORT pict_tab = pict_tab FROM DATABASE abtree(pi) ID 'ENJOY'. picture ENDIF. init = 'X'.... picture TYPE REF TO cl_gui_picture... CALL METHOD picture->load_picture_from_url EXPORTING url = url... url(255) TYPE c... SET PF-STATUS 'SCREEN100'.. CALL SCREEN 100.. pict_tab TYPE TABLE OF pict_line..........container TYPE REF TO cl_gui_custom_container........... CALL METHOD picture->set_display_mode . IF init is initial. CREATE OBJECT: container EXPORTING container_name = 'PICTURE_CONTAINER'....

. In the Transaction. Go to Transaction SHDB and click “New Recording” button. Click “Start recording” button.EXPORTING display_mode = picture->display_mode_fit_center. Mouri Tech Solutions In this example. there you enter the Recording name and transaction for which you wish to do the BDC (In this example it is VV31). 2. The following popup screen gets populated. ENDMODULE. BDC Programming How to do BDC without writing BDC program By Vikram Chellappa. ENDMODULE.Billing) to do the BDC. I have used the transaction VV31 (Create Output – Condition Records . In this case it is Output type (AUS1). LEAVE TO SCREEN 0. 3. MODULE cancel INPUT. enter the mandatory field. Hit enter key. 1.

. SAP will give the Recorded program as shown in the following screen shot. Enter all the mandatory fields and click on save.4. 6. 5. The following screen appears for more entry. Click the Export button and save the file as word document file into the system.

Now open the newly created word document file. 8. (In this case it is output type i. Select/Highlight the first field in the word document for which for which BDC needs to done.7.e. AUS1) and go to the menu path Insert  Field .

10. 12.9. Now you can see that all the required fields have been mapped with unique column names. Similarly you highlight the other fields for which we need to create the BDC and give the unique column names for those fields. 11. Now you can see in the word document that the highlighted field will get replaced with the column name. . A new screen will get populated and there you select the “Merge Field” option from the list box and st enter the Column Name (In this case the 1 column is output_type).

. Check that the column name in the word document is matching with the column name in the Excel file. A mail merge wizard will gets opened in the right hand side.13. 14. Now open the excel file where which you have the data to do the BDC for transaction VV31. Now go the menu path Tools  Letters and Mailings  Mail Merge Wizard. 15.

17. Now click on “Browse” link 20. Close the Excel File. . It will open the popup for selecting the file (which is having data for BDC).16. Now click on “Next: Select recipients” link 19. Switch to world document and Now Click “Next: Start document” link in the bottom of Mail Merge wizard 18.

23. A new popup screen would appear with the data. A new popup will get triggered. 24. In this case it is Sheet1$ and Click “OK” button. Select the work sheet of the Excel file where the actual data present. Press “Open” button 22. Click “OK” button.21. .

25. 27. Now you can see the first record got merged with the word document. . Now click “Next: Write your letter” link. 26. Click “Next: Preview your letters” link.

28.

Click “Next: Complete the merge” link.

29.

Click the “Edit individual letters…” link

30.

A new popup will get triggered, there you select “All” radio button and click “OK” button.

31.

Now you can see the merge has been done in the word document and it will create the BDC program for all the records in the Excel sheet. (In this case we had 10 records in excel sheet, hence the merge has created 10 pages in the word document. One page for each record) Now Select the entire content in the word document (i.e. all the 10 pages) and copy it in a notepad and save as separate “TXT” file.

32.

33. Go to the SHDB transaction and select your recording and click “Change” button.

34. Now use the “Import” button

to download the TXT file which we saved in Step # 32.

35. Once you click the Import button, a popup will come from there you select the file and click “Transfer” button.

36. It will transfer the entire content to the SHDB. Now Save the changes. Click “Back” button. 37. Now click the “Session” button, in order to create a new session.

38.

The following popup will get triggered, there you enter the new session name and check the “Keep session” check box and click “Continue” button.

39.

You will get the “Success Message” that “Batch input session ZTST_GOK was created”.

40.

Now go to the Transaction SM35 (Batch Input: Session Overview), there you select your “Session” which you have created in Step # 38 (You can the status of your session will be New) and click “Process” button.

41.

A small popup will get triggered, there you select the “Background” radio button and check the “Extended Log” check box. Click “Process” button.

42.

You will get the success message “1 session(s) transferred to background processing”.

43.

And you can also see the status of your session has been changed from “New” to “In background”.

44.

Click “Log” button, to see the details about the BDC.

45.

You will taken to the another screen, there you can see status of the BDC.

46.

In our case, the status is “Errors”, to know the details further. Select the entry and click “Analyze session”. It will display the status of all the records.

47.

In the above screen shot you can see the first two records were failed and others were processed. The reason for the same is: For the first time when we used SHDB we created the first condition record. Since this record is already there it failed in the second time. The same thing applies to the second failure case.

Creating a simple database table using BDC
By Banupriya R, YASH Technologies

Report ypriyatest. TABLES: bdcdata. DATA:t_bdcdata LIKE STANDARD TABLE OF bdcdata. PARAMETERS : p_table(15) TYPE c.

DATA: MSG LIKE BDCMSGCOLL, T_MSG LIKE TABLE OF MSG, MESSAGE(72) TYPE C. PERFORM PROCESS. *&--------------------------------------------------------------------* *& Form fill_screendata *&--------------------------------------------------------------------form fill_screendata using value(p_0015) value(p_0016).

BDCDATA-PROGRAM = P_0015. BDCDATA-DYNPRO = P_0016. BDCDATA-DYNBEGIN = 'X'. APPEND BDCDATA TO T_BDCDATA. CLEAR BDCDATA. endform. " fill_screendata *&--------------------------------------------------------------------* *& Form FILL_FIELD_DATA *&--------------------------------------------------------------------form FILL_FIELD_DATA using value(p_0020) value(p_0021).

BDCDATA-FNAM = P_0020. BDCDATA-FVAL = P_0021. APPEND BDCDATA TO T_BDCDATA. CLEAR BDCDATA. endform. " FILL_FIELD_DATA *&--------------------------------------------------------------------* *& Form PROCESS *&--------------------------------------------------------------------form PROCESS . **first screen PERFORM fill_screendata USING 'SAPMSRD0' '0102'. PERFORM FILL_FIELD_DATA USING 'RSRD1-TBMA' 'X'. PERFORM FILL_FIELD_DATA USING 'RSRD1-TBMA_VAL' p_table. PERFORM FILL_FIELD_DATA USING 'BDC_OKCODE' '=ADD'. **second screen PERFORM fill_screendata USING 'SAPLSD41' '2200'. PERFORM FILL_FIELD_DATA USING 'DD02D-DDTEXT' 'Bdc Table'. PERFORM FILL_FIELD_DATA USING 'DD02D-CONTFLAG' 'A'. PERFORM FILL_FIELD_DATA USING 'DD02D-MAINFLAG' 'X'. PERFORM FILL_FIELD_DATA USING 'BDC_OKCODE' '=CHANGE_MAINTFLAG'. PERFORM FILL_FIELD_DATA

USING 'BDC_OKCODE' '/00'. PERFORM FILL_FIELD_DATA USING 'BDC_OKCODE' '=DEF'. **second screen filling table fields PERFORM fill_screendata USING 'SAPLSD41' '2200'. PERFORM FILL_FIELD_DATA USING 'DD03P-FIELDNAME(01)' 'mandt'. PERFORM FILL_FIELD_DATA USING 'DD03P-FIELDNAME(02)' 'name'. PERFORM FILL_FIELD_DATA USING 'DD03P-FIELDNAME(03)' 'empid'. PERFORM FILL_FIELD_DATA USING 'DD03D-ROLLNAME(01)' 'mandt'. PERFORM FILL_FIELD_DATA USING 'DD03D-ROLLNAME(02)' 'char20'. PERFORM FILL_FIELD_DATA USING 'DD03D-ROLLNAME(03)' 'numc4'. PERFORM FILL_FIELD_DATA USING 'DD03P-KEYFLAG(01)' 'X'. PERFORM FILL_FIELD_DATA USING 'BDC_OKCODE' '/00'. PERFORM FILL_FIELD_DATA USING 'BDC_OKCODE' '=WB_SAVE'. **saving the table**** PERFORM fill_screendata USING 'SAPLSTRD' '0100'. PERFORM FILL_FIELD_DATA USING 'KO007-L_DEVCLASS' '$TMP'. PERFORM FILL_FIELD_DATA USING 'KO007-L_AUTHOR' 'SAPDEV02'. PERFORM FILL_FIELD_DATA USING 'BDC_OKCODE' '=TEMP'. **filling technical settings. PERFORM fill_screendata USING 'SAPLSD41' '2200'. PERFORM FILL_FIELD_DATA USING 'BDC_OKCODE' '=SE13'. PERFORM fill_screendata USING 'SAPMSEDS' '0050'. PERFORM FILL_FIELD_DATA USING 'BDC_CURSOR' 'DD09V-TABART'. PERFORM FILL_FIELD_DATA USING 'DD09V-TABART' 'APPL0'. PERFORM FILL_FIELD_DATA USING 'DD09V-TABKAT' '0'. PERFORM FILL_FIELD_DATA USING 'ALLOWSTATE-NOT_ALLOWED' 'X'. PERFORM FILL_FIELD_DATA USING 'BDC_OKCODE' '=SICH'. PERFORM fill_screendata USING 'SAPMSEDS' '0050'. PERFORM FILL_FIELD_DATA USING 'BDC_OKCODE' '=BACK'. PERFORM fill_screendata USING 'SAPLSD41' '2200'. PERFORM FILL_FIELD_DATA

USING 'BDC_OKCODE' '=WB_SAVE'. PERFORM fill_screendata USING 'SAPLSD41' '2200'. PERFORM FILL_FIELD_DATA USING 'BDC_OKCODE' '=WB_CHECK'. PERFORM fill_screendata USING 'SAPLSD41' '2200'. PERFORM FILL_FIELD_DATA USING 'BDC_OKCODE' '=WB_ACTIVATE'. PERFORM FILL_SCREENDATA USING 'SAPLSEWORKINGAREA' '0205'. PERFORM FILL_FIELD_DATA USING 'BDC_OKCODE' '=WEIT'. PERFORM fill_screendata USING 'SAPLSD41' '2200'. PERFORM FILL_FIELD_DATA USING 'BDC_OKCODE' '=BACK'. PERFORM fill_screendata USING 'SAPMSRD0' '0102'. PERFORM FILL_FIELD_DATA USING 'BDC_OKCODE' '=BACK'. CALL TRANSACTION 'SE11' USING T_BDCDATA MODE 'A' MESSAGES INTO T_MSG. LOOP AT T_MSG INTO MSG. CALL FUNCTION 'FORMAT_MESSAGE' EXPORTING ID = MSG-MSGID LANG = 'EN' NO = MSG-MSGNR V1 = MSG-MSGV1 V2 = MSG-MSGV2 V3 = MSG-MSGV3 V4 = MSG-MSGV4 IMPORTING MSG = MESSAGE EXCEPTIONS NOT_FOUND = 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. IF sy-subrc EQ 0. WRITE / MESSAGE. ENDIF. ENDLOOP. endform. " PROCESS

Output First Screen

Setting the delivery class and maintenance

Saving the table

Technical Settings Activating The Table .

BDC recording from testing client to development client .

By Venkatraman N. Login to the Testing client where you will have data. IBM This method would be useful. As an instance. give FK02 as the transaction code to be executed and give recording name like „ZRECORD‟. . when you don‟t have required datum in development client and when you have same in testing client and you want to BDC recording with that datum. here we will try to modify vendor‟s postal code of his address. So. Go to transaction SHDB and press new recording.

Opt a vendor and click the address checkbox and press enter.Now it goes to Vendor master update screen. It will show the vendor‟s address information. .

It will take you to the recording screen. .Now change the existing PIN code 700019 to 560076 and press save.

.

Now you cannot create a program with this recording information in testing client. . Press import button. import your recording information to one presentation server file. Give a text file name and save it in the presentation server. So.

.Then Go to SHDB transaction in development client and go to new recording. If not create it and input the vendor in FK02 transaction and as you did earlier select the address checkbox. In this case your development client should have at least one vendor. Give the recording name as ZRECORDINGNEW and opt the same vendor master updation transaction code FK02.

Because this is not the vendor to whom we are going to change his PIN Code.It will show you the address information. . You don‟t change anything in that and come back.

Now it will show you the recording information. Delete all the recording information and press the import button and browse bdc_recording file from the presentation server. .

.

It would popup for saving the recording. Now save that recording. .The previous recording information will loaded in to BDC recording and go back from the screen.

Input the required details and the expected BDC recording program will get created. It will popup for new program creation.Select the recording and press „program‟ button. .

include bdcrecx1. .report ZVENDORUPDATE no standard page heading line-size 255. start-of-selection.

perform bdc_field using 'LFA1-ORT01' 'Kolkatta'. perform bdc_field using 'BDC_CURSOR' 'RF02K-LIFNR'. perform bdc_field using 'BDC_CURSOR' 'LFA1-PSTLZ'. Shakespeare Sarani'. perform close_group. perform bdc_field using 'RF02K-LIFNR' 'B002568'.perform open_group. perform bdc_field using 'LFA1-SPRAS' 'EN'. perform bdc_field using 'RF02K-D0110' 'X'. perform bdc_dynpro using 'SAPMF02K' '0110'. perform bdc_field using 'LFA1-PSTLZ' '560076'. perform bdc_field using 'LFA1-NAME1' 'MURARI SHARAN SRIVASTAVA'. ……………………………………………………………………………………………………… . perform bdc_transaction using 'FK02'. perform bdc_field using 'LFA1-STRAS' 'Brook House. perform bdc_dynpro using 'SAPMF02K' '0106'. perform bdc_field using 'BDC_OKCODE' '=UPDA'. perform bdc_field using 'LFA1-REGIO' '25'. perform bdc_field using 'LFA1-LAND1' 'IN'. perform bdc_field using 'BDC_OKCODE' '/00'. perform bdc_field using 'LFA1-SORTL' '000568'.

Sign up to vote on this title
UsefulNot useful