Thursday, May 1, 2008

SAP ABAP Function Module to Run an Executable Program with Parameters

SAP ABAP Function Module to Run an Executable Program with Parameters

If you wish to run an executable program from SAP it can be done by using the following Function Module.

GUI_RUN

These function modules are useful when you want to create an interface with SAP. Many a times it may be required to call an executable program from SAP and pass some Parameters to it. The called user program can then process the data and return back parameters to SAP. Function modules similar to GUI_RUN can be used to build such interfaces.

We will see a simple example of opening a Notepad file from SAP and another example by opening a website through a browser.

Example 1

REPORT ZEX_GUIRUN .


CALL FUNCTION 'GUI_RUN'
  EXPORTING
    COMMAND          = 'NOTEPAD.EXE'
   PARAMETER         = 'c:\TEST.TXT'
*   CD               = '
* IMPORTING
*   RETURNCODE       = .

Example 2

REPORT ZEX_GUIRUN .


CALL FUNCTION 'GUI_RUN'
  EXPORTING
    COMMAND          = 'FIREFOX.EXE'
   PARAMETER         = 'GOOGLE.COM'
*   CD               = '
* IMPORTING
*   RETURNCODE       = .

So if you want to open a browser you can use the function module GUI_RUN.

Some other function modules that open a browser from within SAP are as follows.

Calling a Browser from ABAP



Different Types of Menus in SAP.

Different Types of Menus in SAP.

We will examine the following menus.

USER MENU
SAP MENU
SAP BUSINESS WORKPLACE

USER MENU

This is a customized version of the SAP menu. Basically this menu would be specific to a user. If you are working in a Particular area say for example in ABAP then the Basis Administrator would add a menu specific to your tasks.

If a separate user menu has not been designed for you, then you can create a
Favorites list consisting of the transactions, files, and Web addresses you use most frequently. This can be done by selecting the transaction from the SAP Menu and then clicking on the add to Favorites.



SAP MENU

This is the complete list of menus items available in SAP. You can add items to the Favorites list from this menu.



SAP BUSINESS WORKPLACE

SAP Business Workplace gives access to SAP Inbox, Outbox, Folders and other items. Here you also get an Appointment Calender where you can maintain your appointments and reminders. You can also set up meetings and send mails to the participants.


SAP ABAP Checking the Validity of a Date

SAP ABAP Checking the Validity of a Date

To check the validity of a date field you can use the following function module.

DATE_CHECK_PLAUSIBILITY

Please see the example given below.

REPORT ZEX_DATEVALIDATE .


Parameters p_date like sy-datum.




CALL FUNCTION 'DATE_CHECK_PLAUSIBILITY'
     EXPORTING
          DATE                                         = p_date
     EXCEPTIONS
          PLAUSIBILITY_CHECK_FAILED   = 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:/ sy-subrc.

If the value of Sy-subrc is 0 that means the date field has a valid value.

If the input is 01/01/2008 then the output of the above program is as follows.

Validate the date           
                            
    0                       

If the input is 31/31/2008 then the output is as follows.

Validate the date           
                            
    1