Site icon SAP Human Resources Experts And Solutions

How to send custom infotype over SAP ALE

There is a number of infotypes in SAP which are local to some country. SAP doesn’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 ALE 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’s going to be a long tutorial with a lot of images. More than I’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.

Sending short infotypes over SAP ALE

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 – infotype code), sum all length fields. One IDOC segment can store 1000 symbols. If the infotype structure is longer than 1000 symbols it’s a long infotype and we will need to split it to send over SAP ALE. Will show later how it works.

To add custom infotype to a standard HRMD_A IDOC in WE31 transaction create a new segment to include it into IDOC and send over ALE. Naming rule is Z1PXXXX, 7 symbols. It’s done for prior 4.6C compatibility, so if you work with modern systems you can use longer names. The first three letters ‘Z1P’ 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 1000 IDOC segment length.

In my scenario, I’ll use country-specific infotype 0293. Here is how it looks like in segment.

New IDOC segment

 

Don’t forget to release the segment in Edit menu.

For this tutorial, I’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.

I both systems we need to specify IDOC segment in T777D view like in a picture below.

In both systems in WE30 create IDOC extension for basic type HRMD_A.

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.

Half the job done. Release this extension in Edit menu.

In WE82 add our extension to message type HRMD_A so the system will use it instead of standard IDOC.

Change partner profile to send an extended version of HRMD_A IDOC. It could be done in WE20 or BD64 transaction.

Let’s test. Open PFAL and send your personnel number. We can see our segment filled out with data correctly.

You’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.

Sending long infotype over ALE

It’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’ve split it. Best practice is to include a well-known PSKEY 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.

For this example, I’ll take a long infotype which is almost 1600 symbols long. We’ll use two segments. The first segment is Z1PA0294 and second is Z1PB0294.

To connect two segments we make them dependable on each other. The first segment is a parent, second is a child.

Don’t forget to say system we have a couple of segments in our infotype. In T777D fill second segment field with our data.

Run PFAL and here is what we see. Child segment is empty. What’s wrong?

Here is a trick. SAP doesn’t know how we want to fill our segments. In case one segment it’s very simple – the system just copies data with move-corresponding ABAP statement. We need to help SAP to fill this data. Create a project in CMOD with this RHALE001 enhancement.

Inside activate two components. One to split infotype into chunks and second to glue chunks into one whole piece.

EXIT_SAPLRHAL_003 – split
EXIT_SAPLRHAL_004 – glue

I’ve written two functional modules to do data conversion. Sources provided at the end of this article.

ZCONVERT_P0294_TO_Z1PA0294
ZCONVERT_Z1PA0294_TO_P0294

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.

Activate functional modules, activate CMOD project and run PFAL. You’ll see the child segment filled with data.

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: Data conversion in SAP ALE

Share this post with your SAP friends and colleagues. It won’t cost you anything but will motivate us to write more interesting content.



*&---------------------------------------------------------------------*
*&  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.
*&---------------------------------------------------------------------*
*&  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.

 

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.
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.
Exit mobile version