Program To Mass Update Infotype 0006

How To Mass Update Infotype 0006?

Was trying to update infotype 0006.

I have tried the things in following way using 'HR_INFOTYPE_OPERATION' function.

CALL FUNCTION 'HR_INFOTYPE_OPERATION'
    EXPORTING
      INFTY                       = '0006'
      NUMBER                   =  PERNR
      SUBTYPE                  =  '1'
      VALIDITYEND           = IT_PA0006-ENDDA
      VALIDITYBEGIN        = IT_PA0006-BEGDA
      RECORD                   = ls_p0006
      OPERATION              = 'CHANGE'•
     TCLAS                      = 'A'
      nocommit      = ''
      dialog_mode   = '0'

    IMPORTING
      RETURN                   = RETURN.

Function was executed successfully but there was no updates found in the record.

Answer:

The following is a sample program to Upload Address data into infotype 0006.

REPORT  zhr_upload_infotype_0006.

*----------------------------------------------------------------------*
* Description      : Upload program for Address data
*----------------------------------------------------------------------*

TABLES:pernr.

TYPES: BEGIN OF ty_data,
                data(300) TYPE c,
             END   OF ty_data.

TYPES: 
    BEGIN OF ty_pernr,
        pernr TYPE char8,
        subty type char4,
        begda TYPE char8,
        endda TYPE char8,
        aedtm TYPE char8,
        uname TYPE char10,
        ANSSA TYPE char4,
        NAME2 TYPE char40,
        STRAS(60) TYPE c ,
        ORT01 TYPE char40,
        ORT02 TYPE char40,
        PSTLZ type char10,
        LAND1 TYPE char3,
     END  OF ty_pernr.

TYPES: BEGIN OF ty_proposed_values.
         INCLUDE STRUCTURE pprop.
TYPES: END OF ty_proposed_values.

TYPES: BEGIN OF ty_modified_keys.
         INCLUDE STRUCTURE pskey.
TYPES: END OF ty_modified_keys.

DATA: it_data              TYPE TABLE OF ty_data            WITH HEADER LINE,
       it_pernr             TYPE TABLE OF ty_pernr           WITH HEADER LINE,
       it_proposed_values   TYPE TABLE OF ty_proposed_values WITH HEADER LINE,
       it_modified_keys     TYPE TABLE OF ty_modified_keys   WITH HEADER LINE,
       wa_fval              LIKE pprop-fval,
       wa_bapiret           LIKE bapireturn,
       wa_bapiret1          LIKE bapireturn1.

DATA: L_PERNR  LIKE  PSPAR-PERNR.

PARAMETERS: p_file TYPE string.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
   PERFORM f4_file_name.

START-OF-SELECTION.

  CALL FUNCTION 'GUI_UPLOAD'
     EXPORTING
       filename                      = p_file
     TABLES
       data_tab                      =     it_data .

