Wednesday, August 28, 2019

Update Cust group and segments

static void Update_CustGroup(Args _args)
{
  CustGroup                 _custGroup;
  CustTable                 _custTable;
  smmBusRelSegmentGroup     _segmentGroup;
  smmBusRelSubSegmentGroup  _subSegmentGroup;
   

    ttsBegin;
   select forUpdate _custGroup
     where _custGroup.dataAreaId == 'gh'
     && _custGroup.CustGroup == 'HOR-HO-HPB';
    {
        _custGroup.CustGroup ='HOR-HO-HRB';
        _custGroup.update();
         info(' custgroup updated done');
    }
     
   select forUpdate _subSegmentGroup
       where _subSegmentGroup.dataAreaId == 'gh'
       && _subSegmentGroup.SubsegmentId == 'HPB';
    {
        _subSegmentGroup.SubsegmentId           = 'HRB';
        _subSegmentGroup.SubSegmentDescription  = 'CAFES & BAKE SHOPS';
        _subSegmentGroup.update();
       
        info('subsegment updated done');
    }
   
    while select forUpdate _custTable
        where _custTable.dataAreaId == 'gh'
        && _custTable.CustGroup     == 'HOR-HO-HPB'
        && _custTable.SegmentId     == 'HO'
        && _custTable.SubsegmentId  == 'HPB'
        && _custTable.AccountNum    != ''
    {
        _custTable.CustGroup    ='HOR-HO-HRB';
        _custTable.SubsegmentId = 'HRB';
        _custTable.doUpdate();
        info('All customers are updated with cust group');
    }
   
   ttsCommit;
   
   
   
}

No comments:

Post a Comment