I would like to create a new message of a particular type and append various segments programmatically. I have started with the following snippet. What I am currently finding difficult is to define a segment of a particular segment structure. I would like to append a pid segment of 2.3.1 to my message. I know I could you the importfromstring but I wanted to know whether there was a better way of achieving this.