Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

BAPI IN HR-ABAP

Former Member
0 Likes
694

SOME WAY OF DOING BAPI IN HR ..PLEASE IF POSSIBLE ONE EXAMPLE

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
654

Hi Raghunandan,

Look into the following program which might be useful.

HR_INFOTYPE_OPERATION is used to insert,modify,change etc using particular infotype.

data : v_file type string.

PARAMETERS : p_file like rlgrap-filename.

at selection-screen on value-request for p_file.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

PROGRAM_NAME = SYST-CPROG

DYNPRO_NUMBER = SYST-DYNNR

FIELD_NAME = 'P_FILE'

IMPORTING

FILE_NAME = P_FILE.

start-of-selection.

**get pernr.

v_file = p_file.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = V_FILE

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = ' '

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • VIRUS_SCAN_PROFILE =

  • NO_AUTH_CHECK = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

DATA_TAB = i_0008

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 ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

*RP50G-PERNR = '54025'.

*RP50G-CHOIC = '0008'.

*P0008-BEGDA = '20030101'.

*P0008-ENDDA = '99991231'.

*P0008-PREAS = 'w1'.

*P0008-TRFGR = 'L03'.

*Q0008-ANSAL = '50000'.

*P0008-ANCUR = 'EUR'.

*q0008-LGART = 'M100'.

**Q0008-BETRG = '500'.

**Q0008-BETRG = '500'.

**Q0008-WAERS = 'INR'.

loop at i_0008.

***move i0008 to i_0008.

move-corresponding i_0008 to p0008.

append p0008.

*move-corresponding i_0008 to q0008.

*append q0008.

*loop at p0008.

***move i_0008 to p0008.

CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'

EXPORTING

NUMBER = p0008-pernr "RP50G-PERNR

IMPORTING

RETURN = RETURNE.

**IF RETURN EQ 0.

*

**loop at p0008.

CALL FUNCTION 'HR_INFOTYPE_OPERATION'

EXPORTING

INFTY = '0008'

NUMBER = p0008-PERNR

SUBTYPE = p0008-SUBTY

OBJECTID = p0008-OBJPS

LOCKINDICATOR = p0008-SPRPS

VALIDITYEND = p0008-ENDDA

VALIDITYBEGIN = p0008-BEGDA

RECORDNUMBER = p0008-SEQNR

RECORD = p0008

OPERATION = 'INS'

TCLAS = 'A'

DIALOG_MODE = '2'

  • NOCOMMIT =

  • VIEW_IDENTIFIER =

  • SECONDARY_RECORD =

IMPORTING

RETURN = RETURN

KEY = KEY

.

if return is not initial.

write: / 'ERROR OCCURED'.

ENDIF.

CALL FUNCTION 'BAPI_EMPLOYEE_DEQUEUE'

EXPORTING

NUMBER = p0008-pernr "RP50G-PERNR

IMPORTING

RETURN = RETURNE.

endloop.

If you want more clarification on this see the documentation for HR_INFOTYPE _OPERATION.

Hope this helps you understand the usage of BAPI HR_INFOTYPE _OPERATION

*Reward points if found useful

Regards,

Naresh

SOME WAY OF DOING BAPI IN HR ..PLEASE IF POSSIBLE ONE EXAMPLE

3 REPLIES 3
Read only

Former Member
0 Likes
654

Hi,

BAPI Programming Tips and Tricks

SAP created the Business Framework to allow the technical integration and exchange of business data among SAP components and between SAP and non-SAP components. Important components of the Business Framework are the Business Application Programming Interfaces (BAPIs), which represent visible interfaces at the component boundaries and whose properties serve to integrate these components.

The integration can include both components within a local network and components that are connected with one another through the Internet.

BAPIs allow integration at the business level, not the technical level. This provides for greater stability in the link, and independence from the underlying communication technology.

You can get all the standard SAP BAPI functions with the transactions code 'BAPI'.

http://www.sap-img.com/bapi.htm

http://help.sap.com/saphelp_erp2005/helpdata/en/b0/dad2bc0b3611d2a55a0060087832f8/content.htm

Regards,

Jagadish

Read only

Former Member
0 Likes
655

Hi Raghunandan,

Look into the following program which might be useful.

HR_INFOTYPE_OPERATION is used to insert,modify,change etc using particular infotype.

data : v_file type string.

PARAMETERS : p_file like rlgrap-filename.

at selection-screen on value-request for p_file.

CALL FUNCTION 'F4_FILENAME'

EXPORTING

PROGRAM_NAME = SYST-CPROG

DYNPRO_NUMBER = SYST-DYNNR

FIELD_NAME = 'P_FILE'

IMPORTING

FILE_NAME = P_FILE.

start-of-selection.

**get pernr.

v_file = p_file.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = V_FILE

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = ' '

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • VIRUS_SCAN_PROFILE =

  • NO_AUTH_CHECK = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

DATA_TAB = i_0008

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 ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

*RP50G-PERNR = '54025'.

*RP50G-CHOIC = '0008'.

*P0008-BEGDA = '20030101'.

*P0008-ENDDA = '99991231'.

*P0008-PREAS = 'w1'.

*P0008-TRFGR = 'L03'.

*Q0008-ANSAL = '50000'.

*P0008-ANCUR = 'EUR'.

*q0008-LGART = 'M100'.

**Q0008-BETRG = '500'.

**Q0008-BETRG = '500'.

**Q0008-WAERS = 'INR'.

loop at i_0008.

***move i0008 to i_0008.

move-corresponding i_0008 to p0008.

append p0008.

*move-corresponding i_0008 to q0008.

*append q0008.

*loop at p0008.

***move i_0008 to p0008.

CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'

EXPORTING

NUMBER = p0008-pernr "RP50G-PERNR

IMPORTING

RETURN = RETURNE.

**IF RETURN EQ 0.

*

**loop at p0008.

CALL FUNCTION 'HR_INFOTYPE_OPERATION'

EXPORTING

INFTY = '0008'

NUMBER = p0008-PERNR

SUBTYPE = p0008-SUBTY

OBJECTID = p0008-OBJPS

LOCKINDICATOR = p0008-SPRPS

VALIDITYEND = p0008-ENDDA

VALIDITYBEGIN = p0008-BEGDA

RECORDNUMBER = p0008-SEQNR

RECORD = p0008

OPERATION = 'INS'

TCLAS = 'A'

DIALOG_MODE = '2'

  • NOCOMMIT =

  • VIEW_IDENTIFIER =

  • SECONDARY_RECORD =

IMPORTING

RETURN = RETURN

KEY = KEY

.

if return is not initial.

write: / 'ERROR OCCURED'.

ENDIF.

CALL FUNCTION 'BAPI_EMPLOYEE_DEQUEUE'

EXPORTING

NUMBER = p0008-pernr "RP50G-PERNR

IMPORTING

RETURN = RETURNE.

endloop.

If you want more clarification on this see the documentation for HR_INFOTYPE _OPERATION.

Hope this helps you understand the usage of BAPI HR_INFOTYPE _OPERATION

*Reward points if found useful

Regards,

Naresh

Read only

0 Likes
654

Hi Naresh,

1. Just to correct -

HR_INFOTYPE_OPERATION is a simple FM,

and not a BAPI. It is not even RFC enabled.

regards,

amit m.