A Must Sap Abap Tutorials Document for Beginners

August 2, 2018 | Author: Sandip Phuse | Category: Database Index, Databases, Subroutine, Database Transaction, Portable Document Format
Share Embed Donate


Short Description

Download A Must Sap Abap Tutorials Document for Beginners...

Description

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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. 

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

1/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  3.

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

2/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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  

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

3/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  6.

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

4/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  7.

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

5/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

6/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  10. Save it as a local object. 

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

7/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  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.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

8/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

9/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

14. Press Enter. 

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

10/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

17. You will get the following screen.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

11/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

12/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  19. Save it by pressing Yes.

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

13/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

21. Give short description of the data element. And give the lengths and field labels accordingly in Field label tab.

22. Press on Definition tab and give the domain name in Domain field. Double click on ZNUM_D.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

14/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  23. It will ask for save. Press Yes. 

24. Save it as a local Object.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

15/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

 

25. Now it asks for Domain creation. Press Yes. 

26. Give short description in short text field. Enter the data type and no. characters, Press Enter.

Then Press on Activate button or Press Ctrl+F3.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

16/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  27. Save this as a local object.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

17/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  28. Press enter.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

18/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

19/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

20/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  31. Press enter.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

21/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  32. Press Back button. 

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

22/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

 

33. Now we created two fields. And Data elements and Domain for these two fields.

Now we have to maintain the technical settings. Press on Technical settings button.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

23/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  34. Give the data class and size category of the table as per the requirement.

And press the back button.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

24/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  35. Now

activate

the

table

by

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

pressing

the

activate

button

or

CTRL+F3.

25/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

36. Press enter.

37. Now you will get the following screen.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

26/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  38. Now enter the data into table. Go to Utilities  Table contents

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs



Create Entries.

27/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

28/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

29/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

 

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

30/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  43. You will get the following screen.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

31/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  44. 

Again enter the data for the third entry.

45. 

Press save, Reset (Optional) and Back button.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

32/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  46. 

Now you will get the following screen.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

33/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  47. To see the table contents go to Utilities

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs



Table contents  Display. Or press Ctrl+Shift+F10.

34/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  48. You will get the following screen.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

35/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

36/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Now enjoy by creating tables on your own. 

Creating a Structure in ABAP Dictionary

Go to transaction SE11 and select the radio button “Data type”. Enter a structure name starting with Y or 

Z.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

37/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Press create button. A pop-up screen appears with 3 different options. Select the radio button structure.

The screen will be displayed like this.

Provide the description and also components.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

38/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Then press SAVE, CHECK and ACTIVATE. Structure Created Successfully.

Creating Search Helps (Elementary and Secondary) By Vikram Chellappa, Mouri Tech Solutions

Go To SE11 T-code.

Select the radio button of search help.

Provide the search help name. Select the create button.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

39/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Select ELEMENTARY search help.

Press Enter. Provide the short description, the selection method. Provide the fields.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

40/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Save it, Check It & Activate it. Then execute it.

We can see the screen like this, and then press F4 in this page.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

41/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Then press F4 View the output like this.

This is the output for elementary search help.

The Collective Search Help is like this.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

42/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

Provide the Values

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

43/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Select include search help. Then provide search help name, which is already define by the same fields.

Then save it, activate it & execute it.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

44/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Press F4 we can see the output like this.

Diff Between Elementary search helps & Collective search helps

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

45/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

1) Elementary search helps describe a search path. The elementary search help must define where the data of the hit list should be read from (selection method), how the exchange of values between the screen template and selection method is implemented (interface of the search help) and how the online input help should be defined (online behavior of the search help). 2) Collective helps combine several elementary search helps. Collective search help thus cansearch offer several alternative search paths. 3) An elementary search help defines the standard flow of an input help. 4) A collective search help combines several elementary search helps. The user can thus choose one of several alternative search paths with collective search help. 5) A collective search help comprises several elementary search helps. It combines all the search paths that are meaningful for a field. 6) Both elementary search helps and other search helps can be included in a collective search help. If other collective search helps are contained in collective search help, they are expanded to the level of the elementary search helps when the input help is called.

Creating a secondary index

There are two types of indexes: Primary index and secondary index. Primary index is automatically created using the primary keys defined. 

Secondary index could be created as per the user requirement. This article discusses about creating a secondary index. Go to transaction SE11.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

46/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  For our demo purpose, we have considered the table ZAUTHOR. To know if there are any secondary indexes available, click on Goto



Indexes

Following popup appears:

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

47/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  From the above screenshot, it is evident that there are no secondary indexes already created. Click on Create  Create Index

Enter the name of the index.

Fill in the details – Short description and the fields in the index.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

48/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

49/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

Maximum number of secondary indexes we can have are 9.   How to make SELECT statement to make use of any particular secondary index?

Secondary Indexes 

Consider the following example: SELECT * FROM SPFLI %_HINTS ORACLE 'INDEX("SPFLI" "SPFLI~001")' ....... ENDSELECT. In the above example, 001 is the secondary index of the table SPFLI. It's a well-known fact that the efficient way of retrieving data from the database tables is by using secondary indexes. Many database vendors provide the optimizer hints for the same. From SAP® v4.5, optimizer hints can be provided by the %_HINTS parameter.

This is dependent on the database systems that support optimizer hints. The point to be noted here is these optimizer hints are not standardized by the SQL standards. Each database vendor is free to provide the optimizer hints. Now to know which index to use for our table: 1. Go to SE11 and there specify the table name 2. Now from the menu, goto --> indexes 3. select the required index. Now suppose that the identifier 001 represents a non-unique secondary index comprising of the columns CITYFROM and CITYTO. The index name should be defined as: ~ like SPFLI~001 in the above example. The sequence of fields in the WHERE condition is of no relevance in using this optimizers index. If you specify hints incorrectly, ABAPTM ignores them but doesn't return a syntax error or runtime error. The code was written in R/3 4.6C. Code 

Consider the following example: REPORT Suresh_test. TABLES: spfli. DATA : t_spfli LIKE spfli OCCURS 0 WITH HEADER LINE. SELECT * FROM spfli INTO TABLE t_spfli %_HINTS ORACLE 'INDEX("SPFLI" "SPFLI~001")'. LOOP AT t_spfli. WRITE :/ t_spfli. ENDLOOP.

Working with Table Maintenance Generator

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

50/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

 

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

Click on Utilities



Table Maintenance Generator

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

51/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

Creation of a Logical Database

Go to transaction 'SE36' or 'SLDB'.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

52/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Enter the logical database name as shown above .

If we are using Logical Database for HR purpose, we should check the check Box “Info types (HR only).

Press CREATE Button as shown above. It would prompt for package name and workbench request .

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

53/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  On pressing Save button, following screen appears, prompting for the details of the root node.

Click on create button. Following screen appears:

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

54/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Now enter the details of all the tables under LFA1 (as shown below).

Click on create Button.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

55/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Click on create Button.

Now create a Node with hierarchically under LFB1.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

56/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

 

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.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

57/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

 

Select “Transaction with parameters (Parameter transaction)”

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

58/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

 

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

59/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

60/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

61/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  The currency and quantity fields are automatically maintained here.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

62/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Go back to the main screen 

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

63/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

64/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

Automatically created include with naming convention.

Here by using above marked statement we can create Dynamic selection screen for different tables as per the requirements.

Creation of a Logical Database ...Previous 

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

65/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

Database program (with some includes) are automatically created upon the creation of logical database:

Go back to the main screen. 

Here we can maintain texts for select-options and parameters.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

66/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Navigate to the main screen:

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

67/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

68/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

 

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

69/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Click on Display.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

70/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

 

Creation of a View cluster By T.N.Swapna

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

71/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

 

By default all the key fields would be added. We can add more fields by clicking on the button Table fields.

Now Save and activate the view. Maintenance view for Table MARC Follow the same procedure as above. In the Tab View fields, give „S‟ in the column „P‟ for the fields MANDT and MATNR as shown in the screen shot below:

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

72/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

 

This is because the fields MANDT and MATNR would be filled in the view for MARA and thus they act as subsets and appear as header data when we create entries in view cluster. Maintenance view for Table MARD Follow the same procedure as above. In the Tab Vi ew fields, 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, 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. Table Maintenance Generator for ZMM_V_MARA Now, for each view we need to create a table maintenance generator, which has to be done as follows:

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

73/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

 

The table maintenance screen appears. Here give the details as in the screen shot below. This table maintenance is for the view ZMM_V_ MARA.

Before creating a table maintenance generator, create a function group say ZFG_MATERIAL from the transaction SE80. After the function group is successfully created, enter the function group name as

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

74/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

shown in the screen shot. Also select Maintenance type as „One Step‟ and give the Maintenance Screen no. as „1‟ in the Overview screen and click on the button „Create‟.

Similarly, create the Table maintenance Generators for the views ZMM_V_MARC and ZMM_V_MARD. The screen shots for these views would be as follows: Table Maintenance Generators for ZMM_V_MARC and ZMM_V_MARD

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

75/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Note that the Overview screen numbers would change for each view. It would be „2‟ for th e view ZMM_V_MARC and it would be „3‟ for the view ZMM_V_MARD.  

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

76/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

 

An information message would pop up saying

Continue by pressing „Enter‟. The following screen appears. Give a short description and click on „Object Structure‟ as shown in the screen shot below:

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

77/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

On Clicking the „Object Structure‟ the following screen appears. Select the „New Entries‟ button to enter 

the maintenance views created to form a cluster.

Enter the values as shown below:

The entries would be entered in a hierarchical manner. The short text is the description of the view. The „Predecess‟ column specifies the predecessor of that view. So in this case, the predecessor of 

ZMM_V_MARA is ZMM_V_MARA The predecessor of ZMM_V_MARC is ZMM_V_MARA and isthea predecessor of ZMM_V_  MARD is itself. ZMM_V_MARC. The „DEP‟ column explains whether the entry Header entry or a Dependent entry. It is „R‟ for the view ZMM_V_MARA, because it is a header entry and does not depend on any other view. Whereas, it is „S‟ for ZMM_V_MARC and ZMM_V_MARD, because

ZMM_V_MARC is dependent on ZMM_V_MARA and ZMM_V_MARD is dependent on ZMM_V_MARC. The column „POS‟ specifies the sequence of the views. In the column „Start‟ select the radio button

against the entry for ZMM_V_MARA as it comes first in the hierarchy.   After entering the above entries, press „Enter‟. Three pop-ups for each view would appear as shown below. Proceed further by clicking on „Enter‟ key.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

78/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

 

Now select each line and click on „Field -dependence‟ button. A pop -up appears saying „Field dependencies successfully generated‟.

Generate the field dependence for the views ZMM_V_MARC and ZMM_V_MARD in the same way. Now, save the entries and go back to „Header Entry‟ folder. Activate the view cluster. A pop -up appears as shown below. Click on „Yes‟.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

79/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

 

The view cluster is now created successfully. Note: 1. 

The view cluster can be created on the tables whose data has to be stored in a hierarchical manner.

2. 

One has to check whether proper foreign key relationships are maintained between the tables appearing in the cluster. Sometimes while generating the Field-dependencies, errors may occur if the foreign keys are not maintained properly.

Testing the View Cluster From the initial screen of the transaction „SE54‟ give the view cluster name and click on „Test‟.  

Since we have created the view cluster on standard tables MARA, MARC and MARD we observe that all the existing entries would appear. The screen shot below shows all the existing entries of the table MARA. In order to see the corresponding Plant details for the material, just select an entry and double click on Plant details as shown below.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

80/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  The plant details would appear. In the same way for the corresponding storage location details, select an entry and double click on Storage details as shown below. 

In the above screen shot the material selected in the Material details view would appear as a header entry. The storage location details are as follows:

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. 

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

81/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

Row level locking of database table By Swetabh Shukla, Infosys Technologies Normally if a person opens table maintenance generator and tries to maintain the table, no one else can maintain the same table at the same time. This is because of table level lock by default in SAP. Only one user can maintain any table at a time through SM30 or any transaction that calls table maintenance generator. In the tutorial below we will see how to remove table level lock and apply row level lock. This way any number of users can modify the table at same time. But any particular row can be modified by only one user at a time. We will create a transaction for this purpose. The transaction will call our custom report. This custom report will call the table maintenance generator of the table after deleting table level lock.   In current example let‟s create following:  

Report: ZREP_SHUKS3 Transaction: ZTEST_SHUKS3 Table: ZTEST_SHUKS3 with table maintenance generator. Using transaction ZTEST_SHUKS3 we will delete the table level lock and put row level lock so that multiple users can maintain table at same time. Rows locked by one user will not be editable by other user. 1. 

2. 

Create

table

ZTEST_SHUKS3.

Create table maintenance generator for the table.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

82/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  We will make single screen maintenance for this table. Save it. So finally we have table maintenance code automatically generated in function group ZTEST_SHUKS3. 3. 

Create lock object EYTSS_E433SH in SE11. Give it name as EZTEST_SHUKS3.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

83/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

 

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 .

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

84/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

5. 

Normally if a person opens table maintenance generator and tries to maintain the table, no one else can maintain table at the same time. This is because of table level lock by default in SAP. Only one user can maintain any table at a time. In report ZREP_SHUKS3 we will delete the table level lock and put row level lock so that multiple users can maintain table at same time. Rows locked by one user will not be editable by other user. Check the report and comments given below.

*&---------------------------------------------------------------------* *& Report ZREP_SHUKS3 *& *&--------------------------------------------------------------------*& Author : Swetabh Shukla *& Date : 05/22/2009 *& Description : To delete table level lock from table. *&---------------------------------------------------------------------* REPORT zrep_shuks3. **Selection range for view maintenance DATA: BEGIN OF selekttab OCCURS 1. "Selektionsbereich INCLUDE STRUCTURE vimsellist. DATA: END OF selekttab, **Table of inactive CUA functions for view maintenance BEGIN OF excl_cua_funct OCCURS 1. "inaktive CUA-Fkt bei View-Pflege INCLUDE STRUCTURE vimexclfun. DATA: END OF excl_cua_funct. DATA: lt_enq_del TYPE STANDARD TABLE OF seqg3, lt_enq_read TYPE STANDARD TABLE OF seqg7, lw_enq_read TYPE seqg7, lw_enq_del TYPE seqg3, lv_subrc TYPE sy-subrc. *Read all the lock details in system CALL FUNCTION 'ENQUE_READ2' EXPORTING gclient = sy-mandt gname = ' ' guname = '*' TABLES enq = lt_enq_read. *We will search entry for table level lock for our table LOOP AT lt_enq_read INTO lw_enq_read WHERE gname EQ 'RSTABLE' AND garg CS 'ZTEST_SHUKS3'. MOVE-CORRESPONDING lw_enq_read TO lw_enq_del. APPEND lw_enq_del TO lt_enq_del. ENDLOOP. *Delete table level lock entry for our table CALL FUNCTION 'ENQUE_DELETE' EXPORTING check_upd_requests = 1 IMPORTING subrc = lv_subrc

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

85/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

TABLES enq

= lt_enq_del.

*Now call the table maintenace generator. CALL FUNCTION 'VIEW_MAINTENANCE_CALL' EXPORTING action = 'U'= 'ZTEST_SHUKS3' view_name show_selection_popup = 'X' TABLES dba_sellist = selekttab excl_cua_funct = excl_cua_funct. 6. 

Just one more change in table maintenance screen. Now open table maintenance function group(ZTEST_SHUKS3) in SE80.We know for table maintenance SAP automatically creates code in the function group. Now we will make some modification in that existing code to change the behavior. Open the screen you created through table maintenance and add one module.

Open the screen 0001 and add one module in PBO of the screen as shown in figure below.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

86/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Check the code below to be added in the module m_change_locking. MODULE m_change_locking OUTPUT. *Call the function module corresponding to the lock object we created CALL FUNCTION 'ENQUEUE_EZTEST_SHUKS3' EXPORTING matnr = ztest_shuks3-matnr werks = ztest_shuks3-werks EXCEPTIONS foreign_lock = 1 system_failure = 2 OTHERS = 3. IF sy-subrc NE 0. * row is locked..hence gray.. LOOP AT SCREEN. screen-input = 0. MODIFY SCREEN. ENDLOOP. ENDIF. ENDMODULE. " m_change_locking OUTPUT 7. 

