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
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
thank you for the logic i need some scenerios can you provide and i have a doubt on the readblock and writeblock can you explain those things
ReplyDelete