Here's a root script attached.
It's working fine.
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
use Magento\Framework\App\Bootstrap;
require '../app/bootstrap.php';
$bootstrap = Bootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();
$state = $objectManager->get('Magento\Framework\App\State');
$state->setAreaCode('frontend');
$sourceItem = $objectManager->get(\Magento\InventoryApi\Api\Data\SourceItemInterfaceFactory::class);
$sourceItem = $sourceItem->create();
$sourceItem->setSku('PATCHE-HOODY-BLACK-MST- L');
$sourceItem->setQuantity(998);
$sourceItem->setSourceCode('default');
$sourceItem->setStatus(1);
$sourceItemSaver = $objectManager->get(\Magento\InventoryApi\Api\SourceItemsSaveInterface::class);
$sourceItemSaver->execute([$sourceItem]);
After operation, you can check results in inventory_source_item
table and product grid in admin side. It also helps to update saleable quantity also.
so by using this code, saleable quantity and quantity per source will be updated.
this can also be helpful.
https://stackoverflow.com/a/73657391/14146725