‎2007 Mar 23 1:57 PM
Hi folks,
I am trying to delete a record from pa0019. Of course I am not deleting the record directly but copying the existing record into the workarea and deletingit.
However, query of selecting the record from table is not working.
tables: pa0019.
data: wa_pa0019 like pa0019 occurs 0 with header line.
select single * from pa0019 into wa_pa0019 where pernr = 'v_pernr'
and tmart = 'Z9' and termn = '07/07/2005'.
delete pa0019 from wa_pa0019.
I see a record for this employeeid in the table pa0019. why is not retrieving any record? Am I missing something here?
I know this is simple, and have done this before too, but not able to recall what is the problem here?
Any thoughts,
Thanks,
SK
‎2007 Mar 23 2:03 PM
Hi,
select single * from pa0019 into wa_pa0019 where pernr = 'v_pernr'
and tmart = 'Z9' and termn = '07/07/2005'.
by using this u can select only one record.
that will be deleted from ur code.but there may be some other record in uthat table which satisfy the same where condition.
check it.
regards,
bharat.
‎2007 Mar 23 2:13 PM
You should be using PA30 or the function call to HR_INFOTYPE_OPERATION to delete an Infotype record. Deleting directly from the database might affect data integrity/consistency as the validations that go with the Business Logic are not accounted for.
~Suresh
‎2007 Mar 23 2:37 PM
Hi skmysore ,
In select statement u mentioned termn = '07/07/2005' ,where as it should be like '20050707'. And also u have declared wa_pa0019 as internal instead of workarea. Plz check it out .
Regards,
Kiran B
‎2007 Mar 23 3:19 PM
hi,
I am using the function module to delete the records, however I am getting an error
Here is my code
CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'
EXPORTING
NUMBER = itab1-employee
IMPORTING
RETURN = RETURNE.
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
INFTY = '0019'
NUMBER = itab1-employee
SUBTYPE = 'Z9'
VALIDITYEND = itab1-return_date (yyyymmdd)
VALIDITYBEGIN = itab1-return_date
TMART ='Z9'
TERMN = itab1-return_date
OPERATION = 'DEL'
TCLAS = 'A'
DIALOG_MODE = '0'
IMPORTING
RETURN = RETURN
KEY = KEY.
IF RETURN IS NOT INITIAL. **** error here
Incorrect logical expression: Comparison/SELECT-OPTION can only be followed by 'AND', 'OR'
WRITE 😕 'Error Occurred'.
ENDIF.
CALL FUNCTION 'BAPI_EMPLOYEE_DEQUEUE'
EXPORTING
NUMBER = itab1-employee.
I am not using any selection option I am uploading the file intot he internal table and entering new records using BDC and deleting the record from 0019.
Can anyone tell me what is wrong here?
Thanks,
SK
‎2007 Mar 23 3:24 PM
Did you paste your complete code?Your function call doesn't look correct. Are you sure you are passing the RECORD parameter? It would help, if you can paste the code as is.
~Suresh
‎2007 Mar 23 3:34 PM
Global variables inthe program
DATA : RETURN LIKE BAPIRETURN1.
DATA : KEY LIKE BAPIPAKEY.
DATA : RETURNE LIKE BAPIRETURN1.
data: begin of itab1 occurs 0,
employee(8),
reason_type(2),
reason_code(2),
return_date like sy-datum,
end of itab1.
I read the data into the internal table from an external text file, then I upload the record(RLOA) into actions infotype using BDC session, then I need to delete the record for the same employee in 0019.
I think I am missing the RECORD parameter, hwo can i get that?
loop at itab1.
*** check to see whether there is a RLOA record for the employee
select single * from pa0000 where pernr = itab1-employee and
massn = 'z7' and begda = itab1-return_date.
if sy-subrc = 0.
error-employee = itab1-employee.
error-reason = 'RLOA exists for the employee'.
append error.
continue.
else.
clear bdcdata.
refresh bdcdata.
perform load_data.
If the RLOA record is created in Actions infotype delete
the record in monitoring of tasks record in IT0019
if g_monitoringflag = 'X'.
format the date to mm/dd/yyyy
v_returndate = itab1-return_date.
concatenate v_returndate0(2) '/' v_returndate2(2) '/'
v_returndate+4(4) into v_formatdate.
CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'
EXPORTING
NUMBER = itab1-employee
IMPORTING
RETURN = RETURNE.
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
INFTY = '0019'
NUMBER = itab1-employee
SUBTYPE = 'Z9'
VALIDITYEND = itab1-return_date
VALIDITYBEGIN = itab1-return_date
TMART ='Z9'
TERMN = itab1-return_date
OPERATION = 'DEL'
TCLAS = 'A'
DIALOG_MODE = '0'
IMPORTING
RETURN = RETURN
KEY = KEY.
IF RETURN IS NOT INITIAL.
WRITE 😕 'Error Occurred'.
ENDIF.
CALL FUNCTION 'BAPI_EMPLOYEE_DEQUEUE'
EXPORTING
NUMBER = itab1-employee.
if sy-subrc = 0.
clear:g_monitoringflag, v_formatdate.
else.
error-employee = itab1-employee.
error-reason = 'No record created for RLOA'.
clear:v_formatdate.
endif.
endif.
endif.
endloop.
Thanks in advance for your help.
SK
‎2007 Mar 23 3:40 PM
Hi skmysore,
the documentation of this FM says
This function module enables you to maintain master data for employees
and applicants. You can transfer one data record. All validation checks
take place that would take place in the individual maintenance screens
in the dialog. If necessary, the module returns an error message. <b>The
error messages are the same as the error messages in the dialog,</b> that
is, the individual maintenance screen error messages are transferred
rather than interpreted by this module.
So you should try this first in dialog. If this works fine, you have to debug the process. You can set a breakpoint on statement MESSAGE and/or check where (and why) the BAPIRETURN table is filled.
Suggestion: A good method for testing BAPI results is to
CALL REUSE_ALV_GRID_DIPLAY
exporting
I_STRUCTURE_NAME = 'BAPIRET1' for this FM, usually BAPITET2
TABLES
t_outtab = RETURN
This enables you to study, save, copy easily.
Regards,
Clemens