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

Problems copying infotypes using HR_INFOTYPE_OPERATION

Former Member
0 Likes
1,392

Hi guys.

I have implemented the following code in ZXPADU02 to create new instances of infotype 0002 and 0105-0010 when changing the userid on infotype 0105-0001.


CASE innnn-infty.

  WHEN '0105'.

    DATA: lt_p0002     TYPE TABLE OF p0002,
          ls_p0002     LIKE LINE OF lt_p0002,
          lt_p0002_ret TYPE p0002 OCCURS 0 WITH HEADER LINE,
          l_return     TYPE bapireturn1,
          l_uname      LIKE sy-uname,
          lt_p0105     TYPE TABLE OF p0105,
          ls_p0105     LIKE LINE OF lt_p0105,
          lt_p0105_ret TYPE p0105 OCCURS 0 WITH HEADER LINE,
          l_usrid_long LIKE p0105-usrid_long.

    IF sy-ucomm EQ 'UPD'
    AND innnn-data1(4) = '0001'.

      CONCATENATE innnn-data1+4(30) '@xxx.dk' INTO l_usrid_long.
      CONDENSE l_usrid_long NO-GAPS.
      TRANSLATE l_usrid_long TO UPPER CASE.

      CALL FUNCTION 'HR_READ_INFOTYPE'
        EXPORTING
          pernr     = innnn-pernr
          infty     = '0105'
          begda     = innnn-begda
          endda     = innnn-endda
        TABLES
          infty_tab = lt_p0105.

      LOOP AT lt_p0105 INTO ls_p0105 WHERE subty EQ '0010'.
        IF ls_p0105-usrid_long NE l_usrid_long.
          ls_p0105-usrid_long = l_usrid_long.
          lt_p0105_ret = ls_p0105.
          IF lt_p0105_ret-begda LT innnn-begda.
            lt_p0105_ret-begda = innnn-begda.
          ENDIF.
          IF lt_p0105_ret-endda GT innnn-endda.
            lt_p0105_ret-endda = innnn-endda.
          ENDIF.
          APPEND lt_p0105_ret.
        ENDIF.
      ENDLOOP.

      IF sy-subrc NE 0.
        lt_p0105_ret = innnn.
        lt_p0105_ret-subty = '0010'.
        lt_p0105_ret-usrty = '0010'.
        CLEAR lt_p0105_ret-usrid.
        lt_p0105_ret-usrid_long = l_usrid_long.
      ENDIF.

      CALL FUNCTION 'HR_INFOTYPE_OPERATION'
        EXPORTING
          infty     = '0105'
          number    = innnn-pernr
          subtype   = '0010'
          record    = lt_p0105_ret
          operation = 'COP'
        IMPORTING
          return    = l_return.

      CALL FUNCTION 'HR_READ_INFOTYPE'
        EXPORTING
          pernr     = innnn-pernr
          infty     = '0002'
          begda     = innnn-begda
          endda     = innnn-endda
        TABLES
          infty_tab = lt_p0002.

      LOOP AT lt_p0002 INTO ls_p0002.
        IF ls_p0002-inits NE innnn-data1+4(30).
          lt_p0002_ret = ls_p0002.
          IF lt_p0002_ret-begda LT innnn-begda.
            lt_p0002_ret-begda = innnn-begda.
          ENDIF.
          IF lt_p0002_ret-endda GT innnn-endda.
            lt_p0002_ret-endda = innnn-endda.
          ENDIF.
          lt_p0002_ret-inits = innnn-data1+4(30).
          APPEND lt_p0002_ret.
        ENDIF.
      ENDLOOP.

      CALL FUNCTION 'HR_INFOTYPE_OPERATION'
        EXPORTING
          infty     = '0002'
          number    = innnn-pernr
          record    = lt_p0002_ret
          operation = 'COP'
        IMPORTING
          return    = l_return.

      COMMIT WORK.

    ENDIF.

ENDCASE.

I expect that new records will be created when saving infotype 0105-0001, and at first glance it seems to work fine - I can see the new records. The problem is, that if I leave the transaction (PA30), and start it again, the new records are gone, and infotype 0002 and 0105-0001 looks exactly like they did before I saved 0105-0001.

Any thoughts?

Thanks in advance

Best Regards

Poul Steen Hansen, Denmark

Hi guys.

I have implemented the following code in ZXPADU02 to create new instances of infotype 0002 and 0105-0010 when changing the userid on infotype 0105-0001.


