{"id":2144,"date":"2019-02-27T04:38:43","date_gmt":"2019-02-27T04:38:43","guid":{"rendered":"https:\/\/www.se80.co.uk\/training-education\/?p=2144"},"modified":"2019-02-28T00:55:36","modified_gmt":"2019-02-28T00:55:36","slug":"create-hr-infotype-record","status":"publish","type":"post","link":"https:\/\/www.se80.co.uk\/training-education\/create-hr-infotype-record\/","title":{"rendered":"Create new HR Infotype record ABAP Code"},"content":{"rendered":"<p>Example ABAP HR report to create HR infotype record using SAP function module HR_INFOTYPE_OPERATION. In this example, I will demonstrate creating a new 0105 record by selecting an existing one from the SAP database and updating it&#8217;s from and to date. Although the 0105 infotype is being used the code will be similar for almost all other HR infotype updates.\n<\/p>\n<pre>\r\n*&-------------------------------*\r\nREPORT ZUPD_INFOTYPE.\r\n\r\nPARAMETERS: p_itype type PRELP-INFTY DEFAULT '0105',\r\n            p_pernr type pernr-pernr default '1'.\r\n\r\n*Change P0105 to the structure of the infotype you want to update\r\n*Structure can be built dynamically but this wouldn't add any value to\r\n*this example just over complicate it\r\nDATA: ld_record type p0105,\r\n      ld_table  type string.\r\n\r\ndata: return_struct   type BAPIRETURN1,\r\n      personaldatakey type BAPIPAKEY.\r\n\r\n*---------------------------------\r\nSTART-OF-SELECTION.\r\n\r\n  data : it_tabdescr type abap_compdescr_tab,\r\n         wa_tabdescr type abap_compdescr.\r\n  data : ref_table_descr type ref to cl_abap_structdescr.\r\n\r\n  CONCATENATE 'PA' p_itype into ld_table.\r\n  SELECT single *\r\n    from (ld_table)\r\n    into CORRESPONDING FIELDS OF ld_record\r\n   where pernr eq p_pernr\r\n     and USRTY eq 'MAIL'. \"Only relevant for infotype 0105\r\n\r\n* Change values within record you want to create\r\n*  clear: ld_record-???,\r\n*         ld_record-???,\r\n*         ld_record-???.\r\n*  ld_record-??? =\r\n*  ld_record-??? =\r\n\r\n  ld_record-endda = '99991231'.\r\n  ld_record-begda = sy-datum.\r\n\r\n* HR_INFOTYPE_OPERATION will fail if the record is not locked\r\nCALL FUNCTION 'HR_EMPLOYEE_ENQUEUE'\r\n    EXPORTING\r\n      number = p_pernr.\r\n\r\nCALL FUNCTION 'HR_INFOTYPE_OPERATION'\r\n    EXPORTING\r\n      infty         = p_itype\r\n      subtype       = ld_record-subty\r\n      number        = ld_record-pernr     \"employeenumber\r\n      validityend   = ld_record-endda\r\n      validitybegin = ld_record-begda\r\n      record        = ld_record\r\n      operation     = 'INS'\r\n      nocommit      = ' '\r\n      dialog_mode   = '0'\r\n    IMPORTING\r\n      return        = return_struct\r\n      key           = personaldatakey\r\n    EXCEPTIONS\r\n      OTHERS        = 0.\r\n\r\n\r\n* Release lock for the record after the update is completed\r\nCALL FUNCTION 'HR_EMPLOYEE_DEQUEUE'\r\n    EXPORTING\r\n      number = p_pernr.\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Example ABAP HR report to create HR infotype record using SAP function module HR_INFOTYPE_OPERATION. In this example, I will demonstrate creating a new 0105 record by selecting an existing one from the SAP database and updating it&#8217;s from and to date. Although the 0105 infotype is being used the code will be similar for almost [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2150,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[58,12],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Create HR Infotype record using ABAP HR_INFOTYPE_OPERATION<\/title>\n<meta name=\"description\" content=\"Create new HR Infotype record using ABAP fucntion module HR_INFOTYPE_OPERATION, selects an existing record, copies it and changes the dates\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.se80.co.uk\/training-education\/create-hr-infotype-record\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Create HR Infotype record using ABAP HR_INFOTYPE_OPERATION\" \/>\n<meta property=\"og:description\" content=\"Create new HR Infotype record using ABAP fucntion module HR_INFOTYPE_OPERATION, selects an existing record, copies it and changes the dates\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.se80.co.uk\/training-education\/create-hr-infotype-record\/\" \/>\n<meta property=\"og:site_name\" content=\"SAP Help, Training and Education\" \/>\n<meta property=\"article:published_time\" content=\"2019-02-27T04:38:43+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-02-28T00:55:36+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.se80.co.uk\/training-education\/wp-content\/uploads\/2019\/02\/create-HR-Infotype-record.png\" \/>\n\t<meta property=\"og:image:width\" content=\"287\" \/>\n\t<meta property=\"og:image:height\" content=\"316\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"se80\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"se80\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.se80.co.uk\/training-education\/create-hr-infotype-record\/\",\"url\":\"https:\/\/www.se80.co.uk\/training-education\/create-hr-infotype-record\/\",\"name\":\"Create HR Infotype record using ABAP HR_INFOTYPE_OPERATION\",\"isPartOf\":{\"@id\":\"https:\/\/www.se80.co.uk\/training-education\/#website\"},\"datePublished\":\"2019-02-27T04:38:43+00:00\",\"dateModified\":\"2019-02-28T00:55:36+00:00\",\"author\":{\"@id\":\"https:\/\/www.se80.co.uk\/training-education\/#\/schema\/person\/ddc6a049c1b0790f62d70278be75e511\"},\"description\":\"Create new HR Infotype record using ABAP fucntion module HR_INFOTYPE_OPERATION, selects an existing record, copies it and changes the dates\",\"breadcrumb\":{\"@id\":\"https:\/\/www.se80.co.uk\/training-education\/create-hr-infotype-record\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.se80.co.uk\/training-education\/create-hr-infotype-record\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.se80.co.uk\/training-education\/create-hr-infotype-record\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.se80.co.uk\/training-education\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Create new HR Infotype record ABAP Code\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.se80.co.uk\/training-education\/#website\",\"url\":\"https:\/\/www.se80.co.uk\/training-education\/\",\"name\":\"SAP Help, Training and Education\",\"description\":\"Learn SAP\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.se80.co.uk\/training-education\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.se80.co.uk\/training-education\/#\/schema\/person\/ddc6a049c1b0790f62d70278be75e511\",\"name\":\"se80\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.se80.co.uk\/training-education\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/3fd4e388f05bf3c763e46cd1f77afeb2?s=96&d=retro&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/3fd4e388f05bf3c763e46cd1f77afeb2?s=96&d=retro&r=g\",\"caption\":\"se80\"},\"url\":\"https:\/\/www.se80.co.uk\/training-education\/author\/se80\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Create HR Infotype record using ABAP HR_INFOTYPE_OPERATION","description":"Create new HR Infotype record using ABAP fucntion module HR_INFOTYPE_OPERATION, selects an existing record, copies it and changes the dates","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.se80.co.uk\/training-education\/create-hr-infotype-record\/","og_locale":"en_US","og_type":"article","og_title":"Create HR Infotype record using ABAP HR_INFOTYPE_OPERATION","og_description":"Create new HR Infotype record using ABAP fucntion module HR_INFOTYPE_OPERATION, selects an existing record, copies it and changes the dates","og_url":"https:\/\/www.se80.co.uk\/training-education\/create-hr-infotype-record\/","og_site_name":"SAP Help, Training and Education","article_published_time":"2019-02-27T04:38:43+00:00","article_modified_time":"2019-02-28T00:55:36+00:00","og_image":[{"width":287,"height":316,"url":"https:\/\/www.se80.co.uk\/training-education\/wp-content\/uploads\/2019\/02\/create-HR-Infotype-record.png","type":"image\/png"}],"author":"se80","twitter_card":"summary_large_image","twitter_misc":{"Written by":"se80","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.se80.co.uk\/training-education\/create-hr-infotype-record\/","url":"https:\/\/www.se80.co.uk\/training-education\/create-hr-infotype-record\/","name":"Create HR Infotype record using ABAP HR_INFOTYPE_OPERATION","isPartOf":{"@id":"https:\/\/www.se80.co.uk\/training-education\/#website"},"datePublished":"2019-02-27T04:38:43+00:00","dateModified":"2019-02-28T00:55:36+00:00","author":{"@id":"https:\/\/www.se80.co.uk\/training-education\/#\/schema\/person\/ddc6a049c1b0790f62d70278be75e511"},"description":"Create new HR Infotype record using ABAP fucntion module HR_INFOTYPE_OPERATION, selects an existing record, copies it and changes the dates","breadcrumb":{"@id":"https:\/\/www.se80.co.uk\/training-education\/create-hr-infotype-record\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.se80.co.uk\/training-education\/create-hr-infotype-record\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.se80.co.uk\/training-education\/create-hr-infotype-record\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.se80.co.uk\/training-education\/"},{"@type":"ListItem","position":2,"name":"Create new HR Infotype record ABAP Code"}]},{"@type":"WebSite","@id":"https:\/\/www.se80.co.uk\/training-education\/#website","url":"https:\/\/www.se80.co.uk\/training-education\/","name":"SAP Help, Training and Education","description":"Learn SAP","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.se80.co.uk\/training-education\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.se80.co.uk\/training-education\/#\/schema\/person\/ddc6a049c1b0790f62d70278be75e511","name":"se80","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.se80.co.uk\/training-education\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/3fd4e388f05bf3c763e46cd1f77afeb2?s=96&d=retro&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3fd4e388f05bf3c763e46cd1f77afeb2?s=96&d=retro&r=g","caption":"se80"},"url":"https:\/\/www.se80.co.uk\/training-education\/author\/se80\/"}]}},"jetpack_featured_media_url":"https:\/\/www.se80.co.uk\/training-education\/wp-content\/uploads\/2019\/02\/create-HR-Infotype-record.png","_links":{"self":[{"href":"https:\/\/www.se80.co.uk\/training-education\/wp-json\/wp\/v2\/posts\/2144"}],"collection":[{"href":"https:\/\/www.se80.co.uk\/training-education\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.se80.co.uk\/training-education\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.se80.co.uk\/training-education\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.se80.co.uk\/training-education\/wp-json\/wp\/v2\/comments?post=2144"}],"version-history":[{"count":6,"href":"https:\/\/www.se80.co.uk\/training-education\/wp-json\/wp\/v2\/posts\/2144\/revisions"}],"predecessor-version":[{"id":2168,"href":"https:\/\/www.se80.co.uk\/training-education\/wp-json\/wp\/v2\/posts\/2144\/revisions\/2168"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.se80.co.uk\/training-education\/wp-json\/wp\/v2\/media\/2150"}],"wp:attachment":[{"href":"https:\/\/www.se80.co.uk\/training-education\/wp-json\/wp\/v2\/media?parent=2144"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.se80.co.uk\/training-education\/wp-json\/wp\/v2\/categories?post=2144"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.se80.co.uk\/training-education\/wp-json\/wp\/v2\/tags?post=2144"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}