(Glue-2202) Q: Can we remove leading zeroes from SAP when replicating data to Hadoop?

In some cases, it is confusing for users from SAP who are used to see e.g. customer numbers without leading zeros that suddenly the same codes have leading zeroes when exposed to Hadoop.

SNP Glue™ will out of the box replicate data from SAP tables as-is, I.e. in the same way as the data is stored on the SAP database. However, of course, such data can be changed using SNP Glue™ ETL functions.

For these leading zeros, there is currently no out-of-the-box solution. There is, of course, the option to create a piece of generic code for SNP Glue™ transformations, that will escape leading zeros for CHAR fields and NUMC fields. The following screenshot shows data from an SAP system on the left side, on the right side you can see HADOOP content with leading zeros with additional processing.

 The generic ABAP code for SNP Glue™ transformation rule to implement this scenario is this:

DATA: lv_index    TYPE int4 VALUE 1,
        lv_datatype TYPE c    LENGTH 10.

  STATICS: sv_not_required TYPE xfeld,
           st_indices      TYPE TABLE OF int4.

  FIELD-SYMBOLS: <lv_any> TYPE any.

  IF sv_not_required = 'X'.
    RETURN. "No NUMC or CHAR fields in whole structure, skip this whole part
  
ENDIF.

  " Find all NUMC and CHAR fields and remember indices, so performance is faster
  
IF st_indices IS INITIAL.
    DO.
      ASSIGN COMPONENT lv_index OF STRUCTURE is_record TO <lv_any>.
      IF sy-subrc <> 0.
        IF st_indices IS INITIAL.
          sv_not_required = 'X'. "No NUMC or CHAR fields in whole structure
        
ENDIF.
        EXIT.
      ELSE.
        DESCRIBE FIELD <lv_any> TYPE lv_datatype.
        IF lv_datatype = 'n' OR lv_datatype = 'N'
          OR lv_datatype = 'c' OR lv_datatype = 'C'.
          APPEND lv_index TO st_indices.
        ENDIF.
      ENDIF.
      ADD 1 TO lv_index.

    ENDDO.
  ENDIF.

  "Convert only specific fields based on data type
  
LOOP AT st_indices INTO lv_index.
    ASSIGN COMPONENT lv_index OF STRUCTURE is_record TO <lv_any>.
    IF sy-subrc = 0.
      CALL FUNCTION 'CONVERSION_EXIT_ALPHA_OUTPUT'
        EXPORTING
          input  = <lv_any>
        IMPORTING
          output = <lv_any>.
    ENDIF.
  ENDLOOP.


Insert this code into include and then place this include in a single routine in field mapping of the extractor. It will handle the conversion for each column in the single line, that is of type NUMC or CHAR.