Hello Archana
There is a table ESDUS which stores the values for last successful execution for transaction & user and default it in next execution for that user & transaction.
ME21N Node States with Above ESDUS table values:
Above values control the expand & collapse of nodes. (Toggle state)
Create a script for ESDUS table & insert these values & Then REF ESDUS script before PO creation in Me21n Script.
By doing this you are always referring to default one state in ME21N and your script will work in all releases & all systems.
Note: You can insert/change ESDUS table.
Regards
Nisha