Now we are ready for testing. Call the transaction once and make some entries in table. In below screenshot I have entered some random values. Since we have not maintained any check tables etc, so values may be invalid. That can be taken care in real scenario.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

87/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Save data. Let‟s call two sessions of the transaction ZTEST_SHUKS3.

Session 1 In first session we will call the transaction ZTEST_SHUKS3 and try to open some existing values for table maintenance.

Let‟s open an existing value material = MAT1 and Plant = 0678.  

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

88/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  So the entry opens in change mode. Now open a second session of the transaction and see. Now the same material and plant combination can not be changed by any other user or session.

Session 2 Open transaction ZTEST_SHUKS3

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

89/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  So we can see that our transaction is able to achieve a row level locking and has removed table level locking. 

Creation of a table pool and pool table By Kiran Kumar Kandakatla, Intelligroup

In this Tutorial, we create a Table pool first and then create/ (add a table to Table pool) a Pooled Table. Step 1: Go to transaction SE11. Go to Utilities



Other Dictionary Objects

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

90/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

Step 3: Then Select Radio button Table Pool. Press Enter.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

91/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

Step 4:

Then you go to maintain Poll Screen there give Short Description.

Step 5: Then go to Technical settings.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

92/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Step 6: In the “Maintain technical Settings” screen Provide Size category.

Save and activate the table Pool. Go back to SE11. Step 7:

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

93/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

Go to SE11 ABAP Dictionary: Initial Screen. Create a Z table.

Step 8: Maintain Delivery and Maintenance attributes for the Z table.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

94/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Add fields to the Z table. Maintain Technical settings and Enhancement Category.

Step 9: Then Go to Extras Change table category

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

95/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Step 10: Choose Table type. In our Example it is Pooled table.

Step 11: Go back to Delivery and Maintenance tab and provide Pool/Cluster value.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

96/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  We have successfully created Table pool and Pooled table.

PDF Viewer By Sai Kumar B, Enteg

This Program helps you to view any output in PDF viewer as shown below. It‟s very simple to understand. Just convert OFT data into PDF as below. *&---------------------------------------------------------------------* *& Report ZSAP_PDF_VIEWER_DEMO_2 *& *&---------------------------------------------------------------------* REPORT

ZSAP_PDF_VIEWER.

DATA: LT_PDF TYPE TABLE OF TLINE, LS_PDF LIKE LINE OF LT_PDF, LV_URL TYPE CHAR255, PDF_FSIZE TYPE I, LV_CONTENT TYPE XSTRING, LT_DATA TYPE STANDARD TABLE OF X255. DATA : L_JOB_OUTPUT_INFO TYPE SSFCRESCL. DATA : LS_CONTROL_PARAM TYPE SSFCTRLOP. DATA : G_HTML_CONTAINER TYPE REF TO CL_GUI_CUSTOM_CONTAINER, G_HTML_CONTROL TYPE REF TO CL_GUI_HTML_VIEWER. DATA : P_VBELN TYPE

VBELN_VL.

FIELD-SYMBOLS TYPE X.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

97/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  INITIALIZATION. LS_CONTROL_PARAM-GETOTF = 'X'. LS_CONTROL_PARAM-NO_DIALOG = 'X'. START-OF-SELECTION. CALL FUNCTION '/1BCDWB/SF00000034' EXPORTING * ARCHIVE_INDEX = * ARCHIVE_INDEX_TAB = * ARCHIVE_PARAMETERS = CONTROL_PARAMETERS = LS_CONTROL_PARAM P_VBELN = P_VBELN * MAIL_APPL_OBJ = * MAIL_RECIPIENT = * MAIL_SENDER = * OUTPUT_OPTIONS = * USER_SETTINGS = 'X' IMPORTING *

DOCUMENT_OUTPUT_INFO = L_DOCUMENT_OUTPUT_INFO JOB_OUTPUT_INFO = L_JOB_OUTPUT_INFO * JOB_OUTPUT_OPTIONS = L_JOB_ OUTPUT_OPTIONS EXCEPTIONS FORMATTING_ERROR = 1 INTERNAL_ERROR = 2 SEND_ERROR = 3 USER_CANCELED = 4 OTHERS = 5 . IF SY-SUBRC 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. CALL FUNCTION 'CONVERT_OTF' EXPORTING FORMAT = 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.

* convert pdf to xstring string LOOP AT LT_PDF INTO LS_PDF. ASSIGN LS_PDF TO CASTING. CONCATENATE LV_CONTENT INTO LV_CONTENT IN BYTE MODE. ENDLOOP. CALL SCREEN 100.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

98/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

*&---------------------------------------------------------------------* *& Module STATUS_0100 OUTPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE STATUS_0100 OUTPUT. * SET PF-STATUS 'xxxxxxxx'. * SET TITLEBAR 'xxx'. CREATE OBJECT G_HTML_CONTAINER EXPORTING CONTAINER_NAME = 'PDF'. CREATE OBJECT G_HTML_CONTROL EXPORTING PARENT = G_HTML_CONTAINER. * Convert xstring to binary table to pass to the LOAD_DATA method CALL FUNCTION 'SCMS_XSTRING_TO_BINARY' EXPORTING BUFFER = LV_CONTENT TABLES BINARY_TAB = LT_DATA. * Load the HTML CALL METHOD G_HTML_CONTROL->LOAD_DATA( EXPORTING TYPE = 'application' SUBTYPE = 'pdf' IMPORTING ASSIGNED_URL = LV_URL CHANGING DATA_TABLE = LT_DATA EXCEPTIONS DP_INVALID_PARAMETER DP_ERROR_GENERAL CNTL_ERROR OTHERS

= = = =

1 2 3 4 ).

* Show it CALL METHOD G_HTML_CONTROL->SHOW_URL( URL = LV_URL IN_PLACE = 'X' ). ENDMODULE. " STATUS_0100 OUTPUT *&---------------------------------------------------------------------* *& Module USER_COMMAND_0100 INPUT *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* MODULE USER_COMMAND_0100 INPUT. ENDMODULE.

" USER_COMMAND_0100

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

INPUT

99/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

 

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

100/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

*&----------------------------------------------------------------* REPORT ytest_table_html1. *----------------------------------------------------------------* * D A T A D E C L A R A T I O N *----------------------------------------------------------------* *-HTML Table DATA: t_html TYPE STANDARD TABLE OF w3html WITH HEADER LINE, " Html Table *- Declare Internal table and Fieldcatalog it_flight TYPE STANDARD TABLE OF sflight WITH HEADER LINE, " Flights Details it_fcat TYPE lvc_t_fcat WITH HEADER LINE. " Fieldcatalog *-Variables DATA: v_lines TYPE i, v_field(40). *-Fieldsymbols FIELD-SYMBOLS: TYPE ANY. *----------------------------------------------------------------* * S T A R T - O F - S E L E C T I O N *----------------------------------------------------------------* START-OF-SELECTION. SELECT * FROM sflight INTO TABLE it_flight UP TO 20 ROWS. *----------------------------------------------------------------* * E N D - O F - S E L E C T I O N *----------------------------------------------------------------* END-OF-SELECTION. *-Fill the Column headings and Properties * catalog isdynamically used to populate the Headings and Values of * Field The table cells CALL FUNCTION 'LVC_FIELDCATALOG_MERGE' EXPORTING i_structure_name = 'SFLIGHT' CHANGING ct_fieldcat = it_fcat[] EXCEPTIONS inconsistent_interface = 1 program_error = 2. DELETE it_fcat WHERE fieldname = 'MANDT'. t_html-line = ''. APPEND t_html. CLEAR t_html. t_html-line = ''. APPEND t_html. CLEAR t_html. t_html-line = ''. APPEND t_html. CLEAR t_html. t_html-line = 'Flights Details'. APPEND t_html. CLEAR t_html. t_html-line = ''.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

101/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

102/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

TABLES data_tab EXCEPTIONS file_write_error no_batch gui_refuse_filetransfer invalid_type no_authority unknown_error header_not_allowed separator_not_allowed filesize_not_allowed header_too_long dp_error_create dp_error_send dp_error_write unknown_dp_error access_denied dp_out_of_memory disk_full

= t_html = = = = = = = = = = = = = = = = =

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 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 EXCEPTIONS cntl_error error_no_gui bad_parameter file_not_found path_not_found file_extension_unknown error_execute_failed synchronous_failed not_supported_by_gui OTHERS IF sy-subrc 0. MESSAGE ID sy-msgid TYPE

= = = = = = = = = = =

'OPEN' 1 2 3 4 5 6 7 8 9 10.

sy-msgty NUMBER sy-msgno

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

Result:

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

103/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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. 2. 3.

WWW_ITAB_TO_HTML_HEADERS is used to populate column headings. 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.  

*&---------------------------------------------------------------------* *& Report YTEST_TABLE_HTML *&

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

104/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

105/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

*-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 no_authority unknown_error header_not_allowed separator_not_allowed filesize_not_allowed header_too_long dp_error_create dp_error_send dp_error_write unknown_dp_error access_denied dp_out_of_memory disk_full

= = = = = = = = = = = = = =

4 5 6 7 8 9 10 11 12 13 14 15 16 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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

106/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

107/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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 20 w_vbak-vbeln, 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.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

108/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

109/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

 

From this method (DISPATCH) it calls the routine ON_CTMENU_REQUEST which is defined in our program.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

110/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

 

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

111/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Output: Basic list:

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

112/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

113/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

114/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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' 'SPOS' TO TO it_ucomm, 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'.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

115/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

116/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

117/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

118/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

*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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

119/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

 

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

On clicking Continue, it proceeds to SE16.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

120/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

121/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  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.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

122/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

 

Step 3. Select the variant from Variant catalog.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

123/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  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.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

124/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Select Binary Data

Select the Find Button

Press Press the Create button

Enter name and description

Select the image to upload

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

125/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Assign a package (must)

Press Save and OK

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

126/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  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.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

127/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

= 1. ENDIF.OTHERS 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.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

128/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Given below is the desired output

Custom Parameter-id Creation By Abhijit Daptary, Capgemini India

Step1: Creation of parameter ID. Parameter ID can be created in the table TPARA. Just enter the name of the parameter id in the table and that parameter ID will be created.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

129/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Go to the table maintenance generator of the table TPARA and go to the Maintain button through the transaction SM30. Enter the table view name TPARA.

Click on the maintain button. The following information will appear. Click on the Tick button or the ENTER button to go to the next screen.

Enter the Set/Get parameter id as the parameter ID you want to create. Here, I will be creating the parameter Id as ZNAME_DATA1. Click on ENTER button.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

130/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  It will ask for the text of the parameter Id. Enter the text of the parameter ID and click on the Save  button.

Enter the Package and the transport number. The parameter id can be seen in the table TPARA.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

131/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

Step2: Using the parameter Id that you have created. Now go to the SE11 transaction for creating a data element and enter the parameter id at the Further Characteristics tab at the parameter Id section.

Activate the data element and use it with the program. It will act the same good as a standard one.  

Create Dynamic Patterns By Joyjit Ghosh, IBM India

Step1. Create a pattern with only one line that contains *$&$EXIT. 

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

132/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

 

Put this above expression and press save button.

Step2. Now from CMOD create a project and include enhancement SEUED001 in it.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

133/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

 

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

134/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

135/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

APPEND w_buffer TO buffer. WHEN OTHERS. * Do nothing ENDCASE.

Lastly activate the project

Scheduling background jobs by triggering events

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

136/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

137/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

*& Report Z_TRIGGER_EVENT * *& * *&---------------------------------------------------------------------* *& * *& * *&---------------------------------------------------------------------* REPORT Z_TRIGGER_EVENT . CALL FUNCTION 'BP_EVENT_RAISE' EXPORTING eventid = 'Z_TRIGGER_JOB' EXCEPTIONS BAD_EVENTID = 1 EVENTID_DOES_NOT_EXIST = 2 EVENTID_MISSING = 3 RAISE_FAILED = 4 OTHERS = 5 . IF sy-subrc 0. Write: 'Event failed to trigger'. else. Write: 'Event triggered'. ENDIF.

Step3: Configure the background job from transaction SM36.

In the initial screen give job name and job class and press “Start condition” button.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

138/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

139/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

 

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

140/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

141/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  In the initial screen press save button.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

142/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Step4: Now execute the program to trigger the event and as well check the background  job.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

143/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Run transaction SM37

Check the status of job defined above

Now check the spool to see the generated list

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

144/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

 

Performance Tuning using Parallel Cursor By Suresh Kumar Parvathaneni, YASH Technologies

Nested Loops  – This is one of the fear factors for all the ABAP developers as this consumes lot of program execution time. If the number of entries in the internal tables is huge, then the situation would be too worse. The solution for this is to use parallel cursor method whenever there is a need for Nested Loop.  Program using Normal Nested Loop:  REPORT

ZNORMAL_NESTEDLOOP.

TABLES: likp, lips.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

145/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

Data: t_likp t_lips

type table of likp, type TABLE OF lips.

data: W_RUNTIME1 TYPE I, W_RUNTIME2 TYPE I. START-OF-SELECTION. select * from likp into table t_likp. select * from lips into table t_lips. get RUN TIME FIELD w_runtime1. loop at t_likp into likp. loop at t_lips into lips where vbeln eq likp-vbeln. endloop. endloop. get RUN TIME FIELD w_runtime2. w_runtime2 = w_runtime2 - w_runtime1. write w_runtime2.   Nested Loop using Parallel Cursor:  

REPORT

zparallel_cursor2.

TABLES: likp, lips. DATA: t_likp t_lips

TYPE TABLE OF likp, TYPE TABLE OF lips.

DATA: w_runtime1 TYPE i, w_runtime2 TYPE i, w_index LIKE sy-index. START-OF-SELECTION. SELECT * FROM likp INTO TABLE t_likp. SELECT * FROM lips INTO TABLE t_lips.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

146/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

GET RUN TIME FIELD w_runtime1. SORT t_likp BY vbeln. SORT t_lips BY vbeln. LOOP AT t_likp INTO likp. LOOP AT t_lips INTO lips FROM w_index. IF likp-vbeln NE lips-vbeln. w_index = sy-tabix. EXIT. ENDIF. ENDLOOP. ENDLOOP. GET RUN TIME FIELD w_runtime2. w_runtime2 = w_runtime2 - w_runtime1. WRITE w_runtime2. 

Analysis report: Runtime in microseconds: Iteration No 1 2 3

Normal Nested Loop 34,796,147 38,534,583 34,103,426

Using Parallel Cursor 63,829 56,894 50,510

Creating a Transaction Variant By Smita Singh

In this tutorial, we should would default discusstoabout creating a transaction fortype the and transaction MM01. transaction variant a value for Industry sector andvariant material should not allowOur the end user to change those values (output only). Go to transaction SHD0.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

147/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

Click Enter to proceed. Now the MM01 transaction would appear.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

148/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Select the required Industry sector and Material Type and press ENTER. Following popup would appear:

Now make the modifications as shown below:

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

149/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Click on “Exit and Save”. 

Following popup would appear:

Click Enter to proceed. Following screen would appear:

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

150/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Save your entries and go back to the main screen. Now enter the transaction variant name and click on Change button as shown below:

Now click on Insert Row. Enter the name of the screen variant created earlier or use F4 help to select the value:

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

151/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Now click on Goto



Create Variant Transaction

Enter the values as shown above. Click on Enter. The following SE93 transaction would appear:

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

152/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  The name of the Transaction Variant is automatically proposed. Save your entries. 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.

E-Mailing the background jobs By Harini 

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

153/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

This tutorial deals about the procedure in automatic e-mailing of the background jobs. The output of the background job is sent to the recipient as an email. 

Consider the following simple program: REPORT

zbackground_test.

WRITE: 'hello SAPTechnical.com team'.

