Showing posts with label ABAP Function. Show all posts
Showing posts with label ABAP Function. Show all posts
Wednesday, October 24, 2012 at 1:41 AM | 0 comments
Here is a sample MONTH_PLUS_DETERMINE


Please see example code below.

data : lv_newdate type sy-datum.

call function 'MONTH_PLUS_DETERMINE'
  exporting
    months = 1
    olddate = '20120101'
  importing
    newdate = lv_newdate.

write : lv_newdate. " output -> 20120201
Posted by Shanto Labels:
From Release 4.0 the previously 1-character language key has 2-characters as in ISO Code 639. For example, English is now 'EN' insead of 'E', Hebrew is 'HE' instead of 'B' and Korean is 'KO' instead of '3'. Script :

data : lv_output(1).

call function 'CONVERSION_EXIT_ISOLA_INPUT'
exporting
    input = 'ID'     " ID -> Indonesia
importing
    output = lv_output.


write lv_output.
Posted by Shanto Labels: ,
Sunday, November 20, 2011 at 11:08 PM | 0 comments
Here is an example of how to FTP a file from the Application server to a remote server using standard SAP functions.


REPORT YSANTO_12 .

data: begin of gi_data occurs 0,
                line(132) type c,
           end of gi_data.

data: lv_password(20) type c,
           lv_key type i value 26101957,
           lv_pwd_len type I,
           lv_handle type I.

START-OF-SELECTION.

lv_password = 'password'.

describe field lv_password length lv_pwd_len in character mode.


call 'AB_RFC_X_SCRAMBLE_STRING'
           id 'SOURCE' field lv_password id 'KEY' field lv_key
           id 'SCR' field 'X' id 'DESTINATION' field lv_password
           id 'DSTLEN' field lv_pwd_len.

call function 'FTP_CONNECT'
         exporting
           user = 'userid'
           password = lv_password
           host = 'host'
           rfc_destination = 'SAPFTP'
         importing
           handle = lv_handle
         exceptions
           not_connected = 1
           others = 2.

check sy-subrc = 0.

call function 'FTP_COMMAND'
         exporting
           handle = lv_handle
           command = 'dir'    " for get file -> exe commnad 'asci'
         tables                          " then exe command 'get sourcefile targetfile'.
           data = gi_data
         exceptions
           tcpip_error = 1
           command_error = 2
           data_error = 3
           others = 4.


call function 'FTP_DISCONNECT'
         exporting
           handle = lv_handle
         exceptions
           others = 1.

Posted by Shanto Labels: ,
Thursday, January 27, 2011 at 12:04 AM | 1 comments
Fungsi BAPI_TRIP_GET_DETAILS adalah untuk mengambil nilai yang ada di travel expense tcode PR05.
data :
    t_framedata type table of bapitrmain with header line,
    t_receipts type table of bapitrvreo with header line,
    t_addinfo type table of bapitraddi with header line,
    t_amounts type table OF bapitrvsum with header line.

CALL FUNCTION 'BAPI_TRIP_GET_DETAILS'
EXPORTING
    employeenumber = '151515' " <- Employee Number
    tripnumber = '15' " <- Trip Number
    language = sy-langu
    calculate_amounts = 'X'
IMPORTING
    framedata = t_framedata
TABLES
    receipts = t_receipts
    addinfo = t_addinfo
    amounts = t_amounts.
Posted by Shanto Labels:
Fungsi CURRENCY_AMOUNT_DISPLAY_TO_SAP adalah untuk menyimpan suatu nilai ke table sesuai dengan currency.

Contoh :

CALL FUNCTION 'CURRENCY_AMOUNT_DISPLAY_TO_SAP'
EXPORTING
    currency = 'IDR'
    amount_display = 25
IMPORTING
    amount_internal = gd_intval " Hasil 0.2500
EXCEPTIONS
    internal_error = 1
    others = 2.
Posted by Shanto Labels:
Monday, January 24, 2011 at 9:27 PM | 0 comments
Fungsi MONTH_PLUS_DETERMINE adalah untuk menjumlahkan / mengurangkan bulan di dalam tanggal.

Contoh :

CALL FUNCTION 'MONTH_PLUS_DETERMINE'
EXPORTING
   months = 2
   olddate = '20080401'
IMPORTING
   newdate = lv_date_new. " hasil -> 20080601
Posted by Shanto Labels:
Fungsi Get Last Day of The Month adalah mengembalikan nilai tanggal terakhir.

Contoh :

CALL FUNCTION 'LAST_DAY_OF_MONTHS'
EXPORTING
   day_in = '20080401'
IMPORTING
   last_day_of_month = lv_last_day_of_month " hasil -> 20080430
EXCEPTIONS
   day_in_no_date = 1
   others = 2.
Posted by Shanto Labels: