check code tmrw.

{"sourcingDeliveries":{"sourcingDelivery":[{"cargoVolume":"","cargoVolumeUom":"","cargoWeight":"","cargoWeightUom":"","containerId":"","currentStatus":"","currentStatusDate":"","distance":"","distanceUom":"","freightOrderDescription":"","freightOrderType":"PROCURE","freightOrderID":"","meanOfTransport":"","sealNumber":"","shippingInstructions":"","shippingStrategy":"","sourcingDeliveryId":"53270","standardCarrierAlphaCode":"","totalTravellingTime":"","unitTravellingTime":"","carrier":{"city":"","country":"","globalLocationNumber":"","houseNumber":"","location":"","name1":"","name2":"","phone":"","poBox":"","postalCode":"","state":"","street1":"","street2":""},"stages":{"stage":[{"arrivalDateTime":"","carrierId":"","departureDateTime":"","distance":"","distanceUom":"","number":"1","standardCarrierAlphaCode":"","totalTravellingTime":"","unitTravellingTime":"","destination":{"city":"","country":"","globalLocationNumber":"","houseNumber":"","location":"","name1":"","name2":"","phone":"","poBox":"","postalCode":"","state":"","street1":"","street2":""},"source":{"city":"","country":"","globalLocationNumber":"","houseNumber":"","location":"","name1":"","name2":"","phone":"","poBox":"","postalCode":"","state":"","street1":"","street2":""},"stageDeliveries":{"stageDelivery":[{"sequenceNumber":"1","sourcingDeliveryId":"53270"}]}}]},"sourcingDeliveries":{"sourcingDelivery":[{"actualGoodsIssueDate":"","billOfLading":"","commentText":"","companyCode":"","customerDeliveryAppointment":"","distributionChannel":"","division":"","documentDate":"","documentReference":"","goodsReceiptStatus":"","goodsReceiptStatusText":"","grossWeight":"","incotermPart1":"","incotermPart2":"","meanOfTransport":"","palletBase":"","palletSpace":"","pickingInstructionText":"","plannedDeliveryDate":"","plannedGoodsIssueDate":"","plannedLoadingDate":"","plannedMatAvailabilityDate":"","postingDate":"","sourceType":"Vendor","destinationType":"Plant","priority":"","purchasingGroup":"","purchasingOrganization":"","putawayStatus":"","putawayStatusText":"","requestedDeliveryDate":"2024-03-08T00:00:00UTC+00:00","salesOrganisation":"","shippingInstructionText":"","shippingStrategy":"","sourcingDeliveryId":"53270","sourcingDeliveryType":"SOURCING","specialProcessIndicator":"","specialProcessIndicatorText":"","transportationPlanningDate":"","volume":"","volumeUom":"","warehouseNumber":"","weightUom":"","soldToParty":{"city":"","country":"","globalLocationNumber":"","houseNumber":"","location":"","name1":"","name2":"","phone":"","poBox":"","postalCode":"","state":"","street1":"","street2":""},"source":{"location":"IC14683","name1":"RC BRUCK FACTORY","name2":"","houseNumber":"","street1":"Industriestrasse 20","street2":"Adress2","postalCode":"2460","poBox":"","city":"Bruck/Leitha","state":"","country":"AT","phone":"","globalLocationNumber":"9011100000006"},"billToParty":{"city":"","country":"","globalLocationNumber":"","houseNumber":"","location":"","name1":"","name2":"","phone":"","poBox":"","postalCode":"","state":"","street1":"","street2":""},"carrier":{"location":"","name1":"","name2":"","houseNumber":"","street1":"","street2":"","postalCode":"","poBox":"","city":"","state":"","country":"","phone":"","globalLocationNumber":""},"destination":{"location":"RFR_MAIN","name1":"","name2":"","houseNumber":"","street1":"","street2":"","postalCode":"","poBox":"","city":"","state":"","country":"","phone":"","globalLocationNumber":"4006561000073"},"items":{"item":[{"baseUom":"","batch":"406F2BRK05","bestBeforeDate":"2026-02-10T00:00:00UTC+00:00","conversionFactorToBuom":"3456","customerMaterialReference":"","customerPurchaseOrderDate":"","customerPurchaseOrderNumber":"","eanOrUpcReference":"","endProductionDate":"2024-02-10T00:00:00UTC+00:00","externalHU2":"","goodsReceiptQuantityInBuom":"","goodsReceiptQuantityInSuom":"","grossWeight":"","higherItemPosition":"","itemCategory":"","itemPosition":"1","lotNumber":"","materialDescription":"Renal Rind Cat 85g","materialReference":"4026","materialType":"","packagingMaterial":"","parentSsccs":{"parentSscc":[{"localPalletId":"","parentHUNumber":"","parentHuPickedQuantity":""}]},"plannedReceiptQuantityInBuom":"3456.00","plannedReceiptQuantityInSuom":"1.00","plant":"RFR_MAIN","positiveRelease":"Y","positiveReleaseDate":"2024-02-15T00:00:00UTC+00:00","preceedingDocumentCategory":"","preceedingDocumentNumber":"","preceedingDocumentPosition":"","preceedingDocumentType":"","preceedingDocumentTypeDesc":"","productionDate":"2024-02-10T00:00:00UTC+00:00","qualityStatus":"","shipToPurchaseOrderNumber":"","ssccNumber":"390111004018314187","startProductionDate":"2024-02-10T00:00:00UTC+00:00","stockType":"","storageLocation":"","transportationGroup":"","uomCode":"PF","vendorBatch":"","volume":"","volumeUom":"","weightUom":"","wmsQualityStatus":"OK"},{"baseUom":"","batch":"406F2BRK05","bestBeforeDate":"2026-02-10T00:00:00UTC+00:00","conversionFactorToBuom":"3456","customerMaterialReference":"","customerPurchaseOrderDate":"","customerPurchaseOrderNumber":"","eanOrUpcReference":"","endProductionDate":"2024-02-10T00:00:00UTC+00:00","externalHU2":"","goodsReceiptQuantityInBuom":"","goodsReceiptQuantityInSuom":"","grossWeight":"","higherItemPosition":"","itemCategory":"","itemPosition":"2","lotNumber":"","materialDescription":"Renal Rind Cat 85g","materialReference":"4026","materialType":"","packagingMaterial":"","parentSsccs":{"parentSscc":[{"localPalletId":"","parentHUNumber":"","parentHuPickedQuantity":""}]},"plannedReceiptQuantityInBuom":"3456.00","plannedReceiptQuantityInSuom":"1.00","plant":"RFR_MAIN","positiveRelease":"Y","positiveReleaseDate":"2024-02-15T00:00:00UTC+00:00","preceedingDocumentCategory":"","preceedingDocumentNumber":"","preceedingDocumentPosition":"","preceedingDocumentType":"","preceedingDocumentTypeDesc":"","productionDate":"2024-02-10T00:00:00UTC+00:00","qualityStatus":"","shipToPurchaseOrderNumber":"","ssccNumber":"390111004018314194","startProductionDate":"2024-02-10T00:00:00UTC+00:00","stockType":"","storageLocation":"","transportationGroup":"","uomCode":"PF","vendorBatch":"","volume":"","volumeUom":"","weightUom":"","wmsQualityStatus":"OK"},{"baseUom":"","batch":"408E2BRK04","bestBeforeDate":"2026-02-23T00:00:00UTC+00:00","conversionFactorToBuom":"3456","customerMaterialReference":"","customerPurchaseOrderDate":"","customerPurchaseOrderNumber":"","eanOrUpcReference":"","endProductionDate":"2024-02-23T00:00:00UTC+00:00","externalHU2":"","goodsReceiptQuantityInBuom":"","goodsReceiptQuantityInSuom":"","grossWeight":"","higherItemPosition":"","itemCategory":"","itemPosition":"3","lotNumber":"","materialDescription":"Renal Dog 100g","materialReference":"4031","materialType":"","packagingMaterial":"","parentSsccs":{"parentSscc":[{"localPalletId":"","parentHUNumber":"","parentHuPickedQuantity":""}]},"plannedReceiptQuantityInBuom":"3456.00","plannedReceiptQuantityInSuom":"1.00","plant":"RFR_MAIN","positiveRelease":"Y","positiveReleaseDate":"2024-02-28T00:00:00UTC+00:00","preceedingDocumentCategory":"","preceedingDocumentNumber":"","preceedingDocumentPosition":"","preceedingDocumentType":"","preceedingDocumentTypeDesc":"","productionDate":"2024-02-23T00:00:00UTC+00:00","qualityStatus":"","shipToPurchaseOrderNumber":"","ssccNumber":"390111007015831282","startProductionDate":"2024-02-23T00:00:00UTC+00:00","stockType":"","storageLocation":"","transportationGroup":"","uomCode":"PF","vendorBatch":"","volume":"","volumeUom":"","weightUom":"","wmsQualityStatus":"OK"}]}}]}}]}} 