We would schedule the above program as a background job and send the output of the same as an email. Go to Transaction SM36. Enter the job name.

Press Enter. Following popup screen appears:

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

154/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Enter your program name as shown above and click on SAVE.

Click on Back button to navigate to the main screen.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

155/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Click on the button “Spool list recipient” as shown above.

Enter the name of the recipient to which the output to be sent. Now come back to the main screen and click on “Start Condition”.  

Select Immediate and click on save.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

156/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Save your job. Only after you save, the job would be set to status Released.

You can go to transaction SM37 to monitor the background job. Now go to SAP inbox (transaction SBWP/SO01) to check the status of the background job:

In the above screenshot, you can observe an email related to the job we created earlier. Open the attachment to see the output of the background job:

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

157/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

158/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

Other Objects 

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

159/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

 

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

160/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

Application area corresponds to the application area you are working like B - Basis

C - CO

S – SD / SAM

F- FI

W - PM

M – MM/Supply

ABAP Performance Standards By Aveek Ghose, IBM India

Description 

Result (Y, N or N/A) 

Comments 

Run Extended syntax checks with character literals checkbox switched on & Code Inspector to rectify all relevant errors and warning (e.g. 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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

161/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

measure/compare program performance/runtime if program has multiple inefficient databases selects or complicated internal table operations  Use transaction ST05 (SQL Trace) to see what indices your database accesses are using. Check these indices against your “where” clause to assure they are significant. Check other indices for and where you have to change but your clause tothis usetable it. Create new indices if necessary, do“where” not forget to

check the impact by consulting onsite coordinator.   TYPE (data element) command is used while declaring the fields whenever feasible instead of LIKE. Remember not always the data element name matches with the table field name   Internal Table is defined with “TYPE STANDARD TABLE OF” & Work-Areas is used instead of header lines 

Global variables are minimized by declaring local variables or by passing variables through parameters & arguments while creating internal subroutine(s)  In SELECT statement, only the required fields are selected in the same order as they reside on the database table/structure/view  For selecting single rowSingle” from a is database table, “SELECT UP key to 1 Rows” is used. “Select used only when full primary combination is known  No SELECT * is used   Use “SELECT INTO TABLE” rather than “SELECT INTO CORRESPONDING FIELDS OF TABLE”  

Always specify as many primary keys as possible in WHERE clause to make the Select efficient   Always select into an internal table, except when the table will be very large (i.e., when the internal table will be greater than 500,000 records). Use “Up to N Rows” when the number of  records needed is known   Select statement within a GET event is not used  Wild cards like „A%‟ is avoided as much as possible   Nested Select is not used instead “Inner Join” and/or “For all Entries” is used. “For all Entries” is to be used over “Loop at ITAB / Select / ENDLOOP” (FOR ALL ENTRIES retrieves a unique result set so ensure you retrieve the full key from the database)  

When creating joins over database tables there should be an index at least on the inner table for the fields in the join condition else use “ FOR ALL ENTRIES” select statement  Usage of JOIN is limited to a maximum of 2 i.e. not more than 3 database tables are joined at one time  CHECK that the internal table used in FOR ALL ENTRIES is NOT empty as this will retrieve all entries from the table   Delete adjacent duplicate entries from internal table before selection from database table using “ FOR ALL ENTRIES” statement  For copying internal tables use „=‟ operator instead of Looping & Appending  SORT inside a LOOP is not used  

Sort internal table by fields in the correct order, which are used in a READ TABLE statement using BINARY SEARCH. If the order of sorting is invalid the BINARY SEARCH will never work   For large internal tables where only some rows are to be

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

162/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

processed, use SORT and then the READ TABLE command is used to set index to first relevant row before looping from that index. Use CHECK or IF…EXIT…ENDIF as appropriate to exit from the loop  Sort fields and Sort Order on the SORT statement should be mentioned explicitly (e.g. SORT ITAB BY FLD1 FLD2 Hashed table is used ASCENDING) for processing  large amount of data (provided that you access single records only, and all with a fully specified key)  DELETE or SORT is not used on a hashed table since it increases memory consumption  Sorted table is used for range accesses involving table key or index accesses  Fields specified in the WHERE condition with the critical operators NOT and (negative SQL statements) cannot be used for a search using database indexes. Whenever possible formulate SQL statements positively  When coding IF or CASE, testing conditions are nested so that the mostused frequently true conditions are processed first. “equal Also CASE instead of IF when testing multiple fields to” is something  LOOP AT ITAB INTO WORKAREA WHERE K = „XXX‟ should be used instead of LOOP AT ITAB INTO WORKAREA / CHECK ITAB-K = „XXX‟.   Also READ TABLE INTO WORKAREA should be used instead of only READ TABLE.  After the APPEND statement inside a loop, the work area that has been appended is cleared  Internal tables, Work areas & Global Variables are freed when no longer needed (e.g. using the FREE / REFRESH command), especially when the tables are large or the program is a batch program  Do not delete the records of internal table inside the Loop  – End loop. Do not use: LOOP AT ITAB WHERE EQUNR = „00001011‟.   DELETE ITAB. ENDLOOP. Use: DELETE ITAB WHERE EQUNR = „00001011‟.   Use MODIFY the MODIFY ... TRANSPORTING ... for single line, and ITABITAB ... TRANSPORTING f1 f2f1...f2WHERE condition for a set of line, to accelerate the updating of internal table   If possible, 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 

 

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

163/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om



Release the locks set at the beginning

Try to avoid logical databases. If your program uses a logical database, but does not require all fields belonging to a certain GET event, always use the FIELDS addition to reduce the amount of data selected by the logical database   Avoid the aggregate (Count, Max, Min) functions in the database selection  Use Parallel Cursor methods for nested loop into the internal tables if second internal table contains considerable number of records  In Smartform/ Sapscript do not make redundant data retrieval where data is available in interface 

Understanding SQL Trace By Aveek Ghose, IBM India Performing an SQL Trace:

1. 

Access transaction ST05. From the initial screen, click   the check box for SQL trace, under the trace requests, click Trace on. 2.  Run the program containing the SQL query that needs to be analyzed in the SE38 editor. 3.  Come back to ST05 screen, under Trace requests, click  Trace off .  4.

Click List trace to view the trace of the current statement.  

Screen shot of the initial ST05 screen

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

164/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  After clicking list trace  

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

165/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Basic List Trace 

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

166/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  The basic list trace shows the sequence of database operations that are taking place while a query is processed, it includes prepare, fetch, open, reopen, execute. In addition the basic list trace also gives the duration execution for each of the operations with color legend. Summarizing the basic trace list (menu path: Goto à Summary) 

A basic trace list can be summarized to see the summation of execution times of similar database operations. Use menu path: Goto Summary. The above screen shot depicts the summed up execution time. Theat summary option the summed of upaexecution of can all the that the the PID SQL –trace has captured its runtime, butlists the identification particulartime query be queries done using Process ID which is displayed as the first column of the above screen shot. For example, 896 is the process ID for one of the SQL statements. Summary of a particular trace

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

167/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  To get the total execution time, specifically for a particular SQL Statement, select all the PID corresponding to it and click summarize in the application toolbar. This leads to a compressed data of SQL trace as above. Color legends indicating the processes in a trace 1  

Use the menu path: Goto -> Show color legend to know about the color specification in the trace. Color legends indicating the processes in a trace 2  

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

168/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  The above screen shot indicates that the query execution time has exceeded its threshold with the link pink color. A change in object name is indicated with the change in color to yellow. These colors thereby indicate whether the query is well written and also the current status of the database server. Extended list 

(From basic trace list: click extended list button in application toolbar to view the extended list). The extended list shows the cursor id declared for the SQL statement, the connection type also . 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; such an area is also called a private SQL area. Although most Oracle users rely on the automatic cursor handling of the Oracle utilities, the programmatic interfaces offer application designers more control over cursors. In application development, a cursor is a

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

169/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

named resource available to a program and can be used specifically for the parsing of SQL statements embedded within the application. Identical select statements  

Use the menu path: Goto  Identical Selects to view a comprehensive list of identical select statements executed during the trace and the number of times they were executed. Identical select statements are grouped based on the where clause. Note  that identical select statements have similar execution plan used for their processing thereby saving time of execution and provide increased performance, too.  Identical select statements displayed  

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

170/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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. 1) DECLARE: This operation declares a new cursor and assigns the SQL statement to that cursor created.  2) PREPARE: This operation converts the SQL statement into native SQL and frames out an execution plan for that statement. 3) OPEN: This operation opens the declared cursor and passes the parameters for database access. 4) FETCH: This operation passes one or more data records fetched to the database interface of the R/3 system. 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. 6) EXEC: Passes the parameters for the database statement, and executes the statements that change data in the database (such as UPDATE, DELETE, or INSERT).  

Changing the text "Sales Order" to "Billing Request" in the transactions VA01, VA02 and VA03 By Vikram Chellappa, Mouri Tech Solutions  

Scenario: The below steps to be followed for Changing the text Sales Order to Billing Request in VA01, VA02, VA03 Transactions. Go to transaction VA01

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

171/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  In Menu bar Go to System > Status

Double click on the Screen number 101

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

172/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Double click on MODULE CUA_SETZEN

Double Click on PERFORM CUA_SETZEN.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

173/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Click on Enhance

(Shift+F4)

Click on Edit > Enhancement Operations > Show Implicit Enhancement Options

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

174/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

175/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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)

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

176/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

The Below screen will appear

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

177/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

178/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Click on Save and Assign it in corresponding Package.

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

179/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Go to SE80 create a new zprogram named ztitle.

Click on Yes.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

180/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Enter the Program name and continue.

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

181/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

Save it in Package.

Right Click on ztitle > Create >GUI Titles

Enter the Title Code And Title.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

182/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Click on Transfer or (Enter)

Create another Title code.

Assign the Title code and title.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

183/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Repeat the above same procedure.

Right Click on Ztitle and Click on Activate.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

184/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

 

The created GUI title will display under GUI Title.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

185/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Type SAPMV45A in Program > Go to Subroutines.

Scroll down in CUA_SETZEN.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

186/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  The Below screen will display.

Type the Below Code IF sy-tcode = 'VA01'.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

187/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

SET TITLEBAR 'Z01' OF PROGRAM 'ZTITLE' WITH . ELSEIF sy-tcode = 'VA02'. SET TITLEBAR 'Z02' OF PROGRAM 'ZTITLE' WITH . ELSEIF sy-tcode = 'VA03'. SET TITLEBAR 'Z03' OF PROGRAM 'ZTITLE' WITH . ENDIF. 

Click on save and Click on activate Enhancements (Ctrl+F3)

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

188/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Go to Program and Click on Generate.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

189/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

Go to VA02.

Go to VA03.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

190/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

 

Creation of a web service in SAP By Raghava Vakada, Mouri Tech Solutions “In this Scenario, I would like to explain about creating a Web Service with a simple scenario.”

Creating a Web Service In the function library (SE37), display the function module. Open the function Module

: ME_GET_CURRENT_USER_ID  

Choose Utilities  -> More Utilities  -> Creating a Web Service  -> From Function Module. 

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

191/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

192/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  In the following screen, enter the required data and select the checkbox Name Mapping . If the checkbox Name  Mapping is ticked, the wizard accepts the existing names for the end point.

Choose Continue . In the following screen, enter the required data and select the checkbox Release Service for runtime .

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

193/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

 

Choose Continue. 

Choose Complete. 

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

194/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Save as local object. Testing a Web Service. Prerequisites 

Open the transaction WSADMIN.

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.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

195/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  You have entered theunder address application Settings  server on transaction WSADMIN Goto of->the Administration . which the J2EE Engine is running in

Check the J2EE Server and check in your server. 

Choose Web Service Homepage (Execute Button ).  

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

196/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Select the “Document Style” under Style definition in WSDL.  

The Web service requires authentication. 

Enter the user and password

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

197/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

Click on the “Test”. 

Select the “Operations”.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

198/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

Fill in values for the method parameters underneath the heading Request if required . Choose Send. 

The required values are displayed under the Response  heading. The Web service has not been tested successfully.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

199/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

Calling a web service in ABAP that validates an email id By Teja

In this tutorial, we would use a free web service in an ABAP program which validates an emailid. For more details regarding this web service, click here.  Create a program and use the following code: REPORT zvalidate_email. PARAMETERS: p_mail(100) LOWER CASE. verified DATA: http_client TYPE REF TO if_http_client . DATA: w_string TYPE string , w_result TYPE string , r_str TYPE string . DATA: result_tab TYPE TABLE OF string.

" E-Mail id to be

START-OF-SELECTION . CLEAR w_string . CONCATENATE 'http://www.webservicex.net/ValidateEmail.asmx/IsValidEmail?Email=' p_mail INTO w_string . CALL METHOD cl_http_client=>create_by_url EXPORTING url = w_string IMPORTING

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

200/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

Handling favorites in ABAP Workbench By Sunitha 

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

201/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

This document details the procedure in handling the favorites in the ABAP Workbench. I would always want to add my frequently used objects in the favorites. For our learning purpose, let us add the package SWDP_DEMO_TUTORIALS (Demo tutorials for Web Dynpro ABAP) to the favorite list. Go to Transaction SE80 and select “Package” from the list box. 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:

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

202/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

Following screen appears:

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

203/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Using the Download/Upload buttons, we can either download/upload the favorites from one system to another. 

Events in Table Maintenance Scenario: We have a following custom table wh ich 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.

Go to Table Maintenance Generator:

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

204/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Enter the details as shown below:

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

205/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

 

Now click on Environment -> Modification -> Events

Following screen is displayed.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

206/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Click on F4. Following entries are displayed:

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

207/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  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. Testing the scenario: Go to SM30 and try creating new entries. Do not enter the values for “Created on” and “Created by”. 

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

208/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

Check your entries in the database table. You can observe that the date and user name are automatically filled-in. 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. This article is intended to demonstrate the comparison between three different methods in handling this situation. First Method: The normal method used by most of us. Standard internal table processing using WHERE condition Second Method: Same as above, 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. * Program to find the best method in reading the internal tables * Author: Suresh Kumar Parvathaneni * Type declaration TYPES: BEGIN OF TY_MARA, MATNR LIKE MARA-MATNR, MTART LIKE MARA-MTART, END OF TY_MARA. * Internal table declaration DATA: T_MARA TYPE STANDARD TABLE OF TY_MARA, T_MARA1 TYPE SORTED TABLE OF TY_MARA WITH NON-UNIQUE KEY MTART. * Variable declaration DATA: W_COUNTER TYPE I, W_RUNTIME1 TYPE I, W_RUNTIME2 TYPE I, W_TABIX LIKE SY-TABIX. * Table workarea definition DATA: WA_MARA TYPE TY_MARA. SELECT MATNR " Material Number MTART " Material Type FROM MARA INTO TABLE T_MARA. T_MARA1[] = T_MARA[]. * CASE 1: Processing internal table using LOOP..WHERE Condition GET RUN TIME FIELD W_RUNTIME1.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

209/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

LOOP AT T_MARA INTO WA_MARA WHERE MTART EQ 'FHMI'. ADD 1 TO W_COUNTER. ENDLOOP. GET RUN TIME FIELD W_RUNTIME2. * Calculate Runtime W_RUNTIME2 = W_RUNTIME2 - W_RUNTIME1. WRITE W_RUNTIME2. CLEAR W_COUNTER. * CASE 2: Using a Sorted table GET RUN TIME FIELD W_RUNTIME1. LOOP AT T_MARA1 INTO WA_MARA WHERE MTART EQ 'FHMI'. ADD 1 TO W_COUNTER. ENDLOOP. GET RUN TIME FIELD W_RUNTIME2. * Calculate Runtime W_RUNTIME2 = W_RUNTIME2 - W_RUNTIME1. WRITE W_RUNTIME2. CLEAR W_COUNTER. * CASE 3: Using INDEX on a sorted table GET RUN TIME FIELD W_RUNTIME1. READ TABLE T_MARA1 INTO WA_MARA WITH KEY MTART = 'FHMI'. IF SY-SUBRC EQ 0. W_TABIX = SY-TABIX + 1. ADD 1 TO W_COUNTER. LOOP AT T_MARA1 INTO WA_MARA FROM W_TABIX. IF WA_MARA-MTART NE 'FHMI'. EXIT. ENDIF. ADD 1 TO W_COUNTER. ENDLOOP. ENDIF. GET RUN TIME FIELD W_RUNTIME2. * Calculate Runtime W_RUNTIME2 = W_RUNTIME2 - W_RUNTIME1. WRITE W_RUNTIME2.

