Wednesday, 14 November 2018

Replacing Extended ASCII codes in a string using replaceAll in Sterling Integrator

ob_SpecCharRepl = new("java.lang.String",#NAME1:5);
#NAME1:5 = ob_SpecCharRepl.replaceAll("[^^\a-zA-Z0-9]" , "");

Input:
Thè quïck brøwn føx jumps over the lãzy dôg.

Output:
Th quck brwn fx jumps over the lzy dg.

Wednesday, 23 May 2018

Name that changes according to loop index using Xpath

xpath is

//*[local-name()=string(concat("DOC-SPLIT-",//counter/text()))]/SenderIDQual/text()

WHILE IN STERLING INTEGRATOR SAMPLE REQUIREMENT

sku is 10 digit number and upc is 11 digit number.
If first 10 digits of upc number match with sku send both values to output.

For example,

If we have input file like this,

9056396207,90563962602
9056396208,90563962613
9056396209,9056396209
9056396260,90563962083
9056396261,90563962071


Output file should be like this
9056396207,90563962071
9056396208,90563962083
9056396209,9056396209
9056396260,90563962602
9056396261,90563962613

integer sku_length,CNT_TEMP,FLAG;
integer i,j;
String[60] VAR_SKU;

i=1;


SORT($rec,#sku,#upc);

FLAG = 0;

CNT_TEMP = 1;
WHILE i <= count($rec[*]) do
begin

    FLAG = 0;

    VAR_SKU = $rec[i].#sku;
    sku_length=len($rec[i].#sku);

    j=1;
    WHILE j <= count($rec[*]) do
    begin
        if VAR_SKU=LEFT($rec[j].#upc,sku_length) then
        begin
               
            $TEMP_REC[CNT_TEMP].#temp_sku=VAR_SKU;
            $TEMP_REC[CNT_TEMP].#temp_upc=$rec[j].#upc;

            FLAG = 1;

        CNT_TEMP = CNT_TEMP + 1;
        break;
        end
    j=j+1;
    end

    IF FLAG = 0 THEN
    BEGIN
        $TEMP_REC[CNT_TEMP].#temp_sku=VAR_SKU;

    CNT_TEMP = CNT_TEMP + 1;
    END
i=i+1;
end