Skip to Content
0
Dec 26, 2007 at 09:25 AM

BAPI / Urgent

12 Views

hi all ,

i m new for BAPI and using BAPI for updating absence data in PA61, but problem is that its not giving any update message

and also not updates table . can anyone tell me what should i do ? i m also not sure whatever i did thats the way r not...

i m also sending the code that i did....

*REPORT ZHR_BAPI

.

TYPES : BEGIN OF ITAB1 ,

PERNR(8) ,

BEGDA(8) ,

ENDDA(8),

BEGUZ(6) ,

ENDUZ(6) ,

AWART(4) ,

END OF ITAB1 .

************************************************************************

****

TYPES: BEGIN OF T_TEMP,

pernr like BAPIP2001-pernr,

begda like BAPIP2001-begda,

ENDDA like BAPIP2001-ENDDA,

BEGUZ like BAPIP2001-BEGUZ,

ENDUZ like BAPIP2001-ENDUZ,

AWART like BAPIP2001-AWART,

END OF T_TEMP.

DATA: IT_TEMP TYPE TABLE OF T_TEMP,

WA_TEMP TYPE T_TEMP.

DATA : ITAB TYPE STANDARD TABLE OF ITAB1 WITH HEADER LINE ,

wa_itab like itab.

************************************************************************

******************

*DATA : BDCDATA TYPE STANDARD TABLE OF BDCDATA WITH HEADER LINE .

*DATA : MESSTAB TYPE STANDARD TABLE OF BDCMSGCOLL WITH HEADER LINE .

************************************************************************

*****************

DATA: BEGIN OF L_INTERN OCCURS 0.

INCLUDE STRUCTURE ALSMEX_TABLINE.

DATA: END OF L_INTERN.

DATA : L_INDEX TYPE I,

CTR TYPE I VALUE 0,

L_MSTRING(480),

S_LOCNR1(6) TYPE C.

DATA : IT_RETURN TYPE table OF BAPIRETURN1 ,

wa_return type BAPIRETURN1.

************************************************************************

*****************

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

PARAMETERS: P_FILE LIKE RLGRAP-FILENAME

DEFAULT '' OBLIGATORY. " File Name

SELECTION-SCREEN END OF BLOCK B1.

*SELECTION-SCREEN : BEGIN OF BLOCK B4 WITH FRAME TITLE TEXT-014.

*PARAMETER : L1 RADIOBUTTON GROUP RADI DEFAULT 'X',

  • L2 RADIOBUTTON GROUP RADI .

*SELECTION-SCREEN : END OF BLOCK B4 .

************************************************************************

****************

AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_FILE.

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'

  • EXPORTING

  • PROGRAM_NAME = SYST-REPID

  • DYNPRO_NUMBER = SYST-DYNNR

  • FIELD_NAME = ' '

  • STATIC = ' '

  • MASK = ' '

CHANGING

FILE_NAME = P_FILE

  • EXCEPTIONS

  • MASK_TOO_LONG = 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.

----


START-OF-SELECTION.

PERFORM UPLOAD_FILE TABLES ITAB

USING P_FILE.

LOOP AT ITAB into wa_itab..

wa_TEMP-pernr = wa_itab-pernr.

wa_TEMP-begda = wa_itab-begda.

wa_TEMP-ENDDA = wa_itab-ENDDA.

wa_TEMP-BEGUZ = wa_itab-BEGUZ.

wa_TEMP-ENDUZ = wa_itab-ENDUZ.

wa_TEMP-AWART = wa_itab-AWART.

APPEND WA_TEMP TO IT_TEMP.

endloop.

LOOP AT IT_TEMP INTO WA_TEMP.

CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'

EXPORTING

NUMBER = WA_TEMP-PERNR

  • IMPORTING

  • RETURN = WA_TEMP-AWART

.

CALL FUNCTION 'BAPI_ABSENCE_CREATE'

EXPORTING

EMPLOYEENUMBER = WA_TEMP-PERNR

VALIDITYBEGIN = WA_TEMP-begda

VALIDITYEND = WA_TEMP-ENDDA

START = WA_TEMP-BEGUZ

END = WA_TEMP-ENDUZ

ABSENCETYPE = WA_TEMP-AWART

  • ABSENCEHOURS =

  • NOCOMMIT =

IMPORTING

RETURN = wa_RETURN

  • EMPLOYEENUMBER =

  • SUBTYPE =

  • OBJECTID =

  • LOCKINDICATOR =

  • VALIDITYBEGIN =

  • VALIDITYEND =

  • RECORDNUMBER =

.

*ENDLOOP.

CALL FUNCTION 'BAPI_EMPLOYEE_DEQUEUE'

EXPORTING

NUMBER = WA_TEMP-PERNR

  • IMPORTING

  • RETURN = wa_RETURN

.

ENDLOOP .

FORM UPLOAD_FILE TABLES P_IT_TAB

USING P_FILE.

FIELD-SYMBOLS : <FS>.

CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'

EXPORTING

FILENAME = P_FILE

I_BEGIN_COL = '1'

I_BEGIN_ROW = '2'

I_END_COL = '256'

I_END_ROW = '60000'

TABLES

INTERN = L_INTERN

EXCEPTIONS

INCONSISTENT_PARAMETERS = 1

UPLOAD_OLE = 2

OTHERS = 3.

IF SY-SUBRC NE 0.

FORMAT COLOR COL_BACKGROUND INTENSIFIED.

WRITE : / 'File Error'.

EXIT.

ENDIF.

IF L_INTERN[] IS INITIAL.

FORMAT COLOR COL_BACKGROUND INTENSIFIED.

WRITE : / 'No Data Uploaded'.

EXIT.

ELSE.

SORT L_INTERN BY ROW COL.

LOOP AT L_INTERN.

MOVE L_INTERN-COL TO L_INDEX.

ASSIGN COMPONENT L_INDEX OF STRUCTURE P_IT_TAB TO <FS>.

MOVE L_INTERN-VALUE TO <FS>.

AT END OF ROW.

APPEND P_IT_TAB.

CLEAR P_IT_TAB.

ENDAT.

ENDLOOP.

ENDIF.

ENDFORM. "UPLOAD_FILE

can anyone send me the correct code step by step .??

ans will be rewarded....

regards nitin .