Wednesday, April 30, 2008

SAP ABAP Editor Icons

SAP ABAP Editor Icons

If the help of the icons in the SAP ABAP Editor you can do the following from the initial screen.




Check the Program:

The program is checked for syntax errors. One the program is free of Syntax errors you can activate it.

Activate the Program:

Only activated version of the Program can be executed. You can have 2 versions of the program, Active and Inactive.

Run the Program

The program can be executed by this Icon.

Check the where used list.

You can check where all the current program is used in the SAP system. This can be useful for Includes and Function Modules.

Do the Environment Analysis

Gives a list of Objects used in the Program along with short description and development class.

Online Manual

Gives online documentation for ABAP Statements, Keywords, Objects

Delete the Program

Deletes the Program. Make sure that you have a backup of the program before deleting it. If you have transported the program to Quality or Production then it is possible to retrieve the program. As a general rule always back up the program.

Copy the Program

Makes a copy of the Program.

Rename the Program

Renames the Program

Start Debugging

You can start the debugger from here.

Execute the Program with a Variant

Execute the Program with a variant. You need to create a Variant first.

Get the Variant List.

If you have created a Variant you can get a list and choose the desired Variant.




SAP ABAP Function module to calculate the difference between 2 dates

SAP ABAP Function module to calculate the difference between 2 dates.

The function module HR_HK_DIFF_BT_2_DATES in SAP ABAP can be used to calculate the difference between 2 dates.

HR_HK_DIFF_BT_2_DATES

Please check the following program. Experiment with the OUTPUT FORMAT (Example '01', '02', '03', '04', 05'). Make sure that Date1 is greater than Date2

REPORT ZEX_DIFFBETW2DATES .


Data: d_date1 like P0001-BEGDA,
      d_date2 like P0001-BEGDA,
      d_yrs  like P0347-SCRYY,
      d_months like P0347-SCRMM,
      d_days like P0347-SCRDD.


* Date1 should be greater than date 2
d_date1 = '20050101'.
d_date2 = '20000104'.

* This function calculates the diference between date 1 and date 2
CALL FUNCTION 'HR_HK_DIFF_BT_2_DATES'
     EXPORTING
          DATE1                   = d_date1
          DATE2                   = d_date2
          OUTPUT_FORMAT           = '05'
     IMPORTING
          YEARS                   = d_yrs
          MONTHS                  = d_months
          DAYS                    = d_days
     EXCEPTIONS
          INVALID_DATES_SPECIFIED = 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.


write:/ 'Years = ', d_yrs, 'Months = ', d_months, 'Days = ', d_days.

The output of the the above program is as follows.

Difference Between 2 dates                                                                
                                                                                          
Years =  4.0000  Months =    11.0000  Days =      29