Hi Alexandre,
yes, you have to commit before attach new wbs or networks.
I´ve already done something like this, using this order:
BAPI_PROJECTDEF_CREATE
COMMIT WORK AND WAIT
BAPI_PROJECT_MAINTAIN (creating many WBS elements, and using SaveAndWait)
BAPI_PROJECT_MAINTAIN (creating many Networks, and using SaveAndWait)
BAPI_PROJECT_MAINTAIN (creating many Networks Activities, and using SaveAndWait)
BAPI_PROJECT_MAINTAIN (creating many Activity Milestones, and using SaveAndWait)
This works perfectly fine for me in the same routine, but one after the other commit.
Regards,
Frisoni