‎2007 Mar 06 11:29 AM
Hi all
Can any one tell how to use standard BAPIs provided by SAP
rgds
‎2007 Mar 06 11:32 AM
Within SAp they can be used as normal function modules.
For example if the name of the bapi is : BAPI_PO_CREATE, then you should populate the parameters that the BAPI FM expects and then call it using
CALL FUNCTION Statement
call function 'BAPI_PO_CREATE'
exporting
.
.
.
importing
.
.
tables
.
.
Regards,
Ravi
‎2007 Mar 06 11:32 AM
Within SAp they can be used as normal function modules.
For example if the name of the bapi is : BAPI_PO_CREATE, then you should populate the parameters that the BAPI FM expects and then call it using
CALL FUNCTION Statement
call function 'BAPI_PO_CREATE'
exporting
.
.
.
importing
.
.
tables
.
.
Regards,
Ravi
‎2007 Mar 06 11:41 AM
this is the sample program using BAPI -
*&---------------------------------------------------------------------*
*& Report Z_AMIT_BAPI *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
REPORT Z_AMIT_BAPI
no standard page heading line-size 255.
parameters: p_file like rlgrap-filename default 'C:tempemp.txt'.
data :begin of itab occurs 0,
pernr(8),
bdate(10),
edate(10),
mail(30) ,
end of itab.
data: begin of itab1 occurs 0,
pernr like BAPIP0105N-EMPLOYEENO,
bdate like BAPIP0105N-VALIDBEGIN,
edate like BAPIP0105N-VALIDEND,
mail like BAPIP0105N-ID,
end of itab1.
data: number like BAPIP0001-PERNR .
*data: LOCKINDICATOR like P0001-SPRPS value 'X'.
Start-of-selection.
Perform read_file.
loop at itab.
clear itab1.
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
DATE_EXTERNAL = itab-bdate
IMPORTING
DATE_INTERNAL = itab1-bdate.
* EXCEPTIONS
* DATE_EXTERNAL_IS_INVALID = 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.
CALL FUNCTION 'CONVERT_DATE_TO_INTERNAL'
EXPORTING
DATE_EXTERNAL = itab-edate
IMPORTING
DATE_INTERNAL = itab1-edate
* EXCEPTIONS
* DATE_EXTERNAL_IS_INVALID = 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.
move: itab-pernr to itab1-pernr,
itab-mail to itab1-mail.
append itab1.
number = itab1-pernr .
CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'
EXPORTING
NUMBER = number .
* IMPORTING
* RETURN = .
CALL FUNCTION 'BAPI_EMPLCOMM_CREATE'
EXPORTING
EMPLOYEENUMBER = itab1-pernr
SUBTYPE = '0010'
VALIDITYBEGIN = itab1-bdate
VALIDITYEND = itab1-edate
COMMUNICATIONID = itab1-mail.
* NOCOMMIT =
* IMPORTING
* RETURN =
* EMPLOYEENUMBER =
* SUBTYPE =
* OBJECTID =
* LOCKINDICATOR =
* VALIDITYBEGIN =
* VALIDITYEND =
* RECORDNUMBER = .
CALL FUNCTION 'BAPI_EMPLOYEE_DEQUEUE'
EXPORTING
NUMBER = number.
* IMPORTING
* RETURN = .
endloop.
*&---------------------------------------------------------------------*
*& Form read_file
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM read_file .
DATA: full_file_name TYPE string.
full_file_name = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = full_file_name
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = ','
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* DAT_MODE = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* CHECK_BOM = ' '
* NO_AUTH_CHECK = ' '
* IMPORTING
* FILELENGTH =
* HEADER =
TABLES
DATA_TAB = itab
EXCEPTIONS
FILE_OPEN_ERROR = 1
FILE_READ_ERROR = 2
NO_BATCH = 3
GUI_REFUSE_FILETRANSFER = 4
INVALID_TYPE = 5
NO_AUTHORITY = 6
UNKNOWN_ERROR = 7
BAD_DATA_FORMAT = 8
HEADER_NOT_ALLOWED = 9
SEPARATOR_NOT_ALLOWED = 10
HEADER_TOO_LONG = 11
UNKNOWN_DP_ERROR = 12
ACCESS_DENIED = 13
DP_OUT_OF_MEMORY = 14
DISK_FULL = 15
DP_TIMEOUT = 16
OTHERS = 17
.
IF SY-SUBRC <> 0.
MESSAGE e000(000) WITH 'Upload-Error; RC:' sy-subrc.
ENDIF.
ENDFORM. " read_file
‎2007 Mar 06 11:33 AM
hi anup,
If you know the BAPI name just call that in your program,
eg: to get the list of all cost centers in a cost center group
CALL FUNCTION 'BAPI_COSTCENTERGROUP_GETDETAIL'
EXPORTING
controllingarea = 'ZZZ'
groupname = p_ccgrp
IMPORTING
return = it_messages1
TABLES
hierarchynodes = it_nodes1
hierarchyvalues = it_kostl.
Message was edited by:
Chandrasekhar Jagarlamudi