Flat File content:
ST*850*12500001|
BEG*00*NE*71249364**20130103|
CUR*SE*SGD|
REF*BT*SGL169816-7191416|
P01*0000000001*4*EA*0*CP*UP*731304265511*VP*SURT1000XLIQ|
P01*0000000002*10*EA*0*CP*UP*731304265511*VP*SURT1000XLIQ|
P01*0000000003*100*EA*0*CP*UP*731304265511*VP*SURT1000XLIQ|

Question:
Anybody who can share an idea on how to parse dynamically each element. The length of each data differs from time to time like for example : 12500001, 731304265511 and SURT1000XLIQ. The problem is how can i get the data between the asterisk (*) and pipeline (|). Thanks to help....
Your flat file looks like an EDI file, though not an EDIFACT.
There are some converters (either open source or commercial) from EDI to XML, maybe that you can try with such a tool to be able to read the resulting xml file into a DataWindow or a datastore?
As I do not know the actual file format, I cannot be more precise.
Example of EDI -> XML converters :
EDIT: I just landed on an ancient post on the PowerBuilder Developer Journal that addresses the same subject: "Converting X12 EDI to XML", it gives additional ideas.