CASE innnn-infty.

  WHEN '0105'.

    DATA: lt_p0002     TYPE TABLE OF p0002,
          ls_p0002     LIKE LINE OF lt_p0002,
          lt_p0002_ret TYPE p0002 OCCURS 0 WITH HEADER LINE,
          l_return     TYPE bapireturn1,
          l_uname      LIKE sy-uname,
          lt_p0105     TYPE TABLE OF p0105,
          ls_p0105     LIKE LINE OF lt_p0105,
          lt_p0105_ret TYPE p0105 OCCURS 0 WITH HEADER LINE,
          l_usrid_long LIKE p0105-usrid_long.

    IF sy-ucomm EQ 'UPD'
    AND innnn-data1(4) = '0001'.

      CONCATENATE innnn-data1+4(30) '@xxx.dk' INTO l_usrid_long.
      CONDENSE l_usrid_long NO-GAPS.
      TRANSLATE l_usrid_long TO UPPER CASE.

      CALL FUNCTION 'HR_READ_INFOTYPE'
        EXPORTING
          pernr     = innnn-pernr
          infty     = '0105'
          begda     = innnn-begda
          endda     = innnn-endda
        TABLES
          infty_tab = lt_p0105.

      LOOP AT lt_p0105 INTO ls_p0105 WHERE subty EQ '0010'.
        IF ls_p0105-usrid_long NE l_usrid_long.
          ls_p0105-usrid_long = l_usrid_long.
          lt_p0105_ret = ls_p0105.
          IF lt_p0105_ret-begda LT innnn-begda.
            lt_p0105_ret-begda = innnn-begda.
          ENDIF.
          IF lt_p0105_ret-endda GT innnn-endda.
            lt_p0105_ret-endda = innnn-endda.
          ENDIF.
          APPEND lt_p0105_ret.
        ENDIF.
      ENDLOOP.

      IF sy-subrc NE 0.
        lt_p0105_ret = innnn.
        lt_p0105_ret-subty = '0010'.
        lt_p0105_ret-usrty = '0010'.
        CLEAR lt_p0105_ret-usrid.
        lt_p0105_ret-usrid_long = l_usrid_long.
      ENDIF.

      CALL FUNCTION 'HR_INFOTYPE_OPERATION'
        EXPORTING
          infty     = '0105'
          number    = innnn-pernr
          subtype   = '0010'
          record    = lt_p0105_ret
          operation = 'COP'
        IMPORTING
          return    = l_return.

      CALL FUNCTION 'HR_READ_INFOTYPE'
        EXPORTING
          pernr     = innnn-pernr
          infty     = '0002'
          begda     = innnn-begda
          endda     = innnn-endda
        TABLES
          infty_tab = lt_p0002.

      LOOP AT lt_p0002 INTO ls_p0002.
        IF ls_p0002-inits NE innnn-data1+4(30).
          lt_p0002_ret = ls_p0002.
          IF lt_p0002_ret-begda LT innnn-begda.
            lt_p0002_ret-begda = innnn-begda.
          ENDIF.
          IF lt_p0002_ret-endda GT innnn-endda.
            lt_p0002_ret-endda = innnn-endda.
          ENDIF.
          lt_p0002_ret-inits = innnn-data1+4(30).
          APPEND lt_p0002_ret.
        ENDIF.
      ENDLOOP.

      CALL FUNCTION 'HR_INFOTYPE_OPERATION'
        EXPORTING
          infty     = '0002'
          number    = innnn-pernr
          record    = lt_p0002_ret
          operation = 'COP'
        IMPORTING
          return    = l_return.

      COMMIT WORK.

    ENDIF.

ENDCASE.

I expect that new records will be created when saving infotype 0105-0001, and at first glance it seems to work fine - I can see the new records. The problem is, that if I leave the transaction (PA30), and start it again, the new records are gone, and infotype 0002 and 0105-0001 looks exactly like they did before I saved 0105-0001.

Any thoughts?

Thanks in advance

Best Regards

Poul Steen Hansen, Denmark

5 REPLIES 5
Read only

Former Member
0 Likes
977

hi,

please see the below forum. I'm sure this will help you.

regards,

shamim

Read only

0 Likes
977

When i follow the link, i get a thread about converting a SmartForm to SAP Script. I don't understand how that can help me with my problem?

Read only

0 Likes
977

Have you checked in SM21 and SM13 for any further info?

Read only

0 Likes
977

I think that may due to the COMMIT WORK conflict.. Place the code that creates the new records ina separate Report program & SUBMIT that from the User exit. This might isolate the 2 workprocesses & effect both the COMMITs.

~Suresh

Read only

0 Likes
977

I think you are right, but i have chosen another approach. I placed the code in a RFC enabled function module and called it with DESTINATION 'NONE' - Problem solved

Thanks for the input - it was a great help!

Chris: No entries in SM21 and SM13, but good thinking!

Best regards

Poul Steen Hansen, Denmark