ABAP/4

ABAP/4 Example Code: Factorial


DATA: output TYPE i.
PARAMETERS: p_num TYPE i.
START-OF-SELECTION.
  PERFORM factorial USING p_num
                    CHANGING output.
  WRITE:/ output.
*&---------------------------------------------------------------------*
*&      Form  factorial
*&---------------------------------------------------------------------*
*       text
*-----------------------------------

ABAP/4 Example Code: Fibonacci


DATA: output TYPE i.
PARAMETERS: p_num TYPE i.
START-OF-SELECTION.
  PERFORM fibonacci USING p_num
                    CHANGING output.
  WRITE:/ output.
*&---------------------------------------------------------------------*
*&      Form  fibonacci
*&---------------------------------------------------------------------*
*       text
*---------------------------------------

Delete PC Directory in ABAP/4

Example:  We will delete directory ’Temp’ on drive C:

CALL FUNCTION ’GUI_REMOVE_DIRECTORY’      
EXPORTING         
DIRNAME            = ’C:\Temp’     
EXCEPTIONS         
FAILED              = 1         
OTHERS              = 2
            &

Create PC Directory in ABAP/4

Example:  We will create directory ’Temp’ on drive C:

CALL FUNCTION ’GUI_CREATE_DIRECTORY’      
EXPORTING         
DIRNAME            = ’C:\Temp’     
EXCEPTIONS         
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.

How to Get Name of Months in ABAP/4

You can get name of months by select table ’T247’

DATA: it_month_name TYPE TABLE OF t247 WITH HEADER LINE.

SELECT * INTO TABLE it_month_name FROM T247
WHERE spras = sy-langu.

or using function module ’MONTH_NAMES_GET’

DATA: it_month_name TYPE TABLE OF t247 WITH HEADER LINE.
CALL FUNCTION ’MONTH_NAMES_GET’
EXPORTING
LANGUAGE = SY-LANGU
* IMPORTING
* RETURN_CODE =
TABLES
MONTH_NAMES = it_month_name
EXCEPTIONS
MONTH_NAMES_NOT_FOUND = 1
OTHERS = 2
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.

Related Function Module in SAPscript

Fn Name           Description
START_FORM Start Layout Set
OPEN_FORM Open Layout Set
WRITE_FORM Write data by specified text element in window
WRITE_FORM_LINES Write data in TLINE structure to window
CLOSE_FORM Close Layout Set
END_FORM End Layout Set
CONTROL_FORM Create SAPscript Control Statement

See Example

Technorati Tags: