11-04-2008 11:55 PM
Hi Expert,
Could you adv what is significant differences between using INSERT sql command to insert data into PA infotype table compare with PA30 function (Using BDC)?
Could anyone give good example of using FM which have similar action with BDC PA30 function?
the reason is , i did create program to update infotype using INSERT Sql command but i have doubt that i miss several step behin PA30 function.
Please kindly help.
Thanks.
Rudy.
11-05-2008 12:05 AM
Hi,
as you mentioned there might be some logic behind transaction and you miss it in your program. It is always better to use BAPI or BDC than direct write to the SAP table. Try to check this FM HR_ECM_INSERT_INFOTYPE. It looks like general FM for inserting info types (I've never used it).
Cheers
11-05-2008 4:28 AM
Hi Rudy,
If you use direct table update for PA infotype or any standard table you may have following disadvantages:
1. On screen validations are all by passed.
2. Change log if needs to be updated will never happen.
3. Any other infotype updation after the currnt infotype (if configured) will never happen.
4. I am not even sure about the consistency of the database if somewhere the updation fails.
There can be many more which I am not able to recollec right now...
Regards,
Prakash Pandey
11-05-2008 5:50 AM
hi Mohan,
Below is the code which is upadting infotype 169 ....
DATA: it_p0169 TYPE STANDARD TABLE OF pa0169 WITH HEADER LINE.
DATA: wa_p0169 TYPE p0169.
fill your data in wa_p0169..(all the required filed are must )
wa_p0169-INFTY = '0169'.(do not forget to fill in work area )
now pass this work area ...like below one
PERFORM update_pa0169_infotype USING wa_p0169.
FORM update_pa0169_infotype USING p_wa_0169 TYPE p0169.
CONSTANTS: c_action_ins TYPE pspar-actio VALUE 'MOD',
c_infty_0169 TYPE prelp-infty VALUE '0169'.
*
DATA: it_return TYPE bapireturn1.
lock the employee
PERFORM emp_enqueue USING p_wa_0169-pernr.
*Note: FM needed in bulK processing
CALL FUNCTION 'HR_PSBUFFER_INITIALIZE'.
Update the Infotype
CALL FUNCTION 'HR_INFOTYPE_OPERATION'
EXPORTING
infty = c_infty_0169
number = p_wa_0169-pernr
SUBTYPE = '401K'
OBJECTID =
LOCKINDICATOR =
validityend = p_wa_0169-endda
validitybegin = v_begda1
RECORDNUMBER =
record = p_wa_0169
operation = c_action_ins
TCLAS = 'A'
DIALOG_MODE = '0'
NOCOMMIT =
VIEW_IDENTIFIER =
SECONDARY_RECORD =
IMPORTING
return = it_return.
if it_return-MESSAGE is not initial .
delete it_file .
endif.
commit work .
Dequeue this employee when done
PERFORM emp_dequeue USING p_wa_0169-pernr.
endform.
FORM emp_enqueue USING p_pernr LIKE prelp-pernr.
Enqueue this employee to modify
CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'
EXPORTING
number = p_pernr
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
RAISE enqueue_FAILED.
ENDIF.
ENDFORM.
FORM emp_dequeue USING p_pernr LIKE prelp-pernr.
CALL FUNCTION 'BAPI_EMPLOYEE_DEQUEUE'
EXPORTING
number = p_pernr
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
RAISE DEQUEUE_FAILED.
ENDIF.
ENDFORM.
Thanks and regards
Priyank
06-08-2009 4:17 AM