Application Development 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: 

Error in inserting records into Infotype

Former Member
0 Kudos
164

Hi,

I have written a code as follows to insert a record in Infotype 9052.

But no insertion is made.

Can you point me where am wrong?

data : W_P9052 LIKE P9052.
W_P9052-PERNR = P9051-PERNR.
      W_P9052-BEGDA = P9051-ENDDA.
      W_P9052-ENDDA = '99991231'.
 
SELECT * FROM PA0008 INTO WA_PA0008 WHERE PERNR = P9051-PERNR.
      ENDSELECT.
 
      DO 40 TIMES.
        LV_VAR3 = LV_VAR3 + 1.
        CONCATENATE 'LGA' LV_VAR3 INTO LV_VAR1.
        CONCATENATE 'BET' LV_VAR3 INTO LV_VAR2.
        ASSIGN COMPONENT LV_VAR1 OF STRUCTURE WA_PA0008 TO <FS_DESCRIPTION>.
        ASSIGN COMPONENT LV_VAR2 OF STRUCTURE WA_PA0008 TO <FS_AMOUNT>.
 
        IF <FS_DESCRIPTION> IS ASSIGNED.
          IF <FS_AMOUNT> IS ASSIGNED.
            IF <FS_DESCRIPTION> EQ '0F02'.
              MOVE <FS_AMOUNT> TO W_P9052-ZPBMA.
            ELSEIF <FS_DESCRIPTION> EQ '0F03'.
              MOVE <FS_AMOUNT> TO W_P9052-ZPAMA.
            ELSEIF <FS_DESCRIPTION> EQ '0F04'.
              MOVE <FS_AMOUNT> TO W_P9052-ZPFIS.
            ELSEIF <FS_DESCRIPTION> EQ '0F07'.
              MOVE <FS_AMOUNT> TO W_P9052-ZPODA.
            ELSEIF <FS_DESCRIPTION> EQ '0F15' OR <FS_DESCRIPTION> EQ '0F16'.
              MOVE <FS_AMOUNT> TO W_P9052-ZPBMA.
            ELSEIF <FS_DESCRIPTION> EQ '0F18'.
              MOVE <FS_AMOUNT> TO W_P9052-ZPAMA.
            ELSEIF <FS_DESCRIPTION> EQ '0F10'.
              MOVE <FS_AMOUNT> TO W_P9052-ZPFIS.
            ENDIF.
            CLEAR WA_WAGETYPE.
          ENDIF.
        ENDIF.
      ENDDO.
 
 
      CALL FUNCTION 'HR_EMPLOYEE_ENQUEUE'
    EXPORTING
      number = w_P9052-PERNR.
 
 
      CALL FUNCTION 'HR_INFOTYPE_OPERATION'
        EXPORTING
          INFTY                  = '9052'
          NUMBER                 = w_P9052-PERNR
         VALIDITYEND            =  w_P9052-endda
         VALIDITYBEGIN          =  w_p9052-begda
          RECORD                 = W_P9052
          OPERATION              = 'INS'
   TCLAS                  = 'A'
   DIALOG_MODE            = '0'
*   NOCOMMIT               =
*   VIEW_IDENTIFIER        =
*   SECONDARY_RECORD       =
 IMPORTING
   RETURN                 = W_RETURN
*   KEY                    =
      .
 
      CALL FUNCTION 'HR_EMPLOYEE_DEQUEUE'
    EXPORTING
      number = w_P9052-PERNR.

.

TIA

1 ACCEPTED SOLUTION

Former Member
0 Kudos
70

Hello,

You need to read the info type before inserting/modifying the record.

Below code will help you.

LOOP AT t_insert INTO w_insert.

w_pernr = w_insert-ownnum.

CALL FUNCTION 'HR_READ_INFOTYPE'

EXPORTING

pernr = w_pernr

infty = c_infty "'0105'

TABLES

infty_tab = t_0105

EXCEPTIONS

infty_not_found = 1

OTHERS = 2.

READ TABLE t_0105 INTO w_0105 WITH KEY pernr = w_insert-ownnum"#EC *

subty = c_subu.

IF sy-subrc = 0.

MOVE w_0105 TO w_p0105.

w_p0105-usrid = w_insert-lanid.

CLEAR w_0105.

ELSE.

w_p0105-pernr = w_pernr.

w_p0105-usrid = w_insert-lanid.

w_p0105-begda = sy-datum.

w_fnr = 'X'.

