IBM Sterling map editor: is there a way to sort OID in 204 EDI

124 views Asked by At

IBM Sterling map editor: is there a way to sort OID in 204 EDI I need some help/ideas on how to do this

This is the input file

ISA*...
GS*...
...
S5*2*CU*34140*L~
G62*68*20220531~
AT8*G*L*34140*4437~
PLD*27~
N1*ST*COSTCO STORE AAAA*93*0000000761~
N3*1013 HOMER STREET ~
N4*CITY*CA*90210~
OID*SO1241*135020070**PC*1*L*0~
L5**Certificate Of Sale~
AT8*G*L*0*1~
OID*SO1241*135020070**PC*24*L*0~
L5**AIRBAG~
AT8*G*L*0*24~
OID*SO1157*135020014**PC*1*L*0~
L5**Certificate Of Sale~
AT8*G*L*0*1~
OID*SO1241*135020070**PC*1080*L*30720~
L5**APPLES 2 lb~
AT8*G*L*30720*3840~
OID*SO1157*135020014**PC*1070*L*3420~
L5**ORANGES 12 oz~
AT8*G*L*3420*570~
OID*SO1241*135020070**PC*1*L*0~
L5**GPS TRACKER~
AT8*G*L*0*1~
L3*...
SE*...
GE*...
IEA*...

And this is the output file I want to get, EDI to POSITIONAL

HDR1: PO 135020070
ITEM: Certificate Of Sale,QTY 1
ITEM: AIRBAG,QTY 24
ITEM: APPLES 2 lb,QTY 1080
ITEM: GPS TRACKER,QTY 1
HDR1: PO 135020014
ITEM: Certificate Of Sale,QTY 1
ITEM: ORANGES 12 oz,QTY 1070

Currently this is what my MAP is doing

HDR1: PO 135020070
ITEM: Certificate Of Sale,QTY 1
ITEM: AIRBAG,QTY 24
HDR1: PO 135020014
ITEM: Certificate Of Sale,QTY 1
HDR1: PO 135020070
ITEM: APPLES 2 lb,QTY 1080
HDR1: PO 135020014
ITEM: ORANGES 12 oz,QTY 1070
HDR1: PO 135020070
ITEM: GPS TRACKER,QTY 1

This is my current code (extended rule on OID), that produce the map above

if sPONum = "" | (sPONum != "" & sPONum != #0324) then 
  begin
  
    //CREATE PO HEADER     
    sPONum = #0324;
    iCU = iCU + 1;
    $POGroup[iCU].#TEMP_DUNS = sDUNS;
    $POGroup[iCU].#PONumber = #0324;
  
    //CREATE ITEM LINE    
    //RESET ITEM LINE FOR EACH PO 
    iItem = 0;
    iItem = iItem + 1;
    iOID = iOID + 1;
    $TEMP_ITEM[iCU][iItem].#TEMP_Qty = #0380:4;
    $TEMP_ITEM[iCU][iItem].#TEMP_Description = $0320_L5[iS5][iOID][1].#0079:2;

  end
else 
  begin
    iItem = iItem + 1;
    iOID = iOID + 1;
    $TEMP_ITEM[iCU][iItem].#TEMP_Qty = #0380:4;
    $TEMP_ITEM[iCU][iItem].#TEMP_Description = $0320_L5[iS5][iOID][1].#0079:2;

  end

Any tips and pointers for master of map editor out there greatly appreciative of your help

Cheers

1

There are 1 answers

0
BobNoobGuy On

the spaghetti code that I come up with. I am sure there is a more efficient way. Anyone may suggest to make this more elegant.

It is not the best , but it work for my purpose. Thanks

  iOID = iOID + 1;  
  iFOUND = 0;
  iCount = 0;
  While iCount < iOID DO
  begin  
    iCount = iCount + 1;
    //PO HDR FOUND
    if $POGroup[iCount].#PONumber = #0324 & iFOUND = 0 then 
    begin
      iFOUND = iCount;
    end    
  end


  if iFOUND = 0 then 
  begin
    //CREATE PO HEADER
    iNewPO  = iNewPO  + 1;
    $POGroup[iNewPO].#PONumber = #0324;
    $POGroup[iNewPO].#TEMP_DUNS = sDUNS;
    $POGroup[iNewPO].#TEMP_PODt = sPODt;
    $POGroup[iNewPO].#STATUS_CODE = sStatusCode;
    $POGroup[iNewPO].#SCAC = sSCAC;
    $POGroup[iNewPO].#SID = sSID;
    $POGroup[iNewPO].#SONum = #0127:7;
    strdate($0300_S5[iS5].#0373:2,"%Y%m%d", $POGroup[iNewPO].#DeliveryDt);
    $TEMP_MESSAGE[iNewPO][1].#MSG = sShipType;
    
    //CREATE FIRST ITEM LINE    
    //RESET FLAT FILE ITEM LINE FOR EACH PO 
    iItem = 1;
    $TEMP_ITEM[iNewPO][iItem].#TEMP_Qty = #0380:4;
    $TEMP_ITEM[iNewPO][iItem].#TEMP_Description = $0320_L5[iS5][iOID][1].#0079:2;

    
  end
  else 
  begin 
    //FIND MAX ITEM LINE FOR FOUND PO INDEX
    iItmMax = 0;
    iCount = 0;
    While iCount < iOID DO
    begin  
      iCount = iCount + 1;
      //Loop to each item and find the max
      if $TEMP_ITEM[iFOUND][iCount].#TEMP_Qty != "" then iItmMax = iCount;
    end
    
    //SET THE MAX ITEM PLUS ONE
    iItem = iItmMax + 1;  
    
    //CREATE ITEM LINE
    $TEMP_ITEM[iFOUND][iItem].#TEMP_Qty = #0380:4;
    $TEMP_ITEM[iFOUND][iItem].#TEMP_Description = $0320_L5[iS5][iOID][1].#0079:2;
  
    
  end