If I input A,B,C,D in layout A, I want to generate 4 records in table 2
What would be the purpose of duplicating the data like that?
Its for permutation entry.
If user enters ABC in layout A, I need to create the corresponding entries with permutation in table 2.
Well, you could certainly script the process, if you wanted. Whether that's a good way to proceed is another question. Suppose user edits the original entry: you would then need to delete all related records and create a new set, right? You didn't say how the related records will be used - perhaps deleting them would create orphans further down the line.
IOW, abstract questions do not yield the best answers. It's much better, IMHO, to describe the real situation.
How do I script it such that with the input in layout A (table 1), I can create multiple records in table 2?
I tried using new record, but it only creates a new record in table 1, and not table 2.
There is no need for consideration for orphan records, as once the records are permutated, its stays there for both table 1 and table 2. There is no delete for both the records in both table.
The New Record command (or script step) creates a new record in the current table - that is the table to which the current layout belongs. In order to create a new record in another table, you need to switch to another layout. Using your first example, the script could look something like:
Set Variable [ $parentID ; Parent::ParentID ]
Set Variable [ $values ; Parent::Input ]
Go to Layout [ Child ]
Set Variable [ $i ; $i + 1 ]
Exit Loop If [ $i > ValueCount ( $values) ]
Set Field [ Child::ParentID ; $parentID ]
Set Field [ Child::Value ; GetValue ( $values ; $i ) ]
Go to Layout [ Original layout ]
This is assuming user will enter a return-separated list of values into the Input field of the Parent table.