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

ABAP HCM : Insert data into custom infotype using FM

Former Member
0 Likes
3,246

Hello,
I want to insert set data into custom infotype 9000 from another pernr.
before that i have try using FM HR_INFOTYPE_OPERATION for insert data into infotype but data not inserted in PA30.
I get message error "The employee is assigned to a different view indicator".

How i fix it ?


this is my code

SELECT * FROM pa9000 INTO CORRESPONDING FIELDS OF TABLE lt_9000

     WHERE pernr = lv_pernr.

   IF lt_9000[] IS NOT INITIAL and sy-tcode = 'PA40'.

     CONSTANTS: insert TYPE pspar-actio VALUE 'INS'.

     DATA: lv_return LIKE  bapireturn1,

           lv_key    LIKE  bapipakey.

     LOOP AT lt_9000.

       "This code is requred and locks the record ready for modification

       CLEAR lv_return.

       CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'

         EXPORTING

           number = innnn-pernr

         IMPORTING

           return = lv_return.

       MOVE-CORRESPONDING lt_9000 TO lw_9000.

       lw_9000-pernr = innnn-pernr.

       CLEAR lv_return.

       CALL FUNCTION 'HR_INFOTYPE_OPERATION'

         EXPORTING

           infty         = '9000'

*         subtype       = p_record-subty

           number        = innnn-pernr     "employeenumber

           validityend   = innnn-begda

           validitybegin = innnn-endda

           record        = lw_9000

           operation     = insert

*         nocommit      = ''

           dialog_mode   = '2'

           view_identifier  = '07'

         IMPORTING

           return        = lv_return

           key           = lv_key

         EXCEPTIONS

           OTHERS        = 0.

       if lv_return is not INITIAL.

         MESSAGE lv_return-message type 'E'.

       ENDIF.

       "unlock record after modification

       CALL FUNCTION 'HR_EMPLOYEE_DEQUEUE'

         EXPORTING

           number = innnn-pernr.

     ENDLOOP.

   ENDIF.

Thanks
Noor K Sejati

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,172

Hi,

Check the Value you are passing in the parameter view_identifier.

Check the value of the field VIEKN in infotype 0003 for the employee and then pass the same here.

Hope this help.

Hello,
I want to insert set data into custom infotype 9000 from another pernr.
before that i have try using FM HR_INFOTYPE_OPERATION for insert data into infotype but data not inserted in PA30.
I get message error "The employee is assigned to a different view indicator".

How i fix it ?


this is my code

SELECT * FROM pa9000 INTO CORRESPONDING FIELDS OF TABLE lt_9000

     WHERE pernr = lv_pernr.

   IF lt_9000[] IS NOT INITIAL and sy-tcode = 'PA40'.

     CONSTANTS: insert TYPE pspar-actio VALUE 'INS'.

     DATA: lv_return LIKE  bapireturn1,

           lv_key    LIKE  bapipakey.

     LOOP AT lt_9000.

       "This code is requred and locks the record ready for modification

       CLEAR lv_return.

       CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'

         EXPORTING

           number = innnn-pernr

         IMPORTING

           return = lv_return.

       MOVE-CORRESPONDING lt_9000 TO lw_9000.

       lw_9000-pernr = innnn-pernr.

       CLEAR lv_return.

       CALL FUNCTION 'HR_INFOTYPE_OPERATION'

         EXPORTING

           infty         = '9000'

*         subtype       = p_record-subty

           number        = innnn-pernr     "employeenumber

           validityend   = innnn-begda

           validitybegin = innnn-endda

           record        = lw_9000

           operation     = insert

*         nocommit      = ''

           dialog_mode   = '2'

           view_identifier  = '07'

         IMPORTING

           return        = lv_return

           key           = lv_key

         EXCEPTIONS

           OTHERS        = 0.

       if lv_return is not INITIAL.

         MESSAGE lv_return-message type 'E'.

       ENDIF.

       "unlock record after modification

       CALL FUNCTION 'HR_EMPLOYEE_DEQUEUE'

         EXPORTING

           number = innnn-pernr.

     ENDLOOP.

   ENDIF.

Thanks
Noor K Sejati

6 REPLIES 6
Read only

Former Member
0 Likes
2,173

Hi,

Check the Value you are passing in the parameter view_identifier.

Check the value of the field VIEKN in infotype 0003 for the employee and then pass the same here.

Hope this help.

Read only

0 Likes
2,172

i have checked value viekn in infotype 0003 and function was succes.
but when i checked tcode pa30 value infotype custom 9000 not inserted. how i fix it?
what i am missing?

Read only

0 Likes
2,172

Hi Noor,

If no error is throwing and still updation is not happened? Have you used COMMIT statement after HR_INFOTYPE_OPERATION to update the values in backend table.

CALL FUNCTION BAPI_TRANSACTION_COMMIT

Regards

Rajkumar Narsimman

Read only

0 Likes
2,172

Hi Rajkumar,

I try using CALL FUNCTION BAPI_TRANSACTION_COMMIT, after HR_INFOTYPE_OPERATION but get error  Invalid COMMIT WORK in a COMMIT WORK or ROLLBACK WORK.


my code is in the user exit ZXPADU01, maybe using BAPI_TRANSACTION_COMMIT cant work in this exit?



Read only

0 Likes
2,172

If you have written your code in the User Exit, may be use 'STARTING AT NEW TASK' with the FM HR_INFOTYPE_OPERATION.

Hope this helps.

Read only

tapomay_sanyal
Participant
0 Likes
2,172

Hi Noor,

Agree with Gaurav,

check the view indicator value for the pernr from PA0003 and then check whether error is still coming or not.

Code fragment looks fine.

---BR----

Tapomay