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

Problem with 'HR_INFOTYPE_OPERATION'

Former Member
0 Likes
6,254

Good day to everyone. This is my first post and I'm looking forward to get your help.

I'm working on a project and I need to insert a record into infotype.

The problem is when the program reach HR_INFOTYPE_OPERATION the system hangs! and you cannot even close it. Even end session will not work! to kill this session I have to go to sm04 ... etc

can you help me with this!

this is a peace of my code!

CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'

EXPORTING

number = p9057-pernr

IMPORTING

return = wf_bapireturn1.

CALL FUNCTION 'HR_INFOTYPE_OPERATION'

EXPORTING

infty = '9057'

number = wa_pa9057-pernr

subtype = wa_pa9057-subty

  • objectid = wa_pa9057-objps

  • lockindicator = wa_pa9057-sprps

validityend = wa_pa9057-endda

validitybegin = wa_pa9057-begda

  • recordnumber = wa_pa9057-seqnr

record = p9057

operation = 'INS'

tclas = 'A'

dialog_mode = '0'

nocommit = 'X'

  • VIEW_IDENTIFIER =

  • SECONDARY_RECORD =

IMPORTING

return = wf_bapireturn1.

  • key = wf_key.

CALL FUNCTION 'BAPI_EMPLOYEE_DEQUEUE'

EXPORTING

number = p9057-pernr

IMPORTING

return = wf_bapireturn1.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
5,955

9057 is custom infotype, so check it once again 9057 is there in system or not. and also check it is properly created or not.

Good day to everyone. This is my first post and I'm looking forward to get your help.

I'm working on a project and I need to insert a record into infotype.

The problem is when the program reach HR_INFOTYPE_OPERATION the system hangs! and you cannot even close it. Even end session will not work! to kill this session I have to go to sm04 ... etc

can you help me with this!

this is a peace of my code!

CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'

EXPORTING

number = p9057-pernr

IMPORTING

return = wf_bapireturn1.

CALL FUNCTION 'HR_INFOTYPE_OPERATION'

EXPORTING

infty = '9057'

number = wa_pa9057-pernr

subtype = wa_pa9057-subty

  • objectid = wa_pa9057-objps

  • lockindicator = wa_pa9057-sprps

validityend = wa_pa9057-endda

validitybegin = wa_pa9057-begda

  • recordnumber = wa_pa9057-seqnr

record = p9057

operation = 'INS'

tclas = 'A'

dialog_mode = '0'

nocommit = 'X'

  • VIEW_IDENTIFIER =

  • SECONDARY_RECORD =

IMPORTING

return = wf_bapireturn1.

  • key = wf_key.

CALL FUNCTION 'BAPI_EMPLOYEE_DEQUEUE'

EXPORTING

number = p9057-pernr

IMPORTING

return = wf_bapireturn1.

19 REPLIES 19
Read only

Former Member
0 Likes
5,956

9057 is custom infotype, so check it once again 9057 is there in system or not. and also check it is properly created or not.

Read only

0 Likes
5,955

It's there in the system. Also, I've been using direct INSERT statement and it is working fine.

Thank you.

Read only

Former Member
0 Likes
5,955

There is no Problem in Given Code.

Check the Infotype onse for any syntax errors .and let me know for how many records you are updating

if you have large amount of data use FM HR_PSBUFFER_INITIALIZE to clear the Bufffer.

Regards,

Vamshi.

Read only

0 Likes
5,955

Thank you for your response.

I am only adding one record! and there are no syntax error!

Thank you.

Read only

0 Likes
5,955

Hi,

1) May be below code will give some clue, check the returns after each BAPI Call



    CALL FUNCTION 'HR_EMPLOYEE_ENQUEUE'
      EXPORTING
        number = pernr
      IMPORTING
        return = l_return.
    IF l_return-type = 'E'.
      Do error processing
    ELSE.