ENDIF.

CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'

EXPORTING

number = w_pernr.

w_p0105-pernr = w_pernr.

IF w_fnr = 'X'.

CALL FUNCTION 'HR_INFOTYPE_OPERATION'

EXPORTING

infty = c_infty "'0105'

number = w_p0105-pernr

subtype = c_subu "'0001'

validityend = w_p0105-endda

validitybegin = w_p0105-begda

record = w_p0105

operation = c_oprn "'INS'

tclas = 'A'

dialog_mode = '0'

IMPORTING

return = w_return.

ELSE.

CALL FUNCTION 'HR_INFOTYPE_OPERATION'

EXPORTING

infty = c_infty "'0105'

number = w_p0105-pernr

subtype = c_subu "'0001'

validityend = w_p0105-endda

validitybegin = w_p0105-begda

record = w_p0105

operation = 'MOD' "'MOD'

tclas = 'A'

dialog_mode = '0'

IMPORTING

return = w_return.

ENDIF.

CLEAR w_fnr.

CALL FUNCTION 'BAPI_EMPLOYEE_DEQUEUE'

EXPORTING

number = w_pernr.

Endloop.

Hope it helps.

Thanks,

Jayant

3 REPLIES 3

Former Member
0 Kudos
71

Hello,

You need to read the info type before inserting/modifying the record.

Below code will help you.

LOOP AT t_insert INTO w_insert.

w_pernr = w_insert-ownnum.

CALL FUNCTION 'HR_READ_INFOTYPE'

EXPORTING

pernr = w_pernr

infty = c_infty "'0105'

TABLES

infty_tab = t_0105

EXCEPTIONS

infty_not_found = 1

OTHERS = 2.

READ TABLE t_0105 INTO w_0105 WITH KEY pernr = w_insert-ownnum"#EC *

subty = c_subu.

IF sy-subrc = 0.

MOVE w_0105 TO w_p0105.

w_p0105-usrid = w_insert-lanid.

CLEAR w_0105.

ELSE.

w_p0105-pernr = w_pernr.

w_p0105-usrid = w_insert-lanid.

w_p0105-begda = sy-datum.

w_fnr = 'X'.

ENDIF.

CALL FUNCTION 'BAPI_EMPLOYEE_ENQUEUE'

EXPORTING

number = w_pernr.

w_p0105-pernr = w_pernr.

IF w_fnr = 'X'.

CALL FUNCTION 'HR_INFOTYPE_OPERATION'

EXPORTING

infty = c_infty "'0105'

number = w_p0105-pernr

subtype = c_subu "'0001'

validityend = w_p0105-endda

validitybegin = w_p0105-begda

record = w_p0105

operation = c_oprn "'INS'

tclas = 'A'

dialog_mode = '0'

IMPORTING

return = w_return.

ELSE.

CALL FUNCTION 'HR_INFOTYPE_OPERATION'

EXPORTING

infty = c_infty "'0105'

number = w_p0105-pernr

subtype = c_subu "'0001'

validityend = w_p0105-endda

validitybegin = w_p0105-begda

record = w_p0105

operation = 'MOD' "'MOD'

tclas = 'A'

dialog_mode = '0'

IMPORTING

return = w_return.

ENDIF.

CLEAR w_fnr.

CALL FUNCTION 'BAPI_EMPLOYEE_DEQUEUE'

EXPORTING

number = w_pernr.

Endloop.

Hope it helps.

Thanks,

Jayant

Former Member
0 Kudos
70

Also,

In FM HR_INFOTYPE_OPERATION you can change the value of paramter DAILOG_MODE to '2' and see in the Info type entry screen what actually is causing the error.

Thanks,

Jayant

0 Kudos
70

Hi Jayant,

Thanx for ur reply. I set dialog mode as 2. In PAI of 9051 the 1st chain wherein the values get assigned to field is running properly.

there is a 2nd chain wherein the values are actually pushed to the database pa9052. That chain is not run. Hence no insertion is made i guess. Can u help me with any solution. As of the code i've written, there are no entries in 9052 n does it still require that i need to read the infotype b4 making entries?

TIA

Jayant it'd be of gr8 help if ucan give me the declarations of the variables used in ur code so that i can make a cross check.

Edited by: SAKKTHISS KUMAAR on Nov 28, 2008 12:17 PM

Please note that am doing this insert via actions in PA40.

Edited by: SAKKTHISS KUMAAR on Nov 28, 2008 12:47 PM