FieldProperty  rni|emea|cz

import com.sap.gateway.ip.core.customdev.util.Message;
import groovy.json.JsonSlurper;

def Message processData(Message message) {
    // Retrieve properties and payload
    def map = message.getProperties();
    def payload = new JsonSlurper().parseText(message.getBody(String) as String);

    // Extract dynamic values from properties

    /*def fieldProperties = map.get("FieldProperty")?.split("\\|");
    def partnerid = fieldProperties?.getAt(0) ?: "na"; // 1st value before 1st pipe symbol
    def region = fieldProperties?.getAt(1) ?: "na";   // 2nd value after 1st pipe symbol
    def LEcountry = fieldProperties?.getAt(2) ?: "na"; // 3rd value after 2nd pipe symbol*/
   
      // Extract dynamic values from properties
    def system = map.get("FieldProperty").split("\\|")[2]; // 1st value before 1st pipe symbol
    def region = map.get("FieldProperty").split("\\|")[1]; // 2nd value after 1st pipe symbol
    def LEcountry = map.get("FieldProperty").split("\\|")[0]; // 3rd value after 2nd pipe symbol*/

    // Extract values from payload, using "na" as default if a field is missing
  def sourceType = payload?.sourcingDeliveries?.sourcingDelivery[0]?.sourceType ?: "na"
def destinationType = payload?.sourcingDeliveries?.sourcingDelivery[0]?.destinationType ?: "na"
def sourceCountry = payload?.sourcingDeliveries?.sourcingDelivery[0]?.source?.country ?: "na"
def destinationCountry = payload?.sourcingDeliveries?.sourcingDelivery[0]?.destination?.country ?: "na"
def source = payload?.sourcingDeliveries?.sourcingDelivery[0]?.source?.name1 ?: "na"
def destination = payload?.sourcingDeliveries?.sourcingDelivery[0]?.destination?.name1 ?: "na"
def freightOrderType = payload?.sourcingDeliveries?.sourcingDelivery[0]?.freightOrderType?.toLowerCase()?.replaceAll(" ", "") ?: "na"
   

    // Define static values for freightOrderType, organisation, and channel
  //  def freightOrderType = "undefined";
    def organisation = "undefined";
    def channel = "undefined";

    // Construct the TopicName
    def TopicName = "petc/cross/l2c/ord/sourcingdelivery/created/can/v1/trnl/1nav" +
        "${system}" +
        "/${region}" +
        "/${LEcountry}" +
        "/${sourceType}" +
        "/${destinationType}" +
        "/${sourceCountry}" +
        "/${destinationCountry}" +
        "/${source}" +
        "/${destination}" +
        "/${freightOrderType}" +
        "/${organisation}" +
        "/${channel}";

    // Set the constructed TopicName as a message property
    message.setProperty("TopicName", TopicName);

    return message;
}


Popular posts from this blog

pss book : శ్రీకృష్ణుడు దేవుడా, భగవంతుడా completed , second review needed. 26th April 2024

pss book: గురు ప్రార్థనామంజరి . completed 21st july 2024

pss book: కధల జ్ఞానము read review pending. 25th june 2024