* update infotype
      CALL FUNCTION 'HR_INFOTYPE_OPERATION'
        EXPORTING
          infty         = '9310'
          number        = pernr
          validityend   = begda
          validitybegin = begda
          recordnumber  = seqnr
          record        = 
          operation     = 'INS'
          nocommit      = l_nocommit
        IMPORTING
          return        = l_t_return.
      READ TABLE l_t_return WITH KEY type = 'E'.
      IF sy-subrc = 0.
      ENDIF.
*Unlock the pernr
      CLEAR l_return.
      CALL FUNCTION 'HR_EMPLOYEE_DEQUEUE'
        EXPORTING
          number = pernr
        IMPORTING
          return = l_return.

      IF l_return-type = 'E'.
        Error Processing
      ENDIF.

2) Try updating the other PerNrs record as Pernr you are updating may have some data problem.

3) Finally try running the same in debugging mode if it gives some clue.

Let us know if nothing works or yu get some clue.

Regards

Shital

Read only

0 Likes
5,955

Thank you all for your help I really appreciate it.

Unfortunately, the problem is not resolved yet!

Here are my observation.


  wa_pa9057-pernr = p9057-pernr.
  wa_pa9057-subty = p9057-subty.
  wa_pa9057-objps = p9057-objps.
  wa_pa9057-sprps = p9057-sprps.
  wa_pa9057-endda = p9057-endda.
  wa_pa9057-begda = p9057-begda.
  wa_pa9057-uname = sy-uname.
  wa_pa9057-seqnr = p9057-seqnr.
  wa_pa9057-pry_post_trm = p9057-pry_post_trm.
  wa_pa9057-sev_bn = p9057-sev_bn.



  CASE sy-ucomm.
    WHEN 'SAVE'.

      DATA: uname2 LIKE pa9056-uname.

      SELECT SINGLE uname INTO uname2 FROM pa9056 WHERE objps = p9057-objps AND pernr = p9057-pernr.

      IF sy-subrc <> 0.
        MESSAGE e309(zhofs).

      ELSE.

        CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'
          EXPORTING
            number = p9057-pernr
          IMPORTING
            return = wf_bapireturn1.
        IF wf_bapireturn1 = 'E'.
          MESSAGE s001(zhofs).

        ELSE.

          CALL FUNCTION 'HR_INFOTYPE_OPERATION'
            EXPORTING
              infty         = '9057'
              number        = wa_pa9057-pernr
              validityend   = wa_pa9057-endda
              validitybegin = wa_pa9057-begda
              recordnumber  = wa_pa9057-seqnr
              record        = p9057
              operation     = 'INS'
              NOCOMMIT      = ' '
        importing
          RETURN        = wf_bapireturn1.

        ENDIF.

in this case the system hangs ! when I change record parameter to wa_pa9057 it gives me a run time error saying that source field is too short. However, I'm pretty sure that all key values of 9057 is included in my work area!

Thank you.

Read only

Former Member
0 Likes
5,955

Hi Jose,

Send the complete code, will check in the system.

Br/Manas

Read only

0 Likes
5,955

Thank you for your response!



