SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Insert Infotype data with Maintain Text



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> HR
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Wed Sep 05, 2007 12:50 pm    Post subject: Insert Infotype data with Maintain Text Reply with quote

Author: Jatra Riwayanto

Description:
A simple code that will insert infotype data and Maintain Text data.
For the sample I use infotype 2002 (Attendances).

Type and Data declaration:

Code:

TYPES BEGIN OF text_version.
TYPES   nummer TYPE x.
TYPES END OF text_version.

DATA: PERSONALDATAKEY    LIKE BAPIPAKEY.
DATA: RETURN       LIKE BAPIRETURN1.
DATA: P2002       LIKE P2002.
DATA: PSKEY       TYPE PSKEY.
DATA: IT_TEXT       TYPE HRPAD_TEXT_TAB .
DATA: LINE       TYPE HRPAD_TEXT.
DATA: version       TYPE text_version.
DATA: pcl1       TYPE pcl1.Input Parameters:

PARAMETERS:  PERNR  LIKE PA2002-PERNR  DEFAULT '1004511',
             AWART  LIKE PA2002-AWART  DEFAULT 'LW',
             BEGDA  LIKE PA2002-BEGDA  DEFAULT SY-DATUM,
             ENDDA  LIKE PA2002-ENDDA  DEFAULT SY-DATUM,
             BEGUZ  LIKE PA2002-BEGUZ,
             ENDUZ  LIKE PA2002-ENDUZ.


Lock Personnel Number:
Code:

START-OF-SELECTION.

  CALL FUNCTION 'HR_EMPLOYEE_ENQUEUE'
        EXPORTING
          number = PERNR
        IMPORTING
          RETURN = RETURN.

  IF RETURN-NUMBER IS NOT INITIAL.
    EXIT.
  ENDIF.


Insert infotype data:
Code:

* ADD DATA
  CLEAR: P2002.
  P2002-PERNR = PERNR.
  P2002-SUBTY = AWART.
  P2002-ENDDA = BEGDA.
  P2002-BEGDA = BEGDA.
  P2002-BEGUZ = BEGUZ.
  P2002-ENDUZ = ENDUZ.
  P2002-AWART = AWART.
  P2002-ITXEX = 'X'.

* WRITE DATA
  CLEAR: RETURN, PERSONALDATAKEY.
  CALL FUNCTION 'HR_INFOTYPE_OPERATION'
         EXPORTING
              INFTY          = '2002'
              NUMBER         = PERNR
              SUBTYPE        = AWART
              VALIDITYEND    = BEGDA
              VALIDITYBEGIN  = BEGDA
              RECORD         = P2002
              OPERATION      = 'INS'
              NOCOMMIT       = ''
              TCLAS          = 'A'
         IMPORTING
              RETURN         = RETURN
              KEY            = PERSONALDATAKEY
         EXCEPTIONS
              OTHERS         = 0.

  IF RETURN-NUMBER IS INITIAL.
    COMMIT WORK AND WAIT.
  ELSE.
    ROLLBACK WORK.
    EXIT.
  ENDIF.


Insert Maintain Text data:
Code:

* ADD DATA
  CLEAR: PSKEY, IT_TEXT[].
  pskey-pernr = PERNR.
  pskey-infty = '2002'.
  pskey-subty = AWART.
  pskey-endda = BEGDA.
  pskey-begda = ENDDA.
  pskey-seqnr = PERSONALDATAKEY-RECORDNR.
  version-nummer = '02'.

  pcl1-histo = 'X'.
  pcl1-uname = SY-UNAME.
  pcl1-aedtm = SY-DATUM.


* ADD IT_TEXT DATA
  CLEAR: LINE.
  LINE = 'Sample text:'.
  APPEND LINE TO IT_TEXT.

  CLEAR: LINE.
  LINE = 'Here you can store your information.'.
  APPEND LINE TO IT_TEXT.

  EXPORT
    text-version FROM version
    ptext        FROM IT_TEXT
  TO DATABASE pcl1(TX) ID pskey
    FROM pcl1.


Unlock Personnel Number:
Code:

CALL FUNCTION 'HR_EMPLOYEE_DEQUEUE'
      EXPORTING
        number = PERNR
      IMPORTING
        RETURN = RETURN.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> HR All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.