Following is the analysis report in microseconds, as per the data volume: Records: 21,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

Using Sorted table LOOP & WHERE 35774 38250

Using INDEX on Sorted table 3567 3592

Records: 132,693 Iteration No 1 2

Using Normal LOOP & WHERE 34239 34271

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

210/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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. However, from the above statistics, we can say that method 3 is better than the other 2 methods. In production environment, the data would be huge and the performance could be much improved with this simple technique.

Displaying Graphics using an ABAP Program By Raghava Vakada, Mouri Tech Solutions “I would like to explain about a simple report program to display graphic s. The SAP Graphics can be used for various business purposes”.

In this article I am explaining about a simple Sales analysis on a yearly basis. *&---------------------------------------------------------------------* *& Report ZGRAPH_TEST *& *&---------------------------------------------------------------------* REPORT ZGRAPH_TEST. DATA: BEGIN OF TAB OCCURS 5, CLASS(5) TYPE C, VAL1(2) TYPE I, VAL2(2) TYPE I, VAL3(2) TYPE I, END OF TAB. DATA: BEGIN OF OPTTAB OCCURS 1, C(20), END OF OPTTAB. MOVE: 'fan' TAB-CLASS, 12 TO TO TAB-VAL1, 8 TO TAB-VAL2, 15 TO TAB-VAL3. APPEND TAB. CLEAR TAB. MOVE: 'cool' TO TAB-CLASS, 15 TO TAB-VAL1, 10 TO TAB-VAL2, 18 TO TAB-VAL3. APPEND TAB. CLEAR TAB. MOVE: 'DA' TO TAB-CLASS, 17 TO TAB-VAL1, 11 TO TAB-VAL2, 20 TO TAB-VAL3. APPEND TAB. CLEAR TAB. OPTTAB = 'FIFRST = 3D'. APPEND OPTTAB. "// Grafik-Typ OPTTAB = 'P3TYPE = TO'. APPEND OPTTAB. "// Objektart OPTTAB = 'P3CTYP = RO'. APPEND OPTTAB. "// Farben der Objekte OPTTAB = 'TISIZE = 2'. APPEND OPTTAB. "// Haupttitelgröße   OPTTAB = 'CLBACK = X'. APPEND OPTTAB. "// Background Color CALL FUNCTION 'GRAPH_MATRIX_3D' EXPORTING COL1 = '1997' COL2 = '1998' COL3 = '1999' DIM2 = 'Products'

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

211/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

DIM1 TITL TABLES DATA OPTS EXCEPTIONS OTHERS LEAVE PROGRAM. 

= 'Years' = 'Sales In Rs. Crores' = TAB = OPTTAB = 1.

Results : Execute the report program for an output shown below.

Click on Overview for detailed view.

To display more detailed view.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

212/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

 

The ABAP New Editor  TM

By Suresh Kumar Parvathaneni This article, the first part of a two-article series, 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 SA P® GUI for windows 6.40 patch level 10 or higher. However this new editor is supported from the SAP® Version SAP® Netweaver 2004s. 

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. Procedure to shift between Old ABAPTM Editor and New ABAPTM Editor: 

 

Go to Utilities à Settings

 

Click on Front-end Editor (New) as shown below 

 

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

213/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

 

 



Click

for changes to effect.

Features in ABAP

TM

New Editor 

First Look: 

View of the new ABAPTM Editor (from SE38): 

Display Features  Following are some of the features that could be observed while writing the code:  

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

214/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

Line Numbers 

As observed in the above screenshot, the new ABAP TM editor displays the line numbers for easy navigation through the code. Changed line indicators 

The changed lines in the current session are marked with

.

These indicators would vanish once you come out of the program.

Bookmarks  Bookmarks allow in navigating and code editing. There are 9 numbered bookmarks provided by SAP® and unlimited unnumbered bookmarks. Bookmarks could be accessed by the right click of the mouse in the Indicator Margin (The complete left portion of the ABAPTM editor).

To set a bookmark, right click on the Indicative Margin, click on Bookmarks --> Bookmark 0 (Bookmarks are numbered 0 to 9). A Blue flag with the bookmark number would appear on the Indicative Margin. To navigate to any bookmark marked earlier, right click on the Indicative Margin, Go to Bookmark --> Bookmark 0.

Code Hints  Code hints appear as you type in ABAP TM editor. For example, if you start typing for Parameters, following occurs:

   

 

When typed P, nothing appears. When typed PA, code hint PACK appears.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

215/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

 



When typed PAR, code hint PARAMETERS appears.

Press TAB to choose the given code hint.

Changing the Font and Colors of coding environment   Click on , available at the right side bottom of the editor. Click on “Fonts and Colors” on the left side of the window that is appeared after clicking. From here, we can set different colors and fonts for different elements on the editor.

Window Splitter 

The window splitter allows you to work on different parts of the code simultaneously. The window could be set to splitter mode by double clicking the splitter line above the vertical scrollbar (shown below).

The split screen is seen as below:

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

216/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

 

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, click on the button “options” available at the bottom of the right hand side, as

shown in the below screen shot:

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

217/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Following pop-up appears:

Now select “Fonts and Colors” available on the left side.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

218/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Using this, you can design how the screen should look like, For example, you can dictate how the comments should appear (like Font, size, foreground color and background color). Let us take the same “comments” section for our scenario here.  Comments are currently displayed as shown below:

Now click on the options button and select “Fonts and Colors”. Select “Comments” from the list box:

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

219/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Now change the way you would like the options to appear in this section:

Save and check how the way comments appear now.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

220/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Working with Code Templates: To view the Code Templates currently available, Click on “Options” as shown earlier. Now click on “Code Templates” option available on the left side.

You would observe the code templates available for use with the editor. Click on any code template to understand further.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

221/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

    Above screenshot is for “DO”. We would use this for our demo purpose to better under stand the code

template. Write some sample code in your editor.

Now select your program code and click the right button of the mouse. Select -> Format -> Surround by template -> Do () (as shown in the following screenshot)

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

222/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Now observe your code:

Your code is now surrounded by the code template “DO”.  

Creating custom code template: Now we would work on creating our own code template for our future use. As observed in the earlier screenshots, there is no code template available for subroutine. Let us create a code template for the same.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

223/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Select your code and click on right button. Select Format -> Extract template

Enter the name for your code template.

Click on OK.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

224/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

 

Now we need to define the position where the selected text (surrounded text) to appear. Click

on

the

empty

line

between

“form”

and

“endform”

and

click

on

“Insert

tag”

Select Surrounded Text from the given options.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

225/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Save and exit. To test our code template, write a sample code in our program.

Right click and select our code template.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

226/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  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.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

227/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Activate your program. To set the break-point, click on indicator margin, available on the left side of the line numbers. (See the screenshot below):

Break-point in set now.

Working with Menu Painter By Raghava Vakada, Mouri Tech Solutions For theoretical concepts on Menu Painter, please visit SAP.help.com

Create a program in SE38 T- Code.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

228/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Enter the Title of the Program And Select the Type as Executable Program. And click on save. Save it in a Relevant Package.

Go to T-code SE41 Enter the Program name and Status name.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

229/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Click on create

Enter the Short text for Status.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

230/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Click

on

Menu

Bar.

Specify a Menu Name file

Double click on File.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

231/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Enter the Code and text Values.

Click on save, check and Activate. Press Execute or F8.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

232/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Click on Continue and Enter.

Created Menu is displayed here.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

233/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

 

To create a Title, Click on Title List. 

Click on create.

Enter the Title Code and Title. Click on continue.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

234/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

Click on enter and Click on Test.

Enter the created Title Code in Title, Click on execute.

Click on Continue.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

235/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Created

Title

Displayed.

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

236/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

Click on middle Icon .

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

237/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

238/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

Select the require fields and click on continue.

Insert these boxes on the screen.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

239/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  You can view like this after placing the boxes.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

240/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Create require Push buttons from toolbox.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

241/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

Create require check box from toolbox.

Give the required Name , Text and Function Code Name . Click on Save, Check and Activate.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

242/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Output:

Enter the Material number and Press Display.

Click on Display.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

243/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Values are displayed as shown below.

Similarly You Can View Clear And Exit. Clear – It will clear all the displayed contents.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

244/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Exit - It will return to code..

We can Use the same operation in Function Keys.      

F5 Clear F6 Display F7 Exit.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

245/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Enter the Material and Press F6 . The same functionality F5 to Clear and F7 to Exit.

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. 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. For example: On the selection screen of a report, take a Date field, which needs to be dynamic. From Date should be „Current date –   15‟ and To Date should be „Current Date‟. In this way the report when run with this variant, it would be possible to retrieve all those records which

are past 15 days entries from now.

Please find below the procedure to define DYNAMIC Variant.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

246/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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.

Step2: Specify all those values which are static on the selection screen in this step. The n click „Variant

 Attributes‟ to define selection variable for „Date Created‟ on the selection screen.  

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

247/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

248/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Step 4: In the previous step, select „Selection Variables‟ on the menu. It leads to the next screen as shown below. As we have decided to create selection variable for „Date created‟ item only, in this screen you get to see the variable as „Date created‟. Here you are provided with three options.

T: Table variable from TVARV D: Dynamic Date Calculation B: User defined Variables. From the provided options as per our requirement select „D‟ option. This can be done by click ing the Traffic lights under „D‟as shown below to know that the particular option is selected.

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.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

249/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Step 5: Find the suitable formula as „Current date –   xxx, current date + yyy‟ and select it. This will lead

you to the next screen to enter the values for xxx and yyy. So, provide values as 15 for xxx and 0 for yyy. Save the variant and this will conclude the creation of dynamic variant with the help of selection variable. This variant can also be used in the background jobs.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

250/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

 Creating

F1 helps in ease

By Gaurab Banerji

Go to SE61 and create a general text TX like the one shown below.   

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. If you don‟t want to specify a bold text you can just type it in the DOKTITLE in the function module called.

Save the Text. Now Displaying the F1 Help. I have modified an existing program for showing F1 help. See below   *&---------------------------------------------------------------------* *& Report ZGB_TEST_SEARCH_HELP *&

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

* *

251/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

*&---------------------------------------------------------------------* *& *& *&---------------------------------------------------------------------*  

REPORT

ZGB_TEST_SEARCH_HELP

* *

.

* INTERNAL FOR STORING IN SELECTION LIST data: beginTABLE of t_itab occurs NAMES 0, name(10) type c, end of t_itab. *FIELDNAME AND TAB NAME FOR THE SELECTION DATA :field_tab LIKE dfies OCCURS 0 WITH HEADER LINE. *THE TABLE FOR RETURNING THE NAME OF THE SELECTED ITEM DATA : return_tab LIKE ddshretval OCCURS 0 WITH HEADER LINE. *START THE SELECTION SCREEN BLOCK selection-screen begin of block ss1 with frame. parameters: p_name1(10) type c. selection-screen end of block ss1. *&---------------------------------------------------------------------* *& * *& F4 Help for p_name1 * *&---------------------------------------------------------------------* at selection-screen on value-request for p_name1. *CLEAR ALL EXISTING DATA *TO BE DONE EVERYTIME F4 HELP IS REQUESTED REFRESH t_itab. REFRESH field_tab. field_tab-fieldname = 'ERNAM'. field_tab-tabname = 'VBAK'. APPEND field_tab. t_itab-name = 'Andrews'. append t_itab. t_itab-name = 'Jennie'. append t_itab. 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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

252/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

RETURN_TAB = return_tab * DYNPFLD_MAPPING = EXCEPTIONS PARAMETER_ERROR = 1 NO_VALUES_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. else. p_name1 = return_tab-fieldval. ENDIF. *&---------------------------------------------------------------------* *& * *& F1 Help for p_name1 * *&---------------------------------------------------------------------* at selection-screen on help-request for p_name1. CALL FUNCTION 'DSYS_SHOW_FOR_F1HELP' EXPORTING *

* * * * * * * * *

APPLICATION dokclass DOKLANGU dokname DOKTITLE HOMETEXT OUTLINE VIEWNAME Z_ORIGINAL_OUTLINE CALLED_FROM_SO70 SHORT_TEXT APPENDIX IMPORTING

= = = = = = = = = = = =

'SO70' 'TX' SY-LANGU 'Z_GAURAB_DEMO' 'This appears as bold title' ' ' ' ' 'STANDARD' ' ' ' ' ' ' ' '

* APPL = * PF03 = * PF15 = * PF12 = EXCEPTIONS CLASS_UNKNOWN = 1 OBJECT_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.

Apart from the FM DSYS_SHOW_FOR_F1HELP,following FM‟s can also be used:  1. 2.

HELP_OBJECT_SHOW_FOR_FIELD HELP_OBJECT_SHOW 

Here is the output

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

253/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

 

Object oriented programming (OOP) explained with an example By Gaurab Banerji

Create a class that keeps track of a bank account balance. Then write a program to use this class.

Steps involved:     

 



Run the class builder utility (SE24).  Create a class called ZACCOUNTxx, where xx is the last two digits of your logon ID.  Declare a PRIVATE attribute BALANCE of type DMBTR to store the account balance.  Create the following PUBLIC methods: SET_BALANCE (Sets the balance to a new value)  o  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.)   IMPORTING AMOUNT TYPE DMBTR   RETURNING NEW_BALANCE TYPE DMBTR   EXCEPTIONS INSUFFICIENT_FUNDS  Activate all elements of your class.  Write a program called Z_USE_ACCOUNT_xx, 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.  o Set the account balance to some initial value.  o Make several deposits and withdrawals, printing the new balance each time. Do not allow the balance to become less than zero. (Use the exception to detect this.) Test and debug your program. 

"Extra Credit": If you have extra time, try any of the following: 

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

254/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om





Replace the SET_BALANCE method with a constructor. Pass the opening balance when you instantiate the account object.  Create a static attribute and methods to set and get the name of the bank that holds the accounts. 

Step-by-step approach with screen-shots  Go to SE24 (Class builder) Type in ZACCOUNTAA as the name of the class and press Create.

Define 3 methods DEPOSIT, SET_BALANCE and WITHDRAW.

Place the mouse cursor in DEPOSIT and hit the Parameters button.

Write the parameters imported / exported for DEPOSIT method. Similarly for SET_BALANCE

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

255/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  And WITHDRAW

For withdraw we define an exception.

We can see the attributes and methods by pressing “Display object list” button on top. 

Now we IMPLEMENT the 3 methods. Double click the method DEPOSIT.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

256/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

 

Write the required code. Similarly for SET_BALANCE

Similarly for WITHDRAW.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

257/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

Now we are almost done creating the object. Press CTRL + F3 to activate or hit the Matchstick. We will see this in the status Now we are done building the global class we can test it. Press F8.

Click SET_BALANCE. Write the NEW_BALANCE and press ENTER.

We come back to Initial Screen. Now click DEPOSIT.

We see the return Values now.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

258/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Now let‟s WITHDRAW 4000

Now the BALANCE is 2000 Lets try withdrawing 3000 now.

We get an exception.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

259/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

Given below is an example code for using the global class we defined. . 

REPORT ZGB_OOPS_BANK DATA: acct1 type ref to zaccountaa.   DATA: bal type i.  create object: acct1.   selection-screen parameters:

begin p_amnt p_dpst p_wdrw

of

block type type type

a. dmbtr, dmbtr, dmbtr.

selection-screen end of block a.  start-of-selection.  call method write:/ 'Set balance to ', p_amnt. 

acct1->set_balance(

p_amnt

).

bal = acct1->deposit( write:/ 'Deposited ', p_dpst ,' bucks making balance to ', bal.  

p_dpst

).