*----------------------------------------------------------------------*
*  MODULE user_command_2010 INPUT
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
MODULE user_command_2010 INPUT.

  wa_pa9057-pernr = p9057-pernr.
  wa_pa9057-subty = p9057-subty.
  wa_pa9057-objps = p9057-objps.
  wa_pa9057-sprps = p9057-sprps.
  wa_pa9057-endda = p9057-endda.
  wa_pa9057-begda = p9057-begda.
  wa_pa9057-uname = sy-uname.
  wa_pa9057-seqnr = p9057-seqnr.
  wa_pa9057-pry_post_trm = p9057-pry_post_trm.
  wa_pa9057-sev_bn = p9057-sev_bn.

  CLEAR: loc_objps,loc_begda,loc_sev_bn,loc_pry_post_trm .

  loc_objps = p9057-objps.
  loc_begda = p9057-begda.
  loc_sev_bn = p9057-sev_bn.
  loc_pry_post_trm = p9057-pry_post_trm.


  CASE sy-ucomm.
    WHEN 'SAVE'.

      DATA: uname2 LIKE pa9056-uname.

      SELECT SINGLE uname INTO uname2 FROM pa9056 WHERE objps = p9057-objps AND pernr = p9057-pernr.

      IF sy-subrc <> 0.
        MESSAGE e309(zhofs).

      ELSE.

        CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'
          EXPORTING
            number = p9057-pernr
          IMPORTING
            return = wf_bapireturn1.
        IF wf_bapireturn1 = 'E'.
          MESSAGE s001(zhofs).

        ELSE.

          CALL FUNCTION 'HR_INFOTYPE_OPERATION'
            EXPORTING
              infty         = '9057'
              number        = wa_pa9057-pernr
              validityend   = wa_pa9057-endda
              validitybegin = wa_pa9057-begda
              recordnumber  = wa_pa9057-seqnr
              record        = p9057
              operation     = 'INS'
              NOCOMMIT      = ' '
        importing
          RETURN        = wf_bapireturn1.

        ENDIF.





        CALL FUNCTION 'BAPI_EMPLOYEE_DEQUEUE'
          EXPORTING
            number = p9057-pernr
          IMPORTING
            return = wf_bapireturn1.

        IF wf_bapireturn1-number = '0'.
          MESSAGE s308(zhofs).
          wf_en_dis = 1.
        ELSE.
          EXIT.
        ENDIF.

      ENDIF. " check OBJPS

*Write your Logic after saving the record**

    WHEN 'BACK'.
      LEAVE PROGRAM.
      CALL TRANSACTION 'PA30'.

    WHEN 'EXIT'.
      EXIT.

    WHEN 'CANCEL'.
      LEAVE PROGRAM.
    WHEN OTHERS.
  ENDCASE.


ENDMODULE. 

Read only

Former Member
0 Likes
5,955

Please let me know what u r trying to do and what are the type of the infotypes 9056 and 9057, I mean r they PA infotypes or PD infotypes?

Br/Manas

Read only

0 Likes
5,955

They are PA. I want to insert a record at 9057 but I have first to make sure that objps does exist in 9056 before saving. If doesn't exist then I have to throw an error message.

I hope that I'm clear. Please let me know if you want any clarifying.

Thank you.

Read only

Former Member
0 Likes
5,955

Hi,

Go through this piece of code.

It insert data into 0194 infotype successfully.

See if its of any help.

*&---------------------------------------------------------------------*
*&      Form  INSERT_0194
*&---------------------------------------------------------------------*
*       Inserting the infotype with corresponding records
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM INSERT_0194.

  CLEAR WA_0194.
  LOOP AT I_0194 INTO WA_0194.
*Necessary FM required to lock an employee before calling FM
*HR_INFOTYPE_OPERATION
    CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'
      EXPORTING
        NUMBER = WA_0194-PERNR
      IMPORTING
        RETURN = WA_RETURN.


    IF WA_RETURN IS NOT INITIAL.
          <Error Checking>
      CONTINUE.

    ELSE.

