<p>There is a number of infotypes in SAP which are local to some country. SAP doesn&#8217;t provide any standard solution to send these country-specific or custom infotypes over ALE, cause standard IDOC contains only international infotypes. If you develop your infotype and want to send it over <a href="https://saphcmsolutions.com/how-sap-ale-works/" target="_blank" rel="noopener">ALE</a> there are some tips and tricks to handle. Today I want to tell you how to send custom infotype or country-specific infotype over SAP ALE. It&#8217;s going to be a long tutorial with a lot of images. More than I&#8217;d like to show you what is a short and long infotype record in terms of SAP integration and IDOC structure. And, of course, ABAP source codes will be provided for your convenience. Take a cup of coffee and join me with this unique tutorial never been shared before.</p>
<h3>Sending short infotypes over SAP ALE</h3>
<p>A short infotype is an infotype, the size of which fits into one IDOC segment. How to check? Open SE11 transaction, find an infotype structure which is PXXXX (XXXX &#8211; infotype code), sum all length fields. One IDOC segment can store 1000 symbols. If the infotype structure is longer than 1000 symbols it&#8217;s a long infotype and we will need to split it to send over SAP ALE. Will show later how it works.</p>
<p>To add custom infotype to a standard HRMD_A IDOC in <strong>WE31</strong> transaction create a new segment to include it into IDOC and send over ALE. Naming rule is <strong>Z1PXXXX</strong>, 7 symbols. It&#8217;s done for prior 4.6C compatibility, so if you work with modern systems you can use longer names. The first three letters &#8216;Z1P&#8217; is a must. To save time and avoid human mistakes typing all SE11 fields into segment manually you can create a segment from a template. In menu Segment ->; Create with template choose DDIC structure and type in PXXXX, where XXXX is your infotype code. When you save segment systems checks its length to comply with <strong>1000 IDOC segment length</strong>.</p>
<p>In my scenario, I&#8217;ll use country-specific infotype 0293. Here is how it looks like in segment.</p>
<div id="attachment_3190" style="width: 641px" class="wp-caption alignnone"><a href="https://saphr.ru/wp-content/uploads/ale_293_01.png"><img aria-describedby="caption-attachment-3190" class="wp-image-3190 size-full" src="https://saphr.ru/wp-content/uploads/ale_293_01.png" alt="New IDOC segment" width="631" height="743" /></a><p id="caption-attachment-3190" class="wp-caption-text">New IDOC segment</p></div>
<p> ;</p>
<p>Don&#8217;t forget to release the segment in Edit menu.</p>
<p><!--more--></p>
<p>For this tutorial, I&#8217;ve set ALE integration within one SAP instance. It means sender and receiver both in the same system on the same server. So all settings are distributed across both sender and receiver clients. If you send data outside of one server you need to perform some settings on receiving system.</p>
<p>I both systems we need to specify IDOC segment in <strong>T777D</strong> view like in a picture below.</p>
<p><a href="https://saphr.ru/wp-content/uploads/ale_293_02.png"><img class="alignnone size-full wp-image-3191" src="https://saphr.ru/wp-content/uploads/ale_293_02.png" alt="" width="561" height="357" /></a></p>
<p>In both systems in <strong>WE30</strong> create IDOC extension for basic type HRMD_A.</p>
<p><a href="https://saphr.ru/wp-content/uploads/ale_293_03.png"><img class="alignnone size-full wp-image-3192" src="https://saphr.ru/wp-content/uploads/ale_293_03.png" alt="" width="577" height="277" /></a></p>
<p>Add our new segment to IDOC structure. Adding this will say ALE infrastructure to send not basic HRMD_A IDOC but use your custom infotype segment on top of standard IDOC.</p>
<p><a href="https://saphr.ru/wp-content/uploads/ale_293_04.png"><img class="alignnone size-full wp-image-3193" src="https://saphr.ru/wp-content/uploads/ale_293_04.png" alt="" width="787" height="278" /></a></p>
<p>Half the job done. Release this extension in Edit menu.</p>
<p>In <strong>WE82</strong> add our extension to message type HRMD_A so the system will use it instead of standard IDOC.</p>
<p><a href="https://saphr.ru/wp-content/uploads/ale_293_05.png"><img class="alignnone size-full wp-image-3194" src="https://saphr.ru/wp-content/uploads/ale_293_05.png" alt="" width="571" height="492" /></a></p>
<p>Change partner profile to send an extended version of HRMD_A IDOC. It could be done in <strong>WE20</strong> or BD64 transaction.</p>
<p><a href="https://saphr.ru/wp-content/uploads/ale_293_06.png"><img class="alignnone size-full wp-image-3195" src="https://saphr.ru/wp-content/uploads/ale_293_06.png" alt="" width="646" height="632" /></a></p>
<p>Let&#8217;s test. Open <strong>PFAL</strong> and send your personnel number. We can see our segment filled out with data correctly.</p>
<p><a href="https://saphr.ru/wp-content/uploads/ale_293_07.png"><img class="alignnone size-full wp-image-3196" src="https://saphr.ru/wp-content/uploads/ale_293_07.png" alt="" width="1024" height="741" /></a></p>
<p>You&#8217;re done and can send almost any hr infotype in ALE distribution model. Almost any because a lot of infotypes and specifically custom infotypes are not that long to use long infotype ALE distribution solution.</p>
<h3>Sending long infotype over ALE</h3>
<p>It&#8217;s a little more complicated. Overall we can send custom infotype over ALE with the length no more than 3000 symbols. We remember one segment is 1000 long, so we need to split our infotype into three chunks. The solution is simple. We need to have something unique in each segment to be able to build infotype back after we&#8217;ve split it. Best practice is to include a well-known <strong>PSKEY</strong> structure as a key field into each segment. It would allow us to split infotype without any data loss and build it again in receiving system. Very easy! Like a blockchain in SAP HR :) Once receiving system gets this IDOC it reads all segments with the same key and recovers the whole picture.</p>
<p>For this example, I&#8217;ll take a long infotype which is almost 1600 symbols long. We&#8217;ll use two segments. The first segment is Z1PA0294 and second is Z1PB0294.</p>
<p><a href="https://saphr.ru/wp-content/uploads/ale_294_01.png"><img class="alignnone size-full wp-image-3198" src="https://saphr.ru/wp-content/uploads/ale_294_01.png" alt="" width="682" height="744" /></a></p>
<p><a href="https://saphr.ru/wp-content/uploads/ale_294_02.png"><img class="alignnone size-full wp-image-3199" src="https://saphr.ru/wp-content/uploads/ale_294_02.png" alt="" width="628" height="745" /></a></p>
<p>To connect two segments we make them dependable on each other. The first segment is a parent, second is a child.</p>
<p><a href="https://saphr.ru/wp-content/uploads/ale_294_03.png"><img class="alignnone size-full wp-image-3200" src="https://saphr.ru/wp-content/uploads/ale_294_03.png" alt="" width="713" height="200" /></a></p>
<p>Don&#8217;t forget to say system we have a couple of segments in our infotype. In <strong>T777D</strong> fill second segment field with our data.</p>
<p><a href="https://saphr.ru/wp-content/uploads/ale_294_04.png"><img class="alignnone size-full wp-image-3202" src="https://saphr.ru/wp-content/uploads/ale_294_04.png" alt="" width="638" height="351" /></a></p>
<p>Run <strong>PFAL</strong> and here is what we see. Child segment is empty. What&#8217;s wrong?</p>
<p><a href="https://saphr.ru/wp-content/uploads/ale_294_05.png"><img class="alignnone size-full wp-image-3203" src="https://saphr.ru/wp-content/uploads/ale_294_05.png" alt="" width="1007" height="476" /></a></p>
<p>Here is a trick. SAP doesn&#8217;t know how we want to fill our segments. In case one segment it&#8217;s very simple &#8211; the system just copies data with <strong>move-corresponding ABAP statement</strong>. We need to help SAP to fill this data. Create a project in <strong>CMOD</strong> with this <strong>RHALE001</strong> enhancement.</p>
<p><a href="https://saphr.ru/wp-content/uploads/ale_294_06.png"><img class="alignnone size-full wp-image-3204" src="https://saphr.ru/wp-content/uploads/ale_294_06.png" alt="" width="600" height="209" /></a></p>
<p>Inside activate two components. One to split infotype into chunks and second to glue chunks into one whole piece.</p>
<p>EXIT_SAPLRHAL_003 &#8211; split<br />
EXIT_SAPLRHAL_004 &#8211; glue</p>
<p>I&#8217;ve written two functional modules to do data conversion. Sources provided at the end of this article.</p>
<p>ZCONVERT_P0294_TO_Z1PA0294<br />
ZCONVERT_Z1PA0294_TO_P0294</p>
<p>By the name you can guess that one converts the infotype into a segment, the second is the reverse. Pay attention both FMs refers to the first, parent segment, not both.</p>
<p>Activate functional modules, activate CMOD project and run PFAL. You&#8217;ll see the child segment filled with data.</p>
<p>In case you need to do some data conversion you can do it inside these functional modules or use standard solution which I described in another post: <a href="https://saphcmsolutions.com/data-conversion-sap-ale/" target="_blank" rel="noopener">Data conversion in SAP ALE</a></p>
<p><strong style="color: #ff9900;">Share this post with your SAP friends and colleagues. It won&#8217;t cost you anything but will motivate us to write more interesting content.</strong><br />
<!-- Begin MailChimp Signup Form --></p>
<style type="text/css">
	#mc_embed_signup{background:#fff; clear:left; font:14px Helvetica,Arial,sans-serif; width:100%;}<br />
	/* Add your own MailChimp form style overrides in your site stylesheet or in this style block.<br />
	 We recommend moving this block and the preceding CSS link to the HEAD of your HTML file. */<br />
</style>
<div id="mc_embed_signup">
<form id="mc-embedded-subscribe-form" class="validate" action="https://saphcmsolutions.us3.list-manage.com/subscribe/post?u=9946caca159afc9a77502e9a5&;id=ba2e54e4b1" method="post" name="mc-embedded-subscribe-form" novalidate="" target="_blank">
<div id="mc_embed_signup_scroll"><label for="mce-EMAIL">Stay tuned with our best practices and top-notch advices</label><br />
<input id="mce-EMAIL" class="email" name="EMAIL" required="" type="email" value="" placeholder="email address" /><br />
<!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups--></p>
<div style="position: absolute; left: -5000px;" aria-hidden="true"><input tabindex="-1" name="b_9946caca159afc9a77502e9a5_ba2e54e4b1" type="text" value="" /></div>
<div class="clear"><input id="mc-embedded-subscribe" class="button" name="subscribe" type="submit" value="Subscribe" /></div>
</div>
</form>
</div>
<p><!--End mc_embed_signup--></p>
<pre class="lang:abap decode:true" title="ZXHALU04">*&;---------------------------------------------------------------------* 
*&; Include ZXHALU04 
*&;---------------------------------------------------------------------* 
CONSTANTS: c_0294(4) TYPE c VALUE '0294'. 
IF INFTY_NAME = c_0294. 
 CALL FUNCTION 'ZCONVERT_P0294_TO_Z1PA0294' 
 EXPORTING 
 pnnnn_data = pnnnn_data 
 IMPORTING 
 converted = converted 
 subrc = subrc 
 TABLES 
 error_tab = error_message 
 CHANGING 
 sdata_data = sdata_data 
 EXCEPTIONS 
 OTHERS = 0. 
ENDIF.</pre>
<pre class="lang:abap decode:true " title="ZXHALU05">*&;---------------------------------------------------------------------* 
*&; Include ZXHALU05 
*&;---------------------------------------------------------------------* 
CONSTANTS: c_0294(4) TYPE c VALUE '0294'. 
IF INFTY_NAME = c_0294. 
 
 CALL FUNCTION 'ZCONVERT_Z1PA0294_TO_P0294' 
 EXPORTING 
 SDATA_DATA = sdata_data 
 IMPORTING 
 PNNNN_DATA = pnnnn_data 
 CONVERTED = converted 
 SUBRC = subrc 
 TABLES 
 ERROR_TAB = error_message 
 . 
 
ENDIF.</pre>
<p> ;</p>
<pre class="lang:abap decode:true " title="FUNCTION ZCONVERT_P0294_TO_Z1PA0294.">FUNCTION ZCONVERT_P0294_TO_Z1PA0294. 
*"---------------------------------------------------------------------- 
*"*"Local Interface: 
*" IMPORTING 
*" VALUE(PNNNN_DATA) 
*" EXPORTING 
*" VALUE(CONVERTED) TYPE C 
*" VALUE(SUBRC) LIKE SY-SUBRC 
*" TABLES 
*" ERROR_TAB STRUCTURE HRALE_ERR 
*" CHANGING 
*" VALUE(SDATA_DATA) 
*"---------------------------------------------------------------------- 
 
 DATA: BEGIN OF sdata_long, 
 sdata LIKE edidd-sdata, 
 sdata2 LIKE edidd-sdata, 
 sdata3 LIKE edidd-sdata, 
 END OF sdata_long. 
 
 DATA: i0294 LIKE p0294. "workarea for infotype 
 DATA: z1pa0294 LIKE z1pa0294. "workarea for segmenttype 
 DATA: z1pb0294 LIKE z1pb0294. "workarea for segmenttype 
 
 DATA: act_subrc LIKE sy-subrc. 
 
 FIELD-SYMBOLS: <;wplog>; TYPE ANY. 
 
 CLEAR subrc. 
 
* fill workarea for infotype with infotype-data 
 ASSIGN pnnnn_data TO <;wplog>; CASTING TYPE p0294. 
 i0294 = <;wplog>;. 
 
 sdata_long = sdata_data. 
 ASSIGN sdata_long-sdata TO <;wplog>; CASTING TYPE z1pa0294. 
 z1pa0294 = <;wplog>;. 
 ASSIGN sdata_long-sdata2 TO <;wplog>; CASTING TYPE z1pb0294. 
 z1pb0294 = <;wplog>;. 
 
* move fields 
 MOVE-CORRESPONDING i0294 TO z1pa0294. 
 MOVE-CORRESPONDING i0294 TO z1pb0294. 
 
* fill IDoc-data with workarea for segmenttype 
 IF subrc = 0. 
 assign sdata_long-sdata to <;wplog>; casting type z1pa0294. 
 <;wplog>; = z1pa0294. 
 assign sdata_long-sdata2 to <;wplog>; casting type z1pb0294. 
 <;wplog>; = z1pb0294. 
 
 sdata_data = sdata_long. 
 ENDIF. 
 
* set or initialize conversion flag 
 converted = 'X'. 
 
ENDFUNCTION.</pre>
<pre class="lang:abap decode:true " title="FUNCTION ZCONVERT_Z1PA0294_TO_P0294.">FUNCTION ZCONVERT_Z1PA0294_TO_P0294. 
*"-------------------------------------------------------------------- 
*"*"Local Interface: 
*" IMPORTING 
*" VALUE(SDATA_DATA) 
*" EXPORTING 
*" VALUE(PNNNN_DATA) 
*" VALUE(CONVERTED) TYPE C 
*" VALUE(SUBRC) LIKE SY-SUBRC 
*" TABLES 
*" ERROR_TAB STRUCTURE HRALE_ERR 
*"-------------------------------------------------------------------- 
 
 DATA: BEGIN OF sdata_long, 
 sdata LIKE edidd-sdata, 
 sdata2 LIKE edidd-sdata, 
 sdata3 LIKE edidd-sdata, 
 END OF sdata_long. 
 
 DATA: i0294 LIKE p0294. "workarea for infotype 
 DATA: z1pa0294 LIKE z1pa0294. "workarea for segmenttype 
 DATA: z1pb0294 LIKE z1pb0294. "workarea for segmenttype 
 
 
 DATA: act_subrc LIKE sy-subrc. 
 
 FIELD-SYMBOLS: <;wplog>; TYPE ANY. 
 
 CLEAR subrc. 
 
* fill workarea for segmenttype with IDoc-data 
 sdata_long = sdata_data. 
 ASSIGN sdata_long-sdata TO <;wplog>; CASTING TYPE z1pa0294. 
 z1pa0294 = <;wplog>;. 
 ASSIGN sdata_long-sdata2 TO <;wplog>; CASTING TYPE z1pb0294. 
 z1pb0294 = <;wplog>;. 
 
 
* move fields 
 MOVE-CORRESPONDING z1pa0294 TO i0294. 
 MOVE-CORRESPONDING z1pb0294 TO i0294. 
 
* fill infotype-data with workarea for infotype 
 IF subrc = 0. 
 ASSIGN pnnnn_data TO <;wplog>; CASTING TYPE p0294. 
 <;wplog>; = i0294. 
 ENDIF. 
 
* set or initialize conversion flag 
 converted = 'X'. 
 
ENDFUNCTION.</pre>