bal = acct1->withdraw( write:/ 'Withdrew ', p_wdrw ,' bucks making balance to ', bal.

p_wdrw

).

This is the output.

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:

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

260/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

We would develop a small RFC function module in D05 system, which would add two variables. We would pass two variables from DS3 to D05 and get back the sum of those two variables back  to DS3. Activities to be performed in the system D05

Go to SE37. Under Utilities > Create Function Group (say ZGB_FUNC), if doesn‟t exists.  Now create a New Function Module ZGB_FUNC01

Under

IMPORT

Tab,

define

the

following

variables

Under EXPORT Tab

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

261/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  In

the

Source

Code

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

262/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

Activities to be performed in the System DS3  

Create an RFC destination from DS3 to D05. Go to SM59, Press Create. Enter the RFC Destination name: D05-205-TEST Connection Type: 3 In Description: Test Connection to D05 In

The

Technical

Settings

Tab,

enter

the

system

details

In The Logon/Security Tab, enter the logon details. Click on Save. A Popup will imply that connection has been created Now Press the TEST CONNECTION to check the connection.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

263/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  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. For that we have to test REMOTE LOGON. Press the REMOTE LOGON button If we can see this

And this

Then our connection was successful. However if we see the screen as shown below then there is an authentication failure (user-id or password is wrong).

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

264/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  The new connection will become visible in the SM59 list like this.

After establishing the connection, let us create a program, which would trigger the RFC in D05 system. Go to SE38 and create a program ZGB_RFC Write the following code

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

265/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Activate (Ctrl+F3) and Execute (F8) Type any two numbers.

Press (F8) Again. We have the desired output.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

266/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

Uploading Material Master Long Text (Basic data text, Inspection text, Internal comment) By Teja This program could be used to upload the material master long text (Basic data text, inspection text, internal comment). 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. REPORT ZMM_INSERT_LONGTEXT. *Internal table to hold long text... DATA: BEGIN OF T_UPLOAD OCCURS 0, MATNR LIKE MARA-MATNR, " ID(2) TYPE C, " LTEXT LIKE TLINE-TDLINE, " END OF T_UPLOAD, *Internal table to hold long text.... T_LINE LIKE TLINE OCCURS 0 WITH HEADER DATA:

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

Material number Identification Long text

LINE.

267/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

W_GRUN LIKE THEAD-TDID , " To hold id W_OBJECT LIKE THEAD-TDOBJECT VALUE 'MATERIAL', " To hold object id LV_VALUE(70). " Value to hold material number START-OF-SELECTION. * 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. *&---------------------------------------------------------------------* *& 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. DATA: L_ID LIKE THEAD-TDID, L_NAME(70). MOVE : P_C_GRUN TO L_ID, P_LV_VALUE TO L_NAME. 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 . IF SY-SUBRC 0. CLEAR LV_VALUE. ELSE. DELETE T_LINE INDEX 1. ENDIF. ENDFORM. " create_text *&---------------------------------------------------------------------* *& Form upload_file *&---------------------------------------------------------------------* * This routine is used to upload file *----------------------------------------------------------------------* * No interface parameters are passed *----------------------------------------------------------------------* FORM UPLOAD_FILE . CALL FUNCTION 'UPLOAD' EXPORTING * CODEPAGE = ' ' * FILENAME = ' '

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

268/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

* * * * * * * * * * * * * * *

FILETYPE ITEM FILEMASK_MASK FILEMASK_TEXT FILETYPE_NO_CHANGE FILEMASK_ALL FILETYPE_NO_SHOW LINE_EXIT USER_FORM USER_PROG SILENT IMPORTING FILESIZE CANCEL ACT_FILENAME ACT_FILETYPE TABLES DATA_TAB EXCEPTIONS CONVERSION_ERROR

= = = = = = = = = = =

'DAT' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' 'S'

= = = = = T_UPLOAD = 1

INVALID_TABLE_WIDTH = 2 INVALID_TYPE = 3 NO_BATCH = 4 UNKNOWN_ERROR = 5 GUI_REFUSE_FILETRANSFER = 6 OTHERS = 7 . IF SY-SUBRC 0. * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO * WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. SORT T_UPLOAD BY MATNR ID. ENDFORM. " upload_file *&---------------------------------------------------------------------* *& Form place_longtext *&---------------------------------------------------------------------* * This routine places the text in MM02 transaction *----------------------------------------------------------------------* * No interface parameters are passed *----------------------------------------------------------------------* FORM PLACE_LONGTEXT . LOOP AT T_UPLOAD. T_LINE-TDFORMAT = 'ST'. T_LINE-TDLINE = T_UPLOAD-LTEXT. APPEND T_LINE. IF T_UPLOAD-ID EQ 'BT'. MOVE T_UPLOAD-MATNR TO LV_VALUE. MOVE 'GRUN' TO W_GRUN. "Test ID for Basic data text PERFORM CREATE_TEXT USING W_GRUN LV_VALUE. ENDIF. IF T_UPLOAD-ID EQ 'IT'. CLEAR W_GRUN. MOVE T_UPLOAD-MATNR TO LV_VALUE. MOVE 'PRUE' TO W_GRUN. "Test ID for Inspection text PERFORM CREATE_TEXT USING W_GRUN LV_VALUE. ENDIF.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

269/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

IF T_UPLOAD-ID EQ 'IC'. CLEAR W_GRUN. MOVE : T_UPLOAD-MATNR TO LV_VALUE, 'IVER' TO W_GRUN. "Test

ID

for

Internal

comment PERFORM CREATE_TEXT USING W_GRUN LV_VALUE. ENDIF. ENDLOOP. ENDFORM. " place_longtext

System Debugging By Selvamani

Consider the following program, which contains a simple call to the function module ICON_SHOW.

Set a breakpoint at the CALL FUNCTION statement and now execute the program.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

270/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Ensure that the system debugging is switched off, by selecting Settings



system debugging.

On pressing F5, instead of going into the code of the function module, the function module is executed and the following pop-up is shown:

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

271/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

Select a record and press CONTINUE, the program is executed without going into the debug mode of the function module. Reason? Now go to the function module ICON_SHOW. Select Goto

Now again select Goto





Main Program.

Attributes

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

272/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

 

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

273/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

Can we set the custom programs as system programs? Go to our program which has a call to the function module ICON_SHOW. Set the debug point at the CALL FUNCTION statement.

Go to program attributes and set the status to System Program.

Now try debugging the program with system debugging off. This time, the debug point will not even reach the CALL FUNCTION statement. Once you turn the system debugging ON, both our program and the standard function module could be debugged.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

274/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

MESSAGE xxxx RAISING xxxx By Suresh Kumar Parvathaneni  

In general, exceptions in a function module are handled by means of RAISE EXCEPTION. This sets a return code which is passed back to the calling program. For eg., let us consider an example of a function module SXXXX, which would create a purchase order with reference to a Purchase Requisition. The import parameter for this function module is Purchase Requisition number and the export parameter is the Purchase Order number created here. Assume that after a PR is created, a material is moved from one plant to another. Now during the PO creation, because of this mismatch the PO would not be created. In a normal case, if there is any mismatch, we generally use RAISE EXCEPTION XXXX. This would stop the function module from further processing and returns to the calling program with just the return code. But the calling program would never know the material number that caused this error. Now, instead of raising the exception using RAISE EXCEPTION, we would use the following statement: MESSAGE E309(06) with „xxx‟ Raising XXXX.

Using the above statement is similar to the usage of RAISE EXCEPTION, except for: 



If the call to the function module does not handle EXCEPTIONS, then the message is issued (in this case the error message is issued)  

If the calling program handles the exception, then no message is issued. The calling program would have the message details in the standard message variables SY-MSGID, SY-MSGV1 and others. So in our case, the calling program would have the information about the material and plant combination that triggered the exception.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

275/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

 

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. BDC is not a typical integration tool, in the sense that, it can be only be used for uploading data into R/3 and so it is not bi-directional. BDC works on the principle of simulating user input for transactional screen, via an ABAP program. Typically the input comes in the form of a flat file. The ABAP program reads this file and formats the input data screen by screen into an internal table (BDCDATA). The transaction is then started using this internal table as the input and executed in the background.

In Call Transaction , the transactions are triggered at the time of processing itself and so the ABAP program must do the error handling. It can also be used for real-time interfaces and custom error handling & logging features. Whereas in Batch Input Sessions, the ABAP program creates a session with all the transactional data, and this session can be viewed, scheduled and processed (using Transaction SM35) at a later time. The latter technique has a built-in error processing mechanism too. Batch Input (BI) programs still use the classical BDC approach but doesnt require an ABAP program to be written to format the BDCDATA. The user has to format the data using predefined structures and store it in a flat file. The BI program then reads this and invokes the transaction mentioned in the header record of the file. Direct Input (DI) programs work exactly similar to BI programs. But the only difference is, instead of processing screens they validate fields and directly load the data into tables using standard function modules. For this reason, DI programs are much faster (RMDATIND - Material Master DI program works at least 5 times faster) than the BDC counterpart and so ideally suited for loading large volume data. DI programs are not available for all application areas.

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. 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. LSMW offers different techinque for migrating data: Direct input ,BAPI,Idoc,Batch input recording. While bdc basically uses recording. LSMW mapping is done by SAP while in BDC we have to do it explicitly .

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

276/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

 



 



LSMW is basically for standard SAP application while bdc basically for customized application. 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.  Unused/Dead code Avoid leaving unused code in the program. Either comment out or delete the unused situation. Use program --> check --> extended program to check for the variables, which are not used statically.

2.  Subroutine Usage For good modularization, the decision of whether or not to execute a subroutine should be made before the subroutine is called. For example: This is better: 

IF f1 NE 0. PERFORM sub1. ENDIF. FORM sub1. ... ENDFORM. Than this: PERFORM sub1. FORM sub1. IF f1 NE 0. ... ENDIF. ENDFORM.

3.  Usage of IF statements When coding IF tests, nest the testing conditions so that the outer conditions are

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

277/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

those which are most likely to fail. For logical expressions with AND , place the mostly likely false first and for the OR, place the mostly likely true first. Example - nested IF's: IF (least likely to be true). IF (less likely to be true). IF (most likely to be true). ENDIF. ENDIF. ENDIF. Example - IF...ELSEIF...ENDIF : IF (most likely to be true). ELSEIF (less likely to be true). ELSEIF (least likely to be true). ENDIF. Example - AND: IF (least likely to be true) AND (most likely to be true). ENDIF. Example - OR: IF (most likely to be true) OR (least likely to be true). 4.  CASE vs. nested Ifs 

When testing fields "equal to" something, one can either nested IF orabout the CASE statement. The CASE is better for two reasons. It isuse easier to the read and after five nested IFs the performance of the CASE is more efficient.  

5.  MOVE statements When records a and b have the exact same structure, it is more efficient to MOVE a TO b than to MOVE-CORRESPONDING a TO b.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

278/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

MOVE BSEG TO *BSEG.  is

better than

MOVE-CORRESPONDING BSEG TO *BSEG. 6.  SELECT and SELECT SINGLE  When using the SELECT statement, study the key and always provide as much of the leftmost part of the key as possible. If the entire key can be qualified, code a SELECT SINGLE not just a SELECT. If you are only interested in the first row or there is only one row to be returned, using SELECT SINGLE can increase performance by up to three times.

7.  Small internal tables vs. complete internal tables

In general it is better to minimize the number of fields declared in an internal table. While it may be convenient to declare an internal table using the LIKE command, in most cases, programs will not use all fields in the SAP standard table. For example: Instead of this: data: t_mara like mara occurs 0 with header line. Use this: data: begin of t_mara occurs 0, matnr like mara-matnr, ... end of t_mara.

8.  Row-level processing and SELECT SINGLE Similar to the processing of a SELECT-ENDSELECT loop, when calling multiple SELECTSINGLE commands on a non-buffered table (check Data Dictionary -> Technical Info), you should do the following to improve performance: o 

Use the SELECT into to buffer the necessary rows in an internal table, then



sort the rows by the key fields, then



use a READ TABLE WITH KEY ... BINARY SEARCH in place of the SELECT SINGLE command. 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).

9.  READing single records of internal tables  When reading a single record in an internal table, the READ TABLE WITH KEY is not a direct READ. This means that if the data is not sorted according to the key, the system must sequentially read the table. Therefore, you should: o 

SORT the table

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

279/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om



use READ TABLE WITH KEY BINARY SEARCH for better performance.

10.  SORTing internal tables  When SORTing internal tables, specify the fields to SORTed. SORT ITAB BY FLD1 FLD2. is more efficient than SORT ITAB. 

11.  Number of entries in an internal table To find out how many entries are in an internal table use DESCRIBE. DESCRIBE TABLE ITAB LINES CNTLNS. is more efficient than LOOP AT ITAB. CNTLNS = CNTLNS + 1. ENDLOOP.

12.  Performance diagnosis To diagnose performance problems, it is recommended to use the SAP transaction SE30, ABAP/4 Runtime Analysis. The utility allows statistical analysis of transactions and programs. 

13.  Nested SELECTs versus table views Since releASE 4.0,toOPEN SQL allows bothconcept. inner andHowever, outer table A nestedofSELECT loop may be used accomplish the same thejoins. performance nested SELECT loops is very poor in comparison to a join. Hence, to improve performance by a factor of 25x and reduce network load, you should either create a view in the data dictionary then use this view to select data, or code the select using a join.

14.  If nested SELECTs must be used As mentioned previously, performance can be dramatically improved by using views instead of nested SELECTs, however, if this is not possible, 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. data: t_vbak like vbak occurs 0 with header line. data: t_vbap like vbap occurs 0 with header line. select * from vbak into table t_vbak up to 200 rows. select * from vbap for all entries in t_vbak where vbeln = t_vbak-vbeln. ... endselect.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

280/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