*Populating the new structure with the old values
      CLEAR WA_0194_NEW.
      WA_0194_NEW-PERNR = WA_0194-PERNR.
      WA_0194_NEW-BEGDA = WA_0194-BEGDA.
      WA_0194_NEW-ENDDA = WA_0194-ENDDA.
      WA_0194_NEW-GCASE = WA_0194-GCASE.
      WA_0194_NEW-GSTAT = WA_0194-GSTAT.
      WA_0194_NEW-RCVDD = WA_0194-RCVDD.
      WA_0194_NEW-RLSDD = WA_0194-RLSDD.
      WA_0194_NEW-GPRIO = WA_0194-GPRIO.
      WA_0194_NEW-ORIGN = WA_0194-ORIGN.
      WA_0194_NEW-GCATE = WA_0194-GCATE.
      WA_0194_NEW-FIPSC = WA_0194-FIPSC.
      WA_0194_NEW-MEDSU = WA_0194-MEDSU.
      WA_0194_NEW-LIFNR = WA_0194-LIFNR.
      WA_0194_NEW-ORCOD = WA_0194-ORCOD.
      WA_0194_NEW-ORNAM = WA_0194-ORNAM.
      WA_0194_NEW-ORSTR = WA_0194-ORSTR.
      WA_0194_NEW-ORORT = WA_0194-ORORT.
      WA_0194_NEW-ORPLZ = WA_0194-ORPLZ.
      WA_0194_NEW-ORREG = WA_0194-ORREG.
      WA_0194_NEW-PLAIN = WA_0194-PLAIN.
      WA_0194_NEW-SCHID = WA_0194-SCHID.
      WA_0194_NEW-RULNR = WA_0194-RULNR.
      WA_0194_NEW-ANSWR = WA_0194-ANSWR.
      WA_0194_NEW-LAPDY = WA_0194-LAPDY.
      WA_0194_NEW-SCRUL = WA_0194-SCRUL.
      WA_0194_NEW-LAPDT = WA_0194-LAPDT.



*Function Module to insert 0194 data
      CALL FUNCTION 'HR_INFOTYPE_OPERATION'
        EXPORTING
          INFTY                  = '0194'
          NUMBER                 = WA_0194-PERNR
*     SUBTYPE                =
*     OBJECTID               =
*     LOCKINDICATOR          =
*     VALIDITYEND            =
*     VALIDITYBEGIN          =
*     RECORDNUMBER           =
          RECORD                 = WA_0194_NEW
          OPERATION              = 'INS'
         TCLAS                  = 'A'
         DIALOG_MODE            = '0'
*     NOCOMMIT               =
*     VIEW_IDENTIFIER        =
*     SECONDARY_RECORD       =
       IMPORTING
         RETURN                 = WA_RETURN_OP
         KEY                    = KEY_INFO
                .

      COMMIT WORK.

*Success Error Summary
      CLEAR WA_ERROR.
      CLEAR WA_SUCCESS.
      IF WA_RETURN_OP IS NOT INITIAL.
          <Error Checking>
      ELSE.
          <Error Checking>
      ENDIF.

*FM to unlock an employee
      CALL FUNCTION 'BAPI_EMPLOYEE_DEQUEUE'
        EXPORTING
          NUMBER = WA_0194-PERNR
        IMPORTING
          RETURN = WA_RETURN.


      IF WA_RETURN-MESSAGE IS NOT INITIAL.
          <Error Checking>
      ENDIF.

  ENDLOOP.

ENDFORM.                    " INSERT_0194

And WA_0194_NEW is of type P0194 structure.

Regards.

Edited by: rajan roy on Apr 28, 2009 12:29 PM

Read only

0 Likes
5,955

Thank you very much for your effort. Unfortunately, the problem still stand!

All I need that I want to add only 1 record. for that reason I don't need loop at!

I copy/ paste your record. Then I modify it to help my purpose but the same problem happen. The system hangs 4 ever!

thank you again I really appreciate your help.

Read only

0 Likes
5,955

Try executing the code in Debug mode and check where it hangs...

Check if at all it is due to the FM HR_INFOTYPE_OPERATION as in my case it works fine, it must be due to some other reason.

Read only

0 Likes
5,955

In debug mode, I make sure that it hangs on HR_INFOTYPE_OPERATION.

