B2B Integration

 View Only

Using ITX to ensure input data is 7bit ASCII

  • 1.  Using ITX to ensure input data is 7bit ASCII

    IBM Champion
    Posted Thu October 08, 2020 07:56 AM
      |   view attached
    A client asked me how to ensure data was 7bit ASCII.  I created a map (attached) that reads input a byte at a time, and uses the following component rule to fail the input if any of those bytes has a HEX value greater than 127:

    TOBASETEN(STREAMTOHEXTEXT($),16)<128

    Now there are two ways to use this map. You can use it as a pre-processor map, to check an entire file, example:

    <?xml version="1.0" encoding="us-ascii"?>
    <Root xmlns="http://www.example.org/Test" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.example.org/Test
    Input.xsd">
    <Data>This is  sentence.</Data>
    </Root>

    ...would fail validation with Check7bit.mmc, and the trace would say:

    (Level 1: Offset 8, len 1, comp 1 of 1, #9, DI 00000000000A:)
    Data at offset 8 ('Â') failed COMPONENT RULE test
    for component number 1, TYPE X'0002' (File root).

    Or, you could use it inside a map that is already reading the XML, as you are mapping the input to output, by sending the data to a RUN() function:

    =VALID(RUN("Check7Bit.mmc",ECHOIN(1,SomeValue:From:In1)+" -OE1"),FAIL("Value input is higher HEX value than 127!!!"))

    See XML read example.

    For large inputs, byte-by-byte validation may not be very efficient.  Can you think of another way to do the same in ITX?

    ------------------------------
    Paul Brett
     
    IBM Sterling Transformation Extender (ITX) Client Support
    ------------------------------

    #B2BIntegration
    #SupplyChain

    Attachment(s)

    zip
    AsciiExtended.zip   12 KB 1 version