endform. Instead of this: form select_bad. select * from vbak up to 200 rows. select * from vbap where vbeln = vbak-vbeln. ... endselect. endselect. endform. Although using "SELECT...FOR ALL ENTRIES IN..." is generally very fast, you should be aware of the three pitfalls of using it: Firstly, SAP automatically removes any duplicates from the rest of the retrieved records. Therefore, if you wish to ensure that no qualifying records are discarded, the field list of the inner SELECT must be designed to ensure the retrieved records will contain no duplicates (normally, this would mean including in the list of retrieved fields all of those fields that comprise that table's primary key). Secondly, if you were able to code "SELECT ... FROM FOR ALL ENTRIES IN TABLE " and the internal table is empty, then all rows from will be retrieved. Thirdly, if the internal table supplying the selection criteria (i.e. internal table in the example "...FOR ALL ENTRIES IN TABLE ") contains a large number of entries, performance degradation may occur.

15.  SELECT * versus SELECTing individual fields In general, use a SELECT statement specifying a list of fields instead of a SELECT * to reduce network traffic and improve performance. For tables with only a few fields the improvements may be minor, but many SAP tables contain more than 50 fields when the program example:needs only a few. In the latter case, the performace gains can be substantial. For Use: select vbeln auart vbtyp from table vbak into (vbak-vbeln, vbak-auart, vbak-vbtyp) where ... Instead of using: select * from vbak where ...

16.  Avoid unnecessary statements  There are a few cases where one command is better than two. For example: Use: append to . Instead of: = .

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

281/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

append (modify ). And also, use: if not [] is initial. Instead of: describe table lines . if > 0.

17.  Copying or appending internal tables  Use this: [] = []. (if is empty) Instead of this: loop at . append to . endloop. However, if is not empty and should not be overwritten, then use: append lines of [from index1] [to index2] to .

Create/Modify/Delete records in any table from CSV file By Pavan 

Allows to create, modify or delete records based on data coming from a CSV file. No other format than CSV is allowed. A check is done on field names to be sure every key field is present in source file. This file must contain header with fields names corresponding to the DDIC (fields names must be /comma separated too). system can be updated too. Test run uses a true MODIFY DELETE statement butSome is followed byfields a Rollback. REPORT csv_upload LINE-SIZE 255. * Data DATA: it_dd03p TYPE TABLE OF dd03p, is_dd03p TYPE dd03p. DATA: it_rdata TYPE TABLE OF text1024, is_rdata TYPE text1024. DATA: it_fields TYPE TABLE OF fieldname. DATA: it_file TYPE REF TO data, is_file TYPE REF TO data. DATA: w_error TYPE text132. * Macros DEFINE write_error. concatenate 'Error: table' p_table

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

282/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

283/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

IMPORTING file_name = p_file. * Start of selection START-OF-SELECTION. PERFORM f_table_definition USING p_table. PERFORM f_upload_data USING p_file. PERFORM f_prepare_table USING p_table. PERFORM f_process_data. IF p_nodb IS INITIAL. PERFORM f_modify_table. ENDIF. IF p_list = 'X'. PERFORM f_list_records. ENDIF. * End of selection END-OF-SELECTION. *---------------------------------------------------------------------* * FORM f_table_definition * *---------------------------------------------------------------------* * --> VALUE(IN_TABLE) * *---------------------------------------------------------------------* FORM f_table_definition USING value(in_table). DATA: l_tname TYPE tabname, l_state TYPE ddgotstate, l_dd02v TYPE dd02v. l_tname = in_table. 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. IF l_state NE 'A'. write_error 'does not exist or is not active' space. ENDIF. IF l_dd02v-tabclass NE 'TRANSP' AND l_dd02v-tabclass NE 'CLUSTER'. write_error 'is type' l_dd02v-tabclass. ENDIF. ENDFORM.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

284/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

285/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

286/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

287/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

288/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

289/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

l_tleng = l_tleng + 1. ELSE. l_tleng = l_tleng - is_dd03p-outputlen. EXIT. ENDIF. ENDLOOP. * Output header SKIP. FORMAT COLOR COL_HEADING. WRITE: /3 'Contents'. FORMAT RESET. ULINE AT /3(l_tleng). * Output records LOOP AT ASSIGNING . LOOP AT it_dd03p INTO is_dd03p FROM 1 TO l_lasti. IF is_dd03p-position = 1. WRITE: /3 sy-vline. l_offst = 3. ENDIF. ASSIGN COMPONENT is_dd03p-fieldname OF STRUCTURE TO . l_offst = l_offst + 1. IF is_dd03p-decimals LE 2. WRITE: AT l_offst . ELSE. WRITE: AT l_offst DECIMALS 3. ENDIF. l_offst = l_offst + is_dd03p-outputlen. WRITE: AT l_offst sy-vline. ENDLOOP. ENDLOOP. * Output end ULINE AT /3(l_tleng). ENDFORM.

Number Range Object   By Suresh Kumar Parvathaneni  

Creation of a Number range object: 1.  Go to transaction SNRO (Simple way to remember is SapNumberRangeObject).

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

290/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

 

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

291/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  Warning%  Assume that an interval is defined from 1 to 1000. If you want to issue a warning at the number 900, enter 10 (%) here.

4.  Press SAVE. You would get a prompt as shown below:

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

292/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

7.  Click on “Change Intervals”.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

293/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

 

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

294/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  10. Click “Insert” and then SAVE. The number range object is generated.   Testing the Number Range Object:

We can use the function module, NUMBER_GET_NEXT, to get the next number of any number range object. Following is a test program to get the next available number of the object created above: REPORT zsnro_test. DATA: NUMBER TYPE I. 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 . IF sy-subrc 0. MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

295/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ENDIF. Write :/ 'Next available number is: ', Number.

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. ABAPTM Open SQL allows single field, range of fields, entire database table or view into an internal table.

In technical terms Internal table is a dynamic sequential dataset in which all records have the same data structure and a key. A static internal table can be declared in an ABAPTM program initially, when the structure of the internal table is fixed and known to the user. Dynamic internal table is an extension to internal table concept, used when the number of fields is not known at the design time or until the compile time. 

Scenario 1: 

Display the table of contents in grid format using the dynamic internal table.   Creating Dynamic internal table  

PARAMETERS : p_table(10) TYPE C. DATA: w_tabname TYPE w_tabname, w_dref TYPE REF TO data, w_grid TYPE REF TO cl_gui_alv_grid. FIELD-SYMBOLS: TYPE ANY TABLE. w_tabname = p_table. CREATE DATA w_dref TYPE TABLE OF (w_tabname). ASSIGN w_dref->* TO .

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

296/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

Populating Dynamic internal table SELECT * FROM (w_tabname) UP TO 20 ROWS INTO TABLE . Displaying dynamic internal table using Grid. CREATE OBJECT w_grid EXPORTING i_parent = cl_gui_container=>screen0. CALL METHOD w_grid->set_table_for_first_display EXPORTING i_structure_name = w_tabname CHANGING it_outtab

= .

CALL SCREEN 100.  Scenario 2: 

Create a dynamic internal table with the specified number of columns. Creating Dynamic internal table

TYPE-POOLS: slis. FIELD-SYMBOLS: TYPE STANDARD TABLE, “ Dynamic internal table name , type any.

“ Field symbol to create work area “ Field symbol to assign values  

PARAMETERS: p_cols(5) TYPE c.

“ Input number of columns

DATA: t_newtable TYPE REF TO data, t_newline TYPE REF TO data,

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

297/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

t_fldcat TYPE slis_t_fldcat_alv, t_fldcat TYPE lvc_t_fcat, wa_it_fldcat TYPE lvc_s_fcat, wa_colno(2) TYPE n, wa_flname(5) TYPE c. * Create fields . DO p_cols TIMES. CLEAR wa_it_fldcat. move sy-index to wa_colno. concatenate 'COL' wa_colno into wa_flname. wa_it_fldcat-fieldname = wa_flname. wa_it_fldcat-datatype = 'CHAR'. wa_it_fldcat-intlen = 10. APPEND wa_it_fldcat TO t_fldcat. ENDDO. * 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.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

298/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

ASSIGN t_newtable->* TO . * Create dynamic work area and assign to FS CREATE DATA t_newline LIKE LINE OF . ASSIGN t_newline->* TO .   Populating Dynamic internal table

DATA: fieldname(20) TYPE c. DATA: fieldvalue(10) TYPE c. DATA: index(3) TYPE c. DO p_cols TIMES. index = sy-index. MOVE sy-index TO wa_colno. CONCATENATE 'COL' wa_colno INTO wa_flname. * Set up fieldvalue CONCATENATE 'VALUE' index INTO fieldvalue. CONDENSE

fieldvalue NO-GAPS.

ASSIGN COMPONENT wa_flname OF STRUCTURE TO .  = fieldvalue. ENDDO. * Append to the dynamic internal table

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

299/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

APPEND TO .  Displaying dynamic internal table using Grid.

DATA: wa_cat LIKE LINE OF fs_fldcat. DO p_cols TIMES. CLEAR wa_cat. MOVE sy-index TO wa_colno. CONCATENATE 'COL' wa_colno INTO wa_flname. wa_cat-fieldname = wa_flname. wa_cat-seltext_s = wa_flname. wa_cat-outputlen = '10'. APPEND wa_cat TO fs_fldcat. ENDDO. * Call ABAP List Viewer (ALV) CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY' EXPORTING it_fieldcat = fs_fldcat TABLES t_outtab

= . 

Infotype creation Custom Infotype can be created by following these steps: 1. Go to transaction PM01. 2. Provide the Infotype number. The number should be from 9000 to 9999. Avoid providing the Infotype number that already exists.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

300/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

301/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

17. The subtypes for an Infotype can be entered via the maintenance view V_T591A. 18. Continue with step 7 as required.  

Automatic Vendor Debit Posting Submitted by Vikram Please note that there are some custom fields added in the VBAP table, custom message class and custom include program used in this program. Unfortunately, the contributor couldn't provide us with the functional/technical specifications for this program. 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, ADR6, TRDYSE01CM. *---------------------------------------------------------------------* * INCLUDE *---------------------------------------------------------------------* INCLUDE ZZUTI_STD_HEADER_FOOTER. "Standard header and footer  *----------------------------------------------------------------------* * TYPES DECLARATION *----------------------------------------------------------------------* TYPES: BEGIN OF T_CRMEMO, VBELN TYPE VBAK-VBELN, POSNR TYPE VBAP-POSNR, ERDAT TYPE VBAK-ERDAT, AUART TYPE VBAK-AUART, AUGRU TYPE VBAK-AUGRU, WAERK TYPE VBAK-WAERK, VKORG TYPE VBAK-VKORG, VTWEG TYPE VBAK-VTWEG, SPART TYPE VBAK-SPART, VDATU TYPE VBAK-VDATU, BSTNK TYPE VBAK-BSTNK, BSARK TYPE VBAK-BSARK,

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

302/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

BSTDK TYPE VBAK-BSTDK, AEDAT TYPE VBAK-AEDAT, BUKRS_VF TYPE VBAK-BUKRS_VF, MATNR TYPE VBAP-MATNR, ZMENG TYPE VBAP-ZMENG, ZIEME TYPE VBAP-ZIEME, END OF T_CRMEMO, BEGIN OF T_CRMEMO_CHANGE, VBELN(90) TYPE C, POSNR TYPE VBAP-POSNR, ERDAT TYPE VBAK-ERDAT, AUART TYPE VBAK-AUART, AUGRU TYPE VBAK-AUGRU, WAERK TYPE VBAK-WAERK, VKORG TYPE VBAK-VKORG, VTWEG TYPE VBAK-VTWEG, SPART TYPE VBAK-SPART, VDATU TYPE VBAK-VDATU, BSTNK TYPE VBAK-BSTNK, BSARK TYPE VBAK-BSARK, BSTDK TYPE VBAK-BSTDK, AEDAT TYPE VBAK-AEDAT, BUKRS_VF TYPE VBAK-BUKRS_VF, MATNR TYPE VBAP-MATNR, ZMENG TYPE VBAP-ZMENG, ZIEME TYPE VBAP-ZIEME, END OF T_CRMEMO_CHANGE, BEGIN OF MATNR VKORG VTWEG

T_MVKE, TYPE MVKE-MATNR, TYPE MVKE-VKORG, TYPE MVKE-VTWEG,

MTPOS TYPE MVKE-MTPOS, END OF T_MVKE, BEGIN OF T_ORDERS, VBELV TYPE VBFA-VBELV, POSNV TYPE VBFA-POSNV, VBELN TYPE VBFA-VBELN, POSNN TYPE VBFA-POSNN, VBTYP_N TYPE VBFA-VBTYP_N, END OF T_ORDERS, BEGIN OF T_EKPO, EBELN TYPE EKKO-EBELN, EBELP TYPE EKPO-EBELP, WAERS TYPE MENGE TYPE MEINS TYPE NETPR TYPE PEINH TYPE mwskz TYPE TXJCD TYPE END OF T_EKPO,

EKKO-WAERS, EKPO-MENGE, EKPO-MEINS, EKPO-NETPR, EKPO-PEINH, EKPO-mwskz, EKPO-TXJCD,

BEGIN OF T_EKBE,

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

303/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

EBELN TYPE EBELP TYPE ZEKKN TYPE VGABE TYPE GJAHR TYPE BELNR TYPE BUZEI TYPE END OF T_EKBE,

EKBE-EBELN, EKBE-EBELP, EKBE-ZEKKN, EKBE-VGABE, EKBE-GJAHR, EKBE-BELNR, EKBE-BUZEI,

BEGIN OF T_RBKP, BELNR TYPE RBKP-BELNR, GJAHR TYPE RBKP-GJAHR, BLDAT TYPE RBKP-BLDAT, BUDAT TYPE RBKP-BUDAT, XBLNR TYPE RBKP-XBLNR, LIFNR TYPE RBKP-LIFNR, RMWWR TYPE RBKP-RMWWR, WMWST1 TYPE RBKP-WMWST1, XRECH TYPE RBKP-XRECH, STBLG TYPE RBKP-STBLG, END OF T_RBKP, BEGIN OF T_CDHDR, OBJECTCLAS TYPE OBJECTID TYPE CHANGENR TYPE UDATE TYPE UTIME TYPE END OF T_CDHDR,

CDHDR-OBJECTCLAS, CDHDR-OBJECTID, CDHDR-CHANGENR, CDHDR-UDATE, CDHDR-UTIME,

BEGIN OF T_CDPOS, OBJECTCLAS TYPE CDHDR-OBJECTCLAS, OBJECTID TYPE CDHDR-OBJECTID, CHANGENR TYPE TABNAME TYPE TABKEY TYPE FNAME TYPE CHNGIND TYPE VALUE_NEW TYPE VALUE_OLD TYPE END OF T_CDPOS,

CDHDR-CHANGENR, CDPOS-TABNAME, CDPOS-TABKEY, CDPOS-FNAME, CDPOS-CHNGIND, CDPOS-VALUE_NEW, CDPOS-VALUE_OLD,

BEGIN OF T_CHANGE_DOCS, OBJECTCLAS TYPE CDHDR-OBJECTCLAS, OBJECTID TYPE CDHDR-OBJECTID, CHANGENR TYPE CDHDR-CHANGENR, UDATE TYPE CDHDR-UDATE, UTIME TYPE CDHDR-UTIME, TABNAME TYPE CDPOS-TABNAME, TABKEY TYPE CDPOS-TABKEY, FNAME TYPE CDPOS-FNAME, CHNGIND TYPE CDPOS-CHNGIND, VALUE_NEW TYPE CDPOS-VALUE_NEW, VALUE_OLD TYPE CDPOS-VALUE_OLD, END OF T_CHANGE_DOCS, BEGIN OF T_SUCCESS,

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

304/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

305/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

*----------------------------------------------------------------------* DATA: IT_CRMEMO TYPE STANDARD TABLE OF T_CRMEMO WITH HEADER LINE, IT_CRMEMO_CHANGE TYPE STANDARD TABLE OF T_CRMEMO_CHANGE WITH HEADER LINE, IT_MVKE TYPE STANDARD TABLE OF T_MVKE WITH HEADER LINE, IT_CRMEMO_MIRO TYPE STANDARD TABLE OF T_CRMEMO WITH HEADER LINE, IT_CRMEMO_MR8M TYPE STANDARD TABLE OF T_CRMEMO WITH HEADER LINE, IT_ORDERS TYPE STANDARD TABLE OF T_ORDERS WITH HEADER LINE, IT_CMEMO TYPE STANDARD TABLE OF T_ORDERS WITH HEADER LINE, IT_PO TYPE STANDARD TABLE OF T_ORDERS WITH HEADER LINE, IT_EKPO TYPE STANDARD TABLE OF T_EKPO WITH HEADER LINE, IT_EKBE TYPE STANDARD TABLE OF T_EKBE WITH HEADER LINE, IT_EKBE_TEMP TYPE STANDARD TABLE OF T_EKBE WITH HEADER LINE, IT_RBKP TYPE STANDARD TABLE OF T_RBKP WITH HEADER LINE, IT_CDHDR TYPE STANDARD TABLE OF T_CDHDR WITH HEADER LINE, IT_CDPOS TYPE STANDARD TABLE OF T_CDPOS WITH HEADER LINE, IT_CHANGE_DOCS TYPE STANDARD TABLE OF T_CHANGE_DOCS WITH HEADER LINE, IT_SUCCESS TYPE STANDARD TABLE OF T_SUCCESS WITH HEADER LINE, IT_ERROR TYPE STANDARD TABLE OF T_ERROR WITH HEADER LINE, IT_SUCCESS_MR8M TYPE STANDARD TABLE OF T_SUCCESS WITH HEADER LINE, IT_ERROR_MR8M

TYPE STANDARD TABLE OF T_ERROR

WITH HEADER LINE.

*-- Internal table to hold Invoice Item Data DATA:BEGIN OF it_itemdata OCCURS 0. INCLUDE STRUCTURE bapi_incinv_create_item. DATA:END OF it_itemdata. *-- Internal table to hold Invoice Acct Assignment Data DATA:BEGIN OF it_ACCOUNTingdata OCCURS 0. INCLUDE STRUCTURE BAPI_INCINV_CREATE_ACCOUNT. DATA:END OF it_accountingdata. *-- Internal table to hold BAPI return data DATA: BEGIN OF it_return OCCURS 0. INCLUDE STRUCTURE bapiret2. "Return Parameter.  DATA: END OF it_return. *-- Internal table to hold BAPI return data DATA: BEGIN OF it_return_mr8m OCCURS 0. INCLUDE STRUCTURE bapiret2. "Return Parameter.  DATA: END OF it_return_mr8m. *--MAIL related Internal tables DATA: X_DOC_CHNG TYPE SODOCCHGI1, IT_OBJPACK TYPE STANDARD TABLE OF SOPCKLSTI1, IT_OBJHEAD TYPE STANDARD TABLE OF SOLISTI1,

" document attributes  " attachment table  " object header table 

IT_OBJBIN TYPE STANDARD TABLE OF SOLISTI1, " binary table  IT_OBJTXT TYPE STANDARD TABLE OF SOLISTI1, " object text  IT_RECLIST TYPE STANDARD TABLE OF SOMLRECI1, " mail recipients  it_compressed_list TYPE STANDARD TABLE OF SOLI, it_pdf_list TYPE STANDARD TABLE OF TLINE, it_pdf TYPE tline OCCURS 10 WITH HEADER LINE, it_html TYPE solisti1 OCCURS 10 WITH HEADER LINE, *-- Internal table for MIME data (in CHAR format) it_temp TYPE bapiqcmime OCCURS 10 WITH HEADER LINE, *-- Internal table for storing data

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

306/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

it_mime(255) TYPE c OCCURS 10 WITH HEADER LINE. *----------------------------------------------------------------------* * GLOBAL VARIABLES * *----------------------------------------------------------------------* DATA: V_PGM_ID TYPE SY-REPID, " Program id  v_zterm TYPE lfb1-zterm, " Payment Terms  v_text(75) TYPE c, " To store error or success text  v_itemno(6) TYPE n, " To Increment Item No. for BAPI  v_docnr LIKE bapi_incinv_fld-inv_doc_no, " For MIRO document number  v_year1 LIKE bapi_incinv_fld-fisc_year, " For MIRO Fiscal year  v_spono type TSP01-RQIDENT, " For Spool No.  v_type type SOODK-OBJTP, " For Spool Type  V_CRMEMO_QTY TYPE VBAP-ZMENG, " For CR Memo Qty.  V_LINE_AMOUNT TYPE EKPO-NETPR, " For CR Memo Item Qty.  V_GROSSAMT TYPE EKPO-NETPR, " For CR Memo Grand Qty.  v_tax_per(3) amount %  v_tax_amt amount  v_flag(1) fruther  v_tot_s_mr8m Records  v_tot_e_mr8m Records  V_DATE V_DATE2(10) V_TIME(10)

type n,

" For CR Memo Tax

TYPE EKPO-NETPR,

" For CR Memo Tax

type c,

" Flag to process

TYPE i,

" For MR8M Success

TYPE i,

" For MR8M Error

TYPE SY-DATUM, TYPE C, TYPE C,

" For Sel. Screen Date  " For EMail Date  " For EMail Time 

V_TIME2(10) TYPE V_INFO(100) TYPE C, C, V_TABLE_LINES TYPE SY-TABIX,

" " For For EMail EMail Time  Body Text  " To Increment Email

Count 

char char char char

V_TEXT2 v_lines v_temp(500) format  v_offset format  v_lineslen format  v_mimelen format 

v_tabix char format 

TYPE STRING TYPE i, TYPE c,

,

" For EMail Id text  " To Store PDF Lines  " To Convert to 255

TYPE p,

" To Convert to 255

TYPE i,

" To Convert to 255

TYPE i,

" To Convert to 255

type sy-tabix.

" To Convert to 255

*----------------------------------------------------------------------* * CONSTANTS * *----------------------------------------------------------------------* CONSTANTS: C_X(1) TYPE C VALUE 'X', " Constant X or Flag  C_E(1) TYPE C VALUE 'E', " For Error check  c_v(1) TYPE C VALUE 'V', " For PO Docs 

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

307/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

VALUE 'O', VALUE 'C', VALUE 'K', VALUE 'U',

TYPE C TYPE C TYPE C

VALUE 'ALI', " For ALI Format  VALUE 'VBAK', " For Change docs table  VALUE '01', " For Serial No. &

TYPE TYPE TYPE TYPE TYPE TYPE

VALUE VALUE VALUE VALUE VALUE VALUE

C bkpf-blart MVKE-MTPOS C C C

" For Order Docs  " For Credit Memo Docs  " For CR Memo Docs  " For Change tables

'02', " For Reversal Reason  'RE', " Document type  'BANS', " Item Category group  'AUGRU', " Reason Code  '0000500205', " GL Account #  'VERKBELEG'. " For Object Class 

*-- Horizontal tab & line feed constants CLASS CL_ABAP_CHAR_UTILITIES DEFINITION LOAD. CONSTANTS: C_TAB TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB, C_CR_LF TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF . *----------------------------------------------------------------------* * SELECTION SCREEN *----------------------------------------------------------------------* *-- Select Optons SELECTION-SCREEN: BEGIN OF BLOCK B01 WITH FRAME TITLE TEXT-001. SELECT-OPTIONS: S_AUART FOR VBAK-AUART OBLIGATORY NO INTERVALS, " Sales Document Type  S_AUGRU FOR VBAK-AUGRU OBLIGATORY NO INTERVALS, " Order reason  S_ERDAT FOR VBAK-ERDAT OBLIGATORY. " Date on which the record was created  SELECTION-SCREEN: END OF BLOCK B01. *-- Mail Sending Options SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-004. PARAMETERS:P_EMAIL AS CHECKBOX DEFAULT SPACE USER-COMMAND V_COM . PARAMETERS : P_MODE TYPE SO_ESCAPE default  'U' MODIF ID US1. SELECT-OPTIONS: S_EMAIL FOR ADR6-SMTP_ADDR NO INTERVALS MODIF ID US2. * SELECT-OPTIONS: S_EMAIL FOR TRDYSE01CM-USERNAME * NO INTERVALS MODIF ID US2. SELECTION-SCREEN: BEGIN OF LINE. SELECTION-SCREEN: COMMENT 55(40) TEXT-019 MODIF ID US2. SELECTION-SCREEN: END OF LINE. SELECTION-SCREEN END OF BLOCK B2. *----------------------------------------------------------------------* * WORK AREA for SELECT-OPTIONS *----------------------------------------------------------------------* DATA : X_EMAIL LIKE S_EMAIL. "Work area for EMAIL select-options  *----------------------------------------------------------------------* * INITIALIZATION

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

308/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

309/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

*

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

310/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

SCREEN-INPUT = 0. MODIFY SCREEN. ENDIF. IF SCREEN-GROUP2 = 'US2' . SCREEN-INVISIBLE = 0. SCREEN-ACTIVE = 1. MODIFY SCREEN. ENDIF. ELSEIF P_EMAIL = SPACE. IF SCREEN-GROUP1 = 'US1' . SCREEN-INVISIBLE = 1. SCREEN-ACTIVE = 0. MODIFY SCREEN. ENDIF. IF SCREEN-GROUP1 = 'US2' . SCREEN-INVISIBLE = 1. SCREEN-ACTIVE = 0. MODIFY SCREEN. ENDIF. ENDIF. ENDLOOP. ENDFORM.

" F_MODIFY_SCREEN 

*&---------------------------------------------------------------------* *& Form f_validate *&---------------------------------------------------------------------* * Validation of Selection-Screen Inputs *----------------------------------------------------------------------* FORM f_validate . *-- Validate Sales Document Type if not s_AUART[] is initial. select AUART into s_AUART-low from TVAK up to 1 rows where AUART in s_AUART. endselect. if sy-subrc 0. message E000 with 'Invalid Sales Document Type'(e01) . endif. ENDIF. *-- Validate Order reason (reason for the business transaction) if not s_AUGRU[] is initial. select AUGRU into s_AUGRU-low from TVAU up to 1 rows where AUGRU in s_AUGRU. endselect. if sy-subrc 0. message E000 with 'Invalid Order reason'(e02) . endif. endif. ENDFORM. " f_validate  *&---------------------------------------------------------------------*

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

311/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

*& Form F_GET_CREDIT_MEMO_REQUEST *&---------------------------------------------------------------------* * Fetch Credit memo requests from VBAK & VBAP *----------------------------------------------------------------------* FORM F_GET_CREDIT_MEMO_REQUEST . 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. SORT IT_CRMEMO BY VBELN POSNR. ELSE. MESSAGE v_flag =I000 C_X.WITH 'No Credit Memo Request selected'(002). stop. ENDIF. ENDFORM.

" F_GET_CREDIT_MEMO_REQUEST 

*&---------------------------------------------------------------------* *& Form F_GET_MVKE_DOCS *&---------------------------------------------------------------------* * Fetch Sales Data for Material *----------------------------------------------------------------------* FORM F_GET_MVKE_DOCS . DATA: LV_TABIX TYPE SY-TABIX. *-- 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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

312/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

WHERE MATNR = IT_CRMEMO-MATNR AND VKORG = IT_CRMEMO-VKORG AND VTWEG = IT_CRMEMO-VTWEG. IF SY-SUBRC = 0. SORT IT_MVKE BY MATNR VKORG VTWEG MTPOS. ENDIF. *-- Validate Item category group if MVKE-MTOPS 'BANS' then ignore Request line item LOOP AT IT_CRMEMO INTO WA_CRMEMO. 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. IF SY-SUBRC 0. DELETE IT_CRMEMO INDEX LV_TABIX. " Delete CR memo records  ELSE. *-- Else check for credit memo request change date is not initial, and * *

CM

append those records to IT_CRMEMO_CHANGE internal table to retrive change documents IF NOT WA_CRMEMO-AEDAT IS INITIAL. WA_CRMEMO_CHANGE-VBELN = WA_CRMEMO-VBELN. WA_CRMEMO_CHANGE-POSNR = WA_CRMEMO-POSNR. WA_CRMEMO_CHANGE-ERDAT = WA_CRMEMO-ERDAT. WA_CRMEMO_CHANGE-AUART = WA_CRMEMO-AUART. WA_CRMEMO_CHANGE-AUGRU = WA_CRMEMO-AUGRU. WA_CRMEMO_CHANGE-WAERK = WA_CRMEMO-WAERK. WA_CRMEMO_CHANGE-VKORG = WA_CRMEMO-VKORG. WA_CRMEMO_CHANGE-VTWEG = WA_CRMEMO-VTWEG. WA_CRMEMO_CHANGE-SPART = WA_CRMEMO-SPART. WA_CRMEMO_CHANGE-VDATU = WA_CRMEMO-VDATU. WA_CRMEMO_CHANGE-BSTNK WA_CRMEMO_CHANGE-BSARK = = WA_CRMEMO-BSTNK. WA_CRMEMO-BSARK. WA_CRMEMO_CHANGE-BSTDK = WA_CRMEMO-BSTDK. WA_CRMEMO_CHANGE-AEDAT = WA_CRMEMO-AEDAT. WA_CRMEMO_CHANGE-BUKRS_VF = WA_CRMEMO-BUKRS_VF. WA_CRMEMO_CHANGE-MATNR = WA_CRMEMO-MATNR. WA_CRMEMO_CHANGE-ZMENG = WA_CRMEMO-ZMENG. WA_CRMEMO_CHANGE-ZIEME = WA_CRMEMO-ZIEME. APPEND WA_CRMEMO_CHANGE TO IT_CRMEMO_CHANGE. CLEAR WA_CRMEMO_CHANGE. ENDIF. ENDIF. ENDLOOP.

ENDFORM.

" F_GET_MVKE_DOCS 

*&---------------------------------------------------------------------* *& Form F_GET_SO_PO_DOCS *&---------------------------------------------------------------------* * Fetch the Sales Order documents, PO documents, & Credit Memo *----------------------------------------------------------------------* FORM F_GET_SO_PO_DOCS. *-- Fetch Preceding sales orders based on the credit memo request

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

313/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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. IF SY-SUBRC = 0. SORT IT_ORDERS BY VBELV POSNV. *-- 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,C_O) AND VBTYP_V = C_C. IF SY-SUBRC = 0. SORT IT_PO BY VBTYP_N. *-- Copy the IT_PO internal table contents to IT_CMEMO internal table IT_CMEMO[] = IT_PO[]. *-- Delete PO documents from IT_CMEMO internal table DELETE IT_CMEMO WHERE VBTYP_N = C_V. SORT IT_CMEMO BY VBELN POSNN. IF IT_CMEMO[] IS INITIAL. MESSAGE I000 WITH 'No Credit Memo are available for CM Request'(003). * v_flag = c_x. * stop. ENDIF. *-- Delete Credit Memo documents from IT_PO internal table DELETE IT_PO WHERE VBTYP_N = C_O. SORT IT_PO BY VBELN POSNN. ENDIF. ENDIF. ENDFORM.