when I went deep inside that function module I found that it hangs here i.e. like infinite loop. I don't have any clue!

 
  LOOP AT X031L_TAB.
        CLEAR: NAMETAB,
               DFIES.
        CALL 'C_DD_READ_FIELD'
             ID 'TYPE'      FIELD READTYPE
             ID 'TABNAME'   FIELD X031L_TAB-TABNAME
             ID 'FIELDNAME' FIELD X031L_TAB-FIELDNAME
             ID 'LANGUAGE'  FIELD LANGU.
        CASE SY-SUBRC.
          WHEN 0.
          WHEN 2.
            FIELDTEXT_NOT_FOUND = 'X'.
          WHEN OTHERS.
            RAISE INTERNAL_ERROR.
        ENDCASE.
*       DNTAB aus DFIES aufbauen.
        MOVE:  DFIES-TABNAME       TO NAMETAB-TABNAME,
               DFIES-FIELDNAME     TO NAMETAB-FIELDNAME,
               DFIES-LANGU         TO NAMETAB-LANGU,
               DFIES-POSITION      TO NAMETAB-POSITION,
               DFIES-OFFSET        TO NAMETAB-OFFSET,
               DFIES-KEYFLAG       TO NAMETAB-KEYFLAG,
               DFIES-FIELDTEXT     TO NAMETAB-FIELDTEXT,
               DFIES-DATATYPE      TO NAMETAB-DATATYPE,
               DFIES-INTTYPE       TO NAMETAB-INTTYPE,
               DFIES-LENG          TO NAMETAB-DDLEN,
               DFIES-INTLEN        TO NAMETAB-INTLEN,
               DFIES-DECIMALS      TO NAMETAB-DECIMALS,
               DFIES-CHECKTABLE    TO NAMETAB-CHECKTABLE,
               DFIES-REFTABLE      TO NAMETAB-REFTABLE,
               DFIES-REFFIELD      TO NAMETAB-REFFIELD,
               DFIES-PRECFIELD     TO NAMETAB-PRECFIELD,
               DFIES-LOGFLAG       TO NAMETAB-LOGFLAG,
               DFIES-MEMORYID      TO NAMETAB-MEMORYID,
               DFIES-LOWERCASE     TO NAMETAB-LOWERCASE,
               DFIES-SIGN          TO NAMETAB-SIGN,
               DFIES-VALEXI        TO NAMETAB-VALEXI,
               DFIES-NOFORKEY      TO NAMETAB-NOFORKEY,
               DFIES-CONVEXIT      TO NAMETAB-CONVEXIT.
        APPEND NAMETAB.
      ENDLOOP.

Read only

0 Likes
5,955

Hi,

While creating the infotype did you create the 'PS Structure'?

And the parameter you are passing in "record" in HR_INFOTYPE_OPERATION has to be a structure type and custom infotypes generally have reference structures starting with PSxxxx. Check these two things.

Regards.

Read only

Former Member
0 Likes
5,955

Hi,

I'm having the same problem on infotype 2002 insertion. The system loops in the code like an infinite loop.

How did you solve this issue ?

Thank you for your help,

Read only

0 Likes
5,955

Hi,

How have you declared your workarea?

Thanks,

Harini

Read only

0 Likes
5,955

Hi,

I'm just doing a program that load data, with this function module.

Do I have to declare the personal area in my input ?

DATA : ls_p2002 TYPE p2002,

ls_stb_line LIKE LINE OF lt_stb_table. " Internal Table

CLEAR ls_p2002.

ls_p2002-pernr = ls_stb_line-pernr.

ls_p2002-begda = ls_stb_line-stbdy.

ls_p2002-endda = ls_stb_line-stbdy.

ls_p2002-beguz = ls_stb_line-beguz.

ls_p2002-enduz = ls_stb_line-enduz.

ls_p2002-stdaz = ls_stb_line-durtn.

ls_p2002-versl = '7'.

ls_p2002-infty = '2002'.

ls_p2002-subty = '9509'.

ls_p2002-aedtm = sy-datum.

Thank you for your help,

Read only

Former Member
0 Likes
5,955

Hi Joes,

Can u try create a record manualy through PA30 if hang or not.