END-OF-SELECTION.

  LOOP AT it_data .

     SPLIT  it_data AT ','  INTO
        it_pernr-pernr
        it_pernr-subty
        it_pernr-begda
        it_pernr-endda
        it_pernr-aedtm
        it_pernr-uname
        it_pernr-ANSSA
        it_pernr-NAME2
        it_pernr-STRAS
        it_pernr-ORT01
        it_pernr-ORT02
        it_pernr-PSTLZ
        it_pernr-LAND1  .

    it_pernr-aedtm = sy-datum.
     it_pernr-uname = sy-uname.

     APPEND it_pernr.

   ENDLOOP.

  LOOP AT it_pernr.

    it_proposed_values-infty = '0006'.
     it_proposed_values-fname = 'P0006-PERNR'.
     it_proposed_values-fval  = it_pernr-pernr.
     it_proposed_values-seqnr = '01'.

     APPEND it_proposed_values.

    it_proposed_values-infty = '0006'.
     it_proposed_values-fname = 'P0006-SUBTY'.
     it_proposed_values-fval  = it_pernr-subty.
     it_proposed_values-seqnr = '01' .

     APPEND it_proposed_values.

    it_proposed_values-infty = '0006'.
     it_proposed_values-fname = 'P0006-BEGDA'.
     it_proposed_values-fval  = it_pernr-begda.
     it_proposed_values-seqnr = '01'.

     APPEND it_proposed_values.

    it_proposed_values-infty = '0006'.
     it_proposed_values-fname = 'P0006-ENDDA'.
     it_proposed_values-fval  = it_pernr-endda.
     it_proposed_values-seqnr = '01'.

     APPEND it_proposed_values.

    it_proposed_values-infty = '0006'.
     it_proposed_values-fname = 'P0006-AEDTM'.
     it_proposed_values-fval  = it_pernr-aedtm.
     it_proposed_values-seqnr = '01'   .

     APPEND it_proposed_values.

    it_proposed_values-infty = '0006'.
     it_proposed_values-fname = 'P0006-UNAME'.
     it_proposed_values-fval  = it_pernr-uname.
     it_proposed_values-seqnr = '01'.

     APPEND it_proposed_values.

     it_proposed_values-infty = '0006'.
     it_proposed_values-fname = 'P0006-ANSSA'.
     it_proposed_values-fval  = it_pernr-ANSSA.
     it_proposed_values-seqnr = '01' .

     APPEND it_proposed_values.

    it_proposed_values-infty = '0006'.
     it_proposed_values-fname = 'P0006-NAME2'.
     it_proposed_values-fval  = it_pernr-NAME2.
     it_proposed_values-seqnr = '01'.

     APPEND it_proposed_values.

    it_proposed_values-infty = '0006'.
     it_proposed_values-fname = 'P0006-STRAS'.
     it_proposed_values-fval  = it_pernr-STRAS.
     it_proposed_values-seqnr = '01'.

     APPEND it_proposed_values.

    it_proposed_values-infty = '0006'.
     it_proposed_values-fname = 'P0006-ORT01'.
     it_proposed_values-fval  = it_pernr-ORT01.
     it_proposed_values-seqnr = '01'.

     APPEND it_proposed_values.

    it_proposed_values-infty = '0006'.
     it_proposed_values-fname = 'P0006-ORT02'.
     it_proposed_values-fval  = it_pernr-ORT02.
     it_proposed_values-seqnr = '01'.

     APPEND it_proposed_values.

    it_proposed_values-infty = '0006'.
     it_proposed_values-fname = 'P0006-PSTLZ'.
     it_proposed_values-fval  = it_pernr-pstlz.
     it_proposed_values-seqnr = '01'.

     APPEND it_proposed_values.

    it_proposed_values-infty = '0006'.
     it_proposed_values-fname = 'P0006-LAND1'.
     it_proposed_values-fval  = it_pernr-LAND1.
     it_proposed_values-seqnr = '01'.

     APPEND it_proposed_values.

  L_PERNR = it_pernr-pernr.

    CALL FUNCTION 'HR_MAINTAIN_MASTERDATA'
       EXPORTING
         pernr           = L_pernr
         actio           = 'INS'
         tclas           = 'A'
         BEGDA           = SY-DATUM
         ENDDA           = '99991231'
         DIALOG_MODE     = '0'
         NO_EXISTENCE_CHECK = 'X'

       IMPORTING
         return          = wa_bapiret
         return1         = wa_bapiret1

       TABLES
         proposed_values = it_proposed_values
         modified_keys   = it_modified_keys.

  ENDLOOP.

*&---------------------------------------------------------------------*
*&      Form  F4_FILE_NAME
*----------------------------------------------------------------------*

FORM f4_file_name .

*-- F4 functionality for file name on Presentation Server

   DATA: l_file TYPE string.

   CALL METHOD cl_salv_test_data=>select_file

     IMPORTING
       filename = l_file.
       p_file = l_file.

ENDFORM.                    " F4_FILE_NAME

**************************************************************************************

Notes:

Here is the file format is as below and you need to save it in  .txt file format.

00000003,1,20100101,99991231,20100101,John,1,c/0 John,city,city,city,535579,gb

Take note that this is for the single subtype only.

ABAP Tips

See Also
Working Days Between Dates Using HR Calendar

Get help for your ABAP problems
Do you have a ABAP Question?

ABAP Books
ABAP Certification, BAPI, Java, Web Programming, Smart Forms, Sapscripts Reference Books

More ABAP Tips

Main Index
SAP ERP Modules, Basis, ABAP and Other IMG Stuff

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.  The site www.erpgreat.com is in no way affiliated with SAP AG. 
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk. 
 The content on this site may not be reproduced or redistributed without the express written permission of 
www.erpgreat.com or the content authors.