" F_GET_SO_PO_DOCS 

*&---------------------------------------------------------------------* *& Form F_GET_CHANGED_DOCS *&---------------------------------------------------------------------* * Fetch Change Documents for CR Memos from CDHDR and CDPOS tables *----------------------------------------------------------------------*

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

314/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

FORM F_GET_CHANGED_DOCS . *-- 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 . IF SY-SUBRC = 0. SORT IT_CDHDR BY OBJECTCLAS OBJECTID CHANGENR. *-- 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 AND CHANGENR TABNAME AND FNAME AND CHNGIND IF SY-SUBRC = 0. SORT IT_CDPOS BY ENDIF. ENDIF. ENDFORM.

= = = =

IT_CDHDR-CHANGENR C_VBAK C_AUGRU C_U.

OBJECTCLAS OBJECTID CHANGENR.

" F_GET_CHANGED_DOCS 

*&---------------------------------------------------------------------* *& Form F_GET_EKPO *&---------------------------------------------------------------------* * Fetch Purchasing Document Item Details *----------------------------------------------------------------------* FORM F_GET_EKPO . *-- Fetch Purchasing Document Item Details SELECT A~EBELN B~EBELP A~WAERS B~MENGE B~MEINS

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

315/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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). IF SY-SUBRC = 0. SORT IT_EKPO BY EBELN EBELP. ENDIF. ENDFORM.

" F_GET_EKPO 

*&---------------------------------------------------------------------* *& Form F_GET_VENDOR *&---------------------------------------------------------------------* * Fetch MIRO Vendor details based on the PO Details *----------------------------------------------------------------------* FORM F_GET_VENDOR . DATA: LV_TABIX TYPE SY-TABIX. *-- Fetch History per Purchasing Document records for all the PO records SELECT EBELN EBELP ZEKKN VGABE GJAHR BELNR BUZEI FROM INTO EKBE TABLE IT_EKBE FOR ALL ENTRIES IN IT_EKPO WHERE EBELN = IT_EKPO-EBELN AND EBELP = IT_EKPO-EBELP AND VGABE = '2'. * and STBLG = space. IF SY-SUBRC = 0. SORT IT_EKBE BY BELNR GJAHR. *-- 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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

316/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

WHERE BELNR = IT_EKBE-BELNR AND GJAHR = IT_EKBE-GJAHR. IF SY-SUBRC = 0. SORT IT_RBKP BY BELNR GJAHR. ENDIF. ENDIF. *-- Sort PO History documents based on PO # and PO Item SORT IT_EKBE BY EBELN EBELP. *-- Copy the PO History documents into IT_EKBE_TEMP internal table IT_EKBE_TEMP[] = IT_EKBE[]. *-- 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. LV_TABIX = SY-TABIX. READ TABLE IT_RBKP INTO WA_RBKP WITH KEY BELNR = WA_EKBE_TEMP-BELNR GJAHR = WA_EKBE_TEMP-GJAHR *

XRECH = SPACE STBLG = SPACE. IF SY-SUBRC 0. DELETE IT_EKBE_TEMP INDEX LV_TABIX. ENDIF. CLEAR: WA_EKBE_TEMP, WA_RBKP. ENDLOOP.

ENDFORM.

" F_GET_VENDOR 

*&---------------------------------------------------------------------* *& Form F_PROCESS_MIRO *&---------------------------------------------------------------------* * Process MIRO *----------------------------------------------------------------------* FORM F_PROCESS_MIRO . DATA: lv_itemno TYPE i, lv_tabix type sy-index, lc_check(1) TYPE c VALUE 'X', V_FILL_ITEM, lv_rbkp_bldat type sy-datum.

clear : it_itemdata, it_accountingdata, IT_CRMEMO_MIRO, IT_CRMEMO_MR8M. refresh : it_itemdata, it_accountingdata, IT_CRMEMO_MIRO, IT_CRMEMO_MR8M. *-- Copy all the CR Memo Docs and delete order reason not in S_AUGRU IT_CRMEMO_MR8M[] = IT_CRMEMO[]. *-- 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. *-- Delete order reason which are not in S_AUGRU

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

317/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

DELETE IT_CRMEMO WHERE AUGRU NOT IN S_AUGRU. *-- Loop through the credit memo request records LOOP AT IT_CRMEMO INTO WA_CRMEMO. lv_tabix = sy-tabix. *-- 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. lv_rbkp_bldat = WA_CRMEMO-aedat. else. *-- If credit memo request change date is initial then * send create date (ERDAT) to lv_rbkp_bldat lv_rbkp_bldat = WA_CRMEMO-erdat. endif. READ TABLE IT_ORDERS INTO WA_ORDERS WITH KEY VBELN = WA_CRMEMO-VBELN POSNN = WA_CRMEMO-POSNR. IF SY-SUBRC = 0. READ TABLE IT_PO INTO WA_PO WITH KEY VBELV = WA_ORDERS-VBELV POSNV = WA_ORDERS-POSNV. IF SY-SUBRC = 0. READ TABLE IT_EKPO INTO WA_EKPO WITH KEY EBELN = WA_PO-VBELN EBELP = WA_PO-POSNN. IF SY-SUBRC = 0. *-- 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. IF SY-SUBRC = 0. *-- Read IT_RBKP internal table with XRECH (Indicator: post invoice) = 'X' , * 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. IF SY-SUBRC = 0. *-- Read IT_RBKP internal table with XRECH (Indicator: post invoice) = SPACE, * 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 ERDAT

BLDAT = WA_CRMEMOXRECH = ' '  XBLNR+0(10)

WA_EKBE_TEMP-ebeln. * IF SY-SUBRC = 0. CONTINUE. ELSE.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

=

STBLG = SPACE.

318/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

*-- Quantity Conversion (Get the Credit Memo Quantity by passing CMR unit per one PO unit) perform f_quantity_conv. *-- Filling the Line items data *-- Incrementing the item no lv_itemno = lv_itemno + 1. v_itemno = lv_itemno. it_itemdata-invoice_doc_item it_itemdata-po_number it_itemdata-po_item it_itemdata-tax_code it_itemdata-TAXJURCODE

= = = = =

v_itemno. WA_ekPO-ebeln. WA_EKPO-EBELP. WA_ekpo-mwskz. WA_ekpo-TXJCD.

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

item_amount . it_itemdata-quantity

=

(

it_itemdata-

WA_CRMEMO-ZMENG

*

V_CRMEMO_QTY ). it_itemdata-po_unit APPEND it_itemdata.

= WA_EKPO-MEINS.

*-- Populate Account Assignment data IT_ACCOUNTINGDATA-INVOICE_DOC_ITEM = v_itemno. IT_ACCOUNTINGDATA-XUNPL = space. IT_ACCOUNTINGDATA-SERIAL_NO = C_01. IT_ACCOUNTINGDATA-TAX_CODE = it_itemdata-tax_code. IT_ACCOUNTINGDATA-TAXJURCODE IT_ACCOUNTINGDATA-ITEM_AMOUNT IT_ACCOUNTINGDATA-QUANTITY IT_ACCOUNTINGDATA-PO_UNIT IT_ACCOUNTINGDATA-GL_ACCOUNT append IT_ACCOUNTINGDATA. clear IT_ACCOUNTINGDATA.

= = = = =

it_itemdata-TAXJURCODE. it_itemdata-item_amount. it_itemdata-quantity. it_itemdata-po_unit. C_0000500205.

CLEAR it_itemdata. endif. endif. ENDIF. ENDIF. ENDIF. ENDIF. *-- At end of each credit memo request fill the header details of BAPI FM and *-- post the BAPI AT END OF VBELN. read table it_crmemo into wa_crmemo index lv_tabix. *-- Populate the document Header *-- Getting the header data for invoice x_docheader-invoice_ind = space. x_docheader-doc_type = c_blart.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

319/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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. lv_rbkp_bldat. WA_RBKP-XBLNR. WA_CRMEMO-BUKRS_VF. WA_CRMEMO-WAERK. lc_check.

*-- Logic to find the Tax % v_tax_per = ( WA_RBKP-WMWST1 / ( WA_RBKP-RMWWR - WA_RBKP-WMWST1 ) ) * 100. v_tax_amt = ( V_GROSSAMT * v_tax_per ) / 100. V_GROSSAMT = ( V_GROSSAMT + v_tax_amt ). x_docheader-gross_amount = V_GROSSAMT. CLEAR:v_docnr, v_year1. *-- Calling BAPI to create PO invoice document CHECK NOT IT_ITEMDATA[] IS INITIAL. CALL FUNCTION 'BAPI_INCOMINGINVOICE_CREATE'  EXPORTING

* *

headerdata IMPORTING invoicedocnumber fiscalyear TABLES itemdata ACCOUNTingDATA GLACCOUNTDATA taxdata return

= x_docheader = v_docnr = v_year1 = it_itemdata[] = it_ACCOUNTingDATA[] = = = it_return.

*-- Commit work IF NOT v_docnr IS INITIAL. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'  EXPORTING wait = 'X'. *-- Move the data to Success Internal Table wa_success-crmemo = wa_crmemo-vbeln. wa_success-cmemo = wa_cmemo-vbeln. wa_success-orders = wa_orders-vbelv. wa_success-po = wa_po-vbeln. wa_success-miro_no = v_docnr. wa_success-text = 'MIRO is Posted'. append wa_success TO it_success. clear wa_success. ENDIF. *--

Read the values in the table IT_RETURN. CLEAR it_return. READ TABLE it_return INDEX 1. * If message type is error then roll back the work IF it_return-type = C_E. *-- Roll back CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. *-- Move the data to Error Internal Table wa_error-crmemo = wa_crmemo-vbeln.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

320/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

wa_error-cmemo wa_error-orders wa_error-po wa_error-text append wa_error clear wa_error.

= wa_cmemo-vbeln. = wa_orders-vbelv. = wa_po-vbeln. = it_return-MESSAGE. TO it_error.

ENDIF. refresh: it_return, it_itemdata, it_accountingdata. clear: V_GROSSAMT, it_return, it_itemdata, wa_crmemo, wa_orders, wa_po, wa_ekpo, WA_EKBE_TEMP, wa_rbkp, wa_rbkp_tmp, v_docnr, v_year1, WA_SUCCESS, WA_ERROR, it_accountingdata, v_tax_per, v_tax_amt, V_FILL_ITEM, lv_rbkp_bldat. ENDAT. ENDLOOP. ENDFORM.

" F_PROCESS_MIRO 

*&---------------------------------------------------------------------* *& Form f_quantity_conv *&---------------------------------------------------------------------* * Quantity Conversion *----------------------------------------------------------------------* FORM f_quantity_conv . *-- Quantity Conversion (Get the Credit Memo Quantity by passing CMR unit per one PO unit) CLEAR: V_LINE_AMOUNT, V_CRMEMO_QTY. call function 'MC_UNIT_CONVERSION'  EXPORTING MATNR = nach_meins = von_meins = IMPORTING UMREF = EXCEPTIONS CONVERSION_NOT_FOUND = MATERIAL_NOT_FOUND = NACH_MEINS_MISSING = OVERFLOW = VON_MEINS_MISSING = OTHERS = if sy-subrc 0. MESSAGE ID SY-MSGID TYPE

WA_CRMEMO-MATNR WA_EKPO-MEINS WA_CRMEMO-ZIEME V_CRMEMO_QTY 1 2 3 4 5 6. SY-MSGTY NUMBER SY-MSGNO

WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4. ELSE. V_LINE_AMOUNT = ( V_CRMEMO_QTY * WA_CRMEMO-ZMENG WA_EKPO-NETPR ). V_GROSSAMT = V_GROSSAMT + V_LINE_AMOUNT. ENDIF. ENDFORM.

*

WA_EKPO-peinh

" f_quantity_conv 

*&---------------------------------------------------------------------*

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

321/508

*

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

*& 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. DATA : lv_waers LIKE tcurc-waers, lv_sapamount LIKE bapicurr-bapicurr, lv_bapi_amount LIKE bapicurr-bapicurr. lv_waers = p_waers. lv_sapamount = p_kbetr.

CALL FUNCTION 'CURRENCY_AMOUNT_SAP_TO_BAPI'  EXPORTING currency = lv_waers sap_amount = lv_sapamount IMPORTING bapi_amount = lv_bapi_amount. p_amt_doccur = lv_bapi_amount. ENDFORM.

" f_currency_amount_sap_to_bapi 

*&---------------------------------------------------------------------* *& Form f_display_report *&---------------------------------------------------------------------* * Display Report *----------------------------------------------------------------------* FORM f_display_report . *-- Success Report IF NOT IT_SUCCESS[] IS INITIAL. ULINE AT /1(129). WRITE:/1 sy-vline, 'CR Memo', 19 sy-vline, 'Credit Memo', 39 sy-vline, 'Sales Order', 59 sy-vline, 'Purchase Order', 79 sy-vline, 'MIRO Number', 99 sy-vline, 'Text', 129 sy-vline. ULINE AT /1(129). LOOP AT it_success into wa_success. WRITE:/1 sy-vline, wa_success-crmemo, 19 sy-vline, wa_success-cmemo, 39 sy-vline, wa_success-orders, 59 sy-vline, wa_success-po, 79 sy-vline, wa_success-miro_no, 99 sy-vline, wa_success-text, 129 sy-vline. ENDLOOP. ULINE AT /1(129).

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

322/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

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

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

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

323/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

  ULINE AT /1(179). WRITE:/1 sy-vline, 'CR Memo', 19 sy-vline, 'Credit Memo', 39 sy-vline, 'Sales Order', 59 sy-vline, 'Purchase Order', 79 sy-vline, 'Error Text', 179 sy-vline. ULINE AT /1(179). LOOP AT IT_ERROR_MR8M into WA_ERROR_MR8M. WRITE:/1 sy-vline, WA_ERROR_MR8M-crmemo, 19 sy-vline, WA_ERROR_MR8M-cmemo, 39 sy-vline, WA_ERROR_MR8M-orders, 59 sy-vline, WA_ERROR_MR8M-po, 79 sy-vline, WA_ERROR_MR8M-text, 179 sy-vline. ENDLOOP. ULINE AT /1(179). ENDIF. ENDFORM.

" f_display_report 

*&---------------------------------------------------------------------* *& Form F_PROCESS_MR8M *&---------------------------------------------------------------------* * Process Reversal postings *----------------------------------------------------------------------* FORM F_PROCESS_MR8M . clear: wa_CRMEMO_MR8M. LOOP IT_CRMEMO_MR8M readATtable it_cdpos VBELN. if sy-subrc 0. CONTINUE. ELSE. if wa_cdpos-value_old READ TABLE IT_ORDERS

into WA_CRMEMO_MR8M. into wa_cdpos with key

OBJECTID

=

WA_CRMEMO_MR8M-

in s_augru. INTO WA_ORDERS WITH KEY VBELN = wa_CRMEMO_MR8M-VBELN POSNN = wa_CRMEMO_MR8M-

POSNR. IF SY-SUBRC = 0. * READ TABLE IT_CMEMO INTO WA_CMEMO WITH KEY VBELV = WA_ORDERS-VBELV * POSNV = WA_ORDERS-POSNV. * IF SY-SUBRC = 0.

* * *

READ TABLE IT_PO INTO WA_PO WITH KEY VBELV = WA_ORDERS-VBELV POSNV = WA_ORDERS-POSNV. IF SY-SUBRC = 0. READ TABLE IT_EKPO INTO WA_EKPO WITH KEY EBELN = WA_PO-VBELN EBELP = WA_PO-POSNN. IF SY-SUBRC = 0. READ TABLE IT_EKBE INTO WA_EKBE WITH KEY EBELN = WA_EKPO-EBELN EBELP = WA_EKPO-EBELP. IF SY-SUBRC = 0. LOOP AT IT_EKBE into WA_EKBE WHERE EBELN = WA_EKPO-EBELN

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

324/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

* AEDAT

AND EBELP = WA_EKPO-EBELP. READ TABLE IT_RBKP INTO WA_RBKP WITH KEY BELNR = WA_EKBE-BELNR GJAHR = WA_EKBE-GJAHR BLDAT = WA_CRMEMO_MR8MXBLNR+0(10) = WA_EKBE-

EBELN XRECH = SPACE STBLG = SPACE. IF SY-SUBRC = 0. move: WA_RBKP-BELNR TO X_REV_POST-INV_DOC_NO, WA_RBKP-GJAHR TO X_REV_POST-FISC_YEAR, WA_RBKP-BUDAT TO X_REV_POST-PSTNG_DATE. IF WA_RBKP-BUDAT+4(2) = SY-DATUM+4(2). X_REV_POST-REASON_REV = C_01. ELSE. X_REV_POST-REASON_REV = C_02. ENDIF. ENDIF. ENDLOOP. *-- 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. *-- Commit work IF NOT X_REV_POST-INV_DOC_NO IS INITIAL. CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'  EXPORTING wait = 'X'. *-- Move the data to Success Internal Table wa_success_mr8m-crmemo = wa_crmemo-vbeln. wa_success_mr8m-cmemo = wa_cmemo-vbeln. wa_success_mr8m-orders = wa_orders-vbelv. wa_success_mr8m-po = wa_po-vbeln. wa_success_mr8m-text = 'MR8M Done'. append wa_success_mr8m TO it_success_mr8m. clear wa_success_mr8m. ENDIF. *-- Read the values in the table IT_RETURN. CLEAR it_return_mr8m. READ TABLE it_return_mr8m INDEX 1. *-- If message type is error then roll back the work IF it_return_mr8m-type = 'E' . *-- Roll back CALL FUNCTION 'BAPI_TRANSACTION_ROLLBACK'. *-- Move the data to Error Internal Table wa_error_mr8m-crmemo = wa_crmemo-vbeln. wa_error_mr8m-cmemo = wa_cmemo-vbeln.

http://slide pdf.c om/re a de r/full/a -must-sa p-a ba p-tutor ia ls-doc ume nt-for-be ginne rs

325/508

 

5/14/2018

A Must Sa p Aba p Tutor ia ls Doc ume nt for Be ginne rs - slide pdf.c om

wa_error_mr8m-orders wa_error_mr8m-po wa_error_mr8m-text append wa_error_mr8m clear wa_error_mr8m.

* *

*

= wa_orders-vbelv. = wa_po-vbeln. = it_return_mr8m-MESSAGE. TO it_error_mr8m.

ENDIF. ENDIF. ENDIF. ENDIF. ENDIF. ENDIF. ENDIF. ENDIF. ENDIF. CLEAR: wa_error_mr8m, wa_SUCCESS_mr8m, X_REV_POST, wa_CRMEMO_MR8M, wa_orders, wa_po, wa_ekpo, wa_ekbe, wa_rbkp, wa_cmemo. REFRESH: IT_RETURN_MR8M. endloop.

ENDFORM.

" F_PROCESS_MR8M 

*&---------------------------------------------------------------------* *& Form F_spool_id *&---------------------------------------------------------------------* * Create a new spool ID *----------------------------------------------------------------------* FORM F_spool_id . *-- 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) "
View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF